1
2
3
4
5
6
7
8#include <linux/errno.h>
9#include <linux/init.h>
10#include <linux/interrupt.h>
11#include <linux/ioport.h>
12#include <linux/module.h>
13#include <linux/serial_core.h>
14#include <linux/signal.h>
15#include <linux/types.h>
16
17#include <asm/hardware.h>
18#include <asm/parisc-device.h>
19#include <asm/io.h>
20
21#include "8250.h"
22
23static int __init serial_init_chip(struct parisc_device *dev)
24{
25 struct uart_8250_port uart;
26 unsigned long address;
27 int err;
28
29#ifdef CONFIG_64BIT
30 if (!dev->irq && (dev->id.sversion == 0xad))
31 dev->irq = iosapic_serial_irq(dev);
32#endif
33
34 if (!dev->irq) {
35
36
37
38
39
40 if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
41 dev_info(&dev->dev,
42 "Serial: device 0x%llx not configured.\n"
43 "Enable support for Wax, Lasi, Asp or Dino.\n",
44 (unsigned long long)dev->hpa.start);
45 return -ENODEV;
46 }
47
48 address = dev->hpa.start;
49 if (dev->id.sversion != 0x8d)
50 address += 0x800;
51
52 memset(&uart, 0, sizeof(uart));
53 uart.port.iotype = UPIO_MEM;
54
55 uart.port.uartclk = (dev->id.sversion != 0xad) ?
56 7272727 : 1843200;
57 uart.port.mapbase = address;
58 uart.port.membase = ioremap(address, 16);
59 if (!uart.port.membase) {
60 dev_warn(&dev->dev, "Failed to map memory\n");
61 return -ENOMEM;
62 }
63 uart.port.irq = dev->irq;
64 uart.port.flags = UPF_BOOT_AUTOCONF;
65 uart.port.dev = &dev->dev;
66
67 err = serial8250_register_8250_port(&uart);
68 if (err < 0) {
69 dev_warn(&dev->dev,
70 "serial8250_register_8250_port returned error %d\n",
71 err);
72 iounmap(uart.port.membase);
73 return err;
74 }
75
76 return 0;
77}
78
79static const struct parisc_device_id serial_tbl[] __initconst = {
80 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
81 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
82 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
83 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
84 { 0 }
85};
86
87
88
89
90
91
92
93static const struct parisc_device_id lasi_tbl[] __initconst = {
94 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C },
95 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C },
96 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C },
97 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C },
98 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C },
99 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C },
100 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C },
101 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C },
102 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C },
103 { 0 }
104};
105
106
107MODULE_DEVICE_TABLE(parisc, serial_tbl);
108
109static struct parisc_driver lasi_driver __refdata = {
110 .name = "serial_1",
111 .id_table = lasi_tbl,
112 .probe = serial_init_chip,
113};
114
115static struct parisc_driver serial_driver __refdata = {
116 .name = "serial",
117 .id_table = serial_tbl,
118 .probe = serial_init_chip,
119};
120
121static int __init probe_serial_gsc(void)
122{
123 register_parisc_driver(&lasi_driver);
124 register_parisc_driver(&serial_driver);
125 return 0;
126}
127
128module_init(probe_serial_gsc);
129
130MODULE_LICENSE("GPL");
131