host.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * host.c - DesignWare USB3 DRD Controller Host Glue
  3. *
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com
  5. *
  6. * Authors: Felipe Balbi <balbi@ti.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 version 2 of
  10. * the License as published by the Free Software Foundation.
  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. #include <linux/platform_device.h>
  18. #include "core.h"
  19. int dwc3_host_init(struct dwc3 *dwc)
  20. {
  21. struct platform_device *xhci;
  22. int ret;
  23. xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
  24. if (!xhci) {
  25. dev_err(dwc->dev, "couldn't allocate xHCI device\n");
  26. ret = -ENOMEM;
  27. goto err0;
  28. }
  29. dma_set_coherent_mask(&xhci->dev, dwc->dev->coherent_dma_mask);
  30. xhci->dev.parent = dwc->dev;
  31. xhci->dev.dma_mask = dwc->dev->dma_mask;
  32. xhci->dev.dma_parms = dwc->dev->dma_parms;
  33. dwc->xhci = xhci;
  34. ret = platform_device_add_resources(xhci, dwc->xhci_resources,
  35. DWC3_XHCI_RESOURCES_NUM);
  36. if (ret) {
  37. dev_err(dwc->dev, "couldn't add resources to xHCI device\n");
  38. goto err1;
  39. }
  40. ret = platform_device_add(xhci);
  41. if (ret) {
  42. dev_err(dwc->dev, "failed to register xHCI device\n");
  43. goto err1;
  44. }
  45. return 0;
  46. err1:
  47. platform_device_put(xhci);
  48. err0:
  49. return ret;
  50. }
  51. void dwc3_host_exit(struct dwc3 *dwc)
  52. {
  53. platform_device_unregister(dwc->xhci);
  54. }