diff options
| -rw-r--r-- | Documentation/devicetree/bindings/serial/atmel-usart.txt | 10 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91rm9200_devices.c | 16 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9260_devices.c | 7 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9261_devices.c | 4 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9263_devices.c | 4 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9g45_devices.c | 5 | ||||
| -rw-r--r-- | arch/arm/mach-at91/at91sam9rl_devices.c | 5 | ||||
| -rw-r--r-- | drivers/tty/serial/Kconfig | 1 | ||||
| -rw-r--r-- | drivers/tty/serial/atmel_serial.c | 105 | ||||
| -rw-r--r-- | include/linux/platform_data/atmel.h | 1 |
10 files changed, 89 insertions, 69 deletions
diff --git a/Documentation/devicetree/bindings/serial/atmel-usart.txt b/Documentation/devicetree/bindings/serial/atmel-usart.txt index 2f7aad71b3c9..a6391e70a8fd 100644 --- a/Documentation/devicetree/bindings/serial/atmel-usart.txt +++ b/Documentation/devicetree/bindings/serial/atmel-usart.txt | |||
| @@ -13,8 +13,9 @@ Required properties: | |||
| 13 | Optional properties: | 13 | Optional properties: |
| 14 | - atmel,use-dma-rx: use of PDC or DMA for receiving data | 14 | - atmel,use-dma-rx: use of PDC or DMA for receiving data |
| 15 | - atmel,use-dma-tx: use of PDC or DMA for transmitting data | 15 | - atmel,use-dma-tx: use of PDC or DMA for transmitting data |
| 16 | - rts-gpios: specify a GPIO for RTS line. It will use specified PIO instead of the peripheral | 16 | - {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD line respectively. |
| 17 | function pin for the USART RTS feature. If unsure, don't specify this property. | 17 | It will use specified PIO instead of the peripheral function pin for the USART feature. |
| 18 | If unsure, don't specify this property. | ||
| 18 | - add dma bindings for dma transfer: | 19 | - add dma bindings for dma transfer: |
| 19 | - dmas: DMA specifier, consisting of a phandle to DMA controller node, | 20 | - dmas: DMA specifier, consisting of a phandle to DMA controller node, |
| 20 | memory peripheral interface and USART DMA channel ID, FIFO configuration. | 21 | memory peripheral interface and USART DMA channel ID, FIFO configuration. |
| @@ -36,6 +37,11 @@ Example: | |||
| 36 | atmel,use-dma-rx; | 37 | atmel,use-dma-rx; |
| 37 | atmel,use-dma-tx; | 38 | atmel,use-dma-tx; |
| 38 | rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>; | 39 | rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>; |
| 40 | cts-gpios = <&pioD 16 GPIO_ACTIVE_LOW>; | ||
| 41 | dtr-gpios = <&pioD 17 GPIO_ACTIVE_LOW>; | ||
| 42 | dsr-gpios = <&pioD 18 GPIO_ACTIVE_LOW>; | ||
| 43 | dcd-gpios = <&pioD 20 GPIO_ACTIVE_LOW>; | ||
| 44 | rng-gpios = <&pioD 19 GPIO_ACTIVE_LOW>; | ||
| 39 | }; | 45 | }; |
| 40 | 46 | ||
| 41 | - use DMA: | 47 | - use DMA: |
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c index f3f19f21352a..291a90a5b1d4 100644 --- a/arch/arm/mach-at91/at91rm9200_devices.c +++ b/arch/arm/mach-at91/at91rm9200_devices.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | 15 | ||
| 16 | #include <linux/dma-mapping.h> | 16 | #include <linux/dma-mapping.h> |
| 17 | #include <linux/gpio.h> | 17 | #include <linux/gpio.h> |
| 18 | #include <linux/gpio/driver.h> | ||
| 18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
| 19 | #include <linux/i2c-gpio.h> | 20 | #include <linux/i2c-gpio.h> |
| 20 | 21 | ||
| @@ -923,7 +924,6 @@ static struct resource dbgu_resources[] = { | |||
| 923 | static struct atmel_uart_data dbgu_data = { | 924 | static struct atmel_uart_data dbgu_data = { |
| 924 | .use_dma_tx = 0, | 925 | .use_dma_tx = 0, |
| 925 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 926 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
| 926 | .rts_gpio = -EINVAL, | ||
| 927 | }; | 927 | }; |
| 928 | 928 | ||
| 929 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 929 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -962,7 +962,14 @@ static struct resource uart0_resources[] = { | |||
| 962 | static struct atmel_uart_data uart0_data = { | 962 | static struct atmel_uart_data uart0_data = { |
| 963 | .use_dma_tx = 1, | 963 | .use_dma_tx = 1, |
| 964 | .use_dma_rx = 1, | 964 | .use_dma_rx = 1, |
| 965 | .rts_gpio = -EINVAL, | 965 | }; |
| 966 | |||
| 967 | static struct gpiod_lookup_table uart0_gpios_table = { | ||
| 968 | .dev_id = "atmel_usart", | ||
| 969 | .table = { | ||
| 970 | GPIO_LOOKUP("pioA", 21, "rts", GPIO_ACTIVE_LOW), | ||
| 971 | { }, | ||
| 972 | }, | ||
| 966 | }; | 973 | }; |
| 967 | 974 | ||
| 968 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 975 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -993,7 +1000,7 @@ static inline void configure_usart0_pins(unsigned pins) | |||
| 993 | * We need to drive the pin manually. The serial driver will driver | 1000 | * We need to drive the pin manually. The serial driver will driver |
| 994 | * this to high when initializing. | 1001 | * this to high when initializing. |
| 995 | */ | 1002 | */ |
| 996 | uart0_data.rts_gpio = AT91_PIN_PA21; | 1003 | gpiod_add_lookup_table(&uart0_gpios_table); |
| 997 | } | 1004 | } |
| 998 | } | 1005 | } |
| 999 | 1006 | ||
| @@ -1013,7 +1020,6 @@ static struct resource uart1_resources[] = { | |||
| 1013 | static struct atmel_uart_data uart1_data = { | 1020 | static struct atmel_uart_data uart1_data = { |
| 1014 | .use_dma_tx = 1, | 1021 | .use_dma_tx = 1, |
| 1015 | .use_dma_rx = 1, | 1022 | .use_dma_rx = 1, |
| 1016 | .rts_gpio = -EINVAL, | ||
| 1017 | }; | 1023 | }; |
| 1018 | 1024 | ||
| 1019 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 1025 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -1065,7 +1071,6 @@ static struct resource uart2_resources[] = { | |||
| 1065 | static struct atmel_uart_data uart2_data = { | 1071 | static struct atmel_uart_data uart2_data = { |
| 1066 | .use_dma_tx = 1, | 1072 | .use_dma_tx = 1, |
| 1067 | .use_dma_rx = 1, | 1073 | .use_dma_rx = 1, |
| 1068 | .rts_gpio = -EINVAL, | ||
| 1069 | }; | 1074 | }; |
| 1070 | 1075 | ||
| 1071 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 1076 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
| @@ -1109,7 +1114,6 @@ static struct resource uart3_resources[] = { | |||
| 1109 | static struct atmel_uart_data uart3_data = { | 1114 | static struct atmel_uart_data uart3_data = { |
| 1110 | .use_dma_tx = 1, | 1115 | .use_dma_tx = 1, |
| 1111 | .use_dma_rx = 1, | 1116 | .use_dma_rx = 1, |
| 1112 | .rts_gpio = -EINVAL, | ||
| 1113 | }; | 1117 | }; |
| 1114 | 1118 | ||
| 1115 | static u64 uart3_dmamask = DMA_BIT_MASK(32); | 1119 | static u64 uart3_dmamask = DMA_BIT_MASK(32); |
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c index a0282928e9c1..526453ecdaff 100644 --- a/arch/arm/mach-at91/at91sam9260_devices.c +++ b/arch/arm/mach-at91/at91sam9260_devices.c | |||
| @@ -820,7 +820,6 @@ static struct resource dbgu_resources[] = { | |||
| 820 | static struct atmel_uart_data dbgu_data = { | 820 | static struct atmel_uart_data dbgu_data = { |
| 821 | .use_dma_tx = 0, | 821 | .use_dma_tx = 0, |
| 822 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 822 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
| 823 | .rts_gpio = -EINVAL, | ||
| 824 | }; | 823 | }; |
| 825 | 824 | ||
| 826 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 825 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -859,7 +858,6 @@ static struct resource uart0_resources[] = { | |||
| 859 | static struct atmel_uart_data uart0_data = { | 858 | static struct atmel_uart_data uart0_data = { |
| 860 | .use_dma_tx = 1, | 859 | .use_dma_tx = 1, |
| 861 | .use_dma_rx = 1, | 860 | .use_dma_rx = 1, |
| 862 | .rts_gpio = -EINVAL, | ||
| 863 | }; | 861 | }; |
| 864 | 862 | ||
| 865 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 863 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -911,7 +909,6 @@ static struct resource uart1_resources[] = { | |||
| 911 | static struct atmel_uart_data uart1_data = { | 909 | static struct atmel_uart_data uart1_data = { |
| 912 | .use_dma_tx = 1, | 910 | .use_dma_tx = 1, |
| 913 | .use_dma_rx = 1, | 911 | .use_dma_rx = 1, |
| 914 | .rts_gpio = -EINVAL, | ||
| 915 | }; | 912 | }; |
| 916 | 913 | ||
| 917 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 914 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -955,7 +952,6 @@ static struct resource uart2_resources[] = { | |||
| 955 | static struct atmel_uart_data uart2_data = { | 952 | static struct atmel_uart_data uart2_data = { |
| 956 | .use_dma_tx = 1, | 953 | .use_dma_tx = 1, |
| 957 | .use_dma_rx = 1, | 954 | .use_dma_rx = 1, |
| 958 | .rts_gpio = -EINVAL, | ||
| 959 | }; | 955 | }; |
| 960 | 956 | ||
| 961 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 957 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
| @@ -999,7 +995,6 @@ static struct resource uart3_resources[] = { | |||
| 999 | static struct atmel_uart_data uart3_data = { | 995 | static struct atmel_uart_data uart3_data = { |
| 1000 | .use_dma_tx = 1, | 996 | .use_dma_tx = 1, |
| 1001 | .use_dma_rx = 1, | 997 | .use_dma_rx = 1, |
| 1002 | .rts_gpio = -EINVAL, | ||
| 1003 | }; | 998 | }; |
| 1004 | 999 | ||
| 1005 | static u64 uart3_dmamask = DMA_BIT_MASK(32); | 1000 | static u64 uart3_dmamask = DMA_BIT_MASK(32); |
| @@ -1043,7 +1038,6 @@ static struct resource uart4_resources[] = { | |||
| 1043 | static struct atmel_uart_data uart4_data = { | 1038 | static struct atmel_uart_data uart4_data = { |
| 1044 | .use_dma_tx = 1, | 1039 | .use_dma_tx = 1, |
| 1045 | .use_dma_rx = 1, | 1040 | .use_dma_rx = 1, |
| 1046 | .rts_gpio = -EINVAL, | ||
| 1047 | }; | 1041 | }; |
| 1048 | 1042 | ||
| 1049 | static u64 uart4_dmamask = DMA_BIT_MASK(32); | 1043 | static u64 uart4_dmamask = DMA_BIT_MASK(32); |
| @@ -1082,7 +1076,6 @@ static struct resource uart5_resources[] = { | |||
| 1082 | static struct atmel_uart_data uart5_data = { | 1076 | static struct atmel_uart_data uart5_data = { |
| 1083 | .use_dma_tx = 1, | 1077 | .use_dma_tx = 1, |
| 1084 | .use_dma_rx = 1, | 1078 | .use_dma_rx = 1, |
| 1085 | .rts_gpio = -EINVAL, | ||
| 1086 | }; | 1079 | }; |
| 1087 | 1080 | ||
| 1088 | static u64 uart5_dmamask = DMA_BIT_MASK(32); | 1081 | static u64 uart5_dmamask = DMA_BIT_MASK(32); |
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c index 80e35895d28f..b5f7a7226ff8 100644 --- a/arch/arm/mach-at91/at91sam9261_devices.c +++ b/arch/arm/mach-at91/at91sam9261_devices.c | |||
| @@ -881,7 +881,6 @@ static struct resource dbgu_resources[] = { | |||
| 881 | static struct atmel_uart_data dbgu_data = { | 881 | static struct atmel_uart_data dbgu_data = { |
| 882 | .use_dma_tx = 0, | 882 | .use_dma_tx = 0, |
| 883 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 883 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
| 884 | .rts_gpio = -EINVAL, | ||
| 885 | }; | 884 | }; |
| 886 | 885 | ||
| 887 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 886 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -920,7 +919,6 @@ static struct resource uart0_resources[] = { | |||
| 920 | static struct atmel_uart_data uart0_data = { | 919 | static struct atmel_uart_data uart0_data = { |
| 921 | .use_dma_tx = 1, | 920 | .use_dma_tx = 1, |
| 922 | .use_dma_rx = 1, | 921 | .use_dma_rx = 1, |
| 923 | .rts_gpio = -EINVAL, | ||
| 924 | }; | 922 | }; |
| 925 | 923 | ||
| 926 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 924 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -964,7 +962,6 @@ static struct resource uart1_resources[] = { | |||
| 964 | static struct atmel_uart_data uart1_data = { | 962 | static struct atmel_uart_data uart1_data = { |
| 965 | .use_dma_tx = 1, | 963 | .use_dma_tx = 1, |
| 966 | .use_dma_rx = 1, | 964 | .use_dma_rx = 1, |
| 967 | .rts_gpio = -EINVAL, | ||
| 968 | }; | 965 | }; |
| 969 | 966 | ||
| 970 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 967 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -1008,7 +1005,6 @@ static struct resource uart2_resources[] = { | |||
| 1008 | static struct atmel_uart_data uart2_data = { | 1005 | static struct atmel_uart_data uart2_data = { |
| 1009 | .use_dma_tx = 1, | 1006 | .use_dma_tx = 1, |
| 1010 | .use_dma_rx = 1, | 1007 | .use_dma_rx = 1, |
| 1011 | .rts_gpio = -EINVAL, | ||
| 1012 | }; | 1008 | }; |
| 1013 | 1009 | ||
| 1014 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 1010 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c index 43d53d6156dd..39803c3296b2 100644 --- a/arch/arm/mach-at91/at91sam9263_devices.c +++ b/arch/arm/mach-at91/at91sam9263_devices.c | |||
| @@ -1325,7 +1325,6 @@ static struct resource dbgu_resources[] = { | |||
| 1325 | static struct atmel_uart_data dbgu_data = { | 1325 | static struct atmel_uart_data dbgu_data = { |
| 1326 | .use_dma_tx = 0, | 1326 | .use_dma_tx = 0, |
| 1327 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 1327 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
| 1328 | .rts_gpio = -EINVAL, | ||
| 1329 | }; | 1328 | }; |
| 1330 | 1329 | ||
| 1331 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 1330 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -1364,7 +1363,6 @@ static struct resource uart0_resources[] = { | |||
| 1364 | static struct atmel_uart_data uart0_data = { | 1363 | static struct atmel_uart_data uart0_data = { |
| 1365 | .use_dma_tx = 1, | 1364 | .use_dma_tx = 1, |
| 1366 | .use_dma_rx = 1, | 1365 | .use_dma_rx = 1, |
| 1367 | .rts_gpio = -EINVAL, | ||
| 1368 | }; | 1366 | }; |
| 1369 | 1367 | ||
| 1370 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 1368 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -1408,7 +1406,6 @@ static struct resource uart1_resources[] = { | |||
| 1408 | static struct atmel_uart_data uart1_data = { | 1406 | static struct atmel_uart_data uart1_data = { |
| 1409 | .use_dma_tx = 1, | 1407 | .use_dma_tx = 1, |
| 1410 | .use_dma_rx = 1, | 1408 | .use_dma_rx = 1, |
| 1411 | .rts_gpio = -EINVAL, | ||
| 1412 | }; | 1409 | }; |
| 1413 | 1410 | ||
| 1414 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 1411 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -1452,7 +1449,6 @@ static struct resource uart2_resources[] = { | |||
| 1452 | static struct atmel_uart_data uart2_data = { | 1449 | static struct atmel_uart_data uart2_data = { |
| 1453 | .use_dma_tx = 1, | 1450 | .use_dma_tx = 1, |
| 1454 | .use_dma_rx = 1, | 1451 | .use_dma_rx = 1, |
| 1455 | .rts_gpio = -EINVAL, | ||
| 1456 | }; | 1452 | }; |
| 1457 | 1453 | ||
| 1458 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 1454 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c index dab362c06487..4dfedd3f2e15 100644 --- a/arch/arm/mach-at91/at91sam9g45_devices.c +++ b/arch/arm/mach-at91/at91sam9g45_devices.c | |||
| @@ -1588,7 +1588,6 @@ static struct resource dbgu_resources[] = { | |||
| 1588 | static struct atmel_uart_data dbgu_data = { | 1588 | static struct atmel_uart_data dbgu_data = { |
| 1589 | .use_dma_tx = 0, | 1589 | .use_dma_tx = 0, |
| 1590 | .use_dma_rx = 0, | 1590 | .use_dma_rx = 0, |
| 1591 | .rts_gpio = -EINVAL, | ||
| 1592 | }; | 1591 | }; |
| 1593 | 1592 | ||
| 1594 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 1593 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -1627,7 +1626,6 @@ static struct resource uart0_resources[] = { | |||
| 1627 | static struct atmel_uart_data uart0_data = { | 1626 | static struct atmel_uart_data uart0_data = { |
| 1628 | .use_dma_tx = 1, | 1627 | .use_dma_tx = 1, |
| 1629 | .use_dma_rx = 1, | 1628 | .use_dma_rx = 1, |
| 1630 | .rts_gpio = -EINVAL, | ||
| 1631 | }; | 1629 | }; |
| 1632 | 1630 | ||
| 1633 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 1631 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -1671,7 +1669,6 @@ static struct resource uart1_resources[] = { | |||
| 1671 | static struct atmel_uart_data uart1_data = { | 1669 | static struct atmel_uart_data uart1_data = { |
| 1672 | .use_dma_tx = 1, | 1670 | .use_dma_tx = 1, |
| 1673 | .use_dma_rx = 1, | 1671 | .use_dma_rx = 1, |
| 1674 | .rts_gpio = -EINVAL, | ||
| 1675 | }; | 1672 | }; |
| 1676 | 1673 | ||
| 1677 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 1674 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -1715,7 +1712,6 @@ static struct resource uart2_resources[] = { | |||
| 1715 | static struct atmel_uart_data uart2_data = { | 1712 | static struct atmel_uart_data uart2_data = { |
| 1716 | .use_dma_tx = 1, | 1713 | .use_dma_tx = 1, |
| 1717 | .use_dma_rx = 1, | 1714 | .use_dma_rx = 1, |
| 1718 | .rts_gpio = -EINVAL, | ||
| 1719 | }; | 1715 | }; |
| 1720 | 1716 | ||
| 1721 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 1717 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
| @@ -1759,7 +1755,6 @@ static struct resource uart3_resources[] = { | |||
| 1759 | static struct atmel_uart_data uart3_data = { | 1755 | static struct atmel_uart_data uart3_data = { |
| 1760 | .use_dma_tx = 1, | 1756 | .use_dma_tx = 1, |
| 1761 | .use_dma_rx = 1, | 1757 | .use_dma_rx = 1, |
| 1762 | .rts_gpio = -EINVAL, | ||
| 1763 | }; | 1758 | }; |
| 1764 | 1759 | ||
| 1765 | static u64 uart3_dmamask = DMA_BIT_MASK(32); | 1760 | static u64 uart3_dmamask = DMA_BIT_MASK(32); |
diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c index 428fc412aaf1..f75985062913 100644 --- a/arch/arm/mach-at91/at91sam9rl_devices.c +++ b/arch/arm/mach-at91/at91sam9rl_devices.c | |||
| @@ -957,7 +957,6 @@ static struct resource dbgu_resources[] = { | |||
| 957 | static struct atmel_uart_data dbgu_data = { | 957 | static struct atmel_uart_data dbgu_data = { |
| 958 | .use_dma_tx = 0, | 958 | .use_dma_tx = 0, |
| 959 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 959 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
| 960 | .rts_gpio = -EINVAL, | ||
| 961 | }; | 960 | }; |
| 962 | 961 | ||
| 963 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); | 962 | static u64 dbgu_dmamask = DMA_BIT_MASK(32); |
| @@ -996,7 +995,6 @@ static struct resource uart0_resources[] = { | |||
| 996 | static struct atmel_uart_data uart0_data = { | 995 | static struct atmel_uart_data uart0_data = { |
| 997 | .use_dma_tx = 1, | 996 | .use_dma_tx = 1, |
| 998 | .use_dma_rx = 1, | 997 | .use_dma_rx = 1, |
| 999 | .rts_gpio = -EINVAL, | ||
| 1000 | }; | 998 | }; |
| 1001 | 999 | ||
| 1002 | static u64 uart0_dmamask = DMA_BIT_MASK(32); | 1000 | static u64 uart0_dmamask = DMA_BIT_MASK(32); |
| @@ -1048,7 +1046,6 @@ static struct resource uart1_resources[] = { | |||
| 1048 | static struct atmel_uart_data uart1_data = { | 1046 | static struct atmel_uart_data uart1_data = { |
| 1049 | .use_dma_tx = 1, | 1047 | .use_dma_tx = 1, |
| 1050 | .use_dma_rx = 1, | 1048 | .use_dma_rx = 1, |
| 1051 | .rts_gpio = -EINVAL, | ||
| 1052 | }; | 1049 | }; |
| 1053 | 1050 | ||
| 1054 | static u64 uart1_dmamask = DMA_BIT_MASK(32); | 1051 | static u64 uart1_dmamask = DMA_BIT_MASK(32); |
| @@ -1092,7 +1089,6 @@ static struct resource uart2_resources[] = { | |||
| 1092 | static struct atmel_uart_data uart2_data = { | 1089 | static struct atmel_uart_data uart2_data = { |
| 1093 | .use_dma_tx = 1, | 1090 | .use_dma_tx = 1, |
| 1094 | .use_dma_rx = 1, | 1091 | .use_dma_rx = 1, |
| 1095 | .rts_gpio = -EINVAL, | ||
| 1096 | }; | 1092 | }; |
| 1097 | 1093 | ||
| 1098 | static u64 uart2_dmamask = DMA_BIT_MASK(32); | 1094 | static u64 uart2_dmamask = DMA_BIT_MASK(32); |
| @@ -1136,7 +1132,6 @@ static struct resource uart3_resources[] = { | |||
| 1136 | static struct atmel_uart_data uart3_data = { | 1132 | static struct atmel_uart_data uart3_data = { |
| 1137 | .use_dma_tx = 1, | 1133 | .use_dma_tx = 1, |
| 1138 | .use_dma_rx = 1, | 1134 | .use_dma_rx = 1, |
| 1139 | .rts_gpio = -EINVAL, | ||
| 1140 | }; | 1135 | }; |
| 1141 | 1136 | ||
| 1142 | static u64 uart3_dmamask = DMA_BIT_MASK(32); | 1137 | static u64 uart3_dmamask = DMA_BIT_MASK(32); |
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 4bf6d220357b..fb57159bad3a 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig | |||
| @@ -117,6 +117,7 @@ config SERIAL_ATMEL | |||
| 117 | bool "AT91 / AT32 on-chip serial port support" | 117 | bool "AT91 / AT32 on-chip serial port support" |
| 118 | depends on ARCH_AT91 || AVR32 | 118 | depends on ARCH_AT91 || AVR32 |
| 119 | select SERIAL_CORE | 119 | select SERIAL_CORE |
| 120 | select SERIAL_MCTRL_GPIO | ||
| 120 | help | 121 | help |
| 121 | This enables the driver for the on-chip UARTs of the Atmel | 122 | This enables the driver for the on-chip UARTs of the Atmel |
| 122 | AT91 and AT32 processors. | 123 | AT91 and AT32 processors. |
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 53eeea13ff16..43ca659c1d4b 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
| @@ -43,6 +43,8 @@ | |||
| 43 | #include <linux/platform_data/atmel.h> | 43 | #include <linux/platform_data/atmel.h> |
| 44 | #include <linux/timer.h> | 44 | #include <linux/timer.h> |
| 45 | #include <linux/gpio.h> | 45 | #include <linux/gpio.h> |
| 46 | #include <linux/gpio/consumer.h> | ||
| 47 | #include <linux/err.h> | ||
| 46 | 48 | ||
| 47 | #include <asm/io.h> | 49 | #include <asm/io.h> |
| 48 | #include <asm/ioctls.h> | 50 | #include <asm/ioctls.h> |
| @@ -57,6 +59,8 @@ | |||
| 57 | 59 | ||
| 58 | #include <linux/serial_core.h> | 60 | #include <linux/serial_core.h> |
| 59 | 61 | ||
| 62 | #include "serial_mctrl_gpio.h" | ||
| 63 | |||
| 60 | static void atmel_start_rx(struct uart_port *port); | 64 | static void atmel_start_rx(struct uart_port *port); |
| 61 | static void atmel_stop_rx(struct uart_port *port); | 65 | static void atmel_stop_rx(struct uart_port *port); |
| 62 | 66 | ||
| @@ -162,7 +166,7 @@ struct atmel_uart_port { | |||
| 162 | struct circ_buf rx_ring; | 166 | struct circ_buf rx_ring; |
| 163 | 167 | ||
| 164 | struct serial_rs485 rs485; /* rs485 settings */ | 168 | struct serial_rs485 rs485; /* rs485 settings */ |
| 165 | int rts_gpio; /* optional RTS GPIO */ | 169 | struct mctrl_gpios *gpios; |
| 166 | unsigned int tx_done_mask; | 170 | unsigned int tx_done_mask; |
| 167 | bool is_usart; /* usart or uart */ | 171 | bool is_usart; /* usart or uart */ |
| 168 | struct timer_list uart_timer; /* uart timer */ | 172 | struct timer_list uart_timer; /* uart timer */ |
| @@ -237,6 +241,50 @@ static bool atmel_use_dma_rx(struct uart_port *port) | |||
| 237 | return atmel_port->use_dma_rx; | 241 | return atmel_port->use_dma_rx; |
| 238 | } | 242 | } |
| 239 | 243 | ||
| 244 | static unsigned int atmel_get_lines_status(struct uart_port *port) | ||
| 245 | { | ||
| 246 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | ||
| 247 | unsigned int status, ret = 0; | ||
| 248 | |||
| 249 | status = UART_GET_CSR(port); | ||
| 250 | |||
| 251 | mctrl_gpio_get(atmel_port->gpios, &ret); | ||
| 252 | |||
| 253 | if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios, | ||
| 254 | UART_GPIO_CTS))) { | ||
| 255 | if (ret & TIOCM_CTS) | ||
| 256 | status &= ~ATMEL_US_CTS; | ||
| 257 | else | ||
| 258 | status |= ATMEL_US_CTS; | ||
| 259 | } | ||
| 260 | |||
| 261 | if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios, | ||
| 262 | UART_GPIO_DSR))) { | ||
| 263 | if (ret & TIOCM_DSR) | ||
| 264 | status &= ~ATMEL_US_DSR; | ||
| 265 | else | ||
| 266 | status |= ATMEL_US_DSR; | ||
| 267 | } | ||
| 268 | |||
| 269 | if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios, | ||
| 270 | UART_GPIO_RI))) { | ||
| 271 | if (ret & TIOCM_RI) | ||
| 272 | status &= ~ATMEL_US_RI; | ||
| 273 | else | ||
| 274 | status |= ATMEL_US_RI; | ||
| 275 | } | ||
| 276 | |||
| 277 | if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios, | ||
| 278 | UART_GPIO_DCD))) { | ||
| 279 | if (ret & TIOCM_CD) | ||
| 280 | status &= ~ATMEL_US_DCD; | ||
| 281 | else | ||
| 282 | status |= ATMEL_US_DCD; | ||
| 283 | } | ||
| 284 | |||
| 285 | return status; | ||
| 286 | } | ||
| 287 | |||
| 240 | /* Enable or disable the rs485 support */ | 288 | /* Enable or disable the rs485 support */ |
| 241 | void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) | 289 | void atmel_config_rs485(struct uart_port *port, struct serial_rs485 *rs485conf) |
| 242 | { | 290 | { |
| @@ -296,17 +344,6 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) | |||
| 296 | unsigned int mode; | 344 | unsigned int mode; |
| 297 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); | 345 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
| 298 | 346 | ||
| 299 | /* | ||
| 300 | * AT91RM9200 Errata #39: RTS0 is not internally connected | ||
| 301 | * to PA21. We need to drive the pin as a GPIO. | ||
| 302 | */ | ||
| 303 | if (gpio_is_valid(atmel_port->rts_gpio)) { | ||
| 304 | if (mctrl & TIOCM_RTS) | ||
| 305 | gpio_set_value(atmel_port->rts_gpio, 0); | ||
| 306 | else | ||
| 307 | gpio_set_value(atmel_port->rts_gpio, 1); | ||
| 308 | } | ||
| 309 | |||
| 310 | if (mctrl & TIOCM_RTS) | 347 | if (mctrl & TIOCM_RTS) |
| 311 | control |= ATMEL_US_RTSEN; | 348 | control |= ATMEL_US_RTSEN; |
| 312 | else | 349 | else |
| @@ -319,6 +356,8 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) | |||
| 319 | 356 | ||
| 320 | UART_PUT_CR(port, control); | 357 | UART_PUT_CR(port, control); |
| 321 | 358 | ||
| 359 | mctrl_gpio_set(atmel_port->gpios, mctrl); | ||
| 360 | |||
| 322 | /* Local loopback mode? */ | 361 | /* Local loopback mode? */ |
| 323 | mode = UART_GET_MR(port) & ~ATMEL_US_CHMODE; | 362 | mode = UART_GET_MR(port) & ~ATMEL_US_CHMODE; |
| 324 | if (mctrl & TIOCM_LOOP) | 363 | if (mctrl & TIOCM_LOOP) |
| @@ -346,7 +385,8 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) | |||
| 346 | */ | 385 | */ |
| 347 | static u_int atmel_get_mctrl(struct uart_port *port) | 386 | static u_int atmel_get_mctrl(struct uart_port *port) |
| 348 | { | 387 | { |
| 349 | unsigned int status, ret = 0; | 388 | struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); |
| 389 | unsigned int ret = 0, status; | ||
| 350 | 390 | ||
| 351 | status = UART_GET_CSR(port); | 391 | status = UART_GET_CSR(port); |
| 352 | 392 | ||
| @@ -362,7 +402,7 @@ static u_int atmel_get_mctrl(struct uart_port *port) | |||
| 362 | if (!(status & ATMEL_US_RI)) | 402 | if (!(status & ATMEL_US_RI)) |
| 363 | ret |= TIOCM_RI; | 403 | ret |= TIOCM_RI; |
| 364 | 404 | ||
| 365 | return ret; | 405 | return mctrl_gpio_get(atmel_port->gpios, &ret); |
| 366 | } | 406 | } |
| 367 | 407 | ||
| 368 | /* | 408 | /* |
| @@ -1042,7 +1082,7 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id) | |||
| 1042 | unsigned int status, pending, pass_counter = 0; | 1082 | unsigned int status, pending, pass_counter = 0; |
| 1043 | 1083 | ||
| 1044 | do { | 1084 | do { |
| 1045 | status = UART_GET_CSR(port); | 1085 | status = atmel_get_lines_status(port); |
| 1046 | pending = status & UART_GET_IMR(port); | 1086 | pending = status & UART_GET_IMR(port); |
| 1047 | if (!pending) | 1087 | if (!pending) |
| 1048 | break; | 1088 | break; |
| @@ -1568,7 +1608,7 @@ static int atmel_startup(struct uart_port *port) | |||
| 1568 | } | 1608 | } |
| 1569 | 1609 | ||
| 1570 | /* Save current CSR for comparison in atmel_tasklet_func() */ | 1610 | /* Save current CSR for comparison in atmel_tasklet_func() */ |
| 1571 | atmel_port->irq_status_prev = UART_GET_CSR(port); | 1611 | atmel_port->irq_status_prev = atmel_get_lines_status(port); |
| 1572 | atmel_port->irq_status = atmel_port->irq_status_prev; | 1612 | atmel_port->irq_status = atmel_port->irq_status_prev; |
| 1573 | 1613 | ||
| 1574 | /* | 1614 | /* |
| @@ -2324,6 +2364,15 @@ static int atmel_serial_resume(struct platform_device *pdev) | |||
| 2324 | #define atmel_serial_resume NULL | 2364 | #define atmel_serial_resume NULL |
| 2325 | #endif | 2365 | #endif |
| 2326 | 2366 | ||
| 2367 | static int atmel_init_gpios(struct atmel_uart_port *p, struct device *dev) | ||
| 2368 | { | ||
| 2369 | p->gpios = mctrl_gpio_init(dev, 0); | ||
| 2370 | if (IS_ERR_OR_NULL(p->gpios)) | ||
| 2371 | return -1; | ||
| 2372 | |||
| 2373 | return 0; | ||
| 2374 | } | ||
| 2375 | |||
| 2327 | static int atmel_serial_probe(struct platform_device *pdev) | 2376 | static int atmel_serial_probe(struct platform_device *pdev) |
| 2328 | { | 2377 | { |
| 2329 | struct atmel_uart_port *port; | 2378 | struct atmel_uart_port *port; |
| @@ -2359,25 +2408,11 @@ static int atmel_serial_probe(struct platform_device *pdev) | |||
| 2359 | port = &atmel_ports[ret]; | 2408 | port = &atmel_ports[ret]; |
| 2360 | port->backup_imr = 0; | 2409 | port->backup_imr = 0; |
| 2361 | port->uart.line = ret; | 2410 | port->uart.line = ret; |
| 2362 | port->rts_gpio = -EINVAL; /* Invalid, zero could be valid */ | 2411 | |
| 2363 | if (pdata) | 2412 | ret = atmel_init_gpios(port, &pdev->dev); |
| 2364 | port->rts_gpio = pdata->rts_gpio; | 2413 | if (ret < 0) |
| 2365 | else if (np) | 2414 | dev_err(&pdev->dev, "%s", |
| 2366 | port->rts_gpio = of_get_named_gpio(np, "rts-gpios", 0); | 2415 | "Failed to initialize GPIOs. The serial port may not work as expected"); |
| 2367 | |||
| 2368 | if (gpio_is_valid(port->rts_gpio)) { | ||
| 2369 | ret = devm_gpio_request(&pdev->dev, port->rts_gpio, "RTS"); | ||
| 2370 | if (ret) { | ||
| 2371 | dev_err(&pdev->dev, "error requesting RTS GPIO\n"); | ||
| 2372 | goto err; | ||
| 2373 | } | ||
| 2374 | /* Default to 1 as RTS is active low */ | ||
| 2375 | ret = gpio_direction_output(port->rts_gpio, 1); | ||
| 2376 | if (ret) { | ||
| 2377 | dev_err(&pdev->dev, "error setting up RTS GPIO\n"); | ||
| 2378 | goto err; | ||
| 2379 | } | ||
| 2380 | } | ||
| 2381 | 2416 | ||
| 2382 | ret = atmel_init_port(port, pdev); | 2417 | ret = atmel_init_port(port, pdev); |
| 2383 | if (ret) | 2418 | if (ret) |
diff --git a/include/linux/platform_data/atmel.h b/include/linux/platform_data/atmel.h index e26b0c14edea..cea9f70133c5 100644 --- a/include/linux/platform_data/atmel.h +++ b/include/linux/platform_data/atmel.h | |||
| @@ -84,7 +84,6 @@ struct atmel_uart_data { | |||
| 84 | short use_dma_rx; /* use receive DMA? */ | 84 | short use_dma_rx; /* use receive DMA? */ |
| 85 | void __iomem *regs; /* virt. base address, if any */ | 85 | void __iomem *regs; /* virt. base address, if any */ |
| 86 | struct serial_rs485 rs485; /* rs485 settings */ | 86 | struct serial_rs485 rs485; /* rs485 settings */ |
| 87 | int rts_gpio; /* optional RTS GPIO */ | ||
| 88 | }; | 87 | }; |
| 89 | 88 | ||
| 90 | /* Touchscreen Controller */ | 89 | /* Touchscreen Controller */ |
