d7980fa4fa4a33ec9e25d518581e325388cd7450
[openwrt/staging/mkresin.git] / target / linux / bcm53xx / patches-3.18 / 184-USB-bcma-add-bcm53xx-support.patch
1 From b65851f41c22b8c69b8fe9ca7782d19ed2155efc Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Thu, 11 Jun 2015 22:57:39 +0200
4 Subject: [PATCH] USB: bcma: add bcm53xx support
5
6 The Broadcom ARM SoCs with this usb core need a different
7 initialization and they have a different core id. This patch adds
8 support for these USB 2.0 core.
9
10 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
11 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
12 ---
13 drivers/usb/host/bcma-hcd.c | 81 +++++++++++++++++++++++++++++++++++++++++++--
14 1 file changed, 78 insertions(+), 3 deletions(-)
15
16 diff --git a/drivers/usb/host/bcma-hcd.c b/drivers/usb/host/bcma-hcd.c
17 index 8a38313..983bc67 100644
18 --- a/drivers/usb/host/bcma-hcd.c
19 +++ b/drivers/usb/host/bcma-hcd.c
20 @@ -2,7 +2,8 @@
21 * Broadcom specific Advanced Microcontroller Bus
22 * Broadcom USB-core driver (BCMA bus glue)
23 *
24 - * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de>
25 + * Copyright 2011-2015 Hauke Mehrtens <hauke@hauke-m.de>
26 + * Copyright 2015 Felix Fietkau <nbd@openwrt.org>
27 *
28 * Based on ssb-ohci driver
29 * Copyright 2007 Michael Buesch <m@bues.ch>
30 @@ -88,7 +89,7 @@ static void bcma_hcd_4716wa(struct bcma_device *dev)
31 }
32
33 /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
34 -static void bcma_hcd_init_chip(struct bcma_device *dev)
35 +static void bcma_hcd_init_chip_mips(struct bcma_device *dev)
36 {
37 u32 tmp;
38
39 @@ -159,6 +160,70 @@ static void bcma_hcd_init_chip(struct bcma_device *dev)
40 }
41 }
42
43 +static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
44 +{
45 + struct bcma_device *arm_core;
46 + void __iomem *dmu;
47 +
48 + arm_core = bcma_find_core(dev->bus, BCMA_CORE_ARMCA9);
49 + if (!arm_core) {
50 + dev_err(&dev->dev, "can not find ARM Cortex A9 ihost core\n");
51 + return;
52 + }
53 +
54 + dmu = ioremap_nocache(arm_core->addr_s[0], 0x1000);
55 + if (!dmu) {
56 + dev_err(&dev->dev, "can not map ARM Cortex A9 ihost core\n");
57 + return;
58 + }
59 +
60 + /* Unlock DMU PLL settings */
61 + iowrite32(0x0000ea68, dmu + 0x180);
62 +
63 + /* Write USB 2.0 PLL control setting */
64 + iowrite32(0x00dd10c3, dmu + 0x164);
65 +
66 + /* Lock DMU PLL settings */
67 + iowrite32(0x00000000, dmu + 0x180);
68 +
69 + iounmap(dmu);
70 +}
71 +
72 +static void bcma_hcd_init_chip_arm_hc(struct bcma_device *dev)
73 +{
74 + u32 val;
75 +
76 + /*
77 + * Delay after PHY initialized to ensure HC is ready to be configured
78 + */
79 + usleep_range(1000, 2000);
80 +
81 + /* Set packet buffer OUT threshold */
82 + val = bcma_read32(dev, 0x94);
83 + val &= 0xffff;
84 + val |= 0x80 << 16;
85 + bcma_write32(dev, 0x94, val);
86 +
87 + /* Enable break memory transfer */
88 + val = bcma_read32(dev, 0x9c);
89 + val |= 1;
90 + bcma_write32(dev, 0x9c, val);
91 +}
92 +
93 +static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
94 +{
95 + bcma_core_enable(dev, 0);
96 +
97 + if (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4707 ||
98 + dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM53018) {
99 + if (dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4707 ||
100 + dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4708)
101 + bcma_hcd_init_chip_arm_phy(dev);
102 +
103 + bcma_hcd_init_chip_arm_hc(dev);
104 + }
105 +}
106 +
107 static const struct usb_ehci_pdata ehci_pdata = {
108 };
109
110 @@ -230,7 +295,16 @@ static int bcma_hcd_probe(struct bcma_device *dev)
111 if (!usb_dev)
112 return -ENOMEM;
113
114 - bcma_hcd_init_chip(dev);
115 + switch (dev->id.id) {
116 + case BCMA_CORE_NS_USB20:
117 + bcma_hcd_init_chip_arm(dev);
118 + break;
119 + case BCMA_CORE_USB20_HOST:
120 + bcma_hcd_init_chip_mips(dev);
121 + break;
122 + default:
123 + return -ENODEV;
124 + }
125
126 /* In AI chips EHCI is addrspace 0, OHCI is 1 */
127 ohci_addr = dev->addr_s[0];
128 @@ -299,6 +373,7 @@ static int bcma_hcd_resume(struct bcma_device *dev)
129
130 static const struct bcma_device_id bcma_hcd_table[] = {
131 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
132 + BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
133 BCMA_CORETABLE_END
134 };
135 MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);
136 --
137 1.8.4.5
138