kernel: bump 4.14 to 4.14.44
[openwrt/openwrt.git] / target / linux / mediatek / patches-4.14 / 0129-usb-xhci-mtk-support-option-to-disable-usb3-ports.patch
1 From 13a1b2e927893cbb046a1ec5a55ec3516873a3f6 Mon Sep 17 00:00:00 2001
2 From: Chunfeng Yun <chunfeng.yun@mediatek.com>
3 Date: Fri, 13 Oct 2017 16:26:36 +0800
4 Subject: [PATCH 129/224] usb: xhci-mtk: support option to disable usb3 ports
5
6 Add support to disable specific usb3 ports, it's useful when
7 usb3 phy is shared with PCIe or SATA, because we should disable
8 the corresponding usb3 port if the phy is used by PCIe or SATA.
9 Sometimes it's helpful to analyse and solve problems.
10
11 Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
12 Acked-by: Mathias Nyman <mathias.nyman@linux.intel.com>
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 ---
15 drivers/usb/host/xhci-mtk.c | 18 +++++++++++++++---
16 drivers/usb/host/xhci-mtk.h | 1 +
17 2 files changed, 16 insertions(+), 3 deletions(-)
18
19 --- a/drivers/usb/host/xhci-mtk.c
20 +++ b/drivers/usb/host/xhci-mtk.c
21 @@ -92,6 +92,7 @@ static int xhci_mtk_host_enable(struct x
22 {
23 struct mu3c_ippc_regs __iomem *ippc = mtk->ippc_regs;
24 u32 value, check_val;
25 + int u3_ports_disabed = 0;
26 int ret;
27 int i;
28
29 @@ -103,8 +104,13 @@ static int xhci_mtk_host_enable(struct x
30 value &= ~CTRL1_IP_HOST_PDN;
31 writel(value, &ippc->ip_pw_ctr1);
32
33 - /* power on and enable all u3 ports */
34 + /* power on and enable u3 ports except skipped ones */
35 for (i = 0; i < mtk->num_u3_ports; i++) {
36 + if ((0x1 << i) & mtk->u3p_dis_msk) {
37 + u3_ports_disabed++;
38 + continue;
39 + }
40 +
41 value = readl(&ippc->u3_ctrl_p[i]);
42 value &= ~(CTRL_U3_PORT_PDN | CTRL_U3_PORT_DIS);
43 value |= CTRL_U3_PORT_HOST_SEL;
44 @@ -126,7 +132,7 @@ static int xhci_mtk_host_enable(struct x
45 check_val = STS1_SYSPLL_STABLE | STS1_REF_RST |
46 STS1_SYS125_RST | STS1_XHCI_RST;
47
48 - if (mtk->num_u3_ports)
49 + if (mtk->num_u3_ports > u3_ports_disabed)
50 check_val |= STS1_U3_MAC_RST;
51
52 ret = readl_poll_timeout(&ippc->ip_pw_sts1, value,
53 @@ -149,8 +155,11 @@ static int xhci_mtk_host_disable(struct
54 if (!mtk->has_ippc)
55 return 0;
56
57 - /* power down all u3 ports */
58 + /* power down u3 ports except skipped ones */
59 for (i = 0; i < mtk->num_u3_ports; i++) {
60 + if ((0x1 << i) & mtk->u3p_dis_msk)
61 + continue;
62 +
63 value = readl(&ippc->u3_ctrl_p[i]);
64 value |= CTRL_U3_PORT_PDN;
65 writel(value, &ippc->u3_ctrl_p[i]);
66 @@ -573,6 +582,9 @@ static int xhci_mtk_probe(struct platfor
67 }
68
69 mtk->lpm_support = of_property_read_bool(node, "usb3-lpm-capable");
70 + /* optional property, ignore the error if it does not exist */
71 + of_property_read_u32(node, "mediatek,u3p-dis-msk",
72 + &mtk->u3p_dis_msk);
73
74 ret = usb_wakeup_of_property_parse(mtk, node);
75 if (ret)
76 --- a/drivers/usb/host/xhci-mtk.h
77 +++ b/drivers/usb/host/xhci-mtk.h
78 @@ -121,6 +121,7 @@ struct xhci_hcd_mtk {
79 bool has_ippc;
80 int num_u2_ports;
81 int num_u3_ports;
82 + int u3p_dis_msk;
83 struct regulator *vusb33;
84 struct regulator *vbus;
85 struct clk *sys_clk; /* sys and mac clock */