From 2276f03b745c297733e41470dde7f32bdd4b52af Mon Sep 17 00:00:00 2001 From: Robert Jarzmik Date: Sat, 6 Sep 2008 23:01:32 +0100 Subject: [ARM] 5244/1: Add hardware CTSRTS flow control to pxa serial driver Adds hardware CTSRTS control for pxa serial devices through termios controls. Signed-off-by: Robert Jarzmik Signed-off-by: Russell King --- drivers/serial/pxa.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/serial') diff --git a/drivers/serial/pxa.c b/drivers/serial/pxa.c index f7a0d37c422..abc00be5543 100644 --- a/drivers/serial/pxa.c +++ b/drivers/serial/pxa.c @@ -534,6 +534,11 @@ serial_pxa_set_termios(struct uart_port *port, struct ktermios *termios, serial_out(up, UART_IER, up->ier); + if (termios->c_cflag & CRTSCTS) + up->mcr |= UART_MCR_AFE; + else + up->mcr &= ~UART_MCR_AFE; + serial_out(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */ serial_out(up, UART_DLL, quot & 0xff); /* LS of divisor */ serial_out(up, UART_DLM, quot >> 8); /* MS of divisor */ -- cgit v1.2.3 From f05596dbc922276ed675c713519220bae8042e32 Mon Sep 17 00:00:00 2001 From: Anti Sullin Date: Mon, 22 Sep 2008 13:57:54 -0700 Subject: atmel_serial: update the powersave handler to match serial core This problem seems to be unnoticed so far: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b3b708fa2780cd2b5d8266a8f0c3a1cab364d4d2 has changed the serial core behavior to not to suspend the port if the device is enabled as a wakeup source. If the AT91 system goes to slow clock mode, the port should be suspended always and the clocks should be switched off. The patch attached updates the atmel_serial driver to match the changes in serial core. Also, the interrupts are disabled when the clock is disabled. If we disable the clock with interrupts enabled, an interrupt may get stuck. If this is the DBGU interrupt, this blocks the OR logic at system controller and thus all other sysc interrupts. Signed-off-by: Anti Sullin Signed-off-by: Haavard Skinnemoen Cc: Michael Trimarchi Cc: Andrew Victor Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/serial/atmel_serial.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index 3a6da80b081..61fb8b6d19a 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c @@ -131,7 +131,8 @@ struct atmel_uart_char { struct atmel_uart_port { struct uart_port uart; /* uart */ struct clk *clk; /* uart clock */ - unsigned short suspended; /* is port suspended? */ + int may_wakeup; /* cached value of device_may_wakeup for times we need to disable it */ + u32 backup_imr; /* IMR saved during suspend */ int break_active; /* break being received */ short use_dma_rx; /* enable PDC receiver */ @@ -984,8 +985,15 @@ static void atmel_serial_pm(struct uart_port *port, unsigned int state, * This is called on uart_open() or a resume event. */ clk_enable(atmel_port->clk); + + /* re-enable interrupts if we disabled some on suspend */ + UART_PUT_IER(port, atmel_port->backup_imr); break; case 3: + /* Back up the interrupt mask and disable all interrupts */ + atmel_port->backup_imr = UART_GET_IMR(port); + UART_PUT_IDR(port, -1); + /* * Disable the peripheral clock for this serial port. * This is called on uart_close() or a suspend event. @@ -1475,13 +1483,12 @@ static int atmel_serial_suspend(struct platform_device *pdev, cpu_relax(); } - if (device_may_wakeup(&pdev->dev) - && !atmel_serial_clk_will_stop()) - enable_irq_wake(port->irq); - else { - uart_suspend_port(&atmel_uart, port); - atmel_port->suspended = 1; - } + /* we can not wake up if we're running on slow clock */ + atmel_port->may_wakeup = device_may_wakeup(&pdev->dev); + if (atmel_serial_clk_will_stop()) + device_set_wakeup_enable(&pdev->dev, 0); + + uart_suspend_port(&atmel_uart, port); return 0; } @@ -1491,11 +1498,8 @@ static int atmel_serial_resume(struct platform_device *pdev) struct uart_port *port = platform_get_drvdata(pdev); struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); - if (atmel_port->suspended) { - uart_resume_port(&atmel_uart, port); - atmel_port->suspended = 0; - } else - disable_irq_wake(port->irq); + uart_resume_port(&atmel_uart, port); + device_set_wakeup_enable(&pdev->dev, atmel_port->may_wakeup); return 0; } @@ -1513,6 +1517,8 @@ static int __devinit atmel_serial_probe(struct platform_device *pdev) BUILD_BUG_ON(!is_power_of_2(ATMEL_SERIAL_RINGSIZE)); port = &atmel_ports[pdev->id]; + port->backup_imr = 0; + atmel_init_port(port, pdev); if (!atmel_use_dma_rx(&port->uart)) { -- cgit v1.2.3 From 457cd4f5e3011da47f2f76e2bdc545ffcc1189db Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 16 Sep 2008 18:30:27 +0100 Subject: [ARM] 5250/1: unbalanced enable_irq() for serial_ks8695.c fix The function ks8695uart_set_termios() would cause an unbalanced enable_irq() generated message to be printk()ed. This is because there was no book keeping support to remember if the calls to enable_irq() and disable_irq() were balanced for the modem control irq. Signed-off-by: Dick Hollenbeck Signed-off-by: Russell King --- drivers/serial/serial_ks8695.c | 61 +++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c index b9cbfc87f61..998e89dc5aa 100644 --- a/drivers/serial/serial_ks8695.c +++ b/drivers/serial/serial_ks8695.c @@ -63,8 +63,44 @@ #define UART_DUMMY_LSR_RX 0x100 #define UART_PORT_SIZE (KS8695_USR - KS8695_URRB + 4) -#define tx_enabled(port) ((port)->unused[0]) -#define rx_enabled(port) ((port)->unused[1]) +static inline int tx_enabled(struct uart_port *port) +{ + return port->unused[0] & 1; +} + +static inline int rx_enabled(struct uart_port *port) +{ + return port->unused[0] & 2; +} + +static inline int ms_enabled(struct uart_port *port) +{ + return port->unused[0] & 4; +} + +static inline void ms_enable(struct uart_port *port, int enabled) +{ + if(enabled) + port->unused[0] |= 4; + else + port->unused[0] &= ~4; +} + +static inline void rx_enable(struct uart_port *port, int enabled) +{ + if(enabled) + port->unused[0] |= 2; + else + port->unused[0] &= ~2; +} + +static inline void tx_enable(struct uart_port *port, int enabled) +{ + if(enabled) + port->unused[0] |= 1; + else + port->unused[0] &= ~1; +} #ifdef SUPPORT_SYSRQ @@ -75,7 +111,7 @@ static void ks8695uart_stop_tx(struct uart_port *port) { if (tx_enabled(port)) { disable_irq(KS8695_IRQ_UART_TX); - tx_enabled(port) = 0; + tx_enable(port, 0); } } @@ -83,7 +119,7 @@ static void ks8695uart_start_tx(struct uart_port *port) { if (!tx_enabled(port)) { enable_irq(KS8695_IRQ_UART_TX); - tx_enabled(port) = 1; + tx_enable(port, 1); } } @@ -91,18 +127,24 @@ static void ks8695uart_stop_rx(struct uart_port *port) { if (rx_enabled(port)) { disable_irq(KS8695_IRQ_UART_RX); - rx_enabled(port) = 0; + rx_enable(port, 0); } } static void ks8695uart_enable_ms(struct uart_port *port) { - enable_irq(KS8695_IRQ_UART_MODEM_STATUS); + if (!ms_enabled(port)) { + enable_irq(KS8695_IRQ_UART_MODEM_STATUS); + ms_enable(port,1); + } } static void ks8695uart_disable_ms(struct uart_port *port) { - disable_irq(KS8695_IRQ_UART_MODEM_STATUS); + if (ms_enabled(port)) { + disable_irq(KS8695_IRQ_UART_MODEM_STATUS); + ms_enable(port,0); + } } static irqreturn_t ks8695uart_rx_chars(int irq, void *dev_id) @@ -285,8 +327,9 @@ static int ks8695uart_startup(struct uart_port *port) int retval; set_irq_flags(KS8695_IRQ_UART_TX, IRQF_VALID | IRQF_NOAUTOEN); - tx_enabled(port) = 0; - rx_enabled(port) = 1; + tx_enable(port, 0); + rx_enable(port, 1); + ms_enable(port, 1); /* * Allocate the IRQ -- cgit v1.2.3