ohci-sh.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * Copyright (C) 2008 Renesas Solutions Corp.
  5. *
  6. * Author : Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #include <linux/platform_device.h>
  23. static int ohci_sh_start(struct usb_hcd *hcd)
  24. {
  25. struct ohci_hcd *ohci = hcd_to_ohci(hcd);
  26. ohci_hcd_init(ohci);
  27. ohci_init(ohci);
  28. ohci_run(ohci);
  29. return 0;
  30. }
  31. static const struct hc_driver ohci_sh_hc_driver = {
  32. .description = hcd_name,
  33. .product_desc = "SuperH OHCI",
  34. .hcd_priv_size = sizeof(struct ohci_hcd),
  35. /*
  36. * generic hardware linkage
  37. */
  38. .irq = ohci_irq,
  39. .flags = HCD_USB11 | HCD_MEMORY,
  40. /*
  41. * basic lifecycle operations
  42. */
  43. .start = ohci_sh_start,
  44. .stop = ohci_stop,
  45. .shutdown = ohci_shutdown,
  46. /*
  47. * managing i/o requests and associated device resources
  48. */
  49. .urb_enqueue = ohci_urb_enqueue,
  50. .urb_dequeue = ohci_urb_dequeue,
  51. .endpoint_disable = ohci_endpoint_disable,
  52. /*
  53. * scheduling support
  54. */
  55. .get_frame_number = ohci_get_frame,
  56. /*
  57. * root hub support
  58. */
  59. .hub_status_data = ohci_hub_status_data,
  60. .hub_control = ohci_hub_control,
  61. #ifdef CONFIG_PM
  62. .bus_suspend = ohci_bus_suspend,
  63. .bus_resume = ohci_bus_resume,
  64. #endif
  65. .start_port_reset = ohci_start_port_reset,
  66. };
  67. /*-------------------------------------------------------------------------*/
  68. static int ohci_hcd_sh_probe(struct platform_device *pdev)
  69. {
  70. struct resource *res = NULL;
  71. struct usb_hcd *hcd = NULL;
  72. int irq = -1;
  73. int ret;
  74. if (usb_disabled())
  75. return -ENODEV;
  76. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  77. if (!res) {
  78. err("platform_get_resource error.");
  79. return -ENODEV;
  80. }
  81. irq = platform_get_irq(pdev, 0);
  82. if (irq < 0) {
  83. err("platform_get_irq error.");
  84. return -ENODEV;
  85. }
  86. /* initialize hcd */
  87. hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name);
  88. if (!hcd) {
  89. err("Failed to create hcd");
  90. return -ENOMEM;
  91. }
  92. hcd->regs = (void __iomem *)res->start;
  93. hcd->rsrc_start = res->start;
  94. hcd->rsrc_len = resource_size(res);
  95. ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
  96. if (ret != 0) {
  97. err("Failed to add hcd");
  98. usb_put_hcd(hcd);
  99. return ret;
  100. }
  101. return ret;
  102. }
  103. static int ohci_hcd_sh_remove(struct platform_device *pdev)
  104. {
  105. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  106. usb_remove_hcd(hcd);
  107. usb_put_hcd(hcd);
  108. return 0;
  109. }
  110. static struct platform_driver ohci_hcd_sh_driver = {
  111. .probe = ohci_hcd_sh_probe,
  112. .remove = ohci_hcd_sh_remove,
  113. .shutdown = usb_hcd_platform_shutdown,
  114. .driver = {
  115. .name = "sh_ohci",
  116. .owner = THIS_MODULE,
  117. },
  118. };
  119. MODULE_ALIAS("platform:sh_ohci");