mediatek: backport upstream mediatek patches
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0112-usb-mtu3-set-otg_sel-for-u2port-only-if-works-as-dua.patch
1 From 36f70702b66cd3453b65d46b5c26ea87d8897363 Mon Sep 17 00:00:00 2001
2 From: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 Date: Fri, 13 Oct 2017 17:10:46 +0800
4 Subject: [PATCH 112/224] usb: mtu3: set otg_sel for u2port only if works as
5 dual-role mode
6
7 When set otg_sel(SSUSB_U2_PORT_OTG_SEL) for u2port which supports
8 dual-role mode, the controller will automatically switch mode
9 between host and device according to IDDIG signal. But if the
10 u2port only supports device mode, and no IDDIG pin is provided,
11 setting otg_sel may cause failure of detection by host.
12 So set it only for dual-role mode.
13
14 Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
15 Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
16 ---
17 drivers/usb/mtu3/mtu3_core.c | 9 +++++++--
18 1 file changed, 7 insertions(+), 2 deletions(-)
19
20 diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c
21 index 67f7a309aba7..7c149a7da14e 100644
22 --- a/drivers/usb/mtu3/mtu3_core.c
23 +++ b/drivers/usb/mtu3/mtu3_core.c
24 @@ -115,7 +115,9 @@ static int mtu3_device_enable(struct mtu3 *mtu)
25 mtu3_clrbits(ibase, SSUSB_U2_CTRL(0),
26 (SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN |
27 SSUSB_U2_PORT_HOST_SEL));
28 - mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
29 +
30 + if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
31 + mtu3_setbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
32
33 return ssusb_check_clocks(mtu->ssusb, check_clk);
34 }
35 @@ -130,7 +132,10 @@ static void mtu3_device_disable(struct mtu3 *mtu)
36
37 mtu3_setbits(ibase, SSUSB_U2_CTRL(0),
38 SSUSB_U2_PORT_DIS | SSUSB_U2_PORT_PDN);
39 - mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
40 +
41 + if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
42 + mtu3_clrbits(ibase, SSUSB_U2_CTRL(0), SSUSB_U2_PORT_OTG_SEL);
43 +
44 mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
45 }
46
47 --
48 2.11.0
49