blob: bd4e68cd3e2f31d43c982a03f405c544cabb926a [file] [log] [blame]
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001/*
2 * On-Chip devices setup code for the AT91SAM9G45 family
3 *
4 * Copyright (C) 2009 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
15#include <linux/dma-mapping.h>
Russell King2f8163b2011-07-26 10:53:52 +010016#include <linux/gpio.h>
Josh Wu343754f2011-10-22 15:17:40 +080017#include <linux/clk.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010018#include <linux/platform_device.h>
19#include <linux/i2c-gpio.h>
Nicolas Ferre75305d72010-10-22 18:27:48 +020020#include <linux/atmel-mci.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010021
22#include <linux/fb.h>
23#include <video/atmel_lcdc.h>
24
25#include <mach/board.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010026#include <mach/at91sam9g45.h>
27#include <mach/at91sam9g45_matrix.h>
28#include <mach/at91sam9_smc.h>
Nicolas Ferre40262b22009-07-24 11:43:01 +010029#include <mach/at_hdmac.h>
Nicolas Ferre75305d72010-10-22 18:27:48 +020030#include <mach/atmel-mci.h>
Nicolas Ferre789b23b2009-06-26 15:36:58 +010031
Josh Wu343754f2011-10-22 15:17:40 +080032#include <media/atmel-isi.h>
33
Nicolas Ferre789b23b2009-06-26 15:36:58 +010034#include "generic.h"
Josh Wu343754f2011-10-22 15:17:40 +080035#include "clock.h"
Nicolas Ferre789b23b2009-06-26 15:36:58 +010036
37
38/* --------------------------------------------------------------------
Nicolas Ferre40262b22009-07-24 11:43:01 +010039 * HDMAC - AHB DMA Controller
40 * -------------------------------------------------------------------- */
41
42#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
43static u64 hdmac_dmamask = DMA_BIT_MASK(32);
44
Nicolas Ferre40262b22009-07-24 11:43:01 +010045static struct resource hdmac_resources[] = {
46 [0] = {
Jean-Christophe PLAGNIOL-VILLARD9627b202011-10-15 15:47:51 +080047 .start = AT91SAM9G45_BASE_DMA,
48 .end = AT91SAM9G45_BASE_DMA + SZ_512 - 1,
Nicolas Ferre40262b22009-07-24 11:43:01 +010049 .flags = IORESOURCE_MEM,
50 },
Nicolas Ferre8d2602e2010-08-20 16:44:33 +020051 [1] = {
Nicolas Ferre40262b22009-07-24 11:43:01 +010052 .start = AT91SAM9G45_ID_DMA,
53 .end = AT91SAM9G45_ID_DMA,
54 .flags = IORESOURCE_IRQ,
55 },
56};
57
58static struct platform_device at_hdmac_device = {
Nicolas Ferrebdad0b92011-10-10 14:55:17 +020059 .name = "at91sam9g45_dma",
Nicolas Ferre40262b22009-07-24 11:43:01 +010060 .id = -1,
61 .dev = {
62 .dma_mask = &hdmac_dmamask,
63 .coherent_dma_mask = DMA_BIT_MASK(32),
Nicolas Ferre40262b22009-07-24 11:43:01 +010064 },
65 .resource = hdmac_resources,
66 .num_resources = ARRAY_SIZE(hdmac_resources),
67};
68
69void __init at91_add_device_hdmac(void)
70{
Nicolas Ferre2756bf52011-10-10 16:50:43 +020071#if defined(CONFIG_OF)
72 struct device_node *of_node =
73 of_find_node_by_name(NULL, "dma-controller");
74
75 if (of_node)
76 of_node_put(of_node);
77 else
78#endif
79 platform_device_register(&at_hdmac_device);
Nicolas Ferre40262b22009-07-24 11:43:01 +010080}
81#else
82void __init at91_add_device_hdmac(void) {}
83#endif
84
85
86/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +010087 * USB Host (OHCI)
88 * -------------------------------------------------------------------- */
89
90#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
91static u64 ohci_dmamask = DMA_BIT_MASK(32);
92static struct at91_usbh_data usbh_ohci_data;
93
94static struct resource usbh_ohci_resources[] = {
95 [0] = {
96 .start = AT91SAM9G45_OHCI_BASE,
97 .end = AT91SAM9G45_OHCI_BASE + SZ_1M - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = AT91SAM9G45_ID_UHPHS,
102 .end = AT91SAM9G45_ID_UHPHS,
103 .flags = IORESOURCE_IRQ,
104 },
105};
106
107static struct platform_device at91_usbh_ohci_device = {
108 .name = "at91_ohci",
109 .id = -1,
110 .dev = {
111 .dma_mask = &ohci_dmamask,
112 .coherent_dma_mask = DMA_BIT_MASK(32),
113 .platform_data = &usbh_ohci_data,
114 },
115 .resource = usbh_ohci_resources,
116 .num_resources = ARRAY_SIZE(usbh_ohci_resources),
117};
118
119void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
120{
121 int i;
122
123 if (!data)
124 return;
125
126 /* Enable VBus control for UHP ports */
127 for (i = 0; i < data->ports; i++) {
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800128 if (gpio_is_valid(data->vbus_pin[i]))
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100129 at91_set_gpio_output(data->vbus_pin[i], 0);
130 }
131
Thomas Petazzoni1fcaea72011-07-13 11:29:18 +0200132 /* Enable overcurrent notification */
133 for (i = 0; i < data->ports; i++) {
134 if (data->overcurrent_pin[i])
135 at91_set_gpio_input(data->overcurrent_pin[i], 1);
136 }
137
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100138 usbh_ohci_data = *data;
139 platform_device_register(&at91_usbh_ohci_device);
140}
141#else
142void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) {}
143#endif
144
145
146/* --------------------------------------------------------------------
Nicolas Ferref51f78c2009-09-25 12:11:32 +0100147 * USB Host HS (EHCI)
148 * Needs an OHCI host for low and full speed management
149 * -------------------------------------------------------------------- */
150
151#if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
152static u64 ehci_dmamask = DMA_BIT_MASK(32);
153static struct at91_usbh_data usbh_ehci_data;
154
155static struct resource usbh_ehci_resources[] = {
156 [0] = {
157 .start = AT91SAM9G45_EHCI_BASE,
158 .end = AT91SAM9G45_EHCI_BASE + SZ_1M - 1,
159 .flags = IORESOURCE_MEM,
160 },
161 [1] = {
162 .start = AT91SAM9G45_ID_UHPHS,
163 .end = AT91SAM9G45_ID_UHPHS,
164 .flags = IORESOURCE_IRQ,
165 },
166};
167
168static struct platform_device at91_usbh_ehci_device = {
169 .name = "atmel-ehci",
170 .id = -1,
171 .dev = {
172 .dma_mask = &ehci_dmamask,
173 .coherent_dma_mask = DMA_BIT_MASK(32),
174 .platform_data = &usbh_ehci_data,
175 },
176 .resource = usbh_ehci_resources,
177 .num_resources = ARRAY_SIZE(usbh_ehci_resources),
178};
179
180void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)
181{
182 int i;
183
184 if (!data)
185 return;
186
187 /* Enable VBus control for UHP ports */
188 for (i = 0; i < data->ports; i++) {
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800189 if (gpio_is_valid(data->vbus_pin[i]))
Nicolas Ferref51f78c2009-09-25 12:11:32 +0100190 at91_set_gpio_output(data->vbus_pin[i], 0);
191 }
192
193 usbh_ehci_data = *data;
Nicolas Ferref51f78c2009-09-25 12:11:32 +0100194 platform_device_register(&at91_usbh_ehci_device);
195}
196#else
197void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}
198#endif
199
200
201/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100202 * USB HS Device (Gadget)
203 * -------------------------------------------------------------------- */
204
Jochen Friedrichdd0b3822011-10-25 20:51:06 +0200205#if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100206static struct resource usba_udc_resources[] = {
207 [0] = {
208 .start = AT91SAM9G45_UDPHS_FIFO,
209 .end = AT91SAM9G45_UDPHS_FIFO + SZ_512K - 1,
210 .flags = IORESOURCE_MEM,
211 },
212 [1] = {
213 .start = AT91SAM9G45_BASE_UDPHS,
214 .end = AT91SAM9G45_BASE_UDPHS + SZ_1K - 1,
215 .flags = IORESOURCE_MEM,
216 },
217 [2] = {
218 .start = AT91SAM9G45_ID_UDPHS,
219 .end = AT91SAM9G45_ID_UDPHS,
220 .flags = IORESOURCE_IRQ,
221 },
222};
223
224#define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
225 [idx] = { \
226 .name = nam, \
227 .index = idx, \
228 .fifo_size = maxpkt, \
229 .nr_banks = maxbk, \
230 .can_dma = dma, \
231 .can_isoc = isoc, \
232 }
233
234static struct usba_ep_data usba_udc_ep[] __initdata = {
235 EP("ep0", 0, 64, 1, 0, 0),
236 EP("ep1", 1, 1024, 2, 1, 1),
237 EP("ep2", 2, 1024, 2, 1, 1),
238 EP("ep3", 3, 1024, 3, 1, 0),
239 EP("ep4", 4, 1024, 3, 1, 0),
240 EP("ep5", 5, 1024, 3, 1, 1),
241 EP("ep6", 6, 1024, 3, 1, 1),
242};
243
244#undef EP
245
246/*
247 * pdata doesn't have room for any endpoints, so we need to
248 * append room for the ones we need right after it.
249 */
250static struct {
251 struct usba_platform_data pdata;
252 struct usba_ep_data ep[7];
253} usba_udc_data;
254
255static struct platform_device at91_usba_udc_device = {
256 .name = "atmel_usba_udc",
257 .id = -1,
258 .dev = {
259 .platform_data = &usba_udc_data.pdata,
260 },
261 .resource = usba_udc_resources,
262 .num_resources = ARRAY_SIZE(usba_udc_resources),
263};
264
265void __init at91_add_device_usba(struct usba_platform_data *data)
266{
267 usba_udc_data.pdata.vbus_pin = -EINVAL;
268 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
Justin P. Mattock6eab04a2011-04-08 19:49:08 -0700269 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100270
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800271 if (data && gpio_is_valid(data->vbus_pin)) {
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100272 at91_set_gpio_input(data->vbus_pin, 0);
273 at91_set_deglitch(data->vbus_pin, 1);
274 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
275 }
276
277 /* Pullup pin is handled internally by USB device peripheral */
278
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100279 platform_device_register(&at91_usba_udc_device);
280}
281#else
282void __init at91_add_device_usba(struct usba_platform_data *data) {}
283#endif
284
285
286/* --------------------------------------------------------------------
287 * Ethernet
288 * -------------------------------------------------------------------- */
289
290#if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
291static u64 eth_dmamask = DMA_BIT_MASK(32);
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000292static struct macb_platform_data eth_data;
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100293
294static struct resource eth_resources[] = {
295 [0] = {
296 .start = AT91SAM9G45_BASE_EMAC,
297 .end = AT91SAM9G45_BASE_EMAC + SZ_16K - 1,
298 .flags = IORESOURCE_MEM,
299 },
300 [1] = {
301 .start = AT91SAM9G45_ID_EMAC,
302 .end = AT91SAM9G45_ID_EMAC,
303 .flags = IORESOURCE_IRQ,
304 },
305};
306
307static struct platform_device at91sam9g45_eth_device = {
308 .name = "macb",
309 .id = -1,
310 .dev = {
311 .dma_mask = &eth_dmamask,
312 .coherent_dma_mask = DMA_BIT_MASK(32),
313 .platform_data = &eth_data,
314 },
315 .resource = eth_resources,
316 .num_resources = ARRAY_SIZE(eth_resources),
317};
318
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000319void __init at91_add_device_eth(struct macb_platform_data *data)
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100320{
321 if (!data)
322 return;
323
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800324 if (gpio_is_valid(data->phy_irq_pin)) {
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100325 at91_set_gpio_input(data->phy_irq_pin, 0);
326 at91_set_deglitch(data->phy_irq_pin, 1);
327 }
328
329 /* Pins used for MII and RMII */
330 at91_set_A_periph(AT91_PIN_PA17, 0); /* ETXCK_EREFCK */
331 at91_set_A_periph(AT91_PIN_PA15, 0); /* ERXDV */
332 at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
333 at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
334 at91_set_A_periph(AT91_PIN_PA16, 0); /* ERXER */
335 at91_set_A_periph(AT91_PIN_PA14, 0); /* ETXEN */
336 at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX0 */
337 at91_set_A_periph(AT91_PIN_PA11, 0); /* ETX1 */
338 at91_set_A_periph(AT91_PIN_PA19, 0); /* EMDIO */
339 at91_set_A_periph(AT91_PIN_PA18, 0); /* EMDC */
340
341 if (!data->is_rmii) {
342 at91_set_B_periph(AT91_PIN_PA29, 0); /* ECRS */
343 at91_set_B_periph(AT91_PIN_PA30, 0); /* ECOL */
344 at91_set_B_periph(AT91_PIN_PA8, 0); /* ERX2 */
345 at91_set_B_periph(AT91_PIN_PA9, 0); /* ERX3 */
346 at91_set_B_periph(AT91_PIN_PA28, 0); /* ERXCK */
347 at91_set_B_periph(AT91_PIN_PA6, 0); /* ETX2 */
348 at91_set_B_periph(AT91_PIN_PA7, 0); /* ETX3 */
349 at91_set_B_periph(AT91_PIN_PA27, 0); /* ETXER */
350 }
351
352 eth_data = *data;
353 platform_device_register(&at91sam9g45_eth_device);
354}
355#else
Jamie Iles84e0cdb2011-03-08 20:17:06 +0000356void __init at91_add_device_eth(struct macb_platform_data *data) {}
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100357#endif
358
359
360/* --------------------------------------------------------------------
Nicolas Ferre75305d72010-10-22 18:27:48 +0200361 * MMC / SD
362 * -------------------------------------------------------------------- */
363
364#if defined(CONFIG_MMC_ATMELMCI) || defined(CONFIG_MMC_ATMELMCI_MODULE)
365static u64 mmc_dmamask = DMA_BIT_MASK(32);
366static struct mci_platform_data mmc0_data, mmc1_data;
367
368static struct resource mmc0_resources[] = {
369 [0] = {
370 .start = AT91SAM9G45_BASE_MCI0,
371 .end = AT91SAM9G45_BASE_MCI0 + SZ_16K - 1,
372 .flags = IORESOURCE_MEM,
373 },
374 [1] = {
375 .start = AT91SAM9G45_ID_MCI0,
376 .end = AT91SAM9G45_ID_MCI0,
377 .flags = IORESOURCE_IRQ,
378 },
379};
380
381static struct platform_device at91sam9g45_mmc0_device = {
382 .name = "atmel_mci",
383 .id = 0,
384 .dev = {
385 .dma_mask = &mmc_dmamask,
386 .coherent_dma_mask = DMA_BIT_MASK(32),
387 .platform_data = &mmc0_data,
388 },
389 .resource = mmc0_resources,
390 .num_resources = ARRAY_SIZE(mmc0_resources),
391};
392
393static struct resource mmc1_resources[] = {
394 [0] = {
395 .start = AT91SAM9G45_BASE_MCI1,
396 .end = AT91SAM9G45_BASE_MCI1 + SZ_16K - 1,
397 .flags = IORESOURCE_MEM,
398 },
399 [1] = {
400 .start = AT91SAM9G45_ID_MCI1,
401 .end = AT91SAM9G45_ID_MCI1,
402 .flags = IORESOURCE_IRQ,
403 },
404};
405
406static struct platform_device at91sam9g45_mmc1_device = {
407 .name = "atmel_mci",
408 .id = 1,
409 .dev = {
410 .dma_mask = &mmc_dmamask,
411 .coherent_dma_mask = DMA_BIT_MASK(32),
412 .platform_data = &mmc1_data,
413 },
414 .resource = mmc1_resources,
415 .num_resources = ARRAY_SIZE(mmc1_resources),
416};
417
418/* Consider only one slot : slot 0 */
419void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data)
420{
421
422 if (!data)
423 return;
424
425 /* Must have at least one usable slot */
426 if (!data->slot[0].bus_width)
427 return;
428
429#if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
430 {
431 struct at_dma_slave *atslave;
432 struct mci_dma_data *alt_atslave;
433
434 alt_atslave = kzalloc(sizeof(struct mci_dma_data), GFP_KERNEL);
435 atslave = &alt_atslave->sdata;
436
437 /* DMA slave channel configuration */
438 atslave->dma_dev = &at_hdmac_device.dev;
439 atslave->reg_width = AT_DMA_SLAVE_WIDTH_32BIT;
440 atslave->cfg = ATC_FIFOCFG_HALFFIFO
441 | ATC_SRC_H2SEL_HW | ATC_DST_H2SEL_HW;
442 atslave->ctrla = ATC_SCSIZE_16 | ATC_DCSIZE_16;
443 if (mmc_id == 0) /* MCI0 */
444 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI0)
445 | ATC_DST_PER(AT_DMA_ID_MCI0);
446
447 else /* MCI1 */
448 atslave->cfg |= ATC_SRC_PER(AT_DMA_ID_MCI1)
449 | ATC_DST_PER(AT_DMA_ID_MCI1);
450
451 data->dma_slave = alt_atslave;
452 }
453#endif
454
455
456 /* input/irq */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800457 if (gpio_is_valid(data->slot[0].detect_pin)) {
Nicolas Ferre75305d72010-10-22 18:27:48 +0200458 at91_set_gpio_input(data->slot[0].detect_pin, 1);
459 at91_set_deglitch(data->slot[0].detect_pin, 1);
460 }
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800461 if (gpio_is_valid(data->slot[0].wp_pin))
Nicolas Ferre75305d72010-10-22 18:27:48 +0200462 at91_set_gpio_input(data->slot[0].wp_pin, 1);
463
464 if (mmc_id == 0) { /* MCI0 */
465
466 /* CLK */
467 at91_set_A_periph(AT91_PIN_PA0, 0);
468
469 /* CMD */
470 at91_set_A_periph(AT91_PIN_PA1, 1);
471
472 /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
473 at91_set_A_periph(AT91_PIN_PA2, 1);
474 if (data->slot[0].bus_width == 4) {
475 at91_set_A_periph(AT91_PIN_PA3, 1);
476 at91_set_A_periph(AT91_PIN_PA4, 1);
477 at91_set_A_periph(AT91_PIN_PA5, 1);
478 if (data->slot[0].bus_width == 8) {
479 at91_set_A_periph(AT91_PIN_PA6, 1);
480 at91_set_A_periph(AT91_PIN_PA7, 1);
481 at91_set_A_periph(AT91_PIN_PA8, 1);
482 at91_set_A_periph(AT91_PIN_PA9, 1);
483 }
484 }
485
486 mmc0_data = *data;
Nicolas Ferre75305d72010-10-22 18:27:48 +0200487 platform_device_register(&at91sam9g45_mmc0_device);
488
489 } else { /* MCI1 */
490
491 /* CLK */
492 at91_set_A_periph(AT91_PIN_PA31, 0);
493
494 /* CMD */
495 at91_set_A_periph(AT91_PIN_PA22, 1);
496
497 /* DAT0, maybe DAT1..DAT3 and maybe DAT4..DAT7 */
498 at91_set_A_periph(AT91_PIN_PA23, 1);
499 if (data->slot[0].bus_width == 4) {
500 at91_set_A_periph(AT91_PIN_PA24, 1);
501 at91_set_A_periph(AT91_PIN_PA25, 1);
502 at91_set_A_periph(AT91_PIN_PA26, 1);
503 if (data->slot[0].bus_width == 8) {
504 at91_set_A_periph(AT91_PIN_PA27, 1);
505 at91_set_A_periph(AT91_PIN_PA28, 1);
506 at91_set_A_periph(AT91_PIN_PA29, 1);
507 at91_set_A_periph(AT91_PIN_PA30, 1);
508 }
509 }
510
511 mmc1_data = *data;
Nicolas Ferre75305d72010-10-22 18:27:48 +0200512 platform_device_register(&at91sam9g45_mmc1_device);
513
514 }
515}
516#else
517void __init at91_add_device_mci(short mmc_id, struct mci_platform_data *data) {}
518#endif
519
520
521/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100522 * NAND / SmartMedia
523 * -------------------------------------------------------------------- */
524
525#if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
526static struct atmel_nand_data nand_data;
527
528#define NAND_BASE AT91_CHIPSELECT_3
529
530static struct resource nand_resources[] = {
531 [0] = {
532 .start = NAND_BASE,
533 .end = NAND_BASE + SZ_256M - 1,
534 .flags = IORESOURCE_MEM,
535 },
536 [1] = {
Jean-Christophe PLAGNIOL-VILLARDd28edd12011-09-18 09:31:56 +0800537 .start = AT91SAM9G45_BASE_ECC,
538 .end = AT91SAM9G45_BASE_ECC + SZ_512 - 1,
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100539 .flags = IORESOURCE_MEM,
540 }
541};
542
543static struct platform_device at91sam9g45_nand_device = {
544 .name = "atmel_nand",
545 .id = -1,
546 .dev = {
547 .platform_data = &nand_data,
548 },
549 .resource = nand_resources,
550 .num_resources = ARRAY_SIZE(nand_resources),
551};
552
553void __init at91_add_device_nand(struct atmel_nand_data *data)
554{
555 unsigned long csa;
556
557 if (!data)
558 return;
559
560 csa = at91_sys_read(AT91_MATRIX_EBICSA);
561 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
562
563 /* enable pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800564 if (gpio_is_valid(data->enable_pin))
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100565 at91_set_gpio_output(data->enable_pin, 1);
566
567 /* ready/busy pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800568 if (gpio_is_valid(data->rdy_pin))
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100569 at91_set_gpio_input(data->rdy_pin, 1);
570
571 /* card detect pin */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800572 if (gpio_is_valid(data->det_pin))
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100573 at91_set_gpio_input(data->det_pin, 1);
574
575 nand_data = *data;
576 platform_device_register(&at91sam9g45_nand_device);
577}
578#else
579void __init at91_add_device_nand(struct atmel_nand_data *data) {}
580#endif
581
582
583/* --------------------------------------------------------------------
584 * TWI (i2c)
585 * -------------------------------------------------------------------- */
586
587/*
588 * Prefer the GPIO code since the TWI controller isn't robust
589 * (gets overruns and underruns under load) and can only issue
590 * repeated STARTs in one scenario (the driver doesn't yet handle them).
591 */
592#if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
593static struct i2c_gpio_platform_data pdata_i2c0 = {
594 .sda_pin = AT91_PIN_PA20,
595 .sda_is_open_drain = 1,
596 .scl_pin = AT91_PIN_PA21,
597 .scl_is_open_drain = 1,
Peter Korsgaard1d5b4c02010-09-22 21:29:59 +0100598 .udelay = 5, /* ~100 kHz */
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100599};
600
601static struct platform_device at91sam9g45_twi0_device = {
602 .name = "i2c-gpio",
603 .id = 0,
604 .dev.platform_data = &pdata_i2c0,
605};
606
607static struct i2c_gpio_platform_data pdata_i2c1 = {
608 .sda_pin = AT91_PIN_PB10,
609 .sda_is_open_drain = 1,
610 .scl_pin = AT91_PIN_PB11,
611 .scl_is_open_drain = 1,
Peter Korsgaard1d5b4c02010-09-22 21:29:59 +0100612 .udelay = 5, /* ~100 kHz */
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100613};
614
615static struct platform_device at91sam9g45_twi1_device = {
616 .name = "i2c-gpio",
617 .id = 1,
618 .dev.platform_data = &pdata_i2c1,
619};
620
621void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
622{
623 i2c_register_board_info(i2c_id, devices, nr_devices);
624
625 if (i2c_id == 0) {
626 at91_set_GPIO_periph(AT91_PIN_PA20, 1); /* TWD (SDA) */
627 at91_set_multi_drive(AT91_PIN_PA20, 1);
628
629 at91_set_GPIO_periph(AT91_PIN_PA21, 1); /* TWCK (SCL) */
630 at91_set_multi_drive(AT91_PIN_PA21, 1);
631
632 platform_device_register(&at91sam9g45_twi0_device);
633 } else {
634 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* TWD (SDA) */
635 at91_set_multi_drive(AT91_PIN_PB10, 1);
636
637 at91_set_GPIO_periph(AT91_PIN_PB11, 1); /* TWCK (SCL) */
638 at91_set_multi_drive(AT91_PIN_PB11, 1);
639
640 platform_device_register(&at91sam9g45_twi1_device);
641 }
642}
643
644#elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
645static struct resource twi0_resources[] = {
646 [0] = {
647 .start = AT91SAM9G45_BASE_TWI0,
648 .end = AT91SAM9G45_BASE_TWI0 + SZ_16K - 1,
649 .flags = IORESOURCE_MEM,
650 },
651 [1] = {
652 .start = AT91SAM9G45_ID_TWI0,
653 .end = AT91SAM9G45_ID_TWI0,
654 .flags = IORESOURCE_IRQ,
655 },
656};
657
658static struct platform_device at91sam9g45_twi0_device = {
659 .name = "at91_i2c",
660 .id = 0,
661 .resource = twi0_resources,
662 .num_resources = ARRAY_SIZE(twi0_resources),
663};
664
665static struct resource twi1_resources[] = {
666 [0] = {
667 .start = AT91SAM9G45_BASE_TWI1,
668 .end = AT91SAM9G45_BASE_TWI1 + SZ_16K - 1,
669 .flags = IORESOURCE_MEM,
670 },
671 [1] = {
672 .start = AT91SAM9G45_ID_TWI1,
673 .end = AT91SAM9G45_ID_TWI1,
674 .flags = IORESOURCE_IRQ,
675 },
676};
677
678static struct platform_device at91sam9g45_twi1_device = {
679 .name = "at91_i2c",
680 .id = 1,
681 .resource = twi1_resources,
682 .num_resources = ARRAY_SIZE(twi1_resources),
683};
684
685void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
686{
687 i2c_register_board_info(i2c_id, devices, nr_devices);
688
689 /* pins used for TWI interface */
690 if (i2c_id == 0) {
691 at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */
692 at91_set_multi_drive(AT91_PIN_PA20, 1);
693
694 at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */
695 at91_set_multi_drive(AT91_PIN_PA21, 1);
696
697 platform_device_register(&at91sam9g45_twi0_device);
698 } else {
699 at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */
700 at91_set_multi_drive(AT91_PIN_PB10, 1);
701
702 at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */
703 at91_set_multi_drive(AT91_PIN_PB11, 1);
704
705 platform_device_register(&at91sam9g45_twi1_device);
706 }
707}
708#else
709void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
710#endif
711
712
713/* --------------------------------------------------------------------
714 * SPI
715 * -------------------------------------------------------------------- */
716
717#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
718static u64 spi_dmamask = DMA_BIT_MASK(32);
719
720static struct resource spi0_resources[] = {
721 [0] = {
722 .start = AT91SAM9G45_BASE_SPI0,
723 .end = AT91SAM9G45_BASE_SPI0 + SZ_16K - 1,
724 .flags = IORESOURCE_MEM,
725 },
726 [1] = {
727 .start = AT91SAM9G45_ID_SPI0,
728 .end = AT91SAM9G45_ID_SPI0,
729 .flags = IORESOURCE_IRQ,
730 },
731};
732
733static struct platform_device at91sam9g45_spi0_device = {
734 .name = "atmel_spi",
735 .id = 0,
736 .dev = {
737 .dma_mask = &spi_dmamask,
738 .coherent_dma_mask = DMA_BIT_MASK(32),
739 },
740 .resource = spi0_resources,
741 .num_resources = ARRAY_SIZE(spi0_resources),
742};
743
744static const unsigned spi0_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PB18, AT91_PIN_PB19, AT91_PIN_PD27 };
745
746static struct resource spi1_resources[] = {
747 [0] = {
748 .start = AT91SAM9G45_BASE_SPI1,
749 .end = AT91SAM9G45_BASE_SPI1 + SZ_16K - 1,
750 .flags = IORESOURCE_MEM,
751 },
752 [1] = {
753 .start = AT91SAM9G45_ID_SPI1,
754 .end = AT91SAM9G45_ID_SPI1,
755 .flags = IORESOURCE_IRQ,
756 },
757};
758
759static struct platform_device at91sam9g45_spi1_device = {
760 .name = "atmel_spi",
761 .id = 1,
762 .dev = {
763 .dma_mask = &spi_dmamask,
764 .coherent_dma_mask = DMA_BIT_MASK(32),
765 },
766 .resource = spi1_resources,
767 .num_resources = ARRAY_SIZE(spi1_resources),
768};
769
770static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB17, AT91_PIN_PD28, AT91_PIN_PD18, AT91_PIN_PD19 };
771
772void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
773{
774 int i;
775 unsigned long cs_pin;
776 short enable_spi0 = 0;
777 short enable_spi1 = 0;
778
779 /* Choose SPI chip-selects */
780 for (i = 0; i < nr_devices; i++) {
781 if (devices[i].controller_data)
782 cs_pin = (unsigned long) devices[i].controller_data;
783 else if (devices[i].bus_num == 0)
784 cs_pin = spi0_standard_cs[devices[i].chip_select];
785 else
786 cs_pin = spi1_standard_cs[devices[i].chip_select];
787
788 if (devices[i].bus_num == 0)
789 enable_spi0 = 1;
790 else
791 enable_spi1 = 1;
792
793 /* enable chip-select pin */
794 at91_set_gpio_output(cs_pin, 1);
795
796 /* pass chip-select pin to driver */
797 devices[i].controller_data = (void *) cs_pin;
798 }
799
800 spi_register_board_info(devices, nr_devices);
801
802 /* Configure SPI bus(es) */
803 if (enable_spi0) {
804 at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
805 at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
806 at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
807
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100808 platform_device_register(&at91sam9g45_spi0_device);
809 }
810 if (enable_spi1) {
811 at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
812 at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
813 at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
814
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100815 platform_device_register(&at91sam9g45_spi1_device);
816 }
817}
818#else
819void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
820#endif
821
822
823/* --------------------------------------------------------------------
Nicolas Ferre378ac652009-09-18 16:14:22 +0100824 * AC97
825 * -------------------------------------------------------------------- */
826
827#if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
828static u64 ac97_dmamask = DMA_BIT_MASK(32);
829static struct ac97c_platform_data ac97_data;
830
831static struct resource ac97_resources[] = {
832 [0] = {
833 .start = AT91SAM9G45_BASE_AC97C,
834 .end = AT91SAM9G45_BASE_AC97C + SZ_16K - 1,
835 .flags = IORESOURCE_MEM,
836 },
837 [1] = {
838 .start = AT91SAM9G45_ID_AC97C,
839 .end = AT91SAM9G45_ID_AC97C,
840 .flags = IORESOURCE_IRQ,
841 },
842};
843
844static struct platform_device at91sam9g45_ac97_device = {
845 .name = "atmel_ac97c",
846 .id = 0,
847 .dev = {
848 .dma_mask = &ac97_dmamask,
849 .coherent_dma_mask = DMA_BIT_MASK(32),
850 .platform_data = &ac97_data,
851 },
852 .resource = ac97_resources,
853 .num_resources = ARRAY_SIZE(ac97_resources),
854};
855
856void __init at91_add_device_ac97(struct ac97c_platform_data *data)
857{
858 if (!data)
859 return;
860
861 at91_set_A_periph(AT91_PIN_PD8, 0); /* AC97FS */
862 at91_set_A_periph(AT91_PIN_PD9, 0); /* AC97CK */
863 at91_set_A_periph(AT91_PIN_PD7, 0); /* AC97TX */
864 at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
865
866 /* reset */
Jean-Christophe PLAGNIOL-VILLARDcc9f9ae2011-09-19 15:28:25 +0800867 if (gpio_is_valid(data->reset_pin))
Nicolas Ferre378ac652009-09-18 16:14:22 +0100868 at91_set_gpio_output(data->reset_pin, 0);
869
870 ac97_data = *data;
871 platform_device_register(&at91sam9g45_ac97_device);
872}
873#else
874void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
875#endif
876
Josh Wu343754f2011-10-22 15:17:40 +0800877/* --------------------------------------------------------------------
878 * Image Sensor Interface
879 * -------------------------------------------------------------------- */
880#if defined(CONFIG_VIDEO_ATMEL_ISI) || defined(CONFIG_VIDEO_ATMEL_ISI_MODULE)
881static u64 isi_dmamask = DMA_BIT_MASK(32);
882static struct isi_platform_data isi_data;
883
884struct resource isi_resources[] = {
885 [0] = {
886 .start = AT91SAM9G45_BASE_ISI,
887 .end = AT91SAM9G45_BASE_ISI + SZ_16K - 1,
888 .flags = IORESOURCE_MEM,
889 },
890 [1] = {
891 .start = AT91SAM9G45_ID_ISI,
892 .end = AT91SAM9G45_ID_ISI,
893 .flags = IORESOURCE_IRQ,
894 },
895};
896
897static struct platform_device at91sam9g45_isi_device = {
898 .name = "atmel_isi",
899 .id = 0,
900 .dev = {
901 .dma_mask = &isi_dmamask,
902 .coherent_dma_mask = DMA_BIT_MASK(32),
903 .platform_data = &isi_data,
904 },
905 .resource = isi_resources,
906 .num_resources = ARRAY_SIZE(isi_resources),
907};
908
909static struct clk_lookup isi_mck_lookups[] = {
910 CLKDEV_CON_DEV_ID("isi_mck", "atmel_isi.0", NULL),
911};
912
913void __init at91_add_device_isi(struct isi_platform_data *data,
914 bool use_pck_as_mck)
915{
916 struct clk *pck;
917 struct clk *parent;
918
919 if (!data)
920 return;
921 isi_data = *data;
922
923 at91_set_A_periph(AT91_PIN_PB20, 0); /* ISI_D0 */
924 at91_set_A_periph(AT91_PIN_PB21, 0); /* ISI_D1 */
925 at91_set_A_periph(AT91_PIN_PB22, 0); /* ISI_D2 */
926 at91_set_A_periph(AT91_PIN_PB23, 0); /* ISI_D3 */
927 at91_set_A_periph(AT91_PIN_PB24, 0); /* ISI_D4 */
928 at91_set_A_periph(AT91_PIN_PB25, 0); /* ISI_D5 */
929 at91_set_A_periph(AT91_PIN_PB26, 0); /* ISI_D6 */
930 at91_set_A_periph(AT91_PIN_PB27, 0); /* ISI_D7 */
931 at91_set_A_periph(AT91_PIN_PB28, 0); /* ISI_PCK */
932 at91_set_A_periph(AT91_PIN_PB30, 0); /* ISI_HSYNC */
933 at91_set_A_periph(AT91_PIN_PB29, 0); /* ISI_VSYNC */
934 at91_set_B_periph(AT91_PIN_PB8, 0); /* ISI_PD8 */
935 at91_set_B_periph(AT91_PIN_PB9, 0); /* ISI_PD9 */
936 at91_set_B_periph(AT91_PIN_PB10, 0); /* ISI_PD10 */
937 at91_set_B_periph(AT91_PIN_PB11, 0); /* ISI_PD11 */
938
939 platform_device_register(&at91sam9g45_isi_device);
940
941 if (use_pck_as_mck) {
942 at91_set_B_periph(AT91_PIN_PB31, 0); /* ISI_MCK (PCK1) */
943
944 pck = clk_get(NULL, "pck1");
945 parent = clk_get(NULL, "plla");
946
947 BUG_ON(IS_ERR(pck) || IS_ERR(parent));
948
949 if (clk_set_parent(pck, parent)) {
950 pr_err("Failed to set PCK's parent\n");
951 } else {
952 /* Register PCK as ISI_MCK */
953 isi_mck_lookups[0].clk = pck;
954 clkdev_add_table(isi_mck_lookups,
955 ARRAY_SIZE(isi_mck_lookups));
956 }
957
958 clk_put(pck);
959 clk_put(parent);
960 }
961}
962#else
963void __init at91_add_device_isi(struct isi_platform_data *data,
964 bool use_pck_as_mck) {}
965#endif
966
Nicolas Ferre378ac652009-09-18 16:14:22 +0100967
968/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +0100969 * LCD Controller
970 * -------------------------------------------------------------------- */
971
972#if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
973static u64 lcdc_dmamask = DMA_BIT_MASK(32);
974static struct atmel_lcdfb_info lcdc_data;
975
976static struct resource lcdc_resources[] = {
977 [0] = {
978 .start = AT91SAM9G45_LCDC_BASE,
979 .end = AT91SAM9G45_LCDC_BASE + SZ_4K - 1,
980 .flags = IORESOURCE_MEM,
981 },
982 [1] = {
983 .start = AT91SAM9G45_ID_LCDC,
984 .end = AT91SAM9G45_ID_LCDC,
985 .flags = IORESOURCE_IRQ,
986 },
987};
988
989static struct platform_device at91_lcdc_device = {
990 .name = "atmel_lcdfb",
991 .id = 0,
992 .dev = {
993 .dma_mask = &lcdc_dmamask,
994 .coherent_dma_mask = DMA_BIT_MASK(32),
995 .platform_data = &lcdc_data,
996 },
997 .resource = lcdc_resources,
998 .num_resources = ARRAY_SIZE(lcdc_resources),
999};
1000
1001void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
1002{
1003 if (!data)
1004 return;
1005
1006 at91_set_A_periph(AT91_PIN_PE0, 0); /* LCDDPWR */
1007
1008 at91_set_A_periph(AT91_PIN_PE2, 0); /* LCDCC */
1009 at91_set_A_periph(AT91_PIN_PE3, 0); /* LCDVSYNC */
1010 at91_set_A_periph(AT91_PIN_PE4, 0); /* LCDHSYNC */
1011 at91_set_A_periph(AT91_PIN_PE5, 0); /* LCDDOTCK */
1012 at91_set_A_periph(AT91_PIN_PE6, 0); /* LCDDEN */
1013 at91_set_A_periph(AT91_PIN_PE7, 0); /* LCDD0 */
1014 at91_set_A_periph(AT91_PIN_PE8, 0); /* LCDD1 */
1015 at91_set_A_periph(AT91_PIN_PE9, 0); /* LCDD2 */
1016 at91_set_A_periph(AT91_PIN_PE10, 0); /* LCDD3 */
1017 at91_set_A_periph(AT91_PIN_PE11, 0); /* LCDD4 */
1018 at91_set_A_periph(AT91_PIN_PE12, 0); /* LCDD5 */
1019 at91_set_A_periph(AT91_PIN_PE13, 0); /* LCDD6 */
1020 at91_set_A_periph(AT91_PIN_PE14, 0); /* LCDD7 */
1021 at91_set_A_periph(AT91_PIN_PE15, 0); /* LCDD8 */
1022 at91_set_A_periph(AT91_PIN_PE16, 0); /* LCDD9 */
1023 at91_set_A_periph(AT91_PIN_PE17, 0); /* LCDD10 */
1024 at91_set_A_periph(AT91_PIN_PE18, 0); /* LCDD11 */
1025 at91_set_A_periph(AT91_PIN_PE19, 0); /* LCDD12 */
1026 at91_set_A_periph(AT91_PIN_PE20, 0); /* LCDD13 */
1027 at91_set_A_periph(AT91_PIN_PE21, 0); /* LCDD14 */
1028 at91_set_A_periph(AT91_PIN_PE22, 0); /* LCDD15 */
1029 at91_set_A_periph(AT91_PIN_PE23, 0); /* LCDD16 */
1030 at91_set_A_periph(AT91_PIN_PE24, 0); /* LCDD17 */
1031 at91_set_A_periph(AT91_PIN_PE25, 0); /* LCDD18 */
1032 at91_set_A_periph(AT91_PIN_PE26, 0); /* LCDD19 */
1033 at91_set_A_periph(AT91_PIN_PE27, 0); /* LCDD20 */
1034 at91_set_A_periph(AT91_PIN_PE28, 0); /* LCDD21 */
1035 at91_set_A_periph(AT91_PIN_PE29, 0); /* LCDD22 */
1036 at91_set_A_periph(AT91_PIN_PE30, 0); /* LCDD23 */
1037
1038 lcdc_data = *data;
1039 platform_device_register(&at91_lcdc_device);
1040}
1041#else
1042void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
1043#endif
1044
1045
1046/* --------------------------------------------------------------------
1047 * Timer/Counter block
1048 * -------------------------------------------------------------------- */
1049
1050#ifdef CONFIG_ATMEL_TCLIB
1051static struct resource tcb0_resources[] = {
1052 [0] = {
1053 .start = AT91SAM9G45_BASE_TCB0,
1054 .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1,
1055 .flags = IORESOURCE_MEM,
1056 },
1057 [1] = {
1058 .start = AT91SAM9G45_ID_TCB,
1059 .end = AT91SAM9G45_ID_TCB,
1060 .flags = IORESOURCE_IRQ,
1061 },
1062};
1063
1064static struct platform_device at91sam9g45_tcb0_device = {
1065 .name = "atmel_tcb",
1066 .id = 0,
1067 .resource = tcb0_resources,
1068 .num_resources = ARRAY_SIZE(tcb0_resources),
1069};
1070
1071/* TCB1 begins with TC3 */
1072static struct resource tcb1_resources[] = {
1073 [0] = {
1074 .start = AT91SAM9G45_BASE_TCB1,
1075 .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1,
1076 .flags = IORESOURCE_MEM,
1077 },
1078 [1] = {
1079 .start = AT91SAM9G45_ID_TCB,
1080 .end = AT91SAM9G45_ID_TCB,
1081 .flags = IORESOURCE_IRQ,
1082 },
1083};
1084
1085static struct platform_device at91sam9g45_tcb1_device = {
1086 .name = "atmel_tcb",
1087 .id = 1,
1088 .resource = tcb1_resources,
1089 .num_resources = ARRAY_SIZE(tcb1_resources),
1090};
1091
1092static void __init at91_add_device_tc(void)
1093{
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001094 platform_device_register(&at91sam9g45_tcb0_device);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001095 platform_device_register(&at91sam9g45_tcb1_device);
1096}
1097#else
1098static void __init at91_add_device_tc(void) { }
1099#endif
1100
1101
1102/* --------------------------------------------------------------------
1103 * RTC
1104 * -------------------------------------------------------------------- */
1105
1106#if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
Jean-Christophe PLAGNIOL-VILLARDd28bdfc2011-11-14 14:24:53 +08001107static struct resource rtc_resources[] = {
1108 [0] = {
1109 .start = AT91SAM9G45_BASE_RTC,
1110 .end = AT91SAM9G45_BASE_RTC + SZ_256 - 1,
1111 .flags = IORESOURCE_MEM,
1112 },
1113 [1] = {
1114 .start = AT91_ID_SYS,
1115 .end = AT91_ID_SYS,
1116 .flags = IORESOURCE_IRQ,
1117 },
1118};
1119
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001120static struct platform_device at91sam9g45_rtc_device = {
1121 .name = "at91_rtc",
1122 .id = -1,
Jean-Christophe PLAGNIOL-VILLARDd28bdfc2011-11-14 14:24:53 +08001123 .resource = rtc_resources,
1124 .num_resources = ARRAY_SIZE(rtc_resources),
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001125};
1126
1127static void __init at91_add_device_rtc(void)
1128{
1129 platform_device_register(&at91sam9g45_rtc_device);
1130}
1131#else
1132static void __init at91_add_device_rtc(void) {}
1133#endif
1134
1135
1136/* --------------------------------------------------------------------
Nicolas Ferre985f37f2009-11-19 09:32:52 -08001137 * Touchscreen
1138 * -------------------------------------------------------------------- */
1139
1140#if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
1141static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
1142static struct at91_tsadcc_data tsadcc_data;
1143
1144static struct resource tsadcc_resources[] = {
1145 [0] = {
1146 .start = AT91SAM9G45_BASE_TSC,
1147 .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
1148 .flags = IORESOURCE_MEM,
1149 },
1150 [1] = {
1151 .start = AT91SAM9G45_ID_TSC,
1152 .end = AT91SAM9G45_ID_TSC,
1153 .flags = IORESOURCE_IRQ,
1154 }
1155};
1156
1157static struct platform_device at91sam9g45_tsadcc_device = {
1158 .name = "atmel_tsadcc",
1159 .id = -1,
1160 .dev = {
1161 .dma_mask = &tsadcc_dmamask,
1162 .coherent_dma_mask = DMA_BIT_MASK(32),
1163 .platform_data = &tsadcc_data,
1164 },
1165 .resource = tsadcc_resources,
1166 .num_resources = ARRAY_SIZE(tsadcc_resources),
1167};
1168
1169void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
1170{
1171 if (!data)
1172 return;
1173
1174 at91_set_gpio_input(AT91_PIN_PD20, 0); /* AD0_XR */
1175 at91_set_gpio_input(AT91_PIN_PD21, 0); /* AD1_XL */
1176 at91_set_gpio_input(AT91_PIN_PD22, 0); /* AD2_YT */
1177 at91_set_gpio_input(AT91_PIN_PD23, 0); /* AD3_TB */
1178
1179 tsadcc_data = *data;
1180 platform_device_register(&at91sam9g45_tsadcc_device);
1181}
1182#else
1183void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
1184#endif
1185
1186
1187/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001188 * RTT
1189 * -------------------------------------------------------------------- */
1190
1191static struct resource rtt_resources[] = {
1192 {
Jean-Christophe PLAGNIOL-VILLARDeab5fd62011-09-18 10:12:00 +08001193 .start = AT91SAM9G45_BASE_RTT,
1194 .end = AT91SAM9G45_BASE_RTT + SZ_16 - 1,
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001195 .flags = IORESOURCE_MEM,
1196 }
1197};
1198
1199static struct platform_device at91sam9g45_rtt_device = {
1200 .name = "at91_rtt",
1201 .id = 0,
1202 .resource = rtt_resources,
1203 .num_resources = ARRAY_SIZE(rtt_resources),
1204};
1205
1206static void __init at91_add_device_rtt(void)
1207{
1208 platform_device_register(&at91sam9g45_rtt_device);
1209}
1210
1211
1212/* --------------------------------------------------------------------
Peter Korsgaard237a62a2011-10-06 17:41:33 +02001213 * TRNG
1214 * -------------------------------------------------------------------- */
1215
1216#if defined(CONFIG_HW_RANDOM_ATMEL) || defined(CONFIG_HW_RANDOM_ATMEL_MODULE)
1217static struct resource trng_resources[] = {
1218 {
1219 .start = AT91SAM9G45_BASE_TRNG,
1220 .end = AT91SAM9G45_BASE_TRNG + SZ_16K - 1,
1221 .flags = IORESOURCE_MEM,
1222 },
1223};
1224
1225static struct platform_device at91sam9g45_trng_device = {
1226 .name = "atmel-trng",
1227 .id = -1,
1228 .resource = trng_resources,
1229 .num_resources = ARRAY_SIZE(trng_resources),
1230};
1231
1232static void __init at91_add_device_trng(void)
1233{
1234 platform_device_register(&at91sam9g45_trng_device);
1235}
1236#else
1237static void __init at91_add_device_trng(void) {}
1238#endif
1239
1240/* --------------------------------------------------------------------
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001241 * Watchdog
1242 * -------------------------------------------------------------------- */
1243
Yegor Yefremov47263742009-10-20 08:39:41 +01001244#if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +08001245static struct resource wdt_resources[] = {
1246 {
1247 .start = AT91SAM9G45_BASE_WDT,
1248 .end = AT91SAM9G45_BASE_WDT + SZ_16 - 1,
1249 .flags = IORESOURCE_MEM,
1250 }
1251};
1252
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001253static struct platform_device at91sam9g45_wdt_device = {
1254 .name = "at91_wdt",
1255 .id = -1,
Jean-Christophe PLAGNIOL-VILLARDc1c30a22011-11-02 01:43:31 +08001256 .resource = wdt_resources,
1257 .num_resources = ARRAY_SIZE(wdt_resources),
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001258};
1259
1260static void __init at91_add_device_watchdog(void)
1261{
1262 platform_device_register(&at91sam9g45_wdt_device);
1263}
1264#else
1265static void __init at91_add_device_watchdog(void) {}
1266#endif
1267
1268
1269/* --------------------------------------------------------------------
1270 * PWM
1271 * --------------------------------------------------------------------*/
1272
1273#if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE)
1274static u32 pwm_mask;
1275
1276static struct resource pwm_resources[] = {
1277 [0] = {
1278 .start = AT91SAM9G45_BASE_PWMC,
1279 .end = AT91SAM9G45_BASE_PWMC + SZ_16K - 1,
1280 .flags = IORESOURCE_MEM,
1281 },
1282 [1] = {
1283 .start = AT91SAM9G45_ID_PWMC,
1284 .end = AT91SAM9G45_ID_PWMC,
1285 .flags = IORESOURCE_IRQ,
1286 },
1287};
1288
1289static struct platform_device at91sam9g45_pwm0_device = {
1290 .name = "atmel_pwm",
1291 .id = -1,
1292 .dev = {
1293 .platform_data = &pwm_mask,
1294 },
1295 .resource = pwm_resources,
1296 .num_resources = ARRAY_SIZE(pwm_resources),
1297};
1298
1299void __init at91_add_device_pwm(u32 mask)
1300{
1301 if (mask & (1 << AT91_PWM0))
1302 at91_set_B_periph(AT91_PIN_PD24, 1); /* enable PWM0 */
1303
1304 if (mask & (1 << AT91_PWM1))
1305 at91_set_B_periph(AT91_PIN_PD31, 1); /* enable PWM1 */
1306
1307 if (mask & (1 << AT91_PWM2))
1308 at91_set_B_periph(AT91_PIN_PD26, 1); /* enable PWM2 */
1309
1310 if (mask & (1 << AT91_PWM3))
1311 at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */
1312
1313 pwm_mask = mask;
1314
1315 platform_device_register(&at91sam9g45_pwm0_device);
1316}
1317#else
1318void __init at91_add_device_pwm(u32 mask) {}
1319#endif
1320
1321
1322/* --------------------------------------------------------------------
1323 * SSC -- Synchronous Serial Controller
1324 * -------------------------------------------------------------------- */
1325
1326#if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
1327static u64 ssc0_dmamask = DMA_BIT_MASK(32);
1328
1329static struct resource ssc0_resources[] = {
1330 [0] = {
1331 .start = AT91SAM9G45_BASE_SSC0,
1332 .end = AT91SAM9G45_BASE_SSC0 + SZ_16K - 1,
1333 .flags = IORESOURCE_MEM,
1334 },
1335 [1] = {
1336 .start = AT91SAM9G45_ID_SSC0,
1337 .end = AT91SAM9G45_ID_SSC0,
1338 .flags = IORESOURCE_IRQ,
1339 },
1340};
1341
1342static struct platform_device at91sam9g45_ssc0_device = {
1343 .name = "ssc",
1344 .id = 0,
1345 .dev = {
1346 .dma_mask = &ssc0_dmamask,
1347 .coherent_dma_mask = DMA_BIT_MASK(32),
1348 },
1349 .resource = ssc0_resources,
1350 .num_resources = ARRAY_SIZE(ssc0_resources),
1351};
1352
1353static inline void configure_ssc0_pins(unsigned pins)
1354{
1355 if (pins & ATMEL_SSC_TF)
1356 at91_set_A_periph(AT91_PIN_PD1, 1);
1357 if (pins & ATMEL_SSC_TK)
1358 at91_set_A_periph(AT91_PIN_PD0, 1);
1359 if (pins & ATMEL_SSC_TD)
1360 at91_set_A_periph(AT91_PIN_PD2, 1);
1361 if (pins & ATMEL_SSC_RD)
1362 at91_set_A_periph(AT91_PIN_PD3, 1);
1363 if (pins & ATMEL_SSC_RK)
1364 at91_set_A_periph(AT91_PIN_PD4, 1);
1365 if (pins & ATMEL_SSC_RF)
1366 at91_set_A_periph(AT91_PIN_PD5, 1);
1367}
1368
1369static u64 ssc1_dmamask = DMA_BIT_MASK(32);
1370
1371static struct resource ssc1_resources[] = {
1372 [0] = {
1373 .start = AT91SAM9G45_BASE_SSC1,
1374 .end = AT91SAM9G45_BASE_SSC1 + SZ_16K - 1,
1375 .flags = IORESOURCE_MEM,
1376 },
1377 [1] = {
1378 .start = AT91SAM9G45_ID_SSC1,
1379 .end = AT91SAM9G45_ID_SSC1,
1380 .flags = IORESOURCE_IRQ,
1381 },
1382};
1383
1384static struct platform_device at91sam9g45_ssc1_device = {
1385 .name = "ssc",
1386 .id = 1,
1387 .dev = {
1388 .dma_mask = &ssc1_dmamask,
1389 .coherent_dma_mask = DMA_BIT_MASK(32),
1390 },
1391 .resource = ssc1_resources,
1392 .num_resources = ARRAY_SIZE(ssc1_resources),
1393};
1394
1395static inline void configure_ssc1_pins(unsigned pins)
1396{
1397 if (pins & ATMEL_SSC_TF)
1398 at91_set_A_periph(AT91_PIN_PD14, 1);
1399 if (pins & ATMEL_SSC_TK)
1400 at91_set_A_periph(AT91_PIN_PD12, 1);
1401 if (pins & ATMEL_SSC_TD)
1402 at91_set_A_periph(AT91_PIN_PD10, 1);
1403 if (pins & ATMEL_SSC_RD)
1404 at91_set_A_periph(AT91_PIN_PD11, 1);
1405 if (pins & ATMEL_SSC_RK)
1406 at91_set_A_periph(AT91_PIN_PD13, 1);
1407 if (pins & ATMEL_SSC_RF)
1408 at91_set_A_periph(AT91_PIN_PD15, 1);
1409}
1410
1411/*
1412 * SSC controllers are accessed through library code, instead of any
1413 * kind of all-singing/all-dancing driver. For example one could be
1414 * used by a particular I2S audio codec's driver, while another one
1415 * on the same system might be used by a custom data capture driver.
1416 */
1417void __init at91_add_device_ssc(unsigned id, unsigned pins)
1418{
1419 struct platform_device *pdev;
1420
1421 /*
1422 * NOTE: caller is responsible for passing information matching
1423 * "pins" to whatever will be using each particular controller.
1424 */
1425 switch (id) {
1426 case AT91SAM9G45_ID_SSC0:
1427 pdev = &at91sam9g45_ssc0_device;
1428 configure_ssc0_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001429 break;
1430 case AT91SAM9G45_ID_SSC1:
1431 pdev = &at91sam9g45_ssc1_device;
1432 configure_ssc1_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001433 break;
1434 default:
1435 return;
1436 }
1437
1438 platform_device_register(pdev);
1439}
1440
1441#else
1442void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1443#endif
1444
1445
1446/* --------------------------------------------------------------------
1447 * UART
1448 * -------------------------------------------------------------------- */
1449
1450#if defined(CONFIG_SERIAL_ATMEL)
1451static struct resource dbgu_resources[] = {
1452 [0] = {
Jean-Christophe PLAGNIOL-VILLARD13079a72011-11-02 01:43:31 +08001453 .start = AT91SAM9G45_BASE_DBGU,
1454 .end = AT91SAM9G45_BASE_DBGU + SZ_512 - 1,
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001455 .flags = IORESOURCE_MEM,
1456 },
1457 [1] = {
1458 .start = AT91_ID_SYS,
1459 .end = AT91_ID_SYS,
1460 .flags = IORESOURCE_IRQ,
1461 },
1462};
1463
1464static struct atmel_uart_data dbgu_data = {
1465 .use_dma_tx = 0,
1466 .use_dma_rx = 0,
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001467};
1468
1469static u64 dbgu_dmamask = DMA_BIT_MASK(32);
1470
1471static struct platform_device at91sam9g45_dbgu_device = {
1472 .name = "atmel_usart",
1473 .id = 0,
1474 .dev = {
1475 .dma_mask = &dbgu_dmamask,
1476 .coherent_dma_mask = DMA_BIT_MASK(32),
1477 .platform_data = &dbgu_data,
1478 },
1479 .resource = dbgu_resources,
1480 .num_resources = ARRAY_SIZE(dbgu_resources),
1481};
1482
1483static inline void configure_dbgu_pins(void)
1484{
1485 at91_set_A_periph(AT91_PIN_PB12, 0); /* DRXD */
1486 at91_set_A_periph(AT91_PIN_PB13, 1); /* DTXD */
1487}
1488
1489static struct resource uart0_resources[] = {
1490 [0] = {
1491 .start = AT91SAM9G45_BASE_US0,
1492 .end = AT91SAM9G45_BASE_US0 + SZ_16K - 1,
1493 .flags = IORESOURCE_MEM,
1494 },
1495 [1] = {
1496 .start = AT91SAM9G45_ID_US0,
1497 .end = AT91SAM9G45_ID_US0,
1498 .flags = IORESOURCE_IRQ,
1499 },
1500};
1501
1502static struct atmel_uart_data uart0_data = {
1503 .use_dma_tx = 1,
1504 .use_dma_rx = 1,
1505};
1506
1507static u64 uart0_dmamask = DMA_BIT_MASK(32);
1508
1509static struct platform_device at91sam9g45_uart0_device = {
1510 .name = "atmel_usart",
1511 .id = 1,
1512 .dev = {
1513 .dma_mask = &uart0_dmamask,
1514 .coherent_dma_mask = DMA_BIT_MASK(32),
1515 .platform_data = &uart0_data,
1516 },
1517 .resource = uart0_resources,
1518 .num_resources = ARRAY_SIZE(uart0_resources),
1519};
1520
1521static inline void configure_usart0_pins(unsigned pins)
1522{
1523 at91_set_A_periph(AT91_PIN_PB19, 1); /* TXD0 */
1524 at91_set_A_periph(AT91_PIN_PB18, 0); /* RXD0 */
1525
1526 if (pins & ATMEL_UART_RTS)
1527 at91_set_B_periph(AT91_PIN_PB17, 0); /* RTS0 */
1528 if (pins & ATMEL_UART_CTS)
1529 at91_set_B_periph(AT91_PIN_PB15, 0); /* CTS0 */
1530}
1531
1532static struct resource uart1_resources[] = {
1533 [0] = {
1534 .start = AT91SAM9G45_BASE_US1,
1535 .end = AT91SAM9G45_BASE_US1 + SZ_16K - 1,
1536 .flags = IORESOURCE_MEM,
1537 },
1538 [1] = {
1539 .start = AT91SAM9G45_ID_US1,
1540 .end = AT91SAM9G45_ID_US1,
1541 .flags = IORESOURCE_IRQ,
1542 },
1543};
1544
1545static struct atmel_uart_data uart1_data = {
1546 .use_dma_tx = 1,
1547 .use_dma_rx = 1,
1548};
1549
1550static u64 uart1_dmamask = DMA_BIT_MASK(32);
1551
1552static struct platform_device at91sam9g45_uart1_device = {
1553 .name = "atmel_usart",
1554 .id = 2,
1555 .dev = {
1556 .dma_mask = &uart1_dmamask,
1557 .coherent_dma_mask = DMA_BIT_MASK(32),
1558 .platform_data = &uart1_data,
1559 },
1560 .resource = uart1_resources,
1561 .num_resources = ARRAY_SIZE(uart1_resources),
1562};
1563
1564static inline void configure_usart1_pins(unsigned pins)
1565{
1566 at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD1 */
1567 at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD1 */
1568
1569 if (pins & ATMEL_UART_RTS)
1570 at91_set_A_periph(AT91_PIN_PD16, 0); /* RTS1 */
1571 if (pins & ATMEL_UART_CTS)
1572 at91_set_A_periph(AT91_PIN_PD17, 0); /* CTS1 */
1573}
1574
1575static struct resource uart2_resources[] = {
1576 [0] = {
1577 .start = AT91SAM9G45_BASE_US2,
1578 .end = AT91SAM9G45_BASE_US2 + SZ_16K - 1,
1579 .flags = IORESOURCE_MEM,
1580 },
1581 [1] = {
1582 .start = AT91SAM9G45_ID_US2,
1583 .end = AT91SAM9G45_ID_US2,
1584 .flags = IORESOURCE_IRQ,
1585 },
1586};
1587
1588static struct atmel_uart_data uart2_data = {
1589 .use_dma_tx = 1,
1590 .use_dma_rx = 1,
1591};
1592
1593static u64 uart2_dmamask = DMA_BIT_MASK(32);
1594
1595static struct platform_device at91sam9g45_uart2_device = {
1596 .name = "atmel_usart",
1597 .id = 3,
1598 .dev = {
1599 .dma_mask = &uart2_dmamask,
1600 .coherent_dma_mask = DMA_BIT_MASK(32),
1601 .platform_data = &uart2_data,
1602 },
1603 .resource = uart2_resources,
1604 .num_resources = ARRAY_SIZE(uart2_resources),
1605};
1606
1607static inline void configure_usart2_pins(unsigned pins)
1608{
1609 at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD2 */
1610 at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD2 */
1611
1612 if (pins & ATMEL_UART_RTS)
1613 at91_set_B_periph(AT91_PIN_PC9, 0); /* RTS2 */
1614 if (pins & ATMEL_UART_CTS)
1615 at91_set_B_periph(AT91_PIN_PC11, 0); /* CTS2 */
1616}
1617
1618static struct resource uart3_resources[] = {
1619 [0] = {
1620 .start = AT91SAM9G45_BASE_US3,
1621 .end = AT91SAM9G45_BASE_US3 + SZ_16K - 1,
1622 .flags = IORESOURCE_MEM,
1623 },
1624 [1] = {
1625 .start = AT91SAM9G45_ID_US3,
1626 .end = AT91SAM9G45_ID_US3,
1627 .flags = IORESOURCE_IRQ,
1628 },
1629};
1630
1631static struct atmel_uart_data uart3_data = {
1632 .use_dma_tx = 1,
1633 .use_dma_rx = 1,
1634};
1635
1636static u64 uart3_dmamask = DMA_BIT_MASK(32);
1637
1638static struct platform_device at91sam9g45_uart3_device = {
1639 .name = "atmel_usart",
1640 .id = 4,
1641 .dev = {
1642 .dma_mask = &uart3_dmamask,
1643 .coherent_dma_mask = DMA_BIT_MASK(32),
1644 .platform_data = &uart3_data,
1645 },
1646 .resource = uart3_resources,
1647 .num_resources = ARRAY_SIZE(uart3_resources),
1648};
1649
1650static inline void configure_usart3_pins(unsigned pins)
1651{
1652 at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD3 */
1653 at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD3 */
1654
1655 if (pins & ATMEL_UART_RTS)
1656 at91_set_B_periph(AT91_PIN_PA23, 0); /* RTS3 */
1657 if (pins & ATMEL_UART_CTS)
1658 at91_set_B_periph(AT91_PIN_PA24, 0); /* CTS3 */
1659}
1660
1661static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1662struct platform_device *atmel_default_console_device; /* the serial console device */
1663
1664void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1665{
1666 struct platform_device *pdev;
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001667 struct atmel_uart_data *pdata;
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001668
1669 switch (id) {
1670 case 0: /* DBGU */
1671 pdev = &at91sam9g45_dbgu_device;
1672 configure_dbgu_pins();
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001673 break;
1674 case AT91SAM9G45_ID_US0:
1675 pdev = &at91sam9g45_uart0_device;
1676 configure_usart0_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001677 break;
1678 case AT91SAM9G45_ID_US1:
1679 pdev = &at91sam9g45_uart1_device;
1680 configure_usart1_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001681 break;
1682 case AT91SAM9G45_ID_US2:
1683 pdev = &at91sam9g45_uart2_device;
1684 configure_usart2_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001685 break;
1686 case AT91SAM9G45_ID_US3:
1687 pdev = &at91sam9g45_uart3_device;
1688 configure_usart3_pins(pins);
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001689 break;
1690 default:
1691 return;
1692 }
Jean-Christophe PLAGNIOL-VILLARD2b348e22011-04-10 14:10:05 +08001693 pdata = pdev->dev.platform_data;
1694 pdata->num = portnr; /* update to mapped ID */
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001695
1696 if (portnr < ATMEL_MAX_UART)
1697 at91_uarts[portnr] = pdev;
1698}
1699
1700void __init at91_set_serial_console(unsigned portnr)
1701{
Jean-Christophe PLAGNIOL-VILLARDbd602992011-02-02 07:27:07 +01001702 if (portnr < ATMEL_MAX_UART) {
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001703 atmel_default_console_device = at91_uarts[portnr];
Jean-Christophe PLAGNIOL-VILLARD5c1f9662011-06-21 11:24:33 +08001704 at91sam9g45_set_console_clock(at91_uarts[portnr]->id);
Jean-Christophe PLAGNIOL-VILLARDbd602992011-02-02 07:27:07 +01001705 }
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001706}
1707
1708void __init at91_add_device_serial(void)
1709{
1710 int i;
1711
1712 for (i = 0; i < ATMEL_MAX_UART; i++) {
1713 if (at91_uarts[i])
1714 platform_device_register(at91_uarts[i]);
1715 }
1716
1717 if (!atmel_default_console_device)
1718 printk(KERN_INFO "AT91: No default serial console defined.\n");
1719}
1720#else
1721void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1722void __init at91_set_serial_console(unsigned portnr) {}
1723void __init at91_add_device_serial(void) {}
1724#endif
1725
1726
1727/* -------------------------------------------------------------------- */
1728/*
1729 * These devices are always present and don't need any board-specific
1730 * setup.
1731 */
1732static int __init at91_add_standard_devices(void)
1733{
Nicolas Ferre40262b22009-07-24 11:43:01 +01001734 at91_add_device_hdmac();
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001735 at91_add_device_rtc();
1736 at91_add_device_rtt();
Peter Korsgaard237a62a2011-10-06 17:41:33 +02001737 at91_add_device_trng();
Nicolas Ferre789b23b2009-06-26 15:36:58 +01001738 at91_add_device_watchdog();
1739 at91_add_device_tc();
1740 return 0;
1741}
1742
1743arch_initcall(at91_add_standard_devices);