tty/serial: Add helpers to use GPIOs to control modem lines
Subsystems (7)
v2 cover tty/serial: Add helpers to use GPIOs to control modem lines
The USART controller on sam9x5 chips (and also all AT91/SAMA5 chips but at91rm9200) are not capable of handling DTR/DSR/DCD/RI signal. Moreover, even if the controller can handle CTS/RTS, the dedicated CTS/RTS pins are already muxed for other peripherals (LCDC/EMAC/MMC).
So this patchset adds the possibility to control those lines via GPIO, as it is done for RTS in the patch "switch atmel serial to use gpiolib"
As it was suggested by Alexander Shiyan, I made that available for every board.
This is based on 3.14-rc2 + Linus Walleij/Nicolas Ferre's patch:
354e57f3a0a2 ARM/serial: at91: switch atmel serial to use gpiolib
(in Uwe's tree git://git.pengutronix.de/git/ukl/linux.git dropmachtimexh ) and Philipp Zabel's patch:
gpiolib: make gpiod_direction_output take a logical value, add gpiod_direction_output_raw (there won't be a merge conflict if this last patch is not present, the gpios will "just" be on the wrong direction.)
Tested on at91sam9g35, with a null modem cable between 2 serial ports, one with CTS/RTS controlled by the USART controller, the other via GPIO, full duplex transfers.
Did some tests also with null modem cables on a PC.
Updates from v2:
- Instead of controlling modem signal only on atmel board, the code is now available for every board.
- The active low flag from device tree is now used.
Richard Genoud (4):
tty/serial: Add GPIOLIB helpers for controlling modem lines tty/serial: at91: use dev_err instead of printk tty/serial: at91: remove unused open/close hooks tty/serial: at91: use mctrl_gpio helpers
.../devicetree/bindings/serial/atmel-usart.txt | 12 +- Documentation/serial/driver | 21 ++ arch/arm/mach-at91/at91rm9200_devices.c | 25 ++ arch/arm/mach-at91/at91sam9260_devices.c | 35 +++ arch/arm/mach-at91/at91sam9261_devices.c | 20 ++ arch/arm/mach-at91/at91sam9263_devices.c | 20 ++ arch/arm/mach-at91/at91sam9g45_devices.c | 25 ++ arch/arm/mach-at91/at91sam9rl_devices.c | 25 ++ drivers/tty/serial/Kconfig | 4 + drivers/tty/serial/Makefile | 3 + drivers/tty/serial/atmel_serial.c | 313 +++++++++++++++++---- drivers/tty/serial/serial_mctrl_gpio.c | 113 ++++++++ drivers/tty/serial/serial_mctrl_gpio.h | 56 ++++ include/linux/platform_data/atmel.h | 5 + 14 files changed, 615 insertions(+), 62 deletions(-) create mode 100644 drivers/tty/serial/serial_mctrl_gpio.c create mode 100644 drivers/tty/serial/serial_mctrl_gpio.h
Signature · 1 line
1.8.5
PATCH v2 1/4 tty/serial: Add GPIOLIB helpers for controlling modem lines
This patch add some helpers to control modem lines (CTS/RTS/DSR...) via GPIO.
This will be useful for many boards which have a serial controller that only handle CTS/RTS pins (or even just RX/TX).
--- Documentation/serial/driver | 21 ++++++ drivers/tty/serial/Kconfig | 4 ++ drivers/tty/serial/Makefile | 3 + drivers/tty/serial/serial_mctrl_gpio.c | 113 +++++++++++++++++++++++++++++++++ drivers/tty/serial/serial_mctrl_gpio.h | 56 ++++++++++++++++ 5 files changed, 197 insertions(+) create mode 100644 drivers/tty/serial/serial_mctrl_gpio.c create mode 100644 drivers/tty/serial/serial_mctrl_gpio.h
Documentation/serial/driver +21 -0
@@ -429,3 +429,24 @@ thus: struct uart_port port; int my_stuff; }; + +Modem control lines via GPIO +---------------------------- + +Some helpers are provided in order to set/get modem control lines via GPIO. + +mctrl_gpio_init(dev, gpios): + This will get the {cts,rts,...}-gpios from device tree if they are + present and request them, set direction etc. + +mctrl_gpio_free(gpios): + This will free the requested gpios in mctrl_gpio_init(). + +mctrl_gpio_set(gpios, mctrl): + This will sets the gpios according to the mctrl state. + +mctrl_gpio_get(gpios, mctrl): + This will update mctrl with the gpios values. + +get_mctrl_gpio_name(mctrl_gpio_idx): + Returns a name associated to the GPIO modem line.
drivers/tty/serial/Kconfig +4 -0
@@ -1509,4 +1509,8 @@ config SERIAL_ST_ASC_CONSOLE endmenu +config SERIAL_MCTRL_GPIO + def_bool y + depends on GPIOLIB + endif # TTY
drivers/tty/serial/Makefile +3 -0
@@ -87,3 +87,6 @@ obj-$(CONFIG_SERIAL_EFM32_UART) += efm32-uart.o obj-$(CONFIG_SERIAL_ARC) += arc_uart.o obj-$(CONFIG_SERIAL_RP2) += rp2.o obj-$(CONFIG_SERIAL_FSL_LPUART) += fsl_lpuart.o + +# GPIOLIB helpers for modem control lines +obj-$(CONFIG_SERIAL_MCTRL_GPIO) += serial_mctrl_gpio.o
drivers/tty/serial/serial_mctrl_gpio.c new file +113 -0
113 lines not on this page · raw message
drivers/tty/serial/serial_mctrl_gpio.h new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.8.5
Re: [PATCH v2 1/4] tty/serial: Add GPIOLIB helpers for controlling modem lines
Hello.
???????, 11 ??????? 2014, 18:45 +01:00 ?? Richard Genoud <[email protected]>:
Quoted 7 lines
This patch add some helpers to control modem lines (CTS/RTS/DSR...) via GPIO.
This will be useful for many boards which have a serial controller that only handle CTS/RTS pins (or even just RX/TX).Signed-off-by Richard Genoud <[email protected]>---
OK, a few comments below.
...
drivers/tty/serial/Kconfig config SERIAL_ST_ASC_CONSOLE · line 1514
Quoted 3 lines
drivers/tty/serial/Kconfig +3
-0+config SERIAL_MCTRL_GPIO + def_bool y + depends on GPIOLIB
I suggest to move GPIOLIB dependency to serial_mctrl_gpio.h header, so unit can be used with or without GPIOLIB, so Kconfig will look something like this:
config SERIAL_MCTRL_GPIO
tristate
Then, you can select this option for particular UART:
config SERIAL_ATMEL
...
select SERIAL_MCTRL_GPIO
...
Quoted 1 line
+++
b/drivers/tty/serial/serial_mctrl_gpio.c
...
drivers/tty/serial/serial_mctrl_gpio.c line 16
Quoted 3 lines
drivers/tty/serial/serial_mctrl_gpio.c new file +3
-0+static const char *mctrl_gpio_of_names[UART_GPIO_MAX ] = { +"cts" ,"dsr" ,"dcd" ,"ri" ,"rts" ,"dtr" +};
Make a combined array. This will use cycles for set/get operations.
static struct {
const char *name;
unsigned int mctrl;
} mctrl_gpios[] = {
{ "cts", TIOCM_CTS, },
...
};
...
Review
Quoted 2 lines
(quoted diff) +2
-0+int mctrl_gpio_init(struct device *dev, struct mctrl_gpios *gpios) +{
I'm not sure whether to make a non-DT support at all ...
drivers/tty/serial/serial_mctrl_gpio.c line 77
Quoted 6 lines
drivers/tty/serial/serial_mctrl_gpio.c new file +6
-0+enum mctrl_gpio_idx i; +int err =0 ; +int ret =0 ; + +for (i =UART_GPIO_MIN ; i <UART_GPIO_MAX ; i++) { + gpios->gpio[i] =gpiod_get (dev, mctrl_gpio_of_names[i]);
What a reason to using gpiod_xxx() ?
Why we cannot use standart devm_gpio_request/get/set etc. ?
In addition, I recommend create this patch as separate, because it will most likely still be comments later. Thanks.
---
PATCH v2 1/4 tty/serial: Add GPIOLIB helpers for controlling modem lines
2014-02-11 19:23 GMT+01:00 Alexander Shiyan <[email protected]>:
Quoted 1 line
Hello.
Hi !
Quoted 20 lines
???????, 11 ??????? 2014, 18:45 +01:00 ?? Richard Genoud <[email protected]>:
Quoted 7 lines
This patch add some helpers to control modem lines (CTS/RTS/DSR...) via GPIO.
This will be useful for many boards which have a serial controller that only handle CTS/RTS pins (or even just RX/TX).Signed-off-by Richard Genoud <[email protected]>---
OK, a few comments below.
...
drivers/tty/serial/Kconfig config SERIAL_ST_ASC_CONSOLE · line 1514
Quoted 3 lines
drivers/tty/serial/Kconfig +3
-0+config SERIAL_MCTRL_GPIO + def_bool y + depends on GPIOLIBI suggest to move GPIOLIB dependency to
serial_mctrl_gpio.hheader, so unit can be used with or without GPIOLIB, soKconfigwill look something like this:
Quoted 7 lines
config
SERIAL_MCTRL_GPIO
tristateThen, you can select this option for particular UART:
configSERIAL_ATMEL
...
selectSERIAL_MCTRL_GPIO
Yes, you're right, it seems better like that.
Quoted 9 lines
...
Quoted 1 line
+++
b/drivers/tty/serial/serial_mctrl_gpio.c...
drivers/tty/serial/serial_mctrl_gpio.c line 16
Quoted 3 lines
drivers/tty/serial/serial_mctrl_gpio.c new file +3
-0+static const char *mctrl_gpio_of_names[UART_GPIO_MAX ] = { +"cts" ,"dsr" ,"dcd" ,"ri" ,"rts" ,"dtr" +};Make a combined array. This will use cycles for set/get operations.
Quoted 7 lines
static struct {
const char *name;
unsigned int mctrl;
} mctrl_gpios[] = {
{ "cts",TIOCM_CTS, },
...
};
yes, good idea !
Quoted 5 lines
...
Review
Quoted 2 lines
(quoted diff) +2
-0+int mctrl_gpio_init(struct device *dev, struct mctrl_gpios *gpios) +{I'm not sure whether to make a non-DT support at all ...
I don't understand what you mean.
You would like another _init() function for non-DT board ? Well, I thought that non DT board could handle their GPIO init (like I did in atmel_serial.c for platform_data based boards), but still use the mctrl_gpio_{get,set} functions.
Quoted 9 lines
drivers/tty/serial/serial_mctrl_gpio.c line 77
Quoted 6 lines
drivers/tty/serial/serial_mctrl_gpio.c new file +6
-0+enum mctrl_gpio_idx i; +int err =0 ; +int ret =0 ; + +for (i =UART_GPIO_MIN ; i <UART_GPIO_MAX ; i++) { + gpios->gpio[i] =gpiod_get (dev, mctrl_gpio_of_names[i]);What a reason to using
gpiod_xxx()?
Why we cannot use standart devm_gpio_request/get/set etc. ?
Ah ! I missed devm_gpiod_get()
I'll use it.
Quoted 3 lines
In addition, I recommend create this patch as separate, because it will most likely still be comments later.
Well, I'd rather not separate this patch from at least "patch 4/4 tty/serial: at91: use mctrl_gpio helpers"
because if the patch 4/4 is merged before this one, the compilation will fail, and git bisecting will be a pain.
Or there's another solution ?
Quoted 1 line
Thanks.
Thanks !
PATCH v2 2/4 tty/serial: at91: use dev_err instead of printk
In reply to Richard GenoudFor better consistency.
--- drivers/tty/serial/atmel_serial.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/atmel_serial.c +2 -2
@@ -1549,7 +1549,7 @@ static int atmel_startup(struct uart_port *port) retval =request_irq (port->irq, atmel_interrupt,IRQF_SHARED , tty ? tty->name :"atmel_serial" , port);if (retval) { -printk ("atmel_serial: atmel_startup - Can't get irq\n" ); +dev_err (port->dev,"atmel_startup - Can't get irq\n" );return retval; }
@@ -1732,7 +1732,7 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state,clk_disable_unprepare (atmel_port->clk);break ;default : -printk (KERN_ERR "atmel_serial: unknown pm %d\n" , state); +dev_err (port->dev,"atmel_serial: unknown pm %d\n" , state); } }
Signature · 1 line
1.8.5
PATCH v2 3/4 tty/serial: at91: remove unused open/close hooks
In reply to Richard Genoudcommit 95e629b761ce36996d1befe2824d5346b5a220b9 removed the use of board specific hooks in serial_at91.h, so now, the open/close hook are just dead code.
--- drivers/tty/serial/atmel_serial.c | 21 --------------------- 1 file changed, 21 deletions(-)
drivers/tty/serial/atmel_serial.c +0 -21
@@ -112,9 +112,6 @@ static void atmel_stop_rx(struct uart_port *port);#define UART_PUT_TCR (port,v) __raw_writel(v, (port)->membase + ATMEL_PDC_TCR)#define UART_GET_TCR (port) __raw_readl((port)->membase + ATMEL_PDC_TCR) -static int (*atmel_open_hook)(struct uart_port *); -static void (*atmel_close_hook)(struct uart_port *); -struct atmel_dma_buffer {unsigned char *buf;dma_addr_t dma_addr;
@@ -1569,17 +1566,6 @@ static int atmel_startup(struct uart_port *port)if (retval <0 )atmel_set_ops (port); } -/* -* If there is a specific "open" function (to register -* control line interrupts) -*/ -if (atmel_open_hook) { - retval =atmel_open_hook (port); -if (retval) { -free_irq (port->irq, port); -return retval; - } - }/* Save current CSR for comparison in atmel_tasklet_func() */ atmel_port->irq_status_prev =UART_GET_CSR (port);
@@ -1678,13 +1664,6 @@ static void atmel_shutdown(struct uart_port *port)* Free the interrupt */ free_irq (port->irq, port); - -/* -* If there is a specific "close" function (to unregister -* control line interrupts) -*/ -if (atmel_close_hook) -atmel_close_hook (port); }/*
Signature · 1 line
1.8.5
PATCH v2 4/4 tty/serial: at91: use mctrl_gpio helpers
In reply to Richard GenoudOn sam9x5, dedicated CTS (and RTS) pins are unusable together with the LCDC, the EMAC, or the MMC because they share the same line.
Moreover, the USART controller doesn't handle DTR/DSR/DCD/RI signals, so we have to control them via GPIO.
This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals.
--- .../devicetree/bindings/serial/atmel-usart.txt | 12 +- arch/arm/mach-at91/at91rm9200_devices.c | 25 ++ arch/arm/mach-at91/at91sam9260_devices.c | 35 +++ arch/arm/mach-at91/at91sam9261_devices.c | 20 ++ arch/arm/mach-at91/at91sam9263_devices.c | 20 ++ arch/arm/mach-at91/at91sam9g45_devices.c | 25 ++ arch/arm/mach-at91/at91sam9rl_devices.c | 25 ++ drivers/tty/serial/atmel_serial.c | 290 ++++++++++++++++++--- include/linux/platform_data/atmel.h | 5 + 9 files changed, 417 insertions(+), 40 deletions(-)
Documentation/devicetree/bindings/serial/atmel-usart.txt +9 -3
@@ -13,8 +13,9 @@ Required properties: Optional properties: - atmel,use-dma-rx: use of PDC or DMA for receiving data - atmel,use-dma-tx: use of PDC or DMA for transmitting data -- rts-gpios: specify a GPIO for RTS line. It will use specified PIO instead of the peripheral - function pin for the USART RTS feature. If unsure, don't specify this property. +- {rts,cts,dtr,dsr,ri,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD line respectively. + It will use specified PIO instead of the peripheral function pin for the USART feature. + If unsure, don't specify this property. - add dma bindings for dma transfer: - dmas: DMA specifier, consisting of a phandle to DMA controller node, memory peripheral interface and USART DMA channel ID, FIFO configuration.
@@ -35,7 +36,12 @@ Example: clock-names = "usart"; atmel,use-dma-rx; atmel,use-dma-tx; - rts-gpios = <&pioD 15 0>; + rts-gpios = <&pioD 15 GPIO_ACTIVE_LOW>; + cts-gpios = <&pioD 16 GPIO_ACTIVE_LOW>; + dtr-gpios = <&pioD 17 GPIO_ACTIVE_LOW>; + dsr-gpios = <&pioD 18 GPIO_ACTIVE_LOW>; + dcd-gpios = <&pioD 20 GPIO_ACTIVE_LOW>; + ri-gpios = <&pioD 19 GPIO_ACTIVE_LOW>; }; - use DMA:
arch/arm/mach-at91/at91rm9200_devices.c +25 -0
@@ -923,6 +923,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, /* DBGU not capable of receive DMA */ .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -962,6 +967,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -1013,6 +1023,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -1065,6 +1080,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
@@ -1109,6 +1129,11 @@ static struct atmel_uart_data uart3_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart3_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-at91/at91sam9260_devices.c +35 -0
@@ -820,6 +820,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, /* DBGU not capable of receive DMA */ .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -859,6 +864,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -911,6 +921,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -955,6 +970,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
@@ -999,6 +1019,11 @@ static struct atmel_uart_data uart3_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart3_dmamask =DMA_BIT_MASK (32 );
@@ -1043,6 +1068,11 @@ static struct atmel_uart_data uart4_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart4_dmamask =DMA_BIT_MASK (32 );
@@ -1082,6 +1112,11 @@ static struct atmel_uart_data uart5_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart5_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-at91/at91sam9261_devices.c +20 -0
@@ -881,6 +881,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, /* DBGU not capable of receive DMA */ .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -920,6 +925,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -964,6 +974,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -1008,6 +1023,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-at91/at91sam9263_devices.c +20 -0
@@ -1325,6 +1325,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, /* DBGU not capable of receive DMA */ .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -1364,6 +1369,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -1408,6 +1418,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -1452,6 +1467,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-at91/at91sam9g45_devices.c +25 -0
@@ -1588,6 +1588,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -1627,6 +1632,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -1671,6 +1681,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -1715,6 +1730,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
@@ -1759,6 +1779,11 @@ static struct atmel_uart_data uart3_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart3_dmamask =DMA_BIT_MASK (32 );
arch/arm/mach-at91/at91sam9rl_devices.c +25 -0
@@ -957,6 +957,11 @@ static struct atmel_uart_data dbgu_data = { .use_dma_tx = 0, .use_dma_rx = 0, /* DBGU not capable of receive DMA */ .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 dbgu_dmamask =DMA_BIT_MASK (32 );
@@ -996,6 +1001,11 @@ static struct atmel_uart_data uart0_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart0_dmamask =DMA_BIT_MASK (32 );
@@ -1048,6 +1058,11 @@ static struct atmel_uart_data uart1_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart1_dmamask =DMA_BIT_MASK (32 );
@@ -1092,6 +1107,11 @@ static struct atmel_uart_data uart2_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart2_dmamask =DMA_BIT_MASK (32 );
@@ -1136,6 +1156,11 @@ static struct atmel_uart_data uart3_data = { .use_dma_tx = 1, .use_dma_rx = 1, .rts_gpio = -EINVAL, + .cts_gpio = -EINVAL, + .dtr_gpio = -EINVAL, + .dsr_gpio = -EINVAL, + .ri_gpio = -EINVAL, + .dcd_gpio = -EINVAL, };static u64 uart3_dmamask =DMA_BIT_MASK (32 );
drivers/tty/serial/atmel_serial.c +253 -37
418 lines not on this page · raw message
include/linux/platform_data/atmel.h +5 -0
@@ -85,6 +85,11 @@ struct atmel_uart_data {void __iomem *regs;/* virt. base address, if any */ struct serial_rs485 rs485;/* rs485 settings */ int rts_gpio;/* optional RTS GPIO */ +int cts_gpio;/* optional CTS GPIO */ +int dtr_gpio;/* optional DTR GPIO */ +int dsr_gpio;/* optional DSR GPIO */ +int dcd_gpio;/* optional DCD GPIO */ +int ri_gpio;/* optional Ring GPIO */ };/* Touchscreen Controller */
Signature · 1 line
1.8.5
Greg Kroah-Hartman
maintainerv2 cover tty/serial: Add helpers to use GPIOs to control modem lines
In reply to Richard GenoudQuoted 24 lines · Richard Genoud
The USART controller on sam9x5 chips (and also all AT91/SAMA5 chips but at91rm9200) are not capable of handling DTR/DSR/DCD/RI signal. Moreover, even if the controller can handle CTS/RTS, the dedicated CTS/RTS pins are already muxed for other peripherals (LCDC/EMAC/MMC).
So this patchset adds the possibility to control those lines via GPIO, as it is done for RTS in the patch "switch atmel serial to use gpiolib"
As it was suggested by Alexander Shiyan, I made that available for every board.
This is based on 3.14-rc2 + Linus Walleij/Nicolas Ferre's patch:
354e57f3a0a2ARM/serial: at91: switch atmel serial to use gpiolib
(in Uwe's treegit://git.pengutronix.de/git/ukl/linux.gitdropmachtimexh ) and Philipp Zabel's patch:
gpiolib: makegpiod_direction_outputtake a logical value, addgpiod_direction_output_raw(there won't be a merge conflict if this last patch is not present, the gpios will "just" be on the wrong direction.)Tested on at91sam9g35, with a null modem cable between 2 serial ports, one with CTS/RTS controlled by the USART controller, the other via GPIO, full duplex transfers.
Did some tests also with null modem cables on a PC.
Quoted 4 lines
Updates from v2:
- Instead of controlling modem signal only on atmel board, the code is now available for every board.
- The active low flag from device tree is now used.
I'm confused, how does this series relate to the previously sent 8 patch series?
As I don't know what is going on, I'm going to drop both from my to-apply queue, and await a new set of patches.
thanks,
greg k-h