aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9rl_devices.c
diff options
context:
space:
mode:
authorAndrew Victor <linux@maxim.org.za>2008-01-23 03:25:15 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 10:00:32 -0500
commitc8f385a631ef1f49d67a3798ca40dec36ccdf07d (patch)
tree99b2e29909896d8b0389a6899c8c2f8ad1dc1865 /arch/arm/mach-at91/at91sam9rl_devices.c
parentb7b272a8826a2332f689853792eb8c42477fec85 (diff)
[ARM] 4757/1: [AT91] UART initialization
Modify the UART initialization to allow the board-initialization code to specify which pins are connected, and which pins should therefore be initialized. The current at91_init_serial() will continue to work as-is, but is marked as "deprecated" and will be removed once the board-specific files has been updated to use the new interface. As in the AVR32 code, we assume that the TX and RX pins will always be initialized. Signed-off-by: Andrew Victor <linux@maxim.org.za> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-at91/at91sam9rl_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c99
1 files changed, 87 insertions, 12 deletions
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
index e886cdfe919d..a942b9e35560 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -676,12 +676,23 @@ static struct platform_device at91sam9rl_uart0_device = {
676 .num_resources = ARRAY_SIZE(uart0_resources), 676 .num_resources = ARRAY_SIZE(uart0_resources),
677}; 677};
678 678
679static inline void configure_usart0_pins(void) 679static inline void configure_usart0_pins(unsigned pins)
680{ 680{
681 at91_set_A_periph(AT91_PIN_PA6, 1); /* TXD0 */ 681 at91_set_A_periph(AT91_PIN_PA6, 1); /* TXD0 */
682 at91_set_A_periph(AT91_PIN_PA7, 0); /* RXD0 */ 682 at91_set_A_periph(AT91_PIN_PA7, 0); /* RXD0 */
683 at91_set_A_periph(AT91_PIN_PA9, 0); /* RTS0 */ 683
684 at91_set_A_periph(AT91_PIN_PA10, 0); /* CTS0 */ 684 if (pins & ATMEL_UART_RTS)
685 at91_set_A_periph(AT91_PIN_PA9, 0); /* RTS0 */
686 if (pins & ATMEL_UART_CTS)
687 at91_set_A_periph(AT91_PIN_PA10, 0); /* CTS0 */
688 if (pins & ATMEL_UART_DSR)
689 at91_set_A_periph(AT91_PIN_PD14, 0); /* DSR0 */
690 if (pins & ATMEL_UART_DTR)
691 at91_set_A_periph(AT91_PIN_PD15, 0); /* DTR0 */
692 if (pins & ATMEL_UART_DCD)
693 at91_set_A_periph(AT91_PIN_PD16, 0); /* DCD0 */
694 if (pins & ATMEL_UART_RI)
695 at91_set_A_periph(AT91_PIN_PD17, 0); /* RI0 */
685} 696}
686 697
687static struct resource uart1_resources[] = { 698static struct resource uart1_resources[] = {
@@ -716,10 +727,15 @@ static struct platform_device at91sam9rl_uart1_device = {
716 .num_resources = ARRAY_SIZE(uart1_resources), 727 .num_resources = ARRAY_SIZE(uart1_resources),
717}; 728};
718 729
719static inline void configure_usart1_pins(void) 730static inline void configure_usart1_pins(unsigned pins)
720{ 731{
721 at91_set_A_periph(AT91_PIN_PA11, 1); /* TXD1 */ 732 at91_set_A_periph(AT91_PIN_PA11, 1); /* TXD1 */
722 at91_set_A_periph(AT91_PIN_PA12, 0); /* RXD1 */ 733 at91_set_A_periph(AT91_PIN_PA12, 0); /* RXD1 */
734
735 if (pins & ATMEL_UART_RTS)
736 at91_set_B_periph(AT91_PIN_PA18, 0); /* RTS1 */
737 if (pins & ATMEL_UART_CTS)
738 at91_set_B_periph(AT91_PIN_PA19, 0); /* CTS1 */
723} 739}
724 740
725static struct resource uart2_resources[] = { 741static struct resource uart2_resources[] = {
@@ -754,10 +770,15 @@ static struct platform_device at91sam9rl_uart2_device = {
754 .num_resources = ARRAY_SIZE(uart2_resources), 770 .num_resources = ARRAY_SIZE(uart2_resources),
755}; 771};
756 772
757static inline void configure_usart2_pins(void) 773static inline void configure_usart2_pins(unsigned pins)
758{ 774{
759 at91_set_A_periph(AT91_PIN_PA13, 1); /* TXD2 */ 775 at91_set_A_periph(AT91_PIN_PA13, 1); /* TXD2 */
760 at91_set_A_periph(AT91_PIN_PA14, 0); /* RXD2 */ 776 at91_set_A_periph(AT91_PIN_PA14, 0); /* RXD2 */
777
778 if (pins & ATMEL_UART_RTS)
779 at91_set_A_periph(AT91_PIN_PA29, 0); /* RTS2 */
780 if (pins & ATMEL_UART_CTS)
781 at91_set_A_periph(AT91_PIN_PA30, 0); /* CTS2 */
761} 782}
762 783
763static struct resource uart3_resources[] = { 784static struct resource uart3_resources[] = {
@@ -792,16 +813,21 @@ static struct platform_device at91sam9rl_uart3_device = {
792 .num_resources = ARRAY_SIZE(uart3_resources), 813 .num_resources = ARRAY_SIZE(uart3_resources),
793}; 814};
794 815
795static inline void configure_usart3_pins(void) 816static inline void configure_usart3_pins(unsigned pins)
796{ 817{
797 at91_set_A_periph(AT91_PIN_PB0, 1); /* TXD3 */ 818 at91_set_A_periph(AT91_PIN_PB0, 1); /* TXD3 */
798 at91_set_A_periph(AT91_PIN_PB1, 0); /* RXD3 */ 819 at91_set_A_periph(AT91_PIN_PB1, 0); /* RXD3 */
820
821 if (pins & ATMEL_UART_RTS)
822 at91_set_B_periph(AT91_PIN_PD4, 0); /* RTS3 */
823 if (pins & ATMEL_UART_CTS)
824 at91_set_B_periph(AT91_PIN_PD3, 0); /* CTS3 */
799} 825}
800 826
801static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 827static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
802struct platform_device *atmel_default_console_device; /* the serial console device */ 828struct platform_device *atmel_default_console_device; /* the serial console device */
803 829
804void __init at91_init_serial(struct at91_uart_config *config) 830void __init __deprecated at91_init_serial(struct at91_uart_config *config)
805{ 831{
806 int i; 832 int i;
807 833
@@ -809,22 +835,22 @@ void __init at91_init_serial(struct at91_uart_config *config)
809 for (i = 0; i < config->nr_tty; i++) { 835 for (i = 0; i < config->nr_tty; i++) {
810 switch (config->tty_map[i]) { 836 switch (config->tty_map[i]) {
811 case 0: 837 case 0:
812 configure_usart0_pins(); 838 configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS);
813 at91_uarts[i] = &at91sam9rl_uart0_device; 839 at91_uarts[i] = &at91sam9rl_uart0_device;
814 at91_clock_associate("usart0_clk", &at91sam9rl_uart0_device.dev, "usart"); 840 at91_clock_associate("usart0_clk", &at91sam9rl_uart0_device.dev, "usart");
815 break; 841 break;
816 case 1: 842 case 1:
817 configure_usart1_pins(); 843 configure_usart1_pins(0);
818 at91_uarts[i] = &at91sam9rl_uart1_device; 844 at91_uarts[i] = &at91sam9rl_uart1_device;
819 at91_clock_associate("usart1_clk", &at91sam9rl_uart1_device.dev, "usart"); 845 at91_clock_associate("usart1_clk", &at91sam9rl_uart1_device.dev, "usart");
820 break; 846 break;
821 case 2: 847 case 2:
822 configure_usart2_pins(); 848 configure_usart2_pins(0);
823 at91_uarts[i] = &at91sam9rl_uart2_device; 849 at91_uarts[i] = &at91sam9rl_uart2_device;
824 at91_clock_associate("usart2_clk", &at91sam9rl_uart2_device.dev, "usart"); 850 at91_clock_associate("usart2_clk", &at91sam9rl_uart2_device.dev, "usart");
825 break; 851 break;
826 case 3: 852 case 3:
827 configure_usart3_pins(); 853 configure_usart3_pins(0);
828 at91_uarts[i] = &at91sam9rl_uart3_device; 854 at91_uarts[i] = &at91sam9rl_uart3_device;
829 at91_clock_associate("usart3_clk", &at91sam9rl_uart3_device.dev, "usart"); 855 at91_clock_associate("usart3_clk", &at91sam9rl_uart3_device.dev, "usart");
830 break; 856 break;
@@ -846,6 +872,53 @@ void __init at91_init_serial(struct at91_uart_config *config)
846 printk(KERN_INFO "AT91: No default serial console defined.\n"); 872 printk(KERN_INFO "AT91: No default serial console defined.\n");
847} 873}
848 874
875void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins)
876{
877 struct platform_device *pdev;
878
879 switch (id) {
880 case 0: /* DBGU */
881 pdev = &at91sam9rl_dbgu_device;
882 configure_dbgu_pins();
883 at91_clock_associate("mck", &pdev->dev, "usart");
884 break;
885 case AT91SAM9RL_ID_US0:
886 pdev = &at91sam9rl_uart0_device;
887 configure_usart0_pins(pins);
888 at91_clock_associate("usart0_clk", &pdev->dev, "usart");
889 break;
890 case AT91SAM9RL_ID_US1:
891 pdev = &at91sam9rl_uart1_device;
892 configure_usart1_pins(pins);
893 at91_clock_associate("usart1_clk", &pdev->dev, "usart");
894 break;
895 case AT91SAM9RL_ID_US2:
896 pdev = &at91sam9rl_uart2_device;
897 configure_usart2_pins(pins);
898 at91_clock_associate("usart2_clk", &pdev->dev, "usart");
899 break;
900 case AT91SAM9RL_ID_US3:
901 pdev = &at91sam9rl_uart3_device;
902 configure_usart3_pins(pins);
903 at91_clock_associate("usart3_clk", &pdev->dev, "usart");
904 break;
905 default:
906 return;
907 }
908 pdev->id = portnr; /* update to mapped ID */
909
910 if (portnr < ATMEL_MAX_UART)
911 at91_uarts[portnr] = pdev;
912}
913
914void __init at91_set_serial_console(unsigned portnr)
915{
916 if (portnr < ATMEL_MAX_UART)
917 atmel_default_console_device = at91_uarts[portnr];
918 if (!atmel_default_console_device)
919 printk(KERN_INFO "AT91: No default serial console defined.\n");
920}
921
849void __init at91_add_device_serial(void) 922void __init at91_add_device_serial(void)
850{ 923{
851 int i; 924 int i;
@@ -856,7 +929,9 @@ void __init at91_add_device_serial(void)
856 } 929 }
857} 930}
858#else 931#else
859void __init at91_init_serial(struct at91_uart_config *config) {} 932void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
933void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
934void __init at91_set_serial_console(unsigned portnr) {}
860void __init at91_add_device_serial(void) {} 935void __init at91_add_device_serial(void) {}
861#endif 936#endif
862 937