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/dma-mapping.h>
16 #include <linux/platform_device.h>
17 #include <linux/i2c-gpio.h>
20 #include <video/atmel_lcdc.h>
22 #include <asm/arch/board.h>
23 #include <asm/arch/gpio.h>
24 #include <asm/arch/at91sam9263.h>
25 #include <asm/arch/at91sam926x_mc.h>
26 #include <asm/arch/at91sam9263_matrix.h>
31 /* --------------------------------------------------------------------
33 * -------------------------------------------------------------------- */
35 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
36 static u64 ohci_dmamask
= DMA_BIT_MASK(32);
37 static struct at91_usbh_data usbh_data
;
39 static struct resource usbh_resources
[] = {
41 .start
= AT91SAM9263_UHP_BASE
,
42 .end
= AT91SAM9263_UHP_BASE
+ SZ_1M
- 1,
43 .flags
= IORESOURCE_MEM
,
46 .start
= AT91SAM9263_ID_UHP
,
47 .end
= AT91SAM9263_ID_UHP
,
48 .flags
= IORESOURCE_IRQ
,
52 static struct platform_device at91_usbh_device
= {
56 .dma_mask
= &ohci_dmamask
,
57 .coherent_dma_mask
= DMA_BIT_MASK(32),
58 .platform_data
= &usbh_data
,
60 .resource
= usbh_resources
,
61 .num_resources
= ARRAY_SIZE(usbh_resources
),
64 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
)
71 /* Enable VBus control for UHP ports */
72 for (i
= 0; i
< data
->ports
; i
++) {
73 if (data
->vbus_pin
[i
])
74 at91_set_gpio_output(data
->vbus_pin
[i
], 0);
78 platform_device_register(&at91_usbh_device
);
81 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
) {}
85 /* --------------------------------------------------------------------
87 * -------------------------------------------------------------------- */
89 #ifdef CONFIG_USB_GADGET_AT91
90 static struct at91_udc_data udc_data
;
92 static struct resource udc_resources
[] = {
94 .start
= AT91SAM9263_BASE_UDP
,
95 .end
= AT91SAM9263_BASE_UDP
+ SZ_16K
- 1,
96 .flags
= IORESOURCE_MEM
,
99 .start
= AT91SAM9263_ID_UDP
,
100 .end
= AT91SAM9263_ID_UDP
,
101 .flags
= IORESOURCE_IRQ
,
105 static struct platform_device at91_udc_device
= {
109 .platform_data
= &udc_data
,
111 .resource
= udc_resources
,
112 .num_resources
= ARRAY_SIZE(udc_resources
),
115 void __init
at91_add_device_udc(struct at91_udc_data
*data
)
120 if (data
->vbus_pin
) {
121 at91_set_gpio_input(data
->vbus_pin
, 0);
122 at91_set_deglitch(data
->vbus_pin
, 1);
125 /* Pullup pin is handled internally by USB device peripheral */
128 platform_device_register(&at91_udc_device
);
131 void __init
at91_add_device_udc(struct at91_udc_data
*data
) {}
135 /* --------------------------------------------------------------------
137 * -------------------------------------------------------------------- */
139 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
140 static u64 eth_dmamask
= DMA_BIT_MASK(32);
141 static struct at91_eth_data eth_data
;
143 static struct resource eth_resources
[] = {
145 .start
= AT91SAM9263_BASE_EMAC
,
146 .end
= AT91SAM9263_BASE_EMAC
+ SZ_16K
- 1,
147 .flags
= IORESOURCE_MEM
,
150 .start
= AT91SAM9263_ID_EMAC
,
151 .end
= AT91SAM9263_ID_EMAC
,
152 .flags
= IORESOURCE_IRQ
,
156 static struct platform_device at91sam9263_eth_device
= {
160 .dma_mask
= ð_dmamask
,
161 .coherent_dma_mask
= DMA_BIT_MASK(32),
162 .platform_data
= ð_data
,
164 .resource
= eth_resources
,
165 .num_resources
= ARRAY_SIZE(eth_resources
),
168 void __init
at91_add_device_eth(struct at91_eth_data
*data
)
173 if (data
->phy_irq_pin
) {
174 at91_set_gpio_input(data
->phy_irq_pin
, 0);
175 at91_set_deglitch(data
->phy_irq_pin
, 1);
178 /* Pins used for MII and RMII */
179 at91_set_A_periph(AT91_PIN_PE21
, 0); /* ETXCK_EREFCK */
180 at91_set_B_periph(AT91_PIN_PC25
, 0); /* ERXDV */
181 at91_set_A_periph(AT91_PIN_PE25
, 0); /* ERX0 */
182 at91_set_A_periph(AT91_PIN_PE26
, 0); /* ERX1 */
183 at91_set_A_periph(AT91_PIN_PE27
, 0); /* ERXER */
184 at91_set_A_periph(AT91_PIN_PE28
, 0); /* ETXEN */
185 at91_set_A_periph(AT91_PIN_PE23
, 0); /* ETX0 */
186 at91_set_A_periph(AT91_PIN_PE24
, 0); /* ETX1 */
187 at91_set_A_periph(AT91_PIN_PE30
, 0); /* EMDIO */
188 at91_set_A_periph(AT91_PIN_PE29
, 0); /* EMDC */
190 if (!data
->is_rmii
) {
191 at91_set_A_periph(AT91_PIN_PE22
, 0); /* ECRS */
192 at91_set_B_periph(AT91_PIN_PC26
, 0); /* ECOL */
193 at91_set_B_periph(AT91_PIN_PC22
, 0); /* ERX2 */
194 at91_set_B_periph(AT91_PIN_PC23
, 0); /* ERX3 */
195 at91_set_B_periph(AT91_PIN_PC27
, 0); /* ERXCK */
196 at91_set_B_periph(AT91_PIN_PC20
, 0); /* ETX2 */
197 at91_set_B_periph(AT91_PIN_PC21
, 0); /* ETX3 */
198 at91_set_B_periph(AT91_PIN_PC24
, 0); /* ETXER */
202 platform_device_register(&at91sam9263_eth_device
);
205 void __init
at91_add_device_eth(struct at91_eth_data
*data
) {}
209 /* --------------------------------------------------------------------
211 * -------------------------------------------------------------------- */
213 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
214 static u64 mmc_dmamask
= DMA_BIT_MASK(32);
215 static struct at91_mmc_data mmc0_data
, mmc1_data
;
217 static struct resource mmc0_resources
[] = {
219 .start
= AT91SAM9263_BASE_MCI0
,
220 .end
= AT91SAM9263_BASE_MCI0
+ SZ_16K
- 1,
221 .flags
= IORESOURCE_MEM
,
224 .start
= AT91SAM9263_ID_MCI0
,
225 .end
= AT91SAM9263_ID_MCI0
,
226 .flags
= IORESOURCE_IRQ
,
230 static struct platform_device at91sam9263_mmc0_device
= {
234 .dma_mask
= &mmc_dmamask
,
235 .coherent_dma_mask
= DMA_BIT_MASK(32),
236 .platform_data
= &mmc0_data
,
238 .resource
= mmc0_resources
,
239 .num_resources
= ARRAY_SIZE(mmc0_resources
),
242 static struct resource mmc1_resources
[] = {
244 .start
= AT91SAM9263_BASE_MCI1
,
245 .end
= AT91SAM9263_BASE_MCI1
+ SZ_16K
- 1,
246 .flags
= IORESOURCE_MEM
,
249 .start
= AT91SAM9263_ID_MCI1
,
250 .end
= AT91SAM9263_ID_MCI1
,
251 .flags
= IORESOURCE_IRQ
,
255 static struct platform_device at91sam9263_mmc1_device
= {
259 .dma_mask
= &mmc_dmamask
,
260 .coherent_dma_mask
= DMA_BIT_MASK(32),
261 .platform_data
= &mmc1_data
,
263 .resource
= mmc1_resources
,
264 .num_resources
= ARRAY_SIZE(mmc1_resources
),
267 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
)
274 at91_set_gpio_input(data
->det_pin
, 1);
275 at91_set_deglitch(data
->det_pin
, 1);
278 at91_set_gpio_input(data
->wp_pin
, 1);
280 at91_set_gpio_output(data
->vcc_pin
, 0);
282 if (mmc_id
== 0) { /* MCI0 */
284 at91_set_A_periph(AT91_PIN_PA12
, 0);
288 at91_set_A_periph(AT91_PIN_PA16
, 1);
290 /* DAT0, maybe DAT1..DAT3 */
291 at91_set_A_periph(AT91_PIN_PA17
, 1);
293 at91_set_A_periph(AT91_PIN_PA18
, 1);
294 at91_set_A_periph(AT91_PIN_PA19
, 1);
295 at91_set_A_periph(AT91_PIN_PA20
, 1);
299 at91_set_A_periph(AT91_PIN_PA1
, 1);
301 /* DAT0, maybe DAT1..DAT3 */
302 at91_set_A_periph(AT91_PIN_PA0
, 1);
304 at91_set_A_periph(AT91_PIN_PA3
, 1);
305 at91_set_A_periph(AT91_PIN_PA4
, 1);
306 at91_set_A_periph(AT91_PIN_PA5
, 1);
311 at91_clock_associate("mci0_clk", &at91sam9263_mmc1_device
.dev
, "mci_clk");
312 platform_device_register(&at91sam9263_mmc0_device
);
315 at91_set_A_periph(AT91_PIN_PA6
, 0);
319 at91_set_A_periph(AT91_PIN_PA21
, 1);
321 /* DAT0, maybe DAT1..DAT3 */
322 at91_set_A_periph(AT91_PIN_PA22
, 1);
324 at91_set_A_periph(AT91_PIN_PA23
, 1);
325 at91_set_A_periph(AT91_PIN_PA24
, 1);
326 at91_set_A_periph(AT91_PIN_PA25
, 1);
330 at91_set_A_periph(AT91_PIN_PA7
, 1);
332 /* DAT0, maybe DAT1..DAT3 */
333 at91_set_A_periph(AT91_PIN_PA8
, 1);
335 at91_set_A_periph(AT91_PIN_PA9
, 1);
336 at91_set_A_periph(AT91_PIN_PA10
, 1);
337 at91_set_A_periph(AT91_PIN_PA11
, 1);
342 at91_clock_associate("mci1_clk", &at91sam9263_mmc1_device
.dev
, "mci_clk");
343 platform_device_register(&at91sam9263_mmc1_device
);
347 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
) {}
351 /* --------------------------------------------------------------------
353 * -------------------------------------------------------------------- */
355 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
356 static struct at91_nand_data nand_data
;
358 #define NAND_BASE AT91_CHIPSELECT_3
360 static struct resource nand_resources
[] = {
363 .end
= NAND_BASE
+ SZ_256M
- 1,
364 .flags
= IORESOURCE_MEM
,
368 static struct platform_device at91sam9263_nand_device
= {
372 .platform_data
= &nand_data
,
374 .resource
= nand_resources
,
375 .num_resources
= ARRAY_SIZE(nand_resources
),
378 void __init
at91_add_device_nand(struct at91_nand_data
*data
)
380 unsigned long csa
, mode
;
385 csa
= at91_sys_read(AT91_MATRIX_EBI0CSA
);
386 at91_sys_write(AT91_MATRIX_EBI0CSA
, csa
| AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA
);
388 /* set the bus interface characteristics */
389 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
390 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
392 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(3) | AT91_SMC_NCS_WRPULSE_(3)
393 | AT91_SMC_NRDPULSE_(3) | AT91_SMC_NCS_RDPULSE_(3));
395 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(5) | AT91_SMC_NRDCYCLE_(5));
397 if (data
->bus_width_16
)
398 mode
= AT91_SMC_DBW_16
;
400 mode
= AT91_SMC_DBW_8
;
401 at91_sys_write(AT91_SMC_MODE(3), mode
| AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_TDF_(2));
404 if (data
->enable_pin
)
405 at91_set_gpio_output(data
->enable_pin
, 1);
409 at91_set_gpio_input(data
->rdy_pin
, 1);
411 /* card detect pin */
413 at91_set_gpio_input(data
->det_pin
, 1);
416 platform_device_register(&at91sam9263_nand_device
);
419 void __init
at91_add_device_nand(struct at91_nand_data
*data
) {}
423 /* --------------------------------------------------------------------
425 * -------------------------------------------------------------------- */
428 * Prefer the GPIO code since the TWI controller isn't robust
429 * (gets overruns and underruns under load) and can only issue
430 * repeated STARTs in one scenario (the driver doesn't yet handle them).
432 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
434 static struct i2c_gpio_platform_data pdata
= {
435 .sda_pin
= AT91_PIN_PB4
,
436 .sda_is_open_drain
= 1,
437 .scl_pin
= AT91_PIN_PB5
,
438 .scl_is_open_drain
= 1,
439 .udelay
= 2, /* ~100 kHz */
442 static struct platform_device at91sam9263_twi_device
= {
445 .dev
.platform_data
= &pdata
,
448 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
450 at91_set_GPIO_periph(AT91_PIN_PB4
, 1); /* TWD (SDA) */
451 at91_set_multi_drive(AT91_PIN_PB4
, 1);
453 at91_set_GPIO_periph(AT91_PIN_PB5
, 1); /* TWCK (SCL) */
454 at91_set_multi_drive(AT91_PIN_PB5
, 1);
456 i2c_register_board_info(0, devices
, nr_devices
);
457 platform_device_register(&at91sam9263_twi_device
);
460 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
462 static struct resource twi_resources
[] = {
464 .start
= AT91SAM9263_BASE_TWI
,
465 .end
= AT91SAM9263_BASE_TWI
+ SZ_16K
- 1,
466 .flags
= IORESOURCE_MEM
,
469 .start
= AT91SAM9263_ID_TWI
,
470 .end
= AT91SAM9263_ID_TWI
,
471 .flags
= IORESOURCE_IRQ
,
475 static struct platform_device at91sam9263_twi_device
= {
478 .resource
= twi_resources
,
479 .num_resources
= ARRAY_SIZE(twi_resources
),
482 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
484 /* pins used for TWI interface */
485 at91_set_A_periph(AT91_PIN_PB4
, 0); /* TWD */
486 at91_set_multi_drive(AT91_PIN_PB4
, 1);
488 at91_set_A_periph(AT91_PIN_PB5
, 0); /* TWCK */
489 at91_set_multi_drive(AT91_PIN_PB5
, 1);
491 i2c_register_board_info(0, devices
, nr_devices
);
492 platform_device_register(&at91sam9263_twi_device
);
495 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
) {}
499 /* --------------------------------------------------------------------
501 * -------------------------------------------------------------------- */
503 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
504 static u64 spi_dmamask
= DMA_BIT_MASK(32);
506 static struct resource spi0_resources
[] = {
508 .start
= AT91SAM9263_BASE_SPI0
,
509 .end
= AT91SAM9263_BASE_SPI0
+ SZ_16K
- 1,
510 .flags
= IORESOURCE_MEM
,
513 .start
= AT91SAM9263_ID_SPI0
,
514 .end
= AT91SAM9263_ID_SPI0
,
515 .flags
= IORESOURCE_IRQ
,
519 static struct platform_device at91sam9263_spi0_device
= {
523 .dma_mask
= &spi_dmamask
,
524 .coherent_dma_mask
= DMA_BIT_MASK(32),
526 .resource
= spi0_resources
,
527 .num_resources
= ARRAY_SIZE(spi0_resources
),
530 static const unsigned spi0_standard_cs
[4] = { AT91_PIN_PA5
, AT91_PIN_PA3
, AT91_PIN_PA4
, AT91_PIN_PB11
};
532 static struct resource spi1_resources
[] = {
534 .start
= AT91SAM9263_BASE_SPI1
,
535 .end
= AT91SAM9263_BASE_SPI1
+ SZ_16K
- 1,
536 .flags
= IORESOURCE_MEM
,
539 .start
= AT91SAM9263_ID_SPI1
,
540 .end
= AT91SAM9263_ID_SPI1
,
541 .flags
= IORESOURCE_IRQ
,
545 static struct platform_device at91sam9263_spi1_device
= {
549 .dma_mask
= &spi_dmamask
,
550 .coherent_dma_mask
= DMA_BIT_MASK(32),
552 .resource
= spi1_resources
,
553 .num_resources
= ARRAY_SIZE(spi1_resources
),
556 static const unsigned spi1_standard_cs
[4] = { AT91_PIN_PB15
, AT91_PIN_PB16
, AT91_PIN_PB17
, AT91_PIN_PB18
};
558 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
)
561 unsigned long cs_pin
;
562 short enable_spi0
= 0;
563 short enable_spi1
= 0;
565 /* Choose SPI chip-selects */
566 for (i
= 0; i
< nr_devices
; i
++) {
567 if (devices
[i
].controller_data
)
568 cs_pin
= (unsigned long) devices
[i
].controller_data
;
569 else if (devices
[i
].bus_num
== 0)
570 cs_pin
= spi0_standard_cs
[devices
[i
].chip_select
];
572 cs_pin
= spi1_standard_cs
[devices
[i
].chip_select
];
574 if (devices
[i
].bus_num
== 0)
579 /* enable chip-select pin */
580 at91_set_gpio_output(cs_pin
, 1);
582 /* pass chip-select pin to driver */
583 devices
[i
].controller_data
= (void *) cs_pin
;
586 spi_register_board_info(devices
, nr_devices
);
588 /* Configure SPI bus(es) */
590 at91_set_B_periph(AT91_PIN_PA0
, 0); /* SPI0_MISO */
591 at91_set_B_periph(AT91_PIN_PA1
, 0); /* SPI0_MOSI */
592 at91_set_B_periph(AT91_PIN_PA2
, 0); /* SPI0_SPCK */
594 at91_clock_associate("spi0_clk", &at91sam9263_spi0_device
.dev
, "spi_clk");
595 platform_device_register(&at91sam9263_spi0_device
);
598 at91_set_A_periph(AT91_PIN_PB12
, 0); /* SPI1_MISO */
599 at91_set_A_periph(AT91_PIN_PB13
, 0); /* SPI1_MOSI */
600 at91_set_A_periph(AT91_PIN_PB14
, 0); /* SPI1_SPCK */
602 at91_clock_associate("spi1_clk", &at91sam9263_spi1_device
.dev
, "spi_clk");
603 platform_device_register(&at91sam9263_spi1_device
);
607 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
) {}
611 /* --------------------------------------------------------------------
613 * -------------------------------------------------------------------- */
615 #if defined(CONFIG_SND_AT91_AC97) || defined(CONFIG_SND_AT91_AC97_MODULE)
616 static u64 ac97_dmamask
= DMA_BIT_MASK(32);
617 static struct atmel_ac97_data ac97_data
;
619 static struct resource ac97_resources
[] = {
621 .start
= AT91SAM9263_BASE_AC97C
,
622 .end
= AT91SAM9263_BASE_AC97C
+ SZ_16K
- 1,
623 .flags
= IORESOURCE_MEM
,
626 .start
= AT91SAM9263_ID_AC97C
,
627 .end
= AT91SAM9263_ID_AC97C
,
628 .flags
= IORESOURCE_IRQ
,
632 static struct platform_device at91sam9263_ac97_device
= {
636 .dma_mask
= &ac97_dmamask
,
637 .coherent_dma_mask
= DMA_BIT_MASK(32),
638 .platform_data
= &ac97_data
,
640 .resource
= ac97_resources
,
641 .num_resources
= ARRAY_SIZE(ac97_resources
),
644 void __init
at91_add_device_ac97(struct atmel_ac97_data
*data
)
649 at91_set_A_periph(AT91_PIN_PB0
, 0); /* AC97FS */
650 at91_set_A_periph(AT91_PIN_PB1
, 0); /* AC97CK */
651 at91_set_A_periph(AT91_PIN_PB2
, 0); /* AC97TX */
652 at91_set_A_periph(AT91_PIN_PB3
, 0); /* AC97RX */
656 at91_set_gpio_output(data
->reset_pin
, 0);
658 ac97_data
= *ek_data
;
659 platform_device_register(&at91sam9263_ac97_device
);
662 void __init
at91_add_device_ac97(struct atmel_ac97_data
*data
) {}
666 /* --------------------------------------------------------------------
668 * -------------------------------------------------------------------- */
670 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
671 static u64 lcdc_dmamask
= DMA_BIT_MASK(32);
672 static struct atmel_lcdfb_info lcdc_data
;
674 static struct resource lcdc_resources
[] = {
676 .start
= AT91SAM9263_LCDC_BASE
,
677 .end
= AT91SAM9263_LCDC_BASE
+ SZ_4K
- 1,
678 .flags
= IORESOURCE_MEM
,
681 .start
= AT91SAM9263_ID_LCDC
,
682 .end
= AT91SAM9263_ID_LCDC
,
683 .flags
= IORESOURCE_IRQ
,
687 static struct platform_device at91_lcdc_device
= {
688 .name
= "atmel_lcdfb",
691 .dma_mask
= &lcdc_dmamask
,
692 .coherent_dma_mask
= DMA_BIT_MASK(32),
693 .platform_data
= &lcdc_data
,
695 .resource
= lcdc_resources
,
696 .num_resources
= ARRAY_SIZE(lcdc_resources
),
699 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
)
704 at91_set_A_periph(AT91_PIN_PC1
, 0); /* LCDHSYNC */
705 at91_set_A_periph(AT91_PIN_PC2
, 0); /* LCDDOTCK */
706 at91_set_A_periph(AT91_PIN_PC3
, 0); /* LCDDEN */
707 at91_set_B_periph(AT91_PIN_PB9
, 0); /* LCDCC */
708 at91_set_A_periph(AT91_PIN_PC6
, 0); /* LCDD2 */
709 at91_set_A_periph(AT91_PIN_PC7
, 0); /* LCDD3 */
710 at91_set_A_periph(AT91_PIN_PC8
, 0); /* LCDD4 */
711 at91_set_A_periph(AT91_PIN_PC9
, 0); /* LCDD5 */
712 at91_set_A_periph(AT91_PIN_PC10
, 0); /* LCDD6 */
713 at91_set_A_periph(AT91_PIN_PC11
, 0); /* LCDD7 */
714 at91_set_A_periph(AT91_PIN_PC14
, 0); /* LCDD10 */
715 at91_set_A_periph(AT91_PIN_PC15
, 0); /* LCDD11 */
716 at91_set_A_periph(AT91_PIN_PC16
, 0); /* LCDD12 */
717 at91_set_B_periph(AT91_PIN_PC12
, 0); /* LCDD13 */
718 at91_set_A_periph(AT91_PIN_PC18
, 0); /* LCDD14 */
719 at91_set_A_periph(AT91_PIN_PC19
, 0); /* LCDD15 */
720 at91_set_A_periph(AT91_PIN_PC22
, 0); /* LCDD18 */
721 at91_set_A_periph(AT91_PIN_PC23
, 0); /* LCDD19 */
722 at91_set_A_periph(AT91_PIN_PC24
, 0); /* LCDD20 */
723 at91_set_B_periph(AT91_PIN_PC17
, 0); /* LCDD21 */
724 at91_set_A_periph(AT91_PIN_PC26
, 0); /* LCDD22 */
725 at91_set_A_periph(AT91_PIN_PC27
, 0); /* LCDD23 */
728 platform_device_register(&at91_lcdc_device
);
731 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
) {}
735 /* --------------------------------------------------------------------
736 * Image Sensor Interface
737 * -------------------------------------------------------------------- */
739 #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
741 struct resource isi_resources
[] = {
743 .start
= AT91SAM9263_BASE_ISI
,
744 .end
= AT91SAM9263_BASE_ISI
+ SZ_16K
- 1,
745 .flags
= IORESOURCE_MEM
,
748 .start
= AT91SAM9263_ID_ISI
,
749 .end
= AT91SAM9263_ID_ISI
,
750 .flags
= IORESOURCE_IRQ
,
754 static struct platform_device at91sam9263_isi_device
= {
757 .resource
= isi_resources
,
758 .num_resources
= ARRAY_SIZE(isi_resources
),
761 void __init
at91_add_device_isi(void)
763 at91_set_A_periph(AT91_PIN_PE0
, 0); /* ISI_D0 */
764 at91_set_A_periph(AT91_PIN_PE1
, 0); /* ISI_D1 */
765 at91_set_A_periph(AT91_PIN_PE2
, 0); /* ISI_D2 */
766 at91_set_A_periph(AT91_PIN_PE3
, 0); /* ISI_D3 */
767 at91_set_A_periph(AT91_PIN_PE4
, 0); /* ISI_D4 */
768 at91_set_A_periph(AT91_PIN_PE5
, 0); /* ISI_D5 */
769 at91_set_A_periph(AT91_PIN_PE6
, 0); /* ISI_D6 */
770 at91_set_A_periph(AT91_PIN_PE7
, 0); /* ISI_D7 */
771 at91_set_A_periph(AT91_PIN_PE8
, 0); /* ISI_PCK */
772 at91_set_A_periph(AT91_PIN_PE9
, 0); /* ISI_HSYNC */
773 at91_set_A_periph(AT91_PIN_PE10
, 0); /* ISI_VSYNC */
774 at91_set_B_periph(AT91_PIN_PE11
, 0); /* ISI_MCK (PCK3) */
775 at91_set_B_periph(AT91_PIN_PE12
, 0); /* ISI_PD8 */
776 at91_set_B_periph(AT91_PIN_PE13
, 0); /* ISI_PD9 */
777 at91_set_B_periph(AT91_PIN_PE14
, 0); /* ISI_PD10 */
778 at91_set_B_periph(AT91_PIN_PE15
, 0); /* ISI_PD11 */
781 void __init
at91_add_device_isi(void) {}
785 /* --------------------------------------------------------------------
787 * -------------------------------------------------------------------- */
789 static struct resource rtt0_resources
[] = {
791 .start
= AT91_BASE_SYS
+ AT91_RTT0
,
792 .end
= AT91_BASE_SYS
+ AT91_RTT0
+ SZ_16
- 1,
793 .flags
= IORESOURCE_MEM
,
797 static struct platform_device at91sam9263_rtt0_device
= {
800 .resource
= rtt0_resources
,
801 .num_resources
= ARRAY_SIZE(rtt0_resources
),
804 static struct resource rtt1_resources
[] = {
806 .start
= AT91_BASE_SYS
+ AT91_RTT1
,
807 .end
= AT91_BASE_SYS
+ AT91_RTT1
+ SZ_16
- 1,
808 .flags
= IORESOURCE_MEM
,
812 static struct platform_device at91sam9263_rtt1_device
= {
815 .resource
= rtt1_resources
,
816 .num_resources
= ARRAY_SIZE(rtt1_resources
),
819 static void __init
at91_add_device_rtt(void)
821 platform_device_register(&at91sam9263_rtt0_device
);
822 platform_device_register(&at91sam9263_rtt1_device
);
826 /* --------------------------------------------------------------------
828 * -------------------------------------------------------------------- */
830 #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
831 static struct platform_device at91sam9263_wdt_device
= {
837 static void __init
at91_add_device_watchdog(void)
839 platform_device_register(&at91sam9263_wdt_device
);
842 static void __init
at91_add_device_watchdog(void) {}
846 /* --------------------------------------------------------------------
847 * SSC -- Synchronous Serial Controller
848 * -------------------------------------------------------------------- */
850 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
851 static u64 ssc0_dmamask
= DMA_BIT_MASK(32);
853 static struct resource ssc0_resources
[] = {
855 .start
= AT91SAM9263_BASE_SSC0
,
856 .end
= AT91SAM9263_BASE_SSC0
+ SZ_16K
- 1,
857 .flags
= IORESOURCE_MEM
,
860 .start
= AT91SAM9263_ID_SSC0
,
861 .end
= AT91SAM9263_ID_SSC0
,
862 .flags
= IORESOURCE_IRQ
,
866 static struct platform_device at91sam9263_ssc0_device
= {
870 .dma_mask
= &ssc0_dmamask
,
871 .coherent_dma_mask
= DMA_BIT_MASK(32),
873 .resource
= ssc0_resources
,
874 .num_resources
= ARRAY_SIZE(ssc0_resources
),
877 static inline void configure_ssc0_pins(unsigned pins
)
879 if (pins
& ATMEL_SSC_TF
)
880 at91_set_B_periph(AT91_PIN_PB0
, 1);
881 if (pins
& ATMEL_SSC_TK
)
882 at91_set_B_periph(AT91_PIN_PB1
, 1);
883 if (pins
& ATMEL_SSC_TD
)
884 at91_set_B_periph(AT91_PIN_PB2
, 1);
885 if (pins
& ATMEL_SSC_RD
)
886 at91_set_B_periph(AT91_PIN_PB3
, 1);
887 if (pins
& ATMEL_SSC_RK
)
888 at91_set_B_periph(AT91_PIN_PB4
, 1);
889 if (pins
& ATMEL_SSC_RF
)
890 at91_set_B_periph(AT91_PIN_PB5
, 1);
893 static u64 ssc1_dmamask
= DMA_BIT_MASK(32);
895 static struct resource ssc1_resources
[] = {
897 .start
= AT91SAM9263_BASE_SSC1
,
898 .end
= AT91SAM9263_BASE_SSC1
+ SZ_16K
- 1,
899 .flags
= IORESOURCE_MEM
,
902 .start
= AT91SAM9263_ID_SSC1
,
903 .end
= AT91SAM9263_ID_SSC1
,
904 .flags
= IORESOURCE_IRQ
,
908 static struct platform_device at91sam9263_ssc1_device
= {
912 .dma_mask
= &ssc1_dmamask
,
913 .coherent_dma_mask
= DMA_BIT_MASK(32),
915 .resource
= ssc1_resources
,
916 .num_resources
= ARRAY_SIZE(ssc1_resources
),
919 static inline void configure_ssc1_pins(unsigned pins
)
921 if (pins
& ATMEL_SSC_TF
)
922 at91_set_A_periph(AT91_PIN_PB6
, 1);
923 if (pins
& ATMEL_SSC_TK
)
924 at91_set_A_periph(AT91_PIN_PB7
, 1);
925 if (pins
& ATMEL_SSC_TD
)
926 at91_set_A_periph(AT91_PIN_PB8
, 1);
927 if (pins
& ATMEL_SSC_RD
)
928 at91_set_A_periph(AT91_PIN_PB9
, 1);
929 if (pins
& ATMEL_SSC_RK
)
930 at91_set_A_periph(AT91_PIN_PB10
, 1);
931 if (pins
& ATMEL_SSC_RF
)
932 at91_set_A_periph(AT91_PIN_PB11
, 1);
936 * Return the device node so that board init code can use it as the
937 * parent for the device node reflecting how it's used on this board.
939 * SSC controllers are accessed through library code, instead of any
940 * kind of all-singing/all-dancing driver. For example one could be
941 * used by a particular I2S audio codec's driver, while another one
942 * on the same system might be used by a custom data capture driver.
944 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
)
946 struct platform_device
*pdev
;
949 * NOTE: caller is responsible for passing information matching
950 * "pins" to whatever will be using each particular controller.
953 case AT91SAM9263_ID_SSC0
:
954 pdev
= &at91sam9263_ssc0_device
;
955 configure_ssc0_pins(pins
);
956 at91_clock_associate("ssc0_clk", &pdev
->dev
, "pclk");
958 case AT91SAM9263_ID_SSC1
:
959 pdev
= &at91sam9263_ssc1_device
;
960 configure_ssc1_pins(pins
);
961 at91_clock_associate("ssc1_clk", &pdev
->dev
, "pclk");
967 platform_device_register(pdev
);
971 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
) {}
975 /* --------------------------------------------------------------------
977 * -------------------------------------------------------------------- */
979 #if defined(CONFIG_SERIAL_ATMEL)
981 static struct resource dbgu_resources
[] = {
983 .start
= AT91_VA_BASE_SYS
+ AT91_DBGU
,
984 .end
= AT91_VA_BASE_SYS
+ AT91_DBGU
+ SZ_512
- 1,
985 .flags
= IORESOURCE_MEM
,
988 .start
= AT91_ID_SYS
,
990 .flags
= IORESOURCE_IRQ
,
994 static struct atmel_uart_data dbgu_data
= {
996 .use_dma_rx
= 0, /* DBGU not capable of receive DMA */
997 .regs
= (void __iomem
*)(AT91_VA_BASE_SYS
+ AT91_DBGU
),
1000 static u64 dbgu_dmamask
= DMA_BIT_MASK(32);
1002 static struct platform_device at91sam9263_dbgu_device
= {
1003 .name
= "atmel_usart",
1006 .dma_mask
= &dbgu_dmamask
,
1007 .coherent_dma_mask
= DMA_BIT_MASK(32),
1008 .platform_data
= &dbgu_data
,
1010 .resource
= dbgu_resources
,
1011 .num_resources
= ARRAY_SIZE(dbgu_resources
),
1014 static inline void configure_dbgu_pins(void)
1016 at91_set_A_periph(AT91_PIN_PC30
, 0); /* DRXD */
1017 at91_set_A_periph(AT91_PIN_PC31
, 1); /* DTXD */
1020 static struct resource uart0_resources
[] = {
1022 .start
= AT91SAM9263_BASE_US0
,
1023 .end
= AT91SAM9263_BASE_US0
+ SZ_16K
- 1,
1024 .flags
= IORESOURCE_MEM
,
1027 .start
= AT91SAM9263_ID_US0
,
1028 .end
= AT91SAM9263_ID_US0
,
1029 .flags
= IORESOURCE_IRQ
,
1033 static struct atmel_uart_data uart0_data
= {
1038 static u64 uart0_dmamask
= DMA_BIT_MASK(32);
1040 static struct platform_device at91sam9263_uart0_device
= {
1041 .name
= "atmel_usart",
1044 .dma_mask
= &uart0_dmamask
,
1045 .coherent_dma_mask
= DMA_BIT_MASK(32),
1046 .platform_data
= &uart0_data
,
1048 .resource
= uart0_resources
,
1049 .num_resources
= ARRAY_SIZE(uart0_resources
),
1052 static inline void configure_usart0_pins(unsigned pins
)
1054 at91_set_A_periph(AT91_PIN_PA26
, 1); /* TXD0 */
1055 at91_set_A_periph(AT91_PIN_PA27
, 0); /* RXD0 */
1057 if (pins
& ATMEL_UART_RTS
)
1058 at91_set_A_periph(AT91_PIN_PA28
, 0); /* RTS0 */
1059 if (pins
& ATMEL_UART_CTS
)
1060 at91_set_A_periph(AT91_PIN_PA29
, 0); /* CTS0 */
1063 static struct resource uart1_resources
[] = {
1065 .start
= AT91SAM9263_BASE_US1
,
1066 .end
= AT91SAM9263_BASE_US1
+ SZ_16K
- 1,
1067 .flags
= IORESOURCE_MEM
,
1070 .start
= AT91SAM9263_ID_US1
,
1071 .end
= AT91SAM9263_ID_US1
,
1072 .flags
= IORESOURCE_IRQ
,
1076 static struct atmel_uart_data uart1_data
= {
1081 static u64 uart1_dmamask
= DMA_BIT_MASK(32);
1083 static struct platform_device at91sam9263_uart1_device
= {
1084 .name
= "atmel_usart",
1087 .dma_mask
= &uart1_dmamask
,
1088 .coherent_dma_mask
= DMA_BIT_MASK(32),
1089 .platform_data
= &uart1_data
,
1091 .resource
= uart1_resources
,
1092 .num_resources
= ARRAY_SIZE(uart1_resources
),
1095 static inline void configure_usart1_pins(unsigned pins
)
1097 at91_set_A_periph(AT91_PIN_PD0
, 1); /* TXD1 */
1098 at91_set_A_periph(AT91_PIN_PD1
, 0); /* RXD1 */
1100 if (pins
& ATMEL_UART_RTS
)
1101 at91_set_B_periph(AT91_PIN_PD7
, 0); /* RTS1 */
1102 if (pins
& ATMEL_UART_CTS
)
1103 at91_set_B_periph(AT91_PIN_PD8
, 0); /* CTS1 */
1106 static struct resource uart2_resources
[] = {
1108 .start
= AT91SAM9263_BASE_US2
,
1109 .end
= AT91SAM9263_BASE_US2
+ SZ_16K
- 1,
1110 .flags
= IORESOURCE_MEM
,
1113 .start
= AT91SAM9263_ID_US2
,
1114 .end
= AT91SAM9263_ID_US2
,
1115 .flags
= IORESOURCE_IRQ
,
1119 static struct atmel_uart_data uart2_data
= {
1124 static u64 uart2_dmamask
= DMA_BIT_MASK(32);
1126 static struct platform_device at91sam9263_uart2_device
= {
1127 .name
= "atmel_usart",
1130 .dma_mask
= &uart2_dmamask
,
1131 .coherent_dma_mask
= DMA_BIT_MASK(32),
1132 .platform_data
= &uart2_data
,
1134 .resource
= uart2_resources
,
1135 .num_resources
= ARRAY_SIZE(uart2_resources
),
1138 static inline void configure_usart2_pins(unsigned pins
)
1140 at91_set_A_periph(AT91_PIN_PD2
, 1); /* TXD2 */
1141 at91_set_A_periph(AT91_PIN_PD3
, 0); /* RXD2 */
1143 if (pins
& ATMEL_UART_RTS
)
1144 at91_set_B_periph(AT91_PIN_PD5
, 0); /* RTS2 */
1145 if (pins
& ATMEL_UART_CTS
)
1146 at91_set_B_periph(AT91_PIN_PD6
, 0); /* CTS2 */
1149 static struct platform_device
*at91_uarts
[ATMEL_MAX_UART
]; /* the UARTs to use */
1150 struct platform_device
*atmel_default_console_device
; /* the serial console device */
1152 void __init __deprecated
at91_init_serial(struct at91_uart_config
*config
)
1156 /* Fill in list of supported UARTs */
1157 for (i
= 0; i
< config
->nr_tty
; i
++) {
1158 switch (config
->tty_map
[i
]) {
1160 configure_usart0_pins(ATMEL_UART_CTS
| ATMEL_UART_RTS
);
1161 at91_uarts
[i
] = &at91sam9263_uart0_device
;
1162 at91_clock_associate("usart0_clk", &at91sam9263_uart0_device
.dev
, "usart");
1165 configure_usart1_pins(ATMEL_UART_CTS
| ATMEL_UART_RTS
);
1166 at91_uarts
[i
] = &at91sam9263_uart1_device
;
1167 at91_clock_associate("usart1_clk", &at91sam9263_uart1_device
.dev
, "usart");
1170 configure_usart2_pins(ATMEL_UART_CTS
| ATMEL_UART_RTS
);
1171 at91_uarts
[i
] = &at91sam9263_uart2_device
;
1172 at91_clock_associate("usart2_clk", &at91sam9263_uart2_device
.dev
, "usart");
1175 configure_dbgu_pins();
1176 at91_uarts
[i
] = &at91sam9263_dbgu_device
;
1177 at91_clock_associate("mck", &at91sam9263_dbgu_device
.dev
, "usart");
1182 at91_uarts
[i
]->id
= i
; /* update ID number to mapped ID */
1185 /* Set serial console device */
1186 if (config
->console_tty
< ATMEL_MAX_UART
)
1187 atmel_default_console_device
= at91_uarts
[config
->console_tty
];
1188 if (!atmel_default_console_device
)
1189 printk(KERN_INFO
"AT91: No default serial console defined.\n");
1192 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
)
1194 struct platform_device
*pdev
;
1198 pdev
= &at91sam9263_dbgu_device
;
1199 configure_dbgu_pins();
1200 at91_clock_associate("mck", &pdev
->dev
, "usart");
1202 case AT91SAM9263_ID_US0
:
1203 pdev
= &at91sam9263_uart0_device
;
1204 configure_usart0_pins(pins
);
1205 at91_clock_associate("usart0_clk", &pdev
->dev
, "usart");
1207 case AT91SAM9263_ID_US1
:
1208 pdev
= &at91sam9263_uart1_device
;
1209 configure_usart1_pins(pins
);
1210 at91_clock_associate("usart1_clk", &pdev
->dev
, "usart");
1212 case AT91SAM9263_ID_US2
:
1213 pdev
= &at91sam9263_uart2_device
;
1214 configure_usart2_pins(pins
);
1215 at91_clock_associate("usart2_clk", &pdev
->dev
, "usart");
1220 pdev
->id
= portnr
; /* update to mapped ID */
1222 if (portnr
< ATMEL_MAX_UART
)
1223 at91_uarts
[portnr
] = pdev
;
1226 void __init
at91_set_serial_console(unsigned portnr
)
1228 if (portnr
< ATMEL_MAX_UART
)
1229 atmel_default_console_device
= at91_uarts
[portnr
];
1230 if (!atmel_default_console_device
)
1231 printk(KERN_INFO
"AT91: No default serial console defined.\n");
1234 void __init
at91_add_device_serial(void)
1238 for (i
= 0; i
< ATMEL_MAX_UART
; i
++) {
1240 platform_device_register(at91_uarts
[i
]);
1244 void __init
at91_init_serial(struct at91_uart_config
*config
) {}
1245 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
) {}
1246 void __init
at91_set_serial_console(unsigned portnr
) {}
1247 void __init
at91_add_device_serial(void) {}
1251 /* -------------------------------------------------------------------- */
1253 * These devices are always present and don't need any board-specific
1256 static int __init
at91_add_standard_devices(void)
1258 at91_add_device_rtt();
1259 at91_add_device_watchdog();
1263 arch_initcall(at91_add_standard_devices
);