2 * On-Chip devices setup code for the AT91SAM9G45 family
4 * Copyright (C) 2009 Atmel Corporation.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <asm/mach/arch.h>
13 #include <asm/mach/map.h>
15 #include <linux/dma-mapping.h>
16 #include <linux/platform_device.h>
17 #include <linux/i2c-gpio.h>
20 #include <video/atmel_lcdc.h>
22 #include <mach/board.h>
23 #include <mach/gpio.h>
24 #include <mach/at91sam9g45.h>
25 #include <mach/at91sam9g45_matrix.h>
26 #include <mach/at91sam9_smc.h>
27 #include <mach/at_hdmac.h>
32 /* --------------------------------------------------------------------
33 * HDMAC - AHB DMA Controller
34 * -------------------------------------------------------------------- */
36 #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
37 static u64 hdmac_dmamask = DMA_BIT_MASK(32);
39 static struct at_dma_platform_data atdma_pdata = {
43 static struct resource hdmac_resources[] = {
45 .start = AT91_BASE_SYS + AT91_DMA,
46 .end = AT91_BASE_SYS + AT91_DMA + SZ_512 - 1,
47 .flags = IORESOURCE_MEM,
50 .start = AT91SAM9G45_ID_DMA,
51 .end = AT91SAM9G45_ID_DMA,
52 .flags = IORESOURCE_IRQ,
56 static struct platform_device at_hdmac_device = {
60 .dma_mask = &hdmac_dmamask,
61 .coherent_dma_mask = DMA_BIT_MASK(32),
62 .platform_data = &atdma_pdata,
64 .resource = hdmac_resources,
65 .num_resources = ARRAY_SIZE(hdmac_resources),
68 void __init at91_add_device_hdmac(void)
70 dma_cap_set(DMA_MEMCPY, atdma_pdata.cap_mask);
71 dma_cap_set(DMA_SLAVE, atdma_pdata.cap_mask);
72 platform_device_register(&at_hdmac_device);
75 void __init at91_add_device_hdmac(void) {}
79 /* --------------------------------------------------------------------
81 * -------------------------------------------------------------------- */
83 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
84 static u64 ohci_dmamask = DMA_BIT_MASK(32);
85 static struct at91_usbh_data usbh_ohci_data;
87 static struct resource usbh_ohci_resources[] = {
89 .start = AT91SAM9G45_OHCI_BASE,
90 .end = AT91SAM9G45_OHCI_BASE + SZ_1M - 1,
91 .flags = IORESOURCE_MEM,
94 .start = AT91SAM9G45_ID_UHPHS,
95 .end = AT91SAM9G45_ID_UHPHS,
96 .flags = IORESOURCE_IRQ,
100 static struct platform_device at91_usbh_ohci_device = {
104 .dma_mask = &ohci_dmamask,
105 .coherent_dma_mask = DMA_BIT_MASK(32),
106 .platform_data = &usbh_ohci_data,
108 .resource = usbh_ohci_resources,
109 .num_resources = ARRAY_SIZE(usbh_ohci_resources),
112 void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
119 /* Enable VBus control for UHP ports */
120 for (i = 0; i < data->ports; i++) {
121 if (data->vbus_pin[i])
122 at91_set_gpio_output(data->vbus_pin[i], 0);
125 usbh_ohci_data = *data;
126 platform_device_register(&at91_usbh_ohci_device);
129 void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) {}
133 /* --------------------------------------------------------------------
135 * Needs an OHCI host for low and full speed management
136 * -------------------------------------------------------------------- */
138 #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
139 static u64 ehci_dmamask = DMA_BIT_MASK(32);
140 static struct at91_usbh_data usbh_ehci_data;
142 static struct resource usbh_ehci_resources[] = {
144 .start = AT91SAM9G45_EHCI_BASE,
145 .end = AT91SAM9G45_EHCI_BASE + SZ_1M - 1,
146 .flags = IORESOURCE_MEM,
149 .start = AT91SAM9G45_ID_UHPHS,
150 .end = AT91SAM9G45_ID_UHPHS,
151 .flags = IORESOURCE_IRQ,
155 static struct platform_device at91_usbh_ehci_device = {
156 .name = "atmel-ehci",
159 .dma_mask = &ehci_dmamask,
160 .coherent_dma_mask = DMA_BIT_MASK(32),
161 .platform_data = &usbh_ehci_data,
163 .resource = usbh_ehci_resources,
164 .num_resources = ARRAY_SIZE(usbh_ehci_resources),
167 void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)
174 /* Enable VBus control for UHP ports */
175 for (i = 0; i < data->ports; i++) {
176 if (data->vbus_pin[i])
177 at91_set_gpio_output(data->vbus_pin[i], 0);
180 usbh_ehci_data = *data;
181 at91_clock_associate("uhphs_clk", &at91_usbh_ehci_device.dev, "ehci_clk");
182 platform_device_register(&at91_usbh_ehci_device);
185 void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}
189 /* --------------------------------------------------------------------
190 * USB HS Device (Gadget)
191 * -------------------------------------------------------------------- */
193 #if defined(CONFIG_USB_GADGET_ATMEL_USBA) || defined(CONFIG_USB_GADGET_ATMEL_USBA_MODULE)
194 static struct resource usba_udc_resources[] = {
196 .start = AT91SAM9G45_UDPHS_FIFO,
197 .end = AT91SAM9G45_UDPHS_FIFO + SZ_512K - 1,
198 .flags = IORESOURCE_MEM,
201 .start = AT91SAM9G45_BASE_UDPHS,
202 .end = AT91SAM9G45_BASE_UDPHS + SZ_1K - 1,
203 .flags = IORESOURCE_MEM,
206 .start = AT91SAM9G45_ID_UDPHS,
207 .end = AT91SAM9G45_ID_UDPHS,
208 .flags = IORESOURCE_IRQ,
212 #define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
216 .fifo_size = maxpkt, \
222 static struct usba_ep_data usba_udc_ep[] __initdata = {
223 EP("ep0", 0, 64, 1, 0, 0),
224 EP("ep1", 1, 1024, 2, 1, 1),
225 EP("ep2", 2, 1024, 2, 1, 1),
226 EP("ep3", 3, 1024, 3, 1, 0),
227 EP("ep4", 4, 1024, 3, 1, 0),
228 EP("ep5", 5, 1024, 3, 1, 1),
229 EP("ep6", 6, 1024, 3, 1, 1),
235 * pdata doesn't have room for any endpoints, so we need to
236 * append room for the ones we need right after it.
239 struct usba_platform_data pdata;
240 struct usba_ep_data ep[7];
243 static struct platform_device at91_usba_udc_device = {
244 .name = "atmel_usba_udc",
247 .platform_data = &usba_udc_data.pdata,
249 .resource = usba_udc_resources,
250 .num_resources = ARRAY_SIZE(usba_udc_resources),
253 void __init at91_add_device_usba(struct usba_platform_data *data)
255 usba_udc_data.pdata.vbus_pin = -EINVAL;
256 usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
257 memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));;
259 if (data && data->vbus_pin > 0) {
260 at91_set_gpio_input(data->vbus_pin, 0);
261 at91_set_deglitch(data->vbus_pin, 1);
262 usba_udc_data.pdata.vbus_pin = data->vbus_pin;
265 /* Pullup pin is handled internally by USB device peripheral */
268 at91_clock_associate("utmi_clk", &at91_usba_udc_device.dev, "hclk");
269 at91_clock_associate("udphs_clk", &at91_usba_udc_device.dev, "pclk");
271 platform_device_register(&at91_usba_udc_device);
274 void __init at91_add_device_usba(struct usba_platform_data *data) {}
278 /* --------------------------------------------------------------------
280 * -------------------------------------------------------------------- */
282 #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)
283 static u64 eth_dmamask = DMA_BIT_MASK(32);
284 static struct at91_eth_data eth_data;
286 static struct resource eth_resources[] = {
288 .start = AT91SAM9G45_BASE_EMAC,
289 .end = AT91SAM9G45_BASE_EMAC + SZ_16K - 1,
290 .flags = IORESOURCE_MEM,
293 .start = AT91SAM9G45_ID_EMAC,
294 .end = AT91SAM9G45_ID_EMAC,
295 .flags = IORESOURCE_IRQ,
299 static struct platform_device at91sam9g45_eth_device = {
303 .dma_mask = ð_dmamask,
304 .coherent_dma_mask = DMA_BIT_MASK(32),
305 .platform_data = ð_data,
307 .resource = eth_resources,
308 .num_resources = ARRAY_SIZE(eth_resources),
311 void __init at91_add_device_eth(struct at91_eth_data *data)
316 if (data->phy_irq_pin) {
317 at91_set_gpio_input(data->phy_irq_pin, 0);
318 at91_set_deglitch(data->phy_irq_pin, 1);
321 /* Pins used for MII and RMII */
322 at91_set_A_periph(AT91_PIN_PA17, 0); /* ETXCK_EREFCK */
323 at91_set_A_periph(AT91_PIN_PA15, 0); /* ERXDV */
324 at91_set_A_periph(AT91_PIN_PA12, 0); /* ERX0 */
325 at91_set_A_periph(AT91_PIN_PA13, 0); /* ERX1 */
326 at91_set_A_periph(AT91_PIN_PA16, 0); /* ERXER */
327 at91_set_A_periph(AT91_PIN_PA14, 0); /* ETXEN */
328 at91_set_A_periph(AT91_PIN_PA10, 0); /* ETX0 */
329 at91_set_A_periph(AT91_PIN_PA11, 0); /* ETX1 */
330 at91_set_A_periph(AT91_PIN_PA19, 0); /* EMDIO */
331 at91_set_A_periph(AT91_PIN_PA18, 0); /* EMDC */
333 if (!data->is_rmii) {
334 at91_set_B_periph(AT91_PIN_PA29, 0); /* ECRS */
335 at91_set_B_periph(AT91_PIN_PA30, 0); /* ECOL */
336 at91_set_B_periph(AT91_PIN_PA8, 0); /* ERX2 */
337 at91_set_B_periph(AT91_PIN_PA9, 0); /* ERX3 */
338 at91_set_B_periph(AT91_PIN_PA28, 0); /* ERXCK */
339 at91_set_B_periph(AT91_PIN_PA6, 0); /* ETX2 */
340 at91_set_B_periph(AT91_PIN_PA7, 0); /* ETX3 */
341 at91_set_B_periph(AT91_PIN_PA27, 0); /* ETXER */
345 platform_device_register(&at91sam9g45_eth_device);
348 void __init at91_add_device_eth(struct at91_eth_data *data) {}
352 /* --------------------------------------------------------------------
354 * -------------------------------------------------------------------- */
356 #if defined(CONFIG_MTD_NAND_ATMEL) || defined(CONFIG_MTD_NAND_ATMEL_MODULE)
357 static struct atmel_nand_data nand_data;
359 #define NAND_BASE AT91_CHIPSELECT_3
361 static struct resource nand_resources[] = {
364 .end = NAND_BASE + SZ_256M - 1,
365 .flags = IORESOURCE_MEM,
368 .start = AT91_BASE_SYS + AT91_ECC,
369 .end = AT91_BASE_SYS + AT91_ECC + SZ_512 - 1,
370 .flags = IORESOURCE_MEM,
374 static struct platform_device at91sam9g45_nand_device = {
375 .name = "atmel_nand",
378 .platform_data = &nand_data,
380 .resource = nand_resources,
381 .num_resources = ARRAY_SIZE(nand_resources),
384 void __init at91_add_device_nand(struct atmel_nand_data *data)
391 csa = at91_sys_read(AT91_MATRIX_EBICSA);
392 at91_sys_write(AT91_MATRIX_EBICSA, csa | AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA);
395 if (data->enable_pin)
396 at91_set_gpio_output(data->enable_pin, 1);
400 at91_set_gpio_input(data->rdy_pin, 1);
402 /* card detect pin */
404 at91_set_gpio_input(data->det_pin, 1);
407 platform_device_register(&at91sam9g45_nand_device);
410 void __init at91_add_device_nand(struct atmel_nand_data *data) {}
414 /* --------------------------------------------------------------------
416 * -------------------------------------------------------------------- */
419 * Prefer the GPIO code since the TWI controller isn't robust
420 * (gets overruns and underruns under load) and can only issue
421 * repeated STARTs in one scenario (the driver doesn't yet handle them).
423 #if defined(CONFIG_I2C_GPIO) || defined(CONFIG_I2C_GPIO_MODULE)
424 static struct i2c_gpio_platform_data pdata_i2c0 = {
425 .sda_pin = AT91_PIN_PA20,
426 .sda_is_open_drain = 1,
427 .scl_pin = AT91_PIN_PA21,
428 .scl_is_open_drain = 1,
429 .udelay = 2, /* ~100 kHz */
432 static struct platform_device at91sam9g45_twi0_device = {
435 .dev.platform_data = &pdata_i2c0,
438 static struct i2c_gpio_platform_data pdata_i2c1 = {
439 .sda_pin = AT91_PIN_PB10,
440 .sda_is_open_drain = 1,
441 .scl_pin = AT91_PIN_PB11,
442 .scl_is_open_drain = 1,
443 .udelay = 2, /* ~100 kHz */
446 static struct platform_device at91sam9g45_twi1_device = {
449 .dev.platform_data = &pdata_i2c1,
452 void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
454 i2c_register_board_info(i2c_id, devices, nr_devices);
457 at91_set_GPIO_periph(AT91_PIN_PA20, 1); /* TWD (SDA) */
458 at91_set_multi_drive(AT91_PIN_PA20, 1);
460 at91_set_GPIO_periph(AT91_PIN_PA21, 1); /* TWCK (SCL) */
461 at91_set_multi_drive(AT91_PIN_PA21, 1);
463 platform_device_register(&at91sam9g45_twi0_device);
465 at91_set_GPIO_periph(AT91_PIN_PB10, 1); /* TWD (SDA) */
466 at91_set_multi_drive(AT91_PIN_PB10, 1);
468 at91_set_GPIO_periph(AT91_PIN_PB11, 1); /* TWCK (SCL) */
469 at91_set_multi_drive(AT91_PIN_PB11, 1);
471 platform_device_register(&at91sam9g45_twi1_device);
475 #elif defined(CONFIG_I2C_AT91) || defined(CONFIG_I2C_AT91_MODULE)
476 static struct resource twi0_resources[] = {
478 .start = AT91SAM9G45_BASE_TWI0,
479 .end = AT91SAM9G45_BASE_TWI0 + SZ_16K - 1,
480 .flags = IORESOURCE_MEM,
483 .start = AT91SAM9G45_ID_TWI0,
484 .end = AT91SAM9G45_ID_TWI0,
485 .flags = IORESOURCE_IRQ,
489 static struct platform_device at91sam9g45_twi0_device = {
492 .resource = twi0_resources,
493 .num_resources = ARRAY_SIZE(twi0_resources),
496 static struct resource twi1_resources[] = {
498 .start = AT91SAM9G45_BASE_TWI1,
499 .end = AT91SAM9G45_BASE_TWI1 + SZ_16K - 1,
500 .flags = IORESOURCE_MEM,
503 .start = AT91SAM9G45_ID_TWI1,
504 .end = AT91SAM9G45_ID_TWI1,
505 .flags = IORESOURCE_IRQ,
509 static struct platform_device at91sam9g45_twi1_device = {
512 .resource = twi1_resources,
513 .num_resources = ARRAY_SIZE(twi1_resources),
516 void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices)
518 i2c_register_board_info(i2c_id, devices, nr_devices);
520 /* pins used for TWI interface */
522 at91_set_A_periph(AT91_PIN_PA20, 0); /* TWD */
523 at91_set_multi_drive(AT91_PIN_PA20, 1);
525 at91_set_A_periph(AT91_PIN_PA21, 0); /* TWCK */
526 at91_set_multi_drive(AT91_PIN_PA21, 1);
528 platform_device_register(&at91sam9g45_twi0_device);
530 at91_set_A_periph(AT91_PIN_PB10, 0); /* TWD */
531 at91_set_multi_drive(AT91_PIN_PB10, 1);
533 at91_set_A_periph(AT91_PIN_PB11, 0); /* TWCK */
534 at91_set_multi_drive(AT91_PIN_PB11, 1);
536 platform_device_register(&at91sam9g45_twi1_device);
540 void __init at91_add_device_i2c(short i2c_id, struct i2c_board_info *devices, int nr_devices) {}
544 /* --------------------------------------------------------------------
546 * -------------------------------------------------------------------- */
548 #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
549 static u64 spi_dmamask = DMA_BIT_MASK(32);
551 static struct resource spi0_resources[] = {
553 .start = AT91SAM9G45_BASE_SPI0,
554 .end = AT91SAM9G45_BASE_SPI0 + SZ_16K - 1,
555 .flags = IORESOURCE_MEM,
558 .start = AT91SAM9G45_ID_SPI0,
559 .end = AT91SAM9G45_ID_SPI0,
560 .flags = IORESOURCE_IRQ,
564 static struct platform_device at91sam9g45_spi0_device = {
568 .dma_mask = &spi_dmamask,
569 .coherent_dma_mask = DMA_BIT_MASK(32),
571 .resource = spi0_resources,
572 .num_resources = ARRAY_SIZE(spi0_resources),
575 static const unsigned spi0_standard_cs[4] = { AT91_PIN_PB3, AT91_PIN_PB18, AT91_PIN_PB19, AT91_PIN_PD27 };
577 static struct resource spi1_resources[] = {
579 .start = AT91SAM9G45_BASE_SPI1,
580 .end = AT91SAM9G45_BASE_SPI1 + SZ_16K - 1,
581 .flags = IORESOURCE_MEM,
584 .start = AT91SAM9G45_ID_SPI1,
585 .end = AT91SAM9G45_ID_SPI1,
586 .flags = IORESOURCE_IRQ,
590 static struct platform_device at91sam9g45_spi1_device = {
594 .dma_mask = &spi_dmamask,
595 .coherent_dma_mask = DMA_BIT_MASK(32),
597 .resource = spi1_resources,
598 .num_resources = ARRAY_SIZE(spi1_resources),
601 static const unsigned spi1_standard_cs[4] = { AT91_PIN_PB17, AT91_PIN_PD28, AT91_PIN_PD18, AT91_PIN_PD19 };
603 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
606 unsigned long cs_pin;
607 short enable_spi0 = 0;
608 short enable_spi1 = 0;
610 /* Choose SPI chip-selects */
611 for (i = 0; i < nr_devices; i++) {
612 if (devices[i].controller_data)
613 cs_pin = (unsigned long) devices[i].controller_data;
614 else if (devices[i].bus_num == 0)
615 cs_pin = spi0_standard_cs[devices[i].chip_select];
617 cs_pin = spi1_standard_cs[devices[i].chip_select];
619 if (devices[i].bus_num == 0)
624 /* enable chip-select pin */
625 at91_set_gpio_output(cs_pin, 1);
627 /* pass chip-select pin to driver */
628 devices[i].controller_data = (void *) cs_pin;
631 spi_register_board_info(devices, nr_devices);
633 /* Configure SPI bus(es) */
635 at91_set_A_periph(AT91_PIN_PB0, 0); /* SPI0_MISO */
636 at91_set_A_periph(AT91_PIN_PB1, 0); /* SPI0_MOSI */
637 at91_set_A_periph(AT91_PIN_PB2, 0); /* SPI0_SPCK */
639 at91_clock_associate("spi0_clk", &at91sam9g45_spi0_device.dev, "spi_clk");
640 platform_device_register(&at91sam9g45_spi0_device);
643 at91_set_A_periph(AT91_PIN_PB14, 0); /* SPI1_MISO */
644 at91_set_A_periph(AT91_PIN_PB15, 0); /* SPI1_MOSI */
645 at91_set_A_periph(AT91_PIN_PB16, 0); /* SPI1_SPCK */
647 at91_clock_associate("spi1_clk", &at91sam9g45_spi1_device.dev, "spi_clk");
648 platform_device_register(&at91sam9g45_spi1_device);
652 void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
656 /* --------------------------------------------------------------------
658 * -------------------------------------------------------------------- */
660 #if defined(CONFIG_SND_ATMEL_AC97C) || defined(CONFIG_SND_ATMEL_AC97C_MODULE)
661 static u64 ac97_dmamask = DMA_BIT_MASK(32);
662 static struct ac97c_platform_data ac97_data;
664 static struct resource ac97_resources[] = {
666 .start = AT91SAM9G45_BASE_AC97C,
667 .end = AT91SAM9G45_BASE_AC97C + SZ_16K - 1,
668 .flags = IORESOURCE_MEM,
671 .start = AT91SAM9G45_ID_AC97C,
672 .end = AT91SAM9G45_ID_AC97C,
673 .flags = IORESOURCE_IRQ,
677 static struct platform_device at91sam9g45_ac97_device = {
678 .name = "atmel_ac97c",
681 .dma_mask = &ac97_dmamask,
682 .coherent_dma_mask = DMA_BIT_MASK(32),
683 .platform_data = &ac97_data,
685 .resource = ac97_resources,
686 .num_resources = ARRAY_SIZE(ac97_resources),
689 void __init at91_add_device_ac97(struct ac97c_platform_data *data)
694 at91_set_A_periph(AT91_PIN_PD8, 0); /* AC97FS */
695 at91_set_A_periph(AT91_PIN_PD9, 0); /* AC97CK */
696 at91_set_A_periph(AT91_PIN_PD7, 0); /* AC97TX */
697 at91_set_A_periph(AT91_PIN_PD6, 0); /* AC97RX */
701 at91_set_gpio_output(data->reset_pin, 0);
704 platform_device_register(&at91sam9g45_ac97_device);
707 void __init at91_add_device_ac97(struct ac97c_platform_data *data) {}
711 /* --------------------------------------------------------------------
713 * -------------------------------------------------------------------- */
715 #if defined(CONFIG_FB_ATMEL) || defined(CONFIG_FB_ATMEL_MODULE)
716 static u64 lcdc_dmamask = DMA_BIT_MASK(32);
717 static struct atmel_lcdfb_info lcdc_data;
719 static struct resource lcdc_resources[] = {
721 .start = AT91SAM9G45_LCDC_BASE,
722 .end = AT91SAM9G45_LCDC_BASE + SZ_4K - 1,
723 .flags = IORESOURCE_MEM,
726 .start = AT91SAM9G45_ID_LCDC,
727 .end = AT91SAM9G45_ID_LCDC,
728 .flags = IORESOURCE_IRQ,
732 static struct platform_device at91_lcdc_device = {
733 .name = "atmel_lcdfb",
736 .dma_mask = &lcdc_dmamask,
737 .coherent_dma_mask = DMA_BIT_MASK(32),
738 .platform_data = &lcdc_data,
740 .resource = lcdc_resources,
741 .num_resources = ARRAY_SIZE(lcdc_resources),
744 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data)
749 at91_set_A_periph(AT91_PIN_PE0, 0); /* LCDDPWR */
751 at91_set_A_periph(AT91_PIN_PE2, 0); /* LCDCC */
752 at91_set_A_periph(AT91_PIN_PE3, 0); /* LCDVSYNC */
753 at91_set_A_periph(AT91_PIN_PE4, 0); /* LCDHSYNC */
754 at91_set_A_periph(AT91_PIN_PE5, 0); /* LCDDOTCK */
755 at91_set_A_periph(AT91_PIN_PE6, 0); /* LCDDEN */
756 at91_set_A_periph(AT91_PIN_PE7, 0); /* LCDD0 */
757 at91_set_A_periph(AT91_PIN_PE8, 0); /* LCDD1 */
758 at91_set_A_periph(AT91_PIN_PE9, 0); /* LCDD2 */
759 at91_set_A_periph(AT91_PIN_PE10, 0); /* LCDD3 */
760 at91_set_A_periph(AT91_PIN_PE11, 0); /* LCDD4 */
761 at91_set_A_periph(AT91_PIN_PE12, 0); /* LCDD5 */
762 at91_set_A_periph(AT91_PIN_PE13, 0); /* LCDD6 */
763 at91_set_A_periph(AT91_PIN_PE14, 0); /* LCDD7 */
764 at91_set_A_periph(AT91_PIN_PE15, 0); /* LCDD8 */
765 at91_set_A_periph(AT91_PIN_PE16, 0); /* LCDD9 */
766 at91_set_A_periph(AT91_PIN_PE17, 0); /* LCDD10 */
767 at91_set_A_periph(AT91_PIN_PE18, 0); /* LCDD11 */
768 at91_set_A_periph(AT91_PIN_PE19, 0); /* LCDD12 */
769 at91_set_A_periph(AT91_PIN_PE20, 0); /* LCDD13 */
770 at91_set_A_periph(AT91_PIN_PE21, 0); /* LCDD14 */
771 at91_set_A_periph(AT91_PIN_PE22, 0); /* LCDD15 */
772 at91_set_A_periph(AT91_PIN_PE23, 0); /* LCDD16 */
773 at91_set_A_periph(AT91_PIN_PE24, 0); /* LCDD17 */
774 at91_set_A_periph(AT91_PIN_PE25, 0); /* LCDD18 */
775 at91_set_A_periph(AT91_PIN_PE26, 0); /* LCDD19 */
776 at91_set_A_periph(AT91_PIN_PE27, 0); /* LCDD20 */
777 at91_set_A_periph(AT91_PIN_PE28, 0); /* LCDD21 */
778 at91_set_A_periph(AT91_PIN_PE29, 0); /* LCDD22 */
779 at91_set_A_periph(AT91_PIN_PE30, 0); /* LCDD23 */
782 platform_device_register(&at91_lcdc_device);
785 void __init at91_add_device_lcdc(struct atmel_lcdfb_info *data) {}
789 /* --------------------------------------------------------------------
790 * Timer/Counter block
791 * -------------------------------------------------------------------- */
793 #ifdef CONFIG_ATMEL_TCLIB
794 static struct resource tcb0_resources[] = {
796 .start = AT91SAM9G45_BASE_TCB0,
797 .end = AT91SAM9G45_BASE_TCB0 + SZ_16K - 1,
798 .flags = IORESOURCE_MEM,
801 .start = AT91SAM9G45_ID_TCB,
802 .end = AT91SAM9G45_ID_TCB,
803 .flags = IORESOURCE_IRQ,
807 static struct platform_device at91sam9g45_tcb0_device = {
810 .resource = tcb0_resources,
811 .num_resources = ARRAY_SIZE(tcb0_resources),
814 /* TCB1 begins with TC3 */
815 static struct resource tcb1_resources[] = {
817 .start = AT91SAM9G45_BASE_TCB1,
818 .end = AT91SAM9G45_BASE_TCB1 + SZ_16K - 1,
819 .flags = IORESOURCE_MEM,
822 .start = AT91SAM9G45_ID_TCB,
823 .end = AT91SAM9G45_ID_TCB,
824 .flags = IORESOURCE_IRQ,
828 static struct platform_device at91sam9g45_tcb1_device = {
831 .resource = tcb1_resources,
832 .num_resources = ARRAY_SIZE(tcb1_resources),
835 static void __init at91_add_device_tc(void)
837 /* this chip has one clock and irq for all six TC channels */
838 at91_clock_associate("tcb0_clk", &at91sam9g45_tcb0_device.dev, "t0_clk");
839 platform_device_register(&at91sam9g45_tcb0_device);
840 at91_clock_associate("tcb1_clk", &at91sam9g45_tcb1_device.dev, "t0_clk");
841 platform_device_register(&at91sam9g45_tcb1_device);
844 static void __init at91_add_device_tc(void) { }
848 /* --------------------------------------------------------------------
850 * -------------------------------------------------------------------- */
852 #if defined(CONFIG_RTC_DRV_AT91RM9200) || defined(CONFIG_RTC_DRV_AT91RM9200_MODULE)
853 static struct platform_device at91sam9g45_rtc_device = {
859 static void __init at91_add_device_rtc(void)
861 platform_device_register(&at91sam9g45_rtc_device);
864 static void __init at91_add_device_rtc(void) {}
868 /* --------------------------------------------------------------------
870 * -------------------------------------------------------------------- */
872 #if defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC) || defined(CONFIG_TOUCHSCREEN_ATMEL_TSADCC_MODULE)
873 static u64 tsadcc_dmamask = DMA_BIT_MASK(32);
874 static struct at91_tsadcc_data tsadcc_data;
876 static struct resource tsadcc_resources[] = {
878 .start = AT91SAM9G45_BASE_TSC,
879 .end = AT91SAM9G45_BASE_TSC + SZ_16K - 1,
880 .flags = IORESOURCE_MEM,
883 .start = AT91SAM9G45_ID_TSC,
884 .end = AT91SAM9G45_ID_TSC,
885 .flags = IORESOURCE_IRQ,
889 static struct platform_device at91sam9g45_tsadcc_device = {
890 .name = "atmel_tsadcc",
893 .dma_mask = &tsadcc_dmamask,
894 .coherent_dma_mask = DMA_BIT_MASK(32),
895 .platform_data = &tsadcc_data,
897 .resource = tsadcc_resources,
898 .num_resources = ARRAY_SIZE(tsadcc_resources),
901 void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data)
906 at91_set_gpio_input(AT91_PIN_PD20, 0); /* AD0_XR */
907 at91_set_gpio_input(AT91_PIN_PD21, 0); /* AD1_XL */
908 at91_set_gpio_input(AT91_PIN_PD22, 0); /* AD2_YT */
909 at91_set_gpio_input(AT91_PIN_PD23, 0); /* AD3_TB */
912 platform_device_register(&at91sam9g45_tsadcc_device);
915 void __init at91_add_device_tsadcc(struct at91_tsadcc_data *data) {}
919 /* --------------------------------------------------------------------
921 * -------------------------------------------------------------------- */
923 static struct resource rtt_resources[] = {
925 .start = AT91_BASE_SYS + AT91_RTT,
926 .end = AT91_BASE_SYS + AT91_RTT + SZ_16 - 1,
927 .flags = IORESOURCE_MEM,
931 static struct platform_device at91sam9g45_rtt_device = {
934 .resource = rtt_resources,
935 .num_resources = ARRAY_SIZE(rtt_resources),
938 static void __init at91_add_device_rtt(void)
940 platform_device_register(&at91sam9g45_rtt_device);
944 /* --------------------------------------------------------------------
946 * -------------------------------------------------------------------- */
948 #if defined(CONFIG_AT91SAM9X_WATCHDOG) || defined(CONFIG_AT91SAM9X_WATCHDOG_MODULE)
949 static struct platform_device at91sam9g45_wdt_device = {
955 static void __init at91_add_device_watchdog(void)
957 platform_device_register(&at91sam9g45_wdt_device);
960 static void __init at91_add_device_watchdog(void) {}
964 /* --------------------------------------------------------------------
966 * --------------------------------------------------------------------*/
968 #if defined(CONFIG_ATMEL_PWM) || defined(CONFIG_ATMEL_PWM_MODULE)
971 static struct resource pwm_resources[] = {
973 .start = AT91SAM9G45_BASE_PWMC,
974 .end = AT91SAM9G45_BASE_PWMC + SZ_16K - 1,
975 .flags = IORESOURCE_MEM,
978 .start = AT91SAM9G45_ID_PWMC,
979 .end = AT91SAM9G45_ID_PWMC,
980 .flags = IORESOURCE_IRQ,
984 static struct platform_device at91sam9g45_pwm0_device = {
988 .platform_data = &pwm_mask,
990 .resource = pwm_resources,
991 .num_resources = ARRAY_SIZE(pwm_resources),
994 void __init at91_add_device_pwm(u32 mask)
996 if (mask & (1 << AT91_PWM0))
997 at91_set_B_periph(AT91_PIN_PD24, 1); /* enable PWM0 */
999 if (mask & (1 << AT91_PWM1))
1000 at91_set_B_periph(AT91_PIN_PD31, 1); /* enable PWM1 */
1002 if (mask & (1 << AT91_PWM2))
1003 at91_set_B_periph(AT91_PIN_PD26, 1); /* enable PWM2 */
1005 if (mask & (1 << AT91_PWM3))
1006 at91_set_B_periph(AT91_PIN_PD0, 1); /* enable PWM3 */
1010 platform_device_register(&at91sam9g45_pwm0_device);
1013 void __init at91_add_device_pwm(u32 mask) {}
1017 /* --------------------------------------------------------------------
1018 * SSC -- Synchronous Serial Controller
1019 * -------------------------------------------------------------------- */
1021 #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE)
1022 static u64 ssc0_dmamask = DMA_BIT_MASK(32);
1024 static struct resource ssc0_resources[] = {
1026 .start = AT91SAM9G45_BASE_SSC0,
1027 .end = AT91SAM9G45_BASE_SSC0 + SZ_16K - 1,
1028 .flags = IORESOURCE_MEM,
1031 .start = AT91SAM9G45_ID_SSC0,
1032 .end = AT91SAM9G45_ID_SSC0,
1033 .flags = IORESOURCE_IRQ,
1037 static struct platform_device at91sam9g45_ssc0_device = {
1041 .dma_mask = &ssc0_dmamask,
1042 .coherent_dma_mask = DMA_BIT_MASK(32),
1044 .resource = ssc0_resources,
1045 .num_resources = ARRAY_SIZE(ssc0_resources),
1048 static inline void configure_ssc0_pins(unsigned pins)
1050 if (pins & ATMEL_SSC_TF)
1051 at91_set_A_periph(AT91_PIN_PD1, 1);
1052 if (pins & ATMEL_SSC_TK)
1053 at91_set_A_periph(AT91_PIN_PD0, 1);
1054 if (pins & ATMEL_SSC_TD)
1055 at91_set_A_periph(AT91_PIN_PD2, 1);
1056 if (pins & ATMEL_SSC_RD)
1057 at91_set_A_periph(AT91_PIN_PD3, 1);
1058 if (pins & ATMEL_SSC_RK)
1059 at91_set_A_periph(AT91_PIN_PD4, 1);
1060 if (pins & ATMEL_SSC_RF)
1061 at91_set_A_periph(AT91_PIN_PD5, 1);
1064 static u64 ssc1_dmamask = DMA_BIT_MASK(32);
1066 static struct resource ssc1_resources[] = {
1068 .start = AT91SAM9G45_BASE_SSC1,
1069 .end = AT91SAM9G45_BASE_SSC1 + SZ_16K - 1,
1070 .flags = IORESOURCE_MEM,
1073 .start = AT91SAM9G45_ID_SSC1,
1074 .end = AT91SAM9G45_ID_SSC1,
1075 .flags = IORESOURCE_IRQ,
1079 static struct platform_device at91sam9g45_ssc1_device = {
1083 .dma_mask = &ssc1_dmamask,
1084 .coherent_dma_mask = DMA_BIT_MASK(32),
1086 .resource = ssc1_resources,
1087 .num_resources = ARRAY_SIZE(ssc1_resources),
1090 static inline void configure_ssc1_pins(unsigned pins)
1092 if (pins & ATMEL_SSC_TF)
1093 at91_set_A_periph(AT91_PIN_PD14, 1);
1094 if (pins & ATMEL_SSC_TK)
1095 at91_set_A_periph(AT91_PIN_PD12, 1);
1096 if (pins & ATMEL_SSC_TD)
1097 at91_set_A_periph(AT91_PIN_PD10, 1);
1098 if (pins & ATMEL_SSC_RD)
1099 at91_set_A_periph(AT91_PIN_PD11, 1);
1100 if (pins & ATMEL_SSC_RK)
1101 at91_set_A_periph(AT91_PIN_PD13, 1);
1102 if (pins & ATMEL_SSC_RF)
1103 at91_set_A_periph(AT91_PIN_PD15, 1);
1107 * SSC controllers are accessed through library code, instead of any
1108 * kind of all-singing/all-dancing driver. For example one could be
1109 * used by a particular I2S audio codec's driver, while another one
1110 * on the same system might be used by a custom data capture driver.
1112 void __init at91_add_device_ssc(unsigned id, unsigned pins)
1114 struct platform_device *pdev;
1117 * NOTE: caller is responsible for passing information matching
1118 * "pins" to whatever will be using each particular controller.
1121 case AT91SAM9G45_ID_SSC0:
1122 pdev = &at91sam9g45_ssc0_device;
1123 configure_ssc0_pins(pins);
1124 at91_clock_associate("ssc0_clk", &pdev->dev, "pclk");
1126 case AT91SAM9G45_ID_SSC1:
1127 pdev = &at91sam9g45_ssc1_device;
1128 configure_ssc1_pins(pins);
1129 at91_clock_associate("ssc1_clk", &pdev->dev, "pclk");
1135 platform_device_register(pdev);
1139 void __init at91_add_device_ssc(unsigned id, unsigned pins) {}
1143 /* --------------------------------------------------------------------
1145 * -------------------------------------------------------------------- */
1147 #if defined(CONFIG_SERIAL_ATMEL)
1148 static struct resource dbgu_resources[] = {
1150 .start = AT91_VA_BASE_SYS + AT91_DBGU,
1151 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
1152 .flags = IORESOURCE_MEM,
1155 .start = AT91_ID_SYS,
1157 .flags = IORESOURCE_IRQ,
1161 static struct atmel_uart_data dbgu_data = {
1164 .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU),
1167 static u64 dbgu_dmamask = DMA_BIT_MASK(32);
1169 static struct platform_device at91sam9g45_dbgu_device = {
1170 .name = "atmel_usart",
1173 .dma_mask = &dbgu_dmamask,
1174 .coherent_dma_mask = DMA_BIT_MASK(32),
1175 .platform_data = &dbgu_data,
1177 .resource = dbgu_resources,
1178 .num_resources = ARRAY_SIZE(dbgu_resources),
1181 static inline void configure_dbgu_pins(void)
1183 at91_set_A_periph(AT91_PIN_PB12, 0); /* DRXD */
1184 at91_set_A_periph(AT91_PIN_PB13, 1); /* DTXD */
1187 static struct resource uart0_resources[] = {
1189 .start = AT91SAM9G45_BASE_US0,
1190 .end = AT91SAM9G45_BASE_US0 + SZ_16K - 1,
1191 .flags = IORESOURCE_MEM,
1194 .start = AT91SAM9G45_ID_US0,
1195 .end = AT91SAM9G45_ID_US0,
1196 .flags = IORESOURCE_IRQ,
1200 static struct atmel_uart_data uart0_data = {
1205 static u64 uart0_dmamask = DMA_BIT_MASK(32);
1207 static struct platform_device at91sam9g45_uart0_device = {
1208 .name = "atmel_usart",
1211 .dma_mask = &uart0_dmamask,
1212 .coherent_dma_mask = DMA_BIT_MASK(32),
1213 .platform_data = &uart0_data,
1215 .resource = uart0_resources,
1216 .num_resources = ARRAY_SIZE(uart0_resources),
1219 static inline void configure_usart0_pins(unsigned pins)
1221 at91_set_A_periph(AT91_PIN_PB19, 1); /* TXD0 */
1222 at91_set_A_periph(AT91_PIN_PB18, 0); /* RXD0 */
1224 if (pins & ATMEL_UART_RTS)
1225 at91_set_B_periph(AT91_PIN_PB17, 0); /* RTS0 */
1226 if (pins & ATMEL_UART_CTS)
1227 at91_set_B_periph(AT91_PIN_PB15, 0); /* CTS0 */
1230 static struct resource uart1_resources[] = {
1232 .start = AT91SAM9G45_BASE_US1,
1233 .end = AT91SAM9G45_BASE_US1 + SZ_16K - 1,
1234 .flags = IORESOURCE_MEM,
1237 .start = AT91SAM9G45_ID_US1,
1238 .end = AT91SAM9G45_ID_US1,
1239 .flags = IORESOURCE_IRQ,
1243 static struct atmel_uart_data uart1_data = {
1248 static u64 uart1_dmamask = DMA_BIT_MASK(32);
1250 static struct platform_device at91sam9g45_uart1_device = {
1251 .name = "atmel_usart",
1254 .dma_mask = &uart1_dmamask,
1255 .coherent_dma_mask = DMA_BIT_MASK(32),
1256 .platform_data = &uart1_data,
1258 .resource = uart1_resources,
1259 .num_resources = ARRAY_SIZE(uart1_resources),
1262 static inline void configure_usart1_pins(unsigned pins)
1264 at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD1 */
1265 at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD1 */
1267 if (pins & ATMEL_UART_RTS)
1268 at91_set_A_periph(AT91_PIN_PD16, 0); /* RTS1 */
1269 if (pins & ATMEL_UART_CTS)
1270 at91_set_A_periph(AT91_PIN_PD17, 0); /* CTS1 */
1273 static struct resource uart2_resources[] = {
1275 .start = AT91SAM9G45_BASE_US2,
1276 .end = AT91SAM9G45_BASE_US2 + SZ_16K - 1,
1277 .flags = IORESOURCE_MEM,
1280 .start = AT91SAM9G45_ID_US2,
1281 .end = AT91SAM9G45_ID_US2,
1282 .flags = IORESOURCE_IRQ,
1286 static struct atmel_uart_data uart2_data = {
1291 static u64 uart2_dmamask = DMA_BIT_MASK(32);
1293 static struct platform_device at91sam9g45_uart2_device = {
1294 .name = "atmel_usart",
1297 .dma_mask = &uart2_dmamask,
1298 .coherent_dma_mask = DMA_BIT_MASK(32),
1299 .platform_data = &uart2_data,
1301 .resource = uart2_resources,
1302 .num_resources = ARRAY_SIZE(uart2_resources),
1305 static inline void configure_usart2_pins(unsigned pins)
1307 at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD2 */
1308 at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD2 */
1310 if (pins & ATMEL_UART_RTS)
1311 at91_set_B_periph(AT91_PIN_PC9, 0); /* RTS2 */
1312 if (pins & ATMEL_UART_CTS)
1313 at91_set_B_periph(AT91_PIN_PC11, 0); /* CTS2 */
1316 static struct resource uart3_resources[] = {
1318 .start = AT91SAM9G45_BASE_US3,
1319 .end = AT91SAM9G45_BASE_US3 + SZ_16K - 1,
1320 .flags = IORESOURCE_MEM,
1323 .start = AT91SAM9G45_ID_US3,
1324 .end = AT91SAM9G45_ID_US3,
1325 .flags = IORESOURCE_IRQ,
1329 static struct atmel_uart_data uart3_data = {
1334 static u64 uart3_dmamask = DMA_BIT_MASK(32);
1336 static struct platform_device at91sam9g45_uart3_device = {
1337 .name = "atmel_usart",
1340 .dma_mask = &uart3_dmamask,
1341 .coherent_dma_mask = DMA_BIT_MASK(32),
1342 .platform_data = &uart3_data,
1344 .resource = uart3_resources,
1345 .num_resources = ARRAY_SIZE(uart3_resources),
1348 static inline void configure_usart3_pins(unsigned pins)
1350 at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD3 */
1351 at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD3 */
1353 if (pins & ATMEL_UART_RTS)
1354 at91_set_B_periph(AT91_PIN_PA23, 0); /* RTS3 */
1355 if (pins & ATMEL_UART_CTS)
1356 at91_set_B_periph(AT91_PIN_PA24, 0); /* CTS3 */
1359 static struct platform_device *__initdata at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1360 struct platform_device *atmel_default_console_device; /* the serial console device */
1362 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
1364 struct platform_device *pdev;
1368 pdev = &at91sam9g45_dbgu_device;
1369 configure_dbgu_pins();
1370 at91_clock_associate("mck", &pdev->dev, "usart");
1372 case AT91SAM9G45_ID_US0:
1373 pdev = &at91sam9g45_uart0_device;
1374 configure_usart0_pins(pins);
1375 at91_clock_associate("usart0_clk", &pdev->dev, "usart");
1377 case AT91SAM9G45_ID_US1:
1378 pdev = &at91sam9g45_uart1_device;
1379 configure_usart1_pins(pins);
1380 at91_clock_associate("usart1_clk", &pdev->dev, "usart");
1382 case AT91SAM9G45_ID_US2:
1383 pdev = &at91sam9g45_uart2_device;
1384 configure_usart2_pins(pins);
1385 at91_clock_associate("usart2_clk", &pdev->dev, "usart");
1387 case AT91SAM9G45_ID_US3:
1388 pdev = &at91sam9g45_uart3_device;
1389 configure_usart3_pins(pins);
1390 at91_clock_associate("usart3_clk", &pdev->dev, "usart");
1395 pdev->id = portnr; /* update to mapped ID */
1397 if (portnr < ATMEL_MAX_UART)
1398 at91_uarts[portnr] = pdev;
1401 void __init at91_set_serial_console(unsigned portnr)
1403 if (portnr < ATMEL_MAX_UART)
1404 atmel_default_console_device = at91_uarts[portnr];
1407 void __init at91_add_device_serial(void)
1411 for (i = 0; i < ATMEL_MAX_UART; i++) {
1413 platform_device_register(at91_uarts[i]);
1416 if (!atmel_default_console_device)
1417 printk(KERN_INFO "AT91: No default serial console defined.\n");
1420 void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1421 void __init at91_set_serial_console(unsigned portnr) {}
1422 void __init at91_add_device_serial(void) {}
1426 /* -------------------------------------------------------------------- */
1428 * These devices are always present and don't need any board-specific
1431 static int __init at91_add_standard_devices(void)
1433 at91_add_device_hdmac();
1434 at91_add_device_rtc();
1435 at91_add_device_rtt();
1436 at91_add_device_watchdog();
1437 at91_add_device_tc();
1441 arch_initcall(at91_add_standard_devices);