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/gpio.h>
17 #include <linux/platform_device.h>
18 #include <linux/i2c-gpio.h>
21 #include <video/atmel_lcdc.h>
23 #include <mach/board.h>
24 #include <mach/at91sam9263.h>
25 #include <mach/at91sam9263_matrix.h>
26 #include <mach/at91sam9_smc.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 (gpio_is_valid(data->vbus_pin[i]))
74 at91_set_gpio_output(data->vbus_pin[i], 0);
77 /* Enable overcurrent notification */
78 for (i = 0; i < data->ports; i++) {
79 if (data->overcurrent_pin[i])
80 at91_set_gpio_input(data->overcurrent_pin[i], 1);
84 platform_device_register(&at91_usbh_device);
87 void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
91 /* --------------------------------------------------------------------
93 * -------------------------------------------------------------------- */
95 #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
96 static struct at91_udc_data udc_data;
98 static struct resource udc_resources[] = {
100 .start = AT91SAM9263_BASE_UDP,
101 .end = AT91SAM9263_BASE_UDP + SZ_16K - 1,
102 .flags = IORESOURCE_MEM,
105 .start = AT91SAM9263_ID_UDP,
106 .end = AT91SAM9263_ID_UDP,
107 .flags = IORESOURCE_IRQ,
111 static struct platform_device at91_udc_device = {
115 .platform_data = &udc_data,
117 .resource = udc_resources,
118 .num_resources = ARRAY_SIZE(udc_resources),
121 void __init at91_add_device_udc(struct at91_udc_data *data)
126 if (gpio_is_valid(data->vbus_pin)) {
127 at91_set_gpio_input(data->vbus_pin, 0);
128 at91_set_deglitch(data->vbus_pin, 1);
131 /* Pullup pin is handled internally by USB device peripheral */
134 platform_device_register(&at91_udc_device);
137 void __init at91_add_device_udc(struct at91_udc_data *data) {}
141 /* --------------------------------------------------------------------
143 * -------------------------------------------------------------------- */
145 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
146 static u64 eth_dmamask = DMA_BIT_MASK(32);
147 static struct macb_platform_data eth_data;
149 static struct resource eth_resources[] = {
151 .start = AT91SAM9263_BASE_EMAC,
152 .end = AT91SAM9263_BASE_EMAC + SZ_16K - 1,
153 .flags = IORESOURCE_MEM,
156 .start = AT91SAM9263_ID_EMAC,
157 .end = AT91SAM9263_ID_EMAC,
158 .flags = IORESOURCE_IRQ,
162 static struct platform_device at91sam9263_eth_device = {
166 .dma_mask = ð_dmamask,
167 .coherent_dma_mask = DMA_BIT_MASK(32),
168 .platform_data = ð_data,
170 .resource = eth_resources,
171 .num_resources = ARRAY_SIZE(eth_resources),
174 void __init at91_add_device_eth(struct macb_platform_data *data)
179 if (gpio_is_valid(data->phy_irq_pin)) {
180 at91_set_gpio_input(data->phy_irq_pin, 0);
181 at91_set_deglitch(data->phy_irq_pin, 1);
184 /* Pins used for MII and RMII */
185 at91_set_A_periph(AT91_PIN_PE21, 0); /* ETXCK_EREFCK */
186 at91_set_B_periph(AT91_PIN_PC25, 0); /* ERXDV */
187 at91_set_A_periph(AT91_PIN_PE25, 0); /* ERX0 */
188 at91_set_A_periph(AT91_PIN_PE26, 0); /* ERX1 */
189 at91_set_A_periph(AT91_PIN_PE27, 0); /* ERXER */
190 at91_set_A_periph(AT91_PIN_PE28, 0); /* ETXEN */
191 at91_set_A_periph(AT91_PIN_PE23, 0); /* ETX0 */
192 at91_set_A_periph(AT91_PIN_PE24, 0); /* ETX1 */
193 at91_set_A_periph(AT91_PIN_PE30, 0); /* EMDIO */
194 at91_set_A_periph(AT91_PIN_PE29, 0); /* EMDC */
196 if (!data->is_rmii) {
197 at91_set_A_periph(AT91_PIN_PE22, 0); /* ECRS */
198 at91_set_B_periph(AT91_PIN_PC26, 0); /* ECOL */
199 at91_set_B_periph(AT91_PIN_PC22, 0); /* ERX2 */
200 at91_set_B_periph(AT91_PIN_PC23, 0); /* ERX3 */
201 at91_set_B_periph(AT91_PIN_PC27, 0); /* ERXCK */
202 at91_set_B_periph(AT91_PIN_PC20, 0); /* ETX2 */
203 at91_set_B_periph(AT91_PIN_PC21, 0); /* ETX3 */
204 at91_set_B_periph(AT91_PIN_PC24, 0); /* ETXER */
208 platform_device_register(&at91sam9263_eth_device);
211 void __init at91_add_device_eth(struct macb_platform_data *data) {}
215 /* --------------------------------------------------------------------
217 * -------------------------------------------------------------------- */
219 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
220 static u64 mmc_dmamask = DMA_BIT_MASK(32);
221 static struct at91_mmc_data mmc0_data, mmc1_data;
223 static struct resource mmc0_resources[] = {
225 .start = AT91SAM9263_BASE_MCI0,
226 .end = AT91SAM9263_BASE_MCI0 + SZ_16K - 1,
227 .flags = IORESOURCE_MEM,
230 .start = AT91SAM9263_ID_MCI0,
231 .end = AT91SAM9263_ID_MCI0,
232 .flags = IORESOURCE_IRQ,
236 static struct platform_device at91sam9263_mmc0_device = {
240 .dma_mask = &mmc_dmamask,
241 .coherent_dma_mask = DMA_BIT_MASK(32),
242 .platform_data = &mmc0_data,
244 .resource = mmc0_resources,
245 .num_resources = ARRAY_SIZE(mmc0_resources),
248 static struct resource mmc1_resources[] = {
250 .start = AT91SAM9263_BASE_MCI1,
251 .end = AT91SAM9263_BASE_MCI1 + SZ_16K - 1,
252 .flags = IORESOURCE_MEM,
255 .start = AT91SAM9263_ID_MCI1,
256 .end = AT91SAM9263_ID_MCI1,
257 .flags = IORESOURCE_IRQ,
261 static struct platform_device at91sam9263_mmc1_device = {
265 .dma_mask = &mmc_dmamask,
266 .coherent_dma_mask = DMA_BIT_MASK(32),
267 .platform_data = &mmc1_data,
269 .resource = mmc1_resources,
270 .num_resources = ARRAY_SIZE(mmc1_resources),
273 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
279 if (gpio_is_valid(data->det_pin)) {
280 at91_set_gpio_input(data->det_pin, 1);
281 at91_set_deglitch(data->det_pin, 1);
283 if (gpio_is_valid(data->wp_pin))
284 at91_set_gpio_input(data->wp_pin, 1);
285 if (gpio_is_valid(data->vcc_pin))
286 at91_set_gpio_output(data->vcc_pin, 0);
288 if (mmc_id == 0) { /* MCI0 */
290 at91_set_A_periph(AT91_PIN_PA12, 0);
294 at91_set_A_periph(AT91_PIN_PA16, 1);
296 /* DAT0, maybe DAT1..DAT3 */
297 at91_set_A_periph(AT91_PIN_PA17, 1);
299 at91_set_A_periph(AT91_PIN_PA18, 1);
300 at91_set_A_periph(AT91_PIN_PA19, 1);
301 at91_set_A_periph(AT91_PIN_PA20, 1);
305 at91_set_A_periph(AT91_PIN_PA1, 1);
307 /* DAT0, maybe DAT1..DAT3 */
308 at91_set_A_periph(AT91_PIN_PA0, 1);
310 at91_set_A_periph(AT91_PIN_PA3, 1);
311 at91_set_A_periph(AT91_PIN_PA4, 1);
312 at91_set_A_periph(AT91_PIN_PA5, 1);
317 platform_device_register(&at91sam9263_mmc0_device);
320 at91_set_A_periph(AT91_PIN_PA6, 0);
324 at91_set_A_periph(AT91_PIN_PA21, 1);
326 /* DAT0, maybe DAT1..DAT3 */
327 at91_set_A_periph(AT91_PIN_PA22, 1);
329 at91_set_A_periph(AT91_PIN_PA23, 1);
330 at91_set_A_periph(AT91_PIN_PA24, 1);
331 at91_set_A_periph(AT91_PIN_PA25, 1);
335 at91_set_A_periph(AT91_PIN_PA7, 1);
337 /* DAT0, maybe DAT1..DAT3 */
338 at91_set_A_periph(AT91_PIN_PA8, 1);
340 at91_set_A_periph(AT91_PIN_PA9, 1);
341 at91_set_A_periph(AT91_PIN_PA10, 1);
342 at91_set_A_periph(AT91_PIN_PA11, 1);
347 platform_device_register(&at91sam9263_mmc1_device);
351 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
354 /* --------------------------------------------------------------------
355 * Compact Flash (PCMCIA or IDE)
356 * -------------------------------------------------------------------- */
358 #if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
359 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
361 static struct at91_cf_data cf0_data;
363 static struct resource cf0_resources[] = {
365 .start = AT91_CHIPSELECT_4,
366 .end = AT91_CHIPSELECT_4 + SZ_256M - 1,
367 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
371 static struct platform_device cf0_device = {
374 .platform_data = &cf0_data,
376 .resource = cf0_resources,
377 .num_resources = ARRAY_SIZE(cf0_resources),
380 static struct at91_cf_data cf1_data;
382 static struct resource cf1_resources[] = {
384 .start = AT91_CHIPSELECT_5,
385 .end = AT91_CHIPSELECT_5 + SZ_256M - 1,
386 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
390 static struct platform_device cf1_device = {
393 .platform_data = &cf1_data,
395 .resource = cf1_resources,
396 .num_resources = ARRAY_SIZE(cf1_resources),
399 void __init at91_add_device_cf(struct at91_cf_data *data)
401 unsigned long ebi0_csa;
402 struct platform_device *pdev;
408 * assign CS4 or CS5 to SMC with Compact Flash logic support,
409 * we assume SMC timings are configured by board code,
410 * except True IDE where timings are controlled by driver
412 ebi0_csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
413 switch (data->chipselect) {
415 at91_set_A_periph(AT91_PIN_PD6, 0); /* EBI0_NCS4/CFCS0 */
416 ebi0_csa |= AT91_MATRIX_EBI0_CS4A_SMC_CF1;
421 at91_set_A_periph(AT91_PIN_PD7, 0); /* EBI0_NCS5/CFCS1 */
422 ebi0_csa |= AT91_MATRIX_EBI0_CS5A_SMC_CF2;
427 printk(KERN_ERR "AT91 CF: bad chip-select requested (%u)\n",
431 at91_sys_write(AT91_MATRIX_EBI0CSA, ebi0_csa);
433 if (gpio_is_valid(data->det_pin)) {
434 at91_set_gpio_input(data->det_pin, 1);
435 at91_set_deglitch(data->det_pin, 1);
438 if (gpio_is_valid(data->irq_pin)) {
439 at91_set_gpio_input(data->irq_pin, 1);
440 at91_set_deglitch(data->irq_pin, 1);
443 if (gpio_is_valid(data->vcc_pin))
445 at91_set_gpio_output(data->vcc_pin, 0);
447 /* enable EBI controlled pins */
448 at91_set_A_periph(AT91_PIN_PD5, 1); /* NWAIT */
449 at91_set_A_periph(AT91_PIN_PD8, 0); /* CFCE1 */
450 at91_set_A_periph(AT91_PIN_PD9, 0); /* CFCE2 */
451 at91_set_A_periph(AT91_PIN_PD14, 0); /* CFNRW */
453 pdev->name = (data->flags & AT91_CF_TRUE_IDE) ? "pata_at91" : "at91_cf";
454 platform_device_register(pdev);
457 void __init at91_add_device_cf(struct at91_cf_data *data) {}
460 /* --------------------------------------------------------------------
462 * -------------------------------------------------------------------- */
464 #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
465 static struct atmel_nand_data nand_data;
467 #define NAND_BASE AT91_CHIPSELECT_3
469 static struct resource nand_resources[] = {
472 .end = NAND_BASE + SZ_256M - 1,
473 .flags = IORESOURCE_MEM,
476 .start = AT91SAM9263_BASE_ECC0,
477 .end = AT91SAM9263_BASE_ECC0 + SZ_512 - 1,
478 .flags = IORESOURCE_MEM,
482 static struct platform_device at91sam9263_nand_device = {
483 .name = "atmel_nand",
486 .platform_data = &nand_data,
488 .resource = nand_resources,
489 .num_resources = ARRAY_SIZE(nand_resources),
492 void __init at91_add_device_nand(struct atmel_nand_data *data)
499 csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
500 at91_sys_write(AT91_MATRIX_EBI0CSA, csa | AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA);
503 if (gpio_is_valid(data->enable_pin))
504 at91_set_gpio_output(data->enable_pin, 1);
507 if (gpio_is_valid(data->rdy_pin))
508 at91_set_gpio_input(data->rdy_pin, 1);
510 /* card detect pin */
511 if (gpio_is_valid(data->det_pin))
512 at91_set_gpio_input(data->det_pin, 1);
515 platform_device_register(&at91sam9263_nand_device);
518 void __init at91_add_device_nand(struct atmel_nand_data *data) {}
522 /* --------------------------------------------------------------------
524 * -------------------------------------------------------------------- */
527 * Prefer the GPIO code since the TWI controller isn't robust
528 * (gets overruns and underruns under load) and can only issue
529 * repeated STARTs in one scenario (the driver doesn't yet handle them).
531 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
533 static struct i2c_gpio_platform_data pdata = {
534 .sda_pin = AT91_PIN_PB4,
535 .sda_is_open_drain = 1,
536 .scl_pin = AT91_PIN_PB5,
537 .scl_is_open_drain = 1,
538 .udelay = 2, /* ~100 kHz */
541 static struct platform_device at91sam9263_twi_device = {
544 .dev.platform_data = &pdata,
547 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
549 at91_set_GPIO_periph(AT91_PIN_PB4, 1); /* TWD (SDA) */
550 at91_set_multi_drive(AT91_PIN_PB4, 1);
552 at91_set_GPIO_periph(AT91_PIN_PB5, 1); /* TWCK (SCL) */
553 at91_set_multi_drive(AT91_PIN_PB5, 1);
555 i2c_register_board_info(0, devices, nr_devices);
556 platform_device_register(&at91sam9263_twi_device);
559 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
561 static struct resource twi_resources[] = {
563 .start = AT91SAM9263_BASE_TWI,
564 .end = AT91SAM9263_BASE_TWI + SZ_16K - 1,
565 .flags = IORESOURCE_MEM,
568 .start = AT91SAM9263_ID_TWI,
569 .end = AT91SAM9263_ID_TWI,
570 .flags = IORESOURCE_IRQ,
574 static struct platform_device at91sam9263_twi_device = {
577 .resource = twi_resources,
578 .num_resources = ARRAY_SIZE(twi_resources),
581 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
583 /* pins used for TWI interface */
584 at91_set_A_periph(AT91_PIN_PB4, 0); /* TWD */
585 at91_set_multi_drive(AT91_PIN_PB4, 1);
587 at91_set_A_periph(AT91_PIN_PB5, 0); /* TWCK */
588 at91_set_multi_drive(AT91_PIN_PB5, 1);
590 i2c_register_board_info(0, devices, nr_devices);
591 platform_device_register(&at91sam9263_twi_device);
594 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
598 /* --------------------------------------------------------------------
600 * -------------------------------------------------------------------- */
602 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
603 static u64 spi_dmamask = DMA_BIT_MASK(32);
605 static struct resource spi0_resources[] = {
607 .start = AT91SAM9263_BASE_SPI0,
608 .end = AT91SAM9263_BASE_SPI0 + SZ_16K - 1,
609 .flags = IORESOURCE_MEM,
612 .start = AT91SAM9263_ID_SPI0,
613 .end = AT91SAM9263_ID_SPI0,
614 .flags = IORESOURCE_IRQ,
618 static struct platform_device at91sam9263_spi0_device = {
622 .dma_mask = &spi_dmamask,
623 .coherent_dma_mask = DMA_BIT_MASK(32),
625 .resource = spi0_resources,
626 .num_resources = ARRAY_SIZE(spi0_resources),
629 static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA5, AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PB11 };
631 static struct resource spi1_resources[] = {
633 .start = AT91SAM9263_BASE_SPI1,
634 .end = AT91SAM9263_BASE_SPI1 + SZ_16K - 1,
635 .flags = IORESOURCE_MEM,
638 .start = AT91SAM9263_ID_SPI1,
639 .end = AT91SAM9263_ID_SPI1,
640 .flags = IORESOURCE_IRQ,
644 static struct platform_device at91sam9263_spi1_device = {
648 .dma_mask = &spi_dmamask,
649 .coherent_dma_mask = DMA_BIT_MASK(32),
651 .resource = spi1_resources,
652 .num_resources = ARRAY_SIZE(spi1_resources),
655 static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB15, AT91_PIN_PB16, AT91_PIN_PB17, AT91_PIN_PB18 };
657 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
660 unsigned long cs_pin;
661 short enable_spi0 = 0;
662 short enable_spi1 = 0;
664 /* Choose SPI chip-selects */
665 for (i = 0; i < nr_devices; i++) {
666 if (devices[i].controller_data)
667 cs_pin = (unsigned long) devices[i].controller_data;
668 else if (devices[i].bus_num == 0)
669 cs_pin = spi0_standard_cs[devices[i].chip_select];
671 cs_pin = spi1_standard_cs[devices[i].chip_select];
673 if (devices[i].bus_num == 0)
678 /* enable chip-select pin */
679 at91_set_gpio_output(cs_pin, 1);
681 /* pass chip-select pin to driver */
682 devices[i].controller_data = (void *) cs_pin;
685 spi_register_board_info(devices, nr_devices);
687 /* Configure SPI bus(es) */
689 at91_set_B_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
690 at91_set_B_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
691 at91_set_B_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
693 platform_device_register(&at91sam9263_spi0_device);
696 at91_set_A_periph(AT91_PIN_PB12, 0); /* SPI1_MISO */
697 at91_set_A_periph(AT91_PIN_PB13, 0); /* SPI1_MOSI */
698 at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_SPCK */
700 platform_device_register(&at91sam9263_spi1_device);
704 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
708 /* --------------------------------------------------------------------
710 * -------------------------------------------------------------------- */
712 #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
713 static u64 ac97_dmamask = DMA_BIT_MASK(32);
714 static struct ac97c_platform_data ac97_data;
716 static struct resource ac97_resources[] = {
718 .start = AT91SAM9263_BASE_AC97C,
719 .end = AT91SAM9263_BASE_AC97C + SZ_16K - 1,
720 .flags = IORESOURCE_MEM,
723 .start = AT91SAM9263_ID_AC97C,
724 .end = AT91SAM9263_ID_AC97C,
725 .flags = IORESOURCE_IRQ,
729 static struct platform_device at91sam9263_ac97_device = {
730 .name = "atmel_ac97c",
733 .dma_mask = &ac97_dmamask,
734 .coherent_dma_mask = DMA_BIT_MASK(32),
735 .platform_data = &ac97_data,
737 .resource = ac97_resources,
738 .num_resources = ARRAY_SIZE(ac97_resources),
741 void __init at91_add_device_ac97(struct ac97c_platform_data *data)
746 at91_set_A_periph(AT91_PIN_PB0, 0); /* AC97FS */
747 at91_set_A_periph(AT91_PIN_PB1, 0); /* AC97CK */
748 at91_set_A_periph(AT91_PIN_PB2, 0); /* AC97TX */
749 at91_set_A_periph(AT91_PIN_PB3, 0); /* AC97RX */
752 if (gpio_is_valid(data->reset_pin))
753 at91_set_gpio_output(data->reset_pin, 0);
756 platform_device_register(&at91sam9263_ac97_device);
759 void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
762 /* --------------------------------------------------------------------
764 * -------------------------------------------------------------------- */
766 #if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE)
767 static struct resource can_resources[] = {
769 .start = AT91SAM9263_BASE_CAN,
770 .end = AT91SAM9263_BASE_CAN + SZ_16K - 1,
771 .flags = IORESOURCE_MEM,
774 .start = AT91SAM9263_ID_CAN,
775 .end = AT91SAM9263_ID_CAN,
776 .flags = IORESOURCE_IRQ,
780 static struct platform_device at91sam9263_can_device = {
783 .resource = can_resources,
784 .num_resources = ARRAY_SIZE(can_resources),
787 void __init at91_add_device_can(struct at91_can_data *data)
789 at91_set_A_periph(AT91_PIN_PA13, 0); /* CANTX */
790 at91_set_A_periph(AT91_PIN_PA14, 0); /* CANRX */
791 at91sam9263_can_device.dev.platform_data = data;
793 platform_device_register(&at91sam9263_can_device);
796 void __init at91_add_device_can(struct at91_can_data *data) {}
799 /* --------------------------------------------------------------------
801 * -------------------------------------------------------------------- */
803 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
804 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
805 static struct atmel_lcdfb_info lcdc_data;
807 static struct resource lcdc_resources[] = {
809 .start = AT91SAM9263_LCDC_BASE,
810 .end = AT91SAM9263_LCDC_BASE + SZ_4K - 1,
811 .flags = IORESOURCE_MEM,
814 .start = AT91SAM9263_ID_LCDC,
815 .end = AT91SAM9263_ID_LCDC,
816 .flags = IORESOURCE_IRQ,
820 static struct platform_device at91_lcdc_device = {
821 .name = "atmel_lcdfb",
824 .dma_mask = &lcdc_dmamask,
825 .coherent_dma_mask = DMA_BIT_MASK(32),
826 .platform_data = &lcdc_data,
828 .resource = lcdc_resources,
829 .num_resources = ARRAY_SIZE(lcdc_resources),
832 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
837 at91_set_A_periph(AT91_PIN_PC1, 0); /* LCDHSYNC */
838 at91_set_A_periph(AT91_PIN_PC2, 0); /* LCDDOTCK */
839 at91_set_A_periph(AT91_PIN_PC3, 0); /* LCDDEN */
840 at91_set_B_periph(AT91_PIN_PB9, 0); /* LCDCC */
841 at91_set_A_periph(AT91_PIN_PC6, 0); /* LCDD2 */
842 at91_set_A_periph(AT91_PIN_PC7, 0); /* LCDD3 */
843 at91_set_A_periph(AT91_PIN_PC8, 0); /* LCDD4 */
844 at91_set_A_periph(AT91_PIN_PC9, 0); /* LCDD5 */
845 at91_set_A_periph(AT91_PIN_PC10, 0); /* LCDD6 */
846 at91_set_A_periph(AT91_PIN_PC11, 0); /* LCDD7 */
847 at91_set_A_periph(AT91_PIN_PC14, 0); /* LCDD10 */
848 at91_set_A_periph(AT91_PIN_PC15, 0); /* LCDD11 */
849 at91_set_A_periph(AT91_PIN_PC16, 0); /* LCDD12 */
850 at91_set_B_periph(AT91_PIN_PC12, 0); /* LCDD13 */
851 at91_set_A_periph(AT91_PIN_PC18, 0); /* LCDD14 */
852 at91_set_A_periph(AT91_PIN_PC19, 0); /* LCDD15 */
853 at91_set_A_periph(AT91_PIN_PC22, 0); /* LCDD18 */
854 at91_set_A_periph(AT91_PIN_PC23, 0); /* LCDD19 */
855 at91_set_A_periph(AT91_PIN_PC24, 0); /* LCDD20 */
856 at91_set_B_periph(AT91_PIN_PC17, 0); /* LCDD21 */
857 at91_set_A_periph(AT91_PIN_PC26, 0); /* LCDD22 */
858 at91_set_A_periph(AT91_PIN_PC27, 0); /* LCDD23 */
861 platform_device_register(&at91_lcdc_device);
864 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
868 /* --------------------------------------------------------------------
869 * Image Sensor Interface
870 * -------------------------------------------------------------------- */
872 #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
874 struct resource isi_resources[] = {
876 .start = AT91SAM9263_BASE_ISI,
877 .end = AT91SAM9263_BASE_ISI + SZ_16K - 1,
878 .flags = IORESOURCE_MEM,
881 .start = AT91SAM9263_ID_ISI,
882 .end = AT91SAM9263_ID_ISI,
883 .flags = IORESOURCE_IRQ,
887 static struct platform_device at91sam9263_isi_device = {
890 .resource = isi_resources,
891 .num_resources = ARRAY_SIZE(isi_resources),
894 void __init at91_add_device_isi(void)
896 at91_set_A_periph(AT91_PIN_PE0, 0); /* ISI_D0 */
897 at91_set_A_periph(AT91_PIN_PE1, 0); /* ISI_D1 */
898 at91_set_A_periph(AT91_PIN_PE2, 0); /* ISI_D2 */
899 at91_set_A_periph(AT91_PIN_PE3, 0); /* ISI_D3 */
900 at91_set_A_periph(AT91_PIN_PE4, 0); /* ISI_D4 */
901 at91_set_A_periph(AT91_PIN_PE5, 0); /* ISI_D5 */
902 at91_set_A_periph(AT91_PIN_PE6, 0); /* ISI_D6 */
903 at91_set_A_periph(AT91_PIN_PE7, 0); /* ISI_D7 */
904 at91_set_A_periph(AT91_PIN_PE8, 0); /* ISI_PCK */
905 at91_set_A_periph(AT91_PIN_PE9, 0); /* ISI_HSYNC */
906 at91_set_A_periph(AT91_PIN_PE10, 0); /* ISI_VSYNC */
907 at91_set_B_periph(AT91_PIN_PE11, 0); /* ISI_MCK (PCK3) */
908 at91_set_B_periph(AT91_PIN_PE12, 0); /* ISI_PD8 */
909 at91_set_B_periph(AT91_PIN_PE13, 0); /* ISI_PD9 */
910 at91_set_B_periph(AT91_PIN_PE14, 0); /* ISI_PD10 */
911 at91_set_B_periph(AT91_PIN_PE15, 0); /* ISI_PD11 */
914 void __init at91_add_device_isi(void) {}
918 /* --------------------------------------------------------------------
919 * Timer/Counter block
920 * -------------------------------------------------------------------- */
922 #ifdef CONFIG_ATMEL_TCLIB
924 static struct resource tcb_resources[] = {
926 .start = AT91SAM9263_BASE_TCB0,
927 .end = AT91SAM9263_BASE_TCB0 + SZ_16K - 1,
928 .flags = IORESOURCE_MEM,
931 .start = AT91SAM9263_ID_TCB,
932 .end = AT91SAM9263_ID_TCB,
933 .flags = IORESOURCE_IRQ,
937 static struct platform_device at91sam9263_tcb_device = {
940 .resource = tcb_resources,
941 .num_resources = ARRAY_SIZE(tcb_resources),
944 static void __init at91_add_device_tc(void)
946 platform_device_register(&at91sam9263_tcb_device);
949 static void __init at91_add_device_tc(void) { }
953 /* --------------------------------------------------------------------
955 * -------------------------------------------------------------------- */
957 static struct resource rtt0_resources[] = {
959 .start = AT91SAM9263_BASE_RTT0,
960 .end = AT91SAM9263_BASE_RTT0 + SZ_16 - 1,
961 .flags = IORESOURCE_MEM,
965 static struct platform_device at91sam9263_rtt0_device = {
968 .resource = rtt0_resources,
969 .num_resources = ARRAY_SIZE(rtt0_resources),
972 static struct resource rtt1_resources[] = {
974 .start = AT91SAM9263_BASE_RTT1,
975 .end = AT91SAM9263_BASE_RTT1 + SZ_16 - 1,
976 .flags = IORESOURCE_MEM,
980 static struct platform_device at91sam9263_rtt1_device = {
983 .resource = rtt1_resources,
984 .num_resources = ARRAY_SIZE(rtt1_resources),
987 static void __init at91_add_device_rtt(void)
989 platform_device_register(&at91sam9263_rtt0_device);
990 platform_device_register(&at91sam9263_rtt1_device);
994 /* --------------------------------------------------------------------
996 * -------------------------------------------------------------------- */
998 #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
999 static struct resource wdt_resources[] = {
1001 .start = AT91SAM9263_BASE_WDT,
1002 .end = AT91SAM9263_BASE_WDT + SZ_16 - 1,
1003 .flags = IORESOURCE_MEM,
1007 static struct platform_device at91sam9263_wdt_device = {
1010 .resource = wdt_resources,
1011 .num_resources = ARRAY_SIZE(wdt_resources),
1014 static void __init at91_add_device_watchdog(void)
1016 platform_device_register(&at91sam9263_wdt_device);
1019 static void __init at91_add_device_watchdog(void) {}
1023 /* --------------------------------------------------------------------
1025 * --------------------------------------------------------------------*/
1027 #if defined(CONFIG_ATMEL_PWM)
1028 static u32 pwm_mask;
1030 static struct resource pwm_resources[] = {
1032 .start = AT91SAM9263_BASE_PWMC,
1033 .end = AT91SAM9263_BASE_PWMC + SZ_16K - 1,
1034 .flags = IORESOURCE_MEM,
1037 .start = AT91SAM9263_ID_PWMC,
1038 .end = AT91SAM9263_ID_PWMC,
1039 .flags = IORESOURCE_IRQ,
1043 static struct platform_device at91sam9263_pwm0_device = {
1044 .name = "atmel_pwm",
1047 .platform_data = &pwm_mask,
1049 .resource = pwm_resources,
1050 .num_resources = ARRAY_SIZE(pwm_resources),
1053 void __init at91_add_device_pwm(u32 mask)
1055 if (mask & (1 << AT91_PWM0))
1056 at91_set_B_periph(AT91_PIN_PB7, 1); /* enable PWM0 */
1058 if (mask & (1 << AT91_PWM1))
1059 at91_set_B_periph(AT91_PIN_PB8, 1); /* enable PWM1 */
1061 if (mask & (1 << AT91_PWM2))
1062 at91_set_B_periph(AT91_PIN_PC29, 1); /* enable PWM2 */
1064 if (mask & (1 << AT91_PWM3))
1065 at91_set_B_periph(AT91_PIN_PB29, 1); /* enable PWM3 */
1069 platform_device_register(&at91sam9263_pwm0_device);
1072 void __init at91_add_device_pwm(u32 mask) {}
1076 /* --------------------------------------------------------------------
1077 * SSC -- Synchronous Serial Controller
1078 * -------------------------------------------------------------------- */
1080 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
1081 static u64 ssc0_dmamask = DMA_BIT_MASK(32);
1083 static struct resource ssc0_resources[] = {
1085 .start = AT91SAM9263_BASE_SSC0,
1086 .end = AT91SAM9263_BASE_SSC0 + SZ_16K - 1,
1087 .flags = IORESOURCE_MEM,
1090 .start = AT91SAM9263_ID_SSC0,
1091 .end = AT91SAM9263_ID_SSC0,
1092 .flags = IORESOURCE_IRQ,
1096 static struct platform_device at91sam9263_ssc0_device = {
1100 .dma_mask = &ssc0_dmamask,
1101 .coherent_dma_mask = DMA_BIT_MASK(32),
1103 .resource = ssc0_resources,
1104 .num_resources = ARRAY_SIZE(ssc0_resources),
1107 static inline void configure_ssc0_pins(unsigned pins)
1109 if (pins & ATMEL_SSC_TF)
1110 at91_set_B_periph(AT91_PIN_PB0, 1);
1111 if (pins & ATMEL_SSC_TK)
1112 at91_set_B_periph(AT91_PIN_PB1, 1);
1113 if (pins & ATMEL_SSC_TD)
1114 at91_set_B_periph(AT91_PIN_PB2, 1);
1115 if (pins & ATMEL_SSC_RD)
1116 at91_set_B_periph(AT91_PIN_PB3, 1);
1117 if (pins & ATMEL_SSC_RK)
1118 at91_set_B_periph(AT91_PIN_PB4, 1);
1119 if (pins & ATMEL_SSC_RF)
1120 at91_set_B_periph(AT91_PIN_PB5, 1);
1123 static u64 ssc1_dmamask = DMA_BIT_MASK(32);
1125 static struct resource ssc1_resources[] = {
1127 .start = AT91SAM9263_BASE_SSC1,
1128 .end = AT91SAM9263_BASE_SSC1 + SZ_16K - 1,
1129 .flags = IORESOURCE_MEM,
1132 .start = AT91SAM9263_ID_SSC1,
1133 .end = AT91SAM9263_ID_SSC1,
1134 .flags = IORESOURCE_IRQ,
1138 static struct platform_device at91sam9263_ssc1_device = {
1142 .dma_mask = &ssc1_dmamask,
1143 .coherent_dma_mask = DMA_BIT_MASK(32),
1145 .resource = ssc1_resources,
1146 .num_resources = ARRAY_SIZE(ssc1_resources),
1149 static inline void configure_ssc1_pins(unsigned pins)
1151 if (pins & ATMEL_SSC_TF)
1152 at91_set_A_periph(AT91_PIN_PB6, 1);
1153 if (pins & ATMEL_SSC_TK)
1154 at91_set_A_periph(AT91_PIN_PB7, 1);
1155 if (pins & ATMEL_SSC_TD)
1156 at91_set_A_periph(AT91_PIN_PB8, 1);
1157 if (pins & ATMEL_SSC_RD)
1158 at91_set_A_periph(AT91_PIN_PB9, 1);
1159 if (pins & ATMEL_SSC_RK)
1160 at91_set_A_periph(AT91_PIN_PB10, 1);
1161 if (pins & ATMEL_SSC_RF)
1162 at91_set_A_periph(AT91_PIN_PB11, 1);
1166 * SSC controllers are accessed through library code, instead of any
1167 * kind of all-singing/all-dancing driver. For example one could be
1168 * used by a particular I2S audio codec's driver, while another one
1169 * on the same system might be used by a custom data capture driver.
1171 void __init at91_add_device_ssc(unsigned id, unsigned pins)
1173 struct platform_device *pdev;
1176 * NOTE: caller is responsible for passing information matching
1177 * "pins" to whatever will be using each particular controller.
1180 case AT91SAM9263_ID_SSC0:
1181 pdev = &at91sam9263_ssc0_device;
1182 configure_ssc0_pins(pins);
1184 case AT91SAM9263_ID_SSC1:
1185 pdev = &at91sam9263_ssc1_device;
1186 configure_ssc1_pins(pins);
1192 platform_device_register(pdev);
1196 void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1200 /* --------------------------------------------------------------------
1202 * -------------------------------------------------------------------- */
1204 #if defined(CONFIG_SERIAL_ATMEL)
1206 static struct resource dbgu_resources[] = {
1208 .start = AT91SAM9263_BASE_DBGU,
1209 .end = AT91SAM9263_BASE_DBGU + SZ_512 - 1,
1210 .flags = IORESOURCE_MEM,
1213 .start = AT91_ID_SYS,
1215 .flags = IORESOURCE_IRQ,
1219 static struct atmel_uart_data dbgu_data = {
1221 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
1224 static u64 dbgu_dmamask = DMA_BIT_MASK(32);
1226 static struct platform_device at91sam9263_dbgu_device = {
1227 .name = "atmel_usart",
1230 .dma_mask = &dbgu_dmamask,
1231 .coherent_dma_mask = DMA_BIT_MASK(32),
1232 .platform_data = &dbgu_data,
1234 .resource = dbgu_resources,
1235 .num_resources = ARRAY_SIZE(dbgu_resources),
1238 static inline void configure_dbgu_pins(void)
1240 at91_set_A_periph(AT91_PIN_PC30, 0); /* DRXD */
1241 at91_set_A_periph(AT91_PIN_PC31, 1); /* DTXD */
1244 static struct resource uart0_resources[] = {
1246 .start = AT91SAM9263_BASE_US0,
1247 .end = AT91SAM9263_BASE_US0 + SZ_16K - 1,
1248 .flags = IORESOURCE_MEM,
1251 .start = AT91SAM9263_ID_US0,
1252 .end = AT91SAM9263_ID_US0,
1253 .flags = IORESOURCE_IRQ,
1257 static struct atmel_uart_data uart0_data = {
1262 static u64 uart0_dmamask = DMA_BIT_MASK(32);
1264 static struct platform_device at91sam9263_uart0_device = {
1265 .name = "atmel_usart",
1268 .dma_mask = &uart0_dmamask,
1269 .coherent_dma_mask = DMA_BIT_MASK(32),
1270 .platform_data = &uart0_data,
1272 .resource = uart0_resources,
1273 .num_resources = ARRAY_SIZE(uart0_resources),
1276 static inline void configure_usart0_pins(unsigned pins)
1278 at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */
1279 at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */
1281 if (pins & ATMEL_UART_RTS)
1282 at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */
1283 if (pins & ATMEL_UART_CTS)
1284 at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */
1287 static struct resource uart1_resources[] = {
1289 .start = AT91SAM9263_BASE_US1,
1290 .end = AT91SAM9263_BASE_US1 + SZ_16K - 1,
1291 .flags = IORESOURCE_MEM,
1294 .start = AT91SAM9263_ID_US1,
1295 .end = AT91SAM9263_ID_US1,
1296 .flags = IORESOURCE_IRQ,
1300 static struct atmel_uart_data uart1_data = {
1305 static u64 uart1_dmamask = DMA_BIT_MASK(32);
1307 static struct platform_device at91sam9263_uart1_device = {
1308 .name = "atmel_usart",
1311 .dma_mask = &uart1_dmamask,
1312 .coherent_dma_mask = DMA_BIT_MASK(32),
1313 .platform_data = &uart1_data,
1315 .resource = uart1_resources,
1316 .num_resources = ARRAY_SIZE(uart1_resources),
1319 static inline void configure_usart1_pins(unsigned pins)
1321 at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */
1322 at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */
1324 if (pins & ATMEL_UART_RTS)
1325 at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */
1326 if (pins & ATMEL_UART_CTS)
1327 at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */
1330 static struct resource uart2_resources[] = {
1332 .start = AT91SAM9263_BASE_US2,
1333 .end = AT91SAM9263_BASE_US2 + SZ_16K - 1,
1334 .flags = IORESOURCE_MEM,
1337 .start = AT91SAM9263_ID_US2,
1338 .end = AT91SAM9263_ID_US2,
1339 .flags = IORESOURCE_IRQ,
1343 static struct atmel_uart_data uart2_data = {
1348 static u64 uart2_dmamask = DMA_BIT_MASK(32);
1350 static struct platform_device at91sam9263_uart2_device = {
1351 .name = "atmel_usart",
1354 .dma_mask = &uart2_dmamask,
1355 .coherent_dma_mask = DMA_BIT_MASK(32),
1356 .platform_data = &uart2_data,
1358 .resource = uart2_resources,
1359 .num_resources = ARRAY_SIZE(uart2_resources),
1362 static inline void configure_usart2_pins(unsigned pins)
1364 at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */
1365 at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */
1367 if (pins & ATMEL_UART_RTS)
1368 at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */
1369 if (pins & ATMEL_UART_CTS)
1370 at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */
1373 static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1374 struct platform_device *atmel_default_console_device; /* the serial console device */
1376 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1378 struct platform_device *pdev;
1379 struct atmel_uart_data *pdata;
1383 pdev = &at91sam9263_dbgu_device;
1384 configure_dbgu_pins();
1386 case AT91SAM9263_ID_US0:
1387 pdev = &at91sam9263_uart0_device;
1388 configure_usart0_pins(pins);
1390 case AT91SAM9263_ID_US1:
1391 pdev = &at91sam9263_uart1_device;
1392 configure_usart1_pins(pins);
1394 case AT91SAM9263_ID_US2:
1395 pdev = &at91sam9263_uart2_device;
1396 configure_usart2_pins(pins);
1401 pdata = pdev->dev.platform_data;
1402 pdata->num = portnr; /* update to mapped ID */
1404 if (portnr < ATMEL_MAX_UART)
1405 at91_uarts[portnr] = pdev;
1408 void __init at91_set_serial_console(unsigned portnr)
1410 if (portnr < ATMEL_MAX_UART) {
1411 atmel_default_console_device = at91_uarts[portnr];
1412 at91sam9263_set_console_clock(at91_uarts[portnr]->id);
1416 void __init at91_add_device_serial(void)
1420 for (i = 0; i < ATMEL_MAX_UART; i++) {
1422 platform_device_register(at91_uarts[i]);
1425 if (!atmel_default_console_device)
1426 printk(KERN_INFO "AT91: No default serial console defined.\n");
1429 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1430 void __init at91_set_serial_console(unsigned portnr) {}
1431 void __init at91_add_device_serial(void) {}
1435 /* -------------------------------------------------------------------- */
1437 * These devices are always present and don't need any board-specific
1440 static int __init at91_add_standard_devices(void)
1442 at91_add_device_rtt();
1443 at91_add_device_watchdog();
1444 at91_add_device_tc();
1448 arch_initcall(at91_add_standard_devices);