aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/serial.c')
-rw-r--r--arch/arm/mach-omap2/serial.c88
1 files changed, 73 insertions, 15 deletions
diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 2e17b57f5b23..39b797bc14d6 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -33,6 +33,7 @@
33#include "pm.h" 33#include "pm.h"
34#include "prm-regbits-34xx.h" 34#include "prm-regbits-34xx.h"
35 35
36#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV 0x52
36#define UART_OMAP_WER 0x17 /* Wake-up enable register */ 37#define UART_OMAP_WER 0x17 /* Wake-up enable register */
37 38
38#define DEFAULT_TIMEOUT (5 * HZ) 39#define DEFAULT_TIMEOUT (5 * HZ)
@@ -572,6 +573,23 @@ static struct omap_uart_state omap_uart[] = {
572#endif 573#endif
573}; 574};
574 575
576/*
577 * Override the default 8250 read handler: mem_serial_in()
578 * Empty RX fifo read causes an abort on omap3630 and omap4
579 * This function makes sure that an empty rx fifo is not read on these silicons
580 * (OMAP1/2/3430 are not affected)
581 */
582static unsigned int serial_in_override(struct uart_port *up, int offset)
583{
584 if (UART_RX == offset) {
585 unsigned int lsr;
586 lsr = serial_read_reg(omap_uart[up->line].p, UART_LSR);
587 if (!(lsr & UART_LSR_DR))
588 return -EPERM;
589 }
590 return serial_read_reg(omap_uart[up->line].p, offset);
591}
592
575void __init omap_serial_early_init(void) 593void __init omap_serial_early_init(void)
576{ 594{
577 int i; 595 int i;
@@ -631,24 +649,64 @@ void __init omap_serial_early_init(void)
631 } 649 }
632} 650}
633 651
634void __init omap_serial_init(void) 652/**
653 * omap_serial_init_port() - initialize single serial port
654 * @port: serial port number (0-3)
655 *
656 * This function initialies serial driver for given @port only.
657 * Platforms can call this function instead of omap_serial_init()
658 * if they don't plan to use all available UARTs as serial ports.
659 *
660 * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
661 * use only one of the two.
662 */
663void __init omap_serial_init_port(int port)
635{ 664{
636 int i; 665 struct omap_uart_state *uart;
666 struct platform_device *pdev;
667 struct device *dev;
637 668
638 for (i = 0; i < ARRAY_SIZE(omap_uart); i++) { 669 BUG_ON(port < 0);
639 struct omap_uart_state *uart = &omap_uart[i]; 670 BUG_ON(port >= ARRAY_SIZE(omap_uart));
640 struct platform_device *pdev = &uart->pdev;
641 struct device *dev = &pdev->dev;
642 671
643 omap_uart_reset(uart); 672 uart = &omap_uart[port];
644 omap_uart_idle_init(uart); 673 pdev = &uart->pdev;
674 dev = &pdev->dev;
645 675
646 if (WARN_ON(platform_device_register(pdev))) 676 omap_uart_reset(uart);
647 continue; 677 omap_uart_idle_init(uart);
648 if ((cpu_is_omap34xx() && uart->padconf) || 678
649 (uart->wk_en && uart->wk_mask)) { 679 if (WARN_ON(platform_device_register(pdev)))
650 device_init_wakeup(dev, true); 680 return;
651 DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout); 681
652 } 682 if ((cpu_is_omap34xx() && uart->padconf) ||
683 (uart->wk_en && uart->wk_mask)) {
684 device_init_wakeup(dev, true);
685 DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
653 } 686 }
687
688 /* omap44xx: Never read empty UART fifo
689 * omap3xxx: Never read empty UART fifo on UARTs
690 * with IP rev >=0x52
691 */
692 if (cpu_is_omap44xx())
693 uart->p->serial_in = serial_in_override;
694 else if ((serial_read_reg(uart->p, UART_OMAP_MVER) & 0xFF)
695 >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
696 uart->p->serial_in = serial_in_override;
697}
698
699/**
700 * omap_serial_init() - intialize all supported serial ports
701 *
702 * Initializes all available UARTs as serial ports. Platforms
703 * can call this function when they want to have default behaviour
704 * for serial ports (e.g initialize them all as serial ports).
705 */
706void __init omap_serial_init(void)
707{
708 int i;
709
710 for (i = 0; i < ARRAY_SIZE(omap_uart); i++)
711 omap_serial_init_port(i);
654} 712}