2 * arch/arm/mach-at91/at91sam9263_devices.c
4 * Copyright (C) 2007 Atmel Corporation.
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.
12 #include <asm/mach/arch.h>
13 #include <asm/mach/map.h>
15 #include <linux/platform_device.h>
17 #include <video/atmel_lcdc.h>
19 #include <asm/arch/board.h>
20 #include <asm/arch/gpio.h>
21 #include <asm/arch/at91sam9263.h>
22 #include <asm/arch/at91sam926x_mc.h>
23 #include <asm/arch/at91sam9263_matrix.h>
28 /* --------------------------------------------------------------------
30 * -------------------------------------------------------------------- */
32 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
33 static u64 ohci_dmamask
= 0xffffffffUL
;
34 static struct at91_usbh_data usbh_data
;
36 static struct resource usbh_resources
[] = {
38 .start
= AT91SAM9263_UHP_BASE
,
39 .end
= AT91SAM9263_UHP_BASE
+ SZ_1M
- 1,
40 .flags
= IORESOURCE_MEM
,
43 .start
= AT91SAM9263_ID_UHP
,
44 .end
= AT91SAM9263_ID_UHP
,
45 .flags
= IORESOURCE_IRQ
,
49 static struct platform_device at91_usbh_device
= {
53 .dma_mask
= &ohci_dmamask
,
54 .coherent_dma_mask
= 0xffffffff,
55 .platform_data
= &usbh_data
,
57 .resource
= usbh_resources
,
58 .num_resources
= ARRAY_SIZE(usbh_resources
),
61 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
)
68 /* Enable VBus control for UHP ports */
69 for (i
= 0; i
< data
->ports
; i
++) {
70 if (data
->vbus_pin
[i
])
71 at91_set_gpio_output(data
->vbus_pin
[i
], 0);
75 platform_device_register(&at91_usbh_device
);
78 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
) {}
82 /* --------------------------------------------------------------------
84 * -------------------------------------------------------------------- */
86 #ifdef CONFIG_USB_GADGET_AT91
87 static struct at91_udc_data udc_data
;
89 static struct resource udc_resources
[] = {
91 .start
= AT91SAM9263_BASE_UDP
,
92 .end
= AT91SAM9263_BASE_UDP
+ SZ_16K
- 1,
93 .flags
= IORESOURCE_MEM
,
96 .start
= AT91SAM9263_ID_UDP
,
97 .end
= AT91SAM9263_ID_UDP
,
98 .flags
= IORESOURCE_IRQ
,
102 static struct platform_device at91_udc_device
= {
106 .platform_data
= &udc_data
,
108 .resource
= udc_resources
,
109 .num_resources
= ARRAY_SIZE(udc_resources
),
112 void __init
at91_add_device_udc(struct at91_udc_data
*data
)
117 if (data
->vbus_pin
) {
118 at91_set_gpio_input(data
->vbus_pin
, 0);
119 at91_set_deglitch(data
->vbus_pin
, 1);
122 /* Pullup pin is handled internally by USB device peripheral */
125 platform_device_register(&at91_udc_device
);
128 void __init
at91_add_device_udc(struct at91_udc_data
*data
) {}
132 /* --------------------------------------------------------------------
134 * -------------------------------------------------------------------- */
136 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
137 static u64 eth_dmamask
= 0xffffffffUL
;
138 static struct at91_eth_data eth_data
;
140 static struct resource eth_resources
[] = {
142 .start
= AT91SAM9263_BASE_EMAC
,
143 .end
= AT91SAM9263_BASE_EMAC
+ SZ_16K
- 1,
144 .flags
= IORESOURCE_MEM
,
147 .start
= AT91SAM9263_ID_EMAC
,
148 .end
= AT91SAM9263_ID_EMAC
,
149 .flags
= IORESOURCE_IRQ
,
153 static struct platform_device at91sam9263_eth_device
= {
157 .dma_mask
= ð_dmamask
,
158 .coherent_dma_mask
= 0xffffffff,
159 .platform_data
= ð_data
,
161 .resource
= eth_resources
,
162 .num_resources
= ARRAY_SIZE(eth_resources
),
165 void __init
at91_add_device_eth(struct at91_eth_data
*data
)
170 if (data
->phy_irq_pin
) {
171 at91_set_gpio_input(data
->phy_irq_pin
, 0);
172 at91_set_deglitch(data
->phy_irq_pin
, 1);
175 /* Pins used for MII and RMII */
176 at91_set_A_periph(AT91_PIN_PE21
, 0); /* ETXCK_EREFCK */
177 at91_set_B_periph(AT91_PIN_PC25
, 0); /* ERXDV */
178 at91_set_A_periph(AT91_PIN_PE25
, 0); /* ERX0 */
179 at91_set_A_periph(AT91_PIN_PE26
, 0); /* ERX1 */
180 at91_set_A_periph(AT91_PIN_PE27
, 0); /* ERXER */
181 at91_set_A_periph(AT91_PIN_PE28
, 0); /* ETXEN */
182 at91_set_A_periph(AT91_PIN_PE23
, 0); /* ETX0 */
183 at91_set_A_periph(AT91_PIN_PE24
, 0); /* ETX1 */
184 at91_set_A_periph(AT91_PIN_PE30
, 0); /* EMDIO */
185 at91_set_A_periph(AT91_PIN_PE29
, 0); /* EMDC */
187 if (!data
->is_rmii
) {
188 at91_set_A_periph(AT91_PIN_PE22
, 0); /* ECRS */
189 at91_set_B_periph(AT91_PIN_PC26
, 0); /* ECOL */
190 at91_set_B_periph(AT91_PIN_PC22
, 0); /* ERX2 */
191 at91_set_B_periph(AT91_PIN_PC23
, 0); /* ERX3 */
192 at91_set_B_periph(AT91_PIN_PC27
, 0); /* ERXCK */
193 at91_set_B_periph(AT91_PIN_PC20
, 0); /* ETX2 */
194 at91_set_B_periph(AT91_PIN_PC21
, 0); /* ETX3 */
195 at91_set_B_periph(AT91_PIN_PC24
, 0); /* ETXER */
199 platform_device_register(&at91sam9263_eth_device
);
202 void __init
at91_add_device_eth(struct at91_eth_data
*data
) {}
206 /* --------------------------------------------------------------------
208 * -------------------------------------------------------------------- */
210 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
211 static u64 mmc_dmamask
= 0xffffffffUL
;
212 static struct at91_mmc_data mmc0_data
, mmc1_data
;
214 static struct resource mmc0_resources
[] = {
216 .start
= AT91SAM9263_BASE_MCI0
,
217 .end
= AT91SAM9263_BASE_MCI0
+ SZ_16K
- 1,
218 .flags
= IORESOURCE_MEM
,
221 .start
= AT91SAM9263_ID_MCI0
,
222 .end
= AT91SAM9263_ID_MCI0
,
223 .flags
= IORESOURCE_IRQ
,
227 static struct platform_device at91sam9263_mmc0_device
= {
231 .dma_mask
= &mmc_dmamask
,
232 .coherent_dma_mask
= 0xffffffff,
233 .platform_data
= &mmc0_data
,
235 .resource
= mmc0_resources
,
236 .num_resources
= ARRAY_SIZE(mmc0_resources
),
239 static struct resource mmc1_resources
[] = {
241 .start
= AT91SAM9263_BASE_MCI1
,
242 .end
= AT91SAM9263_BASE_MCI1
+ SZ_16K
- 1,
243 .flags
= IORESOURCE_MEM
,
246 .start
= AT91SAM9263_ID_MCI1
,
247 .end
= AT91SAM9263_ID_MCI1
,
248 .flags
= IORESOURCE_IRQ
,
252 static struct platform_device at91sam9263_mmc1_device
= {
256 .dma_mask
= &mmc_dmamask
,
257 .coherent_dma_mask
= 0xffffffff,
258 .platform_data
= &mmc1_data
,
260 .resource
= mmc1_resources
,
261 .num_resources
= ARRAY_SIZE(mmc1_resources
),
264 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
)
271 at91_set_gpio_input(data
->det_pin
, 1);
272 at91_set_deglitch(data
->det_pin
, 1);
275 at91_set_gpio_input(data
->wp_pin
, 1);
277 at91_set_gpio_output(data
->vcc_pin
, 0);
279 if (mmc_id
== 0) { /* MCI0 */
281 at91_set_A_periph(AT91_PIN_PA12
, 0);
285 at91_set_A_periph(AT91_PIN_PA16
, 1);
287 /* DAT0, maybe DAT1..DAT3 */
288 at91_set_A_periph(AT91_PIN_PA17
, 1);
290 at91_set_A_periph(AT91_PIN_PA18
, 1);
291 at91_set_A_periph(AT91_PIN_PA19
, 1);
292 at91_set_A_periph(AT91_PIN_PA20
, 1);
296 at91_set_A_periph(AT91_PIN_PA1
, 1);
298 /* DAT0, maybe DAT1..DAT3 */
299 at91_set_A_periph(AT91_PIN_PA0
, 1);
301 at91_set_A_periph(AT91_PIN_PA3
, 1);
302 at91_set_A_periph(AT91_PIN_PA4
, 1);
303 at91_set_A_periph(AT91_PIN_PA5
, 1);
308 at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device
.dev
, "mci_clk");
309 platform_device_register(&at91sam9263_mmc0_device
);
312 at91_set_A_periph(AT91_PIN_PA6
, 0);
316 at91_set_A_periph(AT91_PIN_PA21
, 1);
318 /* DAT0, maybe DAT1..DAT3 */
319 at91_set_A_periph(AT91_PIN_PA22
, 1);
321 at91_set_A_periph(AT91_PIN_PA23
, 1);
322 at91_set_A_periph(AT91_PIN_PA24
, 1);
323 at91_set_A_periph(AT91_PIN_PA25
, 1);
327 at91_set_A_periph(AT91_PIN_PA7
, 1);
329 /* DAT0, maybe DAT1..DAT3 */
330 at91_set_A_periph(AT91_PIN_PA8
, 1);
332 at91_set_A_periph(AT91_PIN_PA9
, 1);
333 at91_set_A_periph(AT91_PIN_PA10
, 1);
334 at91_set_A_periph(AT91_PIN_PA11
, 1);
339 at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device
.dev
, "mci_clk");
340 platform_device_register(&at91sam9263_mmc1_device
);
344 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
) {}
348 /* --------------------------------------------------------------------
350 * -------------------------------------------------------------------- */
352 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
353 static struct at91_nand_data nand_data
;
355 #define NAND_BASE AT91_CHIPSELECT_3
357 static struct resource nand_resources
[] = {
360 .end
= NAND_BASE
+ SZ_256M
- 1,
361 .flags
= IORESOURCE_MEM
,
365 static struct platform_device at91sam9263_nand_device
= {
369 .platform_data
= &nand_data
,
371 .resource
= nand_resources
,
372 .num_resources
= ARRAY_SIZE(nand_resources
),
375 void __init
at91_add_device_nand(struct at91_nand_data
*data
)
377 unsigned long csa
, mode
;
382 csa
= at91_sys_read(AT91_MATRIX_EBI0CSA
);
383 at91_sys_write(AT91_MATRIX_EBI0CSA
, csa
| AT91_MATRIX_EBI0_CS3A_SMC
);
385 /* set the bus interface characteristics */
386 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
387 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
389 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
390 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
392 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
394 if (data
->bus_width_16
)
395 mode
= AT91_SMC_DBW_16
;
397 mode
= AT91_SMC_DBW_8
;
398 at91_sys_write(AT91_SMC_MODE(3), mode
| AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_TDF_(2));
401 if (data
->enable_pin
)
402 at91_set_gpio_output(data
->enable_pin
, 1);
406 at91_set_gpio_input(data
->rdy_pin
, 1);
408 /* card detect pin */
410 at91_set_gpio_input(data
->det_pin
, 1);
413 platform_device_register(&at91sam9263_nand_device
);
416 void __init
at91_add_device_nand(struct at91_nand_data
*data
) {}
420 /* --------------------------------------------------------------------
422 * -------------------------------------------------------------------- */
424 #if defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
426 static struct resource twi_resources
[] = {
428 .start
= AT91SAM9263_BASE_TWI
,
429 .end
= AT91SAM9263_BASE_TWI
+ SZ_16K
- 1,
430 .flags
= IORESOURCE_MEM
,
433 .start
= AT91SAM9263_ID_TWI
,
434 .end
= AT91SAM9263_ID_TWI
,
435 .flags
= IORESOURCE_IRQ
,
439 static struct platform_device at91sam9263_twi_device
= {
442 .resource
= twi_resources
,
443 .num_resources
= ARRAY_SIZE(twi_resources
),
446 void __init
at91_add_device_i2c(void)
448 /* pins used for TWI interface */
449 at91_set_A_periph(AT91_PIN_PB4
, 0); /* TWD */
450 at91_set_multi_drive(AT91_PIN_PB4
, 1);
452 at91_set_A_periph(AT91_PIN_PB5
, 0); /* TWCK */
453 at91_set_multi_drive(AT91_PIN_PB5
, 1);
455 platform_device_register(&at91sam9263_twi_device
);
458 void __init
at91_add_device_i2c(void) {}
462 /* --------------------------------------------------------------------
464 * -------------------------------------------------------------------- */
466 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
467 static u64 spi_dmamask
= 0xffffffffUL
;
469 static struct resource spi0_resources
[] = {
471 .start
= AT91SAM9263_BASE_SPI0
,
472 .end
= AT91SAM9263_BASE_SPI0
+ SZ_16K
- 1,
473 .flags
= IORESOURCE_MEM
,
476 .start
= AT91SAM9263_ID_SPI0
,
477 .end
= AT91SAM9263_ID_SPI0
,
478 .flags
= IORESOURCE_IRQ
,
482 static struct platform_device at91sam9263_spi0_device
= {
486 .dma_mask
= &spi_dmamask
,
487 .coherent_dma_mask
= 0xffffffff,
489 .resource
= spi0_resources
,
490 .num_resources
= ARRAY_SIZE(spi0_resources
),
493 static const unsigned spi0_standard_cs
[4] = { AT91_PIN_PA5
, AT91_PIN_PA3
, AT91_PIN_PA4
, AT91_PIN_PB11
};
495 static struct resource spi1_resources
[] = {
497 .start
= AT91SAM9263_BASE_SPI1
,
498 .end
= AT91SAM9263_BASE_SPI1
+ SZ_16K
- 1,
499 .flags
= IORESOURCE_MEM
,
502 .start
= AT91SAM9263_ID_SPI1
,
503 .end
= AT91SAM9263_ID_SPI1
,
504 .flags
= IORESOURCE_IRQ
,
508 static struct platform_device at91sam9263_spi1_device
= {
512 .dma_mask
= &spi_dmamask
,
513 .coherent_dma_mask
= 0xffffffff,
515 .resource
= spi1_resources
,
516 .num_resources
= ARRAY_SIZE(spi1_resources
),
519 static const unsigned spi1_standard_cs
[4] = { AT91_PIN_PB15
, AT91_PIN_PB16
, AT91_PIN_PB17
, AT91_PIN_PB18
};
521 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
)
524 unsigned long cs_pin
;
525 short enable_spi0
= 0;
526 short enable_spi1
= 0;
528 /* Choose SPI chip-selects */
529 for (i
= 0; i
< nr_devices
; i
++) {
530 if (devices
[i
].controller_data
)
531 cs_pin
= (unsigned long) devices
[i
].controller_data
;
532 else if (devices
[i
].bus_num
== 0)
533 cs_pin
= spi0_standard_cs
[devices
[i
].chip_select
];
535 cs_pin
= spi1_standard_cs
[devices
[i
].chip_select
];
537 if (devices
[i
].bus_num
== 0)
542 /* enable chip-select pin */
543 at91_set_gpio_output(cs_pin
, 1);
545 /* pass chip-select pin to driver */
546 devices
[i
].controller_data
= (void *) cs_pin
;
549 spi_register_board_info(devices
, nr_devices
);
551 /* Configure SPI bus(es) */
553 at91_set_B_periph(AT91_PIN_PA0
, 0); /* SPI0_MISO */
554 at91_set_B_periph(AT91_PIN_PA1
, 0); /* SPI0_MOSI */
555 at91_set_B_periph(AT91_PIN_PA2
, 0); /* SPI0_SPCK */
557 at91_clock_associate("spi0_clk", &at91sam9263_spi0_device
.dev
, "spi_clk");
558 platform_device_register(&at91sam9263_spi0_device
);
561 at91_set_A_periph(AT91_PIN_PB12
, 0); /* SPI1_MISO */
562 at91_set_A_periph(AT91_PIN_PB13
, 0); /* SPI1_MOSI */
563 at91_set_A_periph(AT91_PIN_PB14
, 0); /* SPI1_SPCK */
565 at91_clock_associate("spi1_clk", &at91sam9263_spi1_device
.dev
, "spi_clk");
566 platform_device_register(&at91sam9263_spi1_device
);
570 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
) {}
574 /* --------------------------------------------------------------------
576 * -------------------------------------------------------------------- */
578 #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
579 static u64 ac97_dmamask
= 0xffffffffUL
;
580 static struct atmel_ac97_data ac97_data
;
582 static struct resource ac97_resources
[] = {
584 .start
= AT91SAM9263_BASE_AC97C
,
585 .end
= AT91SAM9263_BASE_AC97C
+ SZ_16K
- 1,
586 .flags
= IORESOURCE_MEM
,
589 .start
= AT91SAM9263_ID_AC97C
,
590 .end
= AT91SAM9263_ID_AC97C
,
591 .flags
= IORESOURCE_IRQ
,
595 static struct platform_device at91sam9263_ac97_device
= {
599 .dma_mask
= &ac97_dmamask
,
600 .coherent_dma_mask
= 0xffffffff,
601 .platform_data
= &ac97_data
,
603 .resource
= ac97_resources
,
604 .num_resources
= ARRAY_SIZE(ac97_resources
),
607 void __init
at91_add_device_ac97(struct atmel_ac97_data
*data
)
612 at91_set_A_periph(AT91_PIN_PB0
, 0); /* AC97FS */
613 at91_set_A_periph(AT91_PIN_PB1
, 0); /* AC97CK */
614 at91_set_A_periph(AT91_PIN_PB2
, 0); /* AC97TX */
615 at91_set_A_periph(AT91_PIN_PB3
, 0); /* AC97RX */
619 at91_set_gpio_output(data
->reset_pin
, 0);
621 ac97_data
= *ek_data
;
622 platform_device_register(&at91sam9263_ac97_device
);
625 void __init
at91_add_device_ac97(struct atmel_ac97_data
*data
) {}
629 /* --------------------------------------------------------------------
631 * -------------------------------------------------------------------- */
633 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
634 static u64 lcdc_dmamask
= 0xffffffffUL
;
635 static struct atmel_lcdfb_info lcdc_data
;
637 static struct resource lcdc_resources
[] = {
639 .start
= AT91SAM9263_LCDC_BASE
,
640 .end
= AT91SAM9263_LCDC_BASE
+ SZ_4K
- 1,
641 .flags
= IORESOURCE_MEM
,
644 .start
= AT91SAM9263_ID_LCDC
,
645 .end
= AT91SAM9263_ID_LCDC
,
646 .flags
= IORESOURCE_IRQ
,
650 static struct platform_device at91_lcdc_device
= {
651 .name
= "atmel_lcdfb",
654 .dma_mask
= &lcdc_dmamask
,
655 .coherent_dma_mask
= 0xffffffff,
656 .platform_data
= &lcdc_data
,
658 .resource
= lcdc_resources
,
659 .num_resources
= ARRAY_SIZE(lcdc_resources
),
662 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
)
667 at91_set_A_periph(AT91_PIN_PC1
, 0); /* LCDHSYNC */
668 at91_set_A_periph(AT91_PIN_PC2
, 0); /* LCDDOTCK */
669 at91_set_A_periph(AT91_PIN_PC3
, 0); /* LCDDEN */
670 at91_set_B_periph(AT91_PIN_PB9
, 0); /* LCDCC */
671 at91_set_A_periph(AT91_PIN_PC6
, 0); /* LCDD2 */
672 at91_set_A_periph(AT91_PIN_PC7
, 0); /* LCDD3 */
673 at91_set_A_periph(AT91_PIN_PC8
, 0); /* LCDD4 */
674 at91_set_A_periph(AT91_PIN_PC9
, 0); /* LCDD5 */
675 at91_set_A_periph(AT91_PIN_PC10
, 0); /* LCDD6 */
676 at91_set_A_periph(AT91_PIN_PC11
, 0); /* LCDD7 */
677 at91_set_A_periph(AT91_PIN_PC14
, 0); /* LCDD10 */
678 at91_set_A_periph(AT91_PIN_PC15
, 0); /* LCDD11 */
679 at91_set_A_periph(AT91_PIN_PC16
, 0); /* LCDD12 */
680 at91_set_B_periph(AT91_PIN_PC12
, 0); /* LCDD13 */
681 at91_set_A_periph(AT91_PIN_PC18
, 0); /* LCDD14 */
682 at91_set_A_periph(AT91_PIN_PC19
, 0); /* LCDD15 */
683 at91_set_A_periph(AT91_PIN_PC22
, 0); /* LCDD18 */
684 at91_set_A_periph(AT91_PIN_PC23
, 0); /* LCDD19 */
685 at91_set_A_periph(AT91_PIN_PC24
, 0); /* LCDD20 */
686 at91_set_B_periph(AT91_PIN_PC17
, 0); /* LCDD21 */
687 at91_set_A_periph(AT91_PIN_PC26
, 0); /* LCDD22 */
688 at91_set_A_periph(AT91_PIN_PC27
, 0); /* LCDD23 */
691 platform_device_register(&at91_lcdc_device
);
694 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
) {}
698 /* --------------------------------------------------------------------
700 * -------------------------------------------------------------------- */
702 #if defined(CONFIG_LEDS)
706 void __init
at91_init_leds(u8 cpu_led
, u8 timer_led
)
708 /* Enable GPIO to access the LEDs */
709 at91_set_gpio_output(cpu_led
, 1);
710 at91_set_gpio_output(timer_led
, 1);
712 at91_leds_cpu
= cpu_led
;
713 at91_leds_timer
= timer_led
;
716 void __init
at91_init_leds(u8 cpu_led
, u8 timer_led
) {}
720 /* --------------------------------------------------------------------
722 * -------------------------------------------------------------------- */
724 #if defined(CONFIG_SERIAL_ATMEL)
726 static struct resource dbgu_resources
[] = {
728 .start
= AT91_VA_BASE_SYS
+ AT91_DBGU
,
729 .end
= AT91_VA_BASE_SYS
+ AT91_DBGU
+ SZ_512
- 1,
730 .flags
= IORESOURCE_MEM
,
733 .start
= AT91_ID_SYS
,
735 .flags
= IORESOURCE_IRQ
,
739 static struct atmel_uart_data dbgu_data
= {
741 .use_dma_rx
= 0, /* DBGU not capable of receive DMA */
742 .regs
= (void __iomem
*)(AT91_VA_BASE_SYS
+ AT91_DBGU
),
745 static struct platform_device at91sam9263_dbgu_device
= {
746 .name
= "atmel_usart",
749 .platform_data
= &dbgu_data
,
750 .coherent_dma_mask
= 0xffffffff,
752 .resource
= dbgu_resources
,
753 .num_resources
= ARRAY_SIZE(dbgu_resources
),
756 static inline void configure_dbgu_pins(void)
758 at91_set_A_periph(AT91_PIN_PC30
, 0); /* DRXD */
759 at91_set_A_periph(AT91_PIN_PC31
, 1); /* DTXD */
762 static struct resource uart0_resources
[] = {
764 .start
= AT91SAM9263_BASE_US0
,
765 .end
= AT91SAM9263_BASE_US0
+ SZ_16K
- 1,
766 .flags
= IORESOURCE_MEM
,
769 .start
= AT91SAM9263_ID_US0
,
770 .end
= AT91SAM9263_ID_US0
,
771 .flags
= IORESOURCE_IRQ
,
775 static struct atmel_uart_data uart0_data
= {
780 static struct platform_device at91sam9263_uart0_device
= {
781 .name
= "atmel_usart",
784 .platform_data
= &uart0_data
,
785 .coherent_dma_mask
= 0xffffffff,
787 .resource
= uart0_resources
,
788 .num_resources
= ARRAY_SIZE(uart0_resources
),
791 static inline void configure_usart0_pins(void)
793 at91_set_A_periph(AT91_PIN_PA26
, 1); /* TXD0 */
794 at91_set_A_periph(AT91_PIN_PA27
, 0); /* RXD0 */
795 at91_set_A_periph(AT91_PIN_PA28
, 0); /* RTS0 */
796 at91_set_A_periph(AT91_PIN_PA29
, 0); /* CTS0 */
799 static struct resource uart1_resources
[] = {
801 .start
= AT91SAM9263_BASE_US1
,
802 .end
= AT91SAM9263_BASE_US1
+ SZ_16K
- 1,
803 .flags
= IORESOURCE_MEM
,
806 .start
= AT91SAM9263_ID_US1
,
807 .end
= AT91SAM9263_ID_US1
,
808 .flags
= IORESOURCE_IRQ
,
812 static struct atmel_uart_data uart1_data
= {
817 static struct platform_device at91sam9263_uart1_device
= {
818 .name
= "atmel_usart",
821 .platform_data
= &uart1_data
,
822 .coherent_dma_mask
= 0xffffffff,
824 .resource
= uart1_resources
,
825 .num_resources
= ARRAY_SIZE(uart1_resources
),
828 static inline void configure_usart1_pins(void)
830 at91_set_A_periph(AT91_PIN_PD0
, 1); /* TXD1 */
831 at91_set_A_periph(AT91_PIN_PD1
, 0); /* RXD1 */
832 at91_set_B_periph(AT91_PIN_PD7
, 0); /* RTS1 */
833 at91_set_B_periph(AT91_PIN_PD8
, 0); /* CTS1 */
836 static struct resource uart2_resources
[] = {
838 .start
= AT91SAM9263_BASE_US2
,
839 .end
= AT91SAM9263_BASE_US2
+ SZ_16K
- 1,
840 .flags
= IORESOURCE_MEM
,
843 .start
= AT91SAM9263_ID_US2
,
844 .end
= AT91SAM9263_ID_US2
,
845 .flags
= IORESOURCE_IRQ
,
849 static struct atmel_uart_data uart2_data
= {
854 static struct platform_device at91sam9263_uart2_device
= {
855 .name
= "atmel_usart",
858 .platform_data
= &uart2_data
,
859 .coherent_dma_mask
= 0xffffffff,
861 .resource
= uart2_resources
,
862 .num_resources
= ARRAY_SIZE(uart2_resources
),
865 static inline void configure_usart2_pins(void)
867 at91_set_A_periph(AT91_PIN_PD2
, 1); /* TXD2 */
868 at91_set_A_periph(AT91_PIN_PD3
, 0); /* RXD2 */
869 at91_set_B_periph(AT91_PIN_PD5
, 0); /* RTS2 */
870 at91_set_B_periph(AT91_PIN_PD6
, 0); /* CTS2 */
873 struct platform_device
*at91_uarts
[ATMEL_MAX_UART
]; /* the UARTs to use */
874 struct platform_device
*atmel_default_console_device
; /* the serial console device */
876 void __init
at91_init_serial(struct at91_uart_config
*config
)
880 /* Fill in list of supported UARTs */
881 for (i
= 0; i
< config
->nr_tty
; i
++) {
882 switch (config
->tty_map
[i
]) {
884 configure_usart0_pins();
885 at91_uarts
[i
] = &at91sam9263_uart0_device
;
886 at91_clock_associate("usart0_clk", &at91sam9263_uart0_device
.dev
, "usart");
889 configure_usart1_pins();
890 at91_uarts
[i
] = &at91sam9263_uart1_device
;
891 at91_clock_associate("usart1_clk", &at91sam9263_uart1_device
.dev
, "usart");
894 configure_usart2_pins();
895 at91_uarts
[i
] = &at91sam9263_uart2_device
;
896 at91_clock_associate("usart2_clk", &at91sam9263_uart2_device
.dev
, "usart");
899 configure_dbgu_pins();
900 at91_uarts
[i
] = &at91sam9263_dbgu_device
;
901 at91_clock_associate("mck", &at91sam9263_dbgu_device
.dev
, "usart");
906 at91_uarts
[i
]->id
= i
; /* update ID number to mapped ID */
909 /* Set serial console device */
910 if (config
->console_tty
< ATMEL_MAX_UART
)
911 atmel_default_console_device
= at91_uarts
[config
->console_tty
];
912 if (!atmel_default_console_device
)
913 printk(KERN_INFO
"AT91: No default serial console defined.\n");
916 void __init
at91_add_device_serial(void)
920 for (i
= 0; i
< ATMEL_MAX_UART
; i
++) {
922 platform_device_register(at91_uarts
[i
]);
926 void __init
at91_init_serial(struct at91_uart_config
*config
) {}
927 void __init
at91_add_device_serial(void) {}
931 /* -------------------------------------------------------------------- */
933 * These devices are always present and don't need any board-specific
936 static int __init
at91_add_standard_devices(void)
941 arch_initcall(at91_add_standard_devices
);