IB/srp: Let srp_abort() return FAST_IO_FAIL if TL offline
[linux/fpc-iii.git] / arch / arm / mach-davinci / usb.c
blobb0a6b522575f1e51c646f52bd7426a3fd81eef89
1 /*
2 * USB
3 */
4 #include <linux/init.h>
5 #include <linux/platform_device.h>
6 #include <linux/dma-mapping.h>
8 #include <linux/usb/musb.h>
10 #include <mach/common.h>
11 #include <mach/irqs.h>
12 #include <mach/cputype.h>
13 #include <mach/da8xx.h>
14 #include <linux/platform_data/usb-davinci.h>
16 #define DAVINCI_USB_OTG_BASE 0x01c64000
18 #define DA8XX_USB0_BASE 0x01e00000
19 #define DA8XX_USB1_BASE 0x01e25000
21 #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
22 static struct musb_hdrc_eps_bits musb_eps[] = {
23 { "ep1_tx", 8, },
24 { "ep1_rx", 8, },
25 { "ep2_tx", 8, },
26 { "ep2_rx", 8, },
27 { "ep3_tx", 5, },
28 { "ep3_rx", 5, },
29 { "ep4_tx", 5, },
30 { "ep4_rx", 5, },
33 static struct musb_hdrc_config musb_config = {
34 .multipoint = true,
35 .dyn_fifo = true,
36 .soft_con = true,
37 .dma = true,
39 .num_eps = 5,
40 .dma_channels = 8,
41 .ram_bits = 10,
42 .eps_bits = musb_eps,
45 static struct musb_hdrc_platform_data usb_data = {
46 /* OTG requires a Mini-AB connector */
47 .mode = MUSB_OTG,
48 .clock = "usb",
49 .config = &musb_config,
52 static struct resource usb_resources[] = {
54 /* physical address */
55 .start = DAVINCI_USB_OTG_BASE,
56 .end = DAVINCI_USB_OTG_BASE + 0x5ff,
57 .flags = IORESOURCE_MEM,
60 .start = IRQ_USBINT,
61 .flags = IORESOURCE_IRQ,
62 .name = "mc"
65 /* placeholder for the dedicated CPPI IRQ */
66 .flags = IORESOURCE_IRQ,
67 .name = "dma"
71 static u64 usb_dmamask = DMA_BIT_MASK(32);
73 static struct platform_device usb_dev = {
74 .name = "musb-davinci",
75 .id = -1,
76 .dev = {
77 .platform_data = &usb_data,
78 .dma_mask = &usb_dmamask,
79 .coherent_dma_mask = DMA_BIT_MASK(32),
81 .resource = usb_resources,
82 .num_resources = ARRAY_SIZE(usb_resources),
85 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
87 usb_data.power = mA > 510 ? 255 : mA / 2;
88 usb_data.potpgt = (potpgt_ms + 1) / 2;
90 if (cpu_is_davinci_dm646x()) {
91 /* Override the defaults as DM6467 uses different IRQs. */
92 usb_dev.resource[1].start = IRQ_DM646X_USBINT;
93 usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT;
94 } else /* other devices don't have dedicated CPPI IRQ */
95 usb_dev.num_resources = 2;
97 platform_device_register(&usb_dev);
100 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
101 static struct resource da8xx_usb20_resources[] = {
103 .start = DA8XX_USB0_BASE,
104 .end = DA8XX_USB0_BASE + SZ_64K - 1,
105 .flags = IORESOURCE_MEM,
108 .start = IRQ_DA8XX_USB_INT,
109 .flags = IORESOURCE_IRQ,
110 .name = "mc",
114 int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
116 usb_data.clock = "usb20";
117 usb_data.power = mA > 510 ? 255 : mA / 2;
118 usb_data.potpgt = (potpgt + 1) / 2;
120 usb_dev.resource = da8xx_usb20_resources;
121 usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources);
122 usb_dev.name = "musb-da8xx";
124 return platform_device_register(&usb_dev);
126 #endif /* CONFIG_DAVINCI_DA8XX */
128 #else
130 void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms)
134 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
135 int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)
137 return 0;
139 #endif
141 #endif /* CONFIG_USB_MUSB_HDRC */
143 #ifdef CONFIG_ARCH_DAVINCI_DA8XX
144 static struct resource da8xx_usb11_resources[] = {
145 [0] = {
146 .start = DA8XX_USB1_BASE,
147 .end = DA8XX_USB1_BASE + SZ_4K - 1,
148 .flags = IORESOURCE_MEM,
150 [1] = {
151 .start = IRQ_DA8XX_IRQN,
152 .end = IRQ_DA8XX_IRQN,
153 .flags = IORESOURCE_IRQ,
157 static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32);
159 static struct platform_device da8xx_usb11_device = {
160 .name = "ohci",
161 .id = 0,
162 .dev = {
163 .dma_mask = &da8xx_usb11_dma_mask,
164 .coherent_dma_mask = DMA_BIT_MASK(32),
166 .num_resources = ARRAY_SIZE(da8xx_usb11_resources),
167 .resource = da8xx_usb11_resources,
170 int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata)
172 da8xx_usb11_device.dev.platform_data = pdata;
173 return platform_device_register(&da8xx_usb11_device);
175 #endif /* CONFIG_DAVINCI_DA8XX */