blob: aa15997ec9ebb5cfb1e7395705f0e0ca065cdf50 [file] [log] [blame]
Andrew Victorb2c65612007-02-08 09:42:40 +01001/*
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
Andrew Victorc6686ff2008-01-23 09:13:53 +010015#include <linux/dma-mapping.h>
Russell King2f8163b2011-07-26 10:53:52 +010016#include <linux/gpio.h>
Andrew Victorb2c65612007-02-08 09:42:40 +010017#include <linux/platform_device.h>
Andrew Victorf230d3f2007-11-19 13:47:20 +010018#include <linux/i2c-gpio.h>
Andrew Victorb2c65612007-02-08 09:42:40 +010019
Andrew Victorf230d3f2007-11-19 13:47:20 +010020#include <linux/fb.h>
Jan Altenbergb8b78602007-08-03 12:14:34 +010021#include <video/atmel_lcdc.h>
22
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/board.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/at91sam9263.h>
25#include <mach/at91sam9263_matrix.h>
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +080026#include <mach/at91_matrix.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/at91sam9_smc.h>
Andrew Victorb2c65612007-02-08 09:42:40 +010028
29#include "generic.h"
30
Andrew Victorb2c65612007-02-08 09:42:40 +010031
32/* --------------------------------------------------------------------
33 * USB Host
34 * -------------------------------------------------------------------- */
35
36#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +010037static u64 ohci_dmamask = DMA_BIT_MASK(32);
Andrew Victorb2c65612007-02-08 09:42:40 +010038static struct at91_usbh_data usbh_data;
39
40static struct resource usbh_resources[] = {
41 [0] = {
42 .start = AT91SAM9263_UHP_BASE,
43 .end = AT91SAM9263_UHP_BASE + SZ_1M - 1,
44 .flags = IORESOURCE_MEM,
45 },
46 [1] = {
47 .start = AT91SAM9263_ID_UHP,
48 .end = AT91SAM9263_ID_UHP,
49 .flags = IORESOURCE_IRQ,
50 },
51};
52
53static struct platform_device at91_usbh_device = {
54 .name = "at91_ohci",
55 .id = -1,
56 .dev = {
57 .dma_mask = &ohci_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +010058 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +010059 .platform_data = &usbh_data,
60 },
61 .resource = usbh_resources,
62 .num_resources = ARRAY_SIZE(usbh_resources),
63};
64
65void __init at91_add_device_usbh(struct at91_usbh_data *data)
66{
67 int i;
68
69 if (!data)
70 return;
71
72 /* Enable VBus control for UHP ports */
73 for (i = 0; i < data->ports; i++) {
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +080074 if (gpio_is_valid(data->vbus_pin[i]))
Nicolas Ferrecca03552012-03-28 11:56:28 +020075 at91_set_gpio_output(data->vbus_pin[i],
76 data->vbus_pin_active_low[i]);
Andrew Victorb2c65612007-02-08 09:42:40 +010077 }
78
Thomas Petazzoni1fcaea72011-07-13 11:29:18 +020079 /* Enable overcurrent notification */
80 for (i = 0; i < data->ports; i++) {
81 if (data->overcurrent_pin[i])
82 at91_set_gpio_input(data->overcurrent_pin[i], 1);
83 }
84
Andrew Victorb2c65612007-02-08 09:42:40 +010085 usbh_data = *data;
86 platform_device_register(&at91_usbh_device);
87}
88#else
89void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
90#endif
91
92
93/* --------------------------------------------------------------------
94 * USB Device (Gadget)
95 * -------------------------------------------------------------------- */
96
Nicolas Ferree8c9dc92012-01-27 11:14:44 +010097#if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
Andrew Victorb2c65612007-02-08 09:42:40 +010098static struct at91_udc_data udc_data;
99
100static struct resource udc_resources[] = {
101 [0] = {
102 .start = AT91SAM9263_BASE_UDP,
103 .end = AT91SAM9263_BASE_UDP + SZ_16K - 1,
104 .flags = IORESOURCE_MEM,
105 },
106 [1] = {
107 .start = AT91SAM9263_ID_UDP,
108 .end = AT91SAM9263_ID_UDP,
109 .flags = IORESOURCE_IRQ,
110 },
111};
112
113static struct platform_device at91_udc_device = {
114 .name = "at91_udc",
115 .id = -1,
116 .dev = {
117 .platform_data = &udc_data,
118 },
119 .resource = udc_resources,
120 .num_resources = ARRAY_SIZE(udc_resources),
121};
122
123void __init at91_add_device_udc(struct at91_udc_data *data)
124{
125 if (!data)
126 return;
127
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800128 if (gpio_is_valid(data->vbus_pin)) {
Andrew Victorb2c65612007-02-08 09:42:40 +0100129 at91_set_gpio_input(data->vbus_pin, 0);
130 at91_set_deglitch(data->vbus_pin, 1);
131 }
132
133 /* Pullup pin is handled internally by USB device peripheral */
134
135 udc_data = *data;
136 platform_device_register(&at91_udc_device);
137}
138#else
139void __init at91_add_device_udc(struct at91_udc_data *data) {}
140#endif
141
142
143/* --------------------------------------------------------------------
144 * Ethernet
145 * -------------------------------------------------------------------- */
146
147#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100148static u64 eth_dmamask = DMA_BIT_MASK(32);
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000149static struct macb_platform_data eth_data;
Andrew Victorb2c65612007-02-08 09:42:40 +0100150
151static struct resource eth_resources[] = {
152 [0] = {
153 .start = AT91SAM9263_BASE_EMAC,
154 .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1,
155 .flags = IORESOURCE_MEM,
156 },
157 [1] = {
158 .start = AT91SAM9263_ID_EMAC,
159 .end = AT91SAM9263_ID_EMAC,
160 .flags = IORESOURCE_IRQ,
161 },
162};
163
164static struct platform_device at91sam9263_eth_device = {
165 .name = "macb",
166 .id = -1,
167 .dev = {
168 .dma_mask = &eth_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100169 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +0100170 .platform_data = &eth_data,
171 },
172 .resource = eth_resources,
173 .num_resources = ARRAY_SIZE(eth_resources),
174};
175
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000176void __init at91_add_device_eth(struct macb_platform_data *data)
Andrew Victorb2c65612007-02-08 09:42:40 +0100177{
178 if (!data)
179 return;
180
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800181 if (gpio_is_valid(data->phy_irq_pin)) {
Andrew Victorb2c65612007-02-08 09:42:40 +0100182 at91_set_gpio_input(data->phy_irq_pin, 0);
183 at91_set_deglitch(data->phy_irq_pin, 1);
184 }
185
186 /* Pins used for MII and RMII */
187 at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */
188 at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */
189 at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */
190 at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */
191 at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */
192 at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */
193 at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */
194 at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */
195 at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */
196 at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */
197
198 if (!data->is_rmii) {
199 at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */
200 at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
201 at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
202 at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
203 at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
204 at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
205 at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
206 at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
207 }
208
209 eth_data = *data;
210 platform_device_register(&at91sam9263_eth_device);
211}
212#else
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000213void __init at91_add_device_eth(struct macb_platform_data *data) {}
Andrew Victorb2c65612007-02-08 09:42:40 +0100214#endif
215
216
217/* --------------------------------------------------------------------
218 * MMC / SD
219 * -------------------------------------------------------------------- */
220
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200221#if IS_ENABLED(CONFIG_MMC_ATMELMCI)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100222static u64 mmc_dmamask = DMA_BIT_MASK(32);
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200223static struct mci_platform_data mmc0_data, mmc1_data;
Andrew Victorb2c65612007-02-08 09:42:40 +0100224
225static struct resource mmc0_resources[] = {
226 [0] = {
227 .start = AT91SAM9263_BASE_MCI0,
228 .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1,
229 .flags = IORESOURCE_MEM,
230 },
231 [1] = {
232 .start = AT91SAM9263_ID_MCI0,
233 .end = AT91SAM9263_ID_MCI0,
234 .flags = IORESOURCE_IRQ,
235 },
236};
237
238static struct platform_device at91sam9263_mmc0_device = {
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200239 .name = "atmel_mci",
Andrew Victorb2c65612007-02-08 09:42:40 +0100240 .id = 0,
241 .dev = {
242 .dma_mask = &mmc_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100243 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +0100244 .platform_data = &mmc0_data,
245 },
246 .resource = mmc0_resources,
247 .num_resources = ARRAY_SIZE(mmc0_resources),
248};
249
250static struct resource mmc1_resources[] = {
251 [0] = {
252 .start = AT91SAM9263_BASE_MCI1,
253 .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1,
254 .flags = IORESOURCE_MEM,
255 },
256 [1] = {
257 .start = AT91SAM9263_ID_MCI1,
258 .end = AT91SAM9263_ID_MCI1,
259 .flags = IORESOURCE_IRQ,
260 },
261};
262
263static struct platform_device at91sam9263_mmc1_device = {
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200264 .name = "atmel_mci",
Andrew Victorb2c65612007-02-08 09:42:40 +0100265 .id = 1,
266 .dev = {
267 .dma_mask = &mmc_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100268 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +0100269 .platform_data = &mmc1_data,
270 },
271 .resource = mmc1_resources,
272 .num_resources = ARRAY_SIZE(mmc1_resources),
273};
274
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200275void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
Andrew Victorb2c65612007-02-08 09:42:40 +0100276{
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200277 unsigned int i;
278 unsigned int slot_count = 0;
279
Andrew Victorb2c65612007-02-08 09:42:40 +0100280 if (!data)
281 return;
282
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200283 for (i = 0; i < ATMCI_MAX_NR_SLOTS; i++) {
Andrew Victorb2c65612007-02-08 09:42:40 +0100284
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200285 if (!data->slot[i].bus_width)
286 continue;
Andrew Victorb2c65612007-02-08 09:42:40 +0100287
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200288 /* input/irq */
289 if (gpio_is_valid(data->slot[i].detect_pin)) {
290 at91_set_gpio_input(data->slot[i].detect_pin,
291 1);
292 at91_set_deglitch(data->slot[i].detect_pin,
293 1);
294 }
295 if (gpio_is_valid(data->slot[i].wp_pin))
296 at91_set_gpio_input(data->slot[i].wp_pin, 1);
Andrew Victorb2c65612007-02-08 09:42:40 +0100297
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200298 if (mmc_id == 0) { /* MCI0 */
299 switch (i) {
300 case 0: /* slot A */
301 /* CMD */
302 at91_set_A_periph(AT91_PIN_PA1, 1);
303 /* DAT0, maybe DAT1..DAT3 */
304 at91_set_A_periph(AT91_PIN_PA0, 1);
305 if (data->slot[i].bus_width == 4) {
306 at91_set_A_periph(AT91_PIN_PA3, 1);
307 at91_set_A_periph(AT91_PIN_PA4, 1);
308 at91_set_A_periph(AT91_PIN_PA5, 1);
309 }
310 slot_count++;
311 break;
312 case 1: /* slot B */
313 /* CMD */
314 at91_set_A_periph(AT91_PIN_PA16, 1);
315 /* DAT0, maybe DAT1..DAT3 */
316 at91_set_A_periph(AT91_PIN_PA17, 1);
317 if (data->slot[i].bus_width == 4) {
318 at91_set_A_periph(AT91_PIN_PA18, 1);
319 at91_set_A_periph(AT91_PIN_PA19, 1);
320 at91_set_A_periph(AT91_PIN_PA20, 1);
321 }
322 slot_count++;
323 break;
324 default:
325 printk(KERN_ERR
326 "AT91: SD/MMC slot %d not available\n", i);
327 break;
Andrew Victorb2c65612007-02-08 09:42:40 +0100328 }
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200329 if (slot_count) {
330 /* CLK */
331 at91_set_A_periph(AT91_PIN_PA12, 0);
Andrew Victorb2c65612007-02-08 09:42:40 +0100332
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200333 mmc0_data = *data;
334 platform_device_register(&at91sam9263_mmc0_device);
335 }
336 } else if (mmc_id == 1) { /* MCI1 */
337 switch (i) {
338 case 0: /* slot A */
339 /* CMD */
340 at91_set_A_periph(AT91_PIN_PA7, 1);
341 /* DAT0, maybe DAT1..DAT3 */
342 at91_set_A_periph(AT91_PIN_PA8, 1);
343 if (data->slot[i].bus_width == 4) {
344 at91_set_A_periph(AT91_PIN_PA9, 1);
345 at91_set_A_periph(AT91_PIN_PA10, 1);
346 at91_set_A_periph(AT91_PIN_PA11, 1);
347 }
348 slot_count++;
349 break;
350 case 1: /* slot B */
351 /* CMD */
352 at91_set_A_periph(AT91_PIN_PA21, 1);
353 /* DAT0, maybe DAT1..DAT3 */
354 at91_set_A_periph(AT91_PIN_PA22, 1);
355 if (data->slot[i].bus_width == 4) {
356 at91_set_A_periph(AT91_PIN_PA23, 1);
357 at91_set_A_periph(AT91_PIN_PA24, 1);
358 at91_set_A_periph(AT91_PIN_PA25, 1);
359 }
360 slot_count++;
361 break;
362 default:
363 printk(KERN_ERR
364 "AT91: SD/MMC slot %d not available\n", i);
365 break;
366 }
367 if (slot_count) {
368 /* CLK */
369 at91_set_A_periph(AT91_PIN_PA6, 0);
370
371 mmc1_data = *data;
372 platform_device_register(&at91sam9263_mmc1_device);
Andrew Victorb2c65612007-02-08 09:42:40 +0100373 }
374 }
Andrew Victorb2c65612007-02-08 09:42:40 +0100375 }
376}
377#else
Ludovic Desroches4cf33262012-05-21 12:23:27 +0200378void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
Andrew Victorb2c65612007-02-08 09:42:40 +0100379#endif
380
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100381/* --------------------------------------------------------------------
382 * Compact Flash (PCMCIA or IDE)
383 * -------------------------------------------------------------------- */
384
Jean-Christophe PLAGNIOL-VILLARDcf844752011-12-15 21:24:03 +0800385#if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
386 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100387
388static struct at91_cf_data cf0_data;
389
390static struct resource cf0_resources[] = {
391 [0] = {
392 .start = AT91_CHIPSELECT_4,
393 .end = AT91_CHIPSELECT_4 + SZ_256M - 1,
394 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
395 }
396};
397
398static struct platform_device cf0_device = {
399 .id = 0,
400 .dev = {
401 .platform_data = &cf0_data,
402 },
403 .resource = cf0_resources,
404 .num_resources = ARRAY_SIZE(cf0_resources),
405};
406
407static struct at91_cf_data cf1_data;
408
409static struct resource cf1_resources[] = {
410 [0] = {
411 .start = AT91_CHIPSELECT_5,
412 .end = AT91_CHIPSELECT_5 + SZ_256M - 1,
413 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
414 }
415};
416
417static struct platform_device cf1_device = {
418 .id = 1,
419 .dev = {
420 .platform_data = &cf1_data,
421 },
422 .resource = cf1_resources,
423 .num_resources = ARRAY_SIZE(cf1_resources),
424};
425
426void __init at91_add_device_cf(struct at91_cf_data *data)
427{
428 unsigned long ebi0_csa;
429 struct platform_device *pdev;
430
431 if (!data)
432 return;
433
434 /*
435 * assign CS4 or CS5 to SMC with Compact Flash logic support,
436 * we assume SMC timings are configured by board code,
437 * except True IDE where timings are controlled by driver
438 */
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +0800439 ebi0_csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100440 switch (data->chipselect) {
441 case 4:
442 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
443 ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
444 cf0_data = *data;
445 pdev = &cf0_device;
446 break;
447 case 5:
448 at91_set_A_periph(AT91_PIN_PD7, 0); /* EBI0_NCS5/CFCS1 */
449 ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
450 cf1_data = *data;
451 pdev = &cf1_device;
452 break;
453 default:
454 printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
455 data->chipselect);
456 return;
457 }
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +0800458 at91_matrix_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100459
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800460 if (gpio_is_valid(data->det_pin)) {
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100461 at91_set_gpio_input(data->det_pin, 1);
462 at91_set_deglitch(data->det_pin, 1);
463 }
464
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800465 if (gpio_is_valid(data->irq_pin)) {
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100466 at91_set_gpio_input(data->irq_pin, 1);
467 at91_set_deglitch(data->irq_pin, 1);
468 }
469
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800470 if (gpio_is_valid(data->vcc_pin))
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100471 /* initially off */
472 at91_set_gpio_output(data->vcc_pin, 0);
473
474 /* enable EBI controlled pins */
475 at91_set_A_periph(AT91_PIN_PD5, 1); /* NWAIT */
476 at91_set_A_periph(AT91_PIN_PD8, 0); /* CFCE1 */
477 at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */
478 at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
479
Jean-Christophe PLAGNIOL-VILLARDcf844752011-12-15 21:24:03 +0800480 pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "pata_at91" : "at91_cf";
Stanislaw Gruszkae565f202009-03-05 16:10:58 +0100481 platform_device_register(pdev);
482}
483#else
484void __init at91_add_device_cf(struct at91_cf_data *data) {}
485#endif
Andrew Victorb2c65612007-02-08 09:42:40 +0100486
487/* --------------------------------------------------------------------
488 * NAND / SmartMedia
489 * -------------------------------------------------------------------- */
490
Pieter du Preezf6ed6f72008-08-01 10:06:40 +0100491#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200492static struct atmel_nand_data nand_data;
Andrew Victorb2c65612007-02-08 09:42:40 +0100493
494#define NAND_BASE AT91_CHIPSELECT_3
495
496static struct resource nand_resources[] = {
Andrew Victord7a24152008-04-02 21:44:44 +0100497 [0] = {
Andrew Victorb2c65612007-02-08 09:42:40 +0100498 .start = NAND_BASE,
499 .end = NAND_BASE + SZ_256M - 1,
500 .flags = IORESOURCE_MEM,
Andrew Victord7a24152008-04-02 21:44:44 +0100501 },
502 [1] = {
Jean-Christophe PLAGNIOL-VILLARDd28edd12011-09-18 09:31:56 +0800503 .start = AT91SAM9263_BASE_ECC0,
504 .end = AT91SAM9263_BASE_ECC0 + SZ_512 - 1,
Andrew Victord7a24152008-04-02 21:44:44 +0100505 .flags = IORESOURCE_MEM,
Andrew Victorb2c65612007-02-08 09:42:40 +0100506 }
507};
508
509static struct platform_device at91sam9263_nand_device = {
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200510 .name = "atmel_nand",
Andrew Victorb2c65612007-02-08 09:42:40 +0100511 .id = -1,
512 .dev = {
513 .platform_data = &nand_data,
514 },
515 .resource = nand_resources,
516 .num_resources = ARRAY_SIZE(nand_resources),
517};
518
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200519void __init at91_add_device_nand(struct atmel_nand_data *data)
Andrew Victorb2c65612007-02-08 09:42:40 +0100520{
Andrew Victor461d3b42008-10-06 20:01:00 +0100521 unsigned long csa;
Andrew Victorb2c65612007-02-08 09:42:40 +0100522
523 if (!data)
524 return;
525
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +0800526 csa = at91_matrix_read(AT91_MATRIX_EBI0CSA);
527 at91_matrix_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
Andrew Victorb2c65612007-02-08 09:42:40 +0100528
Andrew Victorb2c65612007-02-08 09:42:40 +0100529 /* enable pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800530 if (gpio_is_valid(data->enable_pin))
Andrew Victorb2c65612007-02-08 09:42:40 +0100531 at91_set_gpio_output(data->enable_pin, 1);
532
533 /* ready/busy pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800534 if (gpio_is_valid(data->rdy_pin))
Andrew Victorb2c65612007-02-08 09:42:40 +0100535 at91_set_gpio_input(data->rdy_pin, 1);
536
537 /* card detect pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800538 if (gpio_is_valid(data->det_pin))
Andrew Victorb2c65612007-02-08 09:42:40 +0100539 at91_set_gpio_input(data->det_pin, 1);
540
541 nand_data = *data;
542 platform_device_register(&at91sam9263_nand_device);
543}
544#else
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200545void __init at91_add_device_nand(struct atmel_nand_data *data) {}
Andrew Victorb2c65612007-02-08 09:42:40 +0100546#endif
547
548
549/* --------------------------------------------------------------------
550 * TWI (i2c)
551 * -------------------------------------------------------------------- */
552
Andrew Victorf230d3f2007-11-19 13:47:20 +0100553/*
554 * Prefer the GPIO code since the TWI controller isn't robust
555 * (gets overruns and underruns under load) and can only issue
556 * repeated STARTs in one scenario (the driver doesn't yet handle them).
557 */
558#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
559
560static struct i2c_gpio_platform_data pdata = {
561 .sda_pin = AT91_PIN_PB4,
562 .sda_is_open_drain = 1,
563 .scl_pin = AT91_PIN_PB5,
564 .scl_is_open_drain = 1,
565 .udelay = 2, /* ~100 kHz */
566};
567
568static struct platform_device at91sam9263_twi_device = {
569 .name = "i2c-gpio",
570 .id = -1,
571 .dev.platform_data = &pdata,
572};
573
574void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
575{
576 at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
577 at91_set_multi_drive(AT91_PIN_PB4, 1);
578
579 at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
580 at91_set_multi_drive(AT91_PIN_PB5, 1);
581
582 i2c_register_board_info(0, devices, nr_devices);
583 platform_device_register(&at91sam9263_twi_device);
584}
585
586#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
Andrew Victorb2c65612007-02-08 09:42:40 +0100587
588static struct resource twi_resources[] = {
589 [0] = {
590 .start = AT91SAM9263_BASE_TWI,
591 .end = AT91SAM9263_BASE_TWI + SZ_16K - 1,
592 .flags = IORESOURCE_MEM,
593 },
594 [1] = {
595 .start = AT91SAM9263_ID_TWI,
596 .end = AT91SAM9263_ID_TWI,
597 .flags = IORESOURCE_IRQ,
598 },
599};
600
601static struct platform_device at91sam9263_twi_device = {
602 .name = "at91_i2c",
603 .id = -1,
604 .resource = twi_resources,
605 .num_resources = ARRAY_SIZE(twi_resources),
606};
607
Andrew Victorf230d3f2007-11-19 13:47:20 +0100608void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
Andrew Victorb2c65612007-02-08 09:42:40 +0100609{
610 /* pins used for TWI interface */
611 at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
612 at91_set_multi_drive(AT91_PIN_PB4, 1);
613
614 at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
615 at91_set_multi_drive(AT91_PIN_PB5, 1);
616
Andrew Victorf230d3f2007-11-19 13:47:20 +0100617 i2c_register_board_info(0, devices, nr_devices);
Andrew Victorb2c65612007-02-08 09:42:40 +0100618 platform_device_register(&at91sam9263_twi_device);
619}
620#else
Andrew Victorf230d3f2007-11-19 13:47:20 +0100621void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
Andrew Victorb2c65612007-02-08 09:42:40 +0100622#endif
623
624
625/* --------------------------------------------------------------------
626 * SPI
627 * -------------------------------------------------------------------- */
628
629#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100630static u64 spi_dmamask = DMA_BIT_MASK(32);
Andrew Victorb2c65612007-02-08 09:42:40 +0100631
632static struct resource spi0_resources[] = {
633 [0] = {
634 .start = AT91SAM9263_BASE_SPI0,
635 .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
636 .flags = IORESOURCE_MEM,
637 },
638 [1] = {
639 .start = AT91SAM9263_ID_SPI0,
640 .end = AT91SAM9263_ID_SPI0,
641 .flags = IORESOURCE_IRQ,
642 },
643};
644
645static struct platform_device at91sam9263_spi0_device = {
646 .name = "atmel_spi",
647 .id = 0,
648 .dev = {
649 .dma_mask = &spi_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100650 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +0100651 },
652 .resource = spi0_resources,
653 .num_resources = ARRAY_SIZE(spi0_resources),
654};
655
656static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
657
658static struct resource spi1_resources[] = {
659 [0] = {
660 .start = AT91SAM9263_BASE_SPI1,
661 .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
662 .flags = IORESOURCE_MEM,
663 },
664 [1] = {
665 .start = AT91SAM9263_ID_SPI1,
666 .end = AT91SAM9263_ID_SPI1,
667 .flags = IORESOURCE_IRQ,
668 },
669};
670
671static struct platform_device at91sam9263_spi1_device = {
672 .name = "atmel_spi",
673 .id = 1,
674 .dev = {
675 .dma_mask = &spi_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100676 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victorb2c65612007-02-08 09:42:40 +0100677 },
678 .resource = spi1_resources,
679 .num_resources = ARRAY_SIZE(spi1_resources),
680};
681
682static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
683
684void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
685{
686 int i;
687 unsigned long cs_pin;
688 short enable_spi0 = 0;
689 short enable_spi1 = 0;
690
691 /* Choose SPI chip-selects */
692 for (i = 0; i < nr_devices; i++) {
693 if (devices[i].controller_data)
694 cs_pin = (unsigned long) devices[i].controller_data;
695 else if (devices[i].bus_num == 0)
696 cs_pin = spi0_standard_cs[devices[i].chip_select];
697 else
698 cs_pin = spi1_standard_cs[devices[i].chip_select];
699
Nicolas Ferre0c2c1f62012-03-28 11:58:58 +0200700 if (!gpio_is_valid(cs_pin))
701 continue;
702
Andrew Victorb2c65612007-02-08 09:42:40 +0100703 if (devices[i].bus_num == 0)
704 enable_spi0 = 1;
705 else
706 enable_spi1 = 1;
707
708 /* enable chip-select pin */
709 at91_set_gpio_output(cs_pin, 1);
710
711 /* pass chip-select pin to driver */
712 devices[i].controller_data = (void *) cs_pin;
713 }
714
715 spi_register_board_info(devices, nr_devices);
716
717 /* Configure SPI bus(es) */
718 if (enable_spi0) {
719 at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
720 at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
Andrew Victor7f6e2d92007-02-22 07:34:56 +0100721 at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
Andrew Victorb2c65612007-02-08 09:42:40 +0100722
Andrew Victorb2c65612007-02-08 09:42:40 +0100723 platform_device_register(&at91sam9263_spi0_device);
724 }
725 if (enable_spi1) {
726 at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
727 at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
728 at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
729
Andrew Victorb2c65612007-02-08 09:42:40 +0100730 platform_device_register(&at91sam9263_spi1_device);
731 }
732}
733#else
734void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
735#endif
736
737
738/* --------------------------------------------------------------------
Andrew Victor7776a942007-05-02 17:46:49 +0100739 * AC97
740 * -------------------------------------------------------------------- */
741
sedji gaouaoud656f072009-08-06 15:20:22 +0100742#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100743static u64 ac97_dmamask = DMA_BIT_MASK(32);
sedji gaouaoud656f072009-08-06 15:20:22 +0100744static struct ac97c_platform_data ac97_data;
Andrew Victor7776a942007-05-02 17:46:49 +0100745
746static struct resource ac97_resources[] = {
747 [0] = {
748 .start = AT91SAM9263_BASE_AC97C,
749 .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
750 .flags = IORESOURCE_MEM,
751 },
752 [1] = {
753 .start = AT91SAM9263_ID_AC97C,
754 .end = AT91SAM9263_ID_AC97C,
755 .flags = IORESOURCE_IRQ,
756 },
757};
758
759static struct platform_device at91sam9263_ac97_device = {
sedji gaouaoud656f072009-08-06 15:20:22 +0100760 .name = "atmel_ac97c",
761 .id = 0,
Andrew Victor7776a942007-05-02 17:46:49 +0100762 .dev = {
763 .dma_mask = &ac97_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100764 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor7776a942007-05-02 17:46:49 +0100765 .platform_data = &ac97_data,
766 },
767 .resource = ac97_resources,
768 .num_resources = ARRAY_SIZE(ac97_resources),
769};
770
sedji gaouaoud656f072009-08-06 15:20:22 +0100771void __init at91_add_device_ac97(struct ac97c_platform_data *data)
Andrew Victor7776a942007-05-02 17:46:49 +0100772{
773 if (!data)
774 return;
775
776 at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
777 at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
778 at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
779 at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
780
781 /* reset */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800782 if (gpio_is_valid(data->reset_pin))
Andrew Victor7776a942007-05-02 17:46:49 +0100783 at91_set_gpio_output(data->reset_pin, 0);
784
sedji gaouaoud656f072009-08-06 15:20:22 +0100785 ac97_data = *data;
Andrew Victor7776a942007-05-02 17:46:49 +0100786 platform_device_register(&at91sam9263_ac97_device);
787}
788#else
sedji gaouaoud656f072009-08-06 15:20:22 +0100789void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
Andrew Victor7776a942007-05-02 17:46:49 +0100790#endif
791
Marc Kleine-Budde58a587d2009-09-16 23:37:32 +0000792/* --------------------------------------------------------------------
793 * CAN Controller
794 * -------------------------------------------------------------------- */
795
796#if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE)
797static struct resource can_resources[] = {
798 [0] = {
799 .start = AT91SAM9263_BASE_CAN,
800 .end = AT91SAM9263_BASE_CAN + SZ_16K - 1,
801 .flags = IORESOURCE_MEM,
802 },
803 [1] = {
804 .start = AT91SAM9263_ID_CAN,
805 .end = AT91SAM9263_ID_CAN,
806 .flags = IORESOURCE_IRQ,
807 },
808};
809
810static struct platform_device at91sam9263_can_device = {
811 .name = "at91_can",
812 .id = -1,
813 .resource = can_resources,
814 .num_resources = ARRAY_SIZE(can_resources),
815};
816
817void __init at91_add_device_can(struct at91_can_data *data)
818{
819 at91_set_A_periph(AT91_PIN_PA13, 0); /* CANTX */
820 at91_set_A_periph(AT91_PIN_PA14, 0); /* CANRX */
821 at91sam9263_can_device.dev.platform_data = data;
822
823 platform_device_register(&at91sam9263_can_device);
824}
825#else
826void __init at91_add_device_can(struct at91_can_data *data) {}
827#endif
Andrew Victor7776a942007-05-02 17:46:49 +0100828
829/* --------------------------------------------------------------------
830 * LCD Controller
831 * -------------------------------------------------------------------- */
832
833#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100834static u64 lcdc_dmamask = DMA_BIT_MASK(32);
Andrew Victor7776a942007-05-02 17:46:49 +0100835static struct atmel_lcdfb_info lcdc_data;
836
837static struct resource lcdc_resources[] = {
838 [0] = {
839 .start = AT91SAM9263_LCDC_BASE,
840 .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
841 .flags = IORESOURCE_MEM,
842 },
843 [1] = {
844 .start = AT91SAM9263_ID_LCDC,
845 .end = AT91SAM9263_ID_LCDC,
846 .flags = IORESOURCE_IRQ,
847 },
848};
849
850static struct platform_device at91_lcdc_device = {
851 .name = "atmel_lcdfb",
852 .id = 0,
853 .dev = {
854 .dma_mask = &lcdc_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100855 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor7776a942007-05-02 17:46:49 +0100856 .platform_data = &lcdc_data,
857 },
858 .resource = lcdc_resources,
859 .num_resources = ARRAY_SIZE(lcdc_resources),
860};
861
862void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
863{
864 if (!data)
865 return;
866
867 at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
868 at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
869 at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
870 at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
871 at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
872 at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
873 at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
874 at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
875 at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
876 at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
877 at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
878 at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
879 at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
880 at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */
881 at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
882 at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
883 at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
884 at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
885 at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
886 at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */
887 at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
888 at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
889
890 lcdc_data = *data;
891 platform_device_register(&at91_lcdc_device);
892}
893#else
894void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
895#endif
896
897
898/* --------------------------------------------------------------------
Andrew Victore2920802008-01-22 11:43:26 +0100899 * Image Sensor Interface
900 * -------------------------------------------------------------------- */
901
902#if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
903
904struct resource isi_resources[] = {
905 [0] = {
906 .start = AT91SAM9263_BASE_ISI,
907 .end = AT91SAM9263_BASE_ISI + SZ_16K - 1,
908 .flags = IORESOURCE_MEM,
909 },
910 [1] = {
911 .start = AT91SAM9263_ID_ISI,
912 .end = AT91SAM9263_ID_ISI,
913 .flags = IORESOURCE_IRQ,
914 },
915};
916
917static struct platform_device at91sam9263_isi_device = {
918 .name = "at91_isi",
919 .id = -1,
920 .resource = isi_resources,
921 .num_resources = ARRAY_SIZE(isi_resources),
922};
923
Josh Wu45bb9e62011-10-22 15:17:39 +0800924void __init at91_add_device_isi(struct isi_platform_data *data,
925 bool use_pck_as_mck)
Andrew Victore2920802008-01-22 11:43:26 +0100926{
927 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
928 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
929 at91_set_A_periph(AT91_PIN_PE2, 0); /* ISI_D2 */
930 at91_set_A_periph(AT91_PIN_PE3, 0); /* ISI_D3 */
931 at91_set_A_periph(AT91_PIN_PE4, 0); /* ISI_D4 */
932 at91_set_A_periph(AT91_PIN_PE5, 0); /* ISI_D5 */
933 at91_set_A_periph(AT91_PIN_PE6, 0); /* ISI_D6 */
934 at91_set_A_periph(AT91_PIN_PE7, 0); /* ISI_D7 */
935 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
936 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
937 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
Andrew Victore2920802008-01-22 11:43:26 +0100938 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
939 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
940 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
941 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
Josh Wu45bb9e62011-10-22 15:17:39 +0800942
943 if (use_pck_as_mck) {
944 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
945
946 /* TODO: register the PCK for ISI_MCK and set its parent */
947 }
Andrew Victore2920802008-01-22 11:43:26 +0100948}
949#else
Josh Wu45bb9e62011-10-22 15:17:39 +0800950void __init at91_add_device_isi(struct isi_platform_data *data,
951 bool use_pck_as_mck) {}
Andrew Victore2920802008-01-22 11:43:26 +0100952#endif
953
954
955/* --------------------------------------------------------------------
Andrew Victore5f40bf2008-04-02 21:58:00 +0100956 * Timer/Counter block
957 * -------------------------------------------------------------------- */
958
959#ifdef CONFIG_ATMEL_TCLIB
960
961static struct resource tcb_resources[] = {
962 [0] = {
963 .start = AT91SAM9263_BASE_TCB0,
964 .end = AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
965 .flags = IORESOURCE_MEM,
966 },
967 [1] = {
968 .start = AT91SAM9263_ID_TCB,
969 .end = AT91SAM9263_ID_TCB,
970 .flags = IORESOURCE_IRQ,
971 },
972};
973
974static struct platform_device at91sam9263_tcb_device = {
975 .name = "atmel_tcb",
976 .id = 0,
977 .resource = tcb_resources,
978 .num_resources = ARRAY_SIZE(tcb_resources),
979};
980
Jean-Christophe PLAGNIOL-VILLARD4abb3672012-02-26 19:12:43 +0800981#if defined(CONFIG_OF)
982static struct of_device_id tcb_ids[] = {
983 { .compatible = "atmel,at91rm9200-tcb" },
984 { /*sentinel*/ }
985};
986#endif
987
Andrew Victore5f40bf2008-04-02 21:58:00 +0100988static void __init at91_add_device_tc(void)
989{
Jean-Christophe PLAGNIOL-VILLARD4abb3672012-02-26 19:12:43 +0800990#if defined(CONFIG_OF)
991 struct device_node *np;
992
993 np = of_find_matching_node(NULL, tcb_ids);
994 if (np) {
995 of_node_put(np);
996 return;
997 }
998#endif
999
Andrew Victore5f40bf2008-04-02 21:58:00 +01001000 platform_device_register(&at91sam9263_tcb_device);
1001}
1002#else
1003static void __init at91_add_device_tc(void) { }
1004#endif
1005
1006
1007/* --------------------------------------------------------------------
Andrew Victor884f5a62008-01-23 09:11:13 +01001008 * RTT
1009 * -------------------------------------------------------------------- */
1010
1011static struct resource rtt0_resources[] = {
1012 {
Jean-Christophe PLAGNIOL-VILLARDeab5fd62011-09-18 10:12:00 +08001013 .start = AT91SAM9263_BASE_RTT0,
1014 .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1,
Andrew Victor884f5a62008-01-23 09:11:13 +01001015 .flags = IORESOURCE_MEM,
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001016 }, {
1017 .flags = IORESOURCE_MEM,
Andrew Victor884f5a62008-01-23 09:11:13 +01001018 }
1019};
1020
1021static struct platform_device at91sam9263_rtt0_device = {
1022 .name = "at91_rtt",
1023 .id = 0,
1024 .resource = rtt0_resources,
Andrew Victor884f5a62008-01-23 09:11:13 +01001025};
1026
1027static struct resource rtt1_resources[] = {
1028 {
Jean-Christophe PLAGNIOL-VILLARDeab5fd62011-09-18 10:12:00 +08001029 .start = AT91SAM9263_BASE_RTT1,
1030 .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1,
Andrew Victor884f5a62008-01-23 09:11:13 +01001031 .flags = IORESOURCE_MEM,
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001032 }, {
1033 .flags = IORESOURCE_MEM,
Andrew Victor884f5a62008-01-23 09:11:13 +01001034 }
1035};
1036
1037static struct platform_device at91sam9263_rtt1_device = {
1038 .name = "at91_rtt",
1039 .id = 1,
1040 .resource = rtt1_resources,
Andrew Victor884f5a62008-01-23 09:11:13 +01001041};
1042
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001043#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
1044static void __init at91_add_device_rtt_rtc(void)
1045{
1046 struct platform_device *pdev;
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001047 struct resource *r;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001048
1049 switch (CONFIG_RTC_DRV_AT91SAM9_RTT) {
1050 case 0:
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001051 /*
1052 * The second resource is needed only for the chosen RTT:
1053 * GPBR will serve as the storage for RTC time offset
1054 */
1055 at91sam9263_rtt0_device.num_resources = 2;
1056 at91sam9263_rtt1_device.num_resources = 1;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001057 pdev = &at91sam9263_rtt0_device;
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001058 r = rtt0_resources;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001059 break;
1060 case 1:
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001061 at91sam9263_rtt0_device.num_resources = 1;
1062 at91sam9263_rtt1_device.num_resources = 2;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001063 pdev = &at91sam9263_rtt1_device;
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001064 r = rtt1_resources;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001065 break;
1066 default:
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001067 pr_err("at91sam9263: only supports 2 RTT (%d)\n",
1068 CONFIG_RTC_DRV_AT91SAM9_RTT);
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001069 return;
1070 }
1071
1072 pdev->name = "rtc-at91sam9";
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001073 r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
1074 r[1].end = r[1].start + 3;
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001075}
1076#else
Jean-Christophe PLAGNIOL-VILLARDb3af8b42012-02-15 21:24:46 +08001077static void __init at91_add_device_rtt_rtc(void)
1078{
1079 /* Only one resource is needed: RTT not used as RTC */
1080 at91sam9263_rtt0_device.num_resources = 1;
1081 at91sam9263_rtt1_device.num_resources = 1;
1082}
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001083#endif
1084
Andrew Victor884f5a62008-01-23 09:11:13 +01001085static void __init at91_add_device_rtt(void)
1086{
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +08001087 at91_add_device_rtt_rtc();
Andrew Victor884f5a62008-01-23 09:11:13 +01001088 platform_device_register(&at91sam9263_rtt0_device);
1089 platform_device_register(&at91sam9263_rtt1_device);
1090}
1091
1092
1093/* --------------------------------------------------------------------
1094 * Watchdog
1095 * -------------------------------------------------------------------- */
1096
Andrew Victor2af29b72009-02-11 21:23:10 +01001097#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +08001098static struct resource wdt_resources[] = {
1099 {
1100 .start = AT91SAM9263_BASE_WDT,
1101 .end = AT91SAM9263_BASE_WDT + SZ_16 - 1,
1102 .flags = IORESOURCE_MEM,
1103 }
1104};
1105
Andrew Victor884f5a62008-01-23 09:11:13 +01001106static struct platform_device at91sam9263_wdt_device = {
1107 .name = "at91_wdt",
1108 .id = -1,
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +08001109 .resource = wdt_resources,
1110 .num_resources = ARRAY_SIZE(wdt_resources),
Andrew Victor884f5a62008-01-23 09:11:13 +01001111};
1112
1113static void __init at91_add_device_watchdog(void)
1114{
1115 platform_device_register(&at91sam9263_wdt_device);
1116}
1117#else
1118static void __init at91_add_device_watchdog(void) {}
1119#endif
1120
1121
1122/* --------------------------------------------------------------------
Andrew Victorbb1ad682008-09-18 19:42:37 +01001123 * PWM
1124 * --------------------------------------------------------------------*/
1125
1126#if defined(CONFIG_ATMEL_PWM)
1127static u32 pwm_mask;
1128
1129static struct resource pwm_resources[] = {
1130 [0] = {
1131 .start = AT91SAM9263_BASE_PWMC,
1132 .end = AT91SAM9263_BASE_PWMC + SZ_16K - 1,
1133 .flags = IORESOURCE_MEM,
1134 },
1135 [1] = {
1136 .start = AT91SAM9263_ID_PWMC,
1137 .end = AT91SAM9263_ID_PWMC,
1138 .flags = IORESOURCE_IRQ,
1139 },
1140};
1141
1142static struct platform_device at91sam9263_pwm0_device = {
1143 .name = "atmel_pwm",
1144 .id = -1,
1145 .dev = {
1146 .platform_data = &pwm_mask,
1147 },
1148 .resource = pwm_resources,
1149 .num_resources = ARRAY_SIZE(pwm_resources),
1150};
1151
1152void __init at91_add_device_pwm(u32 mask)
1153{
1154 if (mask & (1 << AT91_PWM0))
1155 at91_set_B_periph(AT91_PIN_PB7, 1); /* enable PWM0 */
1156
1157 if (mask & (1 << AT91_PWM1))
1158 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */
1159
1160 if (mask & (1 << AT91_PWM2))
1161 at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */
1162
1163 if (mask & (1 << AT91_PWM3))
1164 at91_set_B_periph(AT91_PIN_PB29, 1); /* enable PWM3 */
1165
1166 pwm_mask = mask;
1167
1168 platform_device_register(&at91sam9263_pwm0_device);
1169}
1170#else
1171void __init at91_add_device_pwm(u32 mask) {}
1172#endif
1173
1174
1175/* --------------------------------------------------------------------
Andrew Victorbfbc3262008-01-23 09:18:06 +01001176 * SSC -- Synchronous Serial Controller
1177 * -------------------------------------------------------------------- */
1178
1179#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
1180static u64 ssc0_dmamask = DMA_BIT_MASK(32);
1181
1182static struct resource ssc0_resources[] = {
1183 [0] = {
1184 .start = AT91SAM9263_BASE_SSC0,
1185 .end = AT91SAM9263_BASE_SSC0 + SZ_16K - 1,
1186 .flags = IORESOURCE_MEM,
1187 },
1188 [1] = {
1189 .start = AT91SAM9263_ID_SSC0,
1190 .end = AT91SAM9263_ID_SSC0,
1191 .flags = IORESOURCE_IRQ,
1192 },
1193};
1194
1195static struct platform_device at91sam9263_ssc0_device = {
1196 .name = "ssc",
1197 .id = 0,
1198 .dev = {
1199 .dma_mask = &ssc0_dmamask,
1200 .coherent_dma_mask = DMA_BIT_MASK(32),
1201 },
1202 .resource = ssc0_resources,
1203 .num_resources = ARRAY_SIZE(ssc0_resources),
1204};
1205
1206static inline void configure_ssc0_pins(unsigned pins)
1207{
1208 if (pins & ATMEL_SSC_TF)
1209 at91_set_B_periph(AT91_PIN_PB0, 1);
1210 if (pins & ATMEL_SSC_TK)
1211 at91_set_B_periph(AT91_PIN_PB1, 1);
1212 if (pins & ATMEL_SSC_TD)
1213 at91_set_B_periph(AT91_PIN_PB2, 1);
1214 if (pins & ATMEL_SSC_RD)
1215 at91_set_B_periph(AT91_PIN_PB3, 1);
1216 if (pins & ATMEL_SSC_RK)
1217 at91_set_B_periph(AT91_PIN_PB4, 1);
1218 if (pins & ATMEL_SSC_RF)
1219 at91_set_B_periph(AT91_PIN_PB5, 1);
1220}
1221
1222static u64 ssc1_dmamask = DMA_BIT_MASK(32);
1223
1224static struct resource ssc1_resources[] = {
1225 [0] = {
1226 .start = AT91SAM9263_BASE_SSC1,
1227 .end = AT91SAM9263_BASE_SSC1 + SZ_16K - 1,
1228 .flags = IORESOURCE_MEM,
1229 },
1230 [1] = {
1231 .start = AT91SAM9263_ID_SSC1,
1232 .end = AT91SAM9263_ID_SSC1,
1233 .flags = IORESOURCE_IRQ,
1234 },
1235};
1236
1237static struct platform_device at91sam9263_ssc1_device = {
1238 .name = "ssc",
1239 .id = 1,
1240 .dev = {
1241 .dma_mask = &ssc1_dmamask,
1242 .coherent_dma_mask = DMA_BIT_MASK(32),
1243 },
1244 .resource = ssc1_resources,
1245 .num_resources = ARRAY_SIZE(ssc1_resources),
1246};
1247
1248static inline void configure_ssc1_pins(unsigned pins)
1249{
1250 if (pins & ATMEL_SSC_TF)
1251 at91_set_A_periph(AT91_PIN_PB6, 1);
1252 if (pins & ATMEL_SSC_TK)
1253 at91_set_A_periph(AT91_PIN_PB7, 1);
1254 if (pins & ATMEL_SSC_TD)
1255 at91_set_A_periph(AT91_PIN_PB8, 1);
1256 if (pins & ATMEL_SSC_RD)
1257 at91_set_A_periph(AT91_PIN_PB9, 1);
1258 if (pins & ATMEL_SSC_RK)
1259 at91_set_A_periph(AT91_PIN_PB10, 1);
1260 if (pins & ATMEL_SSC_RF)
1261 at91_set_A_periph(AT91_PIN_PB11, 1);
1262}
1263
1264/*
Andrew Victorbfbc3262008-01-23 09:18:06 +01001265 * SSC controllers are accessed through library code, instead of any
1266 * kind of all-singing/all-dancing driver. For example one could be
1267 * used by a particular I2S audio codec's driver, while another one
1268 * on the same system might be used by a custom data capture driver.
1269 */
1270void __init at91_add_device_ssc(unsigned id, unsigned pins)
1271{
1272 struct platform_device *pdev;
1273
1274 /*
1275 * NOTE: caller is responsible for passing information matching
1276 * "pins" to whatever will be using each particular controller.
1277 */
1278 switch (id) {
1279 case AT91SAM9263_ID_SSC0:
1280 pdev = &at91sam9263_ssc0_device;
1281 configure_ssc0_pins(pins);
Andrew Victorbfbc3262008-01-23 09:18:06 +01001282 break;
1283 case AT91SAM9263_ID_SSC1:
1284 pdev = &at91sam9263_ssc1_device;
1285 configure_ssc1_pins(pins);
Andrew Victorbfbc3262008-01-23 09:18:06 +01001286 break;
1287 default:
1288 return;
1289 }
1290
1291 platform_device_register(pdev);
1292}
1293
1294#else
1295void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1296#endif
1297
1298
1299/* --------------------------------------------------------------------
Andrew Victorb2c65612007-02-08 09:42:40 +01001300 * UART
1301 * -------------------------------------------------------------------- */
1302
1303#if defined(CONFIG_SERIAL_ATMEL)
1304
1305static struct resource dbgu_resources[] = {
1306 [0] = {
Jean-Christophe PLAGNIOL-VILLARD13079a72011-11-02 01:43:31 +08001307 .start = AT91SAM9263_BASE_DBGU,
1308 .end = AT91SAM9263_BASE_DBGU + SZ_512 - 1,
Andrew Victorb2c65612007-02-08 09:42:40 +01001309 .flags = IORESOURCE_MEM,
1310 },
1311 [1] = {
1312 .start = AT91_ID_SYS,
1313 .end = AT91_ID_SYS,
1314 .flags = IORESOURCE_IRQ,
1315 },
1316};
1317
1318static struct atmel_uart_data dbgu_data = {
1319 .use_dma_tx = 0,
1320 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
Andrew Victorb2c65612007-02-08 09:42:40 +01001321};
1322
Andrew Victorc6686ff2008-01-23 09:13:53 +01001323static u64 dbgu_dmamask = DMA_BIT_MASK(32);
1324
Andrew Victorb2c65612007-02-08 09:42:40 +01001325static struct platform_device at91sam9263_dbgu_device = {
1326 .name = "atmel_usart",
1327 .id = 0,
1328 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +01001329 .dma_mask = &dbgu_dmamask,
1330 .coherent_dma_mask = DMA_BIT_MASK(32),
1331 .platform_data = &dbgu_data,
Andrew Victorb2c65612007-02-08 09:42:40 +01001332 },
1333 .resource = dbgu_resources,
1334 .num_resources = ARRAY_SIZE(dbgu_resources),
1335};
1336
1337static inline void configure_dbgu_pins(void)
1338{
1339 at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
1340 at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
1341}
1342
1343static struct resource uart0_resources[] = {
1344 [0] = {
1345 .start = AT91SAM9263_BASE_US0,
1346 .end = AT91SAM9263_BASE_US0 + SZ_16K - 1,
1347 .flags = IORESOURCE_MEM,
1348 },
1349 [1] = {
1350 .start = AT91SAM9263_ID_US0,
1351 .end = AT91SAM9263_ID_US0,
1352 .flags = IORESOURCE_IRQ,
1353 },
1354};
1355
1356static struct atmel_uart_data uart0_data = {
1357 .use_dma_tx = 1,
1358 .use_dma_rx = 1,
1359};
1360
Andrew Victorc6686ff2008-01-23 09:13:53 +01001361static u64 uart0_dmamask = DMA_BIT_MASK(32);
1362
Andrew Victorb2c65612007-02-08 09:42:40 +01001363static struct platform_device at91sam9263_uart0_device = {
1364 .name = "atmel_usart",
1365 .id = 1,
1366 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +01001367 .dma_mask = &uart0_dmamask,
1368 .coherent_dma_mask = DMA_BIT_MASK(32),
1369 .platform_data = &uart0_data,
Andrew Victorb2c65612007-02-08 09:42:40 +01001370 },
1371 .resource = uart0_resources,
1372 .num_resources = ARRAY_SIZE(uart0_resources),
1373};
1374
Andrew Victorc8f385a2008-01-23 09:25:15 +01001375static inline void configure_usart0_pins(unsigned pins)
Andrew Victorb2c65612007-02-08 09:42:40 +01001376{
1377 at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */
1378 at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */
Andrew Victorc8f385a2008-01-23 09:25:15 +01001379
1380 if (pins & ATMEL_UART_RTS)
1381 at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */
1382 if (pins & ATMEL_UART_CTS)
1383 at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */
Andrew Victorb2c65612007-02-08 09:42:40 +01001384}
1385
1386static struct resource uart1_resources[] = {
1387 [0] = {
1388 .start = AT91SAM9263_BASE_US1,
1389 .end = AT91SAM9263_BASE_US1 + SZ_16K - 1,
1390 .flags = IORESOURCE_MEM,
1391 },
1392 [1] = {
1393 .start = AT91SAM9263_ID_US1,
1394 .end = AT91SAM9263_ID_US1,
1395 .flags = IORESOURCE_IRQ,
1396 },
1397};
1398
1399static struct atmel_uart_data uart1_data = {
1400 .use_dma_tx = 1,
1401 .use_dma_rx = 1,
1402};
1403
Andrew Victorc6686ff2008-01-23 09:13:53 +01001404static u64 uart1_dmamask = DMA_BIT_MASK(32);
1405
Andrew Victorb2c65612007-02-08 09:42:40 +01001406static struct platform_device at91sam9263_uart1_device = {
1407 .name = "atmel_usart",
1408 .id = 2,
1409 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +01001410 .dma_mask = &uart1_dmamask,
1411 .coherent_dma_mask = DMA_BIT_MASK(32),
1412 .platform_data = &uart1_data,
Andrew Victorb2c65612007-02-08 09:42:40 +01001413 },
1414 .resource = uart1_resources,
1415 .num_resources = ARRAY_SIZE(uart1_resources),
1416};
1417
Andrew Victorc8f385a2008-01-23 09:25:15 +01001418static inline void configure_usart1_pins(unsigned pins)
Andrew Victorb2c65612007-02-08 09:42:40 +01001419{
1420 at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
1421 at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
Andrew Victorc8f385a2008-01-23 09:25:15 +01001422
1423 if (pins & ATMEL_UART_RTS)
1424 at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
1425 if (pins & ATMEL_UART_CTS)
1426 at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
Andrew Victorb2c65612007-02-08 09:42:40 +01001427}
1428
1429static struct resource uart2_resources[] = {
1430 [0] = {
1431 .start = AT91SAM9263_BASE_US2,
1432 .end = AT91SAM9263_BASE_US2 + SZ_16K - 1,
1433 .flags = IORESOURCE_MEM,
1434 },
1435 [1] = {
1436 .start = AT91SAM9263_ID_US2,
1437 .end = AT91SAM9263_ID_US2,
1438 .flags = IORESOURCE_IRQ,
1439 },
1440};
1441
1442static struct atmel_uart_data uart2_data = {
1443 .use_dma_tx = 1,
1444 .use_dma_rx = 1,
1445};
1446
Andrew Victorc6686ff2008-01-23 09:13:53 +01001447static u64 uart2_dmamask = DMA_BIT_MASK(32);
1448
Andrew Victorb2c65612007-02-08 09:42:40 +01001449static struct platform_device at91sam9263_uart2_device = {
1450 .name = "atmel_usart",
1451 .id = 3,
1452 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +01001453 .dma_mask = &uart2_dmamask,
1454 .coherent_dma_mask = DMA_BIT_MASK(32),
1455 .platform_data = &uart2_data,
Andrew Victorb2c65612007-02-08 09:42:40 +01001456 },
1457 .resource = uart2_resources,
1458 .num_resources = ARRAY_SIZE(uart2_resources),
1459};
1460
Andrew Victorc8f385a2008-01-23 09:25:15 +01001461static inline void configure_usart2_pins(unsigned pins)
Andrew Victorb2c65612007-02-08 09:42:40 +01001462{
1463 at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
1464 at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
Andrew Victorc8f385a2008-01-23 09:25:15 +01001465
1466 if (pins & ATMEL_UART_RTS)
1467 at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
1468 if (pins & ATMEL_UART_CTS)
1469 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
Andrew Victorb2c65612007-02-08 09:42:40 +01001470}
1471
Andrew Victor11aadac2008-04-15 21:16:38 +01001472static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
Andrew Victorb2c65612007-02-08 09:42:40 +01001473
Andrew Victorc8f385a2008-01-23 09:25:15 +01001474void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1475{
1476 struct platform_device *pdev;
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001477 struct atmel_uart_data *pdata;
Andrew Victorc8f385a2008-01-23 09:25:15 +01001478
1479 switch (id) {
1480 case 0: /* DBGU */
1481 pdev = &at91sam9263_dbgu_device;
1482 configure_dbgu_pins();
Andrew Victorc8f385a2008-01-23 09:25:15 +01001483 break;
1484 case AT91SAM9263_ID_US0:
1485 pdev = &at91sam9263_uart0_device;
1486 configure_usart0_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001487 break;
1488 case AT91SAM9263_ID_US1:
1489 pdev = &at91sam9263_uart1_device;
1490 configure_usart1_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001491 break;
1492 case AT91SAM9263_ID_US2:
1493 pdev = &at91sam9263_uart2_device;
1494 configure_usart2_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001495 break;
1496 default:
1497 return;
1498 }
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001499 pdata = pdev->dev.platform_data;
1500 pdata->num = portnr; /* update to mapped ID */
Andrew Victorc8f385a2008-01-23 09:25:15 +01001501
1502 if (portnr < ATMEL_MAX_UART)
1503 at91_uarts[portnr] = pdev;
1504}
1505
Andrew Victorb2c65612007-02-08 09:42:40 +01001506void __init at91_add_device_serial(void)
1507{
1508 int i;
1509
1510 for (i = 0; i < ATMEL_MAX_UART; i++) {
1511 if (at91_uarts[i])
1512 platform_device_register(at91_uarts[i]);
1513 }
1514}
1515#else
Andrew Victorc8f385a2008-01-23 09:25:15 +01001516void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
Andrew Victorb2c65612007-02-08 09:42:40 +01001517void __init at91_add_device_serial(void) {}
1518#endif
1519
1520
1521/* -------------------------------------------------------------------- */
1522/*
1523 * These devices are always present and don't need any board-specific
1524 * setup.
1525 */
1526static int __init at91_add_standard_devices(void)
1527{
Jean-Christophe PLAGNIOL-VILLARD4abb3672012-02-26 19:12:43 +08001528 if (of_have_populated_dt())
1529 return 0;
1530
Andrew Victor884f5a62008-01-23 09:11:13 +01001531 at91_add_device_rtt();
1532 at91_add_device_watchdog();
Andrew Victore5f40bf2008-04-02 21:58:00 +01001533 at91_add_device_tc();
Andrew Victorb2c65612007-02-08 09:42:40 +01001534 return 0;
1535}
1536
1537arch_initcall(at91_add_standard_devices);