usb-da8xx.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * DA8xx USB
  3. */
  4. #include <linux/dma-mapping.h>
  5. #include <linux/init.h>
  6. #include <linux/platform_data/usb-davinci.h>
  7. #include <linux/platform_device.h>
  8. #include <linux/usb/musb.h>
  9. #include <mach/common.h>
  10. #include <mach/cputype.h>
  11. #include <mach/da8xx.h>
  12. #include <mach/irqs.h>
  13. #define DA8XX_USB0_BASE 0x01e00000
  14. #define DA8XX_USB1_BASE 0x01e25000
  15. #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
  16. static struct musb_hdrc_config musb_config = {
  17. .multipoint = true,
  18. .num_eps = 5,
  19. .ram_bits = 10,
  20. };
  21. static struct musb_hdrc_platform_data usb_data = {
  22. /* OTG requires a Mini-AB connector */
  23. .mode = MUSB_OTG,
  24. .clock = "usb20",
  25. .config = &musb_config,
  26. };
  27. static struct resource da8xx_usb20_resources[] = {
  28. {
  29. .start = DA8XX_USB0_BASE,
  30. .end = DA8XX_USB0_BASE + SZ_64K - 1,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. {
  34. .start = IRQ_DA8XX_USB_INT,
  35. .flags = IORESOURCE_IRQ,
  36. .name = "mc",
  37. },
  38. };
  39. static u64 usb_dmamask = DMA_BIT_MASK(32);
  40. static struct platform_device usb_dev = {
  41. .name = "musb-da8xx",
  42. .id = -1,
  43. .dev = {
  44. .platform_data = &usb_data,
  45. .dma_mask = &usb_dmamask,
  46. .coherent_dma_mask = DMA_BIT_MASK(32),
  47. },
  48. .resource = da8xx_usb20_resources,
  49. .num_resources = ARRAY_SIZE(da8xx_usb20_resources),
  50. };
  51. int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
  52. {
  53. usb_data.power = mA > 510 ? 255 : mA / 2;
  54. usb_data.potpgt = (potpgt + 1) / 2;
  55. return platform_device_register(&usb_dev);
  56. }
  57. #else
  58. int __init da8xx_register_usb20(unsigned int mA, unsigned int potpgt)
  59. {
  60. return 0;
  61. }
  62. #endif /* CONFIG_USB_MUSB_HDRC */
  63. static struct resource da8xx_usb11_resources[] = {
  64. [0] = {
  65. .start = DA8XX_USB1_BASE,
  66. .end = DA8XX_USB1_BASE + SZ_4K - 1,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. [1] = {
  70. .start = IRQ_DA8XX_IRQN,
  71. .end = IRQ_DA8XX_IRQN,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. };
  75. static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
  76. static struct platform_device da8xx_usb11_device = {
  77. .name = "ohci",
  78. .id = 0,
  79. .dev = {
  80. .dma_mask = &da8xx_usb11_dma_mask,
  81. .coherent_dma_mask = DMA_BIT_MASK(32),
  82. },
  83. .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
  84. .resource = da8xx_usb11_resources,
  85. };
  86. int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
  87. {
  88. da8xx_usb11_device.dev.platform_data = pdata;
  89. return platform_device_register(&da8xx_usb11_device);
  90. }