Changeset 29734


Ignore:
Timestamp:
2012-01-13T21:11:23+01:00 (6 years ago)
Author:
hauke
Message:

brcm47xx: update usb driver

Add workarround for BCM5357 and BCM4749.

This patch contains the following fixes from George Kashperko:

  • separate subroutines for controller initialization workarounds -

following CodingStyle recommendations;

  • devinit devexit devinitconst annotations for CONFIG_HOTPLUG;
  • fix leak in ssb_hcd_create_pdev/bcma_hcd_create_pdev - as hci_res being

kmalloc'ed is never freed anywhere while platform_device_add_resources
will kmemdup resources right away;

  • fix compilation error in ssb_hcd_resume - it will fail as soon as

CONFIG_PM is selected.

Location:
trunk/target/linux/brcm47xx/patches-3.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/brcm47xx/patches-3.0/0032-USB-Add-driver-for-the-bcma-bus.patch

    r29605 r29734  
    1 From 7151c34627b938486008cfab25bfb4e4f730a021 Mon Sep 17 00:00:00 2001 
     1From 4ea647c5a257d57eaf230f783e54b2c0232852b8 Mon Sep 17 00:00:00 2001 
    22From: Hauke Mehrtens <hauke@hauke-m.de> 
    33Date: Sat, 26 Nov 2011 21:33:41 +0100 
    4 Subject: [PATCH 19/21] USB: Add driver for the bcma bus 
     4Subject: [PATCH 19/26] USB: Add driver for the bcma bus 
    55 
    66This adds a USB driver using the generic platform device driver for the 
     
    1616 drivers/usb/host/Kconfig    |   12 ++ 
    1717 drivers/usb/host/Makefile   |    1 + 
    18  drivers/usb/host/bcma-hcd.c |  350 +++++++++++++++++++++++++++++++++++++++++++ 
    19  3 files changed, 363 insertions(+), 0 deletions(-) 
     18 drivers/usb/host/bcma-hcd.c |  309 +++++++++++++++++++++++++++++++++++++++++++ 
     19 3 files changed, 322 insertions(+), 0 deletions(-) 
    2020 create mode 100644 drivers/usb/host/bcma-hcd.c 
    2121 
     
    4747--- /dev/null 
    4848+++ b/drivers/usb/host/bcma-hcd.c 
    49 @@ -0,0 +1,299 @@ 
     49@@ -0,0 +1,309 @@ 
    5050+/* 
    5151+ * Broadcom specific Advanced Microcontroller Bus 
     
    7777+MODULE_LICENSE("GPL"); 
    7878+ 
    79 +#define BCMA_CORE_SIZE         0x1000 
    80 + 
    8179+struct bcma_hcd_device { 
    8280+       struct platform_device *ehci_dev; 
     
    8482+}; 
    8583+ 
     84+static void __devinit bcma_hcd_4716wa(struct bcma_device *dev) 
     85+{ 
     86+#ifdef CONFIG_BCMA_DRIVER_MIPS 
     87+       /* Work around for 4716 failures. */ 
     88+       if (dev->bus->chipinfo.id == 0x4716) { 
     89+               u32 tmp; 
     90+ 
     91+               tmp = bcma_cpu_clock(&dev->bus->drv_mips); 
     92+               if (tmp >= 480000000) 
     93+                       tmp = 0x1846b; /* set CDR to 0x11(fast) */ 
     94+               else if (tmp == 453000000) 
     95+                       tmp = 0x1046b; /* set CDR to 0x10(slow) */ 
     96+               else 
     97+                       tmp = 0; 
     98+ 
     99+               /* Change Shim mdio control reg to fix host not acking at 
     100+                * high frequencies 
     101+                */ 
     102+               if (tmp) { 
     103+                       bcma_write32(dev, 0x524, 0x1); /* write sel to enable */ 
     104+                       udelay(500); 
     105+ 
     106+                       bcma_write32(dev, 0x524, tmp); 
     107+                       udelay(500); 
     108+                       bcma_write32(dev, 0x524, 0x4ab); 
     109+                       udelay(500); 
     110+                       bcma_read32(dev, 0x528); 
     111+                       bcma_write32(dev, 0x528, 0x80000000); 
     112+               } 
     113+       } 
     114+#endif /* CONFIG_BCMA_DRIVER_MIPS */ 
     115+} 
     116+ 
    86117+/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ 
    87 +static void bcma_hcd_init_chip(struct bcma_device *dev) 
     118+static void __devinit bcma_hcd_init_chip(struct bcma_device *dev) 
    88119+{ 
    89120+       u32 tmp; 
     
    151182+                       udelay(1); 
    152183+               } 
    153 +       } 
    154 +#ifdef CONFIG_BCMA_DRIVER_MIPS 
    155 +       /* Work around for 4716 failures. */ 
    156 +       if (dev->bus->chipinfo.id == 0x4716) { 
    157 +               u32 clk_freq; 
    158 + 
    159 +               clk_freq = bcma_cpu_clock(&dev->bus->drv_mips); 
    160 +               if (clk_freq >= 480000000) 
    161 +                       tmp = 0x1846b; /* set CDR to 0x11(fast) */ 
    162 +               else if (clk_freq == 453000000) 
    163 +                       tmp = 0x1046b; /* set CDR to 0x10(slow) */ 
    164 +               else 
    165 +                       tmp = 0; 
    166 + 
    167 +               /* Change Shim mdio control reg to fix host not acking at 
    168 +                * high frequencies 
    169 +                */ 
    170 +               if (tmp) { 
    171 +                       bcma_write32(dev, 0x524, 0x1); /* write sel to enable */ 
    172 +                       udelay(500); 
    173 + 
    174 +                       bcma_write32(dev, 0x524, tmp); 
    175 +                       udelay(500); 
    176 +                       bcma_write32(dev, 0x524, 0x4ab); 
    177 +                       udelay(500); 
    178 +                       tmp = bcma_read32(dev, 0x528); 
    179 +                       bcma_write32(dev, 0x528, 0x80000000); 
    180 +               } 
    181 +       } 
    182 +#endif /* CONFIG_BCMA_DRIVER_MIPS */ 
    183 +} 
    184 + 
    185 +static struct platform_device *bcma_hcd_create_pdev(struct bcma_device *dev, 
    186 +                                                   char *name, u32 addr) 
     184+ 
     185+               bcma_hcd_4716wa(dev); 
     186+       } 
     187+} 
     188+ 
     189+static struct platform_device * __devinit 
     190+bcma_hcd_create_pdev(struct bcma_device *dev, char *name, u32 addr) 
    187191+{ 
    188192+       struct platform_device *hci_dev; 
    189 +       struct resource *hci_res; 
     193+       struct resource hci_res[2]; 
    190194+       int ret = -ENOMEM; 
    191195+ 
    192 +       hci_res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); 
    193 +       if (!hci_res) 
    194 +               return ERR_PTR(-ENOMEM); 
     196+       memset(hci_res, 0, sizeof(hci_res)); 
    195197+ 
    196198+       hci_res[0].start = addr; 
    197 +       hci_res[0].end = hci_res[0].start + BCMA_CORE_SIZE - 1; 
     199+       hci_res[0].end = hci_res[0].start + 0x1000 - 1; 
    198200+       hci_res[0].flags = IORESOURCE_MEM; 
    199201+ 
     
    208210+       hci_dev->dev.dma_mask = &hci_dev->dev.coherent_dma_mask; 
    209211+ 
    210 +       ret = platform_device_add_resources(hci_dev, hci_res, 2); 
     212+       ret = platform_device_add_resources(hci_dev, hci_res, 
     213+                                           ARRAY_SIZE(hci_res)); 
    211214+       if (ret) 
    212215+               goto err_alloc; 
     
    215218+       if (ret) { 
    216219+err_alloc: 
    217 +               kfree(hci_res); 
    218220+               platform_device_put(hci_dev); 
    219221+               return ERR_PTR(ret); 
     
    223225+} 
    224226+ 
    225 +static int bcma_hcd_probe(struct bcma_device *dev) 
     227+static int __devinit bcma_hcd_probe(struct bcma_device *dev) 
    226228+{ 
    227229+       int err; 
    228230+       u16 chipid_top; 
     231+       u32 ohci_addr; 
    229232+       struct bcma_hcd_device *usb_dev; 
    230 + 
     233+       struct bcma_chipinfo *chipinfo; 
     234+ 
     235+       chipinfo = &dev->bus->chipinfo; 
    231236+       /* USBcores are only connected on embedded devices. */ 
    232 +       chipid_top = (dev->bus->chipinfo.id & 0xFF00); 
     237+       chipid_top = (chipinfo->id & 0xFF00); 
    233238+       if (chipid_top != 0x4700 && chipid_top != 0x5300) 
    234239+               return -ENODEV; 
     
    246251+       bcma_hcd_init_chip(dev); 
    247252+ 
     253+       /* In AI chips EHCI is addrspace 0, OHCI is 1 */ 
     254+       ohci_addr = dev->addr1; 
     255+       if ((chipinfo->id == 0x5357 || chipinfo->id == 0x4749) 
     256+           && chipinfo->rev == 0) 
     257+               ohci_addr = 0x18009000; 
     258+ 
    248259+       usb_dev->ohci_dev = bcma_hcd_create_pdev(dev, "ohci-platform", 
    249 +                                                dev->addr1); 
     260+                                                ohci_addr); 
    250261+       if (IS_ERR(usb_dev->ohci_dev)) { 
    251262+               err = PTR_ERR(usb_dev->ohci_dev); 
     
    258269+               err = PTR_ERR(usb_dev->ehci_dev); 
    259270+               goto err_unregister_ohci_dev; 
    260 + 
    261271+       } 
    262272+ 
     
    271281+} 
    272282+ 
    273 +static void bcma_hcd_remove(struct bcma_device *dev) 
     283+static void __devexit bcma_hcd_remove(struct bcma_device *dev) 
    274284+{ 
    275285+       struct bcma_hcd_device *usb_dev; 
     
    320330+#endif /* CONFIG_PM */ 
    321331+ 
    322 +static const struct bcma_device_id bcma_hcd_table[] = { 
     332+static const struct bcma_device_id bcma_hcd_table[] __devinitconst = { 
    323333+       BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_USB20_HOST, BCMA_ANY_REV, BCMA_ANY_CLASS), 
    324334+       BCMA_CORETABLE_END 
     
    330340+       .id_table       = bcma_hcd_table, 
    331341+       .probe          = bcma_hcd_probe, 
    332 +       .remove         = bcma_hcd_remove, 
     342+       .remove         = __devexit_p(bcma_hcd_remove), 
    333343+       .shutdown       = bcma_hcd_shutdown, 
    334344+       .suspend        = bcma_hcd_suspend, 
  • trunk/target/linux/brcm47xx/patches-3.0/0033-USB-Add-driver-for-the-ssb-bus.patch

    r29575 r29734  
    1 From b61e70ad9080a6dbd3731917ec21dbcbb9d382a2 Mon Sep 17 00:00:00 2001 
     1From 0f91c21de577d2d9f1fd164ca686d9a4ff0e2c8b Mon Sep 17 00:00:00 2001 
    22From: Hauke Mehrtens <hauke@hauke-m.de> 
    33Date: Sat, 26 Nov 2011 21:35:17 +0100 
    4 Subject: [PATCH 20/21] USB: Add driver for the ssb bus 
     4Subject: [PATCH 20/26] USB: Add driver for the ssb bus 
    55 
    66This adds a USB driver using the generic platform device driver for the 
     
    2020 drivers/usb/host/Kconfig   |   12 ++ 
    2121 drivers/usb/host/Makefile  |    1 + 
    22  drivers/usb/host/ssb-hcd.c |  320 ++++++++++++++++++++++++++++++++++++++++++++ 
    23  3 files changed, 333 insertions(+), 0 deletions(-) 
     22 drivers/usb/host/ssb-hcd.c |  272 ++++++++++++++++++++++++++++++++++++++++++++ 
     23 3 files changed, 285 insertions(+), 0 deletions(-) 
    2424 create mode 100644 drivers/usb/host/ssb-hcd.c 
    2525 
     
    5151--- /dev/null 
    5252+++ b/drivers/usb/host/ssb-hcd.c 
    53 @@ -0,0 +1,268 @@ 
     53@@ -0,0 +1,272 @@ 
    5454+/* 
    5555+ * Sonics Silicon Backplane 
     
    9090+}; 
    9191+ 
    92 +/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ 
    93 +static u32 ssb_hcd_init_chip(struct ssb_device *dev) 
    94 +{ 
    95 +       u32 tmp, flags = 0; 
    96 + 
    97 +       if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) { 
    98 +               /* Put the device into host-mode. */ 
    99 +               flags |= SSB_HCD_TMSLOW_HOSTMODE; 
    100 +               ssb_device_enable(dev, flags); 
    101 +       } else if (dev->id.coreid == SSB_DEV_USB20_HOST) { 
     92+static void __devinit ssb_hcd_5354wa(struct ssb_device *dev) 
     93+{ 
     94+#ifdef CONFIG_SSB_DRIVER_MIPS 
     95+       /* Work around for 5354 failures */ 
     96+       if (dev->id.revision == 2 && dev->bus->chip_id == 0x5354) { 
     97+               /* Change syn01 reg */ 
     98+               ssb_write32(dev, 0x894, 0x00fe00fe); 
     99+ 
     100+               /* Change syn03 reg */ 
     101+               ssb_write32(dev, 0x89c, ssb_read32(dev, 0x89c) | 0x1); 
     102+       } 
     103+#endif 
     104+} 
     105+ 
     106+static void __devinit ssb_hcd_usb20wa(struct ssb_device *dev) 
     107+{ 
     108+       if (dev->id.coreid == SSB_DEV_USB20_HOST) { 
    102109+               /* 
    103110+                * USB 2.0 special considerations: 
     
    107114+                * and various phy components out of reset. 
    108115+                */ 
    109 +               ssb_device_enable(dev, 0); 
    110116+               ssb_write32(dev, 0x200, 0x7ff); 
    111117+ 
    112118+               /* Change Flush control reg */ 
    113 +               tmp = ssb_read32(dev, 0x400); 
    114 +               tmp &= ~8; 
    115 +               ssb_write32(dev, 0x400, tmp); 
    116 +               tmp = ssb_read32(dev, 0x400); 
     119+               ssb_write32(dev, 0x400, ssb_read32(dev, 0x400) & ~8); 
     120+               ssb_read32(dev, 0x400); 
    117121+ 
    118122+               /* Change Shim control reg */ 
    119 +               tmp = ssb_read32(dev, 0x304); 
    120 +               tmp &= ~0x100; 
    121 +               ssb_write32(dev, 0x304, tmp); 
    122 +               tmp = ssb_read32(dev, 0x304); 
     123+               ssb_write32(dev, 0x304, ssb_read32(dev, 0x304) & ~0x100); 
     124+               ssb_read32(dev, 0x304); 
    123125+ 
    124126+               udelay(1); 
    125127+ 
    126 +               /* Work around for 5354 failures */ 
    127 +               if (dev->id.revision == 2 && dev->bus->chip_id == 0x5354) { 
    128 +                       /* Change syn01 reg */ 
    129 +                       tmp = 0x00fe00fe; 
    130 +                       ssb_write32(dev, 0x894, tmp); 
    131 + 
    132 +                       /* Change syn03 reg */ 
    133 +                       tmp = ssb_read32(dev, 0x89c); 
    134 +                       tmp |= 0x1; 
    135 +                       ssb_write32(dev, 0x89c, tmp); 
    136 +               } 
    137 +       } else 
    138 +               ssb_device_enable(dev, 0); 
     128+               ssb_hcd_5354wa(dev); 
     129+       } 
     130+} 
     131+ 
     132+/* based on arch/mips/brcm-boards/bcm947xx/pcibios.c */ 
     133+static u32 __devinit ssb_hcd_init_chip(struct ssb_device *dev) 
     134+{ 
     135+       u32 flags = 0; 
     136+ 
     137+       if (dev->id.coreid == SSB_DEV_USB11_HOSTDEV) 
     138+               /* Put the device into host-mode. */ 
     139+               flags |= SSB_HCD_TMSLOW_HOSTMODE; 
     140+ 
     141+       ssb_device_enable(dev, flags); 
     142+ 
     143+       ssb_hcd_usb20wa(dev); 
    139144+ 
    140145+       return flags; 
    141146+} 
    142147+ 
    143 +static struct platform_device *ssb_hcd_create_pdev(struct ssb_device *dev, 
    144 +                                                  char *name, u32 addr, 
    145 +                                                  u32 len) 
     148+static struct platform_device * __devinit 
     149+ssb_hcd_create_pdev(struct ssb_device *dev, char *name, u32 addr, u32 len) 
    146150+{ 
    147151+       struct platform_device *hci_dev; 
    148 +       struct resource *hci_res; 
     152+       struct resource hci_res[2]; 
    149153+       int ret = -ENOMEM; 
    150154+ 
    151 +       hci_res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); 
    152 +       if (!hci_res) 
    153 +               return ERR_PTR(-ENOMEM); 
     155+       memset(hci_res, 0, sizeof(hci_res)); 
    154156+ 
    155157+       hci_res[0].start = addr; 
     
    174176+       if (ret) { 
    175177+err_alloc: 
    176 +               kfree(hci_res); 
    177178+               platform_device_put(hci_dev); 
    178179+               return ERR_PTR(ret); 
     
    182183+} 
    183184+ 
    184 +static int ssb_hcd_probe(struct ssb_device *dev, const struct ssb_device_id *id) 
     185+static int __devinit ssb_hcd_probe(struct ssb_device *dev, 
     186+                                  const struct ssb_device_id *id) 
    185187+{ 
    186188+       int err, tmp; 
     
    242244+} 
    243245+ 
    244 +static void ssb_hcd_remove(struct ssb_device *dev) 
     246+static void __devexit ssb_hcd_remove(struct ssb_device *dev) 
    245247+{ 
    246248+       struct ssb_hcd_device *usb_dev; 
     
    265267+} 
    266268+ 
    267 +static void ssb_hcd_shutdown(struct ssb_device *dev) 
     269+static void __devexit ssb_hcd_shutdown(struct ssb_device *dev) 
    268270+{ 
    269271+       ssb_device_disable(dev, 0); 
     
    281283+static int ssb_hcd_resume(struct ssb_device *dev) 
    282284+{ 
     285+       struct ssb_hcd_device *usb_dev = ssb_get_drvdata(dev); 
     286+ 
    283287+       ssb_device_enable(dev, usb_dev->enable_flags); 
    284288+ 
     
    291295+#endif /* CONFIG_PM */ 
    292296+ 
    293 +static const struct ssb_device_id ssb_hcd_table[] = { 
     297+static const struct ssb_device_id ssb_hcd_table[] __devinitconst = { 
    294298+       SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOSTDEV, SSB_ANY_REV), 
    295299+       SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_USB11_HOST, SSB_ANY_REV), 
     
    303307+       .id_table       = ssb_hcd_table, 
    304308+       .probe          = ssb_hcd_probe, 
    305 +       .remove         = ssb_hcd_remove, 
     309+       .remove         = __devexit_p(ssb_hcd_remove), 
    306310+       .shutdown       = ssb_hcd_shutdown, 
    307311+       .suspend        = ssb_hcd_suspend, 
Note: See TracChangeset for help on using the changeset viewer.