MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / drivers / serial / 8250_gsc.c
blob97482bed7f31b3d8ea476376577594b9710bcd60
1 /*
2 * Serial Device Initialisation for Lasi/Asp/Wax/Dino
4 * (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
12 #include <linux/errno.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/ioport.h>
16 #include <linux/module.h>
17 #include <linux/serial.h>
18 #include <linux/signal.h>
19 #include <linux/slab.h>
20 #include <linux/types.h>
22 #include <asm/hardware.h>
23 #include <asm/parisc-device.h>
24 #include <asm/io.h>
25 #include <asm/serial.h>
27 static void setup_parisc_serial(struct serial_struct *serial,
28 unsigned long address, int irq, int line)
30 memset(serial, 0, sizeof(struct serial_struct));
32 /* autoconfig() sets state->type. This sets info->type */
33 serial->type = PORT_16550A;
35 serial->line = line;
36 serial->iomap_base = address;
37 serial->iomem_base = ioremap(address, 0x8);
39 serial->irq = irq;
40 serial->io_type = SERIAL_IO_MEM; /* define access method */
41 serial->flags = 0;
42 serial->xmit_fifo_size = 16;
43 serial->custom_divisor = 0;
44 serial->baud_base = LASI_BASE_BAUD;
47 static int __init
48 serial_init_chip(struct parisc_device *dev)
50 static int serial_line_nr;
51 unsigned long address;
52 int err;
54 struct serial_struct *serial;
56 if (!dev->irq) {
57 /* We find some unattached serial ports by walking native
58 * busses. These should be silently ignored. Otherwise,
59 * what we have here is a missing parent device, so tell
60 * the user what they're missing.
62 if (dev->parent->id.hw_type != HPHW_IOA) {
63 printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
64 "Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa);
66 return -ENODEV;
69 serial = kmalloc(sizeof(*serial), GFP_KERNEL);
70 if (!serial)
71 return -ENOMEM;
73 address = dev->hpa;
74 if (dev->id.sversion != 0x8d) {
75 address += 0x800;
78 setup_parisc_serial(serial, address, dev->irq, serial_line_nr++);
79 err = register_serial(serial);
80 if (err < 0) {
81 printk(KERN_WARNING "register_serial returned error %d\n", err);
82 kfree(serial);
83 return -ENODEV;
86 return 0;
89 static struct parisc_device_id serial_tbl[] = {
90 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
91 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
92 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
93 { 0 }
96 /* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
97 * attached to Dino. Unfortunately, Dino appears before Lasi in the device
98 * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
99 * which only knows about Lasi and then a second which will find all the
100 * other serial ports. HPUX ignores this problem.
102 static struct parisc_device_id lasi_tbl[] = {
103 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
104 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
105 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
106 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
107 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
108 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
109 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
110 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
111 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
112 { 0 }
116 MODULE_DEVICE_TABLE(parisc, serial_tbl);
118 static struct parisc_driver lasi_driver = {
119 .name = "Lasi RS232",
120 .id_table = lasi_tbl,
121 .probe = serial_init_chip,
124 static struct parisc_driver serial_driver = {
125 .name = "Serial RS232",
126 .id_table = serial_tbl,
127 .probe = serial_init_chip,
130 int __init probe_serial_gsc(void)
132 register_parisc_driver(&lasi_driver);
133 register_parisc_driver(&serial_driver);
134 return 0;
137 module_init(probe_serial_gsc);