Commit | Line | Data |
---|---|---|
b2c65616 AV |
1 | /* |
2 | * arch/arm/mach-at91/at91sam9263_devices.c | |
3 | * | |
4 | * Copyright (C) 2007 Atmel Corporation. | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | */ | |
12 | #include <asm/mach/arch.h> | |
13 | #include <asm/mach/map.h> | |
14 | ||
c6686ff9 | 15 | #include <linux/dma-mapping.h> |
b2c65616 | 16 | #include <linux/platform_device.h> |
f230d3f5 | 17 | #include <linux/i2c-gpio.h> |
b2c65616 | 18 | |
f230d3f5 | 19 | #include <linux/fb.h> |
b8b78609 JA |
20 | #include <video/atmel_lcdc.h> |
21 | ||
b2c65616 AV |
22 | #include <asm/arch/board.h> |
23 | #include <asm/arch/gpio.h> | |
24 | #include <asm/arch/at91sam9263.h> | |
25 | #include <asm/arch/at91sam926x_mc.h> | |
26 | #include <asm/arch/at91sam9263_matrix.h> | |
27 | ||
28 | #include "generic.h" | |
29 | ||
b2c65616 AV |
30 | |
31 | /* -------------------------------------------------------------------- | |
32 | * USB Host | |
33 | * -------------------------------------------------------------------- */ | |
34 | ||
35 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | |
c6686ff9 | 36 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
b2c65616 AV |
37 | static struct at91_usbh_data usbh_data; |
38 | ||
39 | static struct resource usbh_resources[] = { | |
40 | [0] = { | |
41 | .start = AT91SAM9263_UHP_BASE, | |
42 | .end = AT91SAM9263_UHP_BASE + SZ_1M - 1, | |
43 | .flags = IORESOURCE_MEM, | |
44 | }, | |
45 | [1] = { | |
46 | .start = AT91SAM9263_ID_UHP, | |
47 | .end = AT91SAM9263_ID_UHP, | |
48 | .flags = IORESOURCE_IRQ, | |
49 | }, | |
50 | }; | |
51 | ||
52 | static struct platform_device at91_usbh_device = { | |
53 | .name = "at91_ohci", | |
54 | .id = -1, | |
55 | .dev = { | |
56 | .dma_mask = &ohci_dmamask, | |
c6686ff9 | 57 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
58 | .platform_data = &usbh_data, |
59 | }, | |
60 | .resource = usbh_resources, | |
61 | .num_resources = ARRAY_SIZE(usbh_resources), | |
62 | }; | |
63 | ||
64 | void __init at91_add_device_usbh(struct at91_usbh_data *data) | |
65 | { | |
66 | int i; | |
67 | ||
68 | if (!data) | |
69 | return; | |
70 | ||
71 | /* Enable VBus control for UHP ports */ | |
72 | for (i = 0; i < data->ports; i++) { | |
73 | if (data->vbus_pin[i]) | |
74 | at91_set_gpio_output(data->vbus_pin[i], 0); | |
75 | } | |
76 | ||
77 | usbh_data = *data; | |
78 | platform_device_register(&at91_usbh_device); | |
79 | } | |
80 | #else | |
81 | void __init at91_add_device_usbh(struct at91_usbh_data *data) {} | |
82 | #endif | |
83 | ||
84 | ||
85 | /* -------------------------------------------------------------------- | |
86 | * USB Device (Gadget) | |
87 | * -------------------------------------------------------------------- */ | |
88 | ||
89 | #ifdef CONFIG_USB_GADGET_AT91 | |
90 | static struct at91_udc_data udc_data; | |
91 | ||
92 | static struct resource udc_resources[] = { | |
93 | [0] = { | |
94 | .start = AT91SAM9263_BASE_UDP, | |
95 | .end = AT91SAM9263_BASE_UDP + SZ_16K - 1, | |
96 | .flags = IORESOURCE_MEM, | |
97 | }, | |
98 | [1] = { | |
99 | .start = AT91SAM9263_ID_UDP, | |
100 | .end = AT91SAM9263_ID_UDP, | |
101 | .flags = IORESOURCE_IRQ, | |
102 | }, | |
103 | }; | |
104 | ||
105 | static struct platform_device at91_udc_device = { | |
106 | .name = "at91_udc", | |
107 | .id = -1, | |
108 | .dev = { | |
109 | .platform_data = &udc_data, | |
110 | }, | |
111 | .resource = udc_resources, | |
112 | .num_resources = ARRAY_SIZE(udc_resources), | |
113 | }; | |
114 | ||
115 | void __init at91_add_device_udc(struct at91_udc_data *data) | |
116 | { | |
117 | if (!data) | |
118 | return; | |
119 | ||
120 | if (data->vbus_pin) { | |
121 | at91_set_gpio_input(data->vbus_pin, 0); | |
122 | at91_set_deglitch(data->vbus_pin, 1); | |
123 | } | |
124 | ||
125 | /* Pullup pin is handled internally by USB device peripheral */ | |
126 | ||
127 | udc_data = *data; | |
128 | platform_device_register(&at91_udc_device); | |
129 | } | |
130 | #else | |
131 | void __init at91_add_device_udc(struct at91_udc_data *data) {} | |
132 | #endif | |
133 | ||
134 | ||
135 | /* -------------------------------------------------------------------- | |
136 | * Ethernet | |
137 | * -------------------------------------------------------------------- */ | |
138 | ||
139 | #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE) | |
c6686ff9 | 140 | static u64 eth_dmamask = DMA_BIT_MASK(32); |
b2c65616 AV |
141 | static struct at91_eth_data eth_data; |
142 | ||
143 | static struct resource eth_resources[] = { | |
144 | [0] = { | |
145 | .start = AT91SAM9263_BASE_EMAC, | |
146 | .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1, | |
147 | .flags = IORESOURCE_MEM, | |
148 | }, | |
149 | [1] = { | |
150 | .start = AT91SAM9263_ID_EMAC, | |
151 | .end = AT91SAM9263_ID_EMAC, | |
152 | .flags = IORESOURCE_IRQ, | |
153 | }, | |
154 | }; | |
155 | ||
156 | static struct platform_device at91sam9263_eth_device = { | |
157 | .name = "macb", | |
158 | .id = -1, | |
159 | .dev = { | |
160 | .dma_mask = ð_dmamask, | |
c6686ff9 | 161 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
162 | .platform_data = ð_data, |
163 | }, | |
164 | .resource = eth_resources, | |
165 | .num_resources = ARRAY_SIZE(eth_resources), | |
166 | }; | |
167 | ||
168 | void __init at91_add_device_eth(struct at91_eth_data *data) | |
169 | { | |
170 | if (!data) | |
171 | return; | |
172 | ||
173 | if (data->phy_irq_pin) { | |
174 | at91_set_gpio_input(data->phy_irq_pin, 0); | |
175 | at91_set_deglitch(data->phy_irq_pin, 1); | |
176 | } | |
177 | ||
178 | /* Pins used for MII and RMII */ | |
179 | at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */ | |
180 | at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */ | |
181 | at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */ | |
182 | at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */ | |
183 | at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */ | |
184 | at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */ | |
185 | at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */ | |
186 | at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */ | |
187 | at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */ | |
188 | at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */ | |
189 | ||
190 | if (!data->is_rmii) { | |
191 | at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */ | |
192 | at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */ | |
193 | at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */ | |
194 | at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */ | |
195 | at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */ | |
196 | at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */ | |
197 | at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */ | |
198 | at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */ | |
199 | } | |
200 | ||
201 | eth_data = *data; | |
202 | platform_device_register(&at91sam9263_eth_device); | |
203 | } | |
204 | #else | |
205 | void __init at91_add_device_eth(struct at91_eth_data *data) {} | |
206 | #endif | |
207 | ||
208 | ||
209 | /* -------------------------------------------------------------------- | |
210 | * MMC / SD | |
211 | * -------------------------------------------------------------------- */ | |
212 | ||
213 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) | |
c6686ff9 | 214 | static u64 mmc_dmamask = DMA_BIT_MASK(32); |
b2c65616 AV |
215 | static struct at91_mmc_data mmc0_data, mmc1_data; |
216 | ||
217 | static struct resource mmc0_resources[] = { | |
218 | [0] = { | |
219 | .start = AT91SAM9263_BASE_MCI0, | |
220 | .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1, | |
221 | .flags = IORESOURCE_MEM, | |
222 | }, | |
223 | [1] = { | |
224 | .start = AT91SAM9263_ID_MCI0, | |
225 | .end = AT91SAM9263_ID_MCI0, | |
226 | .flags = IORESOURCE_IRQ, | |
227 | }, | |
228 | }; | |
229 | ||
230 | static struct platform_device at91sam9263_mmc0_device = { | |
231 | .name = "at91_mci", | |
232 | .id = 0, | |
233 | .dev = { | |
234 | .dma_mask = &mmc_dmamask, | |
c6686ff9 | 235 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
236 | .platform_data = &mmc0_data, |
237 | }, | |
238 | .resource = mmc0_resources, | |
239 | .num_resources = ARRAY_SIZE(mmc0_resources), | |
240 | }; | |
241 | ||
242 | static struct resource mmc1_resources[] = { | |
243 | [0] = { | |
244 | .start = AT91SAM9263_BASE_MCI1, | |
245 | .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1, | |
246 | .flags = IORESOURCE_MEM, | |
247 | }, | |
248 | [1] = { | |
249 | .start = AT91SAM9263_ID_MCI1, | |
250 | .end = AT91SAM9263_ID_MCI1, | |
251 | .flags = IORESOURCE_IRQ, | |
252 | }, | |
253 | }; | |
254 | ||
255 | static struct platform_device at91sam9263_mmc1_device = { | |
256 | .name = "at91_mci", | |
257 | .id = 1, | |
258 | .dev = { | |
259 | .dma_mask = &mmc_dmamask, | |
c6686ff9 | 260 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
261 | .platform_data = &mmc1_data, |
262 | }, | |
263 | .resource = mmc1_resources, | |
264 | .num_resources = ARRAY_SIZE(mmc1_resources), | |
265 | }; | |
266 | ||
267 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) | |
268 | { | |
269 | if (!data) | |
270 | return; | |
271 | ||
272 | /* input/irq */ | |
273 | if (data->det_pin) { | |
274 | at91_set_gpio_input(data->det_pin, 1); | |
275 | at91_set_deglitch(data->det_pin, 1); | |
276 | } | |
277 | if (data->wp_pin) | |
278 | at91_set_gpio_input(data->wp_pin, 1); | |
279 | if (data->vcc_pin) | |
280 | at91_set_gpio_output(data->vcc_pin, 0); | |
281 | ||
282 | if (mmc_id == 0) { /* MCI0 */ | |
283 | /* CLK */ | |
284 | at91_set_A_periph(AT91_PIN_PA12, 0); | |
285 | ||
286 | if (data->slot_b) { | |
287 | /* CMD */ | |
288 | at91_set_A_periph(AT91_PIN_PA16, 1); | |
289 | ||
290 | /* DAT0, maybe DAT1..DAT3 */ | |
291 | at91_set_A_periph(AT91_PIN_PA17, 1); | |
292 | if (data->wire4) { | |
293 | at91_set_A_periph(AT91_PIN_PA18, 1); | |
294 | at91_set_A_periph(AT91_PIN_PA19, 1); | |
295 | at91_set_A_periph(AT91_PIN_PA20, 1); | |
296 | } | |
297 | } else { | |
298 | /* CMD */ | |
299 | at91_set_A_periph(AT91_PIN_PA1, 1); | |
300 | ||
301 | /* DAT0, maybe DAT1..DAT3 */ | |
302 | at91_set_A_periph(AT91_PIN_PA0, 1); | |
303 | if (data->wire4) { | |
304 | at91_set_A_periph(AT91_PIN_PA3, 1); | |
305 | at91_set_A_periph(AT91_PIN_PA4, 1); | |
306 | at91_set_A_periph(AT91_PIN_PA5, 1); | |
307 | } | |
308 | } | |
309 | ||
310 | mmc0_data = *data; | |
311 | at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); | |
312 | platform_device_register(&at91sam9263_mmc0_device); | |
313 | } else { /* MCI1 */ | |
314 | /* CLK */ | |
315 | at91_set_A_periph(AT91_PIN_PA6, 0); | |
316 | ||
317 | if (data->slot_b) { | |
318 | /* CMD */ | |
319 | at91_set_A_periph(AT91_PIN_PA21, 1); | |
320 | ||
321 | /* DAT0, maybe DAT1..DAT3 */ | |
322 | at91_set_A_periph(AT91_PIN_PA22, 1); | |
323 | if (data->wire4) { | |
324 | at91_set_A_periph(AT91_PIN_PA23, 1); | |
325 | at91_set_A_periph(AT91_PIN_PA24, 1); | |
326 | at91_set_A_periph(AT91_PIN_PA25, 1); | |
327 | } | |
328 | } else { | |
329 | /* CMD */ | |
330 | at91_set_A_periph(AT91_PIN_PA7, 1); | |
331 | ||
332 | /* DAT0, maybe DAT1..DAT3 */ | |
333 | at91_set_A_periph(AT91_PIN_PA8, 1); | |
334 | if (data->wire4) { | |
335 | at91_set_A_periph(AT91_PIN_PA9, 1); | |
336 | at91_set_A_periph(AT91_PIN_PA10, 1); | |
337 | at91_set_A_periph(AT91_PIN_PA11, 1); | |
338 | } | |
339 | } | |
340 | ||
341 | mmc1_data = *data; | |
342 | at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device.dev, "mci_clk"); | |
343 | platform_device_register(&at91sam9263_mmc1_device); | |
344 | } | |
345 | } | |
346 | #else | |
347 | void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {} | |
348 | #endif | |
349 | ||
350 | ||
351 | /* -------------------------------------------------------------------- | |
352 | * NAND / SmartMedia | |
353 | * -------------------------------------------------------------------- */ | |
354 | ||
355 | #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE) | |
356 | static struct at91_nand_data nand_data; | |
357 | ||
358 | #define NAND_BASE AT91_CHIPSELECT_3 | |
359 | ||
360 | static struct resource nand_resources[] = { | |
361 | { | |
362 | .start = NAND_BASE, | |
363 | .end = NAND_BASE + SZ_256M - 1, | |
364 | .flags = IORESOURCE_MEM, | |
365 | } | |
366 | }; | |
367 | ||
368 | static struct platform_device at91sam9263_nand_device = { | |
369 | .name = "at91_nand", | |
370 | .id = -1, | |
371 | .dev = { | |
372 | .platform_data = &nand_data, | |
373 | }, | |
374 | .resource = nand_resources, | |
375 | .num_resources = ARRAY_SIZE(nand_resources), | |
376 | }; | |
377 | ||
378 | void __init at91_add_device_nand(struct at91_nand_data *data) | |
379 | { | |
380 | unsigned long csa, mode; | |
381 | ||
382 | if (!data) | |
383 | return; | |
384 | ||
385 | csa = at91_sys_read(AT91_MATRIX_EBI0CSA); | |
386 | at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC); | |
387 | ||
388 | /* set the bus interface characteristics */ | |
389 | at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0) | |
390 | | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0)); | |
391 | ||
392 | at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3) | |
393 | | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3)); | |
394 | ||
395 | at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5)); | |
396 | ||
397 | if (data->bus_width_16) | |
398 | mode = AT91_SMC_DBW_16; | |
399 | else | |
400 | mode = AT91_SMC_DBW_8; | |
401 | at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(2)); | |
402 | ||
403 | /* enable pin */ | |
404 | if (data->enable_pin) | |
405 | at91_set_gpio_output(data->enable_pin, 1); | |
406 | ||
407 | /* ready/busy pin */ | |
408 | if (data->rdy_pin) | |
409 | at91_set_gpio_input(data->rdy_pin, 1); | |
410 | ||
411 | /* card detect pin */ | |
412 | if (data->det_pin) | |
413 | at91_set_gpio_input(data->det_pin, 1); | |
414 | ||
415 | nand_data = *data; | |
416 | platform_device_register(&at91sam9263_nand_device); | |
417 | } | |
418 | #else | |
419 | void __init at91_add_device_nand(struct at91_nand_data *data) {} | |
420 | #endif | |
421 | ||
422 | ||
423 | /* -------------------------------------------------------------------- | |
424 | * TWI (i2c) | |
425 | * -------------------------------------------------------------------- */ | |
426 | ||
f230d3f5 AV |
427 | /* |
428 | * Prefer the GPIO code since the TWI controller isn't robust | |
429 | * (gets overruns and underruns under load) and can only issue | |
430 | * repeated STARTs in one scenario (the driver doesn't yet handle them). | |
431 | */ | |
432 | #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE) | |
433 | ||
434 | static struct i2c_gpio_platform_data pdata = { | |
435 | .sda_pin = AT91_PIN_PB4, | |
436 | .sda_is_open_drain = 1, | |
437 | .scl_pin = AT91_PIN_PB5, | |
438 | .scl_is_open_drain = 1, | |
439 | .udelay = 2, /* ~100 kHz */ | |
440 | }; | |
441 | ||
442 | static struct platform_device at91sam9263_twi_device = { | |
443 | .name = "i2c-gpio", | |
444 | .id = -1, | |
445 | .dev.platform_data = &pdata, | |
446 | }; | |
447 | ||
448 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | |
449 | { | |
450 | at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */ | |
451 | at91_set_multi_drive(AT91_PIN_PB4, 1); | |
452 | ||
453 | at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */ | |
454 | at91_set_multi_drive(AT91_PIN_PB5, 1); | |
455 | ||
456 | i2c_register_board_info(0, devices, nr_devices); | |
457 | platform_device_register(&at91sam9263_twi_device); | |
458 | } | |
459 | ||
460 | #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE) | |
b2c65616 AV |
461 | |
462 | static struct resource twi_resources[] = { | |
463 | [0] = { | |
464 | .start = AT91SAM9263_BASE_TWI, | |
465 | .end = AT91SAM9263_BASE_TWI + SZ_16K - 1, | |
466 | .flags = IORESOURCE_MEM, | |
467 | }, | |
468 | [1] = { | |
469 | .start = AT91SAM9263_ID_TWI, | |
470 | .end = AT91SAM9263_ID_TWI, | |
471 | .flags = IORESOURCE_IRQ, | |
472 | }, | |
473 | }; | |
474 | ||
475 | static struct platform_device at91sam9263_twi_device = { | |
476 | .name = "at91_i2c", | |
477 | .id = -1, | |
478 | .resource = twi_resources, | |
479 | .num_resources = ARRAY_SIZE(twi_resources), | |
480 | }; | |
481 | ||
f230d3f5 | 482 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) |
b2c65616 AV |
483 | { |
484 | /* pins used for TWI interface */ | |
485 | at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */ | |
486 | at91_set_multi_drive(AT91_PIN_PB4, 1); | |
487 | ||
488 | at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */ | |
489 | at91_set_multi_drive(AT91_PIN_PB5, 1); | |
490 | ||
f230d3f5 | 491 | i2c_register_board_info(0, devices, nr_devices); |
b2c65616 AV |
492 | platform_device_register(&at91sam9263_twi_device); |
493 | } | |
494 | #else | |
f230d3f5 | 495 | void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {} |
b2c65616 AV |
496 | #endif |
497 | ||
498 | ||
499 | /* -------------------------------------------------------------------- | |
500 | * SPI | |
501 | * -------------------------------------------------------------------- */ | |
502 | ||
503 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) | |
c6686ff9 | 504 | static u64 spi_dmamask = DMA_BIT_MASK(32); |
b2c65616 AV |
505 | |
506 | static struct resource spi0_resources[] = { | |
507 | [0] = { | |
508 | .start = AT91SAM9263_BASE_SPI0, | |
509 | .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1, | |
510 | .flags = IORESOURCE_MEM, | |
511 | }, | |
512 | [1] = { | |
513 | .start = AT91SAM9263_ID_SPI0, | |
514 | .end = AT91SAM9263_ID_SPI0, | |
515 | .flags = IORESOURCE_IRQ, | |
516 | }, | |
517 | }; | |
518 | ||
519 | static struct platform_device at91sam9263_spi0_device = { | |
520 | .name = "atmel_spi", | |
521 | .id = 0, | |
522 | .dev = { | |
523 | .dma_mask = &spi_dmamask, | |
c6686ff9 | 524 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
525 | }, |
526 | .resource = spi0_resources, | |
527 | .num_resources = ARRAY_SIZE(spi0_resources), | |
528 | }; | |
529 | ||
530 | static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 }; | |
531 | ||
532 | static struct resource spi1_resources[] = { | |
533 | [0] = { | |
534 | .start = AT91SAM9263_BASE_SPI1, | |
535 | .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1, | |
536 | .flags = IORESOURCE_MEM, | |
537 | }, | |
538 | [1] = { | |
539 | .start = AT91SAM9263_ID_SPI1, | |
540 | .end = AT91SAM9263_ID_SPI1, | |
541 | .flags = IORESOURCE_IRQ, | |
542 | }, | |
543 | }; | |
544 | ||
545 | static struct platform_device at91sam9263_spi1_device = { | |
546 | .name = "atmel_spi", | |
547 | .id = 1, | |
548 | .dev = { | |
549 | .dma_mask = &spi_dmamask, | |
c6686ff9 | 550 | .coherent_dma_mask = DMA_BIT_MASK(32), |
b2c65616 AV |
551 | }, |
552 | .resource = spi1_resources, | |
553 | .num_resources = ARRAY_SIZE(spi1_resources), | |
554 | }; | |
555 | ||
556 | static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 }; | |
557 | ||
558 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |
559 | { | |
560 | int i; | |
561 | unsigned long cs_pin; | |
562 | short enable_spi0 = 0; | |
563 | short enable_spi1 = 0; | |
564 | ||
565 | /* Choose SPI chip-selects */ | |
566 | for (i = 0; i < nr_devices; i++) { | |
567 | if (devices[i].controller_data) | |
568 | cs_pin = (unsigned long) devices[i].controller_data; | |
569 | else if (devices[i].bus_num == 0) | |
570 | cs_pin = spi0_standard_cs[devices[i].chip_select]; | |
571 | else | |
572 | cs_pin = spi1_standard_cs[devices[i].chip_select]; | |
573 | ||
574 | if (devices[i].bus_num == 0) | |
575 | enable_spi0 = 1; | |
576 | else | |
577 | enable_spi1 = 1; | |
578 | ||
579 | /* enable chip-select pin */ | |
580 | at91_set_gpio_output(cs_pin, 1); | |
581 | ||
582 | /* pass chip-select pin to driver */ | |
583 | devices[i].controller_data = (void *) cs_pin; | |
584 | } | |
585 | ||
586 | spi_register_board_info(devices, nr_devices); | |
587 | ||
588 | /* Configure SPI bus(es) */ | |
589 | if (enable_spi0) { | |
590 | at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */ | |
591 | at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */ | |
7f6e2d99 | 592 | at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */ |
b2c65616 AV |
593 | |
594 | at91_clock_associate("spi0_clk", &at91sam9263_spi0_device.dev, "spi_clk"); | |
595 | platform_device_register(&at91sam9263_spi0_device); | |
596 | } | |
597 | if (enable_spi1) { | |
598 | at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */ | |
599 | at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */ | |
600 | at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */ | |
601 | ||
602 | at91_clock_associate("spi1_clk", &at91sam9263_spi1_device.dev, "spi_clk"); | |
603 | platform_device_register(&at91sam9263_spi1_device); | |
604 | } | |
605 | } | |
606 | #else | |
607 | void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {} | |
608 | #endif | |
609 | ||
610 | ||
7776a94c AV |
611 | /* -------------------------------------------------------------------- |
612 | * AC97 | |
613 | * -------------------------------------------------------------------- */ | |
614 | ||
615 | #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE) | |
c6686ff9 | 616 | static u64 ac97_dmamask = DMA_BIT_MASK(32); |
7776a94c AV |
617 | static struct atmel_ac97_data ac97_data; |
618 | ||
619 | static struct resource ac97_resources[] = { | |
620 | [0] = { | |
621 | .start = AT91SAM9263_BASE_AC97C, | |
622 | .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1, | |
623 | .flags = IORESOURCE_MEM, | |
624 | }, | |
625 | [1] = { | |
626 | .start = AT91SAM9263_ID_AC97C, | |
627 | .end = AT91SAM9263_ID_AC97C, | |
628 | .flags = IORESOURCE_IRQ, | |
629 | }, | |
630 | }; | |
631 | ||
632 | static struct platform_device at91sam9263_ac97_device = { | |
633 | .name = "ac97c", | |
634 | .id = 1, | |
635 | .dev = { | |
636 | .dma_mask = &ac97_dmamask, | |
c6686ff9 | 637 | .coherent_dma_mask = DMA_BIT_MASK(32), |
7776a94c AV |
638 | .platform_data = &ac97_data, |
639 | }, | |
640 | .resource = ac97_resources, | |
641 | .num_resources = ARRAY_SIZE(ac97_resources), | |
642 | }; | |
643 | ||
644 | void __init at91_add_device_ac97(struct atmel_ac97_data *data) | |
645 | { | |
646 | if (!data) | |
647 | return; | |
648 | ||
649 | at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */ | |
650 | at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */ | |
651 | at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */ | |
652 | at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */ | |
653 | ||
654 | /* reset */ | |
655 | if (data->reset_pin) | |
656 | at91_set_gpio_output(data->reset_pin, 0); | |
657 | ||
658 | ac97_data = *ek_data; | |
659 | platform_device_register(&at91sam9263_ac97_device); | |
660 | } | |
661 | #else | |
662 | void __init at91_add_device_ac97(struct atmel_ac97_data *data) {} | |
663 | #endif | |
664 | ||
665 | ||
666 | /* -------------------------------------------------------------------- | |
667 | * LCD Controller | |
668 | * -------------------------------------------------------------------- */ | |
669 | ||
670 | #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE) | |
c6686ff9 | 671 | static u64 lcdc_dmamask = DMA_BIT_MASK(32); |
7776a94c AV |
672 | static struct atmel_lcdfb_info lcdc_data; |
673 | ||
674 | static struct resource lcdc_resources[] = { | |
675 | [0] = { | |
676 | .start = AT91SAM9263_LCDC_BASE, | |
677 | .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1, | |
678 | .flags = IORESOURCE_MEM, | |
679 | }, | |
680 | [1] = { | |
681 | .start = AT91SAM9263_ID_LCDC, | |
682 | .end = AT91SAM9263_ID_LCDC, | |
683 | .flags = IORESOURCE_IRQ, | |
684 | }, | |
685 | }; | |
686 | ||
687 | static struct platform_device at91_lcdc_device = { | |
688 | .name = "atmel_lcdfb", | |
689 | .id = 0, | |
690 | .dev = { | |
691 | .dma_mask = &lcdc_dmamask, | |
c6686ff9 | 692 | .coherent_dma_mask = DMA_BIT_MASK(32), |
7776a94c AV |
693 | .platform_data = &lcdc_data, |
694 | }, | |
695 | .resource = lcdc_resources, | |
696 | .num_resources = ARRAY_SIZE(lcdc_resources), | |
697 | }; | |
698 | ||
699 | void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) | |
700 | { | |
701 | if (!data) | |
702 | return; | |
703 | ||
704 | at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */ | |
705 | at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */ | |
706 | at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */ | |
707 | at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */ | |
708 | at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */ | |
709 | at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */ | |
710 | at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */ | |
711 | at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */ | |
712 | at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */ | |
713 | at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */ | |
714 | at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */ | |
715 | at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */ | |
716 | at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */ | |
717 | at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */ | |
718 | at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */ | |
719 | at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */ | |
720 | at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */ | |
721 | at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */ | |
722 | at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */ | |
723 | at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */ | |
724 | at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */ | |
725 | at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */ | |
726 | ||
727 | lcdc_data = *data; | |
728 | platform_device_register(&at91_lcdc_device); | |
729 | } | |
730 | #else | |
731 | void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {} | |
732 | #endif | |
733 | ||
734 | ||
e2920802 AV |
735 | /* -------------------------------------------------------------------- |
736 | * Image Sensor Interface | |
737 | * -------------------------------------------------------------------- */ | |
738 | ||
739 | #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE) | |
740 | ||
741 | struct resource isi_resources[] = { | |
742 | [0] = { | |
743 | .start = AT91SAM9263_BASE_ISI, | |
744 | .end = AT91SAM9263_BASE_ISI + SZ_16K - 1, | |
745 | .flags = IORESOURCE_MEM, | |
746 | }, | |
747 | [1] = { | |
748 | .start = AT91SAM9263_ID_ISI, | |
749 | .end = AT91SAM9263_ID_ISI, | |
750 | .flags = IORESOURCE_IRQ, | |
751 | }, | |
752 | }; | |
753 | ||
754 | static struct platform_device at91sam9263_isi_device = { | |
755 | .name = "at91_isi", | |
756 | .id = -1, | |
757 | .resource = isi_resources, | |
758 | .num_resources = ARRAY_SIZE(isi_resources), | |
759 | }; | |
760 | ||
761 | void __init at91_add_device_isi(void) | |
762 | { | |
763 | at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */ | |
764 | at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */ | |
765 | at91_set_A_periph(AT91_PIN_PE2, 0); /* ISI_D2 */ | |
766 | at91_set_A_periph(AT91_PIN_PE3, 0); /* ISI_D3 */ | |
767 | at91_set_A_periph(AT91_PIN_PE4, 0); /* ISI_D4 */ | |
768 | at91_set_A_periph(AT91_PIN_PE5, 0); /* ISI_D5 */ | |
769 | at91_set_A_periph(AT91_PIN_PE6, 0); /* ISI_D6 */ | |
770 | at91_set_A_periph(AT91_PIN_PE7, 0); /* ISI_D7 */ | |
771 | at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */ | |
772 | at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */ | |
773 | at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */ | |
774 | at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */ | |
775 | at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */ | |
776 | at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */ | |
777 | at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */ | |
778 | at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */ | |
779 | } | |
780 | #else | |
781 | void __init at91_add_device_isi(void) {} | |
782 | #endif | |
783 | ||
784 | ||
884f5a6a AV |
785 | /* -------------------------------------------------------------------- |
786 | * RTT | |
787 | * -------------------------------------------------------------------- */ | |
788 | ||
789 | static struct resource rtt0_resources[] = { | |
790 | { | |
791 | .start = AT91_BASE_SYS + AT91_RTT0, | |
792 | .end = AT91_BASE_SYS + AT91_RTT0 + SZ_16 - 1, | |
793 | .flags = IORESOURCE_MEM, | |
794 | } | |
795 | }; | |
796 | ||
797 | static struct platform_device at91sam9263_rtt0_device = { | |
798 | .name = "at91_rtt", | |
799 | .id = 0, | |
800 | .resource = rtt0_resources, | |
801 | .num_resources = ARRAY_SIZE(rtt0_resources), | |
802 | }; | |
803 | ||
804 | static struct resource rtt1_resources[] = { | |
805 | { | |
806 | .start = AT91_BASE_SYS + AT91_RTT1, | |
807 | .end = AT91_BASE_SYS + AT91_RTT1 + SZ_16 - 1, | |
808 | .flags = IORESOURCE_MEM, | |
809 | } | |
810 | }; | |
811 | ||
812 | static struct platform_device at91sam9263_rtt1_device = { | |
813 | .name = "at91_rtt", | |
814 | .id = 1, | |
815 | .resource = rtt1_resources, | |
816 | .num_resources = ARRAY_SIZE(rtt1_resources), | |
817 | }; | |
818 | ||
819 | static void __init at91_add_device_rtt(void) | |
820 | { | |
821 | platform_device_register(&at91sam9263_rtt0_device); | |
822 | platform_device_register(&at91sam9263_rtt1_device); | |
823 | } | |
824 | ||
825 | ||
826 | /* -------------------------------------------------------------------- | |
827 | * Watchdog | |
828 | * -------------------------------------------------------------------- */ | |
829 | ||
830 | #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE) | |
831 | static struct platform_device at91sam9263_wdt_device = { | |
832 | .name = "at91_wdt", | |
833 | .id = -1, | |
834 | .num_resources = 0, | |
835 | }; | |
836 | ||
837 | static void __init at91_add_device_watchdog(void) | |
838 | { | |
839 | platform_device_register(&at91sam9263_wdt_device); | |
840 | } | |
841 | #else | |
842 | static void __init at91_add_device_watchdog(void) {} | |
843 | #endif | |
844 | ||
845 | ||
b2c65616 AV |
846 | /* -------------------------------------------------------------------- |
847 | * LEDs | |
848 | * -------------------------------------------------------------------- */ | |
849 | ||
850 | #if defined(CONFIG_LEDS) | |
851 | u8 at91_leds_cpu; | |
852 | u8 at91_leds_timer; | |
853 | ||
854 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | |
855 | { | |
856 | /* Enable GPIO to access the LEDs */ | |
857 | at91_set_gpio_output(cpu_led, 1); | |
858 | at91_set_gpio_output(timer_led, 1); | |
859 | ||
860 | at91_leds_cpu = cpu_led; | |
861 | at91_leds_timer = timer_led; | |
862 | } | |
863 | #else | |
864 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | |
865 | #endif | |
866 | ||
867 | ||
868 | /* -------------------------------------------------------------------- | |
869 | * UART | |
870 | * -------------------------------------------------------------------- */ | |
871 | ||
872 | #if defined(CONFIG_SERIAL_ATMEL) | |
873 | ||
874 | static struct resource dbgu_resources[] = { | |
875 | [0] = { | |
876 | .start = AT91_VA_BASE_SYS + AT91_DBGU, | |
877 | .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1, | |
878 | .flags = IORESOURCE_MEM, | |
879 | }, | |
880 | [1] = { | |
881 | .start = AT91_ID_SYS, | |
882 | .end = AT91_ID_SYS, | |
883 | .flags = IORESOURCE_IRQ, | |
884 | }, | |
885 | }; | |
886 | ||
887 | static struct atmel_uart_data dbgu_data = { | |
888 | .use_dma_tx = 0, | |
889 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | |
890 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), | |
891 | }; | |
892 | ||
c6686ff9 AV |
893 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
894 | ||
b2c65616 AV |
895 | static struct platform_device at91sam9263_dbgu_device = { |
896 | .name = "atmel_usart", | |
897 | .id = 0, | |
898 | .dev = { | |
c6686ff9 AV |
899 | .dma_mask = &dbgu_dmamask, |
900 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
901 | .platform_data = &dbgu_data, | |
b2c65616 AV |
902 | }, |
903 | .resource = dbgu_resources, | |
904 | .num_resources = ARRAY_SIZE(dbgu_resources), | |
905 | }; | |
906 | ||
907 | static inline void configure_dbgu_pins(void) | |
908 | { | |
909 | at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */ | |
910 | at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */ | |
911 | } | |
912 | ||
913 | static struct resource uart0_resources[] = { | |
914 | [0] = { | |
915 | .start = AT91SAM9263_BASE_US0, | |
916 | .end = AT91SAM9263_BASE_US0 + SZ_16K - 1, | |
917 | .flags = IORESOURCE_MEM, | |
918 | }, | |
919 | [1] = { | |
920 | .start = AT91SAM9263_ID_US0, | |
921 | .end = AT91SAM9263_ID_US0, | |
922 | .flags = IORESOURCE_IRQ, | |
923 | }, | |
924 | }; | |
925 | ||
926 | static struct atmel_uart_data uart0_data = { | |
927 | .use_dma_tx = 1, | |
928 | .use_dma_rx = 1, | |
929 | }; | |
930 | ||
c6686ff9 AV |
931 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
932 | ||
b2c65616 AV |
933 | static struct platform_device at91sam9263_uart0_device = { |
934 | .name = "atmel_usart", | |
935 | .id = 1, | |
936 | .dev = { | |
c6686ff9 AV |
937 | .dma_mask = &uart0_dmamask, |
938 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
939 | .platform_data = &uart0_data, | |
b2c65616 AV |
940 | }, |
941 | .resource = uart0_resources, | |
942 | .num_resources = ARRAY_SIZE(uart0_resources), | |
943 | }; | |
944 | ||
945 | static inline void configure_usart0_pins(void) | |
946 | { | |
947 | at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */ | |
948 | at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */ | |
949 | at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */ | |
950 | at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */ | |
951 | } | |
952 | ||
953 | static struct resource uart1_resources[] = { | |
954 | [0] = { | |
955 | .start = AT91SAM9263_BASE_US1, | |
956 | .end = AT91SAM9263_BASE_US1 + SZ_16K - 1, | |
957 | .flags = IORESOURCE_MEM, | |
958 | }, | |
959 | [1] = { | |
960 | .start = AT91SAM9263_ID_US1, | |
961 | .end = AT91SAM9263_ID_US1, | |
962 | .flags = IORESOURCE_IRQ, | |
963 | }, | |
964 | }; | |
965 | ||
966 | static struct atmel_uart_data uart1_data = { | |
967 | .use_dma_tx = 1, | |
968 | .use_dma_rx = 1, | |
969 | }; | |
970 | ||
c6686ff9 AV |
971 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
972 | ||
b2c65616 AV |
973 | static struct platform_device at91sam9263_uart1_device = { |
974 | .name = "atmel_usart", | |
975 | .id = 2, | |
976 | .dev = { | |
c6686ff9 AV |
977 | .dma_mask = &uart1_dmamask, |
978 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
979 | .platform_data = &uart1_data, | |
b2c65616 AV |
980 | }, |
981 | .resource = uart1_resources, | |
982 | .num_resources = ARRAY_SIZE(uart1_resources), | |
983 | }; | |
984 | ||
985 | static inline void configure_usart1_pins(void) | |
986 | { | |
987 | at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ | |
988 | at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ | |
989 | at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ | |
990 | at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ | |
991 | } | |
992 | ||
993 | static struct resource uart2_resources[] = { | |
994 | [0] = { | |
995 | .start = AT91SAM9263_BASE_US2, | |
996 | .end = AT91SAM9263_BASE_US2 + SZ_16K - 1, | |
997 | .flags = IORESOURCE_MEM, | |
998 | }, | |
999 | [1] = { | |
1000 | .start = AT91SAM9263_ID_US2, | |
1001 | .end = AT91SAM9263_ID_US2, | |
1002 | .flags = IORESOURCE_IRQ, | |
1003 | }, | |
1004 | }; | |
1005 | ||
1006 | static struct atmel_uart_data uart2_data = { | |
1007 | .use_dma_tx = 1, | |
1008 | .use_dma_rx = 1, | |
1009 | }; | |
1010 | ||
c6686ff9 AV |
1011 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
1012 | ||
b2c65616 AV |
1013 | static struct platform_device at91sam9263_uart2_device = { |
1014 | .name = "atmel_usart", | |
1015 | .id = 3, | |
1016 | .dev = { | |
c6686ff9 AV |
1017 | .dma_mask = &uart2_dmamask, |
1018 | .coherent_dma_mask = DMA_BIT_MASK(32), | |
1019 | .platform_data = &uart2_data, | |
b2c65616 AV |
1020 | }, |
1021 | .resource = uart2_resources, | |
1022 | .num_resources = ARRAY_SIZE(uart2_resources), | |
1023 | }; | |
1024 | ||
1025 | static inline void configure_usart2_pins(void) | |
1026 | { | |
1027 | at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ | |
1028 | at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ | |
1029 | at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ | |
1030 | at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ | |
1031 | } | |
1032 | ||
c6686ff9 | 1033 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
b2c65616 AV |
1034 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
1035 | ||
1036 | void __init at91_init_serial(struct at91_uart_config *config) | |
1037 | { | |
1038 | int i; | |
1039 | ||
1040 | /* Fill in list of supported UARTs */ | |
1041 | for (i = 0; i < config->nr_tty; i++) { | |
1042 | switch (config->tty_map[i]) { | |
1043 | case 0: | |
1044 | configure_usart0_pins(); | |
1045 | at91_uarts[i] = &at91sam9263_uart0_device; | |
1046 | at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart"); | |
1047 | break; | |
1048 | case 1: | |
1049 | configure_usart1_pins(); | |
1050 | at91_uarts[i] = &at91sam9263_uart1_device; | |
1051 | at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart"); | |
1052 | break; | |
1053 | case 2: | |
1054 | configure_usart2_pins(); | |
1055 | at91_uarts[i] = &at91sam9263_uart2_device; | |
1056 | at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart"); | |
1057 | break; | |
1058 | case 3: | |
1059 | configure_dbgu_pins(); | |
1060 | at91_uarts[i] = &at91sam9263_dbgu_device; | |
1061 | at91_clock_associate("mck", &at91sam9263_dbgu_device.dev, "usart"); | |
1062 | break; | |
1063 | default: | |
1064 | continue; | |
1065 | } | |
1066 | at91_uarts[i]->id = i; /* update ID number to mapped ID */ | |
1067 | } | |
1068 | ||
1069 | /* Set serial console device */ | |
1070 | if (config->console_tty < ATMEL_MAX_UART) | |
1071 | atmel_default_console_device = at91_uarts[config->console_tty]; | |
1072 | if (!atmel_default_console_device) | |
1073 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | |
1074 | } | |
1075 | ||
1076 | void __init at91_add_device_serial(void) | |
1077 | { | |
1078 | int i; | |
1079 | ||
1080 | for (i = 0; i < ATMEL_MAX_UART; i++) { | |
1081 | if (at91_uarts[i]) | |
1082 | platform_device_register(at91_uarts[i]); | |
1083 | } | |
1084 | } | |
1085 | #else | |
1086 | void __init at91_init_serial(struct at91_uart_config *config) {} | |
1087 | void __init at91_add_device_serial(void) {} | |
1088 | #endif | |
1089 | ||
1090 | ||
1091 | /* -------------------------------------------------------------------- */ | |
1092 | /* | |
1093 | * These devices are always present and don't need any board-specific | |
1094 | * setup. | |
1095 | */ | |
1096 | static int __init at91_add_standard_devices(void) | |
1097 | { | |
884f5a6a AV |
1098 | at91_add_device_rtt(); |
1099 | at91_add_device_watchdog(); | |
b2c65616 AV |
1100 | return 0; |
1101 | } | |
1102 | ||
1103 | arch_initcall(at91_add_standard_devices); |