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