aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2015-11-04 07:14:14 -0500
committerRalf Baechle <ralf@linux-mips.org>2015-11-11 02:38:21 -0500
commit26cfdbe30d81c209a5e81c4c311b02b10b5821c3 (patch)
tree687a4201c886cc4113b0475be151799f5a737e4d
parent1601078df26605da7a8107bdd3143ef6b9d07e3b (diff)
MIPS: lantiq: Initialize the USB core on boot
There is a DWC2 USB core in these SoCs. To make USB work we need to first reset and power the state machine. These are SoC specific registers and not part of the actual USB core. Signed-off-by: Antti Seppälä <a.seppala@gmail.com> Signed-off-by: John Crispin <blogic@openwrt.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/11449/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/lantiq/xway/reset.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/arch/mips/lantiq/xway/reset.c b/arch/mips/lantiq/xway/reset.c
index dd1aaaf8e3e6..4b52ce6d38f8 100644
--- a/arch/mips/lantiq/xway/reset.c
+++ b/arch/mips/lantiq/xway/reset.c
@@ -60,6 +60,37 @@
60#define RCU_BOOT_SEL(x) ((x >> 18) & 0x7) 60#define RCU_BOOT_SEL(x) ((x >> 18) & 0x7)
61#define RCU_BOOT_SEL_XRX200(x) (((x >> 17) & 0xf) | ((x >> 8) & 0x10)) 61#define RCU_BOOT_SEL_XRX200(x) (((x >> 17) & 0xf) | ((x >> 8) & 0x10))
62 62
63/* dwc2 USB configuration registers */
64#define RCU_USB1CFG 0x0018
65#define RCU_USB2CFG 0x0034
66
67/* USB DMA endianness bits */
68#define RCU_USBCFG_HDSEL_BIT BIT(11)
69#define RCU_USBCFG_HOST_END_BIT BIT(10)
70#define RCU_USBCFG_SLV_END_BIT BIT(9)
71
72/* USB reset bits */
73#define RCU_USBRESET 0x0010
74
75#define USBRESET_BIT BIT(4)
76
77#define RCU_USBRESET2 0x0048
78
79#define USB1RESET_BIT BIT(4)
80#define USB2RESET_BIT BIT(5)
81
82#define RCU_CFG1A 0x0038
83#define RCU_CFG1B 0x003C
84
85/* USB PMU devices */
86#define PMU_AHBM BIT(15)
87#define PMU_USB0 BIT(6)
88#define PMU_USB1 BIT(27)
89
90/* USB PHY PMU devices */
91#define PMU_USB0_P BIT(0)
92#define PMU_USB1_P BIT(26)
93
63/* remapped base addr of the reset control unit */ 94/* remapped base addr of the reset control unit */
64static void __iomem *ltq_rcu_membase; 95static void __iomem *ltq_rcu_membase;
65static struct device_node *ltq_rcu_np; 96static struct device_node *ltq_rcu_np;
@@ -272,6 +303,45 @@ static void ltq_machine_power_off(void)
272 unreachable(); 303 unreachable();
273} 304}
274 305
306static void ltq_usb_init(void)
307{
308 /* Power for USB cores 1 & 2 */
309 ltq_pmu_enable(PMU_AHBM);
310 ltq_pmu_enable(PMU_USB0);
311 ltq_pmu_enable(PMU_USB1);
312
313 ltq_rcu_w32(ltq_rcu_r32(RCU_CFG1A) | BIT(0), RCU_CFG1A);
314 ltq_rcu_w32(ltq_rcu_r32(RCU_CFG1B) | BIT(0), RCU_CFG1B);
315
316 /* Enable USB PHY power for cores 1 & 2 */
317 ltq_pmu_enable(PMU_USB0_P);
318 ltq_pmu_enable(PMU_USB1_P);
319
320 /* Configure cores to host mode */
321 ltq_rcu_w32(ltq_rcu_r32(RCU_USB1CFG) & ~RCU_USBCFG_HDSEL_BIT,
322 RCU_USB1CFG);
323 ltq_rcu_w32(ltq_rcu_r32(RCU_USB2CFG) & ~RCU_USBCFG_HDSEL_BIT,
324 RCU_USB2CFG);
325
326 /* Select DMA endianness (Host-endian: big-endian) */
327 ltq_rcu_w32((ltq_rcu_r32(RCU_USB1CFG) & ~RCU_USBCFG_SLV_END_BIT)
328 | RCU_USBCFG_HOST_END_BIT, RCU_USB1CFG);
329 ltq_rcu_w32(ltq_rcu_r32((RCU_USB2CFG) & ~RCU_USBCFG_SLV_END_BIT)
330 | RCU_USBCFG_HOST_END_BIT, RCU_USB2CFG);
331
332 /* Hard reset USB state machines */
333 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET) | USBRESET_BIT, RCU_USBRESET);
334 udelay(50 * 1000);
335 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET) & ~USBRESET_BIT, RCU_USBRESET);
336
337 /* Soft reset USB state machines */
338 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET2)
339 | USB1RESET_BIT | USB2RESET_BIT, RCU_USBRESET2);
340 udelay(50 * 1000);
341 ltq_rcu_w32(ltq_rcu_r32(RCU_USBRESET2)
342 & ~(USB1RESET_BIT | USB2RESET_BIT), RCU_USBRESET2);
343}
344
275static int __init mips_reboot_setup(void) 345static int __init mips_reboot_setup(void)
276{ 346{
277 struct resource res; 347 struct resource res;
@@ -295,6 +365,10 @@ static int __init mips_reboot_setup(void)
295 if (!ltq_rcu_membase) 365 if (!ltq_rcu_membase)
296 panic("Failed to remap core memory"); 366 panic("Failed to remap core memory");
297 367
368 if (of_machine_is_compatible("lantiq,ar9") ||
369 of_machine_is_compatible("lantiq,vr9"))
370 ltq_usb_init();
371
298 _machine_restart = ltq_machine_restart; 372 _machine_restart = ltq_machine_restart;
299 _machine_halt = ltq_machine_halt; 373 _machine_halt = ltq_machine_halt;
300 pm_power_off = ltq_machine_power_off; 374 pm_power_off = ltq_machine_power_off;