drivers/video/msm: update to new kernel
[safe/jmp/linux-2.6] / drivers / serial / uartlite.c
index bacf68d..377f271 100644 (file)
 #include <linux/tty.h>
 #include <linux/delay.h>
 #include <linux/interrupt.h>
+#include <linux/init.h>
 #include <asm/io.h>
 #if defined(CONFIG_OF)
+#include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
+
+/* Match table for of_platform binding */
+static struct of_device_id ulite_of_match[] __devinitdata = {
+       { .compatible = "xlnx,opb-uartlite-1.00.b", },
+       { .compatible = "xlnx,xps-uartlite-1.00.a", },
+       {}
+};
+MODULE_DEVICE_TABLE(of, ulite_of_match);
+
 #endif
 
 #define ULITE_NAME             "ttyUL"
@@ -64,7 +75,7 @@ static struct uart_port ulite_ports[ULITE_NR_UARTS];
 
 static int ulite_receive(struct uart_port *port, int stat)
 {
-       struct tty_struct *tty = port->info->tty;
+       struct tty_struct *tty = port->state->port.tty;
        unsigned char ch = 0;
        char flag = TTY_NORMAL;
 
@@ -114,7 +125,7 @@ static int ulite_receive(struct uart_port *port, int stat)
 
 static int ulite_transmit(struct uart_port *port, int stat)
 {
-       struct circ_buf *xmit  = &port->info->xmit;
+       struct circ_buf *xmit  = &port->state->xmit;
 
        if (stat & ULITE_STATUS_TXFULL)
                return 0;
@@ -143,17 +154,22 @@ static int ulite_transmit(struct uart_port *port, int stat)
 static irqreturn_t ulite_isr(int irq, void *dev_id)
 {
        struct uart_port *port = dev_id;
-       int busy;
+       int busy, n = 0;
 
        do {
                int stat = readb(port->membase + ULITE_STATUS);
                busy  = ulite_receive(port, stat);
                busy |= ulite_transmit(port, stat);
+               n++;
        } while (busy);
 
-       tty_flip_buffer_push(port->info->tty);
-
-       return IRQ_HANDLED;
+       /* work done? */
+       if (n > 1) {
+               tty_flip_buffer_push(port->state->port.tty);
+               return IRQ_HANDLED;
+       } else {
+               return IRQ_NONE;
+       }
 }
 
 static unsigned int ulite_tx_empty(struct uart_port *port)
@@ -210,7 +226,7 @@ static int ulite_startup(struct uart_port *port)
        int ret;
 
        ret = request_irq(port->irq, ulite_isr,
-                         IRQF_DISABLED | IRQF_SAMPLE_RANDOM, "uartlite", port);
+                         IRQF_SHARED | IRQF_SAMPLE_RANDOM, "uartlite", port);
        if (ret)
                return ret;
 
@@ -275,6 +291,9 @@ static void ulite_release_port(struct uart_port *port)
 
 static int ulite_request_port(struct uart_port *port)
 {
+       pr_debug("ulite console: port=%p; port->mapbase=%llx\n",
+                port, (unsigned long long) port->mapbase);
+
        if (!request_mem_region(port->mapbase, ULITE_REGION, "uartlite")) {
                dev_err(port->dev, "Memory region busy\n");
                return -EBUSY;
@@ -375,32 +394,6 @@ static void ulite_console_write(struct console *co, const char *s,
                spin_unlock_irqrestore(&port->lock, flags);
 }
 
-#if defined(CONFIG_OF)
-static inline void __init ulite_console_of_find_device(int id)
-{
-       struct device_node *np;
-       struct resource res;
-       const unsigned int *of_id;
-       int rc;
-
-       for_each_compatible_node(np, NULL, "xilinx,uartlite") {
-               of_id = of_get_property(np, "port-number", NULL);
-               if ((!of_id) || (*of_id != id))
-                       continue;
-
-               rc = of_address_to_resource(np, 0, &res);
-               if (rc)
-                       continue;
-
-               ulite_ports[id].mapbase = res.start;
-               of_node_put(np);
-               return;
-       }
-}
-#else /* CONFIG_OF */
-static inline void __init ulite_console_of_find_device(int id) { /* do nothing */ }
-#endif /* CONFIG_OF */
-
 static int __init ulite_console_setup(struct console *co, char *options)
 {
        struct uart_port *port;
@@ -414,11 +407,7 @@ static int __init ulite_console_setup(struct console *co, char *options)
 
        port = &ulite_ports[co->index];
 
-       /* Check if it is an OF device */
-       if (!port->mapbase)
-               ulite_console_of_find_device(co->index);
-
-       /* Do we have a device now? */
+       /* Has the device been initialized yet? */
        if (!port->mapbase) {
                pr_debug("console on ttyUL%i not present\n", co->index);
                return -ENODEV;
@@ -577,6 +566,9 @@ static int __devexit ulite_remove(struct platform_device *pdev)
        return ulite_release(&pdev->dev);
 }
 
+/* work with hotplug and coldplug */
+MODULE_ALIAS("platform:uartlite");
+
 static struct platform_driver ulite_platform_driver = {
        .probe  = ulite_probe,
        .remove = __devexit_p(ulite_remove),
@@ -597,7 +589,7 @@ ulite_of_probe(struct of_device *op, const struct of_device_id *match)
        const unsigned int *id;
        int irq, rc;
 
-       dev_dbg(&op->dev, "%s(%p, %p)\n", __FUNCTION__, op, match);
+       dev_dbg(&op->dev, "%s(%p, %p)\n", __func__, op, match);
 
        rc = of_address_to_resource(op->node, 0, &res);
        if (rc) {
@@ -617,13 +609,6 @@ static int __devexit ulite_of_remove(struct of_device *op)
        return ulite_release(&op->dev);
 }
 
-/* Match table for of_platform binding */
-static struct of_device_id __devinit ulite_of_match[] = {
-       { .type = "serial", .compatible = "xilinx,uartlite", },
-       {},
-};
-MODULE_DEVICE_TABLE(of, ulite_of_match);
-
 static struct of_platform_driver ulite_of_driver = {
        .owner = THIS_MODULE,
        .name = "uartlite",