aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial/altera_uart.c
diff options
context:
space:
mode:
authorAnton Vorontsov <cbouatmailru@gmail.com>2010-10-01 09:21:33 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-22 13:20:07 -0400
commit2f8b9c15cd88ce22bd80e6eb3988dbaa49f1efd3 (patch)
tree05756c8ef6614576b8e3370dd40586a5959a9069 /drivers/serial/altera_uart.c
parent54381067ed7873e6173d6fe32818a585ad667723 (diff)
altera_uart: Add support for polling mode (IRQ-less)
Some Altera UART implementations doesn't route the IRQ line, so we have to work in polling mode. Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com> Acked-by: Tobias Klauser <tklauser@distanz.ch> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/serial/altera_uart.c')
-rw-r--r--drivers/serial/altera_uart.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/serial/altera_uart.c b/drivers/serial/altera_uart.c
index f8d8a00554da..7dd58da0ddf5 100644
--- a/drivers/serial/altera_uart.c
+++ b/drivers/serial/altera_uart.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/timer.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/module.h> 20#include <linux/module.h>
20#include <linux/console.h> 21#include <linux/console.h>
@@ -76,6 +77,7 @@
76 */ 77 */
77struct altera_uart { 78struct altera_uart {
78 struct uart_port port; 79 struct uart_port port;
80 struct timer_list tmr;
79 unsigned int sigs; /* Local copy of line sigs */ 81 unsigned int sigs; /* Local copy of line sigs */
80 unsigned short imr; /* Local IMR mirror */ 82 unsigned short imr; /* Local IMR mirror */
81}; 83};
@@ -168,6 +170,7 @@ static void altera_uart_set_termios(struct uart_port *port,
168 tty_termios_encode_baud_rate(termios, baud, baud); 170 tty_termios_encode_baud_rate(termios, baud, baud);
169 171
170 spin_lock_irqsave(&port->lock, flags); 172 spin_lock_irqsave(&port->lock, flags);
173 uart_update_timeout(port, termios->c_cflag, baud);
171 writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG); 174 writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG);
172 spin_unlock_irqrestore(&port->lock, flags); 175 spin_unlock_irqrestore(&port->lock, flags);
173} 176}
@@ -268,6 +271,15 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data)
268 return IRQ_RETVAL(isr); 271 return IRQ_RETVAL(isr);
269} 272}
270 273
274static void altera_uart_timer(unsigned long data)
275{
276 struct uart_port *port = (void *)data;
277 struct altera_uart *pp = container_of(port, struct altera_uart, port);
278
279 altera_uart_interrupt(0, port);
280 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port));
281}
282
271static void altera_uart_config_port(struct uart_port *port, int flags) 283static void altera_uart_config_port(struct uart_port *port, int flags)
272{ 284{
273 port->type = PORT_ALTERA_UART; 285 port->type = PORT_ALTERA_UART;
@@ -284,6 +296,12 @@ static int altera_uart_startup(struct uart_port *port)
284 unsigned long flags; 296 unsigned long flags;
285 int ret; 297 int ret;
286 298
299 if (!port->irq) {
300 setup_timer(&pp->tmr, altera_uart_timer, (unsigned long)port);
301 mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port));
302 return 0;
303 }
304
287 ret = request_irq(port->irq, altera_uart_interrupt, IRQF_DISABLED, 305 ret = request_irq(port->irq, altera_uart_interrupt, IRQF_DISABLED,
288 DRV_NAME, port); 306 DRV_NAME, port);
289 if (ret) { 307 if (ret) {
@@ -316,7 +334,10 @@ static void altera_uart_shutdown(struct uart_port *port)
316 334
317 spin_unlock_irqrestore(&port->lock, flags); 335 spin_unlock_irqrestore(&port->lock, flags);
318 336
319 free_irq(port->irq, port); 337 if (port->irq)
338 free_irq(port->irq, port);
339 else
340 del_timer_sync(&pp->tmr);
320} 341}
321 342
322static const char *altera_uart_type(struct uart_port *port) 343static const char *altera_uart_type(struct uart_port *port)