aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndrew Victor <andrew@sanpeople.com>2006-06-19 11:31:55 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-06-19 11:31:55 -0400
commit2e83640270b4a76a3855131953c82bbc1919e589 (patch)
tree7130aceafd79421f20e9c7ffb7b1eb931b2a14a5 /arch
parent814138ffa488824393d2f49f2720dcd197a7d4cf (diff)
[ARM] 3585/1: AT91RM9200 Platform devices
Patch from Andrew Victor This patch updates the platform device support for the AT91RM9200. The changes include: 1. USB Host device renamed to "at91_ohci" since the driver is also usable on the AT91SAM9261 processor. 2. Enabling multidrive on the USB Device's pullup pin should not be done for all boards. Moved into board-specific files. [Patch from David Brownell] 3. Move enabling of PCMCIA/Compact Flash pins out of the driver. 4. Added SPI device and resources. 5. Added Watchdog device and resources. [Patch from David Brownell] 6. Added UART device and resources. 7. The simple devices (watchdog, rtc, i2c) are now automatically registered and don't have to be registered separately in each board-specific file. [Patch from David Brownell] Signed-off-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-at91rm9200/devices.c406
1 files changed, 389 insertions, 17 deletions
diff --git a/arch/arm/mach-at91rm9200/devices.c b/arch/arm/mach-at91rm9200/devices.c
index bfe47bd6e50c..bf753e306a3a 100644
--- a/arch/arm/mach-at91rm9200/devices.c
+++ b/arch/arm/mach-at91rm9200/devices.c
@@ -16,9 +16,15 @@
16#include <linux/config.h> 16#include <linux/config.h>
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18 18
19#include <asm/arch/hardware.h>
19#include <asm/arch/board.h> 20#include <asm/arch/board.h>
20#include <asm/arch/pio.h> 21#include <asm/arch/gpio.h>
21 22
23#include "generic.h"
24
25#define SZ_512 0x00000200
26#define SZ_256 0x00000100
27#define SZ_16 0x00000010
22 28
23/* -------------------------------------------------------------------- 29/* --------------------------------------------------------------------
24 * USB Host 30 * USB Host
@@ -28,7 +34,7 @@
28static u64 ohci_dmamask = 0xffffffffUL; 34static u64 ohci_dmamask = 0xffffffffUL;
29static struct at91_usbh_data usbh_data; 35static struct at91_usbh_data usbh_data;
30 36
31static struct resource at91_usbh_resource[] = { 37static struct resource at91_usbh_resources[] = {
32 [0] = { 38 [0] = {
33 .start = AT91_UHP_BASE, 39 .start = AT91_UHP_BASE,
34 .end = AT91_UHP_BASE + SZ_1M - 1, 40 .end = AT91_UHP_BASE + SZ_1M - 1,
@@ -42,15 +48,15 @@ static struct resource at91_usbh_resource[] = {
42}; 48};
43 49
44static struct platform_device at91rm9200_usbh_device = { 50static struct platform_device at91rm9200_usbh_device = {
45 .name = "at91rm9200-ohci", 51 .name = "at91_ohci",
46 .id = -1, 52 .id = -1,
47 .dev = { 53 .dev = {
48 .dma_mask = &ohci_dmamask, 54 .dma_mask = &ohci_dmamask,
49 .coherent_dma_mask = 0xffffffff, 55 .coherent_dma_mask = 0xffffffff,
50 .platform_data = &usbh_data, 56 .platform_data = &usbh_data,
51 }, 57 },
52 .resource = at91_usbh_resource, 58 .resource = at91_usbh_resources,
53 .num_resources = ARRAY_SIZE(at91_usbh_resource), 59 .num_resources = ARRAY_SIZE(at91_usbh_resources),
54}; 60};
55 61
56void __init at91_add_device_usbh(struct at91_usbh_data *data) 62void __init at91_add_device_usbh(struct at91_usbh_data *data)
@@ -74,11 +80,16 @@ void __init at91_add_device_usbh(struct at91_usbh_data *data) {}
74static struct at91_udc_data udc_data; 80static struct at91_udc_data udc_data;
75 81
76static struct resource at91_udc_resources[] = { 82static struct resource at91_udc_resources[] = {
77 { 83 [0] = {
78 .start = AT91_BASE_UDP, 84 .start = AT91_BASE_UDP,
79 .end = AT91_BASE_UDP + SZ_16K - 1, 85 .end = AT91_BASE_UDP + SZ_16K - 1,
80 .flags = IORESOURCE_MEM, 86 .flags = IORESOURCE_MEM,
81 } 87 },
88 [1] = {
89 .start = AT91_ID_UDP,
90 .end = AT91_ID_UDP,
91 .flags = IORESOURCE_IRQ,
92 },
82}; 93};
83 94
84static struct platform_device at91rm9200_udc_device = { 95static struct platform_device at91rm9200_udc_device = {
@@ -100,10 +111,8 @@ void __init at91_add_device_udc(struct at91_udc_data *data)
100 at91_set_gpio_input(data->vbus_pin, 0); 111 at91_set_gpio_input(data->vbus_pin, 0);
101 at91_set_deglitch(data->vbus_pin, 1); 112 at91_set_deglitch(data->vbus_pin, 1);
102 } 113 }
103 if (data->pullup_pin) { 114 if (data->pullup_pin)
104 at91_set_gpio_output(data->pullup_pin, 0); 115 at91_set_gpio_output(data->pullup_pin, 0);
105 at91_set_multi_drive(data->pullup_pin, 1);
106 }
107 116
108 udc_data = *data; 117 udc_data = *data;
109 platform_device_register(&at91rm9200_udc_device); 118 platform_device_register(&at91rm9200_udc_device);
@@ -197,7 +206,7 @@ static struct at91_cf_data cf_data;
197static struct resource at91_cf_resources[] = { 206static struct resource at91_cf_resources[] = {
198 [0] = { 207 [0] = {
199 .start = AT91_CF_BASE, 208 .start = AT91_CF_BASE,
200 /* ties up CS4, CS5, and CS6 */ 209 /* ties up CS4, CS5 and CS6 */
201 .end = AT91_CF_BASE + (0x30000000 - 1), 210 .end = AT91_CF_BASE + (0x30000000 - 1),
202 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT, 211 .flags = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
203 }, 212 },
@@ -231,6 +240,12 @@ void __init at91_add_device_cf(struct at91_cf_data *data)
231 at91_set_gpio_output(data->vcc_pin, 0); 240 at91_set_gpio_output(data->vcc_pin, 0);
232 at91_set_gpio_output(data->rst_pin, 0); 241 at91_set_gpio_output(data->rst_pin, 0);
233 242
243 /* force poweron defaults for these pins ... */
244 at91_set_A_periph(AT91_PIN_PC9, 0); /* A25/CFRNW */
245 at91_set_A_periph(AT91_PIN_PC10, 0); /* NCS4/CFCS */
246 at91_set_A_periph(AT91_PIN_PC11, 0); /* NCS5/CFCE1 */
247 at91_set_A_periph(AT91_PIN_PC12, 0); /* NCS6/CFCE2 */
248
234 cf_data = *data; 249 cf_data = *data;
235 platform_device_register(&at91rm9200_cf_device); 250 platform_device_register(&at91rm9200_cf_device);
236} 251}
@@ -319,6 +334,7 @@ void __init at91_add_device_mmc(struct at91_mmc_data *data)
319void __init at91_add_device_mmc(struct at91_mmc_data *data) {} 334void __init at91_add_device_mmc(struct at91_mmc_data *data) {}
320#endif 335#endif
321 336
337
322/* -------------------------------------------------------------------- 338/* --------------------------------------------------------------------
323 * NAND / SmartMedia 339 * NAND / SmartMedia
324 * -------------------------------------------------------------------- */ 340 * -------------------------------------------------------------------- */
@@ -400,22 +416,110 @@ void __init at91_add_device_i2c(void) {}
400 416
401 417
402/* -------------------------------------------------------------------- 418/* --------------------------------------------------------------------
419 * SPI
420 * -------------------------------------------------------------------- */
421
422#if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE)
423static u64 spi_dmamask = 0xffffffffUL;
424
425static struct resource at91_spi_resources[] = {
426 [0] = {
427 .start = AT91_BASE_SPI,
428 .end = AT91_BASE_SPI + SZ_16K - 1,
429 .flags = IORESOURCE_MEM,
430 },
431 [1] = {
432 .start = AT91_ID_SPI,
433 .end = AT91_ID_SPI,
434 .flags = IORESOURCE_IRQ,
435 },
436};
437
438static struct platform_device at91rm9200_spi_device = {
439 .name = "at91_spi",
440 .id = 0,
441 .dev = {
442 .dma_mask = &spi_dmamask,
443 .coherent_dma_mask = 0xffffffff,
444 },
445 .resource = at91_spi_resources,
446 .num_resources = ARRAY_SIZE(at91_spi_resources),
447};
448
449static const unsigned at91_spi_standard_cs[4] = { AT91_PIN_PA3, AT91_PIN_PA4, AT91_PIN_PA5, AT91_PIN_PA6 };
450
451void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
452{
453 int i;
454 unsigned long cs_pin;
455
456 at91_set_A_periph(AT91_PIN_PA0, 0); /* MISO */
457 at91_set_A_periph(AT91_PIN_PA1, 0); /* MOSI */
458 at91_set_A_periph(AT91_PIN_PA2, 0); /* SPCK */
459
460 /* Enable SPI chip-selects */
461 for (i = 0; i < nr_devices; i++) {
462 if (devices[i].controller_data)
463 cs_pin = (unsigned long) devices[i].controller_data;
464 else
465 cs_pin = at91_spi_standard_cs[devices[i].chip_select];
466
467#ifdef CONFIG_SPI_AT91_MANUAL_CS
468 at91_set_gpio_output(cs_pin, 1);
469#else
470 at91_set_A_periph(cs_pin, 0);
471#endif
472
473 /* pass chip-select pin to driver */
474 devices[i].controller_data = (void *) cs_pin;
475 }
476
477 spi_register_board_info(devices, nr_devices);
478 at91_clock_associate("spi0_clk", &at91rm9200_spi_device.dev, "spi");
479 platform_device_register(&at91rm9200_spi_device);
480}
481#else
482void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) {}
483#endif
484
485
486/* --------------------------------------------------------------------
403 * RTC 487 * RTC
404 * -------------------------------------------------------------------- */ 488 * -------------------------------------------------------------------- */
405 489
406#if defined(CONFIG_AT91_RTC) || defined(CONFIG_AT91_RTC_MODULE) 490#if defined(CONFIG_RTC_DRV_AT91) || defined(CONFIG_RTC_DRV_AT91_MODULE)
407static struct platform_device at91rm9200_rtc_device = { 491static struct platform_device at91rm9200_rtc_device = {
408 .name = "at91_rtc", 492 .name = "at91_rtc",
409 .id = -1, 493 .id = -1,
410 .num_resources = 0, 494 .num_resources = 0,
411}; 495};
412 496
413void __init at91_add_device_rtc(void) 497static void __init at91_add_device_rtc(void)
414{ 498{
415 platform_device_register(&at91rm9200_rtc_device); 499 platform_device_register(&at91rm9200_rtc_device);
416} 500}
417#else 501#else
418void __init at91_add_device_rtc(void) {} 502static void __init at91_add_device_rtc(void) {}
503#endif
504
505
506/* --------------------------------------------------------------------
507 * Watchdog
508 * -------------------------------------------------------------------- */
509
510#if defined(CONFIG_AT91_WATCHDOG) || defined(CONFIG_AT91_WATCHDOG_MODULE)
511static struct platform_device at91rm9200_wdt_device = {
512 .name = "at91_wdt",
513 .id = -1,
514 .num_resources = 0,
515};
516
517static void __init at91_add_device_watchdog(void)
518{
519 platform_device_register(&at91rm9200_wdt_device);
520}
521#else
522static void __init at91_add_device_watchdog(void) {}
419#endif 523#endif
420 524
421 525
@@ -429,13 +533,281 @@ u8 at91_leds_timer;
429 533
430void __init at91_init_leds(u8 cpu_led, u8 timer_led) 534void __init at91_init_leds(u8 cpu_led, u8 timer_led)
431{ 535{
432 at91_leds_cpu = cpu_led; 536 at91_leds_cpu = cpu_led;
433 at91_leds_timer = timer_led; 537 at91_leds_timer = timer_led;
434} 538}
435
436#else 539#else
437void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} 540void __init at91_init_leds(u8 cpu_led, u8 timer_led) {}
438#endif 541#endif
439 542
440 543
544/* --------------------------------------------------------------------
545 * UART
546 * -------------------------------------------------------------------- */
547
548#if defined(CONFIG_SERIAL_AT91)
549static struct resource dbgu_resources[] = {
550 [0] = {
551 .start = AT91_VA_BASE_SYS + AT91_DBGU,
552 .end = AT91_VA_BASE_SYS + AT91_DBGU + SZ_512 - 1,
553 .flags = IORESOURCE_MEM,
554 },
555 [1] = {
556 .start = AT91_ID_SYS,
557 .end = AT91_ID_SYS,
558 .flags = IORESOURCE_IRQ,
559 },
560};
561
562static struct at91_uart_data dbgu_data = {
563 .use_dma_tx = 0,
564 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
565};
566
567static struct platform_device at91rm9200_dbgu_device = {
568 .name = "at91_usart",
569 .id = 0,
570 .dev = {
571 .platform_data = &dbgu_data,
572 .coherent_dma_mask = 0xffffffff,
573 },
574 .resource = dbgu_resources,
575 .num_resources = ARRAY_SIZE(dbgu_resources),
576};
577
578static inline void configure_dbgu_pins(void)
579{
580 at91_set_A_periph(AT91_PIN_PA30, 0); /* DRXD */
581 at91_set_A_periph(AT91_PIN_PA31, 1); /* DTXD */
582}
583
584static struct resource uart0_resources[] = {
585 [0] = {
586 .start = AT91_BASE_US0,
587 .end = AT91_BASE_US0 + SZ_16K - 1,
588 .flags = IORESOURCE_MEM,
589 },
590 [1] = {
591 .start = AT91_ID_US0,
592 .end = AT91_ID_US0,
593 .flags = IORESOURCE_IRQ,
594 },
595};
596
597static struct at91_uart_data uart0_data = {
598 .use_dma_tx = 1,
599 .use_dma_rx = 1,
600};
601
602static struct platform_device at91rm9200_uart0_device = {
603 .name = "at91_usart",
604 .id = 1,
605 .dev = {
606 .platform_data = &uart0_data,
607 .coherent_dma_mask = 0xffffffff,
608 },
609 .resource = uart0_resources,
610 .num_resources = ARRAY_SIZE(uart0_resources),
611};
612
613static inline void configure_usart0_pins(void)
614{
615 at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */
616 at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */
617 at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */
618
619 /*
620 * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21.
621 * We need to drive the pin manually. Default is off (RTS is active low).
622 */
623 at91_set_gpio_output(AT91_PIN_PA21, 1);
624}
625
626static struct resource uart1_resources[] = {
627 [0] = {
628 .start = AT91_BASE_US1,
629 .end = AT91_BASE_US1 + SZ_16K - 1,
630 .flags = IORESOURCE_MEM,
631 },
632 [1] = {
633 .start = AT91_ID_US1,
634 .end = AT91_ID_US1,
635 .flags = IORESOURCE_IRQ,
636 },
637};
638
639static struct at91_uart_data uart1_data = {
640 .use_dma_tx = 1,
641 .use_dma_rx = 1,
642};
643
644static struct platform_device at91rm9200_uart1_device = {
645 .name = "at91_usart",
646 .id = 2,
647 .dev = {
648 .platform_data = &uart1_data,
649 .coherent_dma_mask = 0xffffffff,
650 },
651 .resource = uart1_resources,
652 .num_resources = ARRAY_SIZE(uart1_resources),
653};
654
655static inline void configure_usart1_pins(void)
656{
657 at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */
658 at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */
659 at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */
660 at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */
661 at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */
662 at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */
663 at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */
664 at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */
665}
666
667static struct resource uart2_resources[] = {
668 [0] = {
669 .start = AT91_BASE_US2,
670 .end = AT91_BASE_US2 + SZ_16K - 1,
671 .flags = IORESOURCE_MEM,
672 },
673 [1] = {
674 .start = AT91_ID_US2,
675 .end = AT91_ID_US2,
676 .flags = IORESOURCE_IRQ,
677 },
678};
679
680static struct at91_uart_data uart2_data = {
681 .use_dma_tx = 1,
682 .use_dma_rx = 1,
683};
684
685static struct platform_device at91rm9200_uart2_device = {
686 .name = "at91_usart",
687 .id = 3,
688 .dev = {
689 .platform_data = &uart2_data,
690 .coherent_dma_mask = 0xffffffff,
691 },
692 .resource = uart2_resources,
693 .num_resources = ARRAY_SIZE(uart2_resources),
694};
695
696static inline void configure_usart2_pins(void)
697{
698 at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */
699 at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */
700}
701
702static struct resource uart3_resources[] = {
703 [0] = {
704 .start = AT91_BASE_US3,
705 .end = AT91_BASE_US3 + SZ_16K - 1,
706 .flags = IORESOURCE_MEM,
707 },
708 [1] = {
709 .start = AT91_ID_US3,
710 .end = AT91_ID_US3,
711 .flags = IORESOURCE_IRQ,
712 },
713};
714
715static struct at91_uart_data uart3_data = {
716 .use_dma_tx = 1,
717 .use_dma_rx = 1,
718};
719
720static struct platform_device at91rm9200_uart3_device = {
721 .name = "at91_usart",
722 .id = 4,
723 .dev = {
724 .platform_data = &uart3_data,
725 .coherent_dma_mask = 0xffffffff,
726 },
727 .resource = uart3_resources,
728 .num_resources = ARRAY_SIZE(uart3_resources),
729};
730
731static inline void configure_usart3_pins(void)
732{
733 at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */
734 at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */
735}
736
737struct platform_device *at91_uarts[AT91_NR_UART]; /* the UARTs to use */
738struct platform_device *at91_default_console_device; /* the serial console device */
739
740void __init at91_init_serial(struct at91_uart_config *config)
741{
742 int i;
743
744 /* Fill in list of supported UARTs */
745 for (i = 0; i < config->nr_tty; i++) {
746 switch (config->tty_map[i]) {
747 case 0:
748 configure_usart0_pins();
749 at91_uarts[i] = &at91rm9200_uart0_device;
750 at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart");
751 break;
752 case 1:
753 configure_usart1_pins();
754 at91_uarts[i] = &at91rm9200_uart1_device;
755 at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart");
756 break;
757 case 2:
758 configure_usart2_pins();
759 at91_uarts[i] = &at91rm9200_uart2_device;
760 at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart");
761 break;
762 case 3:
763 configure_usart3_pins();
764 at91_uarts[i] = &at91rm9200_uart3_device;
765 at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart");
766 break;
767 case 4:
768 configure_dbgu_pins();
769 at91_uarts[i] = &at91rm9200_dbgu_device;
770 at91_clock_associate("mck", &at91rm9200_dbgu_device.dev, "usart");
771 break;
772 default:
773 continue;
774 }
775 at91_uarts[i]->id = i; /* update ID number to mapped ID */
776 }
777
778 /* Set serial console device */
779 if (config->console_tty < AT91_NR_UART)
780 at91_default_console_device = at91_uarts[config->console_tty];
781 if (!at91_default_console_device)
782 printk(KERN_INFO "AT91: No default serial console defined.\n");
783}
784
785void __init at91_add_device_serial(void)
786{
787 int i;
788
789 for (i = 0; i < AT91_NR_UART; i++) {
790 if (at91_uarts[i])
791 platform_device_register(at91_uarts[i]);
792 }
793}
794#else
795void __init at91_init_serial(struct at91_uart_config *config) {}
796void __init at91_add_device_serial(void) {}
797#endif
798
799
441/* -------------------------------------------------------------------- */ 800/* -------------------------------------------------------------------- */
801
802/*
803 * These devices are always present and don't need any board-specific
804 * setup.
805 */
806static int __init at91_add_standard_devices(void)
807{
808 at91_add_device_rtc();
809 at91_add_device_watchdog();
810 return 0;
811}
812
813arch_initcall(at91_add_standard_devices);