ehci-vt8500.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * drivers/usb/host/ehci-vt8500.c
  3. *
  4. * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
  5. *
  6. * Based on ehci-au1xxx.c
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  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. */
  18. #include <linux/of.h>
  19. #include <linux/platform_device.h>
  20. static const struct hc_driver vt8500_ehci_hc_driver = {
  21. .description = hcd_name,
  22. .product_desc = "VT8500 EHCI",
  23. .hcd_priv_size = sizeof(struct ehci_hcd),
  24. /*
  25. * generic hardware linkage
  26. */
  27. .irq = ehci_irq,
  28. .flags = HCD_MEMORY | HCD_USB2,
  29. /*
  30. * basic lifecycle operations
  31. */
  32. .reset = ehci_setup,
  33. .start = ehci_run,
  34. .stop = ehci_stop,
  35. .shutdown = ehci_shutdown,
  36. /*
  37. * managing i/o requests and associated device resources
  38. */
  39. .urb_enqueue = ehci_urb_enqueue,
  40. .urb_dequeue = ehci_urb_dequeue,
  41. .endpoint_disable = ehci_endpoint_disable,
  42. .endpoint_reset = ehci_endpoint_reset,
  43. /*
  44. * scheduling support
  45. */
  46. .get_frame_number = ehci_get_frame,
  47. /*
  48. * root hub support
  49. */
  50. .hub_status_data = ehci_hub_status_data,
  51. .hub_control = ehci_hub_control,
  52. .bus_suspend = ehci_bus_suspend,
  53. .bus_resume = ehci_bus_resume,
  54. .relinquish_port = ehci_relinquish_port,
  55. .port_handed_over = ehci_port_handed_over,
  56. .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete,
  57. };
  58. static u64 vt8500_ehci_dma_mask = DMA_BIT_MASK(32);
  59. static int vt8500_ehci_drv_probe(struct platform_device *pdev)
  60. {
  61. struct usb_hcd *hcd;
  62. struct ehci_hcd *ehci;
  63. struct resource *res;
  64. int ret;
  65. if (usb_disabled())
  66. return -ENODEV;
  67. /*
  68. * Right now device-tree probed devices don't get dma_mask set.
  69. * Since shared usb code relies on it, set it here for now.
  70. * Once we have dma capability bindings this can go away.
  71. */
  72. if (!pdev->dev.dma_mask)
  73. pdev->dev.dma_mask = &vt8500_ehci_dma_mask;
  74. if (pdev->resource[1].flags != IORESOURCE_IRQ) {
  75. pr_debug("resource[1] is not IORESOURCE_IRQ");
  76. return -ENOMEM;
  77. }
  78. hcd = usb_create_hcd(&vt8500_ehci_hc_driver, &pdev->dev, "VT8500");
  79. if (!hcd)
  80. return -ENOMEM;
  81. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  82. hcd->rsrc_start = res->start;
  83. hcd->rsrc_len = resource_size(res);
  84. hcd->regs = devm_request_and_ioremap(&pdev->dev, res);
  85. if (!hcd->regs) {
  86. pr_debug("ioremap failed");
  87. ret = -ENOMEM;
  88. goto err1;
  89. }
  90. ehci = hcd_to_ehci(hcd);
  91. ehci->caps = hcd->regs;
  92. ret = usb_add_hcd(hcd, pdev->resource[1].start,
  93. IRQF_SHARED);
  94. if (ret == 0) {
  95. platform_set_drvdata(pdev, hcd);
  96. return ret;
  97. }
  98. err1:
  99. usb_put_hcd(hcd);
  100. return ret;
  101. }
  102. static int vt8500_ehci_drv_remove(struct platform_device *pdev)
  103. {
  104. struct usb_hcd *hcd = platform_get_drvdata(pdev);
  105. usb_remove_hcd(hcd);
  106. usb_put_hcd(hcd);
  107. platform_set_drvdata(pdev, NULL);
  108. return 0;
  109. }
  110. static const struct of_device_id vt8500_ehci_ids[] = {
  111. { .compatible = "via,vt8500-ehci", },
  112. { .compatible = "wm,prizm-ehci", },
  113. {}
  114. };
  115. static struct platform_driver vt8500_ehci_driver = {
  116. .probe = vt8500_ehci_drv_probe,
  117. .remove = vt8500_ehci_drv_remove,
  118. .shutdown = usb_hcd_platform_shutdown,
  119. .driver = {
  120. .name = "vt8500-ehci",
  121. .owner = THIS_MODULE,
  122. .of_match_table = of_match_ptr(vt8500_ehci_ids),
  123. }
  124. };
  125. MODULE_ALIAS("platform:vt8500-ehci");
  126. MODULE_DEVICE_TABLE(of, vt8500_ehci_ids);