Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Serial Device Initialisation for Lasi/Asp/Wax/Dino
3 *
4 * (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
5 *
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.
10 */
11
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_core.h>
18#include <linux/signal.h>
19#include <linux/types.h>
20
21#include <asm/hardware.h>
22#include <asm/parisc-device.h>
23#include <asm/io.h>
24
25#include "8250.h"
26
27static int __init serial_init_chip(struct parisc_device *dev)
28{
29 struct uart_8250_port uart;
30 unsigned long address;
31 int err;
32
33#ifdef CONFIG_64BIT
34 if (!dev->irq && (dev->id.sversion == 0xad))
35 dev->irq = iosapic_serial_irq(dev);
36#endif
37
38 if (!dev->irq) {
39 /* We find some unattached serial ports by walking native
40 * busses. These should be silently ignored. Otherwise,
41 * what we have here is a missing parent device, so tell
42 * the user what they're missing.
43 */
44 if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
45 dev_info(&dev->dev,
46 "Serial: device 0x%llx not configured.\n"
47 "Enable support for Wax, Lasi, Asp or Dino.\n",
48 (unsigned long long)dev->hpa.start);
49 return -ENODEV;
50 }
51
52 address = dev->hpa.start;
53 if (dev->id.sversion != 0x8d)
54 address += 0x800;
55
56 memset(&uart, 0, sizeof(uart));
57 uart.port.iotype = UPIO_MEM;
58 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
59 uart.port.uartclk = (dev->id.sversion != 0xad) ?
60 7272727 : 1843200;
61 uart.port.mapbase = address;
62 uart.port.membase = ioremap_nocache(address, 16);
63 if (!uart.port.membase) {
64 dev_warn(&dev->dev, "Failed to map memory\n");
65 return -ENOMEM;
66 }
67 uart.port.irq = dev->irq;
68 uart.port.flags = UPF_BOOT_AUTOCONF;
69 uart.port.dev = &dev->dev;
70
71 err = serial8250_register_8250_port(&uart);
72 if (err < 0) {
73 dev_warn(&dev->dev,
74 "serial8250_register_8250_port returned error %d\n",
75 err);
76 iounmap(uart.port.membase);
77 return err;
78 }
79
80 return 0;
81}
82
83static struct parisc_device_id serial_tbl[] = {
84 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
85 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
86 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
87 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
88 { 0 }
89};
90
91/* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
92 * attached to Dino. Unfortunately, Dino appears before Lasi in the device
93 * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
94 * which only knows about Lasi and then a second which will find all the
95 * other serial ports. HPUX ignores this problem.
96 */
97static struct parisc_device_id lasi_tbl[] = {
98 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
99 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
100 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
101 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
102 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
103 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
104 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
105 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
106 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
107 { 0 }
108};
109
110
111MODULE_DEVICE_TABLE(parisc, serial_tbl);
112
113static struct parisc_driver lasi_driver = {
114 .name = "serial_1",
115 .id_table = lasi_tbl,
116 .probe = serial_init_chip,
117};
118
119static struct parisc_driver serial_driver = {
120 .name = "serial",
121 .id_table = serial_tbl,
122 .probe = serial_init_chip,
123};
124
125static int __init probe_serial_gsc(void)
126{
127 register_parisc_driver(&lasi_driver);
128 register_parisc_driver(&serial_driver);
129 return 0;
130}
131
132module_init(probe_serial_gsc);
133
134MODULE_LICENSE("GPL");