082-0002-USB-bcma-support-old-USB-2.0-controller-on-Northstar.patch 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. From d6b76c4ddb124dd22c6e910ca9332e472e7b3273 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Wed, 10 Aug 2016 11:56:46 +0200
  4. Subject: [PATCH] USB: bcma: support old USB 2.0 controller on Northstar
  5. devices
  6. MIME-Version: 1.0
  7. Content-Type: text/plain; charset=UTF-8
  8. Content-Transfer-Encoding: 8bit
  9. Currently bcma-hcd driver handles 3 different bcma cores:
  10. 1) BCMA_CORE_USB20_HOST (0x819)
  11. 2) BCMA_CORE_NS_USB20 (0x504)
  12. 3) BCMA_CORE_NS_USB30 (0x505)
  13. The first one was introduced years ago and so far was used on MIPS
  14. devices only. All Northstar (ARM) devices were using other two cores
  15. which allowed easy implementation of separated initialization paths.
  16. It seems however Broadcom decided to reuse this old USB 2.0 controller
  17. on some recently introduced cheaper Northstar BCM53573 SoCs. I noticed
  18. this on Tenda AC9 (based on BCM47189B0 belonging to BCM53573 family).
  19. There is no difference in this old controller core identification
  20. between MIPS and ARM devices: they share the same id and revision. We
  21. need different controller initialization procedure however.
  22. To handle this add a check for architecture and implement required
  23. initialization for ARM case.
  24. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  25. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  26. ---
  27. drivers/usb/host/bcma-hcd.c | 86 ++++++++++++++++++++++++++++++++++++++++--
  28. include/linux/bcma/bcma_regs.h | 1 +
  29. 2 files changed, 83 insertions(+), 4 deletions(-)
  30. --- a/drivers/usb/host/bcma-hcd.c
  31. +++ b/drivers/usb/host/bcma-hcd.c
  32. @@ -35,6 +35,9 @@ MODULE_AUTHOR("Hauke Mehrtens");
  33. MODULE_DESCRIPTION("Common USB driver for BCMA Bus");
  34. MODULE_LICENSE("GPL");
  35. +/* See BCMA_CLKCTLST_EXTRESREQ and BCMA_CLKCTLST_EXTRESST */
  36. +#define USB_BCMA_CLKCTLST_USB_CLK_REQ 0x00000100
  37. +
  38. struct bcma_hcd_device {
  39. struct bcma_device *core;
  40. struct platform_device *ehci_dev;
  41. @@ -166,6 +169,76 @@ static void bcma_hcd_init_chip_mips(stru
  42. }
  43. }
  44. +/**
  45. + * bcma_hcd_usb20_old_arm_init - Initialize old USB 2.0 controller on ARM
  46. + *
  47. + * Old USB 2.0 core is identified as BCMA_CORE_USB20_HOST and was introduced
  48. + * long before Northstar devices. It seems some cheaper chipsets like BCM53573
  49. + * still use it.
  50. + * Initialization of this old core differs between MIPS and ARM.
  51. + */
  52. +static int bcma_hcd_usb20_old_arm_init(struct bcma_hcd_device *usb_dev)
  53. +{
  54. + struct bcma_device *core = usb_dev->core;
  55. + struct device *dev = &core->dev;
  56. + struct bcma_device *pmu_core;
  57. +
  58. + usleep_range(10000, 20000);
  59. + if (core->id.rev < 5)
  60. + return 0;
  61. +
  62. + pmu_core = bcma_find_core(core->bus, BCMA_CORE_PMU);
  63. + if (!pmu_core) {
  64. + dev_err(dev, "Could not find PMU core\n");
  65. + return -ENOENT;
  66. + }
  67. +
  68. + /* Take USB core out of reset */
  69. + bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK | BCMA_IOCTL_FGC);
  70. + usleep_range(100, 200);
  71. + bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
  72. + usleep_range(100, 200);
  73. + bcma_awrite32(core, BCMA_RESET_CTL, 0);
  74. + usleep_range(100, 200);
  75. + bcma_awrite32(core, BCMA_IOCTL, BCMA_IOCTL_CLK);
  76. + usleep_range(100, 200);
  77. +
  78. + /* Enable Misc PLL */
  79. + bcma_write32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT |
  80. + BCMA_CLKCTLST_HQCLKREQ |
  81. + USB_BCMA_CLKCTLST_USB_CLK_REQ);
  82. + usleep_range(100, 200);
  83. +
  84. + bcma_write32(core, 0x510, 0xc7f85000);
  85. + bcma_write32(core, 0x510, 0xc7f85003);
  86. + usleep_range(300, 600);
  87. +
  88. + /* Program USB PHY PLL parameters */
  89. + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x6);
  90. + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x005360c1);
  91. + usleep_range(100, 200);
  92. + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_ADDR, 0x7);
  93. + bcma_write32(pmu_core, BCMA_CC_PMU_PLLCTL_DATA, 0x0);
  94. + usleep_range(100, 200);
  95. + bcma_set32(pmu_core, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
  96. + usleep_range(100, 200);
  97. +
  98. + bcma_write32(core, 0x510, 0x7f8d007);
  99. + udelay(1000);
  100. +
  101. + /* Take controller out of reset */
  102. + bcma_write32(core, 0x200, 0x4ff);
  103. + usleep_range(25, 50);
  104. + bcma_write32(core, 0x200, 0x6ff);
  105. + usleep_range(25, 50);
  106. + bcma_write32(core, 0x200, 0x7ff);
  107. + usleep_range(25, 50);
  108. +
  109. + of_platform_default_populate(dev->of_node, NULL, dev);
  110. +
  111. + return 0;
  112. +}
  113. +
  114. static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
  115. {
  116. struct bcma_device *arm_core;
  117. @@ -370,19 +443,24 @@ static int bcma_hcd_probe(struct bcma_de
  118. switch (core->id.id) {
  119. case BCMA_CORE_USB20_HOST:
  120. + if (IS_ENABLED(CONFIG_ARM))
  121. + err = bcma_hcd_usb20_old_arm_init(usb_dev);
  122. + else if (IS_ENABLED(CONFIG_MIPS))
  123. + err = bcma_hcd_usb20_init(usb_dev);
  124. + else
  125. + err = -ENOTSUPP;
  126. + break;
  127. case BCMA_CORE_NS_USB20:
  128. err = bcma_hcd_usb20_init(usb_dev);
  129. - if (err)
  130. - return err;
  131. break;
  132. case BCMA_CORE_NS_USB30:
  133. err = bcma_hcd_usb30_init(usb_dev);
  134. - if (err)
  135. - return err;
  136. break;
  137. default:
  138. return -ENODEV;
  139. }
  140. + if (err)
  141. + return err;
  142. bcma_set_drvdata(core, usb_dev);
  143. return 0;
  144. --- a/include/linux/bcma/bcma_regs.h
  145. +++ b/include/linux/bcma/bcma_regs.h
  146. @@ -10,6 +10,7 @@
  147. #define BCMA_CLKCTLST_HAVEALPREQ 0x00000008 /* ALP available request */
  148. #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
  149. #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
  150. +#define BCMA_CLKCTLST_HQCLKREQ 0x00000040 /* HQ Clock */
  151. #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
  152. #define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
  153. #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */