bcm53xx: add profiling support
[openwrt/svn-archive/archive.git] / target / linux / bcm53xx / patches-3.18 / 190-bcma_hcd_add_bcm5301x_support.patch
1 Subject: [PATCH] bcma-hcd: add BCM5301x platform support
2
3 Signed-off-by: Felix Fietkau <nbd@openwrt.org>
4 ---
5 --- a/drivers/usb/host/bcma-hcd.c
6 +++ b/drivers/usb/host/bcma-hcd.c
7 @@ -88,7 +88,7 @@ static void bcma_hcd_4716wa(struct bcma_
8 }
9
10 /* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */
11 -static void bcma_hcd_init_chip(struct bcma_device *dev)
12 +static void bcma_hcd_init_chip_mips(struct bcma_device *dev)
13 {
14 u32 tmp;
15
16 @@ -159,6 +159,52 @@ static void bcma_hcd_init_chip(struct bc
17 }
18 }
19
20 +static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
21 +{
22 + struct bcma_device *arm_core;
23 + void __iomem *dmu;
24 + u32 val;
25 +
26 + bcma_core_disable(dev, 0);
27 + bcma_core_enable(dev, 0);
28 +
29 + msleep(1);
30 +
31 + /* Set packet buffer OUT threshold */
32 + val = bcma_read32(dev, 0x94);
33 + val &= 0xffff;
34 + val |= 0x80 << 16;
35 + bcma_write32(dev, 0x94, val);
36 +
37 + /* Enable break memory transfer */
38 + val = bcma_read32(dev, 0x9c);
39 + val |= 1;
40 + bcma_write32(dev, 0x9c, val);
41 +
42 + if (dev->bus->chipinfo.pkg != BCMA_PKG_ID_BCM4707 &&
43 + dev->bus->chipinfo.pkg != BCMA_PKG_ID_BCM4708)
44 + return;
45 +
46 + arm_core = bcma_find_core(dev->bus, BCMA_CORE_ARMCA9);
47 + if (!arm_core)
48 + return;
49 +
50 + dmu = ioremap_nocache(arm_core->addr_s[0], 0x1000);
51 + if (!dmu)
52 + return;
53 +
54 + /* Unlock DMU PLL settings */
55 + iowrite32(0x0000ea68, dmu + 0x180);
56 +
57 + /* Write USB 2.0 PLL control setting */
58 + iowrite32(0x00dd10c3, dmu + 0x164);
59 +
60 + /* Lock DMU PLL settings */
61 + iowrite32(0x00000000, dmu + 0x180);
62 +
63 + iounmap(dmu);
64 +}
65 +
66 static const struct usb_ehci_pdata ehci_pdata = {
67 };
68
69 @@ -222,7 +268,8 @@ static int bcma_hcd_probe(struct bcma_de
70 chipinfo = &dev->bus->chipinfo;
71 /* USBcores are only connected on embedded devices. */
72 chipid_top = (chipinfo->id & 0xFF00);
73 - if (chipid_top != 0x4700 && chipid_top != 0x5300)
74 + if (chipid_top != 0x4700 && chipid_top != 0x5300 &&
75 + chipinfo->id != BCMA_CHIP_ID_BCM4707)
76 return -ENODEV;
77
78 /* TODO: Probably need checks here; is the core connected? */
79 @@ -234,18 +281,23 @@ static int bcma_hcd_probe(struct bcma_de
80 if (!usb_dev)
81 return -ENOMEM;
82
83 - bcma_hcd_init_chip(dev);
84 -
85 - /* In AI chips EHCI is addrspace 0, OHCI is 1 */
86 - ohci_addr = dev->addr_s[0];
87 - if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
88 - && chipinfo->rev == 0)
89 - ohci_addr = 0x18009000;
90 -
91 - usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
92 - if (IS_ERR(usb_dev->ohci_dev)) {
93 - err = PTR_ERR(usb_dev->ohci_dev);
94 - goto err_free_usb_dev;
95 + if (IS_BUILTIN(CONFIG_ARCH_BCM_5301X) &&
96 + chipinfo->id == BCMA_CHIP_ID_BCM4707) {
97 + bcma_hcd_init_chip_arm(dev);
98 + } else if(IS_BUILTIN(CONFIG_BCM47XX)) {
99 + bcma_hcd_init_chip_mips(dev);
100 +
101 + /* In AI chips EHCI is addrspace 0, OHCI is 1 */
102 + ohci_addr = dev->addr_s[0];
103 + if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749)
104 + && chipinfo->rev == 0)
105 + ohci_addr = 0x18009000;
106 +
107 + usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, true, ohci_addr);
108 + if (IS_ERR(usb_dev->ohci_dev)) {
109 + err = PTR_ERR(usb_dev->ohci_dev);
110 + goto err_free_usb_dev;
111 + }
112 }
113
114 usb_dev->ehci_dev = bcma_hcd_create_pdev(dev, false, dev->addr);
115 @@ -306,6 +358,7 @@ static int bcma_hcd_resume(struct bcma_d
116
117 static const struct bcma_device_id bcma_hcd_table[] = {
118 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS),
119 + BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_NS_USB20, BCMA_ANY_REV, BCMA_ANY_CLASS),
120 BCMA_CORETABLE_END
121 };
122 MODULE_DEVICE_TABLE(bcma, bcma_hcd_table);