diff options
Diffstat (limited to 'arch/arm/mach-at91/at91rm9200_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91rm9200_devices.c | 350 |
1 files changed, 295 insertions, 55 deletions
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index 9296833f91cc..ef6aeb86e980 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <asm/mach/arch.h> | 13 | #include <asm/mach/arch.h> |
14 | #include <asm/mach/map.h> | 14 | #include <asm/mach/map.h> |
15 | 15 | ||
16 | #include <linux/dma-mapping.h> | ||
16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
17 | #include <linux/i2c-gpio.h> | 18 | #include <linux/i2c-gpio.h> |
18 | 19 | ||
@@ -29,7 +30,7 @@ | |||
29 | * -------------------------------------------------------------------- */ | 30 | * -------------------------------------------------------------------- */ |
30 | 31 | ||
31 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) | 32 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
32 | static u64 ohci_dmamask = 0xffffffffUL; | 33 | static u64 ohci_dmamask = DMA_BIT_MASK(32); |
33 | static struct at91_usbh_data usbh_data; | 34 | static struct at91_usbh_data usbh_data; |
34 | 35 | ||
35 | static struct resource usbh_resources[] = { | 36 | static struct resource usbh_resources[] = { |
@@ -50,7 +51,7 @@ static struct platform_device at91rm9200_usbh_device = { | |||
50 | .id = -1, | 51 | .id = -1, |
51 | .dev = { | 52 | .dev = { |
52 | .dma_mask = &ohci_dmamask, | 53 | .dma_mask = &ohci_dmamask, |
53 | .coherent_dma_mask = 0xffffffff, | 54 | .coherent_dma_mask = DMA_BIT_MASK(32), |
54 | .platform_data = &usbh_data, | 55 | .platform_data = &usbh_data, |
55 | }, | 56 | }, |
56 | .resource = usbh_resources, | 57 | .resource = usbh_resources, |
@@ -125,7 +126,7 @@ void __init at91_add_device_udc(struct at91_udc_data *data) {} | |||
125 | * -------------------------------------------------------------------- */ | 126 | * -------------------------------------------------------------------- */ |
126 | 127 | ||
127 | #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE) | 128 | #if defined(CONFIG_ARM_AT91_ETHER) || defined(CONFIG_ARM_AT91_ETHER_MODULE) |
128 | static u64 eth_dmamask = 0xffffffffUL; | 129 | static u64 eth_dmamask = DMA_BIT_MASK(32); |
129 | static struct at91_eth_data eth_data; | 130 | static struct at91_eth_data eth_data; |
130 | 131 | ||
131 | static struct resource eth_resources[] = { | 132 | static struct resource eth_resources[] = { |
@@ -146,7 +147,7 @@ static struct platform_device at91rm9200_eth_device = { | |||
146 | .id = -1, | 147 | .id = -1, |
147 | .dev = { | 148 | .dev = { |
148 | .dma_mask = ð_dmamask, | 149 | .dma_mask = ð_dmamask, |
149 | .coherent_dma_mask = 0xffffffff, | 150 | .coherent_dma_mask = DMA_BIT_MASK(32), |
150 | .platform_data = ð_data, | 151 | .platform_data = ð_data, |
151 | }, | 152 | }, |
152 | .resource = eth_resources, | 153 | .resource = eth_resources, |
@@ -285,7 +286,7 @@ void __init at91_add_device_cf(struct at91_cf_data *data) {} | |||
285 | * -------------------------------------------------------------------- */ | 286 | * -------------------------------------------------------------------- */ |
286 | 287 | ||
287 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) | 288 | #if defined(CONFIG_MMC_AT91) || defined(CONFIG_MMC_AT91_MODULE) |
288 | static u64 mmc_dmamask = 0xffffffffUL; | 289 | static u64 mmc_dmamask = DMA_BIT_MASK(32); |
289 | static struct at91_mmc_data mmc_data; | 290 | static struct at91_mmc_data mmc_data; |
290 | 291 | ||
291 | static struct resource mmc_resources[] = { | 292 | static struct resource mmc_resources[] = { |
@@ -306,7 +307,7 @@ static struct platform_device at91rm9200_mmc_device = { | |||
306 | .id = -1, | 307 | .id = -1, |
307 | .dev = { | 308 | .dev = { |
308 | .dma_mask = &mmc_dmamask, | 309 | .dma_mask = &mmc_dmamask, |
309 | .coherent_dma_mask = 0xffffffff, | 310 | .coherent_dma_mask = DMA_BIT_MASK(32), |
310 | .platform_data = &mmc_data, | 311 | .platform_data = &mmc_data, |
311 | }, | 312 | }, |
312 | .resource = mmc_resources, | 313 | .resource = mmc_resources, |
@@ -375,7 +376,7 @@ static struct at91_nand_data nand_data; | |||
375 | static struct resource nand_resources[] = { | 376 | static struct resource nand_resources[] = { |
376 | { | 377 | { |
377 | .start = NAND_BASE, | 378 | .start = NAND_BASE, |
378 | .end = NAND_BASE + SZ_8M - 1, | 379 | .end = NAND_BASE + SZ_256M - 1, |
379 | .flags = IORESOURCE_MEM, | 380 | .flags = IORESOURCE_MEM, |
380 | } | 381 | } |
381 | }; | 382 | }; |
@@ -513,7 +514,7 @@ void __init at91_add_device_i2c(struct i2c_board_info *devices, int nr_devices) | |||
513 | * -------------------------------------------------------------------- */ | 514 | * -------------------------------------------------------------------- */ |
514 | 515 | ||
515 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) | 516 | #if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE) |
516 | static u64 spi_dmamask = 0xffffffffUL; | 517 | static u64 spi_dmamask = DMA_BIT_MASK(32); |
517 | 518 | ||
518 | static struct resource spi_resources[] = { | 519 | static struct resource spi_resources[] = { |
519 | [0] = { | 520 | [0] = { |
@@ -533,7 +534,7 @@ static struct platform_device at91rm9200_spi_device = { | |||
533 | .id = 0, | 534 | .id = 0, |
534 | .dev = { | 535 | .dev = { |
535 | .dma_mask = &spi_dmamask, | 536 | .dma_mask = &spi_dmamask, |
536 | .coherent_dma_mask = 0xffffffff, | 537 | .coherent_dma_mask = DMA_BIT_MASK(32), |
537 | }, | 538 | }, |
538 | .resource = spi_resources, | 539 | .resource = spi_resources, |
539 | .num_resources = ARRAY_SIZE(spi_resources), | 540 | .num_resources = ARRAY_SIZE(spi_resources), |
@@ -557,8 +558,11 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices) | |||
557 | else | 558 | else |
558 | cs_pin = spi_standard_cs[devices[i].chip_select]; | 559 | cs_pin = spi_standard_cs[devices[i].chip_select]; |
559 | 560 | ||
560 | /* enable chip-select pin */ | 561 | if (devices[i].chip_select == 0) /* for CS0 errata */ |
561 | at91_set_gpio_output(cs_pin, 1); | 562 | at91_set_A_periph(cs_pin, 0); |
563 | else | ||
564 | at91_set_gpio_output(cs_pin, 1); | ||
565 | |||
562 | 566 | ||
563 | /* pass chip-select pin to driver */ | 567 | /* pass chip-select pin to driver */ |
564 | devices[i].controller_data = (void *) cs_pin; | 568 | devices[i].controller_data = (void *) cs_pin; |
@@ -613,24 +617,175 @@ static void __init at91_add_device_watchdog(void) {} | |||
613 | 617 | ||
614 | 618 | ||
615 | /* -------------------------------------------------------------------- | 619 | /* -------------------------------------------------------------------- |
616 | * LEDs | 620 | * SSC -- Synchronous Serial Controller |
617 | * -------------------------------------------------------------------- */ | 621 | * -------------------------------------------------------------------- */ |
618 | 622 | ||
619 | #if defined(CONFIG_LEDS) | 623 | #if defined(CONFIG_ATMEL_SSC) || defined(CONFIG_ATMEL_SSC_MODULE) |
620 | u8 at91_leds_cpu; | 624 | static u64 ssc0_dmamask = DMA_BIT_MASK(32); |
621 | u8 at91_leds_timer; | 625 | |
626 | static struct resource ssc0_resources[] = { | ||
627 | [0] = { | ||
628 | .start = AT91RM9200_BASE_SSC0, | ||
629 | .end = AT91RM9200_BASE_SSC0 + SZ_16K - 1, | ||
630 | .flags = IORESOURCE_MEM, | ||
631 | }, | ||
632 | [1] = { | ||
633 | .start = AT91RM9200_ID_SSC0, | ||
634 | .end = AT91RM9200_ID_SSC0, | ||
635 | .flags = IORESOURCE_IRQ, | ||
636 | }, | ||
637 | }; | ||
638 | |||
639 | static struct platform_device at91rm9200_ssc0_device = { | ||
640 | .name = "ssc", | ||
641 | .id = 0, | ||
642 | .dev = { | ||
643 | .dma_mask = &ssc0_dmamask, | ||
644 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
645 | }, | ||
646 | .resource = ssc0_resources, | ||
647 | .num_resources = ARRAY_SIZE(ssc0_resources), | ||
648 | }; | ||
649 | |||
650 | static inline void configure_ssc0_pins(unsigned pins) | ||
651 | { | ||
652 | if (pins & ATMEL_SSC_TF) | ||
653 | at91_set_A_periph(AT91_PIN_PB0, 1); | ||
654 | if (pins & ATMEL_SSC_TK) | ||
655 | at91_set_A_periph(AT91_PIN_PB1, 1); | ||
656 | if (pins & ATMEL_SSC_TD) | ||
657 | at91_set_A_periph(AT91_PIN_PB2, 1); | ||
658 | if (pins & ATMEL_SSC_RD) | ||
659 | at91_set_A_periph(AT91_PIN_PB3, 1); | ||
660 | if (pins & ATMEL_SSC_RK) | ||
661 | at91_set_A_periph(AT91_PIN_PB4, 1); | ||
662 | if (pins & ATMEL_SSC_RF) | ||
663 | at91_set_A_periph(AT91_PIN_PB5, 1); | ||
664 | } | ||
665 | |||
666 | static u64 ssc1_dmamask = DMA_BIT_MASK(32); | ||
667 | |||
668 | static struct resource ssc1_resources[] = { | ||
669 | [0] = { | ||
670 | .start = AT91RM9200_BASE_SSC1, | ||
671 | .end = AT91RM9200_BASE_SSC1 + SZ_16K - 1, | ||
672 | .flags = IORESOURCE_MEM, | ||
673 | }, | ||
674 | [1] = { | ||
675 | .start = AT91RM9200_ID_SSC1, | ||
676 | .end = AT91RM9200_ID_SSC1, | ||
677 | .flags = IORESOURCE_IRQ, | ||
678 | }, | ||
679 | }; | ||
680 | |||
681 | static struct platform_device at91rm9200_ssc1_device = { | ||
682 | .name = "ssc", | ||
683 | .id = 1, | ||
684 | .dev = { | ||
685 | .dma_mask = &ssc1_dmamask, | ||
686 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
687 | }, | ||
688 | .resource = ssc1_resources, | ||
689 | .num_resources = ARRAY_SIZE(ssc1_resources), | ||
690 | }; | ||
691 | |||
692 | static inline void configure_ssc1_pins(unsigned pins) | ||
693 | { | ||
694 | if (pins & ATMEL_SSC_TF) | ||
695 | at91_set_A_periph(AT91_PIN_PB6, 1); | ||
696 | if (pins & ATMEL_SSC_TK) | ||
697 | at91_set_A_periph(AT91_PIN_PB7, 1); | ||
698 | if (pins & ATMEL_SSC_TD) | ||
699 | at91_set_A_periph(AT91_PIN_PB8, 1); | ||
700 | if (pins & ATMEL_SSC_RD) | ||
701 | at91_set_A_periph(AT91_PIN_PB9, 1); | ||
702 | if (pins & ATMEL_SSC_RK) | ||
703 | at91_set_A_periph(AT91_PIN_PB10, 1); | ||
704 | if (pins & ATMEL_SSC_RF) | ||
705 | at91_set_A_periph(AT91_PIN_PB11, 1); | ||
706 | } | ||
707 | |||
708 | static u64 ssc2_dmamask = DMA_BIT_MASK(32); | ||
709 | |||
710 | static struct resource ssc2_resources[] = { | ||
711 | [0] = { | ||
712 | .start = AT91RM9200_BASE_SSC2, | ||
713 | .end = AT91RM9200_BASE_SSC2 + SZ_16K - 1, | ||
714 | .flags = IORESOURCE_MEM, | ||
715 | }, | ||
716 | [1] = { | ||
717 | .start = AT91RM9200_ID_SSC2, | ||
718 | .end = AT91RM9200_ID_SSC2, | ||
719 | .flags = IORESOURCE_IRQ, | ||
720 | }, | ||
721 | }; | ||
722 | |||
723 | static struct platform_device at91rm9200_ssc2_device = { | ||
724 | .name = "ssc", | ||
725 | .id = 2, | ||
726 | .dev = { | ||
727 | .dma_mask = &ssc2_dmamask, | ||
728 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
729 | }, | ||
730 | .resource = ssc2_resources, | ||
731 | .num_resources = ARRAY_SIZE(ssc2_resources), | ||
732 | }; | ||
733 | |||
734 | static inline void configure_ssc2_pins(unsigned pins) | ||
735 | { | ||
736 | if (pins & ATMEL_SSC_TF) | ||
737 | at91_set_A_periph(AT91_PIN_PB12, 1); | ||
738 | if (pins & ATMEL_SSC_TK) | ||
739 | at91_set_A_periph(AT91_PIN_PB13, 1); | ||
740 | if (pins & ATMEL_SSC_TD) | ||
741 | at91_set_A_periph(AT91_PIN_PB14, 1); | ||
742 | if (pins & ATMEL_SSC_RD) | ||
743 | at91_set_A_periph(AT91_PIN_PB15, 1); | ||
744 | if (pins & ATMEL_SSC_RK) | ||
745 | at91_set_A_periph(AT91_PIN_PB16, 1); | ||
746 | if (pins & ATMEL_SSC_RF) | ||
747 | at91_set_A_periph(AT91_PIN_PB17, 1); | ||
748 | } | ||
622 | 749 | ||
623 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) | 750 | /* |
751 | * SSC controllers are accessed through library code, instead of any | ||
752 | * kind of all-singing/all-dancing driver. For example one could be | ||
753 | * used by a particular I2S audio codec's driver, while another one | ||
754 | * on the same system might be used by a custom data capture driver. | ||
755 | */ | ||
756 | void __init at91_add_device_ssc(unsigned id, unsigned pins) | ||
624 | { | 757 | { |
625 | /* Enable GPIO to access the LEDs */ | 758 | struct platform_device *pdev; |
626 | at91_set_gpio_output(cpu_led, 1); | ||
627 | at91_set_gpio_output(timer_led, 1); | ||
628 | 759 | ||
629 | at91_leds_cpu = cpu_led; | 760 | /* |
630 | at91_leds_timer = timer_led; | 761 | * NOTE: caller is responsible for passing information matching |
762 | * "pins" to whatever will be using each particular controller. | ||
763 | */ | ||
764 | switch (id) { | ||
765 | case AT91RM9200_ID_SSC0: | ||
766 | pdev = &at91rm9200_ssc0_device; | ||
767 | configure_ssc0_pins(pins); | ||
768 | at91_clock_associate("ssc0_clk", &pdev->dev, "ssc"); | ||
769 | break; | ||
770 | case AT91RM9200_ID_SSC1: | ||
771 | pdev = &at91rm9200_ssc1_device; | ||
772 | configure_ssc1_pins(pins); | ||
773 | at91_clock_associate("ssc1_clk", &pdev->dev, "ssc"); | ||
774 | break; | ||
775 | case AT91RM9200_ID_SSC2: | ||
776 | pdev = &at91rm9200_ssc2_device; | ||
777 | configure_ssc2_pins(pins); | ||
778 | at91_clock_associate("ssc2_clk", &pdev->dev, "ssc"); | ||
779 | break; | ||
780 | default: | ||
781 | return; | ||
782 | } | ||
783 | |||
784 | platform_device_register(pdev); | ||
631 | } | 785 | } |
786 | |||
632 | #else | 787 | #else |
633 | void __init at91_init_leds(u8 cpu_led, u8 timer_led) {} | 788 | void __init at91_add_device_ssc(unsigned id, unsigned pins) {} |
634 | #endif | 789 | #endif |
635 | 790 | ||
636 | 791 | ||
@@ -658,12 +813,15 @@ static struct atmel_uart_data dbgu_data = { | |||
658 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), | 813 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), |
659 | }; | 814 | }; |
660 | 815 | ||
816 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | ||
817 | |||
661 | static struct platform_device at91rm9200_dbgu_device = { | 818 | static struct platform_device at91rm9200_dbgu_device = { |
662 | .name = "atmel_usart", | 819 | .name = "atmel_usart", |
663 | .id = 0, | 820 | .id = 0, |
664 | .dev = { | 821 | .dev = { |
665 | .platform_data = &dbgu_data, | 822 | .dma_mask = &dbgu_dmamask, |
666 | .coherent_dma_mask = 0xffffffff, | 823 | .coherent_dma_mask = DMA_BIT_MASK(32), |
824 | .platform_data = &dbgu_data, | ||
667 | }, | 825 | }, |
668 | .resource = dbgu_resources, | 826 | .resource = dbgu_resources, |
669 | .num_resources = ARRAY_SIZE(dbgu_resources), | 827 | .num_resources = ARRAY_SIZE(dbgu_resources), |
@@ -693,28 +851,35 @@ static struct atmel_uart_data uart0_data = { | |||
693 | .use_dma_rx = 1, | 851 | .use_dma_rx = 1, |
694 | }; | 852 | }; |
695 | 853 | ||
854 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | ||
855 | |||
696 | static struct platform_device at91rm9200_uart0_device = { | 856 | static struct platform_device at91rm9200_uart0_device = { |
697 | .name = "atmel_usart", | 857 | .name = "atmel_usart", |
698 | .id = 1, | 858 | .id = 1, |
699 | .dev = { | 859 | .dev = { |
700 | .platform_data = &uart0_data, | 860 | .dma_mask = &uart0_dmamask, |
701 | .coherent_dma_mask = 0xffffffff, | 861 | .coherent_dma_mask = DMA_BIT_MASK(32), |
862 | .platform_data = &uart0_data, | ||
702 | }, | 863 | }, |
703 | .resource = uart0_resources, | 864 | .resource = uart0_resources, |
704 | .num_resources = ARRAY_SIZE(uart0_resources), | 865 | .num_resources = ARRAY_SIZE(uart0_resources), |
705 | }; | 866 | }; |
706 | 867 | ||
707 | static inline void configure_usart0_pins(void) | 868 | static inline void configure_usart0_pins(unsigned pins) |
708 | { | 869 | { |
709 | at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ | 870 | at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ |
710 | at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ | 871 | at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ |
711 | at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ | ||
712 | 872 | ||
713 | /* | 873 | if (pins & ATMEL_UART_CTS) |
714 | * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. | 874 | at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ |
715 | * We need to drive the pin manually. Default is off (RTS is active low). | 875 | |
716 | */ | 876 | if (pins & ATMEL_UART_RTS) { |
717 | at91_set_gpio_output(AT91_PIN_PA21, 1); | 877 | /* |
878 | * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. | ||
879 | * We need to drive the pin manually. Default is off (RTS is active low). | ||
880 | */ | ||
881 | at91_set_gpio_output(AT91_PIN_PA21, 1); | ||
882 | } | ||
718 | } | 883 | } |
719 | 884 | ||
720 | static struct resource uart1_resources[] = { | 885 | static struct resource uart1_resources[] = { |
@@ -735,27 +900,37 @@ static struct atmel_uart_data uart1_data = { | |||
735 | .use_dma_rx = 1, | 900 | .use_dma_rx = 1, |
736 | }; | 901 | }; |
737 | 902 | ||
903 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | ||
904 | |||
738 | static struct platform_device at91rm9200_uart1_device = { | 905 | static struct platform_device at91rm9200_uart1_device = { |
739 | .name = "atmel_usart", | 906 | .name = "atmel_usart", |
740 | .id = 2, | 907 | .id = 2, |
741 | .dev = { | 908 | .dev = { |
742 | .platform_data = &uart1_data, | 909 | .dma_mask = &uart1_dmamask, |
743 | .coherent_dma_mask = 0xffffffff, | 910 | .coherent_dma_mask = DMA_BIT_MASK(32), |
911 | .platform_data = &uart1_data, | ||
744 | }, | 912 | }, |
745 | .resource = uart1_resources, | 913 | .resource = uart1_resources, |
746 | .num_resources = ARRAY_SIZE(uart1_resources), | 914 | .num_resources = ARRAY_SIZE(uart1_resources), |
747 | }; | 915 | }; |
748 | 916 | ||
749 | static inline void configure_usart1_pins(void) | 917 | static inline void configure_usart1_pins(unsigned pins) |
750 | { | 918 | { |
751 | at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ | ||
752 | at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ | ||
753 | at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ | 919 | at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ |
754 | at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ | 920 | at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ |
755 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ | 921 | |
756 | at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ | 922 | if (pins & ATMEL_UART_RI) |
757 | at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ | 923 | at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ |
758 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ | 924 | if (pins & ATMEL_UART_DTR) |
925 | at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ | ||
926 | if (pins & ATMEL_UART_DCD) | ||
927 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ | ||
928 | if (pins & ATMEL_UART_CTS) | ||
929 | at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ | ||
930 | if (pins & ATMEL_UART_DSR) | ||
931 | at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ | ||
932 | if (pins & ATMEL_UART_RTS) | ||
933 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ | ||
759 | } | 934 | } |
760 | 935 | ||
761 | static struct resource uart2_resources[] = { | 936 | static struct resource uart2_resources[] = { |
@@ -776,21 +951,29 @@ static struct atmel_uart_data uart2_data = { | |||
776 | .use_dma_rx = 1, | 951 | .use_dma_rx = 1, |
777 | }; | 952 | }; |
778 | 953 | ||
954 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | ||
955 | |||
779 | static struct platform_device at91rm9200_uart2_device = { | 956 | static struct platform_device at91rm9200_uart2_device = { |
780 | .name = "atmel_usart", | 957 | .name = "atmel_usart", |
781 | .id = 3, | 958 | .id = 3, |
782 | .dev = { | 959 | .dev = { |
783 | .platform_data = &uart2_data, | 960 | .dma_mask = &uart2_dmamask, |
784 | .coherent_dma_mask = 0xffffffff, | 961 | .coherent_dma_mask = DMA_BIT_MASK(32), |
962 | .platform_data = &uart2_data, | ||
785 | }, | 963 | }, |
786 | .resource = uart2_resources, | 964 | .resource = uart2_resources, |
787 | .num_resources = ARRAY_SIZE(uart2_resources), | 965 | .num_resources = ARRAY_SIZE(uart2_resources), |
788 | }; | 966 | }; |
789 | 967 | ||
790 | static inline void configure_usart2_pins(void) | 968 | static inline void configure_usart2_pins(unsigned pins) |
791 | { | 969 | { |
792 | at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ | 970 | at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ |
793 | at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ | 971 | at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ |
972 | |||
973 | if (pins & ATMEL_UART_CTS) | ||
974 | at91_set_B_periph(AT91_PIN_PA30, 0); /* CTS2 */ | ||
975 | if (pins & ATMEL_UART_RTS) | ||
976 | at91_set_B_periph(AT91_PIN_PA31, 0); /* RTS2 */ | ||
794 | } | 977 | } |
795 | 978 | ||
796 | static struct resource uart3_resources[] = { | 979 | static struct resource uart3_resources[] = { |
@@ -811,27 +994,35 @@ static struct atmel_uart_data uart3_data = { | |||
811 | .use_dma_rx = 1, | 994 | .use_dma_rx = 1, |
812 | }; | 995 | }; |
813 | 996 | ||
997 | static u64 uart3_dmamask = DMA_BIT_MASK(32); | ||
998 | |||
814 | static struct platform_device at91rm9200_uart3_device = { | 999 | static struct platform_device at91rm9200_uart3_device = { |
815 | .name = "atmel_usart", | 1000 | .name = "atmel_usart", |
816 | .id = 4, | 1001 | .id = 4, |
817 | .dev = { | 1002 | .dev = { |
818 | .platform_data = &uart3_data, | 1003 | .dma_mask = &uart3_dmamask, |
819 | .coherent_dma_mask = 0xffffffff, | 1004 | .coherent_dma_mask = DMA_BIT_MASK(32), |
1005 | .platform_data = &uart3_data, | ||
820 | }, | 1006 | }, |
821 | .resource = uart3_resources, | 1007 | .resource = uart3_resources, |
822 | .num_resources = ARRAY_SIZE(uart3_resources), | 1008 | .num_resources = ARRAY_SIZE(uart3_resources), |
823 | }; | 1009 | }; |
824 | 1010 | ||
825 | static inline void configure_usart3_pins(void) | 1011 | static inline void configure_usart3_pins(unsigned pins) |
826 | { | 1012 | { |
827 | at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ | 1013 | at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ |
828 | at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ | 1014 | at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ |
1015 | |||
1016 | if (pins & ATMEL_UART_CTS) | ||
1017 | at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */ | ||
1018 | if (pins & ATMEL_UART_RTS) | ||
1019 | at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */ | ||
829 | } | 1020 | } |
830 | 1021 | ||
831 | struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 1022 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
832 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 1023 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
833 | 1024 | ||
834 | void __init at91_init_serial(struct at91_uart_config *config) | 1025 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
835 | { | 1026 | { |
836 | int i; | 1027 | int i; |
837 | 1028 | ||
@@ -839,22 +1030,22 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
839 | for (i = 0; i < config->nr_tty; i++) { | 1030 | for (i = 0; i < config->nr_tty; i++) { |
840 | switch (config->tty_map[i]) { | 1031 | switch (config->tty_map[i]) { |
841 | case 0: | 1032 | case 0: |
842 | configure_usart0_pins(); | 1033 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
843 | at91_uarts[i] = &at91rm9200_uart0_device; | 1034 | at91_uarts[i] = &at91rm9200_uart0_device; |
844 | at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); | 1035 | at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); |
845 | break; | 1036 | break; |
846 | case 1: | 1037 | case 1: |
847 | configure_usart1_pins(); | 1038 | configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI); |
848 | at91_uarts[i] = &at91rm9200_uart1_device; | 1039 | at91_uarts[i] = &at91rm9200_uart1_device; |
849 | at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); | 1040 | at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); |
850 | break; | 1041 | break; |
851 | case 2: | 1042 | case 2: |
852 | configure_usart2_pins(); | 1043 | configure_usart2_pins(0); |
853 | at91_uarts[i] = &at91rm9200_uart2_device; | 1044 | at91_uarts[i] = &at91rm9200_uart2_device; |
854 | at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); | 1045 | at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); |
855 | break; | 1046 | break; |
856 | case 3: | 1047 | case 3: |
857 | configure_usart3_pins(); | 1048 | configure_usart3_pins(0); |
858 | at91_uarts[i] = &at91rm9200_uart3_device; | 1049 | at91_uarts[i] = &at91rm9200_uart3_device; |
859 | at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); | 1050 | at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); |
860 | break; | 1051 | break; |
@@ -876,6 +1067,53 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
876 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 1067 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
877 | } | 1068 | } |
878 | 1069 | ||
1070 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
1071 | { | ||
1072 | struct platform_device *pdev; | ||
1073 | |||
1074 | switch (id) { | ||
1075 | case 0: /* DBGU */ | ||
1076 | pdev = &at91rm9200_dbgu_device; | ||
1077 | configure_dbgu_pins(); | ||
1078 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1079 | break; | ||
1080 | case AT91RM9200_ID_US0: | ||
1081 | pdev = &at91rm9200_uart0_device; | ||
1082 | configure_usart0_pins(pins); | ||
1083 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1084 | break; | ||
1085 | case AT91RM9200_ID_US1: | ||
1086 | pdev = &at91rm9200_uart1_device; | ||
1087 | configure_usart1_pins(pins); | ||
1088 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1089 | break; | ||
1090 | case AT91RM9200_ID_US2: | ||
1091 | pdev = &at91rm9200_uart2_device; | ||
1092 | configure_usart2_pins(pins); | ||
1093 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1094 | break; | ||
1095 | case AT91RM9200_ID_US3: | ||
1096 | pdev = &at91rm9200_uart3_device; | ||
1097 | configure_usart3_pins(pins); | ||
1098 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1099 | break; | ||
1100 | default: | ||
1101 | return; | ||
1102 | } | ||
1103 | pdev->id = portnr; /* update to mapped ID */ | ||
1104 | |||
1105 | if (portnr < ATMEL_MAX_UART) | ||
1106 | at91_uarts[portnr] = pdev; | ||
1107 | } | ||
1108 | |||
1109 | void __init at91_set_serial_console(unsigned portnr) | ||
1110 | { | ||
1111 | if (portnr < ATMEL_MAX_UART) | ||
1112 | atmel_default_console_device = at91_uarts[portnr]; | ||
1113 | if (!atmel_default_console_device) | ||
1114 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1115 | } | ||
1116 | |||
879 | void __init at91_add_device_serial(void) | 1117 | void __init at91_add_device_serial(void) |
880 | { | 1118 | { |
881 | int i; | 1119 | int i; |
@@ -886,7 +1124,9 @@ void __init at91_add_device_serial(void) | |||
886 | } | 1124 | } |
887 | } | 1125 | } |
888 | #else | 1126 | #else |
889 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1127 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
1128 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1129 | void __init at91_set_serial_console(unsigned portnr) {} | ||
890 | void __init at91_add_device_serial(void) {} | 1130 | void __init at91_add_device_serial(void) {} |
891 | #endif | 1131 | #endif |
892 | 1132 | ||