diff options
Diffstat (limited to 'arch/arm/mach-at91')
-rw-r--r-- | arch/arm/mach-at91/at91rm9200_devices.c | 114 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 115 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9261_devices.c | 77 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9263_devices.c | 79 | ||||
-rw-r--r-- | arch/arm/mach-at91/at91sam9rl_devices.c | 99 |
5 files changed, 409 insertions, 75 deletions
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index a2647265c214..23966229ea9a 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c | |||
@@ -884,17 +884,21 @@ static struct platform_device at91rm9200_uart0_device = { | |||
884 | .num_resources = ARRAY_SIZE(uart0_resources), | 884 | .num_resources = ARRAY_SIZE(uart0_resources), |
885 | }; | 885 | }; |
886 | 886 | ||
887 | static inline void configure_usart0_pins(void) | 887 | static inline void configure_usart0_pins(unsigned pins) |
888 | { | 888 | { |
889 | at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ | 889 | at91_set_A_periph(AT91_PIN_PA17, 1); /* TXD0 */ |
890 | at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ | 890 | at91_set_A_periph(AT91_PIN_PA18, 0); /* RXD0 */ |
891 | at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ | ||
892 | 891 | ||
893 | /* | 892 | if (pins & ATMEL_UART_CTS) |
894 | * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. | 893 | at91_set_A_periph(AT91_PIN_PA20, 0); /* CTS0 */ |
895 | * We need to drive the pin manually. Default is off (RTS is active low). | 894 | |
896 | */ | 895 | if (pins & ATMEL_UART_RTS) { |
897 | at91_set_gpio_output(AT91_PIN_PA21, 1); | 896 | /* |
897 | * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. | ||
898 | * We need to drive the pin manually. Default is off (RTS is active low). | ||
899 | */ | ||
900 | at91_set_gpio_output(AT91_PIN_PA21, 1); | ||
901 | } | ||
898 | } | 902 | } |
899 | 903 | ||
900 | static struct resource uart1_resources[] = { | 904 | static struct resource uart1_resources[] = { |
@@ -929,16 +933,23 @@ static struct platform_device at91rm9200_uart1_device = { | |||
929 | .num_resources = ARRAY_SIZE(uart1_resources), | 933 | .num_resources = ARRAY_SIZE(uart1_resources), |
930 | }; | 934 | }; |
931 | 935 | ||
932 | static inline void configure_usart1_pins(void) | 936 | static inline void configure_usart1_pins(unsigned pins) |
933 | { | 937 | { |
934 | at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ | ||
935 | at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ | ||
936 | at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ | 938 | at91_set_A_periph(AT91_PIN_PB20, 1); /* TXD1 */ |
937 | at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ | 939 | at91_set_A_periph(AT91_PIN_PB21, 0); /* RXD1 */ |
938 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ | 940 | |
939 | at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ | 941 | if (pins & ATMEL_UART_RI) |
940 | at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ | 942 | at91_set_A_periph(AT91_PIN_PB18, 0); /* RI1 */ |
941 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ | 943 | if (pins & ATMEL_UART_DTR) |
944 | at91_set_A_periph(AT91_PIN_PB19, 0); /* DTR1 */ | ||
945 | if (pins & ATMEL_UART_DCD) | ||
946 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD1 */ | ||
947 | if (pins & ATMEL_UART_CTS) | ||
948 | at91_set_A_periph(AT91_PIN_PB24, 0); /* CTS1 */ | ||
949 | if (pins & ATMEL_UART_DSR) | ||
950 | at91_set_A_periph(AT91_PIN_PB25, 0); /* DSR1 */ | ||
951 | if (pins & ATMEL_UART_RTS) | ||
952 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS1 */ | ||
942 | } | 953 | } |
943 | 954 | ||
944 | static struct resource uart2_resources[] = { | 955 | static struct resource uart2_resources[] = { |
@@ -973,10 +984,15 @@ static struct platform_device at91rm9200_uart2_device = { | |||
973 | .num_resources = ARRAY_SIZE(uart2_resources), | 984 | .num_resources = ARRAY_SIZE(uart2_resources), |
974 | }; | 985 | }; |
975 | 986 | ||
976 | static inline void configure_usart2_pins(void) | 987 | static inline void configure_usart2_pins(unsigned pins) |
977 | { | 988 | { |
978 | at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ | 989 | at91_set_A_periph(AT91_PIN_PA22, 0); /* RXD2 */ |
979 | at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ | 990 | at91_set_A_periph(AT91_PIN_PA23, 1); /* TXD2 */ |
991 | |||
992 | if (pins & ATMEL_UART_CTS) | ||
993 | at91_set_B_periph(AT91_PIN_PA30, 0); /* CTS2 */ | ||
994 | if (pins & ATMEL_UART_RTS) | ||
995 | at91_set_B_periph(AT91_PIN_PA31, 0); /* RTS2 */ | ||
980 | } | 996 | } |
981 | 997 | ||
982 | static struct resource uart3_resources[] = { | 998 | static struct resource uart3_resources[] = { |
@@ -1011,16 +1027,21 @@ static struct platform_device at91rm9200_uart3_device = { | |||
1011 | .num_resources = ARRAY_SIZE(uart3_resources), | 1027 | .num_resources = ARRAY_SIZE(uart3_resources), |
1012 | }; | 1028 | }; |
1013 | 1029 | ||
1014 | static inline void configure_usart3_pins(void) | 1030 | static inline void configure_usart3_pins(unsigned pins) |
1015 | { | 1031 | { |
1016 | at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ | 1032 | at91_set_B_periph(AT91_PIN_PA5, 1); /* TXD3 */ |
1017 | at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ | 1033 | at91_set_B_periph(AT91_PIN_PA6, 0); /* RXD3 */ |
1034 | |||
1035 | if (pins & ATMEL_UART_CTS) | ||
1036 | at91_set_B_periph(AT91_PIN_PB1, 0); /* CTS3 */ | ||
1037 | if (pins & ATMEL_UART_RTS) | ||
1038 | at91_set_B_periph(AT91_PIN_PB0, 0); /* RTS3 */ | ||
1018 | } | 1039 | } |
1019 | 1040 | ||
1020 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 1041 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
1021 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 1042 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
1022 | 1043 | ||
1023 | void __init at91_init_serial(struct at91_uart_config *config) | 1044 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
1024 | { | 1045 | { |
1025 | int i; | 1046 | int i; |
1026 | 1047 | ||
@@ -1028,22 +1049,22 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
1028 | for (i = 0; i < config->nr_tty; i++) { | 1049 | for (i = 0; i < config->nr_tty; i++) { |
1029 | switch (config->tty_map[i]) { | 1050 | switch (config->tty_map[i]) { |
1030 | case 0: | 1051 | case 0: |
1031 | configure_usart0_pins(); | 1052 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
1032 | at91_uarts[i] = &at91rm9200_uart0_device; | 1053 | at91_uarts[i] = &at91rm9200_uart0_device; |
1033 | at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); | 1054 | at91_clock_associate("usart0_clk", &at91rm9200_uart0_device.dev, "usart"); |
1034 | break; | 1055 | break; |
1035 | case 1: | 1056 | case 1: |
1036 | configure_usart1_pins(); | 1057 | configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI); |
1037 | at91_uarts[i] = &at91rm9200_uart1_device; | 1058 | at91_uarts[i] = &at91rm9200_uart1_device; |
1038 | at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); | 1059 | at91_clock_associate("usart1_clk", &at91rm9200_uart1_device.dev, "usart"); |
1039 | break; | 1060 | break; |
1040 | case 2: | 1061 | case 2: |
1041 | configure_usart2_pins(); | 1062 | configure_usart2_pins(0); |
1042 | at91_uarts[i] = &at91rm9200_uart2_device; | 1063 | at91_uarts[i] = &at91rm9200_uart2_device; |
1043 | at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); | 1064 | at91_clock_associate("usart2_clk", &at91rm9200_uart2_device.dev, "usart"); |
1044 | break; | 1065 | break; |
1045 | case 3: | 1066 | case 3: |
1046 | configure_usart3_pins(); | 1067 | configure_usart3_pins(0); |
1047 | at91_uarts[i] = &at91rm9200_uart3_device; | 1068 | at91_uarts[i] = &at91rm9200_uart3_device; |
1048 | at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); | 1069 | at91_clock_associate("usart3_clk", &at91rm9200_uart3_device.dev, "usart"); |
1049 | break; | 1070 | break; |
@@ -1065,6 +1086,53 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
1065 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 1086 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
1066 | } | 1087 | } |
1067 | 1088 | ||
1089 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
1090 | { | ||
1091 | struct platform_device *pdev; | ||
1092 | |||
1093 | switch (id) { | ||
1094 | case 0: /* DBGU */ | ||
1095 | pdev = &at91rm9200_dbgu_device; | ||
1096 | configure_dbgu_pins(); | ||
1097 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1098 | break; | ||
1099 | case AT91RM9200_ID_US0: | ||
1100 | pdev = &at91rm9200_uart0_device; | ||
1101 | configure_usart0_pins(pins); | ||
1102 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1103 | break; | ||
1104 | case AT91RM9200_ID_US1: | ||
1105 | pdev = &at91rm9200_uart1_device; | ||
1106 | configure_usart1_pins(pins); | ||
1107 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1108 | break; | ||
1109 | case AT91RM9200_ID_US2: | ||
1110 | pdev = &at91rm9200_uart2_device; | ||
1111 | configure_usart2_pins(pins); | ||
1112 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1113 | break; | ||
1114 | case AT91RM9200_ID_US3: | ||
1115 | pdev = &at91rm9200_uart3_device; | ||
1116 | configure_usart3_pins(pins); | ||
1117 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1118 | break; | ||
1119 | default: | ||
1120 | return; | ||
1121 | } | ||
1122 | pdev->id = portnr; /* update to mapped ID */ | ||
1123 | |||
1124 | if (portnr < ATMEL_MAX_UART) | ||
1125 | at91_uarts[portnr] = pdev; | ||
1126 | } | ||
1127 | |||
1128 | void __init at91_set_serial_console(unsigned portnr) | ||
1129 | { | ||
1130 | if (portnr < ATMEL_MAX_UART) | ||
1131 | atmel_default_console_device = at91_uarts[portnr]; | ||
1132 | if (!atmel_default_console_device) | ||
1133 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1134 | } | ||
1135 | |||
1068 | void __init at91_add_device_serial(void) | 1136 | void __init at91_add_device_serial(void) |
1069 | { | 1137 | { |
1070 | int i; | 1138 | int i; |
@@ -1075,7 +1143,9 @@ void __init at91_add_device_serial(void) | |||
1075 | } | 1143 | } |
1076 | } | 1144 | } |
1077 | #else | 1145 | #else |
1078 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1146 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
1147 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1148 | void __init at91_set_serial_console(unsigned portnr) {} | ||
1079 | void __init at91_add_device_serial(void) {} | 1149 | void __init at91_add_device_serial(void) {} |
1080 | #endif | 1150 | #endif |
1081 | 1151 | ||
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index 8acd62b75cb0..5dd06bdccb00 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
@@ -760,16 +760,23 @@ static struct platform_device at91sam9260_uart0_device = { | |||
760 | .num_resources = ARRAY_SIZE(uart0_resources), | 760 | .num_resources = ARRAY_SIZE(uart0_resources), |
761 | }; | 761 | }; |
762 | 762 | ||
763 | static inline void configure_usart0_pins(void) | 763 | static inline void configure_usart0_pins(unsigned pins) |
764 | { | 764 | { |
765 | at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */ | 765 | at91_set_A_periph(AT91_PIN_PB4, 1); /* TXD0 */ |
766 | at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD0 */ | 766 | at91_set_A_periph(AT91_PIN_PB5, 0); /* RXD0 */ |
767 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS0 */ | 767 | |
768 | at91_set_A_periph(AT91_PIN_PB27, 0); /* CTS0 */ | 768 | if (pins & ATMEL_UART_RTS) |
769 | at91_set_A_periph(AT91_PIN_PB24, 0); /* DTR0 */ | 769 | at91_set_A_periph(AT91_PIN_PB26, 0); /* RTS0 */ |
770 | at91_set_A_periph(AT91_PIN_PB22, 0); /* DSR0 */ | 770 | if (pins & ATMEL_UART_CTS) |
771 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD0 */ | 771 | at91_set_A_periph(AT91_PIN_PB27, 0); /* CTS0 */ |
772 | at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */ | 772 | if (pins & ATMEL_UART_DTR) |
773 | at91_set_A_periph(AT91_PIN_PB24, 0); /* DTR0 */ | ||
774 | if (pins & ATMEL_UART_DSR) | ||
775 | at91_set_A_periph(AT91_PIN_PB22, 0); /* DSR0 */ | ||
776 | if (pins & ATMEL_UART_DCD) | ||
777 | at91_set_A_periph(AT91_PIN_PB23, 0); /* DCD0 */ | ||
778 | if (pins & ATMEL_UART_RI) | ||
779 | at91_set_A_periph(AT91_PIN_PB25, 0); /* RI0 */ | ||
773 | } | 780 | } |
774 | 781 | ||
775 | static struct resource uart1_resources[] = { | 782 | static struct resource uart1_resources[] = { |
@@ -804,12 +811,15 @@ static struct platform_device at91sam9260_uart1_device = { | |||
804 | .num_resources = ARRAY_SIZE(uart1_resources), | 811 | .num_resources = ARRAY_SIZE(uart1_resources), |
805 | }; | 812 | }; |
806 | 813 | ||
807 | static inline void configure_usart1_pins(void) | 814 | static inline void configure_usart1_pins(unsigned pins) |
808 | { | 815 | { |
809 | at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */ | 816 | at91_set_A_periph(AT91_PIN_PB6, 1); /* TXD1 */ |
810 | at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD1 */ | 817 | at91_set_A_periph(AT91_PIN_PB7, 0); /* RXD1 */ |
811 | at91_set_A_periph(AT91_PIN_PB28, 0); /* RTS1 */ | 818 | |
812 | at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */ | 819 | if (pins & ATMEL_UART_RTS) |
820 | at91_set_A_periph(AT91_PIN_PB28, 0); /* RTS1 */ | ||
821 | if (pins & ATMEL_UART_CTS) | ||
822 | at91_set_A_periph(AT91_PIN_PB29, 0); /* CTS1 */ | ||
813 | } | 823 | } |
814 | 824 | ||
815 | static struct resource uart2_resources[] = { | 825 | static struct resource uart2_resources[] = { |
@@ -844,10 +854,15 @@ static struct platform_device at91sam9260_uart2_device = { | |||
844 | .num_resources = ARRAY_SIZE(uart2_resources), | 854 | .num_resources = ARRAY_SIZE(uart2_resources), |
845 | }; | 855 | }; |
846 | 856 | ||
847 | static inline void configure_usart2_pins(void) | 857 | static inline void configure_usart2_pins(unsigned pins) |
848 | { | 858 | { |
849 | at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */ | 859 | at91_set_A_periph(AT91_PIN_PB8, 1); /* TXD2 */ |
850 | at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD2 */ | 860 | at91_set_A_periph(AT91_PIN_PB9, 0); /* RXD2 */ |
861 | |||
862 | if (pins & ATMEL_UART_RTS) | ||
863 | at91_set_A_periph(AT91_PIN_PA4, 0); /* RTS2 */ | ||
864 | if (pins & ATMEL_UART_CTS) | ||
865 | at91_set_A_periph(AT91_PIN_PA5, 0); /* CTS2 */ | ||
851 | } | 866 | } |
852 | 867 | ||
853 | static struct resource uart3_resources[] = { | 868 | static struct resource uart3_resources[] = { |
@@ -882,10 +897,15 @@ static struct platform_device at91sam9260_uart3_device = { | |||
882 | .num_resources = ARRAY_SIZE(uart3_resources), | 897 | .num_resources = ARRAY_SIZE(uart3_resources), |
883 | }; | 898 | }; |
884 | 899 | ||
885 | static inline void configure_usart3_pins(void) | 900 | static inline void configure_usart3_pins(unsigned pins) |
886 | { | 901 | { |
887 | at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */ | 902 | at91_set_A_periph(AT91_PIN_PB10, 1); /* TXD3 */ |
888 | at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD3 */ | 903 | at91_set_A_periph(AT91_PIN_PB11, 0); /* RXD3 */ |
904 | |||
905 | if (pins & ATMEL_UART_RTS) | ||
906 | at91_set_B_periph(AT91_PIN_PC8, 0); /* RTS3 */ | ||
907 | if (pins & ATMEL_UART_CTS) | ||
908 | at91_set_B_periph(AT91_PIN_PC10, 0); /* CTS3 */ | ||
889 | } | 909 | } |
890 | 910 | ||
891 | static struct resource uart4_resources[] = { | 911 | static struct resource uart4_resources[] = { |
@@ -967,7 +987,7 @@ static inline void configure_usart5_pins(void) | |||
967 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 987 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
968 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 988 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
969 | 989 | ||
970 | void __init at91_init_serial(struct at91_uart_config *config) | 990 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
971 | { | 991 | { |
972 | int i; | 992 | int i; |
973 | 993 | ||
@@ -975,22 +995,22 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
975 | for (i = 0; i < config->nr_tty; i++) { | 995 | for (i = 0; i < config->nr_tty; i++) { |
976 | switch (config->tty_map[i]) { | 996 | switch (config->tty_map[i]) { |
977 | case 0: | 997 | case 0: |
978 | configure_usart0_pins(); | 998 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS | ATMEL_UART_DSR | ATMEL_UART_DTR | ATMEL_UART_DCD | ATMEL_UART_RI); |
979 | at91_uarts[i] = &at91sam9260_uart0_device; | 999 | at91_uarts[i] = &at91sam9260_uart0_device; |
980 | at91_clock_associate("usart0_clk", &at91sam9260_uart0_device.dev, "usart"); | 1000 | at91_clock_associate("usart0_clk", &at91sam9260_uart0_device.dev, "usart"); |
981 | break; | 1001 | break; |
982 | case 1: | 1002 | case 1: |
983 | configure_usart1_pins(); | 1003 | configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
984 | at91_uarts[i] = &at91sam9260_uart1_device; | 1004 | at91_uarts[i] = &at91sam9260_uart1_device; |
985 | at91_clock_associate("usart1_clk", &at91sam9260_uart1_device.dev, "usart"); | 1005 | at91_clock_associate("usart1_clk", &at91sam9260_uart1_device.dev, "usart"); |
986 | break; | 1006 | break; |
987 | case 2: | 1007 | case 2: |
988 | configure_usart2_pins(); | 1008 | configure_usart2_pins(0); |
989 | at91_uarts[i] = &at91sam9260_uart2_device; | 1009 | at91_uarts[i] = &at91sam9260_uart2_device; |
990 | at91_clock_associate("usart2_clk", &at91sam9260_uart2_device.dev, "usart"); | 1010 | at91_clock_associate("usart2_clk", &at91sam9260_uart2_device.dev, "usart"); |
991 | break; | 1011 | break; |
992 | case 3: | 1012 | case 3: |
993 | configure_usart3_pins(); | 1013 | configure_usart3_pins(0); |
994 | at91_uarts[i] = &at91sam9260_uart3_device; | 1014 | at91_uarts[i] = &at91sam9260_uart3_device; |
995 | at91_clock_associate("usart3_clk", &at91sam9260_uart3_device.dev, "usart"); | 1015 | at91_clock_associate("usart3_clk", &at91sam9260_uart3_device.dev, "usart"); |
996 | break; | 1016 | break; |
@@ -1022,6 +1042,63 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
1022 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 1042 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
1023 | } | 1043 | } |
1024 | 1044 | ||
1045 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
1046 | { | ||
1047 | struct platform_device *pdev; | ||
1048 | |||
1049 | switch (id) { | ||
1050 | case 0: /* DBGU */ | ||
1051 | pdev = &at91sam9260_dbgu_device; | ||
1052 | configure_dbgu_pins(); | ||
1053 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1054 | break; | ||
1055 | case AT91SAM9260_ID_US0: | ||
1056 | pdev = &at91sam9260_uart0_device; | ||
1057 | configure_usart0_pins(pins); | ||
1058 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1059 | break; | ||
1060 | case AT91SAM9260_ID_US1: | ||
1061 | pdev = &at91sam9260_uart1_device; | ||
1062 | configure_usart1_pins(pins); | ||
1063 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1064 | break; | ||
1065 | case AT91SAM9260_ID_US2: | ||
1066 | pdev = &at91sam9260_uart2_device; | ||
1067 | configure_usart2_pins(pins); | ||
1068 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1069 | break; | ||
1070 | case AT91SAM9260_ID_US3: | ||
1071 | pdev = &at91sam9260_uart3_device; | ||
1072 | configure_usart3_pins(pins); | ||
1073 | at91_clock_associate("usart3_clk", &pdev->dev, "usart"); | ||
1074 | break; | ||
1075 | case AT91SAM9260_ID_US4: | ||
1076 | pdev = &at91sam9260_uart4_device; | ||
1077 | configure_usart4_pins(); | ||
1078 | at91_clock_associate("usart4_clk", &pdev->dev, "usart"); | ||
1079 | break; | ||
1080 | case AT91SAM9260_ID_US5: | ||
1081 | pdev = &at91sam9260_uart5_device; | ||
1082 | configure_usart5_pins(); | ||
1083 | at91_clock_associate("usart5_clk", &pdev->dev, "usart"); | ||
1084 | break; | ||
1085 | default: | ||
1086 | return; | ||
1087 | } | ||
1088 | pdev->id = portnr; /* update to mapped ID */ | ||
1089 | |||
1090 | if (portnr < ATMEL_MAX_UART) | ||
1091 | at91_uarts[portnr] = pdev; | ||
1092 | } | ||
1093 | |||
1094 | void __init at91_set_serial_console(unsigned portnr) | ||
1095 | { | ||
1096 | if (portnr < ATMEL_MAX_UART) | ||
1097 | atmel_default_console_device = at91_uarts[portnr]; | ||
1098 | if (!atmel_default_console_device) | ||
1099 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1100 | } | ||
1101 | |||
1025 | void __init at91_add_device_serial(void) | 1102 | void __init at91_add_device_serial(void) |
1026 | { | 1103 | { |
1027 | int i; | 1104 | int i; |
@@ -1032,7 +1109,9 @@ void __init at91_add_device_serial(void) | |||
1032 | } | 1109 | } |
1033 | } | 1110 | } |
1034 | #else | 1111 | #else |
1035 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1112 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
1113 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1114 | void __init at91_set_serial_console(unsigned portnr) {} | ||
1036 | void __init at91_add_device_serial(void) {} | 1115 | void __init at91_add_device_serial(void) {} |
1037 | #endif | 1116 | #endif |
1038 | 1117 | ||
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index ba84ba6f18fb..467a6431d71a 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c | |||
@@ -867,12 +867,15 @@ static struct platform_device at91sam9261_uart0_device = { | |||
867 | .num_resources = ARRAY_SIZE(uart0_resources), | 867 | .num_resources = ARRAY_SIZE(uart0_resources), |
868 | }; | 868 | }; |
869 | 869 | ||
870 | static inline void configure_usart0_pins(void) | 870 | static inline void configure_usart0_pins(unsigned pins) |
871 | { | 871 | { |
872 | at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ | 872 | at91_set_A_periph(AT91_PIN_PC8, 1); /* TXD0 */ |
873 | at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ | 873 | at91_set_A_periph(AT91_PIN_PC9, 0); /* RXD0 */ |
874 | at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ | 874 | |
875 | at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ | 875 | if (pins & ATMEL_UART_RTS) |
876 | at91_set_A_periph(AT91_PIN_PC10, 0); /* RTS0 */ | ||
877 | if (pins & ATMEL_UART_CTS) | ||
878 | at91_set_A_periph(AT91_PIN_PC11, 0); /* CTS0 */ | ||
876 | } | 879 | } |
877 | 880 | ||
878 | static struct resource uart1_resources[] = { | 881 | static struct resource uart1_resources[] = { |
@@ -907,10 +910,15 @@ static struct platform_device at91sam9261_uart1_device = { | |||
907 | .num_resources = ARRAY_SIZE(uart1_resources), | 910 | .num_resources = ARRAY_SIZE(uart1_resources), |
908 | }; | 911 | }; |
909 | 912 | ||
910 | static inline void configure_usart1_pins(void) | 913 | static inline void configure_usart1_pins(unsigned pins) |
911 | { | 914 | { |
912 | at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ | 915 | at91_set_A_periph(AT91_PIN_PC12, 1); /* TXD1 */ |
913 | at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ | 916 | at91_set_A_periph(AT91_PIN_PC13, 0); /* RXD1 */ |
917 | |||
918 | if (pins & ATMEL_UART_RTS) | ||
919 | at91_set_B_periph(AT91_PIN_PA12, 0); /* RTS1 */ | ||
920 | if (pins & ATMEL_UART_CTS) | ||
921 | at91_set_B_periph(AT91_PIN_PA13, 0); /* CTS1 */ | ||
914 | } | 922 | } |
915 | 923 | ||
916 | static struct resource uart2_resources[] = { | 924 | static struct resource uart2_resources[] = { |
@@ -945,16 +953,21 @@ static struct platform_device at91sam9261_uart2_device = { | |||
945 | .num_resources = ARRAY_SIZE(uart2_resources), | 953 | .num_resources = ARRAY_SIZE(uart2_resources), |
946 | }; | 954 | }; |
947 | 955 | ||
948 | static inline void configure_usart2_pins(void) | 956 | static inline void configure_usart2_pins(unsigned pins) |
949 | { | 957 | { |
950 | at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ | 958 | at91_set_A_periph(AT91_PIN_PC15, 0); /* RXD2 */ |
951 | at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ | 959 | at91_set_A_periph(AT91_PIN_PC14, 1); /* TXD2 */ |
960 | |||
961 | if (pins & ATMEL_UART_RTS) | ||
962 | at91_set_B_periph(AT91_PIN_PA15, 0); /* RTS2*/ | ||
963 | if (pins & ATMEL_UART_CTS) | ||
964 | at91_set_B_periph(AT91_PIN_PA16, 0); /* CTS2 */ | ||
952 | } | 965 | } |
953 | 966 | ||
954 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 967 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
955 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 968 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
956 | 969 | ||
957 | void __init at91_init_serial(struct at91_uart_config *config) | 970 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
958 | { | 971 | { |
959 | int i; | 972 | int i; |
960 | 973 | ||
@@ -962,17 +975,17 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
962 | for (i = 0; i < config->nr_tty; i++) { | 975 | for (i = 0; i < config->nr_tty; i++) { |
963 | switch (config->tty_map[i]) { | 976 | switch (config->tty_map[i]) { |
964 | case 0: | 977 | case 0: |
965 | configure_usart0_pins(); | 978 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
966 | at91_uarts[i] = &at91sam9261_uart0_device; | 979 | at91_uarts[i] = &at91sam9261_uart0_device; |
967 | at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart"); | 980 | at91_clock_associate("usart0_clk", &at91sam9261_uart0_device.dev, "usart"); |
968 | break; | 981 | break; |
969 | case 1: | 982 | case 1: |
970 | configure_usart1_pins(); | 983 | configure_usart1_pins(0); |
971 | at91_uarts[i] = &at91sam9261_uart1_device; | 984 | at91_uarts[i] = &at91sam9261_uart1_device; |
972 | at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart"); | 985 | at91_clock_associate("usart1_clk", &at91sam9261_uart1_device.dev, "usart"); |
973 | break; | 986 | break; |
974 | case 2: | 987 | case 2: |
975 | configure_usart2_pins(); | 988 | configure_usart2_pins(0); |
976 | at91_uarts[i] = &at91sam9261_uart2_device; | 989 | at91_uarts[i] = &at91sam9261_uart2_device; |
977 | at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart"); | 990 | at91_clock_associate("usart2_clk", &at91sam9261_uart2_device.dev, "usart"); |
978 | break; | 991 | break; |
@@ -994,6 +1007,48 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
994 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 1007 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
995 | } | 1008 | } |
996 | 1009 | ||
1010 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
1011 | { | ||
1012 | struct platform_device *pdev; | ||
1013 | |||
1014 | switch (id) { | ||
1015 | case 0: /* DBGU */ | ||
1016 | pdev = &at91sam9261_dbgu_device; | ||
1017 | configure_dbgu_pins(); | ||
1018 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1019 | break; | ||
1020 | case AT91SAM9261_ID_US0: | ||
1021 | pdev = &at91sam9261_uart0_device; | ||
1022 | configure_usart0_pins(pins); | ||
1023 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1024 | break; | ||
1025 | case AT91SAM9261_ID_US1: | ||
1026 | pdev = &at91sam9261_uart1_device; | ||
1027 | configure_usart1_pins(pins); | ||
1028 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1029 | break; | ||
1030 | case AT91SAM9261_ID_US2: | ||
1031 | pdev = &at91sam9261_uart2_device; | ||
1032 | configure_usart2_pins(pins); | ||
1033 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1034 | break; | ||
1035 | default: | ||
1036 | return; | ||
1037 | } | ||
1038 | pdev->id = portnr; /* update to mapped ID */ | ||
1039 | |||
1040 | if (portnr < ATMEL_MAX_UART) | ||
1041 | at91_uarts[portnr] = pdev; | ||
1042 | } | ||
1043 | |||
1044 | void __init at91_set_serial_console(unsigned portnr) | ||
1045 | { | ||
1046 | if (portnr < ATMEL_MAX_UART) | ||
1047 | atmel_default_console_device = at91_uarts[portnr]; | ||
1048 | if (!atmel_default_console_device) | ||
1049 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1050 | } | ||
1051 | |||
997 | void __init at91_add_device_serial(void) | 1052 | void __init at91_add_device_serial(void) |
998 | { | 1053 | { |
999 | int i; | 1054 | int i; |
@@ -1004,7 +1059,9 @@ void __init at91_add_device_serial(void) | |||
1004 | } | 1059 | } |
1005 | } | 1060 | } |
1006 | #else | 1061 | #else |
1007 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1062 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
1063 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1064 | void __init at91_set_serial_console(unsigned portnr) {} | ||
1008 | void __init at91_add_device_serial(void) {} | 1065 | void __init at91_add_device_serial(void) {} |
1009 | #endif | 1066 | #endif |
1010 | 1067 | ||
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index c025f5c5ffaa..a9f35d0c1cb0 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
@@ -1071,12 +1071,15 @@ static struct platform_device at91sam9263_uart0_device = { | |||
1071 | .num_resources = ARRAY_SIZE(uart0_resources), | 1071 | .num_resources = ARRAY_SIZE(uart0_resources), |
1072 | }; | 1072 | }; |
1073 | 1073 | ||
1074 | static inline void configure_usart0_pins(void) | 1074 | static inline void configure_usart0_pins(unsigned pins) |
1075 | { | 1075 | { |
1076 | at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */ | 1076 | at91_set_A_periph(AT91_PIN_PA26, 1); /* TXD0 */ |
1077 | at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */ | 1077 | at91_set_A_periph(AT91_PIN_PA27, 0); /* RXD0 */ |
1078 | at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */ | 1078 | |
1079 | at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */ | 1079 | if (pins & ATMEL_UART_RTS) |
1080 | at91_set_A_periph(AT91_PIN_PA28, 0); /* RTS0 */ | ||
1081 | if (pins & ATMEL_UART_CTS) | ||
1082 | at91_set_A_periph(AT91_PIN_PA29, 0); /* CTS0 */ | ||
1080 | } | 1083 | } |
1081 | 1084 | ||
1082 | static struct resource uart1_resources[] = { | 1085 | static struct resource uart1_resources[] = { |
@@ -1111,12 +1114,15 @@ static struct platform_device at91sam9263_uart1_device = { | |||
1111 | .num_resources = ARRAY_SIZE(uart1_resources), | 1114 | .num_resources = ARRAY_SIZE(uart1_resources), |
1112 | }; | 1115 | }; |
1113 | 1116 | ||
1114 | static inline void configure_usart1_pins(void) | 1117 | static inline void configure_usart1_pins(unsigned pins) |
1115 | { | 1118 | { |
1116 | at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ | 1119 | at91_set_A_periph(AT91_PIN_PD0, 1); /* TXD1 */ |
1117 | at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ | 1120 | at91_set_A_periph(AT91_PIN_PD1, 0); /* RXD1 */ |
1118 | at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ | 1121 | |
1119 | at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ | 1122 | if (pins & ATMEL_UART_RTS) |
1123 | at91_set_B_periph(AT91_PIN_PD7, 0); /* RTS1 */ | ||
1124 | if (pins & ATMEL_UART_CTS) | ||
1125 | at91_set_B_periph(AT91_PIN_PD8, 0); /* CTS1 */ | ||
1120 | } | 1126 | } |
1121 | 1127 | ||
1122 | static struct resource uart2_resources[] = { | 1128 | static struct resource uart2_resources[] = { |
@@ -1151,18 +1157,21 @@ static struct platform_device at91sam9263_uart2_device = { | |||
1151 | .num_resources = ARRAY_SIZE(uart2_resources), | 1157 | .num_resources = ARRAY_SIZE(uart2_resources), |
1152 | }; | 1158 | }; |
1153 | 1159 | ||
1154 | static inline void configure_usart2_pins(void) | 1160 | static inline void configure_usart2_pins(unsigned pins) |
1155 | { | 1161 | { |
1156 | at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ | 1162 | at91_set_A_periph(AT91_PIN_PD2, 1); /* TXD2 */ |
1157 | at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ | 1163 | at91_set_A_periph(AT91_PIN_PD3, 0); /* RXD2 */ |
1158 | at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ | 1164 | |
1159 | at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ | 1165 | if (pins & ATMEL_UART_RTS) |
1166 | at91_set_B_periph(AT91_PIN_PD5, 0); /* RTS2 */ | ||
1167 | if (pins & ATMEL_UART_CTS) | ||
1168 | at91_set_B_periph(AT91_PIN_PD6, 0); /* CTS2 */ | ||
1160 | } | 1169 | } |
1161 | 1170 | ||
1162 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 1171 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
1163 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 1172 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
1164 | 1173 | ||
1165 | void __init at91_init_serial(struct at91_uart_config *config) | 1174 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) |
1166 | { | 1175 | { |
1167 | int i; | 1176 | int i; |
1168 | 1177 | ||
@@ -1170,17 +1179,17 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
1170 | for (i = 0; i < config->nr_tty; i++) { | 1179 | for (i = 0; i < config->nr_tty; i++) { |
1171 | switch (config->tty_map[i]) { | 1180 | switch (config->tty_map[i]) { |
1172 | case 0: | 1181 | case 0: |
1173 | configure_usart0_pins(); | 1182 | configure_usart0_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
1174 | at91_uarts[i] = &at91sam9263_uart0_device; | 1183 | at91_uarts[i] = &at91sam9263_uart0_device; |
1175 | at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart"); | 1184 | at91_clock_associate("usart0_clk", &at91sam9263_uart0_device.dev, "usart"); |
1176 | break; | 1185 | break; |
1177 | case 1: | 1186 | case 1: |
1178 | configure_usart1_pins(); | 1187 | configure_usart1_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
1179 | at91_uarts[i] = &at91sam9263_uart1_device; | 1188 | at91_uarts[i] = &at91sam9263_uart1_device; |
1180 | at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart"); | 1189 | at91_clock_associate("usart1_clk", &at91sam9263_uart1_device.dev, "usart"); |
1181 | break; | 1190 | break; |
1182 | case 2: | 1191 | case 2: |
1183 | configure_usart2_pins(); | 1192 | configure_usart2_pins(ATMEL_UART_CTS | ATMEL_UART_RTS); |
1184 | at91_uarts[i] = &at91sam9263_uart2_device; | 1193 | at91_uarts[i] = &at91sam9263_uart2_device; |
1185 | at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart"); | 1194 | at91_clock_associate("usart2_clk", &at91sam9263_uart2_device.dev, "usart"); |
1186 | break; | 1195 | break; |
@@ -1202,6 +1211,48 @@ void __init at91_init_serial(struct at91_uart_config *config) | |||
1202 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | 1211 | printk(KERN_INFO "AT91: No default serial console defined.\n"); |
1203 | } | 1212 | } |
1204 | 1213 | ||
1214 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) | ||
1215 | { | ||
1216 | struct platform_device *pdev; | ||
1217 | |||
1218 | switch (id) { | ||
1219 | case 0: /* DBGU */ | ||
1220 | pdev = &at91sam9263_dbgu_device; | ||
1221 | configure_dbgu_pins(); | ||
1222 | at91_clock_associate("mck", &pdev->dev, "usart"); | ||
1223 | break; | ||
1224 | case AT91SAM9263_ID_US0: | ||
1225 | pdev = &at91sam9263_uart0_device; | ||
1226 | configure_usart0_pins(pins); | ||
1227 | at91_clock_associate("usart0_clk", &pdev->dev, "usart"); | ||
1228 | break; | ||
1229 | case AT91SAM9263_ID_US1: | ||
1230 | pdev = &at91sam9263_uart1_device; | ||
1231 | configure_usart1_pins(pins); | ||
1232 | at91_clock_associate("usart1_clk", &pdev->dev, "usart"); | ||
1233 | break; | ||
1234 | case AT91SAM9263_ID_US2: | ||
1235 | pdev = &at91sam9263_uart2_device; | ||
1236 | configure_usart2_pins(pins); | ||
1237 | at91_clock_associate("usart2_clk", &pdev->dev, "usart"); | ||
1238 | break; | ||
1239 | default: | ||
1240 | return; | ||
1241 | } | ||
1242 | pdev->id = portnr; /* update to mapped ID */ | ||
1243 | |||
1244 | if (portnr < ATMEL_MAX_UART) | ||
1245 | at91_uarts[portnr] = pdev; | ||
1246 | } | ||
1247 | |||
1248 | void __init at91_set_serial_console(unsigned portnr) | ||
1249 | { | ||
1250 | if (portnr < ATMEL_MAX_UART) | ||
1251 | atmel_default_console_device = at91_uarts[portnr]; | ||
1252 | if (!atmel_default_console_device) | ||
1253 | printk(KERN_INFO "AT91: No default serial console defined.\n"); | ||
1254 | } | ||
1255 | |||
1205 | void __init at91_add_device_serial(void) | 1256 | void __init at91_add_device_serial(void) |
1206 | { | 1257 | { |
1207 | int i; | 1258 | int i; |
@@ -1213,6 +1264,8 @@ void __init at91_add_device_serial(void) | |||
1213 | } | 1264 | } |
1214 | #else | 1265 | #else |
1215 | void __init at91_init_serial(struct at91_uart_config *config) {} | 1266 | void __init at91_init_serial(struct at91_uart_config *config) {} |
1267 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
1268 | void __init at91_set_serial_console(unsigned portnr) {} | ||
1216 | void __init at91_add_device_serial(void) {} | 1269 | void __init at91_add_device_serial(void) {} |
1217 | #endif | 1270 | #endif |
1218 | 1271 | ||
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 | ||
679 | static inline void configure_usart0_pins(void) | 679 | static 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 | ||
687 | static struct resource uart1_resources[] = { | 698 | static 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 | ||
719 | static inline void configure_usart1_pins(void) | 730 | static 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 | ||
725 | static struct resource uart2_resources[] = { | 741 | static 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 | ||
757 | static inline void configure_usart2_pins(void) | 773 | static 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 | ||
763 | static struct resource uart3_resources[] = { | 784 | static 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 | ||
795 | static inline void configure_usart3_pins(void) | 816 | static 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 | ||
801 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ | 827 | static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ |
802 | struct platform_device *atmel_default_console_device; /* the serial console device */ | 828 | struct platform_device *atmel_default_console_device; /* the serial console device */ |
803 | 829 | ||
804 | void __init at91_init_serial(struct at91_uart_config *config) | 830 | void __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 | ||
875 | void __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 | |||
914 | void __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 | |||
849 | void __init at91_add_device_serial(void) | 922 | void __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 |
859 | void __init at91_init_serial(struct at91_uart_config *config) {} | 932 | void __init __deprecated at91_init_serial(struct at91_uart_config *config) {} |
933 | void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {} | ||
934 | void __init at91_set_serial_console(unsigned portnr) {} | ||
860 | void __init at91_add_device_serial(void) {} | 935 | void __init at91_add_device_serial(void) {} |
861 | #endif | 936 | #endif |
862 | 937 | ||