blob: b3ceb97d722df0772c5d38a2c590779e3a2c143d [file] [log] [blame]
Andrew Victor86ad76b2006-11-30 16:45:01 +01001/*
Andrew Victor9d041262007-02-05 11:42:07 +01002 * arch/arm/mach-at91/at91sam9261_devices.c
Andrew Victor86ad76b2006-11-30 16:45:01 +01003 *
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
5 * Copyright (C) 2005 David Brownell
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 */
13#include <asm/mach/arch.h>
14#include <asm/mach/map.h>
15
Andrew Victorc6686ff2008-01-23 09:13:53 +010016#include <linux/dma-mapping.h>
Russell King2f8163b2011-07-26 10:53:52 +010017#include <linux/gpio.h>
Andrew Victor86ad76b2006-11-30 16:45:01 +010018#include <linux/platform_device.h>
Andrew Victorf230d3f2007-11-19 13:47:20 +010019#include <linux/i2c-gpio.h>
Andrew Victor86ad76b2006-11-30 16:45:01 +010020
Andrew Victorf230d3f2007-11-19 13:47:20 +010021#include <linux/fb.h>
Jan Altenbergb8b78602007-08-03 12:14:34 +010022#include <video/atmel_lcdc.h>
23
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/board.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/at91sam9261.h>
26#include <mach/at91sam9261_matrix.h>
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +080027#include <mach/at91_matrix.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/at91sam9_smc.h>
Andrew Victor86ad76b2006-11-30 16:45:01 +010029
30#include "generic.h"
31
Andrew Victor86ad76b2006-11-30 16:45:01 +010032
33/* --------------------------------------------------------------------
34 * USB Host
35 * -------------------------------------------------------------------- */
36
37#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +010038static u64 ohci_dmamask = DMA_BIT_MASK(32);
Andrew Victor86ad76b2006-11-30 16:45:01 +010039static struct at91_usbh_data usbh_data;
40
41static struct resource usbh_resources[] = {
42 [0] = {
43 .start = AT91SAM9261_UHP_BASE,
44 .end = AT91SAM9261_UHP_BASE + SZ_1M - 1,
45 .flags = IORESOURCE_MEM,
46 },
47 [1] = {
48 .start = AT91SAM9261_ID_UHP,
49 .end = AT91SAM9261_ID_UHP,
50 .flags = IORESOURCE_IRQ,
51 },
52};
53
54static struct platform_device at91sam9261_usbh_device = {
55 .name = "at91_ohci",
56 .id = -1,
57 .dev = {
58 .dma_mask = &ohci_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +010059 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor86ad76b2006-11-30 16:45:01 +010060 .platform_data = &usbh_data,
61 },
62 .resource = usbh_resources,
63 .num_resources = ARRAY_SIZE(usbh_resources),
64};
65
66void __init at91_add_device_usbh(struct at91_usbh_data *data)
67{
Thomas Petazzoni1fcaea72011-07-13 11:29:18 +020068 int i;
69
Andrew Victor86ad76b2006-11-30 16:45:01 +010070 if (!data)
71 return;
72
Thomas Petazzoni1fcaea72011-07-13 11:29:18 +020073 /* Enable overcurrent notification */
74 for (i = 0; i < data->ports; i++) {
75 if (data->overcurrent_pin[i])
76 at91_set_gpio_input(data->overcurrent_pin[i], 1);
77 }
78
Andrew Victor86ad76b2006-11-30 16:45:01 +010079 usbh_data = *data;
80 platform_device_register(&at91sam9261_usbh_device);
81}
82#else
83void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
84#endif
85
86
87/* --------------------------------------------------------------------
88 * USB Device (Gadget)
89 * -------------------------------------------------------------------- */
90
Anders Darander0e934e22011-11-30 08:47:44 +010091#ifdef CONFIG_USB_AT91
Andrew Victor86ad76b2006-11-30 16:45:01 +010092static struct at91_udc_data udc_data;
93
94static struct resource udc_resources[] = {
95 [0] = {
96 .start = AT91SAM9261_BASE_UDP,
97 .end = AT91SAM9261_BASE_UDP + SZ_16K - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = AT91SAM9261_ID_UDP,
102 .end = AT91SAM9261_ID_UDP,
103 .flags = IORESOURCE_IRQ,
104 },
105};
106
107static struct platform_device at91sam9261_udc_device = {
108 .name = "at91_udc",
109 .id = -1,
110 .dev = {
111 .platform_data = &udc_data,
112 },
113 .resource = udc_resources,
114 .num_resources = ARRAY_SIZE(udc_resources),
115};
116
117void __init at91_add_device_udc(struct at91_udc_data *data)
118{
Andrew Victor86ad76b2006-11-30 16:45:01 +0100119 if (!data)
120 return;
121
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800122 if (gpio_is_valid(data->vbus_pin)) {
Andrew Victor86ad76b2006-11-30 16:45:01 +0100123 at91_set_gpio_input(data->vbus_pin, 0);
124 at91_set_deglitch(data->vbus_pin, 1);
125 }
126
Christian Glindkampda7a42d2008-01-03 12:15:23 +0100127 /* Pullup pin is handled internally by USB device peripheral */
Andrew Victor86ad76b2006-11-30 16:45:01 +0100128
129 udc_data = *data;
130 platform_device_register(&at91sam9261_udc_device);
131}
132#else
133void __init at91_add_device_udc(struct at91_udc_data *data) {}
134#endif
135
136/* --------------------------------------------------------------------
137 * MMC / SD
138 * -------------------------------------------------------------------- */
139
140#if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100141static u64 mmc_dmamask = DMA_BIT_MASK(32);
Andrew Victor86ad76b2006-11-30 16:45:01 +0100142static struct at91_mmc_data mmc_data;
143
144static struct resource mmc_resources[] = {
145 [0] = {
146 .start = AT91SAM9261_BASE_MCI,
147 .end = AT91SAM9261_BASE_MCI + SZ_16K - 1,
148 .flags = IORESOURCE_MEM,
149 },
150 [1] = {
151 .start = AT91SAM9261_ID_MCI,
152 .end = AT91SAM9261_ID_MCI,
153 .flags = IORESOURCE_IRQ,
154 },
155};
156
157static struct platform_device at91sam9261_mmc_device = {
158 .name = "at91_mci",
159 .id = -1,
160 .dev = {
161 .dma_mask = &mmc_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100162 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor86ad76b2006-11-30 16:45:01 +0100163 .platform_data = &mmc_data,
164 },
165 .resource = mmc_resources,
166 .num_resources = ARRAY_SIZE(mmc_resources),
167};
168
Andrew Victord0760b32007-02-08 09:00:39 +0100169void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100170{
171 if (!data)
172 return;
173
174 /* input/irq */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800175 if (gpio_is_valid(data->det_pin)) {
Andrew Victor86ad76b2006-11-30 16:45:01 +0100176 at91_set_gpio_input(data->det_pin, 1);
177 at91_set_deglitch(data->det_pin, 1);
178 }
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800179 if (gpio_is_valid(data->wp_pin))
Andrew Victor86ad76b2006-11-30 16:45:01 +0100180 at91_set_gpio_input(data->wp_pin, 1);
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800181 if (gpio_is_valid(data->vcc_pin))
Andrew Victor86ad76b2006-11-30 16:45:01 +0100182 at91_set_gpio_output(data->vcc_pin, 0);
183
184 /* CLK */
185 at91_set_B_periph(AT91_PIN_PA2, 0);
186
187 /* CMD */
188 at91_set_B_periph(AT91_PIN_PA1, 1);
189
190 /* DAT0, maybe DAT1..DAT3 */
191 at91_set_B_periph(AT91_PIN_PA0, 1);
192 if (data->wire4) {
193 at91_set_B_periph(AT91_PIN_PA4, 1);
194 at91_set_B_periph(AT91_PIN_PA5, 1);
195 at91_set_B_periph(AT91_PIN_PA6, 1);
196 }
197
198 mmc_data = *data;
199 platform_device_register(&at91sam9261_mmc_device);
200}
201#else
Andrew Victord0760b32007-02-08 09:00:39 +0100202void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
Andrew Victor86ad76b2006-11-30 16:45:01 +0100203#endif
204
205
206/* --------------------------------------------------------------------
207 * NAND / SmartMedia
208 * -------------------------------------------------------------------- */
209
Pieter du Preezf6ed6f72008-08-01 10:06:40 +0100210#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200211static struct atmel_nand_data nand_data;
Andrew Victor86ad76b2006-11-30 16:45:01 +0100212
213#define NAND_BASE AT91_CHIPSELECT_3
214
215static struct resource nand_resources[] = {
216 {
217 .start = NAND_BASE,
218 .end = NAND_BASE + SZ_256M - 1,
219 .flags = IORESOURCE_MEM,
220 }
221};
222
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200223static struct platform_device atmel_nand_device = {
224 .name = "atmel_nand",
Andrew Victor86ad76b2006-11-30 16:45:01 +0100225 .id = -1,
226 .dev = {
227 .platform_data = &nand_data,
228 },
229 .resource = nand_resources,
230 .num_resources = ARRAY_SIZE(nand_resources),
231};
232
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200233void __init at91_add_device_nand(struct atmel_nand_data *data)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100234{
Andrew Victor461d3b42008-10-06 20:01:00 +0100235 unsigned long csa;
Andrew Victor86ad76b2006-11-30 16:45:01 +0100236
237 if (!data)
238 return;
239
Jean-Christophe PLAGNIOL-VILLARD4342d642011-11-27 23:15:50 +0800240 csa = at91_matrix_read(AT91_MATRIX_EBICSA);
241 at91_matrix_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
Andrew Victor86ad76b2006-11-30 16:45:01 +0100242
Andrew Victor86ad76b2006-11-30 16:45:01 +0100243 /* enable pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800244 if (gpio_is_valid(data->enable_pin))
Andrew Victor86ad76b2006-11-30 16:45:01 +0100245 at91_set_gpio_output(data->enable_pin, 1);
246
247 /* ready/busy pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800248 if (gpio_is_valid(data->rdy_pin))
Andrew Victor86ad76b2006-11-30 16:45:01 +0100249 at91_set_gpio_input(data->rdy_pin, 1);
250
251 /* card detect pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800252 if (gpio_is_valid(data->det_pin))
Andrew Victor86ad76b2006-11-30 16:45:01 +0100253 at91_set_gpio_input(data->det_pin, 1);
254
255 at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */
256 at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */
257
258 nand_data = *data;
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200259 platform_device_register(&atmel_nand_device);
Andrew Victor86ad76b2006-11-30 16:45:01 +0100260}
261
262#else
HÃ¥vard Skinnemoen3c3796c2008-06-06 18:04:53 +0200263void __init at91_add_device_nand(struct atmel_nand_data *data) {}
Andrew Victor86ad76b2006-11-30 16:45:01 +0100264#endif
265
266
267/* --------------------------------------------------------------------
268 * TWI (i2c)
269 * -------------------------------------------------------------------- */
270
Andrew Victorf230d3f2007-11-19 13:47:20 +0100271/*
272 * Prefer the GPIO code since the TWI controller isn't robust
273 * (gets overruns and underruns under load) and can only issue
274 * repeated STARTs in one scenario (the driver doesn't yet handle them).
275 */
276#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
277
278static struct i2c_gpio_platform_data pdata = {
279 .sda_pin = AT91_PIN_PA7,
280 .sda_is_open_drain = 1,
281 .scl_pin = AT91_PIN_PA8,
282 .scl_is_open_drain = 1,
283 .udelay = 2, /* ~100 kHz */
284};
285
286static struct platform_device at91sam9261_twi_device = {
287 .name = "i2c-gpio",
288 .id = -1,
289 .dev.platform_data = &pdata,
290};
291
292void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
293{
294 at91_set_GPIO_periph(AT91_PIN_PA7, 1); /* TWD (SDA) */
295 at91_set_multi_drive(AT91_PIN_PA7, 1);
296
297 at91_set_GPIO_periph(AT91_PIN_PA8, 1); /* TWCK (SCL) */
298 at91_set_multi_drive(AT91_PIN_PA8, 1);
299
300 i2c_register_board_info(0, devices, nr_devices);
301 platform_device_register(&at91sam9261_twi_device);
302}
303
304#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100305
306static struct resource twi_resources[] = {
307 [0] = {
308 .start = AT91SAM9261_BASE_TWI,
309 .end = AT91SAM9261_BASE_TWI + SZ_16K - 1,
310 .flags = IORESOURCE_MEM,
311 },
312 [1] = {
313 .start = AT91SAM9261_ID_TWI,
314 .end = AT91SAM9261_ID_TWI,
315 .flags = IORESOURCE_IRQ,
316 },
317};
318
319static struct platform_device at91sam9261_twi_device = {
320 .name = "at91_i2c",
321 .id = -1,
322 .resource = twi_resources,
323 .num_resources = ARRAY_SIZE(twi_resources),
324};
325
Andrew Victorf230d3f2007-11-19 13:47:20 +0100326void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100327{
328 /* pins used for TWI interface */
329 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
330 at91_set_multi_drive(AT91_PIN_PA7, 1);
331
332 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */
333 at91_set_multi_drive(AT91_PIN_PA8, 1);
334
Andrew Victorf230d3f2007-11-19 13:47:20 +0100335 i2c_register_board_info(0, devices, nr_devices);
Andrew Victor86ad76b2006-11-30 16:45:01 +0100336 platform_device_register(&at91sam9261_twi_device);
337}
338#else
Andrew Victorf230d3f2007-11-19 13:47:20 +0100339void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
Andrew Victor86ad76b2006-11-30 16:45:01 +0100340#endif
341
342
343/* --------------------------------------------------------------------
344 * SPI
345 * -------------------------------------------------------------------- */
346
347#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100348static u64 spi_dmamask = DMA_BIT_MASK(32);
Andrew Victor86ad76b2006-11-30 16:45:01 +0100349
350static struct resource spi0_resources[] = {
351 [0] = {
352 .start = AT91SAM9261_BASE_SPI0,
353 .end = AT91SAM9261_BASE_SPI0 + SZ_16K - 1,
354 .flags = IORESOURCE_MEM,
355 },
356 [1] = {
357 .start = AT91SAM9261_ID_SPI0,
358 .end = AT91SAM9261_ID_SPI0,
359 .flags = IORESOURCE_IRQ,
360 },
361};
362
363static struct platform_device at91sam9261_spi0_device = {
364 .name = "atmel_spi",
365 .id = 0,
366 .dev = {
367 .dma_mask = &spi_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100368 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor86ad76b2006-11-30 16:45:01 +0100369 },
370 .resource = spi0_resources,
371 .num_resources = ARRAY_SIZE(spi0_resources),
372};
373
374static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
375
376static struct resource spi1_resources[] = {
377 [0] = {
378 .start = AT91SAM9261_BASE_SPI1,
379 .end = AT91SAM9261_BASE_SPI1 + SZ_16K - 1,
380 .flags = IORESOURCE_MEM,
381 },
382 [1] = {
383 .start = AT91SAM9261_ID_SPI1,
384 .end = AT91SAM9261_ID_SPI1,
385 .flags = IORESOURCE_IRQ,
386 },
387};
388
389static struct platform_device at91sam9261_spi1_device = {
390 .name = "atmel_spi",
391 .id = 1,
392 .dev = {
393 .dma_mask = &spi_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100394 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor86ad76b2006-11-30 16:45:01 +0100395 },
396 .resource = spi1_resources,
397 .num_resources = ARRAY_SIZE(spi1_resources),
398};
399
400static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB28, AT91_PIN_PA24, AT91_PIN_PA25, AT91_PIN_PA26 };
401
402void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
403{
404 int i;
405 unsigned long cs_pin;
406 short enable_spi0 = 0;
407 short enable_spi1 = 0;
408
409 /* Choose SPI chip-selects */
410 for (i = 0; i < nr_devices; i++) {
411 if (devices[i].controller_data)
412 cs_pin = (unsigned long) devices[i].controller_data;
413 else if (devices[i].bus_num == 0)
414 cs_pin = spi0_standard_cs[devices[i].chip_select];
415 else
416 cs_pin = spi1_standard_cs[devices[i].chip_select];
417
418 if (devices[i].bus_num == 0)
419 enable_spi0 = 1;
420 else
421 enable_spi1 = 1;
422
423 /* enable chip-select pin */
424 at91_set_gpio_output(cs_pin, 1);
425
426 /* pass chip-select pin to driver */
427 devices[i].controller_data = (void *) cs_pin;
428 }
429
430 spi_register_board_info(devices, nr_devices);
431
432 /* Configure SPI bus(es) */
433 if (enable_spi0) {
434 at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
435 at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
436 at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
437
Andrew Victor86ad76b2006-11-30 16:45:01 +0100438 platform_device_register(&at91sam9261_spi0_device);
439 }
440 if (enable_spi1) {
441 at91_set_A_periph(AT91_PIN_PB30, 0); /* SPI1_MISO */
442 at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */
443 at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */
444
Andrew Victor86ad76b2006-11-30 16:45:01 +0100445 platform_device_register(&at91sam9261_spi1_device);
446 }
447}
448#else
449void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
450#endif
451
452
453/* --------------------------------------------------------------------
454 * LCD Controller
455 * -------------------------------------------------------------------- */
456
Andrew Victor7776a942007-05-02 17:46:49 +0100457#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
Andrew Victorc6686ff2008-01-23 09:13:53 +0100458static u64 lcdc_dmamask = DMA_BIT_MASK(32);
Andrew Victor7776a942007-05-02 17:46:49 +0100459static struct atmel_lcdfb_info lcdc_data;
Andrew Victor86ad76b2006-11-30 16:45:01 +0100460
461static struct resource lcdc_resources[] = {
462 [0] = {
463 .start = AT91SAM9261_LCDC_BASE,
464 .end = AT91SAM9261_LCDC_BASE + SZ_4K - 1,
465 .flags = IORESOURCE_MEM,
466 },
467 [1] = {
468 .start = AT91SAM9261_ID_LCDC,
469 .end = AT91SAM9261_ID_LCDC,
470 .flags = IORESOURCE_IRQ,
471 },
472#if defined(CONFIG_FB_INTSRAM)
473 [2] = {
474 .start = AT91SAM9261_SRAM_BASE,
475 .end = AT91SAM9261_SRAM_BASE + AT91SAM9261_SRAM_SIZE - 1,
476 .flags = IORESOURCE_MEM,
477 },
478#endif
479};
480
481static struct platform_device at91_lcdc_device = {
Andrew Victor7776a942007-05-02 17:46:49 +0100482 .name = "atmel_lcdfb",
Andrew Victor86ad76b2006-11-30 16:45:01 +0100483 .id = 0,
484 .dev = {
485 .dma_mask = &lcdc_dmamask,
Andrew Victorc6686ff2008-01-23 09:13:53 +0100486 .coherent_dma_mask = DMA_BIT_MASK(32),
Andrew Victor86ad76b2006-11-30 16:45:01 +0100487 .platform_data = &lcdc_data,
488 },
489 .resource = lcdc_resources,
490 .num_resources = ARRAY_SIZE(lcdc_resources),
491};
492
Andrew Victor7776a942007-05-02 17:46:49 +0100493void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100494{
495 if (!data) {
496 return;
497 }
498
Andrew Victorf06e6562008-01-22 11:37:32 +0100499#if defined(CONFIG_FB_ATMEL_STN)
500 at91_set_A_periph(AT91_PIN_PB0, 0); /* LCDVSYNC */
501 at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */
502 at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */
503 at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */
504 at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */
505 at91_set_A_periph(AT91_PIN_PB5, 0); /* LCDD0 */
506 at91_set_A_periph(AT91_PIN_PB6, 0); /* LCDD1 */
507 at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */
508 at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */
509#else
Andrew Victor86ad76b2006-11-30 16:45:01 +0100510 at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */
511 at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */
512 at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */
513 at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */
514 at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */
515 at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */
516 at91_set_A_periph(AT91_PIN_PB9, 0); /* LCDD4 */
517 at91_set_A_periph(AT91_PIN_PB10, 0); /* LCDD5 */
518 at91_set_A_periph(AT91_PIN_PB11, 0); /* LCDD6 */
519 at91_set_A_periph(AT91_PIN_PB12, 0); /* LCDD7 */
520 at91_set_A_periph(AT91_PIN_PB15, 0); /* LCDD10 */
521 at91_set_A_periph(AT91_PIN_PB16, 0); /* LCDD11 */
522 at91_set_A_periph(AT91_PIN_PB17, 0); /* LCDD12 */
523 at91_set_A_periph(AT91_PIN_PB18, 0); /* LCDD13 */
524 at91_set_A_periph(AT91_PIN_PB19, 0); /* LCDD14 */
525 at91_set_A_periph(AT91_PIN_PB20, 0); /* LCDD15 */
526 at91_set_B_periph(AT91_PIN_PB23, 0); /* LCDD18 */
527 at91_set_B_periph(AT91_PIN_PB24, 0); /* LCDD19 */
528 at91_set_B_periph(AT91_PIN_PB25, 0); /* LCDD20 */
529 at91_set_B_periph(AT91_PIN_PB26, 0); /* LCDD21 */
530 at91_set_B_periph(AT91_PIN_PB27, 0); /* LCDD22 */
531 at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */
Andrew Victorf06e6562008-01-22 11:37:32 +0100532#endif
Andrew Victor86ad76b2006-11-30 16:45:01 +0100533
Haavard Skinnemoen01d3a5e2008-04-28 02:15:19 -0700534 if (ARRAY_SIZE(lcdc_resources) > 2) {
535 void __iomem *fb;
536 struct resource *fb_res = &lcdc_resources[2];
Joe Perches28f65c12011-06-09 09:13:32 -0700537 size_t fb_len = resource_size(fb_res);
Haavard Skinnemoen01d3a5e2008-04-28 02:15:19 -0700538
Nicolas Ferre90898702008-05-14 16:05:38 -0700539 fb = ioremap(fb_res->start, fb_len);
Haavard Skinnemoen01d3a5e2008-04-28 02:15:19 -0700540 if (fb) {
541 memset(fb, 0, fb_len);
Nicolas Ferre90898702008-05-14 16:05:38 -0700542 iounmap(fb);
Haavard Skinnemoen01d3a5e2008-04-28 02:15:19 -0700543 }
544 }
Andrew Victor86ad76b2006-11-30 16:45:01 +0100545 lcdc_data = *data;
546 platform_device_register(&at91_lcdc_device);
547}
548#else
Andrew Victor7776a942007-05-02 17:46:49 +0100549void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
Andrew Victor86ad76b2006-11-30 16:45:01 +0100550#endif
551
552
553/* --------------------------------------------------------------------
Andrew Victore5f40bf2008-04-02 21:58:00 +0100554 * Timer/Counter block
555 * -------------------------------------------------------------------- */
556
557#ifdef CONFIG_ATMEL_TCLIB
558
559static struct resource tcb_resources[] = {
560 [0] = {
561 .start = AT91SAM9261_BASE_TCB0,
562 .end = AT91SAM9261_BASE_TCB0 + SZ_16K - 1,
563 .flags = IORESOURCE_MEM,
564 },
565 [1] = {
566 .start = AT91SAM9261_ID_TC0,
567 .end = AT91SAM9261_ID_TC0,
568 .flags = IORESOURCE_IRQ,
569 },
570 [2] = {
571 .start = AT91SAM9261_ID_TC1,
572 .end = AT91SAM9261_ID_TC1,
573 .flags = IORESOURCE_IRQ,
574 },
575 [3] = {
576 .start = AT91SAM9261_ID_TC2,
577 .end = AT91SAM9261_ID_TC2,
578 .flags = IORESOURCE_IRQ,
579 },
580};
581
582static struct platform_device at91sam9261_tcb_device = {
583 .name = "atmel_tcb",
584 .id = 0,
585 .resource = tcb_resources,
586 .num_resources = ARRAY_SIZE(tcb_resources),
587};
588
589static void __init at91_add_device_tc(void)
590{
Andrew Victore5f40bf2008-04-02 21:58:00 +0100591 platform_device_register(&at91sam9261_tcb_device);
592}
593#else
594static void __init at91_add_device_tc(void) { }
595#endif
596
597
598/* --------------------------------------------------------------------
Andrew Victor884f5a62008-01-23 09:11:13 +0100599 * RTT
600 * -------------------------------------------------------------------- */
601
602static struct resource rtt_resources[] = {
603 {
Jean-Christophe PLAGNIOL-VILLARDeab5fd62011-09-18 10:12:00 +0800604 .start = AT91SAM9261_BASE_RTT,
605 .end = AT91SAM9261_BASE_RTT + SZ_16 - 1,
Andrew Victor884f5a62008-01-23 09:11:13 +0100606 .flags = IORESOURCE_MEM,
607 }
608};
609
610static struct platform_device at91sam9261_rtt_device = {
611 .name = "at91_rtt",
Andrew Victor4fd92122008-04-02 21:55:19 +0100612 .id = 0,
Andrew Victor884f5a62008-01-23 09:11:13 +0100613 .resource = rtt_resources,
614 .num_resources = ARRAY_SIZE(rtt_resources),
615};
616
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +0800617#if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
618static void __init at91_add_device_rtt_rtc(void)
619{
620 at91sam9261_rtt_device.name = "rtc-at91sam9";
621}
622#else
623static void __init at91_add_device_rtt_rtc(void) {}
624#endif
625
Andrew Victor884f5a62008-01-23 09:11:13 +0100626static void __init at91_add_device_rtt(void)
627{
Jean-Christophe PLAGNIOL-VILLARD205056a2012-02-15 20:51:37 +0800628 at91_add_device_rtt_rtc();
Andrew Victor884f5a62008-01-23 09:11:13 +0100629 platform_device_register(&at91sam9261_rtt_device);
630}
631
632
633/* --------------------------------------------------------------------
634 * Watchdog
635 * -------------------------------------------------------------------- */
636
Andrew Victor2af29b72009-02-11 21:23:10 +0100637#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +0800638static struct resource wdt_resources[] = {
639 {
640 .start = AT91SAM9261_BASE_WDT,
641 .end = AT91SAM9261_BASE_WDT + SZ_16 - 1,
642 .flags = IORESOURCE_MEM,
643 }
644};
645
Andrew Victor884f5a62008-01-23 09:11:13 +0100646static struct platform_device at91sam9261_wdt_device = {
647 .name = "at91_wdt",
648 .id = -1,
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +0800649 .resource = wdt_resources,
650 .num_resources = ARRAY_SIZE(wdt_resources),
Andrew Victor884f5a62008-01-23 09:11:13 +0100651};
652
653static void __init at91_add_device_watchdog(void)
654{
655 platform_device_register(&at91sam9261_wdt_device);
656}
657#else
658static void __init at91_add_device_watchdog(void) {}
659#endif
660
661
662/* --------------------------------------------------------------------
Andrew Victorbfbc3262008-01-23 09:18:06 +0100663 * SSC -- Synchronous Serial Controller
664 * -------------------------------------------------------------------- */
665
666#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
667static u64 ssc0_dmamask = DMA_BIT_MASK(32);
668
669static struct resource ssc0_resources[] = {
670 [0] = {
671 .start = AT91SAM9261_BASE_SSC0,
672 .end = AT91SAM9261_BASE_SSC0 + SZ_16K - 1,
673 .flags = IORESOURCE_MEM,
674 },
675 [1] = {
676 .start = AT91SAM9261_ID_SSC0,
677 .end = AT91SAM9261_ID_SSC0,
678 .flags = IORESOURCE_IRQ,
679 },
680};
681
682static struct platform_device at91sam9261_ssc0_device = {
683 .name = "ssc",
684 .id = 0,
685 .dev = {
686 .dma_mask = &ssc0_dmamask,
687 .coherent_dma_mask = DMA_BIT_MASK(32),
688 },
689 .resource = ssc0_resources,
690 .num_resources = ARRAY_SIZE(ssc0_resources),
691};
692
693static inline void configure_ssc0_pins(unsigned pins)
694{
695 if (pins & ATMEL_SSC_TF)
696 at91_set_A_periph(AT91_PIN_PB21, 1);
697 if (pins & ATMEL_SSC_TK)
698 at91_set_A_periph(AT91_PIN_PB22, 1);
699 if (pins & ATMEL_SSC_TD)
700 at91_set_A_periph(AT91_PIN_PB23, 1);
701 if (pins & ATMEL_SSC_RD)
702 at91_set_A_periph(AT91_PIN_PB24, 1);
703 if (pins & ATMEL_SSC_RK)
704 at91_set_A_periph(AT91_PIN_PB25, 1);
705 if (pins & ATMEL_SSC_RF)
706 at91_set_A_periph(AT91_PIN_PB26, 1);
707}
708
709static u64 ssc1_dmamask = DMA_BIT_MASK(32);
710
711static struct resource ssc1_resources[] = {
712 [0] = {
713 .start = AT91SAM9261_BASE_SSC1,
714 .end = AT91SAM9261_BASE_SSC1 + SZ_16K - 1,
715 .flags = IORESOURCE_MEM,
716 },
717 [1] = {
718 .start = AT91SAM9261_ID_SSC1,
719 .end = AT91SAM9261_ID_SSC1,
720 .flags = IORESOURCE_IRQ,
721 },
722};
723
724static struct platform_device at91sam9261_ssc1_device = {
725 .name = "ssc",
726 .id = 1,
727 .dev = {
728 .dma_mask = &ssc1_dmamask,
729 .coherent_dma_mask = DMA_BIT_MASK(32),
730 },
731 .resource = ssc1_resources,
732 .num_resources = ARRAY_SIZE(ssc1_resources),
733};
734
735static inline void configure_ssc1_pins(unsigned pins)
736{
737 if (pins & ATMEL_SSC_TF)
738 at91_set_B_periph(AT91_PIN_PA17, 1);
739 if (pins & ATMEL_SSC_TK)
740 at91_set_B_periph(AT91_PIN_PA18, 1);
741 if (pins & ATMEL_SSC_TD)
742 at91_set_B_periph(AT91_PIN_PA19, 1);
743 if (pins & ATMEL_SSC_RD)
744 at91_set_B_periph(AT91_PIN_PA20, 1);
745 if (pins & ATMEL_SSC_RK)
746 at91_set_B_periph(AT91_PIN_PA21, 1);
747 if (pins & ATMEL_SSC_RF)
748 at91_set_B_periph(AT91_PIN_PA22, 1);
749}
750
751static u64 ssc2_dmamask = DMA_BIT_MASK(32);
752
753static struct resource ssc2_resources[] = {
754 [0] = {
755 .start = AT91SAM9261_BASE_SSC2,
756 .end = AT91SAM9261_BASE_SSC2 + SZ_16K - 1,
757 .flags = IORESOURCE_MEM,
758 },
759 [1] = {
760 .start = AT91SAM9261_ID_SSC2,
761 .end = AT91SAM9261_ID_SSC2,
762 .flags = IORESOURCE_IRQ,
763 },
764};
765
766static struct platform_device at91sam9261_ssc2_device = {
767 .name = "ssc",
768 .id = 2,
769 .dev = {
770 .dma_mask = &ssc2_dmamask,
771 .coherent_dma_mask = DMA_BIT_MASK(32),
772 },
773 .resource = ssc2_resources,
774 .num_resources = ARRAY_SIZE(ssc2_resources),
775};
776
777static inline void configure_ssc2_pins(unsigned pins)
778{
779 if (pins & ATMEL_SSC_TF)
780 at91_set_B_periph(AT91_PIN_PC25, 1);
781 if (pins & ATMEL_SSC_TK)
782 at91_set_B_periph(AT91_PIN_PC26, 1);
783 if (pins & ATMEL_SSC_TD)
784 at91_set_B_periph(AT91_PIN_PC27, 1);
785 if (pins & ATMEL_SSC_RD)
786 at91_set_B_periph(AT91_PIN_PC28, 1);
787 if (pins & ATMEL_SSC_RK)
788 at91_set_B_periph(AT91_PIN_PC29, 1);
789 if (pins & ATMEL_SSC_RF)
790 at91_set_B_periph(AT91_PIN_PC30, 1);
791}
792
793/*
794 * SSC controllers are accessed through library code, instead of any
795 * kind of all-singing/all-dancing driver. For example one could be
796 * used by a particular I2S audio codec's driver, while another one
797 * on the same system might be used by a custom data capture driver.
798 */
799void __init at91_add_device_ssc(unsigned id, unsigned pins)
800{
801 struct platform_device *pdev;
802
803 /*
804 * NOTE: caller is responsible for passing information matching
805 * "pins" to whatever will be using each particular controller.
806 */
807 switch (id) {
808 case AT91SAM9261_ID_SSC0:
809 pdev = &at91sam9261_ssc0_device;
810 configure_ssc0_pins(pins);
Andrew Victorbfbc3262008-01-23 09:18:06 +0100811 break;
812 case AT91SAM9261_ID_SSC1:
813 pdev = &at91sam9261_ssc1_device;
814 configure_ssc1_pins(pins);
Andrew Victorbfbc3262008-01-23 09:18:06 +0100815 break;
816 case AT91SAM9261_ID_SSC2:
817 pdev = &at91sam9261_ssc2_device;
818 configure_ssc2_pins(pins);
Andrew Victorbfbc3262008-01-23 09:18:06 +0100819 break;
820 default:
821 return;
822 }
823
824 platform_device_register(pdev);
825}
826
827#else
828void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
829#endif
830
831
832/* --------------------------------------------------------------------
Andrew Victor86ad76b2006-11-30 16:45:01 +0100833 * UART
834 * -------------------------------------------------------------------- */
835
836#if defined(CONFIG_SERIAL_ATMEL)
837static struct resource dbgu_resources[] = {
838 [0] = {
Jean-Christophe PLAGNIOL-VILLARD13079a72011-11-02 01:43:31 +0800839 .start = AT91SAM9261_BASE_DBGU,
840 .end = AT91SAM9261_BASE_DBGU + SZ_512 - 1,
Andrew Victor86ad76b2006-11-30 16:45:01 +0100841 .flags = IORESOURCE_MEM,
842 },
843 [1] = {
844 .start = AT91_ID_SYS,
845 .end = AT91_ID_SYS,
846 .flags = IORESOURCE_IRQ,
847 },
848};
849
850static struct atmel_uart_data dbgu_data = {
851 .use_dma_tx = 0,
852 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
Andrew Victor86ad76b2006-11-30 16:45:01 +0100853};
854
Andrew Victorc6686ff2008-01-23 09:13:53 +0100855static u64 dbgu_dmamask = DMA_BIT_MASK(32);
856
Andrew Victor86ad76b2006-11-30 16:45:01 +0100857static struct platform_device at91sam9261_dbgu_device = {
858 .name = "atmel_usart",
859 .id = 0,
860 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +0100861 .dma_mask = &dbgu_dmamask,
862 .coherent_dma_mask = DMA_BIT_MASK(32),
863 .platform_data = &dbgu_data,
Andrew Victor86ad76b2006-11-30 16:45:01 +0100864 },
865 .resource = dbgu_resources,
866 .num_resources = ARRAY_SIZE(dbgu_resources),
867};
868
869static inline void configure_dbgu_pins(void)
870{
871 at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */
872 at91_set_A_periph(AT91_PIN_PA10, 1); /* DTXD */
873}
874
875static struct resource uart0_resources[] = {
876 [0] = {
877 .start = AT91SAM9261_BASE_US0,
878 .end = AT91SAM9261_BASE_US0 + SZ_16K - 1,
879 .flags = IORESOURCE_MEM,
880 },
881 [1] = {
882 .start = AT91SAM9261_ID_US0,
883 .end = AT91SAM9261_ID_US0,
884 .flags = IORESOURCE_IRQ,
885 },
886};
887
888static struct atmel_uart_data uart0_data = {
889 .use_dma_tx = 1,
890 .use_dma_rx = 1,
891};
892
Andrew Victorc6686ff2008-01-23 09:13:53 +0100893static u64 uart0_dmamask = DMA_BIT_MASK(32);
894
Andrew Victor86ad76b2006-11-30 16:45:01 +0100895static struct platform_device at91sam9261_uart0_device = {
896 .name = "atmel_usart",
897 .id = 1,
898 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +0100899 .dma_mask = &uart0_dmamask,
900 .coherent_dma_mask = DMA_BIT_MASK(32),
901 .platform_data = &uart0_data,
Andrew Victor86ad76b2006-11-30 16:45:01 +0100902 },
903 .resource = uart0_resources,
904 .num_resources = ARRAY_SIZE(uart0_resources),
905};
906
Andrew Victorc8f385a2008-01-23 09:25:15 +0100907static inline void configure_usart0_pins(unsigned pins)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100908{
909 at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */
910 at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */
Andrew Victorc8f385a2008-01-23 09:25:15 +0100911
912 if (pins & ATMEL_UART_RTS)
913 at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */
914 if (pins & ATMEL_UART_CTS)
915 at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */
Andrew Victor86ad76b2006-11-30 16:45:01 +0100916}
917
918static struct resource uart1_resources[] = {
919 [0] = {
920 .start = AT91SAM9261_BASE_US1,
921 .end = AT91SAM9261_BASE_US1 + SZ_16K - 1,
922 .flags = IORESOURCE_MEM,
923 },
924 [1] = {
925 .start = AT91SAM9261_ID_US1,
926 .end = AT91SAM9261_ID_US1,
927 .flags = IORESOURCE_IRQ,
928 },
929};
930
931static struct atmel_uart_data uart1_data = {
932 .use_dma_tx = 1,
933 .use_dma_rx = 1,
934};
935
Andrew Victorc6686ff2008-01-23 09:13:53 +0100936static u64 uart1_dmamask = DMA_BIT_MASK(32);
937
Andrew Victor86ad76b2006-11-30 16:45:01 +0100938static struct platform_device at91sam9261_uart1_device = {
939 .name = "atmel_usart",
940 .id = 2,
941 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +0100942 .dma_mask = &uart1_dmamask,
943 .coherent_dma_mask = DMA_BIT_MASK(32),
944 .platform_data = &uart1_data,
Andrew Victor86ad76b2006-11-30 16:45:01 +0100945 },
946 .resource = uart1_resources,
947 .num_resources = ARRAY_SIZE(uart1_resources),
948};
949
Andrew Victorc8f385a2008-01-23 09:25:15 +0100950static inline void configure_usart1_pins(unsigned pins)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100951{
952 at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */
953 at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */
Andrew Victorc8f385a2008-01-23 09:25:15 +0100954
955 if (pins & ATMEL_UART_RTS)
956 at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */
957 if (pins & ATMEL_UART_CTS)
958 at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */
Andrew Victor86ad76b2006-11-30 16:45:01 +0100959}
960
961static struct resource uart2_resources[] = {
962 [0] = {
963 .start = AT91SAM9261_BASE_US2,
964 .end = AT91SAM9261_BASE_US2 + SZ_16K - 1,
965 .flags = IORESOURCE_MEM,
966 },
967 [1] = {
968 .start = AT91SAM9261_ID_US2,
969 .end = AT91SAM9261_ID_US2,
970 .flags = IORESOURCE_IRQ,
971 },
972};
973
974static struct atmel_uart_data uart2_data = {
975 .use_dma_tx = 1,
976 .use_dma_rx = 1,
977};
978
Andrew Victorc6686ff2008-01-23 09:13:53 +0100979static u64 uart2_dmamask = DMA_BIT_MASK(32);
980
Andrew Victor86ad76b2006-11-30 16:45:01 +0100981static struct platform_device at91sam9261_uart2_device = {
982 .name = "atmel_usart",
983 .id = 3,
984 .dev = {
Andrew Victorc6686ff2008-01-23 09:13:53 +0100985 .dma_mask = &uart2_dmamask,
986 .coherent_dma_mask = DMA_BIT_MASK(32),
987 .platform_data = &uart2_data,
Andrew Victor86ad76b2006-11-30 16:45:01 +0100988 },
989 .resource = uart2_resources,
990 .num_resources = ARRAY_SIZE(uart2_resources),
991};
992
Andrew Victorc8f385a2008-01-23 09:25:15 +0100993static inline void configure_usart2_pins(unsigned pins)
Andrew Victor86ad76b2006-11-30 16:45:01 +0100994{
995 at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */
996 at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */
Andrew Victorc8f385a2008-01-23 09:25:15 +0100997
998 if (pins & ATMEL_UART_RTS)
999 at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/
1000 if (pins & ATMEL_UART_CTS)
1001 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */
Andrew Victor86ad76b2006-11-30 16:45:01 +01001002}
1003
Andrew Victor11aadac2008-04-15 21:16:38 +01001004static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
Andrew Victor86ad76b2006-11-30 16:45:01 +01001005struct platform_device *atmel_default_console_device; /* the serial console device */
1006
Andrew Victorc8f385a2008-01-23 09:25:15 +01001007void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1008{
1009 struct platform_device *pdev;
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001010 struct atmel_uart_data *pdata;
Andrew Victorc8f385a2008-01-23 09:25:15 +01001011
1012 switch (id) {
1013 case 0: /* DBGU */
1014 pdev = &at91sam9261_dbgu_device;
1015 configure_dbgu_pins();
Andrew Victorc8f385a2008-01-23 09:25:15 +01001016 break;
1017 case AT91SAM9261_ID_US0:
1018 pdev = &at91sam9261_uart0_device;
1019 configure_usart0_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001020 break;
1021 case AT91SAM9261_ID_US1:
1022 pdev = &at91sam9261_uart1_device;
1023 configure_usart1_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001024 break;
1025 case AT91SAM9261_ID_US2:
1026 pdev = &at91sam9261_uart2_device;
1027 configure_usart2_pins(pins);
Andrew Victorc8f385a2008-01-23 09:25:15 +01001028 break;
1029 default:
1030 return;
1031 }
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001032 pdata = pdev->dev.platform_data;
1033 pdata->num = portnr; /* update to mapped ID */
Andrew Victorc8f385a2008-01-23 09:25:15 +01001034
1035 if (portnr < ATMEL_MAX_UART)
1036 at91_uarts[portnr] = pdev;
1037}
1038
1039void __init at91_set_serial_console(unsigned portnr)
1040{
Jean-Christophe PLAGNIOL-VILLARDbd602992011-02-02 07:27:07 +01001041 if (portnr < ATMEL_MAX_UART) {
Andrew Victorc8f385a2008-01-23 09:25:15 +01001042 atmel_default_console_device = at91_uarts[portnr];
Jean-Christophe PLAGNIOL-VILLARD5c1f9662011-06-21 11:24:33 +08001043 at91sam9261_set_console_clock(at91_uarts[portnr]->id);
Jean-Christophe PLAGNIOL-VILLARDbd602992011-02-02 07:27:07 +01001044 }
Andrew Victorc8f385a2008-01-23 09:25:15 +01001045}
1046
Andrew Victor86ad76b2006-11-30 16:45:01 +01001047void __init at91_add_device_serial(void)
1048{
1049 int i;
1050
1051 for (i = 0; i < ATMEL_MAX_UART; i++) {
1052 if (at91_uarts[i])
1053 platform_device_register(at91_uarts[i]);
1054 }
Andrew Victor11aadac2008-04-15 21:16:38 +01001055
1056 if (!atmel_default_console_device)
1057 printk(KERN_INFO "AT91: No default serial console defined.\n");
Andrew Victor86ad76b2006-11-30 16:45:01 +01001058}
1059#else
Andrew Victorc8f385a2008-01-23 09:25:15 +01001060void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1061void __init at91_set_serial_console(unsigned portnr) {}
Andrew Victor86ad76b2006-11-30 16:45:01 +01001062void __init at91_add_device_serial(void) {}
1063#endif
1064
1065
1066/* -------------------------------------------------------------------- */
1067
1068/*
1069 * These devices are always present and don't need any board-specific
1070 * setup.
1071 */
1072static int __init at91_add_standard_devices(void)
1073{
Andrew Victor884f5a62008-01-23 09:11:13 +01001074 at91_add_device_rtt();
1075 at91_add_device_watchdog();
Andrew Victore5f40bf2008-04-02 21:58:00 +01001076 at91_add_device_tc();
Andrew Victor86ad76b2006-11-30 16:45:01 +01001077 return 0;
1078}
1079
1080arch_initcall(at91_add_standard_devices);