082-0003-USB-bcma-drop-Northstar-PHY-2.0-initialization-code.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. From e8624859dde2ad07633dac7ec86629a516411ea1 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
  3. Date: Wed, 21 Sep 2016 18:01:43 +0200
  4. Subject: [PATCH] USB: bcma: drop Northstar PHY 2.0 initialization code
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. This driver should initialize controller only, PHY initialization should
  9. be handled by separated PHY driver. We already have phy-bcm-ns-usb2 in
  10. place so let it makes its duty.
  11. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  12. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  13. ---
  14. drivers/usb/host/bcma-hcd.c | 80 ++++++++++++++-------------------------------
  15. 1 file changed, 25 insertions(+), 55 deletions(-)
  16. --- a/drivers/usb/host/bcma-hcd.c
  17. +++ b/drivers/usb/host/bcma-hcd.c
  18. @@ -239,44 +239,10 @@ static int bcma_hcd_usb20_old_arm_init(s
  19. return 0;
  20. }
  21. -static void bcma_hcd_init_chip_arm_phy(struct bcma_device *dev)
  22. -{
  23. - struct bcma_device *arm_core;
  24. - void __iomem *dmu;
  25. -
  26. - arm_core = bcma_find_core(dev->bus, BCMA_CORE_ARMCA9);
  27. - if (!arm_core) {
  28. - dev_err(&dev->dev, "can not find ARM Cortex A9 ihost core\n");
  29. - return;
  30. - }
  31. -
  32. - dmu = ioremap_nocache(arm_core->addr_s[0], 0x1000);
  33. - if (!dmu) {
  34. - dev_err(&dev->dev, "can not map ARM Cortex A9 ihost core\n");
  35. - return;
  36. - }
  37. -
  38. - /* Unlock DMU PLL settings */
  39. - iowrite32(0x0000ea68, dmu + 0x180);
  40. -
  41. - /* Write USB 2.0 PLL control setting */
  42. - iowrite32(0x00dd10c3, dmu + 0x164);
  43. -
  44. - /* Lock DMU PLL settings */
  45. - iowrite32(0x00000000, dmu + 0x180);
  46. -
  47. - iounmap(dmu);
  48. -}
  49. -
  50. -static void bcma_hcd_init_chip_arm_hc(struct bcma_device *dev)
  51. +static void bcma_hcd_usb20_ns_init_hc(struct bcma_device *dev)
  52. {
  53. u32 val;
  54. - /*
  55. - * Delay after PHY initialized to ensure HC is ready to be configured
  56. - */
  57. - usleep_range(1000, 2000);
  58. -
  59. /* Set packet buffer OUT threshold */
  60. val = bcma_read32(dev, 0x94);
  61. val &= 0xffff;
  62. @@ -287,20 +253,33 @@ static void bcma_hcd_init_chip_arm_hc(st
  63. val = bcma_read32(dev, 0x9c);
  64. val |= 1;
  65. bcma_write32(dev, 0x9c, val);
  66. +
  67. + /*
  68. + * Broadcom initializes PHY and then waits to ensure HC is ready to be
  69. + * configured. In our case the order is reversed. We just initialized
  70. + * controller and we let HCD initialize PHY, so let's wait (sleep) now.
  71. + */
  72. + usleep_range(1000, 2000);
  73. }
  74. -static void bcma_hcd_init_chip_arm(struct bcma_device *dev)
  75. +/**
  76. + * bcma_hcd_usb20_ns_init - Initialize Northstar USB 2.0 controller
  77. + */
  78. +static int bcma_hcd_usb20_ns_init(struct bcma_hcd_device *bcma_hcd)
  79. {
  80. - bcma_core_enable(dev, 0);
  81. + struct bcma_device *core = bcma_hcd->core;
  82. + struct bcma_chipinfo *ci = &core->bus->chipinfo;
  83. + struct device *dev = &core->dev;
  84. +
  85. + bcma_core_enable(core, 0);
  86. - if (dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM4707 ||
  87. - dev->bus->chipinfo.id == BCMA_CHIP_ID_BCM53018) {
  88. - if (dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4707 ||
  89. - dev->bus->chipinfo.pkg == BCMA_PKG_ID_BCM4708)
  90. - bcma_hcd_init_chip_arm_phy(dev);
  91. + if (ci->id == BCMA_CHIP_ID_BCM4707 ||
  92. + ci->id == BCMA_CHIP_ID_BCM53018)
  93. + bcma_hcd_usb20_ns_init_hc(core);
  94. - bcma_hcd_init_chip_arm_hc(dev);
  95. - }
  96. + of_platform_default_populate(dev->of_node, NULL, dev);
  97. +
  98. + return 0;
  99. }
  100. static void bcma_hci_platform_power_gpio(struct bcma_device *dev, bool val)
  101. @@ -373,16 +352,7 @@ static int bcma_hcd_usb20_init(struct bc
  102. if (dma_set_mask_and_coherent(dev->dma_dev, DMA_BIT_MASK(32)))
  103. return -EOPNOTSUPP;
  104. - switch (dev->id.id) {
  105. - case BCMA_CORE_NS_USB20:
  106. - bcma_hcd_init_chip_arm(dev);
  107. - break;
  108. - case BCMA_CORE_USB20_HOST:
  109. - bcma_hcd_init_chip_mips(dev);
  110. - break;
  111. - default:
  112. - return -ENODEV;
  113. - }
  114. + bcma_hcd_init_chip_mips(dev);
  115. /* In AI chips EHCI is addrspace 0, OHCI is 1 */
  116. ohci_addr = dev->addr_s[0];
  117. @@ -451,7 +421,7 @@ static int bcma_hcd_probe(struct bcma_de
  118. err = -ENOTSUPP;
  119. break;
  120. case BCMA_CORE_NS_USB20:
  121. - err = bcma_hcd_usb20_init(usb_dev);
  122. + err = bcma_hcd_usb20_ns_init(usb_dev);
  123. break;
  124. case BCMA_CORE_NS_USB30:
  125. err = bcma_hcd_usb30_init(usb_dev);