ehci-au1xxx.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * EHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * Bus Glue for AMD Alchemy Au1xxx
  5. *
  6. * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org>
  7. *
  8. * Modified for AMD Alchemy Au1200 EHC
  9. * by K.Boge <karsten.boge@amd.com>
  10. *
  11. * This file is licenced under the GPL.
  12. */
  13. #include <linux/platform_device.h>
  14. #include <asm/mach-au1x00/au1000.h>
  15. extern int usb_disabled(void);
  16. static int au1xxx_ehci_setup(struct usb_hcd *hcd)
  17. {
  18. struct ehci_hcd *ehci = hcd_to_ehci(hcd);
  19. int ret;
  20. ehci->caps = hcd->regs;
  21. ret = ehci_setup(hcd);
  22. ehci->need_io_watchdog = 0;
  23. return ret;
  24. }
  25. static const struct hc_driver ehci_au1xxx_hc_driver = {
  26. .description = hcd_name,
  27. .product_desc = "Au1xxx EHCI",
  28. .hcd_priv_size = sizeof(struct ehci_hcd),
  29. /*
  30. * generic hardware linkage
  31. */
  32. .irq = ehci_irq,
  33. .flags = HCD_MEMORY | HCD_USB2,
  34. /*
  35. * basic lifecycle operations
  36. *
  37. * FIXME -- ehci_init() doesn't do enough here.
  38. * See ehci-ppc-soc for a complete implementation.
  39. */
  40. .reset = au1xxx_ehci_setup,
  41. .start = ehci_run,
  42. .stop = ehci_stop,
  43. .shutdown = ehci_shutdown,
  44. /*
  45. * managing i/o requests and associated device resources
  46. */
  47. .urb_enqueue = ehci_urb_enqueue,
  48. .urb_dequeue = ehci_urb_dequeue,
  49. .endpoint_disable = ehci_endpoint_disable,
  50. .endpoint_reset = ehci_endpoint_reset,
  51. /*
  52. * scheduling support
  53. */
  54. .get_frame_number = ehci_get_frame,
  55. /*
  56. * root hub support
  57. */
  58. .hub_status_data = ehci_hub_status_data,
  59. .hub_control = ehci_hub_control,
  60. .bus_suspend = ehci_bus_suspend,
  61. .bus_resume = ehci_bus_resume,
  62. .relinquish_port = ehci_relinquish_port,
  63. .port_handed_over = ehci_port_handed_over,
  64. .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
  65. };
  66. static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
  67. {
  68. struct usb_hcd *hcd;
  69. struct resource *res;
  70. int ret;
  71. if (usb_disabled())
  72. return -ENODEV;
  73. if (pdev->resource[1].flags != IORESOURCE_IRQ) {
  74. pr_debug("resource[1] is not IORESOURCE_IRQ");
  75. return -ENOMEM;
  76. }
  77. hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx");
  78. if (!hcd)
  79. return -ENOMEM;
  80. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  81. hcd->rsrc_start = res->start;
  82. hcd->rsrc_len = resource_size(res);
  83. hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
  84. if (!hcd->regs) {
  85. pr_debug("devm_request_and_ioremap failed");
  86. ret = -ENOMEM;
  87. goto err1;
  88. }
  89. if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) {
  90. printk(KERN_INFO "%s: controller init failed!\n", pdev->name);
  91. ret = -ENODEV;
  92. goto err1;
  93. }
  94. ret = usb_add_hcd(hcd, pdev->resource[1].start,
  95. IRQF_SHARED);
  96. if (ret == 0) {
  97. platform_set_drvdata(pdev, hcd);
  98. return ret;
  99. }
  100. alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
  101. err1:
  102. usb_put_hcd(hcd);
  103. return ret;
  104. }
  105. static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
  106. {
  107. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  108. usb_remove_hcd(hcd);
  109. alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
  110. usb_put_hcd(hcd);
  111. platform_set_drvdata(pdev, NULL);
  112. return 0;
  113. }
  114. #ifdef CONFIG_PM
  115. static int ehci_hcd_au1xxx_drv_suspend(struct device *dev)
  116. {
  117. struct usb_hcd *hcd = dev_get_drvdata(dev);
  118. bool do_wakeup = device_may_wakeup(dev);
  119. int rc;
  120. rc = ehci_suspend(hcd, do_wakeup);
  121. alchemy_usb_control(ALCHEMY_USB_EHCI0, 0);
  122. return rc;
  123. }
  124. static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
  125. {
  126. struct usb_hcd *hcd = dev_get_drvdata(dev);
  127. alchemy_usb_control(ALCHEMY_USB_EHCI0, 1);
  128. ehci_resume(hcd, false);
  129. return 0;
  130. }
  131. static const struct dev_pm_ops au1xxx_ehci_pmops = {
  132. .suspend = ehci_hcd_au1xxx_drv_suspend,
  133. .resume = ehci_hcd_au1xxx_drv_resume,
  134. };
  135. #define AU1XXX_EHCI_PMOPS &au1xxx_ehci_pmops
  136. #else
  137. #define AU1XXX_EHCI_PMOPS NULL
  138. #endif
  139. static struct platform_driver ehci_hcd_au1xxx_driver = {
  140. .probe = ehci_hcd_au1xxx_drv_probe,
  141. .remove = ehci_hcd_au1xxx_drv_remove,
  142. .shutdown = usb_hcd_platform_shutdown,
  143. .driver = {
  144. .name = "au1xxx-ehci",
  145. .owner = THIS_MODULE,
  146. .pm = AU1XXX_EHCI_PMOPS,
  147. }
  148. };
  149. MODULE_ALIAS("platform:au1xxx-ehci");