0120-USB-add-OHCI-EHCI-OF-binding.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. From 08d438b69f3023f16b044b07eebee6b9c2302f60 Mon Sep 17 00:00:00 2001
  2. From: John Crispin <[email protected]>
  3. Date: Sun, 14 Jul 2013 23:34:53 +0200
  4. Subject: [PATCH 120/133] USB: add OHCI/EHCI OF binding
  5. based on f3bc64d6d1f21c1b92d75f233a37b75d77af6963
  6. Signed-off-by: John Crispin <[email protected]>
  7. ---
  8. drivers/usb/Makefile | 3 ++-
  9. drivers/usb/host/ehci-platform.c | 21 +++++++++++++++++----
  10. drivers/usb/host/ohci-platform.c | 37 ++++++++++++++++++++++++++++++++-----
  11. 3 files changed, 51 insertions(+), 10 deletions(-)
  12. --- a/drivers/usb/Makefile
  13. +++ b/drivers/usb/Makefile
  14. @@ -10,6 +10,8 @@ obj-$(CONFIG_USB_DWC3) += dwc3/
  15. obj-$(CONFIG_USB_MON) += mon/
  16. +obj-$(CONFIG_USB_PHY) += phy/
  17. +
  18. obj-$(CONFIG_PCI) += host/
  19. obj-$(CONFIG_USB_EHCI_HCD) += host/
  20. obj-$(CONFIG_USB_ISP116X_HCD) += host/
  21. @@ -44,7 +46,6 @@ obj-$(CONFIG_USB_MICROTEK) += image/
  22. obj-$(CONFIG_USB_SERIAL) += serial/
  23. obj-$(CONFIG_USB) += misc/
  24. -obj-$(CONFIG_USB_PHY) += phy/
  25. obj-$(CONFIG_EARLY_PRINTK_DBGP) += early/
  26. obj-$(CONFIG_USB_ATM) += atm/
  27. --- a/drivers/usb/host/ehci-platform.c
  28. +++ b/drivers/usb/host/ehci-platform.c
  29. @@ -29,6 +29,8 @@
  30. #include <linux/usb.h>
  31. #include <linux/usb/hcd.h>
  32. #include <linux/usb/ehci_pdriver.h>
  33. +#include <linux/usb/phy.h>
  34. +#include <linux/usb/otg.h>
  35. #include "ehci.h"
  36. @@ -118,6 +120,15 @@ static int ehci_platform_probe(struct pl
  37. hcd->rsrc_start = res_mem->start;
  38. hcd->rsrc_len = resource_size(res_mem);
  39. +#ifdef CONFIG_USB_PHY
  40. + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
  41. + if (!IS_ERR_OR_NULL(hcd->phy)) {
  42. + otg_set_host(hcd->phy->otg,
  43. + &hcd->self);
  44. + usb_phy_init(hcd->phy);
  45. + }
  46. +#endif
  47. +
  48. hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
  49. if (IS_ERR(hcd->regs)) {
  50. err = PTR_ERR(hcd->regs);
  51. @@ -155,6 +166,9 @@ static int ehci_platform_remove(struct p
  52. if (pdata == &ehci_platform_defaults)
  53. dev->dev.platform_data = NULL;
  54. + if (pdata == &ehci_platform_defaults)
  55. + dev->dev.platform_data = NULL;
  56. +
  57. return 0;
  58. }
  59. @@ -199,9 +213,8 @@ static int ehci_platform_resume(struct d
  60. #define ehci_platform_resume NULL
  61. #endif /* CONFIG_PM */
  62. -static const struct of_device_id vt8500_ehci_ids[] = {
  63. - { .compatible = "via,vt8500-ehci", },
  64. - { .compatible = "wm,prizm-ehci", },
  65. +static const struct of_device_id ralink_ehci_ids[] = {
  66. + { .compatible = "ralink,rt3xxx-ehci", },
  67. {}
  68. };
  69. @@ -225,7 +238,7 @@ static struct platform_driver ehci_platf
  70. .owner = THIS_MODULE,
  71. .name = "ehci-platform",
  72. .pm = &ehci_platform_pm_ops,
  73. - .of_match_table = of_match_ptr(vt8500_ehci_ids),
  74. + .of_match_table = of_match_ptr(ralink_ehci_ids),
  75. }
  76. };
  77. --- a/drivers/usb/host/ohci-platform.c
  78. +++ b/drivers/usb/host/ohci-platform.c
  79. @@ -16,6 +16,10 @@
  80. #include <linux/err.h>
  81. #include <linux/platform_device.h>
  82. #include <linux/usb/ohci_pdriver.h>
  83. +#include <linux/dma-mapping.h>
  84. +#include <linux/of.h>
  85. +
  86. +static struct usb_ohci_pdata ohci_platform_defaults;
  87. static int ohci_platform_reset(struct usb_hcd *hcd)
  88. {
  89. @@ -88,14 +92,22 @@ static int ohci_platform_probe(struct pl
  90. {
  91. struct usb_hcd *hcd;
  92. struct resource *res_mem;
  93. - struct usb_ohci_pdata *pdata = dev->dev.platform_data;
  94. + struct usb_ohci_pdata *pdata;
  95. int irq;
  96. int err = -ENOMEM;
  97. - if (!pdata) {
  98. - WARN_ON(1);
  99. - return -ENODEV;
  100. - }
  101. + /*
  102. + * use reasonable defaults so platforms don't have to provide these.
  103. + * with DT probing on ARM, none of these are set.
  104. + */
  105. + if (!dev->dev.platform_data)
  106. + dev->dev.platform_data = &ohci_platform_defaults;
  107. + if (!dev->dev.dma_mask)
  108. + dev->dev.dma_mask = &dev->dev.coherent_dma_mask;
  109. + if (!dev->dev.coherent_dma_mask)
  110. + dev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
  111. +
  112. + pdata = dev->dev.platform_data;
  113. if (usb_disabled())
  114. return -ENODEV;
  115. @@ -128,6 +140,12 @@ static int ohci_platform_probe(struct pl
  116. hcd->rsrc_start = res_mem->start;
  117. hcd->rsrc_len = resource_size(res_mem);
  118. +#ifdef CONFIG_USB_PHY
  119. + hcd->phy = devm_usb_get_phy(&dev->dev, USB_PHY_TYPE_USB2);
  120. + if (!IS_ERR_OR_NULL(hcd->phy))
  121. + usb_phy_init(hcd->phy);
  122. +#endif
  123. +
  124. hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
  125. if (IS_ERR(hcd->regs)) {
  126. err = PTR_ERR(hcd->regs);
  127. @@ -162,6 +180,9 @@ static int ohci_platform_remove(struct p
  128. if (pdata->power_off)
  129. pdata->power_off(dev);
  130. + if (pdata == &ohci_platform_defaults)
  131. + dev->dev.platform_data = NULL;
  132. +
  133. return 0;
  134. }
  135. @@ -201,6 +222,11 @@ static int ohci_platform_resume(struct d
  136. #define ohci_platform_resume NULL
  137. #endif /* CONFIG_PM */
  138. +static const struct of_device_id ralink_ohci_ids[] = {
  139. + { .compatible = "ralink,rt3xxx-ohci", },
  140. + {}
  141. +};
  142. +
  143. static const struct platform_device_id ohci_platform_table[] = {
  144. { "ohci-platform", 0 },
  145. { }
  146. @@ -221,5 +247,6 @@ static struct platform_driver ohci_platf
  147. .owner = THIS_MODULE,
  148. .name = "ohci-platform",
  149. .pm = &ohci_platform_pm_ops,
  150. + .of_match_table = of_match_ptr(ralink_ohci_ids),
  151. }
  152. };