ohci-sh.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * OHCI HCD (Host Controller Driver) for USB.
  3. *
  4. * Copyright (C) 2008 Renesas Solutions Corp.
  5. *
  6. * Author : Yoshihiro Shimoda <shimoda.yoshihiro@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. hcd->state = HC_STATE_RUNNING;
  30. return 0;
  31. }
  32. static const struct hc_driver ohci_sh_hc_driver = {
  33. .description = hcd_name,
  34. .product_desc = "SuperH OHCI",
  35. .hcd_priv_size = sizeof(struct ohci_hcd),
  36. /*
  37. * generic hardware linkage
  38. */
  39. .irq = ohci_irq,
  40. .flags = HCD_USB11 | HCD_MEMORY,
  41. /*
  42. * basic lifecycle operations
  43. */
  44. .start = ohci_sh_start,
  45. .stop = ohci_stop,
  46. .shutdown = ohci_shutdown,
  47. /*
  48. * managing i/o requests and associated device resources
  49. */
  50. .urb_enqueue = ohci_urb_enqueue,
  51. .urb_dequeue = ohci_urb_dequeue,
  52. .endpoint_disable = ohci_endpoint_disable,
  53. /*
  54. * scheduling support
  55. */
  56. .get_frame_number = ohci_get_frame,
  57. /*
  58. * root hub support
  59. */
  60. .hub_status_data = ohci_hub_status_data,
  61. .hub_control = ohci_hub_control,
  62. #ifdef CONFIG_PM
  63. .bus_suspend = ohci_bus_suspend,
  64. .bus_resume = ohci_bus_resume,
  65. #endif
  66. .start_port_reset = ohci_start_port_reset,
  67. };
  68. /*-------------------------------------------------------------------------*/
  69. static int ohci_hcd_sh_probe(struct platform_device *pdev)
  70. {
  71. struct resource *res = NULL;
  72. struct usb_hcd *hcd = NULL;
  73. int irq = -1;
  74. int ret;
  75. if (usb_disabled())
  76. return -ENODEV;
  77. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  78. if (!res) {
  79. err("platform_get_resource error.");
  80. return -ENODEV;
  81. }
  82. irq = platform_get_irq(pdev, 0);
  83. if (irq < 0) {
  84. err("platform_get_irq error.");
  85. return -ENODEV;
  86. }
  87. /* initialize hcd */
  88. hcd = usb_create_hcd(&ohci_sh_hc_driver, &pdev->dev, (char *)hcd_name);
  89. if (!hcd) {
  90. err("Failed to create hcd");
  91. return -ENOMEM;
  92. }
  93. hcd->regs = (void __iomem *)res->start;
  94. hcd->rsrc_start = res->start;
  95. hcd->rsrc_len = resource_size(res);
  96. ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
  97. if (ret != 0) {
  98. err("Failed to add hcd");
  99. usb_put_hcd(hcd);
  100. return ret;
  101. }
  102. return ret;
  103. }
  104. static int ohci_hcd_sh_remove(struct platform_device *pdev)
  105. {
  106. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  107. usb_remove_hcd(hcd);
  108. usb_put_hcd(hcd);
  109. return 0;
  110. }
  111. static struct platform_driver ohci_hcd_sh_driver = {
  112. .probe = ohci_hcd_sh_probe,
  113. .remove = ohci_hcd_sh_remove,
  114. .shutdown = usb_hcd_platform_shutdown,
  115. .driver = {
  116. .name = "sh_ohci",
  117. .owner = THIS_MODULE,
  118. },
  119. };
  120. MODULE_ALIAS("platform:sh_ohci");