aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-at91/at91sam9261_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/at91sam9261_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/at91sam9261_devices.c')
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c77
1 files changed, 67 insertions, 10 deletions
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
870static inline void configure_usart0_pins(void) 870static 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
878static struct resource uart1_resources[] = { 881static 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
910static inline void configure_usart1_pins(void) 913static 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
916static struct resource uart2_resources[] = { 924static 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
948static inline void configure_usart2_pins(void) 956static 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
954static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */ 967static struct platform_device *at91_uarts[ATMEL_MAX_UART]; /* the UARTs to use */
955struct platform_device *atmel_default_console_device; /* the serial console device */ 968struct platform_device *atmel_default_console_device; /* the serial console device */
956 969
957void __init at91_init_serial(struct at91_uart_config *config) 970void __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
1010void __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
1044void __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
997void __init at91_add_device_serial(void) 1052void __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
1007void __init at91_init_serial(struct at91_uart_config *config) {} 1062void __init __deprecated at91_init_serial(struct at91_uart_config *config) {}
1063void __init at91_register_uart(unsigned id, unsigned portnr, unsigned pins) {}
1064void __init at91_set_serial_console(unsigned portnr) {}
1008void __init at91_add_device_serial(void) {} 1065void __init at91_add_device_serial(void) {}
1009#endif 1066#endif
1010 1067