V4L/DVB: tvp5150: support new vbi ops to set/get VBI format
[safe/jmp/linux-2.6] / drivers / serial / 8250_hp300.c
index b8d51eb..c13438c 100644 (file)
@@ -9,15 +9,17 @@
 #include <linux/init.h>
 #include <linux/string.h>
 #include <linux/kernel.h>
-#include <linux/tty.h>
 #include <linux/serial.h>
-#include <linux/serialP.h>
 #include <linux/serial_core.h>
+#include <linux/serial_8250.h>
 #include <linux/delay.h>
 #include <linux/dio.h>
 #include <linux/console.h>
+#include <linux/slab.h>
 #include <asm/io.h>
 
+#include "8250.h"
+
 #if !defined(CONFIG_HPDCA) && !defined(CONFIG_HPAPCI)
 #warning CONFIG_8250 defined but neither CONFIG_HPDCA nor CONFIG_HPAPCI defined, are you sure?
 #endif
@@ -35,7 +37,7 @@ static struct hp300_port *hp300_ports;
 #ifdef CONFIG_HPDCA
 
 static int __devinit hpdca_init_one(struct dio_dev *d,
-                                const struct dio_device_id *ent);
+                                       const struct dio_device_id *ent);
 static void __devexit hpdca_remove_one(struct dio_dev *d);
 
 static struct dio_device_id hpdca_dio_tbl[] = {
@@ -55,6 +57,8 @@ static struct dio_driver hpdca_driver = {
 
 #endif
 
+static unsigned int num_ports;
+
 extern int hp300_uart_scode;
 
 /* Offset to UART registers from base of DCA */
@@ -82,7 +86,7 @@ extern int hp300_uart_scode;
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
 /*
- * Parse the bootinfo to find descriptions for headless console and 
+ * Parse the bootinfo to find descriptions for headless console and
  * debug serial ports and register them with the 8250 driver.
  * This function should be called before serial_console_init() is called
  * to make sure the serial console will be available for use. IA-64 kernel
@@ -123,13 +127,11 @@ int __init hp300_setup_serial_console(void)
                printk(KERN_WARNING "Serial console is APCI but support is disabled (CONFIG_HPAPCI)!\n");
                return 0;
 #endif
-       }
-       else {
+       } else {
 #ifdef CONFIG_HPDCA
                unsigned long pa = dio_scodetophysaddr(scode);
-               if (!pa) {
+               if (!pa)
                        return 0;
-               }
 
                printk(KERN_INFO "Serial console is HP DCA at select code %d\n", scode);
 
@@ -142,28 +144,25 @@ int __init hp300_setup_serial_console(void)
                /* Enable board-interrupts */
                out_8(pa + DIO_VIRADDRBASE + DCA_IC, DCA_IC_IE);
 
-               if (DIO_ID(pa + DIO_VIRADDRBASE) & 0x80) {
+               if (DIO_ID(pa + DIO_VIRADDRBASE) & 0x80)
                        add_preferred_console("ttyS", port.line, "9600n8");
-               }
 #else
                printk(KERN_WARNING "Serial console is DCA but support is disabled (CONFIG_HPDCA)!\n");
                return 0;
 #endif
        }
 
-       if (early_serial_setup(&port) < 0) {
+       if (early_serial_setup(&port) < 0)
                printk(KERN_WARNING "hp300_setup_serial_console(): early_serial_setup() failed.\n");
-       }
-
        return 0;
 }
 #endif /* CONFIG_SERIAL_8250_CONSOLE */
 
 #ifdef CONFIG_HPDCA
 static int __devinit hpdca_init_one(struct dio_dev *d,
-                                const struct dio_device_id *ent)
+                               const struct dio_device_id *ent)
 {
-       struct serial_struct serial_req;
+       struct uart_port port;
        int line;
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -172,21 +171,22 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
                return 0;
        }
 #endif
-       memset(&serial_req, 0, sizeof(struct serial_struct));
+       memset(&port, 0, sizeof(struct uart_port));
 
        /* Memory mapped I/O */
