]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/serial/samsung.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6.29
[mv-sheeva.git] / drivers / serial / samsung.c
index 44fc38afa22847c2a3de82af56fbb3e90468eba7..41ac94872b8d952a6b3250cacf3f12432e5ed107 100644 (file)
 #define S3C24XX_SERIAL_MAJOR   204
 #define S3C24XX_SERIAL_MINOR   64
 
-/* we can support 3 uarts, but not always use them */
-
-#if defined(CONFIG_CPU_S3C2400) || defined(CONFIG_CPU_S3C24A0)
-#define NR_PORTS (2)
-#else
-#define NR_PORTS (3)
-#endif
-
-/* port irq numbers */
-
-#define TX_IRQ(port) ((port)->irq + 1)
-#define RX_IRQ(port) ((port)->irq)
-
 /* macros to change one thing to another */
 
 #define tx_enabled(port) ((port)->unused[0])
@@ -137,8 +124,10 @@ static void s3c24xx_serial_rx_disable(struct uart_port *port)
 
 static void s3c24xx_serial_stop_tx(struct uart_port *port)
 {
+       struct s3c24xx_uart_port *ourport = to_ourport(port);
+
        if (tx_enabled(port)) {
-               disable_irq(TX_IRQ(port));
+               disable_irq(ourport->tx_irq);
                tx_enabled(port) = 0;
                if (port->flags & UPF_CONS_FLOW)
                        s3c24xx_serial_rx_enable(port);
@@ -147,11 +136,13 @@ static void s3c24xx_serial_stop_tx(struct uart_port *port)
 
 static void s3c24xx_serial_start_tx(struct uart_port *port)
 {
+       struct s3c24xx_uart_port *ourport = to_ourport(port);
+
        if (!tx_enabled(port)) {
                if (port->flags & UPF_CONS_FLOW)
                        s3c24xx_serial_rx_disable(port);
 
-               enable_irq(TX_IRQ(port));
+               enable_irq(ourport->tx_irq);
                tx_enabled(port) = 1;
        }
 }
@@ -159,9 +150,11 @@ static void s3c24xx_serial_start_tx(struct uart_port *port)
 
 static void s3c24xx_serial_stop_rx(struct uart_port *port)
 {
+       struct s3c24xx_uart_port *ourport = to_ourport(port);
+
        if (rx_enabled(port)) {
                dbg("s3c24xx_serial_stop_rx: port=%p\n", port);
-               disable_irq(RX_IRQ(port));
+               disable_irq(ourport->rx_irq);
                rx_enabled(port) = 0;
        }
 }
@@ -385,13 +378,13 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
        struct s3c24xx_uart_port *ourport = to_ourport(port);
 
        if (ourport->tx_claimed) {
-               free_irq(TX_IRQ(port), ourport);
+               free_irq(ourport->tx_irq, ourport);
                tx_enabled(port) = 0;
                ourport->tx_claimed = 0;
        }
 
        if (ourport->rx_claimed) {
-               free_irq(RX_IRQ(port), ourport);
+               free_irq(ourport->rx_irq, ourport);
                ourport->rx_claimed = 0;
                rx_enabled(port) = 0;
        }
@@ -408,12 +401,11 @@ static int s3c24xx_serial_startup(struct uart_port *port)
 
        rx_enabled(port) = 1;
 
-       ret = request_irq(RX_IRQ(port),
-                         s3c24xx_serial_rx_chars, 0,
+       ret = request_irq(ourport->rx_irq, s3c24xx_serial_rx_chars, 0,
                          s3c24xx_serial_portname(port), ourport);
 
        if (ret != 0) {
-               printk(KERN_ERR "cannot get irq %d\n", RX_IRQ(port));
+               printk(KERN_ERR "cannot get irq %d\n", ourport->rx_irq);
                return ret;
        }
 
@@ -423,12 +415,11 @@ static int s3c24xx_serial_startup(struct uart_port *port)
 
        tx_enabled(port) = 1;
 
-       ret = request_irq(TX_IRQ(port),
-                         s3c24xx_serial_tx_chars, 0,
+       ret = request_irq(ourport->tx_irq, s3c24xx_serial_tx_chars, 0,
                          s3c24xx_serial_portname(port), ourport);
 
        if (ret) {
-               printk(KERN_ERR "cannot get irq %d\n", TX_IRQ(port));
+               printk(KERN_ERR "cannot get irq %d\n", ourport->tx_irq);
                goto err;
        }
 
@@ -833,14 +824,14 @@ static struct uart_ops s3c24xx_serial_ops = {
 static struct uart_driver s3c24xx_uart_drv = {
        .owner          = THIS_MODULE,
        .dev_name       = "s3c2410_serial",
-       .nr             = 3,
+       .nr             = CONFIG_SERIAL_SAMSUNG_UARTS,
        .cons           = S3C24XX_SERIAL_CONSOLE,
        .driver_name    = S3C24XX_SERIAL_NAME,
        .major          = S3C24XX_SERIAL_MAJOR,
        .minor          = S3C24XX_SERIAL_MINOR,
 };
 
-static struct s3c24xx_uart_port s3c24xx_serial_ports[NR_PORTS] = {
+static struct s3c24xx_uart_port s3c24xx_serial_ports[CONFIG_SERIAL_SAMSUNG_UARTS] = {
        [0] = {
                .port = {
                        .lock           = __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[0].port.lock),
@@ -865,7 +856,7 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[NR_PORTS] = {
                        .line           = 1,
                }
        },
-#if NR_PORTS > 2
+#if CONFIG_SERIAL_SAMSUNG_UARTS > 2
 
        [2] = {
                .port = {
@@ -878,6 +869,20 @@ static struct s3c24xx_uart_port s3c24xx_serial_ports[NR_PORTS] = {
                        .flags          = UPF_BOOT_AUTOCONF,
                        .line           = 2,
                }
+       },
+#endif
+#if CONFIG_SERIAL_SAMSUNG_UARTS > 3
+       [3] = {
+               .port = {
+                       .lock           = __SPIN_LOCK_UNLOCKED(s3c24xx_serial_ports[3].port.lock),
+                       .iotype         = UPIO_MEM,
+                       .irq            = IRQ_S3CUART_RX3,
+                       .uartclk        = 0,
+                       .fifosize       = 16,
+                       .ops            = &s3c24xx_serial_ops,
+                       .flags          = UPF_BOOT_AUTOCONF,
+                       .line           = 3,
+               }
        }
 #endif
 };
@@ -932,17 +937,13 @@ static int s3c24xx_serial_cpufreq_transition(struct notifier_block *nb,
                struct ktermios *termios;
                struct tty_struct *tty;
 
-               if (uport->info == NULL) {
-                       printk(KERN_WARNING "%s: info NULL\n", __func__);
+               if (uport->info == NULL)
                        goto exit;
-               }
 
                tty = uport->info->port.tty;
 
-               if (tty == NULL) {
-                       printk(KERN_WARNING "%s: tty is NULL\n", __func__);
+               if (tty == NULL)
                        goto exit;
-               }
 
                termios = tty->termios;
 
@@ -1007,8 +1008,11 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
        if (port->mapbase != 0)
                return 0;
 
-       if (cfg->hwport > 3)
-               return -EINVAL;
+       if (cfg->hwport > CONFIG_SERIAL_SAMSUNG_UARTS) {
+               printk(KERN_ERR "%s: port %d bigger than %d\n", __func__,
+                      cfg->hwport, CONFIG_SERIAL_SAMSUNG_UARTS);
+               return -ERANGE;
+       }
 
        /* setup info for port */
        port->dev       = &platdev->dev;
@@ -1041,13 +1045,21 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
        ret = platform_get_irq(platdev, 0);
        if (ret < 0)
                port->irq = 0;
-       else
+       else {
                port->irq = ret;
+               ourport->rx_irq = ret;
+               ourport->tx_irq = ret + 1;
+       }
+       
+       ret = platform_get_irq(platdev, 1);
+       if (ret > 0)
+               ourport->tx_irq = ret;
 
        ourport->clk    = clk_get(&platdev->dev, "uart");
 
-       dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n",
-           port->mapbase, port->membase, port->irq, port->uartclk);
+       dbg("port: map=%08x, mem=%08x, irq=%d (%d,%d), clock=%ld\n",
+           port->mapbase, port->membase, port->irq,
+           ourport->rx_irq, ourport->tx_irq, port->uartclk);
 
        /* reset the fifos (and setup the uart) */
        s3c24xx_serial_resetport(port, cfg);
@@ -1317,7 +1329,7 @@ static int s3c24xx_serial_init_ports(struct s3c24xx_uart_info *info)
 
        platdev_ptr = s3c24xx_uart_devs;
 
-       for (i = 0; i < NR_PORTS; i++, ptr++, platdev_ptr++) {
+       for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++, ptr++, platdev_ptr++) {
                s3c24xx_serial_init_port(ptr, info, *platdev_ptr);
        }
 
@@ -1338,7 +1350,7 @@ s3c24xx_serial_console_setup(struct console *co, char *options)
 
        /* is this a valid port */
 
-       if (co->index == -1 || co->index >= NR_PORTS)
+       if (co->index == -1 || co->index >= CONFIG_SERIAL_SAMSUNG_UARTS)
                co->index = 0;
 
        port = &s3c24xx_serial_ports[co->index].port;