From patchwork Tue Jul 27 10:50:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 12402519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4B91C4338F for ; Tue, 27 Jul 2021 10:57:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F53561989 for ; Tue, 27 Jul 2021 10:57:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8F53561989 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wMQeFlGOUabs40tgxeQDbufeqAA4PEkHtZGggPJQWic=; b=Of/uKiXPdMhzHy 3jaK5OjTRDctprFas1AO1uMMvT033IYj1FKYQDcasaYG8XjFfxop4AH+KqhO4tnO785A7Zau9FIF7 OassITwWPd93CEWtiXbekcf/TadFMQaK3ecday+dENH9/VzZIPBy7aszoMalqAnVoIAW5a7WnI0je 81D+YlLWbl/T4LXXI1Z3ZpUeBoIFEeGCMbs3WRJua3+clqBOij7HXDRk0d9mQlpo/vcbFh+38+3E4 pnypVwLfgOgXA4VQhxC37vNl8/oNSwhOEjVbtOkarJdCBvS7FMYCf3kTsYn+lrXmN5vHj8ivJ9ES1 8+qM8mjtJxnCJW+T0WjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8KjJ-00EVN1-DI; Tue, 27 Jul 2021 10:54:33 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8Kj4-00EVKK-NS; Tue, 27 Jul 2021 10:54:20 +0000 X-UUID: 85fb98d2fc3e4d209ddeda57dfecc95b-20210727 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=iiJ9TlMy1Y3hIWltnCNZ1n1OG+Lm6SmtBMcv7Xs9hlE=; b=JaJJLVZul2qP11T0A0VL90GfKtAmYZT+kkn1jHOxVMWb8VgJk8BgvSAX7tSyffLsx95b1lK0kBj9qkYld19Lbxw1Q7C3FWfdi+ZHsJfkIbln8ak3w/SVZ1XpQcTBHAbrokutcqHTWdxiHAovJngnVOo+a0elVdoiM1g3TwSqdho=; X-UUID: 85fb98d2fc3e4d209ddeda57dfecc95b-20210727 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1250745340; Tue, 27 Jul 2021 03:54:10 -0700 Received: from MTKMBS06N2.mediatek.inc (172.21.101.130) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 03:50:45 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs06n2.mediatek.inc (172.21.101.130) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 18:50:44 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 27 Jul 2021 18:50:44 +0800 From: Macpaul Lin To: , Chunfeng Yun , Kishon Vijay Abraham I , Vinod Koul , Matthias Brugger CC: Ainge Hsu , Eddie Hung , Kuohong Wang , Mediatek WSD Upstream , Macpaul Lin , "Macpaul Lin" , , , , Subject: [PATCH 1/2] phy: introduce phy mode PHY_MODE_UART and phy_get_mode_ext() Date: Tue, 27 Jul 2021 18:50:12 +0800 Message-ID: <1627383013-4535-1-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210727_035418_817646_0FE031E5 X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some embedded platform shared PINs between USB and UART. For example, some phone will use special cable detection in boot loader to switch USB port function into UART mode. Hence Kernel need to query the hardware state from PHY registers to confirm the initialzation flow for PHY and USB driver. To support this kind of PIN switch, new PHY MODE and query API is required. Here we introduce a new PHY mode: PHY_MODE_UART. API phy_get_mode_ext() can be used to query the MODE from hardware instead of reading it from phy attributes. Signed-off-by: Macpaul Lin --- drivers/phy/phy-core.c | 17 +++++++++++++++++ include/linux/phy/phy.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index ccb575b..b8f6539 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c @@ -373,6 +373,23 @@ int phy_set_mode_ext(struct phy *phy, enum phy_mode mode, int submode) } EXPORT_SYMBOL_GPL(phy_set_mode_ext); +int phy_get_mode_ext(struct phy *phy) +{ + int ret; + + if (!phy || !phy->ops->get_mode_ext) + return 0; + + mutex_lock(&phy->mutex); + ret = phy->ops->get_mode_ext(phy); + if (!ret) + ret = phy->attrs.mode; + mutex_unlock(&phy->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(phy_get_mode_ext); + int phy_set_media(struct phy *phy, enum phy_media media) { int ret; diff --git a/include/linux/phy/phy.h b/include/linux/phy/phy.h index 0ed434d..7d32c6b 100644 --- a/include/linux/phy/phy.h +++ b/include/linux/phy/phy.h @@ -34,6 +34,7 @@ enum phy_mode { PHY_MODE_USB_DEVICE_HS, PHY_MODE_USB_DEVICE_SS, PHY_MODE_USB_OTG, + PHY_MODE_UART, PHY_MODE_UFS_HS_A, PHY_MODE_UFS_HS_B, PHY_MODE_PCIE, @@ -70,6 +71,7 @@ enum phy_media { * @power_on: powering on the phy * @power_off: powering off the phy * @set_mode: set the mode of the phy + * @get_mode_ext: get the extented mode of the phy * @set_media: set the media type of the phy (optional) * @set_speed: set the speed of the phy (optional) * @reset: resetting the phy @@ -83,6 +85,7 @@ struct phy_ops { int (*power_on)(struct phy *phy); int (*power_off)(struct phy *phy); int (*set_mode)(struct phy *phy, enum phy_mode mode, int submode); + int (*get_mode_ext)(struct phy *phy); int (*set_media)(struct phy *phy, enum phy_media media); int (*set_speed)(struct phy *phy, int speed); From patchwork Tue Jul 27 10:50:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Macpaul Lin X-Patchwork-Id: 12402517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C628BC4338F for ; Tue, 27 Jul 2021 10:56:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 99A1A6134F for ; Tue, 27 Jul 2021 10:56:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 99A1A6134F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1EA5YjCdz4J/J40jzRAUQySXr38kzSGZcGxr1tVwAkc=; b=G/3fWW5PcKBbt6 v9W4xmyYnvrx89EH2bBXqplTPtxnJqIyHzrrrvndVk/OXdeu2rDdp8NasCmMEFKXAWjTSo2ww6TiF tgcPoNUjXl7QUj8zKYc7yrxbEKJlhULHS/myhxjBA/MLmcgoPHv1fvC9QmoaO2yC/hZTRUBTAK7zS +wiqvJHVC0zrbspqEICpIS0KjqZFQEa4/w7PnaEKsEcs+22sonZDay3p4Crfb6ughpaqSeXkRCe3q TnW+7niJleu3PWwvP0urERNSeUXAPS2jpFDFG2e147C+X5dLVHQ+y5V5xPNc9xVmGBBnYfdwO62pJ kCbTwBkQLQZ0Em02/z2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8Kj8-00EVLh-1W; Tue, 27 Jul 2021 10:54:22 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8Kj2-00EVKL-Ty; Tue, 27 Jul 2021 10:54:18 +0000 X-UUID: 3adc6a49ce0b403c962488e67d20b38c-20210727 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=CYtQSGtSHETR7avRzJw9VhWzhJTZ2PEVERAinsmhPUA=; b=AahjWVAEwYpC7yRoR5p8u6ZhLSd01Vv1TqGR3jY+8qyMQzFMACq9Sl5TDmaXKDJGGEizYEgNPsQ0ngSHMLKQEETm7xXjR2UxAsztNR827fcexDX/brXUr+uPapdnbdIfxqou832blVZuJ6I2ohHo9tAOMgJF1boSnf1Fwue0qRg=; X-UUID: 3adc6a49ce0b403c962488e67d20b38c-20210727 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1808219637; Tue, 27 Jul 2021 03:54:10 -0700 Received: from MTKMBS01N2.mediatek.inc (172.21.101.79) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 03:50:58 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n2.mediatek.inc (172.21.101.79) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 27 Jul 2021 18:50:44 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 27 Jul 2021 18:50:45 +0800 From: Macpaul Lin To: , Chunfeng Yun , Kishon Vijay Abraham I , Vinod Koul , Matthias Brugger CC: Ainge Hsu , Eddie Hung , Kuohong Wang , Mediatek WSD Upstream , Macpaul Lin , "Macpaul Lin" , , , , Subject: [PATCH 2/2] phy: mediatek: phy-mtk-tphy: support USB2UART switch Date: Tue, 27 Jul 2021 18:50:13 +0800 Message-ID: <1627383013-4535-2-git-send-email-macpaul.lin@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1627383013-4535-1-git-send-email-macpaul.lin@mediatek.com> References: <1627383013-4535-1-git-send-email-macpaul.lin@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210727_035417_020949_843394CE X-CRM114-Status: GOOD ( 15.32 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some embedded platform shared PINs between USB and UART. For example, some phone will use special cable detection in boot loader to switch USB port function into UART mode. This patch support USB2UART switch function in phy-mtk-tphy. 1. Implement USB2UART switch API support in phy-mtk-tphy. 2. Use PHY_MODE_UART support according to new mode in phy.h. 3. Use mtk_phy_get_mode_ext() to query the current MODE from hardware. Signed-off-by: Macpaul Lin --- drivers/phy/mediatek/phy-mtk-tphy.c | 114 +++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c index cdbcc49..a7dfeec 100644 --- a/drivers/phy/mediatek/phy-mtk-tphy.c +++ b/drivers/phy/mediatek/phy-mtk-tphy.c @@ -68,6 +68,7 @@ #define PA6_RG_U2_SQTH_VAL(x) (0xf & (x)) #define U3P_U2PHYACR4 0x020 +#define P2C_RG_USB20_DM_100K_EN BIT(17) #define P2C_RG_USB20_GPIO_CTL BIT(9) #define P2C_USB20_GPIO_MODE BIT(8) #define P2C_U2_GPIO_CTR_MSK (P2C_RG_USB20_GPIO_CTL | P2C_USB20_GPIO_MODE) @@ -76,6 +77,12 @@ #define P2C_RG_SIF_U2PLL_FORCE_ON BIT(24) #define U3P_U2PHYDTM0 0x068 +#define P2C_RG_UART_MODE GENMASK(31, 30) +#define P2C_RG_UART_MODE_VAL(x) ((0x3 & (x)) << 30) +#define P2C_RG_UART_MODE_OFET (30) +#define P2C_FORCE_UART_I BIT(29) +#define P2C_FORCE_UART_BIAS_EN BIT(28) +#define P2C_FORCE_UART_TX_OE BIT(27) #define P2C_FORCE_UART_EN BIT(26) #define P2C_FORCE_DATAIN BIT(23) #define P2C_FORCE_DM_PULLDOWN BIT(21) @@ -98,6 +105,8 @@ P2C_RG_DPPULLDOWN | P2C_RG_TERMSEL) #define U3P_U2PHYDTM1 0x06C +#define P2C_RG_UART_BIAS_EN BIT(18) +#define P2C_RG_UART_TX_OE BIT(17) #define P2C_RG_UART_EN BIT(16) #define P2C_FORCE_IDDIG BIT(9) #define P2C_RG_VBUSVALID BIT(5) @@ -600,6 +609,90 @@ static void u2_phy_instance_exit(struct mtk_tphy *tphy, } } +static void u2_phy_instance_set_mode_2uart(struct u2phy_banks *u2_banks) +{ + u32 tmp; + + /* Clear PA6_RG_U2_BC11_SW_EN */ + tmp = readl(u2_banks->com + U3P_USBPHYACR6); + tmp &= ~(PA6_RG_U2_BC11_SW_EN); + writel(tmp, u2_banks->com + U3P_USBPHYACR6); + + /* Set P2C_RG_SUSPENDM */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_RG_SUSPENDM; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_FORCE_SUSPENDM */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_FORCE_SUSPENDM; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Clear and Set P2C_RG_UART_MODE to 2'b01 */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp &= ~(P2C_RG_UART_MODE); + tmp |= P2C_RG_UART_MODE_VAL(0x1); + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Clear P2C_FORCE_UART_I */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp &= ~(P2C_FORCE_UART_I); + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_FORCE_UART_BIAS_EN */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_FORCE_UART_BIAS_EN; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_FORCE_UART_TX_OE */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_FORCE_UART_TX_OE; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_FORCE_UART_EN */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_FORCE_UART_EN; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_RG_UART_BIAS_EN */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_RG_UART_BIAS_EN; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_RG_UART_TX_OE */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_RG_UART_TX_OE; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_RG_UART_EN */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp |= P2C_RG_UART_EN; + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); + + /* Set P2C_RG_USB20_DM_100K_EN */ + tmp = readl(u2_banks->com + U3P_U2PHYACR4); + tmp |= P2C_RG_USB20_DM_100K_EN; + writel(tmp, u2_banks->com + U3P_U2PHYACR4); + + /* Clear P2C_RG_DMPULLDOWN, P2C_RG_DPPULLDOWN */ + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + tmp &= ~(P2C_RG_DPPULLDOWN | P2C_RG_DMPULLDOWN); + writel(tmp, u2_banks->com + U3P_U2PHYDTM0); +} + +static int u2_phy_instance_get_mode_ext(struct mtk_tphy *tphy, struct mtk_phy_instance *instance) +{ + struct u2phy_banks *u2_banks = &instance->u2_banks; + u32 tmp; + + tmp = readl(u2_banks->com + U3P_U2PHYDTM0); + + if ((tmp & P2C_RG_UART_MODE) >> P2C_RG_UART_MODE_OFET) + return PHY_MODE_UART; + else + return PHY_MODE_USB_OTG; +} + static void u2_phy_instance_set_mode(struct mtk_tphy *tphy, struct mtk_phy_instance *instance, enum phy_mode mode) @@ -609,6 +702,9 @@ static void u2_phy_instance_set_mode(struct mtk_tphy *tphy, tmp = readl(u2_banks->com + U3P_U2PHYDTM1); switch (mode) { + case PHY_MODE_UART: + u2_phy_instance_set_mode_2uart(u2_banks); + return; case PHY_MODE_USB_DEVICE: tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG; break; @@ -933,6 +1029,10 @@ static int mtk_phy_init(struct phy *phy) return ret; } + ret = u2_phy_instance_get_mode_ext(tphy, instance); + if (ret == PHY_MODE_UART) + return 0; + switch (instance->type) { case PHY_TYPE_USB2: u2_phy_instance_init(tphy, instance); @@ -996,6 +1096,19 @@ static int mtk_phy_exit(struct phy *phy) return 0; } +static int mtk_phy_get_mode_ext(struct phy *phy) +{ + struct mtk_phy_instance *instance = phy_get_drvdata(phy); + struct mtk_tphy *tphy = dev_get_drvdata(phy->dev.parent); + int ret; + + ret = 0; + if (instance->type == PHY_TYPE_USB2) + ret = u2_phy_instance_get_mode_ext(tphy, instance); + + return ret; +} + static int mtk_phy_set_mode(struct phy *phy, enum phy_mode mode, int submode) { struct mtk_phy_instance *instance = phy_get_drvdata(phy); @@ -1060,6 +1173,7 @@ static struct phy *mtk_phy_xlate(struct device *dev, .power_on = mtk_phy_power_on, .power_off = mtk_phy_power_off, .set_mode = mtk_phy_set_mode, + .get_mode_ext = mtk_phy_get_mode_ext, .owner = THIS_MODULE, };