Commit | Line | Data |
---|---|---|
73a59c1c SP |
1 | /* |
2 | * arch/arm/mach-at91rm9200/devices.c | |
3 | * | |
4 | * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org> | |
5 | * Copyright (C) 2005 David Brownell | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | */ | |
13 | #include <asm/mach/arch.h> | |
14 | #include <asm/mach/map.h> | |
15 | ||
16 | #include <linux/config.h> | |
17 | #include <linux/platform_device.h> | |
18 | ||
19 | #include <asm/arch/board.h> | |
20 | #include <asm/arch/pio.h> | |
21 | ||
22 | ||
23 | /* -------------------------------------------------------------------- | |
24 | * USB Host | |
25 | * -------------------------------------------------------------------- */ | |
26 | ||
27 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
28 | static u64 ohci_dmamask = 0xffffffffUL; | |
29 | static struct at91_usbh_data usbh_data; | |
30 | ||
3267c077 | 31 | static struct resource at91_usbh_resource[] = { |
73a59c1c SP |
32 | [0] = { |
33 | .start = AT91_UHP_BASE, | |
3267c077 | 34 | .end = AT91_UHP_BASE + SZ_1M - 1, |
73a59c1c SP |
35 | .flags = IORESOURCE_MEM, |
36 | }, | |
37 | [1] = { | |
38 | .start = AT91_ID_UHP, | |
39 | .end = AT91_ID_UHP, | |
40 | .flags = IORESOURCE_IRQ, | |
41 | }, | |
42 | }; | |
43 | ||
44 | static struct platform_device at91rm9200_usbh_device = { | |
45 | .name = "at91rm9200-ohci", | |
46 | .id = -1, | |
47 | .dev = { | |
48 | .dma_mask = &ohci_dmamask, | |
49 | .coherent_dma_mask = 0xffffffff, | |
50 | .platform_data = &usbh_data, | |
51 | }, | |
3267c077 AV |
52 | .resource = at91_usbh_resource, |
53 | .num_resources = ARRAY_SIZE(at91_usbh_resource), | |
73a59c1c SP |
54 | }; |
55 | ||
56 | void __init at91_add_device_usbh(struct at91_usbh_data *data) | |
57 | { | |
58 | if (!data) | |
59 | return; | |
60 | ||
61 | usbh_data = *data; | |
62 | platform_device_register(&at91rm9200_usbh_device); | |
63 | } | |
64 | #else | |
65 | void __init at91_add_device_usbh(struct at91_usbh_data *data) {} | |
66 | #endif | |
67 | ||
68 | ||
69 | /* -------------------------------------------------------------------- | |
70 | * USB Device (Gadget) | |
71 | * -------------------------------------------------------------------- */ | |
72 | ||
73 | #ifdef CONFIG_USB_GADGET_AT91 | |
74 | static struct at91_udc_data udc_data; | |
75 | ||
76 | static struct resource at91_udc_resources[] = { | |
77 | { | |
78 | .start = AT91_BASE_UDP, | |
79 | .end = AT91_BASE_UDP + SZ_16K - 1, | |
80 | .flags = IORESOURCE_MEM, | |
81 | } | |
82 | }; | |
83 | ||
84 | static struct platform_device at91rm9200_udc_device = { | |
85 | .name = "at91_udc", | |
86 | .id = -1, | |
87 | .dev = { | |
88 | .platform_data = &udc_data, | |
89 | }, | |
90 | .resource = at91_udc_resources, | |
91 | .num_resources = ARRAY_SIZE(at91_udc_resources), | |
92 | }; | |
93 | ||
94 | void __init at91_add_device_udc(struct at91_udc_data *data) | |
95 | { | |
96 | if (!data) | |
97 | return; | |
98 | ||
99 | if (data->vbus_pin) { | |
100 | at91_set_gpio_input(data->vbus_pin, 0); | |
101 | at91_set_deglitch(data->vbus_pin, 1); | |
102 | } | |
df666b9c | 103 | if (data->pullup_pin) { |
73a59c1c | 104 | at91_set_gpio_output(data->pullup_pin, 0); |
df666b9c AV |
105 | at91_set_multi_drive(data->pullup_pin, 1); |
106 | } | |
73a59c1c SP |
107 | |
108 | udc_data = *data; | |
109 | platform_device_register(&at91rm9200_udc_device); | |
110 | } | |
111 | #else | |
112 | void __init at91_add_device_udc(struct at91_udc_data *data) {} | |
113 | #endif | |
114 | ||
115 | ||
116 | /* -------------------------------------------------------------------- | |
117 | * Ethernet | |
118 | * -------------------------------------------------------------------- */ | |
119 | ||
120 | #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE) | |
121 | static u64 eth_dmamask = 0xffffffffUL; | |
122 | static struct at91_eth_data eth_data; | |
123 | ||
3267c077 AV |
124 | static struct resource at91_eth_resources[] = { |
125 | [0] = { | |
126 | .start = AT91_BASE_EMAC, | |
127 | .end = AT91_BASE_EMAC + SZ_16K - 1, | |
128 | .flags = IORESOURCE_MEM, | |
129 | }, | |
130 | [1] = { | |
131 | .start = AT91_ID_EMAC, | |
132 | .end = AT91_ID_EMAC, | |
133 | .flags = IORESOURCE_IRQ, | |
134 | }, | |
135 | }; | |
136 | ||
73a59c1c SP |
137 | static struct platform_device at91rm9200_eth_device = { |
138 | .name = "at91_ether", | |
139 | .id = -1, | |
140 | .dev = { | |
141 | .dma_mask = ð_dmamask, | |
142 | .coherent_dma_mask = 0xffffffff, | |
143 | .platform_data = ð_data, | |
144 | }, | |
3267c077 AV |
145 | .resource = at91_eth_resources, |
146 | .num_resources = ARRAY_SIZE(at91_eth_resources), | |
73a59c1c SP |
147 | }; |
148 | ||
149 | void __init at91_add_device_eth(struct at91_eth_data *data) | |
150 | { | |
151 | if (!data) | |
152 | return; | |
153 | ||
154 | if (data->phy_irq_pin) { | |
155 | at91_set_gpio_input(data->phy_irq_pin, 0); | |
156 | at91_set_deglitch(data->phy_irq_pin, 1); | |
157 | } | |
158 | ||
159 | /* Pins used for MII and RMII */ | |
160 | at91_set_A_periph(AT91_PIN_PA16, 0); /* EMDIO */ | |
161 | at91_set_A_periph(AT91_PIN_PA15, 0); /* EMDC */ | |
162 | at91_set_A_periph(AT91_PIN_PA14, 0); /* ERXER */ | |
163 | at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */ | |
164 | at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */ | |
165 | at91_set_A_periph(AT91_PIN_PA11, 0); /* ECRS_ECRSDV */ | |
166 | at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX1 */ | |
167 | at91_set_A_periph(AT91_PIN_PA9, 0); /* ETX0 */ | |
168 | at91_set_A_periph(AT91_PIN_PA8, 0); /* ETXEN */ | |
169 | at91_set_A_periph(AT91_PIN_PA7, 0); /* ETXCK_EREFCK */ | |
170 | ||
171 | if (!data->is_rmii) { | |
172 | at91_set_B_periph(AT91_PIN_PB19, 0); /* ERXCK */ | |
173 | at91_set_B_periph(AT91_PIN_PB18, 0); /* ECOL */ | |
174 | at91_set_B_periph(AT91_PIN_PB17, 0); /* ERXDV */ | |
175 | at91_set_B_periph(AT91_PIN_PB16, 0); /* ERX3 */ | |
176 | at91_set_B_periph(AT91_PIN_PB15, 0); /* ERX2 */ | |
177 | at91_set_B_periph(AT91_PIN_PB14, 0); /* ETXER */ | |
178 | at91_set_B_periph(AT91_PIN_PB13, 0); /* ETX3 */ | |
179 | at91_set_B_periph(AT91_PIN_PB12, 0); /* ETX2 */ | |
180 | } | |
181 | ||
182 | eth_data = *data; | |
183 | platform_device_register(&at91rm9200_eth_device); | |
184 | } | |
185 | #else | |
186 | void __init at91_add_device_eth(struct at91_eth_data *data) {} | |
187 | #endif | |
188 | ||
189 | ||
190 | /* -------------------------------------------------------------------- | |
191 | * Compact Flash / PCMCIA | |
192 | * -------------------------------------------------------------------- */ | |
193 | ||
194 | #if defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE) | |
195 | static struct at91_cf_data cf_data; | |
196 | ||
2c536200 DB |
197 | static struct resource at91_cf_resources[] = { |
198 | [0] = { | |
199 | .start = AT91_CF_BASE, | |
200 | /* ties up CS4, CS5, and CS6 */ | |
201 | .end = AT91_CF_BASE + (0x30000000 - 1), | |
202 | .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, | |
203 | }, | |
204 | }; | |
205 | ||
73a59c1c SP |
206 | static struct platform_device at91rm9200_cf_device = { |
207 | .name = "at91_cf", | |
208 | .id = -1, | |
209 | .dev = { | |
210 | .platform_data = &cf_data, | |
211 | }, | |
2c536200 DB |
212 | .resource = at91_cf_resources, |
213 | .num_resources = ARRAY_SIZE(at91_cf_resources), | |
73a59c1c SP |
214 | }; |
215 | ||
216 | void __init at91_add_device_cf(struct at91_cf_data *data) | |
217 | { | |
218 | if (!data) | |
219 | return; | |
220 | ||
221 | /* input/irq */ | |
222 | if (data->irq_pin) { | |
223 | at91_set_gpio_input(data->irq_pin, 1); | |
224 | at91_set_deglitch(data->irq_pin, 1); | |
225 | } | |
226 | at91_set_gpio_input(data->det_pin, 1); | |
227 | at91_set_deglitch(data->det_pin, 1); | |
228 | ||
229 | /* outputs, initially off */ | |
230 | if (data->vcc_pin) | |
231 | at91_set_gpio_output(data->vcc_pin, 0); | |
232 | at91_set_gpio_output(data->rst_pin, 0); | |
233 | ||
234 | cf_data = *data; | |
235 | platform_device_register(&at91rm9200_cf_device); | |
236 | } | |
237 | #else | |
238 | void __init at91_add_device_cf(struct at91_cf_data *data) {} | |
239 | #endif | |
240 | ||
241 | ||
242 | /* -------------------------------------------------------------------- | |
243 | * MMC / SD | |
244 | * -------------------------------------------------------------------- */ | |
245 | ||
246 | #if defined(CONFIG_MMC_AT91RM9200) || defined(CONFIG_MMC_AT91RM9200_MODULE) | |
247 | static u64 mmc_dmamask = 0xffffffffUL; | |
248 | static struct at91_mmc_data mmc_data; | |
249 | ||
250 | static struct resource at91_mmc_resources[] = { | |
3267c077 | 251 | [0] = { |
73a59c1c SP |
252 | .start = AT91_BASE_MCI, |
253 | .end = AT91_BASE_MCI + SZ_16K - 1, | |
254 | .flags = IORESOURCE_MEM, | |
3267c077 AV |
255 | }, |
256 | [1] = { | |
257 | .start = AT91_ID_MCI, | |
258 | .end = AT91_ID_MCI, | |
259 | .flags = IORESOURCE_IRQ, | |
260 | }, | |
73a59c1c SP |
261 | }; |
262 | ||
263 | static struct platform_device at91rm9200_mmc_device = { | |
3267c077 | 264 | .name = "at91_mci", |
73a59c1c SP |
265 | .id = -1, |
266 | .dev = { | |
267 | .dma_mask = &mmc_dmamask, | |
268 | .coherent_dma_mask = 0xffffffff, | |
269 | .platform_data = &mmc_data, | |
270 | }, | |
271 | .resource = at91_mmc_resources, | |
272 | .num_resources = ARRAY_SIZE(at91_mmc_resources), | |
273 | }; | |
274 | ||
275 | void __init at91_add_device_mmc(struct at91_mmc_data *data) | |
276 | { | |
277 | if (!data) | |
278 | return; | |
279 | ||
280 | /* input/irq */ | |
281 | if (data->det_pin) { | |
282 | at91_set_gpio_input(data->det_pin, 1); | |
283 | at91_set_deglitch(data->det_pin, 1); | |
284 | } | |
285 | if (data->wp_pin) | |
286 | at91_set_gpio_input(data->wp_pin, 1); | |
287 | ||
288 | /* CLK */ | |
289 | at91_set_A_periph(AT91_PIN_PA27, 0); | |
290 | ||
291 | if (data->is_b) { | |
292 | /* CMD */ | |
293 | at91_set_B_periph(AT91_PIN_PA8, 0); | |
294 | ||
295 | /* DAT0, maybe DAT1..DAT3 */ | |
296 | at91_set_B_periph(AT91_PIN_PA9, 0); | |
297 | if (data->wire4) { | |
298 | at91_set_B_periph(AT91_PIN_PA10, 0); | |
299 | at91_set_B_periph(AT91_PIN_PA11, 0); | |
300 | at91_set_B_periph(AT91_PIN_PA12, 0); | |
301 | } | |
302 | } else { | |
303 | /* CMD */ | |
304 | at91_set_A_periph(AT91_PIN_PA28, 0); | |
305 | ||
306 | /* DAT0, maybe DAT1..DAT3 */ | |
307 | at91_set_A_periph(AT91_PIN_PA29, 0); | |
308 | if (data->wire4) { | |
309 | at91_set_B_periph(AT91_PIN_PB3, 0); | |
310 | at91_set_B_periph(AT91_PIN_PB4, 0); | |
311 | at91_set_B_periph(AT91_PIN_PB5, 0); | |
312 | } | |
313 | } | |
314 | ||
315 | mmc_data = *data; | |
316 | platform_device_register(&at91rm9200_mmc_device); | |
317 | } | |
318 | #else | |
319 | void __init at91_add_device_mmc(struct at91_mmc_data *data) {} | |
320 | #endif | |
321 | ||
3267c077 AV |
322 | /* -------------------------------------------------------------------- |
323 | * NAND / SmartMedia | |
324 | * -------------------------------------------------------------------- */ | |
325 | ||
326 | #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) | |
327 | static struct at91_nand_data nand_data; | |
328 | ||
329 | static struct resource at91_nand_resources[] = { | |
330 | { | |
331 | .start = AT91_SMARTMEDIA_BASE, | |
332 | .end = AT91_SMARTMEDIA_BASE + SZ_8M - 1, | |
333 | .flags = IORESOURCE_MEM, | |
334 | } | |
335 | }; | |
336 | ||
337 | static struct platform_device at91_nand_device = { | |
338 | .name = "at91_nand", | |
339 | .id = -1, | |
340 | .dev = { | |
341 | .platform_data = &nand_data, | |
342 | }, | |
343 | .resource = at91_nand_resources, | |
344 | .num_resources = ARRAY_SIZE(at91_nand_resources), | |
345 | }; | |
346 | ||
347 | void __init at91_add_device_nand(struct at91_nand_data *data) | |
348 | { | |
349 | if (!data) | |
350 | return; | |
351 | ||
352 | /* enable pin */ | |
353 | if (data->enable_pin) | |
354 | at91_set_gpio_output(data->enable_pin, 1); | |
355 | ||
356 | /* ready/busy pin */ | |
357 | if (data->rdy_pin) | |
358 | at91_set_gpio_input(data->rdy_pin, 1); | |
359 | ||
360 | /* card detect pin */ | |
361 | if (data->det_pin) | |
362 | at91_set_gpio_input(data->det_pin, 1); | |
363 | ||
364 | at91_set_A_periph(AT91_PIN_PC1, 0); /* SMOE */ | |
365 | at91_set_A_periph(AT91_PIN_PC3, 0); /* SMWE */ | |
366 | ||
367 | nand_data = *data; | |
368 | platform_device_register(&at91_nand_device); | |
369 | } | |
370 | #else | |
371 | void __init at91_add_device_nand(struct at91_nand_data *data) {} | |
372 | #endif | |
373 | ||
374 | ||
375 | /* -------------------------------------------------------------------- | |
376 | * TWI (i2c) | |
377 | * -------------------------------------------------------------------- */ | |
378 | ||
379 | #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) | |
380 | static struct platform_device at91rm9200_twi_device = { | |
381 | .name = "at91_i2c", | |
382 | .id = -1, | |
383 | .num_resources = 0, | |
384 | }; | |
385 | ||
386 | void __init at91_add_device_i2c(void) | |
387 | { | |
388 | /* pins used for TWI interface */ | |
389 | at91_set_A_periph(AT91_PIN_PA25, 0); /* TWD */ | |
390 | at91_set_multi_drive(AT91_PIN_PA25, 1); | |
391 | ||
392 | at91_set_A_periph(AT91_PIN_PA26, 0); /* TWCK */ | |
393 | at91_set_multi_drive(AT91_PIN_PA26, 1); | |
394 | ||
395 | platform_device_register(&at91rm9200_twi_device); | |
396 | } | |
397 | #else | |
398 | void __init at91_add_device_i2c(void) {} | |
399 | #endif | |
400 | ||
401 | ||
402 | /* -------------------------------------------------------------------- | |
403 | * RTC | |
404 | * -------------------------------------------------------------------- */ | |
405 | ||
406 | #if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE) | |
407 | static struct platform_device at91rm9200_rtc_device = { | |
408 | .name = "at91_rtc", | |
409 | .id = -1, | |
410 | .num_resources = 0, | |
411 | }; | |
412 | ||
413 | void __init at91_add_device_rtc(void) | |
414 | { | |
415 | platform_device_register(&at91rm9200_rtc_device); | |
416 | } | |
417 | #else | |
418 | void __init at91_add_device_rtc(void) {} | |
419 | #endif | |
420 | ||
421 | ||
cc2832a1 AV |
422 | /* -------------------------------------------------------------------- |
423 | * LEDs | |
424 | * -------------------------------------------------------------------- */ | |
425 | ||
426 | #if defined(CONFIG_LEDS) | |
427 | u8 at91_leds_cpu; | |
428 | u8 at91_leds_timer; | |
429 | ||
430 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | |
431 | { | |
432 | at91_leds_cpu = cpu_led; | |
433 | at91_leds_timer = timer_led; | |
434 | } | |
435 | ||
436 | #else | |
437 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | |
438 | #endif | |
439 | ||
440 | ||
73a59c1c | 441 | /* -------------------------------------------------------------------- */ |