busybox: fix md5sum
[openwrt/staging/rmilecki.git] / target / linux / bcm53xx / patches-4.4 / 170-USB-bcma-support-old-USB-2.0-controller-on-Northstar.patch
1 From ef54f033c53bf4518f6e16e7ed815acd855e03c5 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Wed, 10 Aug 2016 11:51:16 +0200
4 Subject: [PATCH] USB: bcma: support old USB 2.0 controller on Northstar
5 devices
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 Currently bcma-hcd driver handles 3 different bcma cores:
11 1) BCMA_CORE_USB20_HOST (0x819)
12 2) BCMA_CORE_NS_USB20 (0x504)
13 3) BCMA_CORE_NS_USB30 (0x505)
14
15 The first one was introduced years ago and so far was used on MIPS
16 devices only. All Northstar (ARM) devices were using other two cores
17 which allowed easy implementation of separated initialization paths.
18
19 It seems however Broadcom decided to reuse this old USB 2.0 controller
20 on some recently introduced cheaper Northstar BCM53573 SoCs. I noticed
21 this on Tenda AC9 (based on BCM47189B0 belonging to BCM53573 family).
22
23 There is no difference in this old controller core identification
24 between MIPS and ARM devices: they share the same id and revision. We
25 need different controller initialization procedure however.
26 To handle this add a check for architecture and implement required
27 initialization for ARM case.
28
29 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
30 ---
31 drivers/usb/host/bcma-hcd.c | 86 ++++++++++++++++++++++++++++++++++++++++--
32 include/linux/bcma/bcma_regs.h | 1 +
33 2 files changed, 83 insertions(+), 4 deletions(-)
34
35 --- a/drivers/usb/host/bcma-hcd.c
36 +++ b/drivers/usb/host/bcma-hcd.c
37 @@ -35,6 +35,9 @@ MODULE_AUTHOR("Hauke Mehrtens");
38 MODULE_DESCRIPTION("Common USB driver for BCMA Bus");
39 MODULE_LICENSE("GPL");
40
41 +/* See BCMA_CLKCTLST_EXTRESREQ and BCMA_CLKCTLST_EXTRESST */
42 +#define USB_BCMA_CLKCTLST_USB_CLK_REQ 0x00000100
43 +
44 struct bcma_hcd_device {
45 struct bcma_device *core;
46 struct platform_device *ehci_dev;
47 @@ -166,6 +169,76 @@ static void bcma_hcd_init_chip_mips(stru
48 }
49 }
50
51 +/**
52 + * bcma_hcd_usb20_old_arm_init - Initialize old USB 2.0 controller on ARM
53 + *
54 + * Old USB 2.0 core is identified as BCMA_CORE_USB20_HOST and was introduced
55 + * long before Northstar devices. It seems some cheaper chipsets like BCM53573
56 + * still use it.
57 + * Initialization of this old core differs between MIPS and ARM.
58 + */
59 +static int bcma_hcd_usb20_old_arm_init(struct bcma_hcd_device *usb_dev)
60 +{
61 + struct bcma_device *core = usb_dev->core;
62 + struct device *dev = &core->dev;
63 + struct bcma_device *pmu_core;
64 +
65 + usleep_range(10000, 20000);
66 + if (core->id.rev < 5)
67 + return 0;
68 +
69 + pmu_core = bcma_find_core(core->bus, BCMA_CORE_PMU);
70 + if (!pmu_core) {
71 + dev_err(dev, "Could not find PMU core\n");
72 + return -ENOENT;
73 + }
74 +
75 + /* Take USB core out of reset */
76 + bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK | BCMA_IOCTL_FGC);
77 + usleep_range(100, 200);
78 + bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
79 + usleep_range(100, 200);
80 + bcma_awrite32(core, BCMA_RESET_CTL, 0);
81 + usleep_range(100, 200);
82 + bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK);
83 + usleep_range(100, 200);
84 +
85 + /* Enable Misc PLL */
86 + bcma_write32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT |
87 + BCMA_CLKCTLST_HQCLKREQ |
88 + USB_BCMA_CLKCTLST_USB_CLK_REQ);
89 + usleep_range(100, 200);
90 +
91 + bcma_write32(core, 0x510, 0xc7f85000);
92 + bcma_write32(core, 0x510, 0xc7f85003);
93 + usleep_range(300, 600);
94 +
95 + /* Program USB PHY PLL parameters */
96 + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x6);
97 + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x005360c1);
98 + usleep_range(100, 200);
99 + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x7);
100 + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x0);
101 + usleep_range(100, 200);
102 + bcma_set32(pmu_core, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
103 + usleep_range(100, 200);
104 +
105 + bcma_write32(core, 0x510, 0x7f8d007);
106 + udelay(1000);
107 +
108 + /* Take controller out of reset */
109 + bcma_write32(core, 0x200, 0x4ff);
110 + usleep_range(25, 50);
111 + bcma_write32(core, 0x200, 0x6ff);
112 + usleep_range(25, 50);
113 + bcma_write32(core, 0x200, 0x7ff);
114 + usleep_range(25, 50);
115 +
116 + of_platform_default_populate(dev->of_node, NULL, dev);
117 +
118 + return 0;
119 +}
120 +
121 static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
122 {
123 struct bcma_device *arm_core;
124 @@ -370,19 +443,24 @@ static int bcma_hcd_probe(struct bcma_de
125
126 switch (core->id.id) {
127 case BCMA_CORE_USB20_HOST:
128 + if (IS_ENABLED(CONFIG_ARM))
129 + err = bcma_hcd_usb20_old_arm_init(usb_dev);
130 + else if (IS_ENABLED(CONFIG_MIPS))
131 + err = bcma_hcd_usb20_init(usb_dev);
132 + else
133 + err = -ENOTSUPP;
134 + break;
135 case BCMA_CORE_NS_USB20:
136 err = bcma_hcd_usb20_init(usb_dev);
137 - if (err)
138 - return err;
139 break;
140 case BCMA_CORE_NS_USB30:
141 err = bcma_hcd_usb30_init(usb_dev);
142 - if (err)
143 - return err;
144 break;
145 default:
146 return -ENODEV;
147 }
148 + if (err)
149 + return err;
150
151 bcma_set_drvdata(core, usb_dev);
152 return 0;
153 --- a/include/linux/bcma/bcma_regs.h
154 +++ b/include/linux/bcma/bcma_regs.h
155 @@ -10,6 +10,7 @@
156 #define BCMA_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
157 #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
158 #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
159 +#define BCMA_CLKCTLST_HQCLKREQ 0x00000040 /* HQ Clock */
160 #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
161 #define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
162 #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */