920-usb-chipidea-AR933x-platform-support.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  2. +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
  3. @@ -659,6 +659,7 @@
  4. #define AR933X_BOOTSTRAP_MDIO_GPIO_EN BIT(18)
  5. #define AR933X_BOOTSTRAP_EEPBUSY BIT(4)
  6. +#define AR933X_BOOTSTRAP_USB_MODE_HOST BIT(3)
  7. #define AR933X_BOOTSTRAP_REF_CLK_40 BIT(0)
  8. #define AR934X_BOOTSTRAP_SW_OPTION8 BIT(23)
  9. @@ -688,6 +689,8 @@
  10. #define QCA956X_BOOTSTRAP_REF_CLK_40 BIT(2)
  11. +#define AR933X_USB_CONFIG_HOST_ONLY BIT(8)
  12. +
  13. #define AR934X_PCIE_WMAC_INT_WMAC_MISC BIT(0)
  14. #define AR934X_PCIE_WMAC_INT_WMAC_TX BIT(1)
  15. #define AR934X_PCIE_WMAC_INT_WMAC_RXLP BIT(2)
  16. --- a/arch/mips/ath79/dev-usb.c
  17. +++ b/arch/mips/ath79/dev-usb.c
  18. @@ -19,6 +19,9 @@
  19. #include <linux/platform_device.h>
  20. #include <linux/usb/ehci_pdriver.h>
  21. #include <linux/usb/ohci_pdriver.h>
  22. +#include <linux/usb/otg.h>
  23. +#include <linux/usb/chipidea.h>
  24. +#include <linux/usb/usb_phy_generic.h>
  25. #include <asm/mach-ath79/ath79.h>
  26. #include <asm/mach-ath79/ar71xx_regs.h>
  27. @@ -170,6 +173,44 @@ static void __init ar913x_usb_setup(void
  28. &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  29. }
  30. +static void __init ar9xxx_ci_usb_setup(int bus_id, int irq)
  31. +{
  32. + struct ci_hdrc_platform_data ci_pdata;
  33. + bool host_mode = true;
  34. +
  35. + if (soc_is_ar933x())
  36. + host_mode = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP) &
  37. + AR933X_BOOTSTRAP_USB_MODE_HOST;
  38. + else
  39. + host_mode = !(ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP) &
  40. + AR934X_BOOTSTRAP_USB_MODE_DEVICE);
  41. +
  42. + if (host_mode) {
  43. + ath79_usb_register("ehci-platform", bus_id,
  44. + AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
  45. + irq, &ath79_ehci_pdata_v2,
  46. + sizeof(ath79_ehci_pdata_v2));
  47. +
  48. + return;
  49. + }
  50. +
  51. + memset(&ci_pdata, 0, sizeof(ci_pdata));
  52. + ci_pdata.name = "ci_hdrc_ar9xxx";
  53. + ci_pdata.capoffset = DEF_CAPOFFSET;
  54. + ci_pdata.dr_mode = USB_DR_MODE_PERIPHERAL;
  55. + ci_pdata.flags = CI_HDRC_DUAL_ROLE_NOT_OTG | CI_HDRC_DP_ALWAYS_PULLUP;
  56. + ci_pdata.vbus_extcon.edev = ERR_PTR(-ENODEV);
  57. + ci_pdata.id_extcon.edev = ERR_PTR(-ENODEV);
  58. + ci_pdata.itc_setting = 1;
  59. +
  60. + platform_device_register_simple("usb_phy_generic",
  61. + PLATFORM_DEVID_AUTO, NULL, 0);
  62. +
  63. + ath79_usb_register("ci_hdrc", -1,
  64. + AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
  65. + irq, &ci_pdata, sizeof(ci_pdata));
  66. +}
  67. +
  68. static void __init ar933x_usb_setup(void)
  69. {
  70. ath79_device_reset_set(AR933X_RESET_USBSUS_OVERRIDE);
  71. @@ -181,10 +222,7 @@ static void __init ar933x_usb_setup(void
  72. ath79_device_reset_clear(AR933X_RESET_USB_PHY);
  73. mdelay(10);
  74. - ath79_usb_register("ehci-platform", -1,
  75. - AR933X_EHCI_BASE, AR933X_EHCI_SIZE,
  76. - ATH79_CPU_IRQ(3),
  77. - &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  78. + ar9xxx_ci_usb_setup(-1, ATH79_CPU_IRQ(3));
  79. }
  80. static void enable_tx_tx_idp_violation_fix(unsigned base)
  81. @@ -230,10 +268,7 @@ static void __init ar934x_usb_setup(void
  82. if (ath79_soc_rev >= 3)
  83. ath79_ehci_pdata_v2.reset_notifier = ar934x_usb_reset_notifier;
  84. - ath79_usb_register("ehci-platform", -1,
  85. - AR934X_EHCI_BASE, AR934X_EHCI_SIZE,
  86. - ATH79_CPU_IRQ(3),
  87. - &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  88. + ar9xxx_ci_usb_setup(-1, ATH79_CPU_IRQ(3));
  89. }
  90. static void __init qca953x_usb_setup(void)
  91. @@ -254,10 +289,7 @@ static void __init qca953x_usb_setup(voi
  92. ath79_device_reset_clear(QCA953X_RESET_USB_HOST);
  93. udelay(1000);
  94. - ath79_usb_register("ehci-platform", -1,
  95. - QCA953X_EHCI_BASE, QCA953X_EHCI_SIZE,
  96. - ATH79_CPU_IRQ(3),
  97. - &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  98. + ar9xxx_ci_usb_setup(-1, ATH79_CPU_IRQ(3));
  99. }
  100. static void qca955x_usb_reset_notifier(struct platform_device *pdev)
  101. @@ -285,10 +317,7 @@ static void __init qca955x_usb_setup(voi
  102. {
  103. ath79_ehci_pdata_v2.reset_notifier = qca955x_usb_reset_notifier;
  104. - ath79_usb_register("ehci-platform", 0,
  105. - QCA955X_EHCI0_BASE, QCA955X_EHCI_SIZE,
  106. - ATH79_IP3_IRQ(0),
  107. - &ath79_ehci_pdata_v2, sizeof(ath79_ehci_pdata_v2));
  108. + ar9xxx_ci_usb_setup(0, ATH79_IP3_IRQ(0));
  109. ath79_usb_register("ehci-platform", 1,
  110. QCA955X_EHCI1_BASE, QCA955X_EHCI_SIZE,