lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1587100986-3104-2-git-send-email-macpaul.lin@mediatek.com>
Date:   Fri, 17 Apr 2020 13:23:06 +0800
From:   Macpaul Lin <macpaul.lin@...iatek.com>
To:     Min Guo <min.Guo@...iatek.com>,
        Chunfeng Yun <chunfeng.yun@...iatek.com>,
        Kishon Vijay Abraham I <kishon@...com>,
        Rob Herring <robh+dt@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>, <devicetree@...r.kernel.org>
CC:     Mediatek WSD Upstream <wsd_upstream@...iatek.com>,
        Macpaul Lin <macpaul.lin@...iatek.com>,
        Macpaul Lin <macpaul.lin@...il.com>
Subject: [PATCH 2/2] phy: phy-mtk-tphy: introduce force_vbus for u2 phy

For some platforms, they don't have vbus pin connection between usb phy and
mac. Hence we need to control force_vbus related registers to keep hardware
works normal.
This patch add corresponding behavior of force vbus in u2 phy related
functions.

Signed-off-by: Macpaul Lin <macpaul.lin@...iatek.com>
---
 drivers/phy/mediatek/phy-mtk-tphy.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
index cdbcc49f7115..46f0fea175e5 100644
--- a/drivers/phy/mediatek/phy-mtk-tphy.c
+++ b/drivers/phy/mediatek/phy-mtk-tphy.c
@@ -99,6 +99,7 @@
 
 #define U3P_U2PHYDTM1		0x06C
 #define P2C_RG_UART_EN			BIT(16)
+#define P2C_FORCE_VBUSVALID		BIT(13)
 #define P2C_FORCE_IDDIG		BIT(9)
 #define P2C_RG_VBUSVALID		BIT(5)
 #define P2C_RG_SESSEND			BIT(4)
@@ -318,6 +319,7 @@ struct mtk_tphy {
 	int nphys;
 	int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */
 	int src_coef; /* coefficient for slew rate calibrate */
+	bool force_vbus;
 };
 
 static void hs_slew_rate_calibrate(struct mtk_tphy *tphy,
@@ -611,13 +613,20 @@ static void u2_phy_instance_set_mode(struct mtk_tphy *tphy,
 	switch (mode) {
 	case PHY_MODE_USB_DEVICE:
 		tmp |= P2C_FORCE_IDDIG | P2C_RG_IDDIG;
+		if (tphy->force_vbus)
+			tmp |= P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID;
 		break;
 	case PHY_MODE_USB_HOST:
 		tmp |= P2C_FORCE_IDDIG;
-		tmp &= ~P2C_RG_IDDIG;
+		if (tphy->force_vbus)
+			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
+		else
+			tmp &= ~P2C_RG_IDDIG;
 		break;
 	case PHY_MODE_USB_OTG:
 		tmp &= ~(P2C_FORCE_IDDIG | P2C_RG_IDDIG);
+		if (tphy->force_vbus)
+			tmp &= ~(P2C_RG_VBUSVALID | P2C_FORCE_VBUSVALID);
 		break;
 	default:
 		return;
@@ -1187,6 +1196,11 @@ static int mtk_tphy_probe(struct platform_device *pdev)
 			retval = PTR_ERR(instance->da_ref_clk);
 			goto put_child;
 		}
+
+		/*
+		 * On some platform, vbus is dis-connected between PHY and MAC.
+		 */
+		tphy->force_vbus = device_property_read_bool(dev, "force_vbus");
 	}
 
 	provider = devm_of_phy_provider_register(dev, mtk_phy_xlate);
-- 
2.18.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