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/at91_matrix.h>
27 #include <mach/at91sam9_smc.h>
32 /* --------------------------------------------------------------------
34 * -------------------------------------------------------------------- */
36 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
37 static u64 ohci_dmamask
= DMA_BIT_MASK(32);
38 static struct at91_usbh_data usbh_data
;
40 static struct resource usbh_resources
[] = {
42 .start
= AT91SAM9263_UHP_BASE
,
43 .end
= AT91SAM9263_UHP_BASE
+ SZ_1M
- 1,
44 .flags
= IORESOURCE_MEM
,
47 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_UHP
,
48 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_UHP
,
49 .flags
= IORESOURCE_IRQ
,
53 static struct platform_device at91_usbh_device
= {
57 .dma_mask
= &ohci_dmamask
,
58 .coherent_dma_mask
= DMA_BIT_MASK(32),
59 .platform_data
= &usbh_data
,
61 .resource
= usbh_resources
,
62 .num_resources
= ARRAY_SIZE(usbh_resources
),
65 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
)
72 /* Enable VBus control for UHP ports */
73 for (i
= 0; i
< data
->ports
; i
++) {
74 if (gpio_is_valid(data
->vbus_pin
[i
]))
75 at91_set_gpio_output(data
->vbus_pin
[i
],
76 data
->vbus_pin_active_low
[i
]);
79 /* Enable overcurrent notification */
80 for (i
= 0; i
< data
->ports
; i
++) {
81 if (data
->overcurrent_pin
[i
])
82 at91_set_gpio_input(data
->overcurrent_pin
[i
], 1);
86 platform_device_register(&at91_usbh_device
);
89 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
) {}
93 /* --------------------------------------------------------------------
95 * -------------------------------------------------------------------- */
97 #if defined(CONFIG_USB_AT91) || defined(CONFIG_USB_AT91_MODULE)
98 static struct at91_udc_data udc_data
;
100 static struct resource udc_resources
[] = {
102 .start
= AT91SAM9263_BASE_UDP
,
103 .end
= AT91SAM9263_BASE_UDP
+ SZ_16K
- 1,
104 .flags
= IORESOURCE_MEM
,
107 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_UDP
,
108 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_UDP
,
109 .flags
= IORESOURCE_IRQ
,
113 static struct platform_device at91_udc_device
= {
117 .platform_data
= &udc_data
,
119 .resource
= udc_resources
,
120 .num_resources
= ARRAY_SIZE(udc_resources
),
123 void __init
at91_add_device_udc(struct at91_udc_data
*data
)
128 if (gpio_is_valid(data
->vbus_pin
)) {
129 at91_set_gpio_input(data
->vbus_pin
, 0);
130 at91_set_deglitch(data
->vbus_pin
, 1);
133 /* Pullup pin is handled internally by USB device peripheral */
136 platform_device_register(&at91_udc_device
);
139 void __init
at91_add_device_udc(struct at91_udc_data
*data
) {}
143 /* --------------------------------------------------------------------
145 * -------------------------------------------------------------------- */
147 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
148 static u64 eth_dmamask
= DMA_BIT_MASK(32);
149 static struct macb_platform_data eth_data
;
151 static struct resource eth_resources
[] = {
153 .start
= AT91SAM9263_BASE_EMAC
,
154 .end
= AT91SAM9263_BASE_EMAC
+ SZ_16K
- 1,
155 .flags
= IORESOURCE_MEM
,
158 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_EMAC
,
159 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_EMAC
,
160 .flags
= IORESOURCE_IRQ
,
164 static struct platform_device at91sam9263_eth_device
= {
168 .dma_mask
= ð_dmamask
,
169 .coherent_dma_mask
= DMA_BIT_MASK(32),
170 .platform_data
= ð_data
,
172 .resource
= eth_resources
,
173 .num_resources
= ARRAY_SIZE(eth_resources
),
176 void __init
at91_add_device_eth(struct macb_platform_data
*data
)
181 if (gpio_is_valid(data
->phy_irq_pin
)) {
182 at91_set_gpio_input(data
->phy_irq_pin
, 0);
183 at91_set_deglitch(data
->phy_irq_pin
, 1);
186 /* Pins used for MII and RMII */
187 at91_set_A_periph(AT91_PIN_PE21
, 0); /* ETXCK_EREFCK */
188 at91_set_B_periph(AT91_PIN_PC25
, 0); /* ERXDV */
189 at91_set_A_periph(AT91_PIN_PE25
, 0); /* ERX0 */
190 at91_set_A_periph(AT91_PIN_PE26
, 0); /* ERX1 */
191 at91_set_A_periph(AT91_PIN_PE27
, 0); /* ERXER */
192 at91_set_A_periph(AT91_PIN_PE28
, 0); /* ETXEN */
193 at91_set_A_periph(AT91_PIN_PE23
, 0); /* ETX0 */
194 at91_set_A_periph(AT91_PIN_PE24
, 0); /* ETX1 */
195 at91_set_A_periph(AT91_PIN_PE30
, 0); /* EMDIO */
196 at91_set_A_periph(AT91_PIN_PE29
, 0); /* EMDC */
198 if (!data
->is_rmii
) {
199 at91_set_A_periph(AT91_PIN_PE22
, 0); /* ECRS */
200 at91_set_B_periph(AT91_PIN_PC26
, 0); /* ECOL */
201 at91_set_B_periph(AT91_PIN_PC22
, 0); /* ERX2 */
202 at91_set_B_periph(AT91_PIN_PC23
, 0); /* ERX3 */
203 at91_set_B_periph(AT91_PIN_PC27
, 0); /* ERXCK */
204 at91_set_B_periph(AT91_PIN_PC20
, 0); /* ETX2 */
205 at91_set_B_periph(AT91_PIN_PC21
, 0); /* ETX3 */
206 at91_set_B_periph(AT91_PIN_PC24
, 0); /* ETXER */
210 platform_device_register(&at91sam9263_eth_device
);
213 void __init
at91_add_device_eth(struct macb_platform_data
*data
) {}
217 /* --------------------------------------------------------------------
219 * -------------------------------------------------------------------- */
221 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
222 static u64 mmc_dmamask
= DMA_BIT_MASK(32);
223 static struct at91_mmc_data mmc0_data
, mmc1_data
;
225 static struct resource mmc0_resources
[] = {
227 .start
= AT91SAM9263_BASE_MCI0
,
228 .end
= AT91SAM9263_BASE_MCI0
+ SZ_16K
- 1,
229 .flags
= IORESOURCE_MEM
,
232 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_MCI0
,
233 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_MCI0
,
234 .flags
= IORESOURCE_IRQ
,
238 static struct platform_device at91sam9263_mmc0_device
= {
242 .dma_mask
= &mmc_dmamask
,
243 .coherent_dma_mask
= DMA_BIT_MASK(32),
244 .platform_data
= &mmc0_data
,
246 .resource
= mmc0_resources
,
247 .num_resources
= ARRAY_SIZE(mmc0_resources
),
250 static struct resource mmc1_resources
[] = {
252 .start
= AT91SAM9263_BASE_MCI1
,
253 .end
= AT91SAM9263_BASE_MCI1
+ SZ_16K
- 1,
254 .flags
= IORESOURCE_MEM
,
257 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_MCI1
,
258 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_MCI1
,
259 .flags
= IORESOURCE_IRQ
,
263 static struct platform_device at91sam9263_mmc1_device
= {
267 .dma_mask
= &mmc_dmamask
,
268 .coherent_dma_mask
= DMA_BIT_MASK(32),
269 .platform_data
= &mmc1_data
,
271 .resource
= mmc1_resources
,
272 .num_resources
= ARRAY_SIZE(mmc1_resources
),
275 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
)
281 if (gpio_is_valid(data
->det_pin
)) {
282 at91_set_gpio_input(data
->det_pin
, 1);
283 at91_set_deglitch(data
->det_pin
, 1);
285 if (gpio_is_valid(data
->wp_pin
))
286 at91_set_gpio_input(data
->wp_pin
, 1);
287 if (gpio_is_valid(data
->vcc_pin
))
288 at91_set_gpio_output(data
->vcc_pin
, 0);
290 if (mmc_id
== 0) { /* MCI0 */
292 at91_set_A_periph(AT91_PIN_PA12
, 0);
296 at91_set_A_periph(AT91_PIN_PA16
, 1);
298 /* DAT0, maybe DAT1..DAT3 */
299 at91_set_A_periph(AT91_PIN_PA17
, 1);
301 at91_set_A_periph(AT91_PIN_PA18
, 1);
302 at91_set_A_periph(AT91_PIN_PA19
, 1);
303 at91_set_A_periph(AT91_PIN_PA20
, 1);
307 at91_set_A_periph(AT91_PIN_PA1
, 1);
309 /* DAT0, maybe DAT1..DAT3 */
310 at91_set_A_periph(AT91_PIN_PA0
, 1);
312 at91_set_A_periph(AT91_PIN_PA3
, 1);
313 at91_set_A_periph(AT91_PIN_PA4
, 1);
314 at91_set_A_periph(AT91_PIN_PA5
, 1);
319 platform_device_register(&at91sam9263_mmc0_device
);
322 at91_set_A_periph(AT91_PIN_PA6
, 0);
326 at91_set_A_periph(AT91_PIN_PA21
, 1);
328 /* DAT0, maybe DAT1..DAT3 */
329 at91_set_A_periph(AT91_PIN_PA22
, 1);
331 at91_set_A_periph(AT91_PIN_PA23
, 1);
332 at91_set_A_periph(AT91_PIN_PA24
, 1);
333 at91_set_A_periph(AT91_PIN_PA25
, 1);
337 at91_set_A_periph(AT91_PIN_PA7
, 1);
339 /* DAT0, maybe DAT1..DAT3 */
340 at91_set_A_periph(AT91_PIN_PA8
, 1);
342 at91_set_A_periph(AT91_PIN_PA9
, 1);
343 at91_set_A_periph(AT91_PIN_PA10
, 1);
344 at91_set_A_periph(AT91_PIN_PA11
, 1);
349 platform_device_register(&at91sam9263_mmc1_device
);
353 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
) {}
356 /* --------------------------------------------------------------------
357 * Compact Flash (PCMCIA or IDE)
358 * -------------------------------------------------------------------- */
360 #if defined(CONFIG_PATA_AT91) || defined(CONFIG_PATA_AT91_MODULE) || \
361 defined(CONFIG_AT91_CF) || defined(CONFIG_AT91_CF_MODULE)
363 static struct at91_cf_data cf0_data
;
365 static struct resource cf0_resources
[] = {
367 .start
= AT91_CHIPSELECT_4
,
368 .end
= AT91_CHIPSELECT_4
+ SZ_256M
- 1,
369 .flags
= IORESOURCE_MEM
| IORESOURCE_MEM_8AND16BIT
,
373 static struct platform_device cf0_device
= {
376 .platform_data
= &cf0_data
,
378 .resource
= cf0_resources
,
379 .num_resources
= ARRAY_SIZE(cf0_resources
),
382 static struct at91_cf_data cf1_data
;
384 static struct resource cf1_resources
[] = {
386 .start
= AT91_CHIPSELECT_5
,
387 .end
= AT91_CHIPSELECT_5
+ SZ_256M
- 1,
388 .flags
= IORESOURCE_MEM
| IORESOURCE_MEM_8AND16BIT
,
392 static struct platform_device cf1_device
= {
395 .platform_data
= &cf1_data
,
397 .resource
= cf1_resources
,
398 .num_resources
= ARRAY_SIZE(cf1_resources
),
401 void __init
at91_add_device_cf(struct at91_cf_data
*data
)
403 unsigned long ebi0_csa
;
404 struct platform_device
*pdev
;
410 * assign CS4 or CS5 to SMC with Compact Flash logic support,
411 * we assume SMC timings are configured by board code,
412 * except True IDE where timings are controlled by driver
414 ebi0_csa
= at91_matrix_read(AT91_MATRIX_EBI0CSA
);
415 switch (data
->chipselect
) {
417 at91_set_A_periph(AT91_PIN_PD6
, 0); /* EBI0_NCS4/CFCS0 */
418 ebi0_csa
|= AT91_MATRIX_EBI0_CS4A_SMC_CF1
;
423 at91_set_A_periph(AT91_PIN_PD7
, 0); /* EBI0_NCS5/CFCS1 */
424 ebi0_csa
|= AT91_MATRIX_EBI0_CS5A_SMC_CF2
;
429 printk(KERN_ERR
"AT91 CF: bad chip-select requested (%u)\n",
433 at91_matrix_write(AT91_MATRIX_EBI0CSA
, ebi0_csa
);
435 if (gpio_is_valid(data
->det_pin
)) {
436 at91_set_gpio_input(data
->det_pin
, 1);
437 at91_set_deglitch(data
->det_pin
, 1);
440 if (gpio_is_valid(data
->irq_pin
)) {
441 at91_set_gpio_input(data
->irq_pin
, 1);
442 at91_set_deglitch(data
->irq_pin
, 1);
445 if (gpio_is_valid(data
->vcc_pin
))
447 at91_set_gpio_output(data
->vcc_pin
, 0);
449 /* enable EBI controlled pins */
450 at91_set_A_periph(AT91_PIN_PD5
, 1); /* NWAIT */
451 at91_set_A_periph(AT91_PIN_PD8
, 0); /* CFCE1 */
452 at91_set_A_periph(AT91_PIN_PD9
, 0); /* CFCE2 */
453 at91_set_A_periph(AT91_PIN_PD14
, 0); /* CFNRW */
455 pdev
->name
= (data
->flags
& AT91_CF_TRUE_IDE
) ? "pata_at91" : "at91_cf";
456 platform_device_register(pdev
);
459 void __init
at91_add_device_cf(struct at91_cf_data
*data
) {}
462 /* --------------------------------------------------------------------
464 * -------------------------------------------------------------------- */
466 #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
467 static struct atmel_nand_data nand_data
;
469 #define NAND_BASE AT91_CHIPSELECT_3
471 static struct resource nand_resources
[] = {
474 .end
= NAND_BASE
+ SZ_256M
- 1,
475 .flags
= IORESOURCE_MEM
,
478 .start
= AT91SAM9263_BASE_ECC0
,
479 .end
= AT91SAM9263_BASE_ECC0
+ SZ_512
- 1,
480 .flags
= IORESOURCE_MEM
,
484 static struct platform_device at91sam9263_nand_device
= {
485 .name
= "atmel_nand",
488 .platform_data
= &nand_data
,
490 .resource
= nand_resources
,
491 .num_resources
= ARRAY_SIZE(nand_resources
),
494 void __init
at91_add_device_nand(struct atmel_nand_data
*data
)
501 csa
= at91_matrix_read(AT91_MATRIX_EBI0CSA
);
502 at91_matrix_write(AT91_MATRIX_EBI0CSA
, csa
| AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA
);
505 if (gpio_is_valid(data
->enable_pin
))
506 at91_set_gpio_output(data
->enable_pin
, 1);
509 if (gpio_is_valid(data
->rdy_pin
))
510 at91_set_gpio_input(data
->rdy_pin
, 1);
512 /* card detect pin */
513 if (gpio_is_valid(data
->det_pin
))
514 at91_set_gpio_input(data
->det_pin
, 1);
517 platform_device_register(&at91sam9263_nand_device
);
520 void __init
at91_add_device_nand(struct atmel_nand_data
*data
) {}
524 /* --------------------------------------------------------------------
526 * -------------------------------------------------------------------- */
529 * Prefer the GPIO code since the TWI controller isn't robust
530 * (gets overruns and underruns under load) and can only issue
531 * repeated STARTs in one scenario (the driver doesn't yet handle them).
533 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
535 static struct i2c_gpio_platform_data pdata
= {
536 .sda_pin
= AT91_PIN_PB4
,
537 .sda_is_open_drain
= 1,
538 .scl_pin
= AT91_PIN_PB5
,
539 .scl_is_open_drain
= 1,
540 .udelay
= 2, /* ~100 kHz */
543 static struct platform_device at91sam9263_twi_device
= {
546 .dev
.platform_data
= &pdata
,
549 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
551 at91_set_GPIO_periph(AT91_PIN_PB4
, 1); /* TWD (SDA) */
552 at91_set_multi_drive(AT91_PIN_PB4
, 1);
554 at91_set_GPIO_periph(AT91_PIN_PB5
, 1); /* TWCK (SCL) */
555 at91_set_multi_drive(AT91_PIN_PB5
, 1);
557 i2c_register_board_info(0, devices
, nr_devices
);
558 platform_device_register(&at91sam9263_twi_device
);
561 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
563 static struct resource twi_resources
[] = {
565 .start
= AT91SAM9263_BASE_TWI
,
566 .end
= AT91SAM9263_BASE_TWI
+ SZ_16K
- 1,
567 .flags
= IORESOURCE_MEM
,
570 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_TWI
,
571 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_TWI
,
572 .flags
= IORESOURCE_IRQ
,
576 static struct platform_device at91sam9263_twi_device
= {
579 .resource
= twi_resources
,
580 .num_resources
= ARRAY_SIZE(twi_resources
),
583 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
585 /* pins used for TWI interface */
586 at91_set_A_periph(AT91_PIN_PB4
, 0); /* TWD */
587 at91_set_multi_drive(AT91_PIN_PB4
, 1);
589 at91_set_A_periph(AT91_PIN_PB5
, 0); /* TWCK */
590 at91_set_multi_drive(AT91_PIN_PB5
, 1);
592 i2c_register_board_info(0, devices
, nr_devices
);
593 platform_device_register(&at91sam9263_twi_device
);
596 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
) {}
600 /* --------------------------------------------------------------------
602 * -------------------------------------------------------------------- */
604 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
605 static u64 spi_dmamask
= DMA_BIT_MASK(32);
607 static struct resource spi0_resources
[] = {
609 .start
= AT91SAM9263_BASE_SPI0
,
610 .end
= AT91SAM9263_BASE_SPI0
+ SZ_16K
- 1,
611 .flags
= IORESOURCE_MEM
,
614 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SPI0
,
615 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SPI0
,
616 .flags
= IORESOURCE_IRQ
,
620 static struct platform_device at91sam9263_spi0_device
= {
624 .dma_mask
= &spi_dmamask
,
625 .coherent_dma_mask
= DMA_BIT_MASK(32),
627 .resource
= spi0_resources
,
628 .num_resources
= ARRAY_SIZE(spi0_resources
),
631 static const unsigned spi0_standard_cs
[4] = { AT91_PIN_PA5
, AT91_PIN_PA3
, AT91_PIN_PA4
, AT91_PIN_PB11
};
633 static struct resource spi1_resources
[] = {
635 .start
= AT91SAM9263_BASE_SPI1
,
636 .end
= AT91SAM9263_BASE_SPI1
+ SZ_16K
- 1,
637 .flags
= IORESOURCE_MEM
,
640 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SPI1
,
641 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SPI1
,
642 .flags
= IORESOURCE_IRQ
,
646 static struct platform_device at91sam9263_spi1_device
= {
650 .dma_mask
= &spi_dmamask
,
651 .coherent_dma_mask
= DMA_BIT_MASK(32),
653 .resource
= spi1_resources
,
654 .num_resources
= ARRAY_SIZE(spi1_resources
),
657 static const unsigned spi1_standard_cs
[4] = { AT91_PIN_PB15
, AT91_PIN_PB16
, AT91_PIN_PB17
, AT91_PIN_PB18
};
659 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
)
662 unsigned long cs_pin
;
663 short enable_spi0
= 0;
664 short enable_spi1
= 0;
666 /* Choose SPI chip-selects */
667 for (i
= 0; i
< nr_devices
; i
++) {
668 if (devices
[i
].controller_data
)
669 cs_pin
= (unsigned long) devices
[i
].controller_data
;
670 else if (devices
[i
].bus_num
== 0)
671 cs_pin
= spi0_standard_cs
[devices
[i
].chip_select
];
673 cs_pin
= spi1_standard_cs
[devices
[i
].chip_select
];
675 if (!gpio_is_valid(cs_pin
))
678 if (devices
[i
].bus_num
== 0)
683 /* enable chip-select pin */
684 at91_set_gpio_output(cs_pin
, 1);
686 /* pass chip-select pin to driver */
687 devices
[i
].controller_data
= (void *) cs_pin
;
690 spi_register_board_info(devices
, nr_devices
);
692 /* Configure SPI bus(es) */
694 at91_set_B_periph(AT91_PIN_PA0
, 0); /* SPI0_MISO */
695 at91_set_B_periph(AT91_PIN_PA1
, 0); /* SPI0_MOSI */
696 at91_set_B_periph(AT91_PIN_PA2
, 0); /* SPI0_SPCK */
698 platform_device_register(&at91sam9263_spi0_device
);
701 at91_set_A_periph(AT91_PIN_PB12
, 0); /* SPI1_MISO */
702 at91_set_A_periph(AT91_PIN_PB13
, 0); /* SPI1_MOSI */
703 at91_set_A_periph(AT91_PIN_PB14
, 0); /* SPI1_SPCK */
705 platform_device_register(&at91sam9263_spi1_device
);
709 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
) {}
713 /* --------------------------------------------------------------------
715 * -------------------------------------------------------------------- */
717 #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
718 static u64 ac97_dmamask
= DMA_BIT_MASK(32);
719 static struct ac97c_platform_data ac97_data
;
721 static struct resource ac97_resources
[] = {
723 .start
= AT91SAM9263_BASE_AC97C
,
724 .end
= AT91SAM9263_BASE_AC97C
+ SZ_16K
- 1,
725 .flags
= IORESOURCE_MEM
,
728 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_AC97C
,
729 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_AC97C
,
730 .flags
= IORESOURCE_IRQ
,
734 static struct platform_device at91sam9263_ac97_device
= {
735 .name
= "atmel_ac97c",
738 .dma_mask
= &ac97_dmamask
,
739 .coherent_dma_mask
= DMA_BIT_MASK(32),
740 .platform_data
= &ac97_data
,
742 .resource
= ac97_resources
,
743 .num_resources
= ARRAY_SIZE(ac97_resources
),
746 void __init
at91_add_device_ac97(struct ac97c_platform_data
*data
)
751 at91_set_A_periph(AT91_PIN_PB0
, 0); /* AC97FS */
752 at91_set_A_periph(AT91_PIN_PB1
, 0); /* AC97CK */
753 at91_set_A_periph(AT91_PIN_PB2
, 0); /* AC97TX */
754 at91_set_A_periph(AT91_PIN_PB3
, 0); /* AC97RX */
757 if (gpio_is_valid(data
->reset_pin
))
758 at91_set_gpio_output(data
->reset_pin
, 0);
761 platform_device_register(&at91sam9263_ac97_device
);
764 void __init
at91_add_device_ac97(struct ac97c_platform_data
*data
) {}
767 /* --------------------------------------------------------------------
769 * -------------------------------------------------------------------- */
771 #if defined(CONFIG_CAN_AT91) || defined(CONFIG_CAN_AT91_MODULE)
772 static struct resource can_resources
[] = {
774 .start
= AT91SAM9263_BASE_CAN
,
775 .end
= AT91SAM9263_BASE_CAN
+ SZ_16K
- 1,
776 .flags
= IORESOURCE_MEM
,
779 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_CAN
,
780 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_CAN
,
781 .flags
= IORESOURCE_IRQ
,
785 static struct platform_device at91sam9263_can_device
= {
788 .resource
= can_resources
,
789 .num_resources
= ARRAY_SIZE(can_resources
),
792 void __init
at91_add_device_can(struct at91_can_data
*data
)
794 at91_set_A_periph(AT91_PIN_PA13
, 0); /* CANTX */
795 at91_set_A_periph(AT91_PIN_PA14
, 0); /* CANRX */
796 at91sam9263_can_device
.dev
.platform_data
= data
;
798 platform_device_register(&at91sam9263_can_device
);
801 void __init
at91_add_device_can(struct at91_can_data
*data
) {}
804 /* --------------------------------------------------------------------
806 * -------------------------------------------------------------------- */
808 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
809 static u64 lcdc_dmamask
= DMA_BIT_MASK(32);
810 static struct atmel_lcdfb_info lcdc_data
;
812 static struct resource lcdc_resources
[] = {
814 .start
= AT91SAM9263_LCDC_BASE
,
815 .end
= AT91SAM9263_LCDC_BASE
+ SZ_4K
- 1,
816 .flags
= IORESOURCE_MEM
,
819 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_LCDC
,
820 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_LCDC
,
821 .flags
= IORESOURCE_IRQ
,
825 static struct platform_device at91_lcdc_device
= {
826 .name
= "atmel_lcdfb",
829 .dma_mask
= &lcdc_dmamask
,
830 .coherent_dma_mask
= DMA_BIT_MASK(32),
831 .platform_data
= &lcdc_data
,
833 .resource
= lcdc_resources
,
834 .num_resources
= ARRAY_SIZE(lcdc_resources
),
837 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
)
842 at91_set_A_periph(AT91_PIN_PC1
, 0); /* LCDHSYNC */
843 at91_set_A_periph(AT91_PIN_PC2
, 0); /* LCDDOTCK */
844 at91_set_A_periph(AT91_PIN_PC3
, 0); /* LCDDEN */
845 at91_set_B_periph(AT91_PIN_PB9
, 0); /* LCDCC */
846 at91_set_A_periph(AT91_PIN_PC6
, 0); /* LCDD2 */
847 at91_set_A_periph(AT91_PIN_PC7
, 0); /* LCDD3 */
848 at91_set_A_periph(AT91_PIN_PC8
, 0); /* LCDD4 */
849 at91_set_A_periph(AT91_PIN_PC9
, 0); /* LCDD5 */
850 at91_set_A_periph(AT91_PIN_PC10
, 0); /* LCDD6 */
851 at91_set_A_periph(AT91_PIN_PC11
, 0); /* LCDD7 */
852 at91_set_A_periph(AT91_PIN_PC14
, 0); /* LCDD10 */
853 at91_set_A_periph(AT91_PIN_PC15
, 0); /* LCDD11 */
854 at91_set_A_periph(AT91_PIN_PC16
, 0); /* LCDD12 */
855 at91_set_B_periph(AT91_PIN_PC12
, 0); /* LCDD13 */
856 at91_set_A_periph(AT91_PIN_PC18
, 0); /* LCDD14 */
857 at91_set_A_periph(AT91_PIN_PC19
, 0); /* LCDD15 */
858 at91_set_A_periph(AT91_PIN_PC22
, 0); /* LCDD18 */
859 at91_set_A_periph(AT91_PIN_PC23
, 0); /* LCDD19 */
860 at91_set_A_periph(AT91_PIN_PC24
, 0); /* LCDD20 */
861 at91_set_B_periph(AT91_PIN_PC17
, 0); /* LCDD21 */
862 at91_set_A_periph(AT91_PIN_PC26
, 0); /* LCDD22 */
863 at91_set_A_periph(AT91_PIN_PC27
, 0); /* LCDD23 */
866 platform_device_register(&at91_lcdc_device
);
869 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
) {}
873 /* --------------------------------------------------------------------
874 * Image Sensor Interface
875 * -------------------------------------------------------------------- */
877 #if defined(CONFIG_VIDEO_AT91_ISI) || defined(CONFIG_VIDEO_AT91_ISI_MODULE)
879 struct resource isi_resources
[] = {
881 .start
= AT91SAM9263_BASE_ISI
,
882 .end
= AT91SAM9263_BASE_ISI
+ SZ_16K
- 1,
883 .flags
= IORESOURCE_MEM
,
886 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_ISI
,
887 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_ISI
,
888 .flags
= IORESOURCE_IRQ
,
892 static struct platform_device at91sam9263_isi_device
= {
895 .resource
= isi_resources
,
896 .num_resources
= ARRAY_SIZE(isi_resources
),
899 void __init
at91_add_device_isi(struct isi_platform_data
*data
,
902 at91_set_A_periph(AT91_PIN_PE0
, 0); /* ISI_D0 */
903 at91_set_A_periph(AT91_PIN_PE1
, 0); /* ISI_D1 */
904 at91_set_A_periph(AT91_PIN_PE2
, 0); /* ISI_D2 */
905 at91_set_A_periph(AT91_PIN_PE3
, 0); /* ISI_D3 */
906 at91_set_A_periph(AT91_PIN_PE4
, 0); /* ISI_D4 */
907 at91_set_A_periph(AT91_PIN_PE5
, 0); /* ISI_D5 */
908 at91_set_A_periph(AT91_PIN_PE6
, 0); /* ISI_D6 */
909 at91_set_A_periph(AT91_PIN_PE7
, 0); /* ISI_D7 */
910 at91_set_A_periph(AT91_PIN_PE8
, 0); /* ISI_PCK */
911 at91_set_A_periph(AT91_PIN_PE9
, 0); /* ISI_HSYNC */
912 at91_set_A_periph(AT91_PIN_PE10
, 0); /* ISI_VSYNC */
913 at91_set_B_periph(AT91_PIN_PE12
, 0); /* ISI_PD8 */
914 at91_set_B_periph(AT91_PIN_PE13
, 0); /* ISI_PD9 */
915 at91_set_B_periph(AT91_PIN_PE14
, 0); /* ISI_PD10 */
916 at91_set_B_periph(AT91_PIN_PE15
, 0); /* ISI_PD11 */
918 if (use_pck_as_mck
) {
919 at91_set_B_periph(AT91_PIN_PE11
, 0); /* ISI_MCK (PCK3) */
921 /* TODO: register the PCK for ISI_MCK and set its parent */
925 void __init
at91_add_device_isi(struct isi_platform_data
*data
,
926 bool use_pck_as_mck
) {}
930 /* --------------------------------------------------------------------
931 * Timer/Counter block
932 * -------------------------------------------------------------------- */
934 #ifdef CONFIG_ATMEL_TCLIB
936 static struct resource tcb_resources
[] = {
938 .start
= AT91SAM9263_BASE_TCB0
,
939 .end
= AT91SAM9263_BASE_TCB0
+ SZ_16K
- 1,
940 .flags
= IORESOURCE_MEM
,
943 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_TCB
,
944 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_TCB
,
945 .flags
= IORESOURCE_IRQ
,
949 static struct platform_device at91sam9263_tcb_device
= {
952 .resource
= tcb_resources
,
953 .num_resources
= ARRAY_SIZE(tcb_resources
),
956 #if defined(CONFIG_OF)
957 static struct of_device_id tcb_ids
[] = {
958 { .compatible
= "atmel,at91rm9200-tcb" },
963 static void __init
at91_add_device_tc(void)
965 #if defined(CONFIG_OF)
966 struct device_node
*np
;
968 np
= of_find_matching_node(NULL
, tcb_ids
);
975 platform_device_register(&at91sam9263_tcb_device
);
978 static void __init
at91_add_device_tc(void) { }
982 /* --------------------------------------------------------------------
984 * -------------------------------------------------------------------- */
986 static struct resource rtt0_resources
[] = {
988 .start
= AT91SAM9263_BASE_RTT0
,
989 .end
= AT91SAM9263_BASE_RTT0
+ SZ_16
- 1,
990 .flags
= IORESOURCE_MEM
,
992 .flags
= IORESOURCE_MEM
,
994 .flags
= IORESOURCE_IRQ
,
998 static struct platform_device at91sam9263_rtt0_device
= {
1001 .resource
= rtt0_resources
,
1004 static struct resource rtt1_resources
[] = {
1006 .start
= AT91SAM9263_BASE_RTT1
,
1007 .end
= AT91SAM9263_BASE_RTT1
+ SZ_16
- 1,
1008 .flags
= IORESOURCE_MEM
,
1010 .flags
= IORESOURCE_MEM
,
1012 .flags
= IORESOURCE_IRQ
,
1016 static struct platform_device at91sam9263_rtt1_device
= {
1019 .resource
= rtt1_resources
,
1022 #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
1023 static void __init
at91_add_device_rtt_rtc(void)
1025 struct platform_device
*pdev
;
1028 switch (CONFIG_RTC_DRV_AT91SAM9_RTT
) {
1031 * The second resource is needed only for the chosen RTT:
1032 * GPBR will serve as the storage for RTC time offset
1034 at91sam9263_rtt0_device
.num_resources
= 3;
1035 at91sam9263_rtt1_device
.num_resources
= 1;
1036 pdev
= &at91sam9263_rtt0_device
;
1040 at91sam9263_rtt0_device
.num_resources
= 1;
1041 at91sam9263_rtt1_device
.num_resources
= 3;
1042 pdev
= &at91sam9263_rtt1_device
;
1046 pr_err("at91sam9263: only supports 2 RTT (%d)\n",
1047 CONFIG_RTC_DRV_AT91SAM9_RTT
);
1051 pdev
->name
= "rtc-at91sam9";
1052 r
[1].start
= AT91SAM9263_BASE_GPBR
+ 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR
;
1053 r
[1].end
= r
[1].start
+ 3;
1054 r
[2].start
= NR_IRQS_LEGACY
+ AT91_ID_SYS
;
1055 r
[2].end
= NR_IRQS_LEGACY
+ AT91_ID_SYS
;
1058 static void __init
at91_add_device_rtt_rtc(void)
1060 /* Only one resource is needed: RTT not used as RTC */
1061 at91sam9263_rtt0_device
.num_resources
= 1;
1062 at91sam9263_rtt1_device
.num_resources
= 1;
1066 static void __init
at91_add_device_rtt(void)
1068 at91_add_device_rtt_rtc();
1069 platform_device_register(&at91sam9263_rtt0_device
);
1070 platform_device_register(&at91sam9263_rtt1_device
);
1074 /* --------------------------------------------------------------------
1076 * -------------------------------------------------------------------- */
1078 #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
1079 static struct resource wdt_resources
[] = {
1081 .start
= AT91SAM9263_BASE_WDT
,
1082 .end
= AT91SAM9263_BASE_WDT
+ SZ_16
- 1,
1083 .flags
= IORESOURCE_MEM
,
1087 static struct platform_device at91sam9263_wdt_device
= {
1090 .resource
= wdt_resources
,
1091 .num_resources
= ARRAY_SIZE(wdt_resources
),
1094 static void __init
at91_add_device_watchdog(void)
1096 platform_device_register(&at91sam9263_wdt_device
);
1099 static void __init
at91_add_device_watchdog(void) {}
1103 /* --------------------------------------------------------------------
1105 * --------------------------------------------------------------------*/
1107 #if defined(CONFIG_ATMEL_PWM)
1108 static u32 pwm_mask
;
1110 static struct resource pwm_resources
[] = {
1112 .start
= AT91SAM9263_BASE_PWMC
,
1113 .end
= AT91SAM9263_BASE_PWMC
+ SZ_16K
- 1,
1114 .flags
= IORESOURCE_MEM
,
1117 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_PWMC
,
1118 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_PWMC
,
1119 .flags
= IORESOURCE_IRQ
,
1123 static struct platform_device at91sam9263_pwm0_device
= {
1124 .name
= "atmel_pwm",
1127 .platform_data
= &pwm_mask
,
1129 .resource
= pwm_resources
,
1130 .num_resources
= ARRAY_SIZE(pwm_resources
),
1133 void __init
at91_add_device_pwm(u32 mask
)
1135 if (mask
& (1 << AT91_PWM0
))
1136 at91_set_B_periph(AT91_PIN_PB7
, 1); /* enable PWM0 */
1138 if (mask
& (1 << AT91_PWM1
))
1139 at91_set_B_periph(AT91_PIN_PB8
, 1); /* enable PWM1 */
1141 if (mask
& (1 << AT91_PWM2
))
1142 at91_set_B_periph(AT91_PIN_PC29
, 1); /* enable PWM2 */
1144 if (mask
& (1 << AT91_PWM3
))
1145 at91_set_B_periph(AT91_PIN_PB29
, 1); /* enable PWM3 */
1149 platform_device_register(&at91sam9263_pwm0_device
);
1152 void __init
at91_add_device_pwm(u32 mask
) {}
1156 /* --------------------------------------------------------------------
1157 * SSC -- Synchronous Serial Controller
1158 * -------------------------------------------------------------------- */
1160 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
1161 static u64 ssc0_dmamask
= DMA_BIT_MASK(32);
1163 static struct resource ssc0_resources
[] = {
1165 .start
= AT91SAM9263_BASE_SSC0
,
1166 .end
= AT91SAM9263_BASE_SSC0
+ SZ_16K
- 1,
1167 .flags
= IORESOURCE_MEM
,
1170 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SSC0
,
1171 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SSC0
,
1172 .flags
= IORESOURCE_IRQ
,
1176 static struct platform_device at91sam9263_ssc0_device
= {
1180 .dma_mask
= &ssc0_dmamask
,
1181 .coherent_dma_mask
= DMA_BIT_MASK(32),
1183 .resource
= ssc0_resources
,
1184 .num_resources
= ARRAY_SIZE(ssc0_resources
),
1187 static inline void configure_ssc0_pins(unsigned pins
)
1189 if (pins
& ATMEL_SSC_TF
)
1190 at91_set_B_periph(AT91_PIN_PB0
, 1);
1191 if (pins
& ATMEL_SSC_TK
)
1192 at91_set_B_periph(AT91_PIN_PB1
, 1);
1193 if (pins
& ATMEL_SSC_TD
)
1194 at91_set_B_periph(AT91_PIN_PB2
, 1);
1195 if (pins
& ATMEL_SSC_RD
)
1196 at91_set_B_periph(AT91_PIN_PB3
, 1);
1197 if (pins
& ATMEL_SSC_RK
)
1198 at91_set_B_periph(AT91_PIN_PB4
, 1);
1199 if (pins
& ATMEL_SSC_RF
)
1200 at91_set_B_periph(AT91_PIN_PB5
, 1);
1203 static u64 ssc1_dmamask
= DMA_BIT_MASK(32);
1205 static struct resource ssc1_resources
[] = {
1207 .start
= AT91SAM9263_BASE_SSC1
,
1208 .end
= AT91SAM9263_BASE_SSC1
+ SZ_16K
- 1,
1209 .flags
= IORESOURCE_MEM
,
1212 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SSC1
,
1213 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_SSC1
,
1214 .flags
= IORESOURCE_IRQ
,
1218 static struct platform_device at91sam9263_ssc1_device
= {
1222 .dma_mask
= &ssc1_dmamask
,
1223 .coherent_dma_mask
= DMA_BIT_MASK(32),
1225 .resource
= ssc1_resources
,
1226 .num_resources
= ARRAY_SIZE(ssc1_resources
),
1229 static inline void configure_ssc1_pins(unsigned pins
)
1231 if (pins
& ATMEL_SSC_TF
)
1232 at91_set_A_periph(AT91_PIN_PB6
, 1);
1233 if (pins
& ATMEL_SSC_TK
)
1234 at91_set_A_periph(AT91_PIN_PB7
, 1);
1235 if (pins
& ATMEL_SSC_TD
)
1236 at91_set_A_periph(AT91_PIN_PB8
, 1);
1237 if (pins
& ATMEL_SSC_RD
)
1238 at91_set_A_periph(AT91_PIN_PB9
, 1);
1239 if (pins
& ATMEL_SSC_RK
)
1240 at91_set_A_periph(AT91_PIN_PB10
, 1);
1241 if (pins
& ATMEL_SSC_RF
)
1242 at91_set_A_periph(AT91_PIN_PB11
, 1);
1246 * SSC controllers are accessed through library code, instead of any
1247 * kind of all-singing/all-dancing driver. For example one could be
1248 * used by a particular I2S audio codec's driver, while another one
1249 * on the same system might be used by a custom data capture driver.
1251 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
)
1253 struct platform_device
*pdev
;
1256 * NOTE: caller is responsible for passing information matching
1257 * "pins" to whatever will be using each particular controller.
1260 case AT91SAM9263_ID_SSC0
:
1261 pdev
= &at91sam9263_ssc0_device
;
1262 configure_ssc0_pins(pins
);
1264 case AT91SAM9263_ID_SSC1
:
1265 pdev
= &at91sam9263_ssc1_device
;
1266 configure_ssc1_pins(pins
);
1272 platform_device_register(pdev
);
1276 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
) {}
1280 /* --------------------------------------------------------------------
1282 * -------------------------------------------------------------------- */
1284 #if defined(CONFIG_SERIAL_ATMEL)
1286 static struct resource dbgu_resources
[] = {
1288 .start
= AT91SAM9263_BASE_DBGU
,
1289 .end
= AT91SAM9263_BASE_DBGU
+ SZ_512
- 1,
1290 .flags
= IORESOURCE_MEM
,
1293 .start
= NR_IRQS_LEGACY
+ AT91_ID_SYS
,
1294 .end
= NR_IRQS_LEGACY
+ AT91_ID_SYS
,
1295 .flags
= IORESOURCE_IRQ
,
1299 static struct atmel_uart_data dbgu_data
= {
1301 .use_dma_rx
= 0, /* DBGU not capable of receive DMA */
1304 static u64 dbgu_dmamask
= DMA_BIT_MASK(32);
1306 static struct platform_device at91sam9263_dbgu_device
= {
1307 .name
= "atmel_usart",
1310 .dma_mask
= &dbgu_dmamask
,
1311 .coherent_dma_mask
= DMA_BIT_MASK(32),
1312 .platform_data
= &dbgu_data
,
1314 .resource
= dbgu_resources
,
1315 .num_resources
= ARRAY_SIZE(dbgu_resources
),
1318 static inline void configure_dbgu_pins(void)
1320 at91_set_A_periph(AT91_PIN_PC30
, 0); /* DRXD */
1321 at91_set_A_periph(AT91_PIN_PC31
, 1); /* DTXD */
1324 static struct resource uart0_resources
[] = {
1326 .start
= AT91SAM9263_BASE_US0
,
1327 .end
= AT91SAM9263_BASE_US0
+ SZ_16K
- 1,
1328 .flags
= IORESOURCE_MEM
,
1331 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US0
,
1332 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US0
,
1333 .flags
= IORESOURCE_IRQ
,
1337 static struct atmel_uart_data uart0_data
= {
1342 static u64 uart0_dmamask
= DMA_BIT_MASK(32);
1344 static struct platform_device at91sam9263_uart0_device
= {
1345 .name
= "atmel_usart",
1348 .dma_mask
= &uart0_dmamask
,
1349 .coherent_dma_mask
= DMA_BIT_MASK(32),
1350 .platform_data
= &uart0_data
,
1352 .resource
= uart0_resources
,
1353 .num_resources
= ARRAY_SIZE(uart0_resources
),
1356 static inline void configure_usart0_pins(unsigned pins
)
1358 at91_set_A_periph(AT91_PIN_PA26
, 1); /* TXD0 */
1359 at91_set_A_periph(AT91_PIN_PA27
, 0); /* RXD0 */
1361 if (pins
& ATMEL_UART_RTS
)
1362 at91_set_A_periph(AT91_PIN_PA28
, 0); /* RTS0 */
1363 if (pins
& ATMEL_UART_CTS
)
1364 at91_set_A_periph(AT91_PIN_PA29
, 0); /* CTS0 */
1367 static struct resource uart1_resources
[] = {
1369 .start
= AT91SAM9263_BASE_US1
,
1370 .end
= AT91SAM9263_BASE_US1
+ SZ_16K
- 1,
1371 .flags
= IORESOURCE_MEM
,
1374 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US1
,
1375 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US1
,
1376 .flags
= IORESOURCE_IRQ
,
1380 static struct atmel_uart_data uart1_data
= {
1385 static u64 uart1_dmamask
= DMA_BIT_MASK(32);
1387 static struct platform_device at91sam9263_uart1_device
= {
1388 .name
= "atmel_usart",
1391 .dma_mask
= &uart1_dmamask
,
1392 .coherent_dma_mask
= DMA_BIT_MASK(32),
1393 .platform_data
= &uart1_data
,
1395 .resource
= uart1_resources
,
1396 .num_resources
= ARRAY_SIZE(uart1_resources
),
1399 static inline void configure_usart1_pins(unsigned pins
)
1401 at91_set_A_periph(AT91_PIN_PD0
, 1); /* TXD1 */
1402 at91_set_A_periph(AT91_PIN_PD1
, 0); /* RXD1 */
1404 if (pins
& ATMEL_UART_RTS
)
1405 at91_set_B_periph(AT91_PIN_PD7
, 0); /* RTS1 */
1406 if (pins
& ATMEL_UART_CTS
)
1407 at91_set_B_periph(AT91_PIN_PD8
, 0); /* CTS1 */
1410 static struct resource uart2_resources
[] = {
1412 .start
= AT91SAM9263_BASE_US2
,
1413 .end
= AT91SAM9263_BASE_US2
+ SZ_16K
- 1,
1414 .flags
= IORESOURCE_MEM
,
1417 .start
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US2
,
1418 .end
= NR_IRQS_LEGACY
+ AT91SAM9263_ID_US2
,
1419 .flags
= IORESOURCE_IRQ
,
1423 static struct atmel_uart_data uart2_data
= {
1428 static u64 uart2_dmamask
= DMA_BIT_MASK(32);
1430 static struct platform_device at91sam9263_uart2_device
= {
1431 .name
= "atmel_usart",
1434 .dma_mask
= &uart2_dmamask
,
1435 .coherent_dma_mask
= DMA_BIT_MASK(32),
1436 .platform_data
= &uart2_data
,
1438 .resource
= uart2_resources
,
1439 .num_resources
= ARRAY_SIZE(uart2_resources
),
1442 static inline void configure_usart2_pins(unsigned pins
)
1444 at91_set_A_periph(AT91_PIN_PD2
, 1); /* TXD2 */
1445 at91_set_A_periph(AT91_PIN_PD3
, 0); /* RXD2 */
1447 if (pins
& ATMEL_UART_RTS
)
1448 at91_set_B_periph(AT91_PIN_PD5
, 0); /* RTS2 */
1449 if (pins
& ATMEL_UART_CTS
)
1450 at91_set_B_periph(AT91_PIN_PD6
, 0); /* CTS2 */
1453 static struct platform_device
*__initdata at91_uarts
[ATMEL_MAX_UART
]; /* the UARTs to use */
1455 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
)
1457 struct platform_device
*pdev
;
1458 struct atmel_uart_data
*pdata
;
1462 pdev
= &at91sam9263_dbgu_device
;
1463 configure_dbgu_pins();
1465 case AT91SAM9263_ID_US0
:
1466 pdev
= &at91sam9263_uart0_device
;
1467 configure_usart0_pins(pins
);
1469 case AT91SAM9263_ID_US1
:
1470 pdev
= &at91sam9263_uart1_device
;
1471 configure_usart1_pins(pins
);
1473 case AT91SAM9263_ID_US2
:
1474 pdev
= &at91sam9263_uart2_device
;
1475 configure_usart2_pins(pins
);
1480 pdata
= pdev
->dev
.platform_data
;
1481 pdata
->num
= portnr
; /* update to mapped ID */
1483 if (portnr
< ATMEL_MAX_UART
)
1484 at91_uarts
[portnr
] = pdev
;
1487 void __init
at91_add_device_serial(void)
1491 for (i
= 0; i
< ATMEL_MAX_UART
; i
++) {
1493 platform_device_register(at91_uarts
[i
]);
1497 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
) {}
1498 void __init
at91_add_device_serial(void) {}
1502 /* -------------------------------------------------------------------- */
1504 * These devices are always present and don't need any board-specific
1507 static int __init
at91_add_standard_devices(void)
1509 if (of_have_populated_dt())
1512 at91_add_device_rtt();
1513 at91_add_device_watchdog();
1514 at91_add_device_tc();
1518 arch_initcall(at91_add_standard_devices
);