Commit | Line | Data |
---|---|---|
cece6e5a DB |
1 | /* |
2 | * USB | |
3 | */ | |
cece6e5a DB |
4 | #include <linux/init.h> |
5 | #include <linux/platform_device.h> | |
6 | #include <linux/dma-mapping.h> | |
7 | ||
8 | #include <linux/usb/musb.h> | |
cece6e5a DB |
9 | |
10 | #include <mach/common.h> | |
d0e58ae7 | 11 | #include <mach/irqs.h> |
efd91181 | 12 | #include <mach/cputype.h> |
ec2a0833 | 13 | #include <linux/platform_data/usb-davinci.h> |
cece6e5a | 14 | |
e5d3d252 | 15 | #define DAVINCI_USB_OTG_BASE 0x01c64000 |
b0ea26e1 SS |
16 | |
17 | #define DA8XX_USB0_BASE 0x01e00000 | |
e5d3d252 | 18 | #define DA8XX_USB1_BASE 0x01e25000 |
f5c122da | 19 | |
cece6e5a DB |
20 | #if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) |
21 | static struct musb_hdrc_eps_bits musb_eps[] = { | |
22 | { "ep1_tx", 8, }, | |
23 | { "ep1_rx", 8, }, | |
24 | { "ep2_tx", 8, }, | |
25 | { "ep2_rx", 8, }, | |
26 | { "ep3_tx", 5, }, | |
27 | { "ep3_rx", 5, }, | |
28 | { "ep4_tx", 5, }, | |
29 | { "ep4_rx", 5, }, | |
30 | }; | |
31 | ||
32 | static struct musb_hdrc_config musb_config = { | |
33 | .multipoint = true, | |
34 | .dyn_fifo = true, | |
35 | .soft_con = true, | |
36 | .dma = true, | |
37 | ||
38 | .num_eps = 5, | |
39 | .dma_channels = 8, | |
40 | .ram_bits = 10, | |
41 | .eps_bits = musb_eps, | |
42 | }; | |
43 | ||
44 | static struct musb_hdrc_platform_data usb_data = { | |
cece6e5a DB |
45 | /* OTG requires a Mini-AB connector */ |
46 | .mode = MUSB_OTG, | |
34f32c97 | 47 | .clock = "usb", |
cece6e5a DB |
48 | .config = &musb_config, |
49 | }; | |
50 | ||
51 | static struct resource usb_resources[] = { | |
52 | { | |
53 | /* physical address */ | |
54 | .start = DAVINCI_USB_OTG_BASE, | |
55 | .end = DAVINCI_USB_OTG_BASE + 0x5ff, | |
56 | .flags = IORESOURCE_MEM, | |
57 | }, | |
58 | { | |
59 | .start = IRQ_USBINT, | |
60 | .flags = IORESOURCE_IRQ, | |
fcf173e4 | 61 | .name = "mc" |
cece6e5a | 62 | }, |
efd91181 SS |
63 | { |
64 | /* placeholder for the dedicated CPPI IRQ */ | |
65 | .flags = IORESOURCE_IRQ, | |
fcf173e4 | 66 | .name = "dma" |
efd91181 | 67 | }, |
cece6e5a DB |
68 | }; |
69 | ||
284901a9 | 70 | static u64 usb_dmamask = DMA_BIT_MASK(32); |
cece6e5a DB |
71 | |
72 | static struct platform_device usb_dev = { | |
73b089b0 | 73 | .name = "musb-davinci", |
cece6e5a DB |
74 | .id = -1, |
75 | .dev = { | |
76 | .platform_data = &usb_data, | |
77 | .dma_mask = &usb_dmamask, | |
284901a9 | 78 | .coherent_dma_mask = DMA_BIT_MASK(32), |
cece6e5a DB |
79 | }, |
80 | .resource = usb_resources, | |
81 | .num_resources = ARRAY_SIZE(usb_resources), | |
82 | }; | |
83 | ||
355fb4e3 | 84 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
cece6e5a | 85 | { |
355fb4e3 SS |
86 | usb_data.power = mA > 510 ? 255 : mA / 2; |
87 | usb_data.potpgt = (potpgt_ms + 1) / 2; | |
efd91181 SS |
88 | |
89 | if (cpu_is_davinci_dm646x()) { | |
90 | /* Override the defaults as DM6467 uses different IRQs. */ | |
91 | usb_dev.resource[1].start = IRQ_DM646X_USBINT; | |
92 | usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; | |
93 | } else /* other devices don't have dedicated CPPI IRQ */ | |
94 | usb_dev.num_resources = 2; | |
95 | ||
cece6e5a DB |
96 | platform_device_register(&usb_dev); |
97 | } | |
98 | ||
b0ea26e1 SS |
99 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
100 | static struct resource da8xx_usb20_resources[] = { | |
101 | { | |
102 | .start = DA8XX_USB0_BASE, | |
103 | .end = DA8XX_USB0_BASE + SZ_64K - 1, | |
104 | .flags = IORESOURCE_MEM, | |
105 | }, | |
106 | { | |
107 | .start = IRQ_DA8XX_USB_INT, | |
108 | .flags = IORESOURCE_IRQ, | |
5a166f4f | 109 | .name = "mc", |
b0ea26e1 SS |
110 | }, |
111 | }; | |
112 | ||
113 | int __init da8xx_register_usb20(unsigned mA, unsigned potpgt) | |
114 | { | |
115 | usb_data.clock = "usb20"; | |
116 | usb_data.power = mA > 510 ? 255 : mA / 2; | |
117 | usb_data.potpgt = (potpgt + 1) / 2; | |
118 | ||
119 | usb_dev.resource = da8xx_usb20_resources; | |
120 | usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources); | |
8ceae51e | 121 | usb_dev.name = "musb-da8xx"; |
b0ea26e1 SS |
122 | |
123 | return platform_device_register(&usb_dev); | |
124 | } | |
125 | #endif /* CONFIG_DAVINCI_DA8XX */ | |
126 | ||
cece6e5a DB |
127 | #else |
128 | ||
355fb4e3 | 129 | void __init davinci_setup_usb(unsigned mA, unsigned potpgt_ms) |
cece6e5a DB |
130 | { |
131 | } | |
132 | ||
b0ea26e1 SS |
133 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
134 | int __init da8xx_register_usb20(unsigned mA, unsigned potpgt) | |
135 | { | |
136 | return 0; | |
137 | } | |
138 | #endif | |
139 | ||
cece6e5a DB |
140 | #endif /* CONFIG_USB_MUSB_HDRC */ |
141 | ||
e5d3d252 SS |
142 | #ifdef CONFIG_ARCH_DAVINCI_DA8XX |
143 | static struct resource da8xx_usb11_resources[] = { | |
144 | [0] = { | |
145 | .start = DA8XX_USB1_BASE, | |
146 | .end = DA8XX_USB1_BASE + SZ_4K - 1, | |
147 | .flags = IORESOURCE_MEM, | |
148 | }, | |
149 | [1] = { | |
150 | .start = IRQ_DA8XX_IRQN, | |
151 | .end = IRQ_DA8XX_IRQN, | |
152 | .flags = IORESOURCE_IRQ, | |
153 | }, | |
154 | }; | |
155 | ||
156 | static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); | |
157 | ||
158 | static struct platform_device da8xx_usb11_device = { | |
159 | .name = "ohci", | |
160 | .id = 0, | |
161 | .dev = { | |
162 | .dma_mask = &da8xx_usb11_dma_mask, | |
163 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
164 | }, | |
165 | .num_resources = ARRAY_SIZE(da8xx_usb11_resources), | |
166 | .resource = da8xx_usb11_resources, | |
167 | }; | |
168 | ||
169 | int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) | |
170 | { | |
171 | da8xx_usb11_device.dev.platform_data = pdata; | |
172 | return platform_device_register(&da8xx_usb11_device); | |
173 | } | |
174 | #endif /* CONFIG_DAVINCI_DA8XX */ |