diff options
Diffstat (limited to 'arch/arm/mach-at91/at91sam9260_devices.c')
-rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 115 |
1 files changed, 97 insertions, 18 deletions
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 | ||