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/at91sam926x_mc.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)
115 if (data->vbus_pin) {
116 at91_set_gpio_input(data->vbus_pin, 0);
117 at91_set_deglitch(data->vbus_pin, 1);
120 /* Pullup pin is handled internally */
121 x = at91_sys_read(AT91_MATRIX_USBPUCR);
122 at91_sys_write(AT91_MATRIX_USBPUCR, x | AT91_MATRIX_USBPUCR_PUON);
125 platform_device_register(&at91sam9261_udc_device);
128 void __init at91_add_device_udc(struct at91_udc_data *data) {}
131 /* --------------------------------------------------------------------
133 * -------------------------------------------------------------------- */
135 #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE)
136 static u64 mmc_dmamask = DMA_BIT_MASK(32);
137 static struct at91_mmc_data mmc_data;
139 static struct resource mmc_resources[] = {
141 .start = AT91SAM9261_BASE_MCI,
142 .end = AT91SAM9261_BASE_MCI + SZ_16K - 1,
143 .flags = IORESOURCE_MEM,
146 .start = AT91SAM9261_ID_MCI,
147 .end = AT91SAM9261_ID_MCI,
148 .flags = IORESOURCE_IRQ,
152 static struct platform_device at91sam9261_mmc_device = {
156 .dma_mask = &mmc_dmamask,
157 .coherent_dma_mask = DMA_BIT_MASK(32),
158 .platform_data = &mmc_data,
160 .resource = mmc_resources,
161 .num_resources = ARRAY_SIZE(mmc_resources),
164 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data)
171 at91_set_gpio_input(data->det_pin, 1);
172 at91_set_deglitch(data->det_pin, 1);
175 at91_set_gpio_input(data->wp_pin, 1);
177 at91_set_gpio_output(data->vcc_pin, 0);
180 at91_set_B_periph(AT91_PIN_PA2, 0);
183 at91_set_B_periph(AT91_PIN_PA1, 1);
185 /* DAT0, maybe DAT1..DAT3 */
186 at91_set_B_periph(AT91_PIN_PA0, 1);
188 at91_set_B_periph(AT91_PIN_PA4, 1);
189 at91_set_B_periph(AT91_PIN_PA5, 1);
190 at91_set_B_periph(AT91_PIN_PA6, 1);
194 platform_device_register(&at91sam9261_mmc_device);
197 void __init at91_add_device_mmc(short mmc_id, struct at91_mmc_data *data) {}
201 /* --------------------------------------------------------------------
203 * -------------------------------------------------------------------- */
205 #if defined(CONFIG_MTD_NAND_AT91) || defined(CONFIG_MTD_NAND_AT91_MODULE)
206 static struct at91_nand_data nand_data;
208 #define NAND_BASE AT91_CHIPSELECT_3
210 static struct resource nand_resources[] = {
213 .end = NAND_BASE + SZ_256M - 1,
214 .flags = IORESOURCE_MEM,
218 static struct platform_device at91_nand_device = {
222 .platform_data = &nand_data,
224 .resource = nand_resources,
225 .num_resources = ARRAY_SIZE(nand_resources),
228 void __init at91_add_device_nand(struct at91_nand_data *data)
230 unsigned long csa, mode;
235 csa = at91_sys_read(AT91_MATRIX_EBICSA);
236 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_CS3A_SMC_SMARTMEDIA);
238 /* set the bus interface characteristics */
239 at91_sys_write(AT91_SMC_SETUP(3), AT91_SMC_NWESETUP_(0) | AT91_SMC_NCS_WRSETUP_(0)
240 | AT91_SMC_NRDSETUP_(0) | AT91_SMC_NCS_RDSETUP_(0));
242 at91_sys_write(AT91_SMC_PULSE(3), AT91_SMC_NWEPULSE_(2) | AT91_SMC_NCS_WRPULSE_(5)
243 | AT91_SMC_NRDPULSE_(2) | AT91_SMC_NCS_RDPULSE_(5));
245 at91_sys_write(AT91_SMC_CYCLE(3), AT91_SMC_NWECYCLE_(7) | AT91_SMC_NRDCYCLE_(7));
247 if (data->bus_width_16)
248 mode = AT91_SMC_DBW_16;
250 mode = AT91_SMC_DBW_8;
251 at91_sys_write(AT91_SMC_MODE(3), mode | AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_TDF_(1));
254 if (data->enable_pin)
255 at91_set_gpio_output(data->enable_pin, 1);
259 at91_set_gpio_input(data->rdy_pin, 1);
261 /* card detect pin */
263 at91_set_gpio_input(data->det_pin, 1);
265 at91_set_A_periph(AT91_PIN_PC0, 0); /* NANDOE */
266 at91_set_A_periph(AT91_PIN_PC1, 0); /* NANDWE */
269 platform_device_register(&at91_nand_device);
273 void __init at91_add_device_nand(struct at91_nand_data *data) {}
277 /* --------------------------------------------------------------------
279 * -------------------------------------------------------------------- */
282 * Prefer the GPIO code since the TWI controller isn't robust
283 * (gets overruns and underruns under load) and can only issue
284 * repeated STARTs in one scenario (the driver doesn't yet handle them).
286 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
288 static struct i2c_gpio_platform_data pdata = {
289 .sda_pin = AT91_PIN_PA7,
290 .sda_is_open_drain = 1,
291 .scl_pin = AT91_PIN_PA8,
292 .scl_is_open_drain = 1,
293 .udelay = 2, /* ~100 kHz */
296 static struct platform_device at91sam9261_twi_device = {
299 .dev.platform_data = &pdata,
302 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
304 at91_set_GPIO_periph(AT91_PIN_PA7, 1); /* TWD (SDA) */
305 at91_set_multi_drive(AT91_PIN_PA7, 1);
307 at91_set_GPIO_periph(AT91_PIN_PA8, 1); /* TWCK (SCL) */
308 at91_set_multi_drive(AT91_PIN_PA8, 1);
310 i2c_register_board_info(0, devices, nr_devices);
311 platform_device_register(&at91sam9261_twi_device);
314 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
316 static struct resource twi_resources[] = {
318 .start = AT91SAM9261_BASE_TWI,
319 .end = AT91SAM9261_BASE_TWI + SZ_16K - 1,
320 .flags = IORESOURCE_MEM,
323 .start = AT91SAM9261_ID_TWI,
324 .end = AT91SAM9261_ID_TWI,
325 .flags = IORESOURCE_IRQ,
329 static struct platform_device at91sam9261_twi_device = {
332 .resource = twi_resources,
333 .num_resources = ARRAY_SIZE(twi_resources),
336 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices)
338 /* pins used for TWI interface */
339 at91_set_A_periph(AT91_PIN_PA7, 0); /* TWD */
340 at91_set_multi_drive(AT91_PIN_PA7, 1);
342 at91_set_A_periph(AT91_PIN_PA8, 0); /* TWCK */
343 at91_set_multi_drive(AT91_PIN_PA8, 1);
345 i2c_register_board_info(0, devices, nr_devices);
346 platform_device_register(&at91sam9261_twi_device);
349 void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) {}
353 /* --------------------------------------------------------------------
355 * -------------------------------------------------------------------- */
357 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
358 static u64 spi_dmamask = DMA_BIT_MASK(32);
360 static struct resource spi0_resources[] = {
362 .start = AT91SAM9261_BASE_SPI0,
363 .end = AT91SAM9261_BASE_SPI0 + SZ_16K - 1,
364 .flags = IORESOURCE_MEM,
367 .start = AT91SAM9261_ID_SPI0,
368 .end = AT91SAM9261_ID_SPI0,
369 .flags = IORESOURCE_IRQ,
373 static struct platform_device at91sam9261_spi0_device = {
377 .dma_mask = &spi_dmamask,
378 .coherent_dma_mask = DMA_BIT_MASK(32),
380 .resource = spi0_resources,
381 .num_resources = ARRAY_SIZE(spi0_resources),
384 static const unsigned spi0_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
386 static struct resource spi1_resources[] = {
388 .start = AT91SAM9261_BASE_SPI1,
389 .end = AT91SAM9261_BASE_SPI1 + SZ_16K - 1,
390 .flags = IORESOURCE_MEM,
393 .start = AT91SAM9261_ID_SPI1,
394 .end = AT91SAM9261_ID_SPI1,
395 .flags = IORESOURCE_IRQ,
399 static struct platform_device at91sam9261_spi1_device = {
403 .dma_mask = &spi_dmamask,
404 .coherent_dma_mask = DMA_BIT_MASK(32),
406 .resource = spi1_resources,
407 .num_resources = ARRAY_SIZE(spi1_resources),
410 static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB28, AT91_PIN_PA24, AT91_PIN_PA25, AT91_PIN_PA26 };
412 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
415 unsigned long cs_pin;
416 short enable_spi0 = 0;
417 short enable_spi1 = 0;
419 /* Choose SPI chip-selects */
420 for (i = 0; i < nr_devices; i++) {
421 if (devices[i].controller_data)
422 cs_pin = (unsigned long) devices[i].controller_data;
423 else if (devices[i].bus_num == 0)
424 cs_pin = spi0_standard_cs[devices[i].chip_select];
426 cs_pin = spi1_standard_cs[devices[i].chip_select];
428 if (devices[i].bus_num == 0)
433 /* enable chip-select pin */
434 at91_set_gpio_output(cs_pin, 1);
436 /* pass chip-select pin to driver */
437 devices[i].controller_data = (void *) cs_pin;
440 spi_register_board_info(devices, nr_devices);
442 /* Configure SPI bus(es) */
444 at91_set_A_periph(AT91_PIN_PA0, 0); /* SPI0_MISO */
445 at91_set_A_periph(AT91_PIN_PA1, 0); /* SPI0_MOSI */
446 at91_set_A_periph(AT91_PIN_PA2, 0); /* SPI0_SPCK */
448 at91_clock_associate("spi0_clk", &at91sam9261_spi0_device.dev, "spi_clk");
449 platform_device_register(&at91sam9261_spi0_device);
452 at91_set_A_periph(AT91_PIN_PB30, 0); /* SPI1_MISO */
453 at91_set_A_periph(AT91_PIN_PB31, 0); /* SPI1_MOSI */
454 at91_set_A_periph(AT91_PIN_PB29, 0); /* SPI1_SPCK */
456 at91_clock_associate("spi1_clk", &at91sam9261_spi1_device.dev, "spi_clk");
457 platform_device_register(&at91sam9261_spi1_device);
461 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
465 /* --------------------------------------------------------------------
467 * -------------------------------------------------------------------- */
469 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
470 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
471 static struct atmel_lcdfb_info lcdc_data;
473 static struct resource lcdc_resources[] = {
475 .start = AT91SAM9261_LCDC_BASE,
476 .end = AT91SAM9261_LCDC_BASE + SZ_4K - 1,
477 .flags = IORESOURCE_MEM,
480 .start = AT91SAM9261_ID_LCDC,
481 .end = AT91SAM9261_ID_LCDC,
482 .flags = IORESOURCE_IRQ,
484 #if defined(CONFIG_FB_INTSRAM)
486 .start = AT91SAM9261_SRAM_BASE,
487 .end = AT91SAM9261_SRAM_BASE + AT91SAM9261_SRAM_SIZE - 1,
488 .flags = IORESOURCE_MEM,
493 static struct platform_device at91_lcdc_device = {
494 .name = "atmel_lcdfb",
497 .dma_mask = &lcdc_dmamask,
498 .coherent_dma_mask = DMA_BIT_MASK(32),
499 .platform_data = &lcdc_data,
501 .resource = lcdc_resources,
502 .num_resources = ARRAY_SIZE(lcdc_resources),
505 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
511 #if defined(CONFIG_FB_ATMEL_STN)
512 at91_set_A_periph(AT91_PIN_PB0, 0); /* LCDVSYNC */
513 at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */
514 at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */
515 at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */
516 at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */
517 at91_set_A_periph(AT91_PIN_PB5, 0); /* LCDD0 */
518 at91_set_A_periph(AT91_PIN_PB6, 0); /* LCDD1 */
519 at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */
520 at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */
522 at91_set_A_periph(AT91_PIN_PB1, 0); /* LCDHSYNC */
523 at91_set_A_periph(AT91_PIN_PB2, 0); /* LCDDOTCK */
524 at91_set_A_periph(AT91_PIN_PB3, 0); /* LCDDEN */
525 at91_set_A_periph(AT91_PIN_PB4, 0); /* LCDCC */
526 at91_set_A_periph(AT91_PIN_PB7, 0); /* LCDD2 */
527 at91_set_A_periph(AT91_PIN_PB8, 0); /* LCDD3 */
528 at91_set_A_periph(AT91_PIN_PB9, 0); /* LCDD4 */
529 at91_set_A_periph(AT91_PIN_PB10, 0); /* LCDD5 */
530 at91_set_A_periph(AT91_PIN_PB11, 0); /* LCDD6 */
531 at91_set_A_periph(AT91_PIN_PB12, 0); /* LCDD7 */
532 at91_set_A_periph(AT91_PIN_PB15, 0); /* LCDD10 */
533 at91_set_A_periph(AT91_PIN_PB16, 0); /* LCDD11 */
534 at91_set_A_periph(AT91_PIN_PB17, 0); /* LCDD12 */
535 at91_set_A_periph(AT91_PIN_PB18, 0); /* LCDD13 */
536 at91_set_A_periph(AT91_PIN_PB19, 0); /* LCDD14 */
537 at91_set_A_periph(AT91_PIN_PB20, 0); /* LCDD15 */
538 at91_set_B_periph(AT91_PIN_PB23, 0); /* LCDD18 */
539 at91_set_B_periph(AT91_PIN_PB24, 0); /* LCDD19 */
540 at91_set_B_periph(AT91_PIN_PB25, 0); /* LCDD20 */
541 at91_set_B_periph(AT91_PIN_PB26, 0); /* LCDD21 */
542 at91_set_B_periph(AT91_PIN_PB27, 0); /* LCDD22 */
543 at91_set_B_periph(AT91_PIN_PB28, 0); /* LCDD23 */
547 platform_device_register(&at91_lcdc_device);
550 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
554 /* --------------------------------------------------------------------
556 * -------------------------------------------------------------------- */
558 static struct resource rtt_resources[] = {
560 .start = AT91_BASE_SYS + AT91_RTT,
561 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
562 .flags = IORESOURCE_MEM,
566 static struct platform_device at91sam9261_rtt_device = {
569 .resource = rtt_resources,
570 .num_resources = ARRAY_SIZE(rtt_resources),
573 static void __init at91_add_device_rtt(void)
575 platform_device_register(&at91sam9261_rtt_device);
579 /* --------------------------------------------------------------------
581 * -------------------------------------------------------------------- */
583 #if defined(CONFIG_AT91SAM9_WATCHDOG) || defined(CONFIG_AT91SAM9_WATCHDOG_MODULE)
584 static struct platform_device at91sam9261_wdt_device = {
590 static void __init at91_add_device_watchdog(void)
592 platform_device_register(&at91sam9261_wdt_device);
595 static void __init at91_add_device_watchdog(void) {}
599 /* --------------------------------------------------------------------
600 * SSC -- Synchronous Serial Controller
601 * -------------------------------------------------------------------- */
603 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
604 static u64 ssc0_dmamask = DMA_BIT_MASK(32);
606 static struct resource ssc0_resources[] = {
608 .start = AT91SAM9261_BASE_SSC0,
609 .end = AT91SAM9261_BASE_SSC0 + SZ_16K - 1,
610 .flags = IORESOURCE_MEM,
613 .start = AT91SAM9261_ID_SSC0,
614 .end = AT91SAM9261_ID_SSC0,
615 .flags = IORESOURCE_IRQ,
619 static struct platform_device at91sam9261_ssc0_device = {
623 .dma_mask = &ssc0_dmamask,
624 .coherent_dma_mask = DMA_BIT_MASK(32),
626 .resource = ssc0_resources,
627 .num_resources = ARRAY_SIZE(ssc0_resources),
630 static inline void configure_ssc0_pins(unsigned pins)
632 if (pins & ATMEL_SSC_TF)
633 at91_set_A_periph(AT91_PIN_PB21, 1);
634 if (pins & ATMEL_SSC_TK)
635 at91_set_A_periph(AT91_PIN_PB22, 1);
636 if (pins & ATMEL_SSC_TD)
637 at91_set_A_periph(AT91_PIN_PB23, 1);
638 if (pins & ATMEL_SSC_RD)
639 at91_set_A_periph(AT91_PIN_PB24, 1);
640 if (pins & ATMEL_SSC_RK)
641 at91_set_A_periph(AT91_PIN_PB25, 1);
642 if (pins & ATMEL_SSC_RF)
643 at91_set_A_periph(AT91_PIN_PB26, 1);
646 static u64 ssc1_dmamask = DMA_BIT_MASK(32);
648 static struct resource ssc1_resources[] = {
650 .start = AT91SAM9261_BASE_SSC1,
651 .end = AT91SAM9261_BASE_SSC1 + SZ_16K - 1,
652 .flags = IORESOURCE_MEM,
655 .start = AT91SAM9261_ID_SSC1,
656 .end = AT91SAM9261_ID_SSC1,
657 .flags = IORESOURCE_IRQ,
661 static struct platform_device at91sam9261_ssc1_device = {
665 .dma_mask = &ssc1_dmamask,
666 .coherent_dma_mask = DMA_BIT_MASK(32),
668 .resource = ssc1_resources,
669 .num_resources = ARRAY_SIZE(ssc1_resources),
672 static inline void configure_ssc1_pins(unsigned pins)
674 if (pins & ATMEL_SSC_TF)
675 at91_set_B_periph(AT91_PIN_PA17, 1);
676 if (pins & ATMEL_SSC_TK)
677 at91_set_B_periph(AT91_PIN_PA18, 1);
678 if (pins & ATMEL_SSC_TD)
679 at91_set_B_periph(AT91_PIN_PA19, 1);
680 if (pins & ATMEL_SSC_RD)
681 at91_set_B_periph(AT91_PIN_PA20, 1);
682 if (pins & ATMEL_SSC_RK)
683 at91_set_B_periph(AT91_PIN_PA21, 1);
684 if (pins & ATMEL_SSC_RF)
685 at91_set_B_periph(AT91_PIN_PA22, 1);
688 static u64 ssc2_dmamask = DMA_BIT_MASK(32);
690 static struct resource ssc2_resources[] = {
692 .start = AT91SAM9261_BASE_SSC2,
693 .end = AT91SAM9261_BASE_SSC2 + SZ_16K - 1,
694 .flags = IORESOURCE_MEM,
697 .start = AT91SAM9261_ID_SSC2,
698 .end = AT91SAM9261_ID_SSC2,
699 .flags = IORESOURCE_IRQ,
703 static struct platform_device at91sam9261_ssc2_device = {
707 .dma_mask = &ssc2_dmamask,
708 .coherent_dma_mask = DMA_BIT_MASK(32),
710 .resource = ssc2_resources,
711 .num_resources = ARRAY_SIZE(ssc2_resources),
714 static inline void configure_ssc2_pins(unsigned pins)
716 if (pins & ATMEL_SSC_TF)
717 at91_set_B_periph(AT91_PIN_PC25, 1);
718 if (pins & ATMEL_SSC_TK)
719 at91_set_B_periph(AT91_PIN_PC26, 1);
720 if (pins & ATMEL_SSC_TD)
721 at91_set_B_periph(AT91_PIN_PC27, 1);
722 if (pins & ATMEL_SSC_RD)
723 at91_set_B_periph(AT91_PIN_PC28, 1);
724 if (pins & ATMEL_SSC_RK)
725 at91_set_B_periph(AT91_PIN_PC29, 1);
726 if (pins & ATMEL_SSC_RF)
727 at91_set_B_periph(AT91_PIN_PC30, 1);
731 * SSC controllers are accessed through library code, instead of any
732 * kind of all-singing/all-dancing driver. For example one could be
733 * used by a particular I2S audio codec's driver, while another one
734 * on the same system might be used by a custom data capture driver.
736 void __init at91_add_device_ssc(unsigned id, unsigned pins)
738 struct platform_device *pdev;
741 * NOTE: caller is responsible for passing information matching
742 * "pins" to whatever will be using each particular controller.
745 case AT91SAM9261_ID_SSC0:
746 pdev = &at91sam9261_ssc0_device;
747 configure_ssc0_pins(pins);
748 at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");
750 case AT91SAM9261_ID_SSC1:
751 pdev = &at91sam9261_ssc1_device;
752 configure_ssc1_pins(pins);
753 at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");
755 case AT91SAM9261_ID_SSC2:
756 pdev = &at91sam9261_ssc2_device;
757 configure_ssc2_pins(pins);
758 at91_clock_associate("ssc2_clk", &pdev->dev, "pclk");
764 platform_device_register(pdev);
768 void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
772 /* --------------------------------------------------------------------
774 * -------------------------------------------------------------------- */
776 #if defined(CONFIG_SERIAL_ATMEL)
777 static struct resource dbgu_resources[] = {
779 .start = AT91_VA_BASE_SYS + AT91_DBGU,
780 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
781 .flags = IORESOURCE_MEM,
784 .start = AT91_ID_SYS,
786 .flags = IORESOURCE_IRQ,
790 static struct atmel_uart_data dbgu_data = {
792 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
793 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
796 static u64 dbgu_dmamask = DMA_BIT_MASK(32);
798 static struct platform_device at91sam9261_dbgu_device = {
799 .name = "atmel_usart",
802 .dma_mask = &dbgu_dmamask,
803 .coherent_dma_mask = DMA_BIT_MASK(32),
804 .platform_data = &dbgu_data,
806 .resource = dbgu_resources,
807 .num_resources = ARRAY_SIZE(dbgu_resources),
810 static inline void configure_dbgu_pins(void)
812 at91_set_A_periph(AT91_PIN_PA9, 0); /* DRXD */
813 at91_set_A_periph(AT91_PIN_PA10, 1); /* DTXD */
816 static struct resource uart0_resources[] = {
818 .start = AT91SAM9261_BASE_US0,
819 .end = AT91SAM9261_BASE_US0 + SZ_16K - 1,
820 .flags = IORESOURCE_MEM,
823 .start = AT91SAM9261_ID_US0,
824 .end = AT91SAM9261_ID_US0,
825 .flags = IORESOURCE_IRQ,
829 static struct atmel_uart_data uart0_data = {
834 static u64 uart0_dmamask = DMA_BIT_MASK(32);
836 static struct platform_device at91sam9261_uart0_device = {
837 .name = "atmel_usart",
840 .dma_mask = &uart0_dmamask,
841 .coherent_dma_mask = DMA_BIT_MASK(32),
842 .platform_data = &uart0_data,
844 .resource = uart0_resources,
845 .num_resources = ARRAY_SIZE(uart0_resources),
848 static inline void configure_usart0_pins(unsigned pins)
850 at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */
851 at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */
853 if (pins & ATMEL_UART_RTS)
854 at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */
855 if (pins & ATMEL_UART_CTS)
856 at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */
859 static struct resource uart1_resources[] = {
861 .start = AT91SAM9261_BASE_US1,
862 .end = AT91SAM9261_BASE_US1 + SZ_16K - 1,
863 .flags = IORESOURCE_MEM,
866 .start = AT91SAM9261_ID_US1,
867 .end = AT91SAM9261_ID_US1,
868 .flags = IORESOURCE_IRQ,
872 static struct atmel_uart_data uart1_data = {
877 static u64 uart1_dmamask = DMA_BIT_MASK(32);
879 static struct platform_device at91sam9261_uart1_device = {
880 .name = "atmel_usart",
883 .dma_mask = &uart1_dmamask,
884 .coherent_dma_mask = DMA_BIT_MASK(32),
885 .platform_data = &uart1_data,
887 .resource = uart1_resources,
888 .num_resources = ARRAY_SIZE(uart1_resources),
891 static inline void configure_usart1_pins(unsigned pins)
893 at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */
894 at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */
896 if (pins & ATMEL_UART_RTS)
897 at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */
898 if (pins & ATMEL_UART_CTS)
899 at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */
902 static struct resource uart2_resources[] = {
904 .start = AT91SAM9261_BASE_US2,
905 .end = AT91SAM9261_BASE_US2 + SZ_16K - 1,
906 .flags = IORESOURCE_MEM,
909 .start = AT91SAM9261_ID_US2,
910 .end = AT91SAM9261_ID_US2,
911 .flags = IORESOURCE_IRQ,
915 static struct atmel_uart_data uart2_data = {
920 static u64 uart2_dmamask = DMA_BIT_MASK(32);
922 static struct platform_device at91sam9261_uart2_device = {
923 .name = "atmel_usart",
926 .dma_mask = &uart2_dmamask,
927 .coherent_dma_mask = DMA_BIT_MASK(32),
928 .platform_data = &uart2_data,
930 .resource = uart2_resources,
931 .num_resources = ARRAY_SIZE(uart2_resources),
934 static inline void configure_usart2_pins(unsigned pins)
936 at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */
937 at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */
939 if (pins & ATMEL_UART_RTS)
940 at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/
941 if (pins & ATMEL_UART_CTS)
942 at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */
945 static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
946 struct platform_device *atmel_default_console_device; /* the serial console device */
948 void __init __deprecated at91_init_serial(struct at91_uart_config *config)
952 /* Fill in list of supported UARTs */
953 for (i = 0; i < config->nr_tty; i++) {
954 switch (config->tty_map[i]) {
956 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
957 at91_uarts[i] = &at91sam9261_uart0_device;
958 at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart");
961 configure_usart1_pins(0);
962 at91_uarts[i] = &at91sam9261_uart1_device;
963 at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart");
966 configure_usart2_pins(0);
967 at91_uarts[i] = &at91sam9261_uart2_device;
968 at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart");
971 configure_dbgu_pins();
972 at91_uarts[i] = &at91sam9261_dbgu_device;
973 at91_clock_associate("mck", &at91sam9261_dbgu_device.dev, "usart");
978 at91_uarts[i]->id = i; /* update ID number to mapped ID */
981 /* Set serial console device */
982 if (config->console_tty < ATMEL_MAX_UART)
983 atmel_default_console_device = at91_uarts[config->console_tty];
984 if (!atmel_default_console_device)
985 printk(KERN_INFO "AT91: No default serial console defined.\n");
988 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
990 struct platform_device *pdev;
994 pdev = &at91sam9261_dbgu_device;
995 configure_dbgu_pins();
996 at91_clock_associate("mck", &pdev->dev, "usart");
998 case AT91SAM9261_ID_US0:
999 pdev = &at91sam9261_uart0_device;
1000 configure_usart0_pins(pins);
1001 at91_clock_associate("usart0_clk", &pdev->dev, "usart");
1003 case AT91SAM9261_ID_US1:
1004 pdev = &at91sam9261_uart1_device;
1005 configure_usart1_pins(pins);
1006 at91_clock_associate("usart1_clk", &pdev->dev, "usart");
1008 case AT91SAM9261_ID_US2:
1009 pdev = &at91sam9261_uart2_device;
1010 configure_usart2_pins(pins);
1011 at91_clock_associate("usart2_clk", &pdev->dev, "usart");
1016 pdev->id = portnr; /* update to mapped ID */
1018 if (portnr < ATMEL_MAX_UART)
1019 at91_uarts[portnr] = pdev;
1022 void __init at91_set_serial_console(unsigned portnr)
1024 if (portnr < ATMEL_MAX_UART)
1025 atmel_default_console_device = at91_uarts[portnr];
1026 if (!atmel_default_console_device)
1027 printk(KERN_INFO "AT91: No default serial console defined.\n");
1030 void __init at91_add_device_serial(void)
1034 for (i = 0; i < ATMEL_MAX_UART; i++) {
1036 platform_device_register(at91_uarts[i]);
1040 void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1041 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1042 void __init at91_set_serial_console(unsigned portnr) {}
1043 void __init at91_add_device_serial(void) {}
1047 /* -------------------------------------------------------------------- */
1050 * These devices are always present and don't need any board-specific
1053 static int __init at91_add_standard_devices(void)
1055 at91_add_device_rtt();
1056 at91_add_device_watchdog();
1060 arch_initcall(at91_add_standard_devices);