From 8c9915bf310eeb1fe5a9a614cda6ee57d712460b Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:37:29 +0100 Subject: [ARM] 4993/1: : Trivial: Remove unused defines This patch removes the unused defines NR_PORTS and IMX_ISR_PASS_LIMIT in the imx serial driver. Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 56af1f566a4c..06fa54c53fdc 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -166,10 +166,6 @@ #define SERIAL_IMX_MAJOR 204 #define MINOR_START 41 -#define NR_PORTS 2 - -#define IMX_ISR_PASS_LIMIT 256 - /* * This is the size of our serial port register set. */ -- cgit v1.2.3-70-g09d2 From 864eeed051b527c8081e2f85b51ba24823acaf71 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:39:22 +0100 Subject: [ARM] 4994/1: : Move error handling into execution path Move the error handling code for erroneous receive characters into execution path. This makes the code more readable and the compiler should know how to optimize this, right? Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 74 +++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 41 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 06fa54c53fdc..c637ae219126 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -354,66 +354,58 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) struct tty_struct *tty = sport->port.info->tty; unsigned long flags, temp; - rx = readl(sport->port.membase + URXD0); spin_lock_irqsave(&sport->port.lock,flags); - do { + while ((rx = readl(sport->port.membase + URXD0)) & URXD_CHARRDY) { flg = TTY_NORMAL; sport->port.icount.rx++; temp = readl(sport->port.membase + USR2); - if( temp & USR2_BRCD ) { + if (temp & USR2_BRCD) { writel(temp | USR2_BRCD, sport->port.membase + USR2); - if(uart_handle_break(&sport->port)) - goto ignore_char; + if (uart_handle_break(&sport->port)) + continue; } if (uart_handle_sysrq_char (&sport->port, (unsigned char)rx)) - goto ignore_char; + continue; + + if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) { + if (rx & URXD_PRERR) + sport->port.icount.parity++; + else if (rx & URXD_FRMERR) + sport->port.icount.frame++; + if (rx & URXD_OVRRUN) + sport->port.icount.overrun++; + + if (rx & sport->port.ignore_status_mask) { + if (++ignored > 100) + goto out; + continue; + } + + rx &= sport->port.read_status_mask; + + if (rx & URXD_PRERR) + flg = TTY_PARITY; + else if (rx & URXD_FRMERR) + flg = TTY_FRAME; + if (rx & URXD_OVRRUN) + flg = TTY_OVERRUN; - if( rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) - goto handle_error; +#ifdef SUPPORT_SYSRQ + sport->port.sysrq = 0; +#endif + } - error_return: tty_insert_flip_char(tty, rx, flg); - - ignore_char: - rx = readl(sport->port.membase + URXD0); - } while(rx & URXD_CHARRDY); + } out: spin_unlock_irqrestore(&sport->port.lock,flags); tty_flip_buffer_push(tty); return IRQ_HANDLED; - -handle_error: - if (rx & URXD_PRERR) - sport->port.icount.parity++; - else if (rx & URXD_FRMERR) - sport->port.icount.frame++; - if (rx & URXD_OVRRUN) - sport->port.icount.overrun++; - - if (rx & sport->port.ignore_status_mask) { - if (++ignored > 100) - goto out; - goto ignore_char; - } - - rx &= sport->port.read_status_mask; - - if (rx & URXD_PRERR) - flg = TTY_PARITY; - else if (rx & URXD_FRMERR) - flg = TTY_FRAME; - if (rx & URXD_OVRRUN) - flg = TTY_OVERRUN; - -#ifdef SUPPORT_SYSRQ - sport->port.sysrq = 0; -#endif - goto error_return; } /* -- cgit v1.2.3-70-g09d2 From 0d3c3938ff9855d8996db4083efd62e86b8987eb Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:43:14 +0100 Subject: [ARM] 4995/1: : Do not use URXD_CHARRDY for polling Do not use the URXD_CHARRDY bit for polling for new characters. This works on i.MX1, but on MX31 the datasheet states that this bit should not be used for polling. On MX27 it is even worse, here we get a bus error when we access the read FIFO when no character is present. Instead, use USR2_RDR (receive data ready) bit. Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index c637ae219126..f7596641f121 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -356,10 +356,12 @@ static irqreturn_t imx_rxint(int irq, void *dev_id) spin_lock_irqsave(&sport->port.lock,flags); - while ((rx = readl(sport->port.membase + URXD0)) & URXD_CHARRDY) { + while (readl(sport->port.membase + USR2) & USR2_RDR) { flg = TTY_NORMAL; sport->port.icount.rx++; + rx = readl(sport->port.membase + URXD0); + temp = readl(sport->port.membase + USR2); if (temp & USR2_BRCD) { writel(temp | USR2_BRCD, sport->port.membase + USR2); -- cgit v1.2.3-70-g09d2 From 789d52589a0849004ced991549a61dd110dfeb10 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:44:47 +0100 Subject: [ARM] 4996/1: : do not enable tx empty interrupt on startup We are not interested in tranceiver empty interrupts until we actually sent a buffer. Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index f7596641f121..dd1e071834be 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -536,7 +536,7 @@ static int imx_startup(struct uart_port *port) writel(USR1_RTSD, sport->port.membase + USR1); temp = readl(sport->port.membase + UCR1); - temp |= (UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN); + temp |= UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN; writel(temp, sport->port.membase + UCR1); temp = readl(sport->port.membase + UCR2); -- cgit v1.2.3-70-g09d2 From 3d454446e2b83b4e1e2997b2c6e689c85ab61868 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:47:32 +0100 Subject: [ARM] 4998/1: : do not use hardcoded io space size Do not use hardcoded io space size. Instead use the information provided by the resource. Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index dd1e071834be..0ce2b4a45e6d 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -166,11 +166,6 @@ #define SERIAL_IMX_MAJOR 204 #define MINOR_START 41 -/* - * This is the size of our serial port register set. - */ -#define UART_PORT_SIZE 0x100 - /* * This determines how often we check the modem status signals * for any change. They generally aren't connected to an IRQ @@ -721,9 +716,11 @@ static const char *imx_type(struct uart_port *port) */ static void imx_release_port(struct uart_port *port) { - struct imx_port *sport = (struct imx_port *)port; + struct platform_device *pdev = to_platform_device(port->dev); + struct resource *mmres; - release_mem_region(sport->port.mapbase, UART_PORT_SIZE); + mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + release_mem_region(mmres->start, mmres->end - mmres->start + 1); } /* @@ -731,10 +728,18 @@ static void imx_release_port(struct uart_port *port) */ static int imx_request_port(struct uart_port *port) { - struct imx_port *sport = (struct imx_port *)port; + struct platform_device *pdev = to_platform_device(port->dev); + struct resource *mmres; + void *ret; + + mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!mmres) + return -ENODEV; + + ret = request_mem_region(mmres->start, mmres->end - mmres->start + 1, + "imx-uart"); - return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, - "imx-uart") != NULL ? 0 : -EBUSY; + return ret ? 0 : -EBUSY; } /* -- cgit v1.2.3-70-g09d2 From 3a8daaa49fb71d90e45d1e86d7f9f9e298bda05c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 17 Apr 2008 08:48:37 +0100 Subject: [ARM] 4999/1: : fix membase The membase field in struct uart_port should be the the physical address. This patch fixes it. Signed-off-by: Sascha Hauer Signed-off-by: Russell King --- drivers/serial/imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/serial') diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c index 0ce2b4a45e6d..cf29a2d0ba4c 100644 --- a/drivers/serial/imx.c +++ b/drivers/serial/imx.c @@ -810,7 +810,7 @@ static struct imx_port imx_ports[] = { .type = PORT_IMX, .iotype = UPIO_MEM, .membase = (void *)IMX_UART1_BASE, - .mapbase = IMX_UART1_BASE, /* FIXME */ + .mapbase = 0x00206000, .irq = UART1_MINT_RX, .uartclk = 16000000, .fifosize = 32, @@ -826,7 +826,7 @@ static struct imx_port imx_ports[] = { .type = PORT_IMX, .iotype = UPIO_MEM, .membase = (void *)IMX_UART2_BASE, - .mapbase = IMX_UART2_BASE, /* FIXME */ + .mapbase = 0x00207000, .irq = UART2_MINT_RX, .uartclk = 16000000, .fifosize = 32, -- cgit v1.2.3-70-g09d2