ci13xxx_msm.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. */
  7. #include <linux/module.h>
  8. #include <linux/platform_device.h>
  9. #include <linux/pm_runtime.h>
  10. #include <linux/usb/msm_hsusb_hw.h>
  11. #include <linux/usb/ulpi.h>
  12. #include <linux/usb/gadget.h>
  13. #include <linux/usb/chipidea.h>
  14. #include "ci.h"
  15. #define MSM_USB_BASE (udc->hw_bank.abs)
  16. static void ci13xxx_msm_notify_event(struct ci13xxx *udc, unsigned event)
  17. {
  18. struct device *dev = udc->gadget.dev.parent;
  19. int val;
  20. switch (event) {
  21. case CI13XXX_CONTROLLER_RESET_EVENT:
  22. dev_dbg(dev, "CI13XXX_CONTROLLER_RESET_EVENT received\n");
  23. writel(0, USB_AHBBURST);
  24. writel(0, USB_AHBMODE);
  25. break;
  26. case CI13XXX_CONTROLLER_STOPPED_EVENT:
  27. dev_dbg(dev, "CI13XXX_CONTROLLER_STOPPED_EVENT received\n");
  28. /*
  29. * Put the transceiver in non-driving mode. Otherwise host
  30. * may not detect soft-disconnection.
  31. */
  32. val = usb_phy_io_read(udc->transceiver, ULPI_FUNC_CTRL);
  33. val &= ~ULPI_FUNC_CTRL_OPMODE_MASK;
  34. val |= ULPI_FUNC_CTRL_OPMODE_NONDRIVING;
  35. usb_phy_io_write(udc->transceiver, val, ULPI_FUNC_CTRL);
  36. break;
  37. default:
  38. dev_dbg(dev, "unknown ci13xxx_udc event\n");
  39. break;
  40. }
  41. }
  42. static struct ci13xxx_udc_driver ci13xxx_msm_udc_driver = {
  43. .name = "ci13xxx_msm",
  44. .flags = CI13XXX_REGS_SHARED |
  45. CI13XXX_REQUIRE_TRANSCEIVER |
  46. CI13XXX_PULLUP_ON_VBUS |
  47. CI13XXX_DISABLE_STREAMING,
  48. .notify_event = ci13xxx_msm_notify_event,
  49. };
  50. static int ci13xxx_msm_probe(struct platform_device *pdev)
  51. {
  52. struct platform_device *plat_ci;
  53. int ret;
  54. dev_dbg(&pdev->dev, "ci13xxx_msm_probe\n");
  55. plat_ci = platform_device_alloc("ci_hdrc", -1);
  56. if (!plat_ci) {
  57. dev_err(&pdev->dev, "can't allocate ci_hdrc platform device\n");
  58. return -ENOMEM;
  59. }
  60. ret = platform_device_add_resources(plat_ci, pdev->resource,
  61. pdev->num_resources);
  62. if (ret) {
  63. dev_err(&pdev->dev, "can't add resources to platform device\n");
  64. goto put_platform;
  65. }
  66. ret = platform_device_add_data(plat_ci, &ci13xxx_msm_udc_driver,
  67. sizeof(ci13xxx_msm_udc_driver));
  68. if (ret)
  69. goto put_platform;
  70. ret = platform_device_add(plat_ci);
  71. if (ret)
  72. goto put_platform;
  73. pm_runtime_no_callbacks(&pdev->dev);
  74. pm_runtime_enable(&pdev->dev);
  75. return 0;
  76. put_platform:
  77. platform_device_put(plat_ci);
  78. return ret;
  79. }
  80. static struct platform_driver ci13xxx_msm_driver = {
  81. .probe = ci13xxx_msm_probe,
  82. .driver = { .name = "msm_hsusb", },
  83. };
  84. MODULE_ALIAS("platform:msm_hsusb");
  85. static int __init ci13xxx_msm_init(void)
  86. {
  87. return platform_driver_register(&ci13xxx_msm_driver);
  88. }
  89. module_init(ci13xxx_msm_init);
  90. MODULE_LICENSE("GPL v2");