aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/serial/atmel-usart.txt3
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c10
-rw-r--r--arch/arm/mach-at91/at91sam9260_devices.c7
-rw-r--r--arch/arm/mach-at91/at91sam9261_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9263_devices.c4
-rw-r--r--arch/arm/mach-at91/at91sam9g45_devices.c5
-rw-r--r--arch/arm/mach-at91/at91sam9rl_devices.c5
-rw-r--r--drivers/tty/serial/atmel_serial.c49
-rw-r--r--include/linux/platform_data/atmel.h1
9 files changed, 68 insertions, 20 deletions
diff --git a/Documentation/devicetree/bindings/serial/atmel-usart.txt b/Documentation/devicetree/bindings/serial/atmel-usart.txt
index 2191dcb9f1da..3adc61c2e4ca 100644
--- a/Documentation/devicetree/bindings/serial/atmel-usart.txt
+++ b/Documentation/devicetree/bindings/serial/atmel-usart.txt
@@ -10,6 +10,8 @@ Required properties:
10Optional properties: 10Optional properties:
11- atmel,use-dma-rx: use of PDC or DMA for receiving data 11- atmel,use-dma-rx: use of PDC or DMA for receiving data
12- atmel,use-dma-tx: use of PDC or DMA for transmitting data 12- atmel,use-dma-tx: use of PDC or DMA for transmitting data
13- rts-gpios: specify a GPIO for RTS line. It will use specified PIO instead of the peripheral
14 function pin for the USART RTS feature. If unsure, don't specify this property.
13- add dma bindings for dma transfer: 15- add dma bindings for dma transfer:
14 - dmas: DMA specifier, consisting of a phandle to DMA controller node, 16 - dmas: DMA specifier, consisting of a phandle to DMA controller node,
15 memory peripheral interface and USART DMA channel ID, FIFO configuration. 17 memory peripheral interface and USART DMA channel ID, FIFO configuration.
@@ -28,6 +30,7 @@ Example:
28 interrupts = <7>; 30 interrupts = <7>;
29 atmel,use-dma-rx; 31 atmel,use-dma-rx;
30 atmel,use-dma-tx; 32 atmel,use-dma-tx;
33 rts-gpios = <&pioD 15 0>;
31 }; 34 };
32 35
33- use DMA: 36- use DMA:
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 3ebc9792560c..605add05af7e 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -922,6 +922,7 @@ static struct resource dbgu_resources[] = {
922static struct atmel_uart_data dbgu_data = { 922static struct atmel_uart_data dbgu_data = {
923 .use_dma_tx = 0, 923 .use_dma_tx = 0,
924 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 924 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
925 .rts_gpio = -EINVAL,
925}; 926};
926 927
927static u64 dbgu_dmamask = DMA_BIT_MASK(32); 928static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -960,6 +961,7 @@ static struct resource uart0_resources[] = {
960static struct atmel_uart_data uart0_data = { 961static struct atmel_uart_data uart0_data = {
961 .use_dma_tx = 1, 962 .use_dma_tx = 1,
962 .use_dma_rx = 1, 963 .use_dma_rx = 1,
964 .rts_gpio = -EINVAL,
963}; 965};
964 966
965static u64 uart0_dmamask = DMA_BIT_MASK(32); 967static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -987,9 +989,10 @@ static inline void configure_usart0_pins(unsigned pins)
987 if (pins & ATMEL_UART_RTS) { 989 if (pins & ATMEL_UART_RTS) {
988 /* 990 /*
989 * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21. 991 * AT91RM9200 Errata #39 - RTS0 is not internally connected to PA21.
990 * We need to drive the pin manually. Default is off (RTS is active low). 992 * We need to drive the pin manually. The serial driver will driver
993 * this to high when initializing.
991 */ 994 */
992 at91_set_gpio_output(AT91_PIN_PA21, 1); 995 uart0_data.rts_gpio = AT91_PIN_PA21;
993 } 996 }
994} 997}
995 998
@@ -1009,6 +1012,7 @@ static struct resource uart1_resources[] = {
1009static struct atmel_uart_data uart1_data = { 1012static struct atmel_uart_data uart1_data = {
1010 .use_dma_tx = 1, 1013 .use_dma_tx = 1,
1011 .use_dma_rx = 1, 1014 .use_dma_rx = 1,
1015 .rts_gpio = -EINVAL,
1012}; 1016};
1013 1017
1014static u64 uart1_dmamask = DMA_BIT_MASK(32); 1018static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -1060,6 +1064,7 @@ static struct resource uart2_resources[] = {
1060static struct atmel_uart_data uart2_data = { 1064static struct atmel_uart_data uart2_data = {
1061 .use_dma_tx = 1, 1065 .use_dma_tx = 1,
1062 .use_dma_rx = 1, 1066 .use_dma_rx = 1,
1067 .rts_gpio = -EINVAL,
1063}; 1068};
1064 1069
1065static u64 uart2_dmamask = DMA_BIT_MASK(32); 1070static u64 uart2_dmamask = DMA_BIT_MASK(32);
@@ -1103,6 +1108,7 @@ static struct resource uart3_resources[] = {
1103static struct atmel_uart_data uart3_data = { 1108static struct atmel_uart_data uart3_data = {
1104 .use_dma_tx = 1, 1109 .use_dma_tx = 1,
1105 .use_dma_rx = 1, 1110 .use_dma_rx = 1,
1111 .rts_gpio = -EINVAL,
1106}; 1112};
1107 1113
1108static u64 uart3_dmamask = DMA_BIT_MASK(32); 1114static 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 eda8d1679d40..b52527c78b12 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -819,6 +819,7 @@ static struct resource dbgu_resources[] = {
819static struct atmel_uart_data dbgu_data = { 819static struct atmel_uart_data dbgu_data = {
820 .use_dma_tx = 0, 820 .use_dma_tx = 0,
821 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 821 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
822 .rts_gpio = -EINVAL,
822}; 823};
823 824
824static u64 dbgu_dmamask = DMA_BIT_MASK(32); 825static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -857,6 +858,7 @@ static struct resource uart0_resources[] = {
857static struct atmel_uart_data uart0_data = { 858static struct atmel_uart_data uart0_data = {
858 .use_dma_tx = 1, 859 .use_dma_tx = 1,
859 .use_dma_rx = 1, 860 .use_dma_rx = 1,
861 .rts_gpio = -EINVAL,
860}; 862};
861 863
862static u64 uart0_dmamask = DMA_BIT_MASK(32); 864static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -908,6 +910,7 @@ static struct resource uart1_resources[] = {
908static struct atmel_uart_data uart1_data = { 910static struct atmel_uart_data uart1_data = {
909 .use_dma_tx = 1, 911 .use_dma_tx = 1,
910 .use_dma_rx = 1, 912 .use_dma_rx = 1,
913 .rts_gpio = -EINVAL,
911}; 914};
912 915
913static u64 uart1_dmamask = DMA_BIT_MASK(32); 916static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -951,6 +954,7 @@ static struct resource uart2_resources[] = {
951static struct atmel_uart_data uart2_data = { 954static struct atmel_uart_data uart2_data = {
952 .use_dma_tx = 1, 955 .use_dma_tx = 1,
953 .use_dma_rx = 1, 956 .use_dma_rx = 1,
957 .rts_gpio = -EINVAL,
954}; 958};
955 959
956static u64 uart2_dmamask = DMA_BIT_MASK(32); 960static u64 uart2_dmamask = DMA_BIT_MASK(32);
@@ -994,6 +998,7 @@ static struct resource uart3_resources[] = {
994static struct atmel_uart_data uart3_data = { 998static struct atmel_uart_data uart3_data = {
995 .use_dma_tx = 1, 999 .use_dma_tx = 1,
996 .use_dma_rx = 1, 1000 .use_dma_rx = 1,
1001 .rts_gpio = -EINVAL,
997}; 1002};
998 1003
999static u64 uart3_dmamask = DMA_BIT_MASK(32); 1004static u64 uart3_dmamask = DMA_BIT_MASK(32);
@@ -1037,6 +1042,7 @@ static struct resource uart4_resources[] = {
1037static struct atmel_uart_data uart4_data = { 1042static struct atmel_uart_data uart4_data = {
1038 .use_dma_tx = 1, 1043 .use_dma_tx = 1,
1039 .use_dma_rx = 1, 1044 .use_dma_rx = 1,
1045 .rts_gpio = -EINVAL,
1040}; 1046};
1041 1047
1042static u64 uart4_dmamask = DMA_BIT_MASK(32); 1048static u64 uart4_dmamask = DMA_BIT_MASK(32);
@@ -1075,6 +1081,7 @@ static struct resource uart5_resources[] = {
1075static struct atmel_uart_data uart5_data = { 1081static struct atmel_uart_data uart5_data = {
1076 .use_dma_tx = 1, 1082 .use_dma_tx = 1,
1077 .use_dma_rx = 1, 1083 .use_dma_rx = 1,
1084 .rts_gpio = -EINVAL,
1078}; 1085};
1079 1086
1080static u64 uart5_dmamask = DMA_BIT_MASK(32); 1087static 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 b2a34740146a..6c1a2ecc306f 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -880,6 +880,7 @@ static struct resource dbgu_resources[] = {
880static struct atmel_uart_data dbgu_data = { 880static struct atmel_uart_data dbgu_data = {
881 .use_dma_tx = 0, 881 .use_dma_tx = 0,
882 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 882 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
883 .rts_gpio = -EINVAL,
883}; 884};
884 885
885static u64 dbgu_dmamask = DMA_BIT_MASK(32); 886static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -918,6 +919,7 @@ static struct resource uart0_resources[] = {
918static struct atmel_uart_data uart0_data = { 919static struct atmel_uart_data uart0_data = {
919 .use_dma_tx = 1, 920 .use_dma_tx = 1,
920 .use_dma_rx = 1, 921 .use_dma_rx = 1,
922 .rts_gpio = -EINVAL,
921}; 923};
922 924
923static u64 uart0_dmamask = DMA_BIT_MASK(32); 925static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -961,6 +963,7 @@ static struct resource uart1_resources[] = {
961static struct atmel_uart_data uart1_data = { 963static struct atmel_uart_data uart1_data = {
962 .use_dma_tx = 1, 964 .use_dma_tx = 1,
963 .use_dma_rx = 1, 965 .use_dma_rx = 1,
966 .rts_gpio = -EINVAL,
964}; 967};
965 968
966static u64 uart1_dmamask = DMA_BIT_MASK(32); 969static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -1004,6 +1007,7 @@ static struct resource uart2_resources[] = {
1004static struct atmel_uart_data uart2_data = { 1007static struct atmel_uart_data uart2_data = {
1005 .use_dma_tx = 1, 1008 .use_dma_tx = 1,
1006 .use_dma_rx = 1, 1009 .use_dma_rx = 1,
1010 .rts_gpio = -EINVAL,
1007}; 1011};
1008 1012
1009static u64 uart2_dmamask = DMA_BIT_MASK(32); 1013static 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 4aeadddbc181..97cc2a0d6f90 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -1324,6 +1324,7 @@ static struct resource dbgu_resources[] = {
1324static struct atmel_uart_data dbgu_data = { 1324static struct atmel_uart_data dbgu_data = {
1325 .use_dma_tx = 0, 1325 .use_dma_tx = 0,
1326 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 1326 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
1327 .rts_gpio = -EINVAL,
1327}; 1328};
1328 1329
1329static u64 dbgu_dmamask = DMA_BIT_MASK(32); 1330static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -1362,6 +1363,7 @@ static struct resource uart0_resources[] = {
1362static struct atmel_uart_data uart0_data = { 1363static struct atmel_uart_data uart0_data = {
1363 .use_dma_tx = 1, 1364 .use_dma_tx = 1,
1364 .use_dma_rx = 1, 1365 .use_dma_rx = 1,
1366 .rts_gpio = -EINVAL,
1365}; 1367};
1366 1368
1367static u64 uart0_dmamask = DMA_BIT_MASK(32); 1369static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -1405,6 +1407,7 @@ static struct resource uart1_resources[] = {
1405static struct atmel_uart_data uart1_data = { 1407static struct atmel_uart_data uart1_data = {
1406 .use_dma_tx = 1, 1408 .use_dma_tx = 1,
1407 .use_dma_rx = 1, 1409 .use_dma_rx = 1,
1410 .rts_gpio = -EINVAL,
1408}; 1411};
1409 1412
1410static u64 uart1_dmamask = DMA_BIT_MASK(32); 1413static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -1448,6 +1451,7 @@ static struct resource uart2_resources[] = {
1448static struct atmel_uart_data uart2_data = { 1451static struct atmel_uart_data uart2_data = {
1449 .use_dma_tx = 1, 1452 .use_dma_tx = 1,
1450 .use_dma_rx = 1, 1453 .use_dma_rx = 1,
1454 .rts_gpio = -EINVAL,
1451}; 1455};
1452 1456
1453static u64 uart2_dmamask = DMA_BIT_MASK(32); 1457static 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 cb36fa872d30..c10149588e21 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -1587,6 +1587,7 @@ static struct resource dbgu_resources[] = {
1587static struct atmel_uart_data dbgu_data = { 1587static struct atmel_uart_data dbgu_data = {
1588 .use_dma_tx = 0, 1588 .use_dma_tx = 0,
1589 .use_dma_rx = 0, 1589 .use_dma_rx = 0,
1590 .rts_gpio = -EINVAL,
1590}; 1591};
1591 1592
1592static u64 dbgu_dmamask = DMA_BIT_MASK(32); 1593static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -1625,6 +1626,7 @@ static struct resource uart0_resources[] = {
1625static struct atmel_uart_data uart0_data = { 1626static struct atmel_uart_data uart0_data = {
1626 .use_dma_tx = 1, 1627 .use_dma_tx = 1,
1627 .use_dma_rx = 1, 1628 .use_dma_rx = 1,
1629 .rts_gpio = -EINVAL,
1628}; 1630};
1629 1631
1630static u64 uart0_dmamask = DMA_BIT_MASK(32); 1632static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -1668,6 +1670,7 @@ static struct resource uart1_resources[] = {
1668static struct atmel_uart_data uart1_data = { 1670static struct atmel_uart_data uart1_data = {
1669 .use_dma_tx = 1, 1671 .use_dma_tx = 1,
1670 .use_dma_rx = 1, 1672 .use_dma_rx = 1,
1673 .rts_gpio = -EINVAL,
1671}; 1674};
1672 1675
1673static u64 uart1_dmamask = DMA_BIT_MASK(32); 1676static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -1711,6 +1714,7 @@ static struct resource uart2_resources[] = {
1711static struct atmel_uart_data uart2_data = { 1714static struct atmel_uart_data uart2_data = {
1712 .use_dma_tx = 1, 1715 .use_dma_tx = 1,
1713 .use_dma_rx = 1, 1716 .use_dma_rx = 1,
1717 .rts_gpio = -EINVAL,
1714}; 1718};
1715 1719
1716static u64 uart2_dmamask = DMA_BIT_MASK(32); 1720static u64 uart2_dmamask = DMA_BIT_MASK(32);
@@ -1754,6 +1758,7 @@ static struct resource uart3_resources[] = {
1754static struct atmel_uart_data uart3_data = { 1758static struct atmel_uart_data uart3_data = {
1755 .use_dma_tx = 1, 1759 .use_dma_tx = 1,
1756 .use_dma_rx = 1, 1760 .use_dma_rx = 1,
1761 .rts_gpio = -EINVAL,
1757}; 1762};
1758 1763
1759static u64 uart3_dmamask = DMA_BIT_MASK(32); 1764static 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 a698bdab2cce..4120af972b61 100644
--- a/arch/arm/mach-at91/at91sam9rl_devices.c
+++ b/arch/arm/mach-at91/at91sam9rl_devices.c
@@ -956,6 +956,7 @@ static struct resource dbgu_resources[] = {
956static struct atmel_uart_data dbgu_data = { 956static struct atmel_uart_data dbgu_data = {
957 .use_dma_tx = 0, 957 .use_dma_tx = 0,
958 .use_dma_rx = 0, /* DBGU not capable of receive DMA */ 958 .use_dma_rx = 0, /* DBGU not capable of receive DMA */
959 .rts_gpio = -EINVAL,
959}; 960};
960 961
961static u64 dbgu_dmamask = DMA_BIT_MASK(32); 962static u64 dbgu_dmamask = DMA_BIT_MASK(32);
@@ -994,6 +995,7 @@ static struct resource uart0_resources[] = {
994static struct atmel_uart_data uart0_data = { 995static struct atmel_uart_data uart0_data = {
995 .use_dma_tx = 1, 996 .use_dma_tx = 1,
996 .use_dma_rx = 1, 997 .use_dma_rx = 1,
998 .rts_gpio = -EINVAL,
997}; 999};
998 1000
999static u64 uart0_dmamask = DMA_BIT_MASK(32); 1001static u64 uart0_dmamask = DMA_BIT_MASK(32);
@@ -1045,6 +1047,7 @@ static struct resource uart1_resources[] = {
1045static struct atmel_uart_data uart1_data = { 1047static struct atmel_uart_data uart1_data = {
1046 .use_dma_tx = 1, 1048 .use_dma_tx = 1,
1047 .use_dma_rx = 1, 1049 .use_dma_rx = 1,
1050 .rts_gpio = -EINVAL,
1048}; 1051};
1049 1052
1050static u64 uart1_dmamask = DMA_BIT_MASK(32); 1053static u64 uart1_dmamask = DMA_BIT_MASK(32);
@@ -1088,6 +1091,7 @@ static struct resource uart2_resources[] = {
1088static struct atmel_uart_data uart2_data = { 1091static struct atmel_uart_data uart2_data = {
1089 .use_dma_tx = 1, 1092 .use_dma_tx = 1,
1090 .use_dma_rx = 1, 1093 .use_dma_rx = 1,
1094 .rts_gpio = -EINVAL,
1091}; 1095};
1092 1096
1093static u64 uart2_dmamask = DMA_BIT_MASK(32); 1097static u64 uart2_dmamask = DMA_BIT_MASK(32);
@@ -1131,6 +1135,7 @@ static struct resource uart3_resources[] = {
1131static struct atmel_uart_data uart3_data = { 1135static struct atmel_uart_data uart3_data = {
1132 .use_dma_tx = 1, 1136 .use_dma_tx = 1,
1133 .use_dma_rx = 1, 1137 .use_dma_rx = 1,
1138 .rts_gpio = -EINVAL,
1134}; 1139};
1135 1140
1136static u64 uart3_dmamask = DMA_BIT_MASK(32); 1141static u64 uart3_dmamask = DMA_BIT_MASK(32);
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index c7d99af46a96..40d6c9b0d98b 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -35,21 +35,18 @@
35#include <linux/platform_device.h> 35#include <linux/platform_device.h>
36#include <linux/of.h> 36#include <linux/of.h>
37#include <linux/of_device.h> 37#include <linux/of_device.h>
38#include <linux/of_gpio.h>
38#include <linux/dma-mapping.h> 39#include <linux/dma-mapping.h>
39#include <linux/atmel_pdc.h> 40#include <linux/atmel_pdc.h>
40#include <linux/atmel_serial.h> 41#include <linux/atmel_serial.h>
41#include <linux/uaccess.h> 42#include <linux/uaccess.h>
42#include <linux/platform_data/atmel.h> 43#include <linux/platform_data/atmel.h>
43#include <linux/timer.h> 44#include <linux/timer.h>
45#include <linux/gpio.h>
44 46
45#include <asm/io.h> 47#include <asm/io.h>
46#include <asm/ioctls.h> 48#include <asm/ioctls.h>
47 49
48#ifdef CONFIG_ARM
49#include <mach/cpu.h>
50#include <asm/gpio.h>
51#endif
52
53#define PDC_BUFFER_SIZE 512 50#define PDC_BUFFER_SIZE 512
54/* Revisit: We should calculate this based on the actual port settings */ 51/* Revisit: We should calculate this based on the actual port settings */
55#define PDC_RX_TIMEOUT (3 * 10) /* 3 bytes */ 52#define PDC_RX_TIMEOUT (3 * 10) /* 3 bytes */
@@ -168,6 +165,7 @@ struct atmel_uart_port {
168 struct circ_buf rx_ring; 165 struct circ_buf rx_ring;
169 166
170 struct serial_rs485 rs485; /* rs485 settings */ 167 struct serial_rs485 rs485; /* rs485 settings */
168 int rts_gpio; /* optional RTS GPIO */
171 unsigned int tx_done_mask; 169 unsigned int tx_done_mask;
172 bool is_usart; /* usart or uart */ 170 bool is_usart; /* usart or uart */
173 struct timer_list uart_timer; /* uart timer */ 171 struct timer_list uart_timer; /* uart timer */
@@ -301,20 +299,16 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
301 unsigned int mode; 299 unsigned int mode;
302 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 300 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
303 301
304#ifdef CONFIG_ARCH_AT91RM9200 302 /*
305 if (cpu_is_at91rm9200()) { 303 * AT91RM9200 Errata #39: RTS0 is not internally connected
306 /* 304 * to PA21. We need to drive the pin as a GPIO.
307 * AT91RM9200 Errata #39: RTS0 is not internally connected 305 */
308 * to PA21. We need to drive the pin manually. 306 if (gpio_is_valid(atmel_port->rts_gpio)) {
309 */ 307 if (mctrl & TIOCM_RTS)
310 if (port->mapbase == AT91RM9200_BASE_US0) { 308 gpio_set_value(atmel_port->rts_gpio, 0);
311 if (mctrl & TIOCM_RTS) 309 else
312 at91_set_gpio_value(AT91_PIN_PA21, 0); 310 gpio_set_value(atmel_port->rts_gpio, 1);
313 else
314 at91_set_gpio_value(AT91_PIN_PA21, 1);
315 }
316 } 311 }
317#endif
318 312
319 if (mctrl & TIOCM_RTS) 313 if (mctrl & TIOCM_RTS)
320 control |= ATMEL_US_RTSEN; 314 control |= ATMEL_US_RTSEN;
@@ -2379,6 +2373,25 @@ static int atmel_serial_probe(struct platform_device *pdev)
2379 port = &atmel_ports[ret]; 2373 port = &atmel_ports[ret];
2380 port->backup_imr = 0; 2374 port->backup_imr = 0;
2381 port->uart.line = ret; 2375 port->uart.line = ret;
2376 port->rts_gpio = -EINVAL; /* Invalid, zero could be valid */
2377 if (pdata)
2378 port->rts_gpio = pdata->rts_gpio;
2379 else if (np)
2380 port->rts_gpio = of_get_named_gpio(np, "rts-gpios", 0);
2381
2382 if (gpio_is_valid(port->rts_gpio)) {
2383 ret = devm_gpio_request(&pdev->dev, port->rts_gpio, "RTS");
2384 if (ret) {
2385 dev_err(&pdev->dev, "error requesting RTS GPIO\n");
2386 goto err;
2387 }
2388 /* Default to 1 as RTS is active low */
2389 ret = gpio_direction_output(port->rts_gpio, 1);
2390 if (ret) {
2391 dev_err(&pdev->dev, "error setting up RTS GPIO\n");
2392 goto err;
2393 }
2394 }
2382 2395
2383 ret = atmel_init_port(port, pdev); 2396 ret = atmel_init_port(port, pdev);
2384 if (ret) 2397 if (ret)
diff --git a/include/linux/platform_data/atmel.h b/include/linux/platform_data/atmel.h
index cea9f70133c5..e26b0c14edea 100644
--- a/include/linux/platform_data/atmel.h
+++ b/include/linux/platform_data/atmel.h
@@ -84,6 +84,7 @@ 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 */
87}; 88};
88 89
89 /* Touchscreen Controller */ 90 /* Touchscreen Controller */