blob: 2e3ea1a70d7b90768f33f26a39f098eed7df2c12 [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{
Alan Cox2655a2c2012-07-12 12:59:50 +010029 struct uart_8250_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -070030 unsigned long address;
31 int err;
32
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020033#ifdef CONFIG_64BIT
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020034 if (!dev->irq && (dev->id.sversion == 0xad))
Thomas Bogendoerferdd5e6d62013-07-30 02:02:16 +020035 dev->irq = iosapic_serial_irq(dev);
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020036#endif
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 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 */
Alan Cox8b4a4832008-02-08 04:18:50 -080044 if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
45 printk(KERN_INFO
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070046 "Serial: device 0x%llx not configured.\n"
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040047 "Enable support for Wax, Lasi, Asp or Dino.\n",
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070048 (unsigned long long)dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 return -ENODEV;
50 }
51
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040052 address = dev->hpa.start;
Alan Cox8b4a4832008-02-08 04:18:50 -080053 if (dev->id.sversion != 0x8d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 address += 0x800;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
Alan Cox2655a2c2012-07-12 12:59:50 +010056 memset(&uart, 0, sizeof(uart));
57 uart.port.iotype = UPIO_MEM;
Matthew Wilcox136ce402006-08-28 11:53:30 -060058 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020059 uart.port.uartclk = (dev->id.sversion != 0xad) ?
60 7272727 : 1843200;
Alan Cox2655a2c2012-07-12 12:59:50 +010061 uart.port.mapbase = address;
62 uart.port.membase = ioremap_nocache(address, 16);
63 uart.port.irq = dev->irq;
64 uart.port.flags = UPF_BOOT_AUTOCONF;
65 uart.port.dev = &dev->dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
Alan Cox2655a2c2012-07-12 12:59:50 +010067 err = serial8250_register_8250_port(&uart);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 if (err < 0) {
Alan Cox8b4a4832008-02-08 04:18:50 -080069 printk(KERN_WARNING
Alan Cox2655a2c2012-07-12 12:59:50 +010070 "serial8250_register_8250_port returned error %d\n", err);
71 iounmap(uart.port.membase);
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 return err;
73 }
Alan Cox8b4a4832008-02-08 04:18:50 -080074
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 return 0;
76}
77
78static struct parisc_device_id serial_tbl[] = {
79 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
80 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
81 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020082 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 { 0 }
84};
85
86/* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
87 * attached to Dino. Unfortunately, Dino appears before Lasi in the device
88 * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
89 * which only knows about Lasi and then a second which will find all the
90 * other serial ports. HPUX ignores this problem.
91 */
92static struct parisc_device_id lasi_tbl[] = {
93 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
94 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
95 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
96 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
97 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
98 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
99 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
100 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
101 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
102 { 0 }
103};
104
105
106MODULE_DEVICE_TABLE(parisc, serial_tbl);
107
108static struct parisc_driver lasi_driver = {
109 .name = "serial_1",
110 .id_table = lasi_tbl,
111 .probe = serial_init_chip,
112};
113
114static struct parisc_driver serial_driver = {
115 .name = "serial",
116 .id_table = serial_tbl,
117 .probe = serial_init_chip,
118};
119
Adrian Bunk9f561df2008-10-18 20:27:45 -0700120static int __init probe_serial_gsc(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121{
122 register_parisc_driver(&lasi_driver);
123 register_parisc_driver(&serial_driver);
124 return 0;
125}
126
127module_init(probe_serial_gsc);
Adrian Bunk920519c2008-07-23 21:29:44 -0700128
129MODULE_LICENSE("GPL");