]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/serial/atmel_serial.c
Merge master.kernel.org:/pub/scm/linux/kernel/git/lethal/sh-2.6
[mv-sheeva.git] / drivers / serial / atmel_serial.c
index 2c5b72ccc4beeb9786f1ee78cd1ee16183bc6056..391a1f4167a4f38819997c5a80cb12607e788fa6 100644 (file)
 #include <asm/arch/at91rm9200_pdc.h>
 #include <asm/mach/serial_at91.h>
 #include <asm/arch/board.h>
+#ifdef CONFIG_ARM
 #include <asm/arch/system.h>
 #include <asm/arch/gpio.h>
+#endif
 
 #include "atmel_serial.h"
 
 //#define UART_PUT_TNPR(port,v)        writel(v, (port)->membase + ATMEL_PDC_TNPR)
 //#define UART_PUT_TNCR(port,v)        writel(v, (port)->membase + ATMEL_PDC_TNCR)
 
-static int (*at91_open)(struct uart_port *);
-static void (*at91_close)(struct uart_port *);
+static int (*atmel_open_hook)(struct uart_port *);
+static void (*atmel_close_hook)(struct uart_port *);
 
 /*
  * We wrap our port structure around the generic uart_port.
@@ -135,6 +137,7 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
        unsigned int control = 0;
        unsigned int mode;
 
+#ifdef CONFIG_ARM
        if (arch_identify() == ARCH_ID_AT91RM9200) {
                /*
                 * AT91RM9200 Errata #39: RTS0 is not internally connected to PA21.
@@ -147,6 +150,7 @@ static void atmel_set_mctrl(struct uart_port *port, u_int mctrl)
                                at91_set_gpio_value(AT91_PIN_PA21, 1);
                }
        }
+#endif
 
        if (mctrl & TIOCM_RTS)
                control |= ATMEL_US_RTSEN;
@@ -245,7 +249,7 @@ static void atmel_break_ctl(struct uart_port *port, int break_state)
 /*
  * Characters received (called from interrupt handler)
  */
-static void atmel_rx_chars(struct uart_port *port, struct pt_regs *regs)
+static void atmel_rx_chars(struct uart_port *port)
 {
        struct tty_struct *tty = port->info->tty;
        unsigned int status, ch, flg;
@@ -287,7 +291,7 @@ static void atmel_rx_chars(struct uart_port *port, struct pt_regs *regs)
                                flg = TTY_FRAME;
                }
 
-               if (uart_handle_sysrq_char(port, ch, regs))
+               if (uart_handle_sysrq_char(port, ch))
                        goto ignore_char;
 
                uart_insert_char(port, status, ATMEL_US_OVRE, ch, flg);
@@ -335,7 +339,7 @@ static void atmel_tx_chars(struct uart_port *port)
 /*
  * Interrupt handler
  */
-static irqreturn_t atmel_interrupt(int irq, void *dev_id, struct pt_regs *regs)
+static irqreturn_t atmel_interrupt(int irq, void *dev_id)
 {
        struct uart_port *port = dev_id;
        struct atmel_uart_port *atmel_port = (struct atmel_uart_port *) port;
@@ -346,7 +350,7 @@ static irqreturn_t atmel_interrupt(int irq, void *dev_id, struct pt_regs *regs)
        while (pending) {
                /* Interrupt receive */
                if (pending & ATMEL_US_RXRDY)
-                       atmel_rx_chars(port, regs);
+                       atmel_rx_chars(port);
 
                // TODO: All reads to CSR will clear these interrupts!
                if (pending & ATMEL_US_RIIC) port->icount.rng++;
@@ -399,8 +403,8 @@ static int atmel_startup(struct uart_port *port)
         * If there is a specific "open" function (to register
         * control line interrupts)
         */
-       if (at91_open) {
-               retval = at91_open(port);
+       if (atmel_open_hook) {
+               retval = atmel_open_hook(port);
                if (retval) {
                        free_irq(port->irq, port);
                        return retval;
@@ -440,8 +444,8 @@ static void atmel_shutdown(struct uart_port *port)
         * If there is a specific "close" function (to unregister
         * control line interrupts)
         */
-       if (at91_close)
-               at91_close(port);
+       if (atmel_close_hook)
+               atmel_close_hook(port);
 }
 
 /*
@@ -694,8 +698,9 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, struct
        port->mapbase   = pdev->resource[0].start;
        port->irq       = pdev->resource[1].start;
 
-       if (port->mapbase == AT91_VA_BASE_SYS + AT91_DBGU)              /* Part of system perpherals - already mapped */
-               port->membase = (void __iomem *) port->mapbase;
+       if (data->regs)
+               /* Already mapped by setup code */
+               port->membase = data->regs;
        else {
                port->flags     |= UPF_IOREMAP;
                port->membase   = NULL;
@@ -711,7 +716,7 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, struct
 /*
  * Register board-specific modem-control line handlers.
  */
-void __init at91_register_uart_fns(struct at91_port_fns *fns)
+void __init atmel_register_uart_fns(struct atmel_port_fns *fns)
 {
        if (fns->enable_ms)
                atmel_pops.enable_ms = fns->enable_ms;
@@ -719,8 +724,8 @@ void __init at91_register_uart_fns(struct at91_port_fns *fns)
                atmel_pops.get_mctrl = fns->get_mctrl;
        if (fns->set_mctrl)
                atmel_pops.set_mctrl = fns->set_mctrl;
-       at91_open               = fns->open;
-       at91_close              = fns->close;
+       atmel_open_hook         = fns->open;
+       atmel_close_hook        = fns->close;
        atmel_pops.pm           = fns->pm;
        atmel_pops.set_wake     = fns->set_wake;
 }
@@ -788,8 +793,14 @@ static void __init atmel_console_get_options(struct uart_port *port, int *baud,
        else if (mr == ATMEL_US_PAR_ODD)
                *parity = 'o';
 
+       /*
+        * The serial core only rounds down when matching this to a
+        * supported baud rate. Make sure we don't end up slightly
+        * lower than one of those, as it would make us fall through
+        * to a much lower baud rate than we really want.
+        */
        quot = UART_GET_BRGR(port);
-       *baud = port->uartclk / (16 * (quot));
+       *baud = port->uartclk / (16 * (quot - 1));
 }
 
 static int __init atmel_console_setup(struct console *co, char *options)