kernel: bump 4.14 to 4.14.44
[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 --- a/drivers/phy/mediatek/phy-mtk-tphy.c
20 +++ b/drivers/phy/mediatek/phy-mtk-tphy.c
21 @@ -440,9 +440,9 @@ static void u2_phy_instance_init(struct
22 u32 index = instance->index;
23 u32 tmp;
24
25 - /* switch to USB function. (system register, force ip into usb mode) */
26 + /* switch to USB function, and enable usb pll */
27 tmp = readl(com + U3P_U2PHYDTM0);
28 - tmp &= ~P2C_FORCE_UART_EN;
29 + tmp &= ~(P2C_FORCE_UART_EN | P2C_FORCE_SUSPENDM);
30 tmp |= P2C_RG_XCVRSEL_VAL(1) | P2C_RG_DATAIN_VAL(0);
31 writel(tmp, com + U3P_U2PHYDTM0);
32
33 @@ -502,10 +502,8 @@ static void u2_phy_instance_power_on(str
34 u32 index = instance->index;
35 u32 tmp;
36
37 - /* (force_suspendm=0) (let suspendm=1, enable usb 480MHz pll) */
38 tmp = readl(com + U3P_U2PHYDTM0);
39 - tmp &= ~(P2C_FORCE_SUSPENDM | P2C_RG_XCVRSEL);
40 - tmp &= ~(P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
41 + tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN | P2C_DTM0_PART_MASK);
42 writel(tmp, com + U3P_U2PHYDTM0);
43
44 /* OTG Enable */
45 @@ -540,7 +538,6 @@ static void u2_phy_instance_power_off(st
46
47 tmp = readl(com + U3P_U2PHYDTM0);
48 tmp &= ~(P2C_RG_XCVRSEL | P2C_RG_DATAIN);
49 - tmp |= P2C_FORCE_SUSPENDM;
50 writel(tmp, com + U3P_U2PHYDTM0);
51
52 /* OTG Disable */
53 @@ -548,18 +545,16 @@ static void u2_phy_instance_power_off(st
54 tmp &= ~PA6_RG_U2_OTG_VBUSCMP_EN;
55 writel(tmp, com + U3P_USBPHYACR6);
56
57 - /* let suspendm=0, set utmi into analog power down */
58 - tmp = readl(com + U3P_U2PHYDTM0);
59 - tmp &= ~P2C_RG_SUSPENDM;
60 - writel(tmp, com + U3P_U2PHYDTM0);
61 - udelay(1);
62 -
63 tmp = readl(com + U3P_U2PHYDTM1);
64 tmp &= ~(P2C_RG_VBUSVALID | P2C_RG_AVALID);
65 tmp |= P2C_RG_SESSEND;
66 writel(tmp, com + U3P_U2PHYDTM1);
67
68 if (tphy->pdata->avoid_rx_sen_degradation && index) {
69 + tmp = readl(com + U3P_U2PHYDTM0);
70 + tmp &= ~(P2C_RG_SUSPENDM | P2C_FORCE_SUSPENDM);
71 + writel(tmp, com + U3P_U2PHYDTM0);
72 +
73 tmp = readl(com + U3D_U2PHYDCR0);
74 tmp &= ~P2C_RG_SIF_U2PLL_FORCE_ON;
75 writel(tmp, com + U3D_U2PHYDCR0);