]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/serial/amba-pl011.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[mv-sheeva.git] / drivers / serial / amba-pl011.c
index d84476ee65923d85a4ce5043b162565324c6db79..d503625730df56dc4334868acba23a33d486e802 100644 (file)
@@ -31,7 +31,6 @@
  * required, these have to be supplied via some other means (eg, GPIO)
  * and hooked into this driver.
  */
-#include <linux/config.h>
 
 #if defined(CONFIG_SERIAL_AMBA_PL011_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
 #define SUPPORT_SYSRQ
 #include <linux/tty_flip.h>
 #include <linux/serial_core.h>
 #include <linux/serial.h>
+#include <linux/amba/bus.h>
+#include <linux/amba/serial.h>
+#include <linux/clk.h>
 
 #include <asm/io.h>
 #include <asm/sizes.h>
-#include <asm/hardware/amba.h>
-#include <asm/hardware/clock.h>
-#include <asm/hardware/amba_serial.h>
 
 #define UART_NR                        14
 
@@ -108,27 +107,13 @@ static void pl011_enable_ms(struct uart_port *port)
        writew(uap->im, uap->port.membase + UART011_IMSC);
 }
 
-static void
-#ifdef SUPPORT_SYSRQ
-pl011_rx_chars(struct uart_amba_port *uap, struct pt_regs *regs)
-#else
-pl011_rx_chars(struct uart_amba_port *uap)
-#endif
+static void pl011_rx_chars(struct uart_amba_port *uap)
 {
        struct tty_struct *tty = uap->port.info->tty;
        unsigned int status, ch, flag, max_count = 256;
 
        status = readw(uap->port.membase + UART01x_FR);
        while ((status & UART01x_FR_RXFE) == 0 && max_count--) {
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                       if (tty->low_latency)
-                               tty_flip_buffer_push(tty);
-                       /*
-                        * If this failed then we will throw away the
-                        * bytes but must do so to clear interrupts
-                        */
-               }
-
                ch = readw(uap->port.membase + UART01x_DR) | UART_DUMMY_DR_RX;
                flag = TTY_NORMAL;
                uap->port.icount.rx++;
@@ -160,7 +145,7 @@ pl011_rx_chars(struct uart_amba_port *uap)
                                flag = TTY_FRAME;
                }
 
-               if (uart_handle_sysrq_char(&uap->port, ch & 255, regs))
+               if (uart_handle_sysrq_char(&uap->port, ch & 255))
                        goto ignore_char;
 
                uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
@@ -228,7 +213,7 @@ static void pl011_modem_status(struct uart_amba_port *uap)
        wake_up_interruptible(&uap->port.info->delta_msr_wait);
 }
 
-static irqreturn_t pl011_int(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t pl011_int(int irq, void *dev_id)
 {
        struct uart_amba_port *uap = dev_id;
        unsigned int status, pass_counter = AMBA_ISR_PASS_LIMIT;
@@ -244,11 +229,7 @@ static irqreturn_t pl011_int(int irq, void *dev_id, struct pt_regs *regs)
                               uap->port.membase + UART011_ICR);
 
                        if (status & (UART011_RTIS|UART011_RXIS))
-#ifdef SUPPORT_SYSRQ
-                               pl011_rx_chars(uap, regs);
-#else
                                pl011_rx_chars(uap);
-#endif
                        if (status & (UART011_DSRMIS|UART011_DCDMIS|
                                      UART011_CTSMIS|UART011_RIMIS))
                                pl011_modem_status(uap);
@@ -596,14 +577,12 @@ static struct uart_amba_port *amba_ports[UART_NR];
 
 #ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
 
-static inline void
-pl011_console_write_char(struct uart_amba_port *uap, char ch)
+static void pl011_console_putchar(struct uart_port *port, int ch)
 {
-       unsigned int status;
+       struct uart_amba_port *uap = (struct uart_amba_port *)port;
 
-       do {
-               status = readw(uap->port.membase + UART01x_FR);
-       } while (status & UART01x_FR_TXFF);
+       while (readw(uap->port.membase + UART01x_FR) & UART01x_FR_TXFF)
+               barrier();
        writew(ch, uap->port.membase + UART01x_DR);
 }
 
@@ -612,7 +591,6 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
 {
        struct uart_amba_port *uap = amba_ports[co->index];
        unsigned int status, old_cr, new_cr;
-       int i;
 
        clk_enable(uap->clk);
 
@@ -624,14 +602,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
        new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
        writew(new_cr, uap->port.membase + UART011_CR);
 
-       /*
-        *      Now, do each character
-        */
-       for (i = 0; i < count; i++) {
-               pl011_console_write_char(uap, s[i]);
-               if (s[i] == '\n')
-                       pl011_console_write_char(uap, '\r');
-       }
+       uart_console_write(&uap->port, s, count, pl011_console_putchar);
 
        /*
         *      Finally, wait for transmitter to become empty
@@ -761,10 +732,6 @@ static int pl011_probe(struct amba_device *dev, void *id)
                goto unmap;
        }
 
-       ret = clk_use(uap->clk);
-       if (ret)
-               goto putclk;
-
        uap->port.dev = &dev->dev;
        uap->port.mapbase = dev->res.start;
        uap->port.membase = base;
@@ -782,8 +749,6 @@ static int pl011_probe(struct amba_device *dev, void *id)
        if (ret) {
                amba_set_drvdata(dev, NULL);
                amba_ports[i] = NULL;
-               clk_unuse(uap->clk);
- putclk:
                clk_put(uap->clk);
  unmap:
                iounmap(base);
@@ -808,7 +773,6 @@ static int pl011_remove(struct amba_device *dev)
                        amba_ports[i] = NULL;
 
        iounmap(uap->port.membase);
-       clk_unuse(uap->clk);
        clk_put(uap->clk);
        kfree(uap);
        return 0;