diff options
author | Andrew Victor <linux@maxim.org.za> | 2008-01-23 03:25:15 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-01-26 10:00:32 -0500 |
commit | c8f385a631ef1f49d67a3798ca40dec36ccdf07d (patch) | |
tree | 99b2e29909896d8b0389a6899c8c2f8ad1dc1865 /arch/arm/mach-at91/at91rm9200_devices.c | |
parent | b7b272a8826a2332f689853792eb8c42477fec85 (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/at91rm9200_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91rm9200_devices.c | 114 |
1 files changed, 92 insertions, 22 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 | ||