blob: 948d0a1c6ae8edc91eefaadb5037f4a311d12509 [file] [log] [blame]
Greg Kroah-Hartmane3b3d0f2017-11-06 18:11:51 +01001// SPDX-License-Identifier: GPL-2.0+
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * Serial Device Initialisation for Lasi/Asp/Wax/Dino
4 *
5 * (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <linux/types.h>
16
17#include <asm/hardware.h>
18#include <asm/parisc-device.h>
19#include <asm/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21#include "8250.h"
22
Alan Cox8b4a4832008-02-08 04:18:50 -080023static int __init serial_init_chip(struct parisc_device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070024{
Alan Cox2655a2c2012-07-12 12:59:50 +010025 struct uart_8250_port uart;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 unsigned long address;
27 int err;
28
Randy Dunlap6e879362022-02-14 10:00:19 -080029#if defined(CONFIG_64BIT) && defined(CONFIG_IOSAPIC)
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020030 if (!dev->irq && (dev->id.sversion == 0xad))
Thomas Bogendoerferdd5e6d62013-07-30 02:02:16 +020031 dev->irq = iosapic_serial_irq(dev);
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020032#endif
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 if (!dev->irq) {
35 /* We find some unattached serial ports by walking native
36 * busses. These should be silently ignored. Otherwise,
37 * what we have here is a missing parent device, so tell
38 * the user what they're missing.
39 */
Alan Cox8b4a4832008-02-08 04:18:50 -080040 if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
Phillip Raffeck9f59fbf2016-01-14 16:08:19 +010041 dev_info(&dev->dev,
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070042 "Serial: device 0x%llx not configured.\n"
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040043 "Enable support for Wax, Lasi, Asp or Dino.\n",
Alexander Beregalov8e8e8262009-05-28 14:34:34 -070044 (unsigned long long)dev->hpa.start);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 return -ENODEV;
46 }
47
Matthew Wilcox53f01bb2005-10-21 22:36:40 -040048 address = dev->hpa.start;
Alan Cox8b4a4832008-02-08 04:18:50 -080049 if (dev->id.sversion != 0x8d)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 address += 0x800;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Alan Cox2655a2c2012-07-12 12:59:50 +010052 memset(&uart, 0, sizeof(uart));
53 uart.port.iotype = UPIO_MEM;
Matthew Wilcox136ce402006-08-28 11:53:30 -060054 /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020055 uart.port.uartclk = (dev->id.sversion != 0xad) ?
56 7272727 : 1843200;
Alan Cox2655a2c2012-07-12 12:59:50 +010057 uart.port.mapbase = address;
Christoph Hellwig4bdc0d62020-01-06 09:43:50 +010058 uart.port.membase = ioremap(address, 16);
Arvind Yadav2cc32b12017-01-19 13:30:44 +053059 if (!uart.port.membase) {
60 dev_warn(&dev->dev, "Failed to map memory\n");
61 return -ENOMEM;
62 }
Alan Cox2655a2c2012-07-12 12:59:50 +010063 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) {
Phillip Raffeck9f59fbf2016-01-14 16:08:19 +010069 dev_warn(&dev->dev,
70 "serial8250_register_8250_port returned error %d\n",
71 err);
Alan Cox2655a2c2012-07-12 12:59:50 +010072 iounmap(uart.port.membase);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 return err;
74 }
Alan Cox8b4a4832008-02-08 04:18:50 -080075
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 return 0;
77}
78
Helge Deller9e466f12017-08-21 21:56:08 +020079static const struct parisc_device_id serial_tbl[] __initconst = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 { 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 },
Thomas Bogendoerfer9a66d182013-06-09 23:00:21 +020083 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 { 0 }
85};
86
87/* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1
88 * attached to Dino. Unfortunately, Dino appears before Lasi in the device
89 * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one
90 * which only knows about Lasi and then a second which will find all the
91 * other serial ports. HPUX ignores this problem.
92 */
Helge Deller9e466f12017-08-21 21:56:08 +020093static const struct parisc_device_id lasi_tbl[] __initconst = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
95 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
96 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
97 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
98 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
99 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
100 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
101 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
102 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
103 { 0 }
104};
105
106
107MODULE_DEVICE_TABLE(parisc, serial_tbl);
108
Helge Deller9e466f12017-08-21 21:56:08 +0200109static struct parisc_driver lasi_driver __refdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 .name = "serial_1",
111 .id_table = lasi_tbl,
112 .probe = serial_init_chip,
113};
114
Helge Deller9e466f12017-08-21 21:56:08 +0200115static struct parisc_driver serial_driver __refdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 .name = "serial",
117 .id_table = serial_tbl,
118 .probe = serial_init_chip,
119};
120
Adrian Bunk9f561df2008-10-18 20:27:45 -0700121static int __init probe_serial_gsc(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
123 register_parisc_driver(&lasi_driver);
124 register_parisc_driver(&serial_driver);
125 return 0;
126}
127
128module_init(probe_serial_gsc);
Adrian Bunk920519c2008-07-23 21:29:44 -0700129
130MODULE_LICENSE("GPL");