082-05-USB-bcma-add-bcm53xx-support.patch 3.7 KB

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