diff options
Diffstat (limited to 'drivers/tty/serial/altera_uart.c')
-rw-r--r-- | drivers/tty/serial/altera_uart.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/drivers/tty/serial/altera_uart.c b/drivers/tty/serial/altera_uart.c index 1d04c5037f25..e7903751e058 100644 --- a/drivers/tty/serial/altera_uart.c +++ b/drivers/tty/serial/altera_uart.c | |||
@@ -377,6 +377,26 @@ static int altera_uart_verify_port(struct uart_port *port, | |||
377 | return 0; | 377 | return 0; |
378 | } | 378 | } |
379 | 379 | ||
380 | #ifdef CONFIG_CONSOLE_POLL | ||
381 | static int altera_uart_poll_get_char(struct uart_port *port) | ||
382 | { | ||
383 | while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & | ||
384 | ALTERA_UART_STATUS_RRDY_MSK)) | ||
385 | cpu_relax(); | ||
386 | |||
387 | return altera_uart_readl(port, ALTERA_UART_RXDATA_REG); | ||
388 | } | ||
389 | |||
390 | static void altera_uart_poll_put_char(struct uart_port *port, unsigned char c) | ||
391 | { | ||
392 | while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & | ||
393 | ALTERA_UART_STATUS_TRDY_MSK)) | ||
394 | cpu_relax(); | ||
395 | |||
396 | altera_uart_writel(port, c, ALTERA_UART_TXDATA_REG); | ||
397 | } | ||
398 | #endif | ||
399 | |||
380 | /* | 400 | /* |
381 | * Define the basic serial functions we support. | 401 | * Define the basic serial functions we support. |
382 | */ | 402 | */ |
@@ -397,35 +417,16 @@ static struct uart_ops altera_uart_ops = { | |||
397 | .release_port = altera_uart_release_port, | 417 | .release_port = altera_uart_release_port, |
398 | .config_port = altera_uart_config_port, | 418 | .config_port = altera_uart_config_port, |
399 | .verify_port = altera_uart_verify_port, | 419 | .verify_port = altera_uart_verify_port, |
420 | #ifdef CONFIG_CONSOLE_POLL | ||
421 | .poll_get_char = altera_uart_poll_get_char, | ||
422 | .poll_put_char = altera_uart_poll_put_char, | ||
423 | #endif | ||
400 | }; | 424 | }; |
401 | 425 | ||
402 | static struct altera_uart altera_uart_ports[CONFIG_SERIAL_ALTERA_UART_MAXPORTS]; | 426 | static struct altera_uart altera_uart_ports[CONFIG_SERIAL_ALTERA_UART_MAXPORTS]; |
403 | 427 | ||
404 | #if defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) | 428 | #if defined(CONFIG_SERIAL_ALTERA_UART_CONSOLE) |
405 | 429 | ||
406 | int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp) | ||
407 | { | ||
408 | struct uart_port *port; | ||
409 | int i; | ||
410 | |||
411 | for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS && platp[i].mapbase; i++) { | ||
412 | port = &altera_uart_ports[i].port; | ||
413 | |||
414 | port->line = i; | ||
415 | port->type = PORT_ALTERA_UART; | ||
416 | port->mapbase = platp[i].mapbase; | ||
417 | port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); | ||
418 | port->iotype = SERIAL_IO_MEM; | ||
419 | port->irq = platp[i].irq; | ||
420 | port->uartclk = platp[i].uartclk; | ||
421 | port->flags = UPF_BOOT_AUTOCONF; | ||
422 | port->ops = &altera_uart_ops; | ||
423 | port->private_data = platp; | ||
424 | } | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | static void altera_uart_console_putc(struct uart_port *port, const char c) | 430 | static void altera_uart_console_putc(struct uart_port *port, const char c) |
430 | { | 431 | { |
431 | while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & | 432 | while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & |