2 * arch/arm/mach-at91/at91sam9261_devices.c
4 * Copyright (C) 2005 Thibaut VARENE <varenet@parisc-linux.org>
5 * Copyright (C) 2005 David Brownell
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
13 #include <asm/mach/arch.h>
14 #include <asm/mach/map.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/platform_device.h>
18 #include <linux/i2c-gpio.h>
21 #include <video/atmel_lcdc.h>
23 #include <asm/arch/board.h>
24 #include <asm/arch/gpio.h>
25 #include <asm/arch/at91sam9261.h>
26 #include <asm/arch/at91sam9261_matrix.h>
27 #include <asm/arch/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
= AT91SAM9261_UHP_BASE
,
43 .end
= AT91SAM9261_UHP_BASE
+ SZ_1M
- 1,
44 .flags
= IORESOURCE_MEM
,
47 .start
= AT91SAM9261_ID_UHP
,
48 .end
= AT91SAM9261_ID_UHP
,
49 .flags
= IORESOURCE_IRQ
,
53 static struct platform_device at91sam9261_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
)
71 platform_device_register(&at91sam9261_usbh_device
);
74 void __init
at91_add_device_usbh(struct at91_usbh_data
*data
) {}
78 /* --------------------------------------------------------------------
80 * -------------------------------------------------------------------- */
82 #ifdef CONFIG_USB_GADGET_AT91
83 static struct at91_udc_data udc_data
;
85 static struct resource udc_resources
[] = {
87 .start
= AT91SAM9261_BASE_UDP
,
88 .end
= AT91SAM9261_BASE_UDP
+ SZ_16K
- 1,
89 .flags
= IORESOURCE_MEM
,
92 .start
= AT91SAM9261_ID_UDP
,
93 .end
= AT91SAM9261_ID_UDP
,
94 .flags
= IORESOURCE_IRQ
,
98 static struct platform_device at91sam9261_udc_device
= {
102 .platform_data
= &udc_data
,
104 .resource
= udc_resources
,
105 .num_resources
= ARRAY_SIZE(udc_resources
),
108 void __init
at91_add_device_udc(struct at91_udc_data
*data
)
113 if (data
->vbus_pin
) {
114 at91_set_gpio_input(data
->vbus_pin
, 0);
115 at91_set_deglitch(data
->vbus_pin
, 1);
118 /* Pullup pin is handled internally by USB device peripheral */
121 platform_device_register(&at91sam9261_udc_device
);
124 void __init
at91_add_device_udc(struct at91_udc_data
*data
) {}
127 /* --------------------------------------------------------------------
129 * -------------------------------------------------------------------- */
131 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
132 static u64 mmc_dmamask
= DMA_BIT_MASK(32);
133 static struct at91_mmc_data mmc_data
;
135 static struct resource mmc_resources
[] = {
137 .start
= AT91SAM9261_BASE_MCI
,
138 .end
= AT91SAM9261_BASE_MCI
+ SZ_16K
- 1,
139 .flags
= IORESOURCE_MEM
,
142 .start
= AT91SAM9261_ID_MCI
,
143 .end
= AT91SAM9261_ID_MCI
,
144 .flags
= IORESOURCE_IRQ
,
148 static struct platform_device at91sam9261_mmc_device
= {
152 .dma_mask
= &mmc_dmamask
,
153 .coherent_dma_mask
= DMA_BIT_MASK(32),
154 .platform_data
= &mmc_data
,
156 .resource
= mmc_resources
,
157 .num_resources
= ARRAY_SIZE(mmc_resources
),
160 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
)
167 at91_set_gpio_input(data
->det_pin
, 1);
168 at91_set_deglitch(data
->det_pin
, 1);
171 at91_set_gpio_input(data
->wp_pin
, 1);
173 at91_set_gpio_output(data
->vcc_pin
, 0);
176 at91_set_B_periph(AT91_PIN_PA2
, 0);
179 at91_set_B_periph(AT91_PIN_PA1
, 1);
181 /* DAT0, maybe DAT1..DAT3 */
182 at91_set_B_periph(AT91_PIN_PA0
, 1);
184 at91_set_B_periph(AT91_PIN_PA4
, 1);
185 at91_set_B_periph(AT91_PIN_PA5
, 1);
186 at91_set_B_periph(AT91_PIN_PA6
, 1);
190 platform_device_register(&at91sam9261_mmc_device
);
193 void __init
at91_add_device_mmc(short mmc_id
, struct at91_mmc_data
*data
) {}
197 /* --------------------------------------------------------------------
199 * -------------------------------------------------------------------- */
201 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
202 static struct at91_nand_data nand_data
;
204 #define NAND_BASE AT91_CHIPSELECT_3
206 static struct resource nand_resources
[] = {
209 .end
= NAND_BASE
+ SZ_256M
- 1,
210 .flags
= IORESOURCE_MEM
,
214 static struct platform_device at91_nand_device
= {
218 .platform_data
= &nand_data
,
220 .resource
= nand_resources
,
221 .num_resources
= ARRAY_SIZE(nand_resources
),
224 void __init
at91_add_device_nand(struct at91_nand_data
*data
)
226 unsigned long csa
, mode
;
231 csa
= at91_sys_read(AT91_MATRIX_EBICSA
);
232 at91_sys_write(AT91_MATRIX_EBICSA
, csa
| AT91_MATRIX_CS3A_SMC_SMARTMEDIA
);
234 /* set the bus interface characteristics */
235 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
236 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
238 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)
239 | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));
241 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
243 if (data
->bus_width_16
)
244 mode
= AT91_SMC_DBW_16
;
246 mode
= AT91_SMC_DBW_8
;
247 at91_sys_write(AT91_SMC_MODE(3), mode
| AT91_SMC_READMODE
| AT91_SMC_WRITEMODE
| AT91_SMC_EXNWMODE_DISABLE
| AT91_SMC_TDF_(1));
250 if (data
->enable_pin
)
251 at91_set_gpio_output(data
->enable_pin
, 1);
255 at91_set_gpio_input(data
->rdy_pin
, 1);
257 /* card detect pin */
259 at91_set_gpio_input(data
->det_pin
, 1);
261 at91_set_A_periph(AT91_PIN_PC0
, 0); /* NANDOE */
262 at91_set_A_periph(AT91_PIN_PC1
, 0); /* NANDWE */
265 platform_device_register(&at91_nand_device
);
269 void __init
at91_add_device_nand(struct at91_nand_data
*data
) {}
273 /* --------------------------------------------------------------------
275 * -------------------------------------------------------------------- */
278 * Prefer the GPIO code since the TWI controller isn't robust
279 * (gets overruns and underruns under load) and can only issue
280 * repeated STARTs in one scenario (the driver doesn't yet handle them).
282 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
284 static struct i2c_gpio_platform_data pdata
= {
285 .sda_pin
= AT91_PIN_PA7
,
286 .sda_is_open_drain
= 1,
287 .scl_pin
= AT91_PIN_PA8
,
288 .scl_is_open_drain
= 1,
289 .udelay
= 2, /* ~100 kHz */
292 static struct platform_device at91sam9261_twi_device
= {
295 .dev
.platform_data
= &pdata
,
298 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
300 at91_set_GPIO_periph(AT91_PIN_PA7
, 1); /* TWD (SDA) */
301 at91_set_multi_drive(AT91_PIN_PA7
, 1);
303 at91_set_GPIO_periph(AT91_PIN_PA8
, 1); /* TWCK (SCL) */
304 at91_set_multi_drive(AT91_PIN_PA8
, 1);
306 i2c_register_board_info(0, devices
, nr_devices
);
307 platform_device_register(&at91sam9261_twi_device
);
310 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
312 static struct resource twi_resources
[] = {
314 .start
= AT91SAM9261_BASE_TWI
,
315 .end
= AT91SAM9261_BASE_TWI
+ SZ_16K
- 1,
316 .flags
= IORESOURCE_MEM
,
319 .start
= AT91SAM9261_ID_TWI
,
320 .end
= AT91SAM9261_ID_TWI
,
321 .flags
= IORESOURCE_IRQ
,
325 static struct platform_device at91sam9261_twi_device
= {
328 .resource
= twi_resources
,
329 .num_resources
= ARRAY_SIZE(twi_resources
),
332 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
)
334 /* pins used for TWI interface */
335 at91_set_A_periph(AT91_PIN_PA7
, 0); /* TWD */
336 at91_set_multi_drive(AT91_PIN_PA7
, 1);
338 at91_set_A_periph(AT91_PIN_PA8
, 0); /* TWCK */
339 at91_set_multi_drive(AT91_PIN_PA8
, 1);
341 i2c_register_board_info(0, devices
, nr_devices
);
342 platform_device_register(&at91sam9261_twi_device
);
345 void __init
at91_add_device_i2c(struct i2c_board_info
*devices
, int nr_devices
) {}
349 /* --------------------------------------------------------------------
351 * -------------------------------------------------------------------- */
353 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
354 static u64 spi_dmamask
= DMA_BIT_MASK(32);
356 static struct resource spi0_resources
[] = {
358 .start
= AT91SAM9261_BASE_SPI0
,
359 .end
= AT91SAM9261_BASE_SPI0
+ SZ_16K
- 1,
360 .flags
= IORESOURCE_MEM
,
363 .start
= AT91SAM9261_ID_SPI0
,
364 .end
= AT91SAM9261_ID_SPI0
,
365 .flags
= IORESOURCE_IRQ
,
369 static struct platform_device at91sam9261_spi0_device
= {
373 .dma_mask
= &spi_dmamask
,
374 .coherent_dma_mask
= DMA_BIT_MASK(32),
376 .resource
= spi0_resources
,
377 .num_resources
= ARRAY_SIZE(spi0_resources
),
380 static const unsigned spi0_standard_cs
[4] = { AT91_PIN_PA3
, AT91_PIN_PA4
, AT91_PIN_PA5
, AT91_PIN_PA6
};
382 static struct resource spi1_resources
[] = {
384 .start
= AT91SAM9261_BASE_SPI1
,
385 .end
= AT91SAM9261_BASE_SPI1
+ SZ_16K
- 1,
386 .flags
= IORESOURCE_MEM
,
389 .start
= AT91SAM9261_ID_SPI1
,
390 .end
= AT91SAM9261_ID_SPI1
,
391 .flags
= IORESOURCE_IRQ
,
395 static struct platform_device at91sam9261_spi1_device
= {
399 .dma_mask
= &spi_dmamask
,
400 .coherent_dma_mask
= DMA_BIT_MASK(32),
402 .resource
= spi1_resources
,
403 .num_resources
= ARRAY_SIZE(spi1_resources
),
406 static const unsigned spi1_standard_cs
[4] = { AT91_PIN_PB28
, AT91_PIN_PA24
, AT91_PIN_PA25
, AT91_PIN_PA26
};
408 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
)
411 unsigned long cs_pin
;
412 short enable_spi0
= 0;
413 short enable_spi1
= 0;
415 /* Choose SPI chip-selects */
416 for (i
= 0; i
< nr_devices
; i
++) {
417 if (devices
[i
].controller_data
)
418 cs_pin
= (unsigned long) devices
[i
].controller_data
;
419 else if (devices
[i
].bus_num
== 0)
420 cs_pin
= spi0_standard_cs
[devices
[i
].chip_select
];
422 cs_pin
= spi1_standard_cs
[devices
[i
].chip_select
];
424 if (devices
[i
].bus_num
== 0)
429 /* enable chip-select pin */
430 at91_set_gpio_output(cs_pin
, 1);
432 /* pass chip-select pin to driver */
433 devices
[i
].controller_data
= (void *) cs_pin
;
436 spi_register_board_info(devices
, nr_devices
);
438 /* Configure SPI bus(es) */
440 at91_set_A_periph(AT91_PIN_PA0
, 0); /* SPI0_MISO */
441 at91_set_A_periph(AT91_PIN_PA1
, 0); /* SPI0_MOSI */
442 at91_set_A_periph(AT91_PIN_PA2
, 0); /* SPI0_SPCK */
444 at91_clock_associate("spi0_clk", &at91sam9261_spi0_device
.dev
, "spi_clk");
445 platform_device_register(&at91sam9261_spi0_device
);
448 at91_set_A_periph(AT91_PIN_PB30
, 0); /* SPI1_MISO */
449 at91_set_A_periph(AT91_PIN_PB31
, 0); /* SPI1_MOSI */
450 at91_set_A_periph(AT91_PIN_PB29
, 0); /* SPI1_SPCK */
452 at91_clock_associate("spi1_clk", &at91sam9261_spi1_device
.dev
, "spi_clk");
453 platform_device_register(&at91sam9261_spi1_device
);
457 void __init
at91_add_device_spi(struct spi_board_info
*devices
, int nr_devices
) {}
461 /* --------------------------------------------------------------------
463 * -------------------------------------------------------------------- */
465 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
466 static u64 lcdc_dmamask
= DMA_BIT_MASK(32);
467 static struct atmel_lcdfb_info lcdc_data
;
469 static struct resource lcdc_resources
[] = {
471 .start
= AT91SAM9261_LCDC_BASE
,
472 .end
= AT91SAM9261_LCDC_BASE
+ SZ_4K
- 1,
473 .flags
= IORESOURCE_MEM
,
476 .start
= AT91SAM9261_ID_LCDC
,
477 .end
= AT91SAM9261_ID_LCDC
,
478 .flags
= IORESOURCE_IRQ
,
480 #if defined(CONFIG_FB_INTSRAM)
482 .start
= AT91SAM9261_SRAM_BASE
,
483 .end
= AT91SAM9261_SRAM_BASE
+ AT91SAM9261_SRAM_SIZE
- 1,
484 .flags
= IORESOURCE_MEM
,
489 static struct platform_device at91_lcdc_device
= {
490 .name
= "atmel_lcdfb",
493 .dma_mask
= &lcdc_dmamask
,
494 .coherent_dma_mask
= DMA_BIT_MASK(32),
495 .platform_data
= &lcdc_data
,
497 .resource
= lcdc_resources
,
498 .num_resources
= ARRAY_SIZE(lcdc_resources
),
501 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
)
507 #if defined(CONFIG_FB_ATMEL_STN)
508 at91_set_A_periph(AT91_PIN_PB0
, 0); /* LCDVSYNC */
509 at91_set_A_periph(AT91_PIN_PB1
, 0); /* LCDHSYNC */
510 at91_set_A_periph(AT91_PIN_PB2
, 0); /* LCDDOTCK */
511 at91_set_A_periph(AT91_PIN_PB3
, 0); /* LCDDEN */
512 at91_set_A_periph(AT91_PIN_PB4
, 0); /* LCDCC */
513 at91_set_A_periph(AT91_PIN_PB5
, 0); /* LCDD0 */
514 at91_set_A_periph(AT91_PIN_PB6
, 0); /* LCDD1 */
515 at91_set_A_periph(AT91_PIN_PB7
, 0); /* LCDD2 */
516 at91_set_A_periph(AT91_PIN_PB8
, 0); /* LCDD3 */
518 at91_set_A_periph(AT91_PIN_PB1
, 0); /* LCDHSYNC */
519 at91_set_A_periph(AT91_PIN_PB2
, 0); /* LCDDOTCK */
520 at91_set_A_periph(AT91_PIN_PB3
, 0); /* LCDDEN */
521 at91_set_A_periph(AT91_PIN_PB4
, 0); /* LCDCC */
522 at91_set_A_periph(AT91_PIN_PB7
, 0); /* LCDD2 */
523 at91_set_A_periph(AT91_PIN_PB8
, 0); /* LCDD3 */
524 at91_set_A_periph(AT91_PIN_PB9
, 0); /* LCDD4 */
525 at91_set_A_periph(AT91_PIN_PB10
, 0); /* LCDD5 */
526 at91_set_A_periph(AT91_PIN_PB11
, 0); /* LCDD6 */
527 at91_set_A_periph(AT91_PIN_PB12
, 0); /* LCDD7 */
528 at91_set_A_periph(AT91_PIN_PB15
, 0); /* LCDD10 */
529 at91_set_A_periph(AT91_PIN_PB16
, 0); /* LCDD11 */
530 at91_set_A_periph(AT91_PIN_PB17
, 0); /* LCDD12 */
531 at91_set_A_periph(AT91_PIN_PB18
, 0); /* LCDD13 */
532 at91_set_A_periph(AT91_PIN_PB19
, 0); /* LCDD14 */
533 at91_set_A_periph(AT91_PIN_PB20
, 0); /* LCDD15 */
534 at91_set_B_periph(AT91_PIN_PB23
, 0); /* LCDD18 */
535 at91_set_B_periph(AT91_PIN_PB24
, 0); /* LCDD19 */
536 at91_set_B_periph(AT91_PIN_PB25
, 0); /* LCDD20 */
537 at91_set_B_periph(AT91_PIN_PB26
, 0); /* LCDD21 */
538 at91_set_B_periph(AT91_PIN_PB27
, 0); /* LCDD22 */
539 at91_set_B_periph(AT91_PIN_PB28
, 0); /* LCDD23 */
542 if (ARRAY_SIZE(lcdc_resources
) > 2) {
544 struct resource
*fb_res
= &lcdc_resources
[2];
545 size_t fb_len
= fb_res
->end
- fb_res
->start
+ 1;
547 fb
= ioremap(fb_res
->start
, fb_len
);
549 memset(fb
, 0, fb_len
);
554 platform_device_register(&at91_lcdc_device
);
557 void __init
at91_add_device_lcdc(struct atmel_lcdfb_info
*data
) {}
561 /* --------------------------------------------------------------------
562 * Timer/Counter block
563 * -------------------------------------------------------------------- */
565 #ifdef CONFIG_ATMEL_TCLIB
567 static struct resource tcb_resources
[] = {
569 .start
= AT91SAM9261_BASE_TCB0
,
570 .end
= AT91SAM9261_BASE_TCB0
+ SZ_16K
- 1,
571 .flags
= IORESOURCE_MEM
,
574 .start
= AT91SAM9261_ID_TC0
,
575 .end
= AT91SAM9261_ID_TC0
,
576 .flags
= IORESOURCE_IRQ
,
579 .start
= AT91SAM9261_ID_TC1
,
580 .end
= AT91SAM9261_ID_TC1
,
581 .flags
= IORESOURCE_IRQ
,
584 .start
= AT91SAM9261_ID_TC2
,
585 .end
= AT91SAM9261_ID_TC2
,
586 .flags
= IORESOURCE_IRQ
,
590 static struct platform_device at91sam9261_tcb_device
= {
593 .resource
= tcb_resources
,
594 .num_resources
= ARRAY_SIZE(tcb_resources
),
597 static void __init
at91_add_device_tc(void)
599 /* this chip has a separate clock and irq for each TC channel */
600 at91_clock_associate("tc0_clk", &at91sam9261_tcb_device
.dev
, "t0_clk");
601 at91_clock_associate("tc1_clk", &at91sam9261_tcb_device
.dev
, "t1_clk");
602 at91_clock_associate("tc2_clk", &at91sam9261_tcb_device
.dev
, "t2_clk");
603 platform_device_register(&at91sam9261_tcb_device
);
606 static void __init
at91_add_device_tc(void) { }
610 /* --------------------------------------------------------------------
612 * -------------------------------------------------------------------- */
614 static struct resource rtt_resources
[] = {
616 .start
= AT91_BASE_SYS
+ AT91_RTT
,
617 .end
= AT91_BASE_SYS
+ AT91_RTT
+ SZ_16
- 1,
618 .flags
= IORESOURCE_MEM
,
622 static struct platform_device at91sam9261_rtt_device
= {
625 .resource
= rtt_resources
,
626 .num_resources
= ARRAY_SIZE(rtt_resources
),
629 static void __init
at91_add_device_rtt(void)
631 platform_device_register(&at91sam9261_rtt_device
);
635 /* --------------------------------------------------------------------
637 * -------------------------------------------------------------------- */
639 #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
640 static struct platform_device at91sam9261_wdt_device
= {
646 static void __init
at91_add_device_watchdog(void)
648 platform_device_register(&at91sam9261_wdt_device
);
651 static void __init
at91_add_device_watchdog(void) {}
655 /* --------------------------------------------------------------------
656 * SSC -- Synchronous Serial Controller
657 * -------------------------------------------------------------------- */
659 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
660 static u64 ssc0_dmamask
= DMA_BIT_MASK(32);
662 static struct resource ssc0_resources
[] = {
664 .start
= AT91SAM9261_BASE_SSC0
,
665 .end
= AT91SAM9261_BASE_SSC0
+ SZ_16K
- 1,
666 .flags
= IORESOURCE_MEM
,
669 .start
= AT91SAM9261_ID_SSC0
,
670 .end
= AT91SAM9261_ID_SSC0
,
671 .flags
= IORESOURCE_IRQ
,
675 static struct platform_device at91sam9261_ssc0_device
= {
679 .dma_mask
= &ssc0_dmamask
,
680 .coherent_dma_mask
= DMA_BIT_MASK(32),
682 .resource
= ssc0_resources
,
683 .num_resources
= ARRAY_SIZE(ssc0_resources
),
686 static inline void configure_ssc0_pins(unsigned pins
)
688 if (pins
& ATMEL_SSC_TF
)
689 at91_set_A_periph(AT91_PIN_PB21
, 1);
690 if (pins
& ATMEL_SSC_TK
)
691 at91_set_A_periph(AT91_PIN_PB22
, 1);
692 if (pins
& ATMEL_SSC_TD
)
693 at91_set_A_periph(AT91_PIN_PB23
, 1);
694 if (pins
& ATMEL_SSC_RD
)
695 at91_set_A_periph(AT91_PIN_PB24
, 1);
696 if (pins
& ATMEL_SSC_RK
)
697 at91_set_A_periph(AT91_PIN_PB25
, 1);
698 if (pins
& ATMEL_SSC_RF
)
699 at91_set_A_periph(AT91_PIN_PB26
, 1);
702 static u64 ssc1_dmamask
= DMA_BIT_MASK(32);
704 static struct resource ssc1_resources
[] = {
706 .start
= AT91SAM9261_BASE_SSC1
,
707 .end
= AT91SAM9261_BASE_SSC1
+ SZ_16K
- 1,
708 .flags
= IORESOURCE_MEM
,
711 .start
= AT91SAM9261_ID_SSC1
,
712 .end
= AT91SAM9261_ID_SSC1
,
713 .flags
= IORESOURCE_IRQ
,
717 static struct platform_device at91sam9261_ssc1_device
= {
721 .dma_mask
= &ssc1_dmamask
,
722 .coherent_dma_mask
= DMA_BIT_MASK(32),
724 .resource
= ssc1_resources
,
725 .num_resources
= ARRAY_SIZE(ssc1_resources
),
728 static inline void configure_ssc1_pins(unsigned pins
)
730 if (pins
& ATMEL_SSC_TF
)
731 at91_set_B_periph(AT91_PIN_PA17
, 1);
732 if (pins
& ATMEL_SSC_TK
)
733 at91_set_B_periph(AT91_PIN_PA18
, 1);
734 if (pins
& ATMEL_SSC_TD
)
735 at91_set_B_periph(AT91_PIN_PA19
, 1);
736 if (pins
& ATMEL_SSC_RD
)
737 at91_set_B_periph(AT91_PIN_PA20
, 1);
738 if (pins
& ATMEL_SSC_RK
)
739 at91_set_B_periph(AT91_PIN_PA21
, 1);
740 if (pins
& ATMEL_SSC_RF
)
741 at91_set_B_periph(AT91_PIN_PA22
, 1);
744 static u64 ssc2_dmamask
= DMA_BIT_MASK(32);
746 static struct resource ssc2_resources
[] = {
748 .start
= AT91SAM9261_BASE_SSC2
,
749 .end
= AT91SAM9261_BASE_SSC2
+ SZ_16K
- 1,
750 .flags
= IORESOURCE_MEM
,
753 .start
= AT91SAM9261_ID_SSC2
,
754 .end
= AT91SAM9261_ID_SSC2
,
755 .flags
= IORESOURCE_IRQ
,
759 static struct platform_device at91sam9261_ssc2_device
= {
763 .dma_mask
= &ssc2_dmamask
,
764 .coherent_dma_mask
= DMA_BIT_MASK(32),
766 .resource
= ssc2_resources
,
767 .num_resources
= ARRAY_SIZE(ssc2_resources
),
770 static inline void configure_ssc2_pins(unsigned pins
)
772 if (pins
& ATMEL_SSC_TF
)
773 at91_set_B_periph(AT91_PIN_PC25
, 1);
774 if (pins
& ATMEL_SSC_TK
)
775 at91_set_B_periph(AT91_PIN_PC26
, 1);
776 if (pins
& ATMEL_SSC_TD
)
777 at91_set_B_periph(AT91_PIN_PC27
, 1);
778 if (pins
& ATMEL_SSC_RD
)
779 at91_set_B_periph(AT91_PIN_PC28
, 1);
780 if (pins
& ATMEL_SSC_RK
)
781 at91_set_B_periph(AT91_PIN_PC29
, 1);
782 if (pins
& ATMEL_SSC_RF
)
783 at91_set_B_periph(AT91_PIN_PC30
, 1);
787 * SSC controllers are accessed through library code, instead of any
788 * kind of all-singing/all-dancing driver. For example one could be
789 * used by a particular I2S audio codec's driver, while another one
790 * on the same system might be used by a custom data capture driver.
792 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
)
794 struct platform_device
*pdev
;
797 * NOTE: caller is responsible for passing information matching
798 * "pins" to whatever will be using each particular controller.
801 case AT91SAM9261_ID_SSC0
:
802 pdev
= &at91sam9261_ssc0_device
;
803 configure_ssc0_pins(pins
);
804 at91_clock_associate("ssc0_clk", &pdev
->dev
, "pclk");
806 case AT91SAM9261_ID_SSC1
:
807 pdev
= &at91sam9261_ssc1_device
;
808 configure_ssc1_pins(pins
);
809 at91_clock_associate("ssc1_clk", &pdev
->dev
, "pclk");
811 case AT91SAM9261_ID_SSC2
:
812 pdev
= &at91sam9261_ssc2_device
;
813 configure_ssc2_pins(pins
);
814 at91_clock_associate("ssc2_clk", &pdev
->dev
, "pclk");
820 platform_device_register(pdev
);
824 void __init
at91_add_device_ssc(unsigned id
, unsigned pins
) {}
828 /* --------------------------------------------------------------------
830 * -------------------------------------------------------------------- */
832 #if defined(CONFIG_SERIAL_ATMEL)
833 static struct resource dbgu_resources
[] = {
835 .start
= AT91_VA_BASE_SYS
+ AT91_DBGU
,
836 .end
= AT91_VA_BASE_SYS
+ AT91_DBGU
+ SZ_512
- 1,
837 .flags
= IORESOURCE_MEM
,
840 .start
= AT91_ID_SYS
,
842 .flags
= IORESOURCE_IRQ
,
846 static struct atmel_uart_data dbgu_data
= {
848 .use_dma_rx
= 0, /* DBGU not capable of receive DMA */
849 .regs
= (void __iomem
*)(AT91_VA_BASE_SYS
+ AT91_DBGU
),
852 static u64 dbgu_dmamask
= DMA_BIT_MASK(32);
854 static struct platform_device at91sam9261_dbgu_device
= {
855 .name
= "atmel_usart",
858 .dma_mask
= &dbgu_dmamask
,
859 .coherent_dma_mask
= DMA_BIT_MASK(32),
860 .platform_data
= &dbgu_data
,
862 .resource
= dbgu_resources
,
863 .num_resources
= ARRAY_SIZE(dbgu_resources
),
866 static inline void configure_dbgu_pins(void)
868 at91_set_A_periph(AT91_PIN_PA9
, 0); /* DRXD */
869 at91_set_A_periph(AT91_PIN_PA10
, 1); /* DTXD */
872 static struct resource uart0_resources
[] = {
874 .start
= AT91SAM9261_BASE_US0
,
875 .end
= AT91SAM9261_BASE_US0
+ SZ_16K
- 1,
876 .flags
= IORESOURCE_MEM
,
879 .start
= AT91SAM9261_ID_US0
,
880 .end
= AT91SAM9261_ID_US0
,
881 .flags
= IORESOURCE_IRQ
,
885 static struct atmel_uart_data uart0_data
= {
890 static u64 uart0_dmamask
= DMA_BIT_MASK(32);
892 static struct platform_device at91sam9261_uart0_device
= {
893 .name
= "atmel_usart",
896 .dma_mask
= &uart0_dmamask
,
897 .coherent_dma_mask
= DMA_BIT_MASK(32),
898 .platform_data
= &uart0_data
,
900 .resource
= uart0_resources
,
901 .num_resources
= ARRAY_SIZE(uart0_resources
),
904 static inline void configure_usart0_pins(unsigned pins
)
906 at91_set_A_periph(AT91_PIN_PC8
, 1); /* TXD0 */
907 at91_set_A_periph(AT91_PIN_PC9
, 0); /* RXD0 */
909 if (pins
& ATMEL_UART_RTS
)
910 at91_set_A_periph(AT91_PIN_PC10
, 0); /* RTS0 */
911 if (pins
& ATMEL_UART_CTS
)
912 at91_set_A_periph(AT91_PIN_PC11
, 0); /* CTS0 */
915 static struct resource uart1_resources
[] = {
917 .start
= AT91SAM9261_BASE_US1
,
918 .end
= AT91SAM9261_BASE_US1
+ SZ_16K
- 1,
919 .flags
= IORESOURCE_MEM
,
922 .start
= AT91SAM9261_ID_US1
,
923 .end
= AT91SAM9261_ID_US1
,
924 .flags
= IORESOURCE_IRQ
,
928 static struct atmel_uart_data uart1_data
= {
933 static u64 uart1_dmamask
= DMA_BIT_MASK(32);
935 static struct platform_device at91sam9261_uart1_device
= {
936 .name
= "atmel_usart",
939 .dma_mask
= &uart1_dmamask
,
940 .coherent_dma_mask
= DMA_BIT_MASK(32),
941 .platform_data
= &uart1_data
,
943 .resource
= uart1_resources
,
944 .num_resources
= ARRAY_SIZE(uart1_resources
),
947 static inline void configure_usart1_pins(unsigned pins
)
949 at91_set_A_periph(AT91_PIN_PC12
, 1); /* TXD1 */
950 at91_set_A_periph(AT91_PIN_PC13
, 0); /* RXD1 */
952 if (pins
& ATMEL_UART_RTS
)
953 at91_set_B_periph(AT91_PIN_PA12
, 0); /* RTS1 */
954 if (pins
& ATMEL_UART_CTS
)
955 at91_set_B_periph(AT91_PIN_PA13
, 0); /* CTS1 */
958 static struct resource uart2_resources
[] = {
960 .start
= AT91SAM9261_BASE_US2
,
961 .end
= AT91SAM9261_BASE_US2
+ SZ_16K
- 1,
962 .flags
= IORESOURCE_MEM
,
965 .start
= AT91SAM9261_ID_US2
,
966 .end
= AT91SAM9261_ID_US2
,
967 .flags
= IORESOURCE_IRQ
,
971 static struct atmel_uart_data uart2_data
= {
976 static u64 uart2_dmamask
= DMA_BIT_MASK(32);
978 static struct platform_device at91sam9261_uart2_device
= {
979 .name
= "atmel_usart",
982 .dma_mask
= &uart2_dmamask
,
983 .coherent_dma_mask
= DMA_BIT_MASK(32),
984 .platform_data
= &uart2_data
,
986 .resource
= uart2_resources
,
987 .num_resources
= ARRAY_SIZE(uart2_resources
),
990 static inline void configure_usart2_pins(unsigned pins
)
992 at91_set_A_periph(AT91_PIN_PC15
, 0); /* RXD2 */
993 at91_set_A_periph(AT91_PIN_PC14
, 1); /* TXD2 */
995 if (pins
& ATMEL_UART_RTS
)
996 at91_set_B_periph(AT91_PIN_PA15
, 0); /* RTS2*/
997 if (pins
& ATMEL_UART_CTS
)
998 at91_set_B_periph(AT91_PIN_PA16
, 0); /* CTS2 */
1001 static struct platform_device
*__initdata at91_uarts
[ATMEL_MAX_UART
]; /* the UARTs to use */
1002 struct platform_device
*atmel_default_console_device
; /* the serial console device */
1004 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
)
1006 struct platform_device
*pdev
;
1010 pdev
= &at91sam9261_dbgu_device
;
1011 configure_dbgu_pins();
1012 at91_clock_associate("mck", &pdev
->dev
, "usart");
1014 case AT91SAM9261_ID_US0
:
1015 pdev
= &at91sam9261_uart0_device
;
1016 configure_usart0_pins(pins
);
1017 at91_clock_associate("usart0_clk", &pdev
->dev
, "usart");
1019 case AT91SAM9261_ID_US1
:
1020 pdev
= &at91sam9261_uart1_device
;
1021 configure_usart1_pins(pins
);
1022 at91_clock_associate("usart1_clk", &pdev
->dev
, "usart");
1024 case AT91SAM9261_ID_US2
:
1025 pdev
= &at91sam9261_uart2_device
;
1026 configure_usart2_pins(pins
);
1027 at91_clock_associate("usart2_clk", &pdev
->dev
, "usart");
1032 pdev
->id
= portnr
; /* update to mapped ID */
1034 if (portnr
< ATMEL_MAX_UART
)
1035 at91_uarts
[portnr
] = pdev
;
1038 void __init
at91_set_serial_console(unsigned portnr
)
1040 if (portnr
< ATMEL_MAX_UART
)
1041 atmel_default_console_device
= at91_uarts
[portnr
];
1044 void __init
at91_add_device_serial(void)
1048 for (i
= 0; i
< ATMEL_MAX_UART
; i
++) {
1050 platform_device_register(at91_uarts
[i
]);
1053 if (!atmel_default_console_device
)
1054 printk(KERN_INFO
"AT91: No default serial console defined.\n");
1057 void __init
at91_register_uart(unsigned id
, unsigned portnr
, unsigned pins
) {}
1058 void __init
at91_set_serial_console(unsigned portnr
) {}
1059 void __init
at91_add_device_serial(void) {}
1063 /* -------------------------------------------------------------------- */
1066 * These devices are always present and don't need any board-specific
1069 static int __init
at91_add_standard_devices(void)
1071 at91_add_device_rtt();
1072 at91_add_device_watchdog();
1073 at91_add_device_tc();
1077 arch_initcall(at91_add_standard_devices
);