mediatek: backport upstream mediatek patches
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0177-phy-phy-mtk-tphy-use-auto-instead-of-force-to-bypass.patch
1 From dacdae142ffd909ed6718adb05af74ff800da668 Mon Sep 17 00:00:00 2001
2 From: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 Date: Thu, 7 Dec 2017 19:53:34 +0800
4 Subject: [PATCH 177/224] phy: phy-mtk-tphy: use auto instead of force to
5 bypass utmi signals
6
7 When system is running, if usb2 phy is forced to bypass utmi signals,
8 all PLL will be turned off, and it can't detect device connection
9 anymore, so replace force mode with auto mode which can bypass utmi
10 signals automatically if no device attached for normal flow.
11 But keep the force mode to fix RX sensitivity degradation issue.
12
13 Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
14 Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
15 ---
16 drivers/phy/mediatek/phy-mtk-tphy.c | 19 +++++++------------
17 1 file changed, 7 insertions(+), 12 deletions(-)
18
19 diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c
20 index 402385f2562a..54cc44b2d289 100644
21 --- a/drivers/phy/mediatek/phy-mtk-tphy.c
22 +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
23 @@ -440,9 +440,9 @@ static void u2_phy_instance_init(struct mtk_tphy *tphy,
24 u32 index = instance->index;
25 u32 tmp;
26
27 - /* switch to USB function. (system register, force ip into usb mode) */
28 + /* switch to USB function, and enable usb pll */
29 tmp = readl(com + U3P_U2PHYDTM0);
30 - tmp &= ~P2C_FORCE_UART_EN;
31 + tmp &= ~(P2C_FORCE_UART_EN | P2C_FORCE_SUSPENDM);
32 tmp |= P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0);
33 writel(tmp, com + U3P_U2PHYDTM0);
34
35 @@ -502,10 +502,8 @@ static void u2_phy_instance_power_on(struct mtk_tphy *tphy,
36 u32 index = instance->index;
37 u32 tmp;
38
39 - /* (force_suspendm=0) (let suspendm=1, enable usb 480MHz pll) */
40 tmp = readl(com + U3P_U2PHYDTM0);
41 - tmp &= ~(P2C_FORCE_SUSPENDM | P2C_RG_XCVRSEL);
42 - tmp &= ~(P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
43 + tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
44 writel(tmp, com + U3P_U2PHYDTM0);
45
46 /* OTG Enable */
47 @@ -540,7 +538,6 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
48
49 tmp = readl(com + U3P_U2PHYDTM0);
50 tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN);
51 - tmp |= P2C_FORCE_SUSPENDM;
52 writel(tmp, com + U3P_U2PHYDTM0);
53
54 /* OTG Disable */
55 @@ -548,18 +545,16 @@ static void u2_phy_instance_power_off(struct mtk_tphy *tphy,
56 tmp &= ~PA6_RG_U2_OTG_VBUSCMP_EN;
57 writel(tmp, com + U3P_USBPHYACR6);
58
59 - /* let suspendm=0, set utmi into analog power down */
60 - tmp = readl(com + U3P_U2PHYDTM0);
61 - tmp &= ~P2C_RG_SUSPENDM;
62 - writel(tmp, com + U3P_U2PHYDTM0);
63 - udelay(1);
64 -
65 tmp = readl(com + U3P_U2PHYDTM1);
66 tmp &= ~(P2C_RG_VBUSVALID | P2C_RG_AVALID);
67 tmp |= P2C_RG_SESSEND;
68 writel(tmp, com + U3P_U2PHYDTM1);
69
70 if (tphy->pdata->avoid_rx_sen_degradation && index) {
71 + tmp = readl(com + U3P_U2PHYDTM0);
72 + tmp &= ~(P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM);
73 + writel(tmp, com + U3P_U2PHYDTM0);
74 +
75 tmp = readl(com + U3D_U2PHYDCR0);
76 tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON;
77 writel(tmp, com + U3D_U2PHYDCR0);
78 --
79 2.11.0
80