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