Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
On Tuesday 26 May 2015 12:34 PM, Yegor Yefremov wrote: Hi Tony, Nishanth and Felipe, On Fri, May 22, 2015 at 7:54 PM, Tony Lindgren t...@atomide.com wrote: * Felipe Balbi ba...@ti.com [150522 10:41]: On Fri, May 22, 2015 at 09:52:13AM -0700, Tony Lindgren wrote: * Nishanth Menon n...@ti.com [150522 08:36]: On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? Yes please. Also, do we really want to allow mapping random GPIO pins to the UART driver? I guess it would be See drivers/tty/serial/serial_mctrl_gpio.[ch], these are used for UARTs on SoCs with enough GPIOs available whose UART don't have full Modem signals. It's pretty handy for BT, GSM, LTE, whatever type of modem-like device. OK I need this functionality for a real device having switchable RS232/422/485 driver. So I need both RS232 signals, that are not all possible to get via pinmux, and RS485 transmitter switching. AFAIK RS485 feature is still not implemented in 8250. That's why I would like this patch to be still included into omap_serial for now. No one I know in TI has used or tested the RS485 functionality. Thats why Sebastian left it when he created the 8250_omap driver. Since you have the setup to test it, is it possible for you to migrate that functionality to 8250_omap.c itself rather than enhance omap-serial.c? We really want to be gravitating towards 8250_omap.c and this patch will take us backwards. As a bonus you get more efficient interrupt handling etc with the new driver. Thanks, Sekhar -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
Hi Tony, Nishanth and Felipe, On Fri, May 22, 2015 at 7:54 PM, Tony Lindgren t...@atomide.com wrote: * Felipe Balbi ba...@ti.com [150522 10:41]: On Fri, May 22, 2015 at 09:52:13AM -0700, Tony Lindgren wrote: * Nishanth Menon n...@ti.com [150522 08:36]: On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? Yes please. Also, do we really want to allow mapping random GPIO pins to the UART driver? I guess it would be See drivers/tty/serial/serial_mctrl_gpio.[ch], these are used for UARTs on SoCs with enough GPIOs available whose UART don't have full Modem signals. It's pretty handy for BT, GSM, LTE, whatever type of modem-like device. OK I need this functionality for a real device having switchable RS232/422/485 driver. So I need both RS232 signals, that are not all possible to get via pinmux, and RS485 transmitter switching. AFAIK RS485 feature is still not implemented in 8250. That's why I would like this patch to be still included into omap_serial for now. Yegor -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] tty: serial: omap: use mctrl_gpio helpers
From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/omap_serial.txt b/Documentation/devicetree/bindings/serial/omap_serial.txt index 54c2a15..10fcba8 100644 --- a/Documentation/devicetree/bindings/serial/omap_serial.txt +++ b/Documentation/devicetree/bindings/serial/omap_serial.txt @@ -16,6 +16,9 @@ Optional properties: - dmas : DMA specifier, consisting of a phandle to the DMA controller node and a DMA channel number. - dma-names : rx for receive channel, tx for transmit channel. +- {rts,cts,dtr,dsr,rng,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 UART feature. If unsure, don't specify this property. Example: @@ -27,4 +30,10 @@ Example: dma-names = tx, rx; ti,hwmods = uart4; clock-frequency = 4800; +cts-gpios = gpio3 5 GPIO_ACTIVE_LOW; +rts-gpios = gpio3 6 GPIO_ACTIVE_LOW; +dtr-gpios = gpio1 12 GPIO_ACTIVE_LOW; +dsr-gpios = gpio1 13 GPIO_ACTIVE_LOW; +dcd-gpios = gpio1 14 GPIO_ACTIVE_LOW; +rng-gpios = gpio1 15 GPIO_ACTIVE_LOW; }; diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index f8120c1..bbe0e06 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig @@ -1106,6 +1106,7 @@ config SERIAL_OMAP tristate OMAP serial port support depends on ARCH_OMAP2PLUS select SERIAL_CORE + select SERIAL_MCTRL_GPIO help If you have a machine based on an Texas Instruments OMAP CPU you can enable its onboard serial ports by enabling this option. diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 7f49172..42751b0 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c @@ -43,9 +43,13 @@ #include linux/gpio.h #include linux/of_gpio.h #include linux/platform_data/serial-omap.h +#include linux/gpio/consumer.h +#include linux/err.h #include dt-bindings/gpio/gpio.h +#include serial_mctrl_gpio.h + #define OMAP_MAX_HSUART_PORTS 10 #define UART_BUILD_REVISION(x, y) (((x) 8) | (y)) @@ -164,6 +168,9 @@ struct uart_omap_port { u32 features; int rts_gpio; + struct mctrl_gpios *gpios; + int gpio_irq[UART_GPIO_MAX]; + boolms_irq_enabled; struct pm_qos_request pm_qos_request; u32 latency; @@ -301,6 +308,27 @@ static void serial_omap_enable_ms(struct uart_port *port) dev_dbg(up-port.dev, serial_omap_enable_ms+%d\n, up-port.line); pm_runtime_get_sync(up-dev); + + /* + * Interrupt should not be enabled twice + */ + if (up-ms_irq_enabled) + return; + + up-ms_irq_enabled = true; + + if (up-gpio_irq[UART_GPIO_CTS] = 0) + enable_irq(up-gpio_irq[UART_GPIO_CTS]); + + if (up-gpio_irq[UART_GPIO_DSR] = 0) + enable_irq(up-gpio_irq[UART_GPIO_DSR]); + + if (up-gpio_irq[UART_GPIO_RI] = 0) + enable_irq(up-gpio_irq[UART_GPIO_RI]); + + if (up-gpio_irq[UART_GPIO_DCD] = 0) + enable_irq(up-gpio_irq[UART_GPIO_DCD]); + up-ier |= UART_IER_MSI; serial_out(up, UART_IER, up-ier); pm_runtime_mark_last_busy(up-dev); @@ -317,6 +345,11 @@ static void serial_omap_stop_tx(struct uart_port *port) /* Handle RS-485 */ if (port-rs485.flags SER_RS485_ENABLED) { if (up-scr OMAP_UART_SCR_TX_EMPTY) { + struct gpio_desc *rts_gpiod; + + rts_gpiod = mctrl_gpio_to_gpiod(up-gpios, + UART_GPIO_RTS); + /* THR interrupt is fired when both TX FIFO and TX * shift register are empty. This means there's nothing * left to transmit now, so make sure the THR interrupt @@ -328,11 +361,11 @@ static void serial_omap_stop_tx(struct uart_port *port) serial_out(up, UART_OMAP_SCR, up-scr); res = (port-rs485.flags SER_RS485_RTS_AFTER_SEND) ? 1 : 0; - if (gpio_get_value(up-rts_gpio) != res) { + if
Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? -- Regards, Nishanth Menon -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
* Nishanth Menon n...@ti.com [150522 08:36]: On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? Yes please. Also, do we really want to allow mapping random GPIO pins to the UART driver? I guess it would be handy for powering UART connected devices like BT up and down.. There's one fix pending to 8250_omap for mainline BTW: [PATCH] serial: 8250_omap: provide complete custom startup shutdown callbacks But other than that it seems to behave at least for me. Regards, Tony -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
On Fri, May 22, 2015 at 09:52:13AM -0700, Tony Lindgren wrote: * Nishanth Menon n...@ti.com [150522 08:36]: On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? Yes please. Also, do we really want to allow mapping random GPIO pins to the UART driver? I guess it would be See drivers/tty/serial/serial_mctrl_gpio.[ch], these are used for UARTs on SoCs with enough GPIOs available whose UART don't have full Modem signals. It's pretty handy for BT, GSM, LTE, whatever type of modem-like device. -- balbi signature.asc Description: Digital signature
Re: [PATCH] tty: serial: omap: use mctrl_gpio helpers
* Felipe Balbi ba...@ti.com [150522 10:41]: On Fri, May 22, 2015 at 09:52:13AM -0700, Tony Lindgren wrote: * Nishanth Menon n...@ti.com [150522 08:36]: On 05/22/2015 07:16 AM, yegorsli...@googlemail.com wrote: From: Yegor Yefremov yegorsli...@googlemail.com This patch permits to use GPIOs to control the CTS/RTS/DTR/DSR/DCD/RI signals. Signed-off-by: Yegor Yefremov yegorsli...@googlemail.com --- .../devicetree/bindings/serial/omap_serial.txt |9 + drivers/tty/serial/Kconfig |1 + drivers/tty/serial/omap-serial.c | 168 +++- 3 files changed, 171 insertions(+), 7 deletions(-) Would we rather move introducing new features to 8250_omap.c rather than doing that to omap-serial and keep feature creeping it such that we wont ever be able to switch to 8250_omap ? Yes please. Also, do we really want to allow mapping random GPIO pins to the UART driver? I guess it would be See drivers/tty/serial/serial_mctrl_gpio.[ch], these are used for UARTs on SoCs with enough GPIOs available whose UART don't have full Modem signals. It's pretty handy for BT, GSM, LTE, whatever type of modem-like device. OK Tony -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html