aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9263_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/at91sam9263_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/at91sam9263_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c79
1 files changed, 66 insertions, 13 deletions
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
1074static inline void configure_usart0_pins(void) 1074static 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
1082static struct resource uart1_resources[] = { 1085static 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
1114static inline void configure_usart1_pins(void) 1117static 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
1122static struct resource uart2_resources[] = { 1128static 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
1154static inline void configure_usart2_pins(void) 1160static 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
1162static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 1171static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
1163struct platform_device *atmel_default_console_device; /* the serial console device */ 1172struct platform_device *atmel_default_console_device; /* the serial console device */
1164 1173
1165void __init at91_init_serial(struct at91_uart_config *config) 1174void __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
1214void __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
1248void __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
1205void __init at91_add_device_serial(void) 1256void __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
1215void __init at91_init_serial(struct at91_uart_config *config) {} 1266void __init at91_init_serial(struct at91_uart_config *config) {}
1267void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1268void __init at91_set_serial_console(unsigned portnr) {}
1216void __init at91_add_device_serial(void) {} 1269void __init at91_add_device_serial(void) {}
1217#endif 1270#endif
1218 1271