-       serial_req.io_type = SERIAL_IO_MEM;
-       serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
-       serial_req.irq = d->ipl;
-       serial_req.baud_base = HPDCA_BAUD_BASE;
-       serial_req.iomap_base = (d->resource.start + UART_OFFSET);
-       serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE);
-       serial_req.iomem_reg_shift = 1;
-       line = register_serial(&serial_req);
+       port.iotype = UPIO_MEM;
+       port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
+       port.irq = d->ipl;
+       port.uartclk = HPDCA_BAUD_BASE * 16;
+       port.mapbase = (d->resource.start + UART_OFFSET);
+       port.membase = (char *)(port.mapbase + DIO_VIRADDRBASE);
+       port.regshift = 1;
+       port.dev = &d->dev;
+       line = serial8250_register_port(&port);
 
        if (line < 0) {
                printk(KERN_NOTICE "8250_hp300: register_serial() DCA scode %d"
-                      " irq %d failed\n", d->scode, serial_req.irq);
+                      " irq %d failed\n", d->scode, port.irq);
                return -ENOMEM;
        }
 
@@ -198,18 +198,19 @@ static int __devinit hpdca_init_one(struct dio_dev *d,
        out_8(d->resource.start + DIO_VIRADDRBASE + DCA_ID, 0xff);
        udelay(100);
 
+       num_ports++;
+
        return 0;
 }
 #endif
 
 static int __init hp300_8250_init(void)
 {
-       static int called = 0;
-       int num_ports;
+       static int called;
 #ifdef CONFIG_HPAPCI
        int line;
        unsigned long base;
-       struct serial_struct serial_req;
+       struct uart_port uport;
        struct hp300_port *port;
        int i;
 #endif
@@ -220,11 +221,8 @@ static int __init hp300_8250_init(void)
        if (!MACH_IS_HP300)
                return -ENODEV;
 
-       num_ports = 0;
-
 #ifdef CONFIG_HPDCA
-       if (dio_module_init(&hpdca_driver) == 0)
-               num_ports++;
+       dio_register_driver(&hpdca_driver);
 #endif
 #ifdef CONFIG_HPAPCI
        if (hp300_model < HP_400) {
@@ -237,13 +235,12 @@ static int __init hp300_8250_init(void)
         * Port 1 is either the console or the DCA.
         */
        for (i = 1; i < 4; i++) {
-               /* Port 1 is the console on a 425e, on other machines it's mapped to
-                * DCA.
+               /* Port 1 is the console on a 425e, on other machines it's
+                * mapped to DCA.
                 */
 #ifdef CONFIG_SERIAL_8250_CONSOLE
-               if (i == 1) {
+               if (i == 1)
                        continue;
-               }
 #endif
 
                /* Create new serial device */
@@ -251,25 +248,26 @@ static int __init hp300_8250_init(void)
                if (!port)
                        return -ENOMEM;
 
-               memset(&serial_req, 0, sizeof(struct serial_struct));
+               memset(&uport, 0, sizeof(struct uart_port));
 
                base = (FRODO_BASE + FRODO_APCI_OFFSET(i));
 
                /* Memory mapped I/O */
-               serial_req.io_type = SERIAL_IO_MEM;
-               serial_req.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF;
+               uport.iotype = UPIO_MEM;
+               uport.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ \
+                             | UPF_BOOT_AUTOCONF;
                /* XXX - no interrupt support yet */
-               serial_req.irq = 0;
-               serial_req.baud_base = HPAPCI_BAUD_BASE;
-               serial_req.iomap_base = base;
-               serial_req.iomem_base = (char *)(serial_req.iomap_base + DIO_VIRADDRBASE);
-               serial_req.iomem_reg_shift = 2;
+               uport.irq = 0;
+               uport.uartclk = HPAPCI_BAUD_BASE * 16;
+               uport.mapbase = base;
+               uport.membase = (char *)(base + DIO_VIRADDRBASE);
+               uport.regshift = 2;
 
-               line = register_serial(&serial_req);
+               line = serial8250_register_port(&uport);
 
                if (line < 0) {
-                       printk(KERN_NOTICE "8250_hp300: register_serial() APCI %d"
-                              " irq %d failed\n", i, serial_req.irq);
+                       printk(KERN_NOTICE "8250_hp300: register_serial() APCI"
+                              " %d irq %d failed\n", i, uport.irq);
                        kfree(port);
                        continue;
                }
@@ -299,7 +297,7 @@ static void __devexit hpdca_remove_one(struct dio_dev *d)
                /* Disable board-interrupts */
                out_8(d->resource.start + DIO_VIRADDRBASE + DCA_IC, 0);
        }
-       unregister_serial(line);
+       serial8250_unregister_port(line);
 }
 #endif
 
@@ -309,7 +307,7 @@ static void __exit hp300_8250_exit(void)
        struct hp300_port *port, *to_free;
 
        for (port = hp300_ports; port; ) {
-               unregister_serial(port->line);
+               serial8250_unregister_port(port->line);
                to_free = port;
                port = port->next;
                kfree(to_free);