serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
PATCH 1/4 serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
Dedicated CTS and RTS pins are unusable together with a lot of other peripherals because they share the same line. Pinctrl is limited.
Moreover, the AUART 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/fsl-mxs-auart.txt | 10 ++- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/mxs-auart.c | 77 +++++++++++++++++++++- 3 files changed, 84 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/serial/fsl-mxs-auart.txt +9 -1
@@ -11,8 +11,13 @@ Required properties: - dma-names: "rx" for RX channel, "tx" for TX channel. Optional properties: -- fsl,uart-has-rtscts : Indicate the UART has RTS and CTS lines, +- fsl,uart-has-rtscts : Indicate the UART has RTS and CTS lines + for hardware flow control, it also means you enable the DMA support for this UART. +- {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 USART feature. + If unsure, don't specify this property. Example: auart0: serial@8006a000 {
@@ -21,6 +26,9 @@ auart0: serial@8006a000 { interrupts = <112>; dmas = <&dma_apbx 8>, <&dma_apbx 9>; dma-names = "rx", "tx"; + cts-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; + dsr-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; + dcd-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; }; Note: Each auart port should have an alias correctly numbered in "aliases"
drivers/tty/serial/Kconfig +1 -0
@@ -1357,6 +1357,7 @@ config SERIAL_MXS_AUART depends on ARCH_MXS tristate "MXS AUART support" select SERIAL_CORE + select SERIAL_MCTRL_GPIO if GPIOLIB help This driver supports the MXS Application UART (AUART) port.
drivers/tty/serial/mxs-auart.c +74 -3
146 lines not on this page · raw message
Signature · 1 line
1.7.11.3
PATCH 1/4 serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
Please for comments in order to resend clean patches. 4/4: can be applied separately
TODO:
- tx_empty fix
- port.lock
- pm support
best regards
Janusz
W dniu 2014-09-19 20:13, Janusz Uzycki pisze:
Quoted 218 lines
Dedicated CTS and RTS pins are unusable together with a lot of other peripherals because they share the same line. Pinctrl is limited.
Moreover, the AUART 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.
Signed-off-by Janusz Uzycki <[email protected]>--- .../devicetree/bindings/serial/fsl-mxs-auart.txt | 10 ++- drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/mxs-auart.c | 77 +++++++++++++++++++++- 3 files changed, 84 insertions(+), 4 deletions(-)Documentation/devicetree/bindings/serial/fsl-mxs-auart.txt +9
-1@@ -11,8 +11,13 @@ Required properties: - dma-names: "rx" for RX channel, "tx" for TX channel. Optional properties: -- fsl,uart-has-rtscts : Indicate the UART has RTS and CTS lines, +- fsl,uart-has-rtscts : Indicate the UART has RTS and CTS lines + for hardware flow control, it also means you enable the DMA support for this UART. +- {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 USART feature. + If unsure, don't specify this property. Example: auart0: serial@8006a000 {@@ -21,6 +26,9 @@ auart0: serial@8006a000 { interrupts = <112>; dmas = <&dma_apbx 8>, <&dma_apbx 9>; dma-names = "rx", "tx"; + cts-gpios = <&gpio1 15 GPIO_ACTIVE_LOW>; + dsr-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; + dcd-gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; }; Note: Each auart port should have an alias correctly numbered in "aliases"drivers/tty/serial/Kconfig +1
-0@@ -1357,6 +1357,7 @@ config SERIAL_MXS_AUART depends on ARCH_MXS tristate "MXS AUART support" select SERIAL_CORE + select SERIAL_MCTRL_GPIO if GPIOLIB help This driver supports the MXS Application UART (AUART) port.drivers/tty/serial/mxs-auart.c +74
-3@@ -38,6 +38,9 @@#include <asm/cacheflush.h> +#include <linux/err.h> +#include "serial_mctrl_gpio.h" +#define MXS_AUART_MAJOR 242#define MXS_AUART_PORTS 5#define MXS_AUART_FIFO_SIZE 16@@ -156,6 +159,8 @@ struct mxs_auart_port {struct scatterlist rx_sgl;struct dma_chan *rx_dma_chan;void *rx_dma_buf; + +struct mctrl_gpios *gpios; };static struct platform_device_id mxs_auart_devtype[] = {@@ -415,8 +420,43 @@ static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl) ctrl |=AUART_CTRL2_RTS ; } +/* Does tty layer modify mctrl for input lines +* and the code below is required? */ +#if 0 s->ctrl = mctrl; +#else + s->ctrl &= ~(TIOCM_RTS |TIOCM_DTR ); + s->ctrl |= mctrl & (TIOCM_RTS |TIOCM_DTR ); +#endif writel (ctrl, u->membase +AUART_CTRL2 ); + +mctrl_gpio_set (s->gpios, mctrl); +} + +/* mxs_auart_modem_status() based on 8250.c, +* similar function could be as serial's helper... */ +#define MCTRL_ANY_DELTA (TIOCM_RI | TIOCM_DSR | TIOCM_CD | TIOCM_CTS) +static u32 mxs_auart_modem_status (struct mxs_auart_port *s,u32 mctrl) +{ +u32 mctrl_diff; + + mctrl_diff = mctrl ^ s->ctrl; + s->ctrl = mctrl; +if (mctrl_diff &MCTRL_ANY_DELTA && +/*interrupt_enabled &&*/ + s->port.state !=NULL ) { +if (mctrl_diff &TIOCM_RI ) + s->port.icount.rng++; +if (mctrl_diff &TIOCM_DSR ) + s->port.icount.dsr++; +if (mctrl_diff &TIOCM_CD ) +uart_handle_dcd_change (&s->port, mctrl &TIOCM_CD ); +if (mctrl_diff &TIOCM_CTS ) +uart_handle_cts_change (&s->port, mctrl &TIOCM_CTS ); + +wake_up_interruptible (&s->port.state->port.delta_msr_wait); + } +return mctrl; }static u32 mxs_auart_get_mctrl (struct uart_port *u)@@ -433,7 +473,9 @@ static u32 mxs_auart_get_mctrl(struct uart_port *u)if (ctrl2 &AUART_CTRL2_RTS ) mctrl |=TIOCM_RTS ; -return mctrl; +/* should mxs_auart_modem_status() be in interrupt only? */ +return mxs_auart_modem_status (s, +mctrl_gpio_get (s->gpios, &mctrl)); }static int mxs_auart_dma_prep_rx (struct mxs_auart_port *s);@@ -637,7 +679,12 @@ static void mxs_auart_settermios(struct uart_port *u, ctrl |=AUART_LINECTRL_STP2 ;/* figure out the hardware flow control settings */ -if (cflag &CRTSCTS ) { +/*FIXME: DMA for hardware flow control only? */ +if (cflag &CRTSCTS && + (IS_ERR_OR_NULL (mctrl_gpio_to_gpiod (s->gpios, +UART_GPIO_RTS )) || +IS_ERR_OR_NULL (mctrl_gpio_to_gpiod (s->gpios, +UART_GPIO_CTS )))) {/* * The DMA has a bug(see errata:2836) in mx23. * So we can not implement the DMA for auart in mx23, @@ -696,8 +743,14 @@ static irqreturn_t mxs_auart_irq_handle(int irq, void *context) | AUART_INTR_CTSMIS), s->port.membase + AUART_INTR_CLR); +mxs_auart_modem_status (s, +mctrl_gpio_get (s->gpios, &s->ctrl)); +if (istat &AUART_INTR_CTSMIS ) { -uart_handle_cts_change (&s->port, stat &AUART_STAT_CTS ); +if (IS_ERR_OR_NULL (mctrl_gpio_to_gpiod (s->gpios, +UART_GPIO_CTS ))) +uart_handle_cts_change (&s->port, + stat &AUART_STAT_CTS );writel (AUART_INTR_CTSMIS , s->port.membase +AUART_INTR_CLR ); istat &= ~AUART_INTR_CTSMIS ;@@ -758,6 +811,8 @@ static int mxs_auart_startup(struct uart_port *u)*/ writel (AUART_LINECTRL_FEN , u->membase +AUART_LINECTRL_SET ); +/* get initial status of modem lines */ +mctrl_gpio_get (s->gpios, &s->ctrl);return 0 ; }@@ -1021,6 +1076,14 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,return 0 ; } +static int mxs_auart_init_gpios (struct mxs_auart_port *s,struct device *dev) +{ + s->gpios =mctrl_gpio_init (dev,0 ); +if (IS_ERR_OR_NULL (s->gpios)) +return -1 ; +return 0 ; +} +static int mxs_auart_probe (struct platform_device *pdev) { const struct of_device_id *of_id =@@ -1078,6 +1141,11 @@ static int mxs_auart_probe(struct platform_device *pdev)platform_set_drvdata (pdev, s); + ret =mxs_auart_init_gpios (s, &pdev->dev); +if (ret <0 ) +dev_err (&pdev->dev,"%s" , +"Failed to initialize GPIOs. The serial port may not work as expected" ); + auart_port[s->port.line] = s;mxs_auart_reset (&s->port);@@ -1094,6 +1162,7 @@ static int mxs_auart_probe(struct platform_device *pdev)return 0 ; out_free_irq: +mctrl_gpio_free (&pdev->dev, s->gpios);/*useless?*/ auart_port[pdev->id] =NULL ;free_irq (s->irq, s); out_free_clk:@@ -1112,6 +1181,8 @@ static int mxs_auart_remove(struct platform_device *pdev) auart_port[pdev->id] =NULL ; +mctrl_gpio_free (&pdev->dev, s->gpios);/*useless?*/ +clk_put (s->clk);free_irq (s->irq, s);kfree (s);
PATCH 1/4 serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
In reply to Janusz UzyckiW dniu 2014-09-25 17:29, Richard Genoud pisze:
Quoted 2 lines
2014-09-20 10:08 GMT+02:00 Janusz Użycki <[email protected]>:
Hi,
Hi Richard,
first, thanks for the very useful answers.
Quoted 6 lines
Quoted 4 lines
Could you look on my patch series [1...4]
serial: mxs-auart:
usemctrl_gpiohelpers for handling modem signals (v2.2c) at http://news.gmane.org/gmane.linux.serial ?If you resend them, put me in the CC list. That will be easier for me to have a look at them.
sure
Quoted 9 lines
Quoted 3 lines
I added some comments in patch's code. In
atmel_serialmctrl_gpio_free()is ommited, is it useless?If you take a look at
mctrl_gpio_init(), you'll see that all the allocations are done with devm_* functions.
So that they are automatically deallocated when the module unloads. I still wrotemctrl_gpio_free()for some cases where we want to free memory without unloading the module.
Quoted 3 lines
So you don't have to call
mctrl_gpio_free()at the end ofmxs_auart_probe()andmxs_auart_remove()
(cfDocumentation/serial/driver)
It is clear now, thanks.
Quoted 11 lines
Quoted 3 lines
Atmel_serialalso does not parse modem line status inmxs_auart_get_mctrl(), 8250 driver does it. Which solution is ok?Well, in
atmel_get_mctrl(), we have to retrieve the line status from the uart controller :
that's done with :
status =UART_GET_CSR(port);
Then, for the lines controlled via GPIO, we are callingmctrl_gpio_get()that updates the mctrl flags with gpios states.It doesn't seems different from 8250.
But serial8250_get_mctrl() in 8250_core.c calls serial8250_modem_status() which calls eg. uart_handle_cts_change() even if enable_ms() wasn't called. This is the difference.
The serial8250_modem_status() is also called in the interrupt and, what I don't understand, in serial8250_console_write().
Quoted 8 lines
Quoted 3 lines
Do you happen to know if tty layer
modifies mctrl betweenmxs_auart_get_mctrl(),mxs_auart_set_mctrl()andmxs_auart_get_mctrl()again?I don't quite understand what you mean.
The only way for the kernel to get line status (DCD, CTS,DSR,RI) is viaget_mctrl.
And the only way for the kernel to set line status (RTS,DTR,out1,out2,loop) is viaset_mctrl.
Yes, but:
* mxs_auart_set_mctrl() in the mxs-auart stores the lastest mctrl in private ctrl field
* the stored value is used to supply initial returned value by mxs_auart_get_mctrl()
* uart_update_mctrl() in serial_core.c modifies only selected bits in port->mctrl field - OK, input bits stay untouched
* uart_port_startup() in serial_code.c sets RTS and DTR and zeroes others (also input bits)
* uart_set_termios() in serial_core.c modifies the bits too
* uart_suspend_port() in serial_core.c sets all mctrl bits to 0
It looks that mxs_auart_set_mctrl() doesn't have to store mctrl at all because uart_tiocmget() in serial_core.c restores the output bits from port->mctrl field. So the code is duplicated.
Do you agree?P.S. It was even implemented in serial_core.c in 2.6.12.
best regards
Janusz
Quoted 2 lines
best regards,
Richard.
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/4 serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
Quoted 5 lines · Janusz U?ycki
But
serial8250_get_mctrl()in8250_core.ccallsserial8250_modem_status()which calls eg.uart_handle_cts_change()even ifenable_ms()wasn't called. This is the difference.
Theserial8250_modem_status()is also called in the interrupt and, what I don't understand, inserial8250_console_write().
Reading the MSR register clears the interrupts. So, whenever MSR is read, you have to deal with any state changes which _would_ have been passed to the interrupt function.
Plus, it's not quite as you make out above.
If enable_ms() is not called, then UART_IER_MSI will not be set in up->ier. Hence, uart_handle_cts_change() will not be called.
The reason for the call in the console function is to account for the state changes during console write with CTS flow control - this again needs the MSR register to be read, and we have to account for MSR state changes after the console write has completed.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
PATCH 1/4 serial: mxs-auart: use mctrl_gpio helpers for handling modem signals (v2.2c)
W dniu 2014-09-26 15:11, Russell King - ARM Linux pisze:
Quoted 6 lines · Janusz Użycki
Quoted 5 lines
But
serial8250_get_mctrl()in8250_core.ccallsserial8250_modem_status()which calls eg.uart_handle_cts_change()even ifenable_ms()wasn't called. This is the difference.
Theserial8250_modem_status()is also called in the interrupt and, what I don't understand, inserial8250_console_write().
Quoted 8 lines
Reading the MSR register clears the interrupts. So, whenever MSR is read, you have to deal with any state changes which _would_ have been passed to the interrupt function.
Plus, it's not quite as you make out above.
If
enable_ms()is not called, thenUART_IER_MSIwill not be set inup->ier. Hence,uart_handle_cts_change()will not be called.
Oh, now I understand the condition "up->ier & UART_IER_MSI"
in serial8250_modem_status().
So in case of gpio modem lines interrupt is the only right place like in atmel_serial.c.
Quoted 4 lines
The reason for the call in the console function is to account for the state changes during console write with CTS flow control - this again needs the MSR register to be read, and we have to account for MSR state changes after the console write has completed.
It means that gpio modem lines does not support flow control for console on the moment, right Richard?
best regards
Janusz
--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/4 serial: mxs-auart: add interrupts for modem control lines
In reply to Janusz UzyckiHandle CTS/DSR/RI/DCD GPIO interrupts in mxs-auart.
--- drivers/tty/serial/mxs-auart.c | 146 ++++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 3 deletions(-)
drivers/tty/serial/mxs-auart.c +143 -3
@@ -38,7 +38,10 @@#include <asm/cacheflush.h> +#include <linux/gpio.h> +#include <linux/gpio/consumer.h> #include <linux/err.h> +#include <linux/irq.h> #include "serial_mctrl_gpio.h" #define MXS_AUART_MAJOR 242
@@ -161,6 +164,8 @@ struct mxs_auart_port {void *rx_dma_buf;struct mctrl_gpios *gpios; +int gpio_irq[UART_GPIO_MAX ]; +bool ms_irq_enabled; };static struct platform_device_id mxs_auart_devtype[] = {
@@ -478,6 +483,64 @@ static u32 mxs_auart_get_mctrl(struct uart_port *u) mctrl_gpio_get(s->gpios, &mctrl)); } +/* +* Enable modem status interrupts +*/ +static void mxs_auart_enable_ms (struct uart_port *port) +{ +struct mxs_auart_port *s =to_auart_port (port); + +/* +* Interrupt should not be enabled twice +*/ +if (s->ms_irq_enabled) +return ; + + s->ms_irq_enabled = true; + +if (s->gpio_irq[UART_GPIO_CTS ] >=0 ) +enable_irq (s->gpio_irq[UART_GPIO_CTS ]); +/* otherwise: shouldn't be AUART_INTR_CTSMIEN enabled here? (FIXME) */ + +if (s->gpio_irq[UART_GPIO_DSR ] >=0 ) +enable_irq (s->gpio_irq[UART_GPIO_DSR ]); + +if (s->gpio_irq[UART_GPIO_RI ] >=0 ) +enable_irq (s->gpio_irq[UART_GPIO_RI ]); + +if (s->gpio_irq[UART_GPIO_DCD ] >=0 ) +enable_irq (s->gpio_irq[UART_GPIO_DCD ]); +} + +/* +* Disable modem status interrupts +*/ +static void mxs_auart_disable_ms (struct uart_port *port) +{ +struct mxs_auart_port *s =to_auart_port (port); + +/* +* Interrupt should not be disabled twice +*/ +if (!s->ms_irq_enabled) +return ; + + s->ms_irq_enabled = false; + +if (s->gpio_irq[UART_GPIO_CTS ] >=0 ) +disable_irq (s->gpio_irq[UART_GPIO_CTS ]); +/* otherwise: shouldn't be AUART_INTR_CTSMIEN disabled here? (FIXME) */ + +if (s->gpio_irq[UART_GPIO_DSR ] >=0 ) +disable_irq (s->gpio_irq[UART_GPIO_DSR ]); + +if (s->gpio_irq[UART_GPIO_RI ] >=0 ) +disable_irq (s->gpio_irq[UART_GPIO_RI ]); + +if (s->gpio_irq[UART_GPIO_DCD ] >=0 ) +disable_irq (s->gpio_irq[UART_GPIO_DCD ]); +} +static int mxs_auart_dma_prep_rx (struct mxs_auart_port *s);static void dma_rx_callback (void *arg) {
@@ -726,6 +789,12 @@ static void mxs_auart_settermios(struct uart_port *u,dev_err (s->dev,"We can not start up the DMA.\n" ); } } + +/* CTS flow-control and modem-status interrupts */ +if (UART_ENABLE_MS (u, termios->c_cflag)) +mxs_auart_enable_ms (u); +else +mxs_auart_disable_ms (u); }static irqreturn_t mxs_auart_irq_handle (int irq,void *context)
@@ -743,8 +812,15 @@ static irqreturn_t mxs_auart_irq_handle(int irq, void *context) | AUART_INTR_CTSMIS), s->port.membase + AUART_INTR_CLR); -mxs_auart_modem_status (s, -mctrl_gpio_get (s->gpios, &s->ctrl)); +/* +* Dealing with GPIO interrupt +*/ +if (irq == s->gpio_irq[UART_GPIO_CTS ] || + irq == s->gpio_irq[UART_GPIO_DCD ] || + irq == s->gpio_irq[UART_GPIO_DSR ] || + irq == s->gpio_irq[UART_GPIO_RI ]) +mxs_auart_modem_status (s, +mctrl_gpio_get (s->gpios, &s->ctrl));if (istat &AUART_INTR_CTSMIS ) { if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,
@@ -813,6 +889,8 @@ static int mxs_auart_startup(struct uart_port *u)/* get initial status of modem lines */ mctrl_gpio_get (s->gpios, &s->ctrl); + + s->ms_irq_enabled = false;return 0 ; }
@@ -820,6 +898,8 @@ static void mxs_auart_shutdown(struct uart_port *u) {struct mxs_auart_port *s =to_auart_port (u); +mxs_auart_disable_ms (u); +if (auart_dma_enabled (s))mxs_auart_dma_exit (s);
@@ -876,6 +956,7 @@ static struct uart_ops mxs_auart_ops = { .start_tx = mxs_auart_start_tx, .stop_tx = mxs_auart_stop_tx, .stop_rx = mxs_auart_stop_rx, + .enable_ms = mxs_auart_enable_ms, .break_ctl = mxs_auart_break_ctl, .set_mctrl = mxs_auart_set_mctrl, .get_mctrl = mxs_auart_get_mctrl,
@@ -1078,12 +1159,61 @@ static int serial_mxs_probe_dt(struct mxs_auart_port *s,static int mxs_auart_init_gpios (struct mxs_auart_port *s,struct device *dev) { +enum mctrl_gpio_idx i; +struct gpio_desc *gpiod; + s->gpios =mctrl_gpio_init (dev,0 );if (IS_ERR_OR_NULL (s->gpios))return -1 ; + +for (i =0 ; i <UART_GPIO_MAX ; i++) { + gpiod =mctrl_gpio_to_gpiod (s->gpios, i); +if (gpiod && (gpiod_get_direction (gpiod) ==GPIOF_DIR_IN )) + s->gpio_irq[i] =gpiod_to_irq (gpiod); +else + s->gpio_irq[i] = -EINVAL ; + } +return 0 ; } +static void mxs_auart_free_gpio_irq (struct mxs_auart_port *s) +{ +enum mctrl_gpio_idx i; + +for (i =0 ; i <UART_GPIO_MAX ; i++) +if (s->gpio_irq[i] >=0 ) +free_irq (s->gpio_irq[i], s); +} + +static int mxs_auart_request_gpio_irq (struct mxs_auart_port *s) +{ +int *irq = s->gpio_irq; +enum mctrl_gpio_idx i; +int err =0 ; + +for (i =0 ; (i <UART_GPIO_MAX ) && !err; i++) { +if (irq[i] <0 ) +continue ; + +irq_set_status_flags (irq[i],IRQ_NOAUTOEN ); + err =request_irq (irq[i], mxs_auart_irq_handle, +IRQ_TYPE_EDGE_BOTH ,dev_name (s->dev), s); +if (err) +dev_err (s->dev,"%s - Can't get %d irq\n" , + __func__, irq[i]); + } + +/* +* If something went wrong, rollback. +*/ +while (err && (--i >=0 )) +if (irq[i] >=0 ) +free_irq (irq[i], s); + +return err; +} +static int mxs_auart_probe (struct platform_device *pdev) { const struct of_device_id *of_id =
@@ -1146,13 +1276,20 @@ static int mxs_auart_probe(struct platform_device *pdev)dev_err (&pdev->dev,"%s" ,"Failed to initialize GPIOs. The serial port may not work as expected" ); +/* +* Get the GPIO lines IRQ +*/ + ret =mxs_auart_request_gpio_irq (s); +if (ret) + goto out_free_irq; + auart_port[s->port.line] = s;mxs_auart_reset (&s->port); ret =uart_add_one_port (&auart_driver, &s->port);if (ret) - goto out_free_irq; + goto out_free_gpio_irq; version =readl (s->port.membase +AUART_VERSION ); dev_info(&pdev->dev, "Found APPUART %d.%d.%d\n",
@@ -1161,6 +1298,8 @@ static int mxs_auart_probe(struct platform_device *pdev)return 0 ; +out_free_gpio_irq: +mxs_auart_free_gpio_irq (s); out_free_irq:mctrl_gpio_free (&pdev->dev, s->gpios);/*useless?*/ auart_port[pdev->id] =NULL ;
@@ -1181,6 +1320,7 @@ static int mxs_auart_remove(struct platform_device *pdev) auart_port[pdev->id] =NULL ; +mxs_auart_free_gpio_irq (s);mctrl_gpio_free (&pdev->dev, s->gpios);/*useless?*/ clk_put (s->clk);
Signature · 1 line
1.7.11.3
PATCH 3/4 serial: mxs-auart: enable PPS support
In reply to Janusz UzyckiEnables PPS support in mxs-auart serial driver to make PPS API working.
--- drivers/tty/serial/mxs-auart.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/tty/serial/mxs-auart.c +10 -0
@@ -797,6 +797,15 @@ static void mxs_auart_settermios(struct uart_port *u,mxs_auart_disable_ms (u); } +static void mxs_auart_set_ldisc (struct uart_port *port,int new) +{ +if (new ==N_PPS ) { + port->flags |=UPF_HARDPPS_CD ; +mxs_auart_enable_ms (port); + }else + port->flags &= ~UPF_HARDPPS_CD ; +} +static irqreturn_t mxs_auart_irq_handle (int irq,void *context) {u32 istat;
@@ -963,6 +972,7 @@ static struct uart_ops mxs_auart_ops = { .startup = mxs_auart_startup, .shutdown = mxs_auart_shutdown, .set_termios = mxs_auart_settermios, + .set_ldisc = mxs_auart_set_ldisc, .type = mxs_auart_type, .release_port = mxs_auart_release_port, .request_port = mxs_auart_request_port,
Signature · 1 line
1.7.11.3
PATCH 4/4 serial: mxs-auart: add sysrq support
In reply to Janusz UzyckiWhen using mxs-auart based console, sometime we need the sysrq function to help debugging kernel. The sysrq code is basically there, this patch just simply enable it.
--- drivers/tty/serial/mxs-auart.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/mxs-auart.c +6 -0
@@ -14,6 +14,12 @@* http://www.gnu.org/copyleft/gpl.html */ +#if defined(CONFIG_SERIAL_MXS_AUART_CONSOLE ) && defined(CONFIG_MAGIC_SYSRQ ) +#include <linux/sysrq.h> +/* define before linux/serial_core.h */ +#define SUPPORT_SYSRQ +#endif +#include <linux/kernel.h> #include <linux/errno.h> #include <linux/init.h>
Signature · 1 line
1.7.11.3