usb.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * USB
  4. */
  5. #include <linux/init.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/dma-mapping.h>
  8. #include <linux/usb/musb.h>
  9. #include <mach/common.h>
  10. #include <mach/irqs.h>
  11. #include <mach/cputype.h>
  12. #include <linux/platform_data/usb-davinci.h>
  13. #define DAVINCI_USB_OTG_BASE 0x01c64000
  14. #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
  15. static struct musb_hdrc_config musb_config = {
  16. .multipoint = true,
  17. .num_eps = 5,
  18. .ram_bits = 10,
  19. };
  20. static struct musb_hdrc_platform_data usb_data = {
  21. /* OTG requires a Mini-AB connector */
  22. .mode = MUSB_OTG,
  23. .clock = "usb",
  24. .config = &musb_config,
  25. };
  26. static struct resource usb_resources[] = {
  27. {
  28. /* physical address */
  29. .start = DAVINCI_USB_OTG_BASE,
  30. .end = DAVINCI_USB_OTG_BASE + 0x5ff,
  31. .flags = IORESOURCE_MEM,
  32. },
  33. {
  34. .start = IRQ_USBINT,
  35. .flags = IORESOURCE_IRQ,
  36. .name = "mc"
  37. },
  38. {
  39. /* placeholder for the dedicated CPPI IRQ */
  40. .flags = IORESOURCE_IRQ,
  41. .name = "dma"
  42. },
  43. };
  44. static u64 usb_dmamask = DMA_BIT_MASK(32);
  45. static struct platform_device usb_dev = {
  46. .name = "musb-davinci",
  47. .id = -1,
  48. .dev = {
  49. .platform_data = &usb_data,
  50. .dma_mask = &usb_dmamask,
  51. .coherent_dma_mask = DMA_BIT_MASK(32),
  52. },
  53. .resource = usb_resources,
  54. .num_resources = ARRAY_SIZE(usb_resources),
  55. };
  56. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  57. {
  58. usb_data.power = mA > 510 ? 255 : mA / 2;
  59. usb_data.potpgt = (potpgt_ms + 1) / 2;
  60. if (cpu_is_davinci_dm646x()) {
  61. /* Override the defaults as DM6467 uses different IRQs. */
  62. usb_dev.resource[1].start = IRQ_DM646X_USBINT;
  63. usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
  64. } else /* other devices don't have dedicated CPPI IRQ */
  65. usb_dev.num_resources = 2;
  66. platform_device_register(&usb_dev);
  67. }
  68. #else
  69. void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
  70. {
  71. }
  72. #endif /* CONFIG_USB_MUSB_HDRC */