usb.c 1.9 KB

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