blob: d8c0ffbfa6e39b53bafaef22f2d090e2739613e9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/types.h>
20
21#include <asm/hardware.h>
22#include <asm/parisc-device.h>
23#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include "8250.h"
26
Alan Cox8b4a4832008-02-08 04:18:50 -080027static int __init serial_init_chip(struct parisc_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070028{
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 struct uart_port port;
30 unsigned long address;
31 int err;
32
33 if (!dev->irq) {
34 /* We find some unattached serial ports by walking native
35 * busses. These should be silently ignored. Otherwise,
36 * what we have here is a missing parent device, so tell
37 * the user what they're missing.
38 */
Alan Cox8b4a4832008-02-08 04:18:50 -080039 if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
40 printk(KERN_INFO
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070041 "Serial: device 0x%llx not configured.\n"
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040042 "Enable support for Wax, Lasi, Asp or Dino.\n",
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070043 (unsigned long long)dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044 return -ENODEV;
45 }
46
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040047 address = dev->hpa.start;
Alan Cox8b4a4832008-02-08 04:18:50 -080048 if (dev->id.sversion != 0x8d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 address += 0x800;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Helge Deller5076c152006-03-27 12:52:15 -070051 memset(&port, 0, sizeof(port));
52 port.iotype = UPIO_MEM;
Matthew Wilcox136ce402006-08-28 11:53:30 -060053 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
54 port.uartclk = 7272727;
Helge Deller5076c152006-03-27 12:52:15 -070055 port.mapbase = address;
56 port.membase = ioremap_nocache(address, 16);
57 port.irq = dev->irq;
58 port.flags = UPF_BOOT_AUTOCONF;
59 port.dev = &dev->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61 err = serial8250_register_port(&port);
62 if (err < 0) {
Alan Cox8b4a4832008-02-08 04:18:50 -080063 printk(KERN_WARNING
64 "serial8250_register_port returned error %d\n", err);
Amol Ladd9964d52006-09-30 23:29:21 -070065 iounmap(port.membase);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 return err;
67 }
Alan Cox8b4a4832008-02-08 04:18:50 -080068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 return 0;
70}
71
72static struct parisc_device_id serial_tbl[] = {
73 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
74 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
75 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
76 { 0 }
77};
78
79/* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
80 * attached to Dino. Unfortunately, Dino appears before Lasi in the device
81 * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
82 * which only knows about Lasi and then a second which will find all the
83 * other serial ports. HPUX ignores this problem.
84 */
85static struct parisc_device_id lasi_tbl[] = {
86 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
87 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
88 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
89 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
90 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
91 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
92 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
93 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
94 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
95 { 0 }
96};
97
98
99MODULE_DEVICE_TABLE(parisc, serial_tbl);
100
101static struct parisc_driver lasi_driver = {
102 .name = "serial_1",
103 .id_table = lasi_tbl,
104 .probe = serial_init_chip,
105};
106
107static struct parisc_driver serial_driver = {
108 .name = "serial",
109 .id_table = serial_tbl,
110 .probe = serial_init_chip,
111};
112
Adrian Bunk9f561df2008-10-18 20:27:45 -0700113static int __init probe_serial_gsc(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114{
115 register_parisc_driver(&lasi_driver);
116 register_parisc_driver(&serial_driver);
117 return 0;
118}
119
120module_init(probe_serial_gsc);
Adrian Bunk920519c2008-07-23 21:29:44 -0700121
122MODULE_LICENSE("GPL");