Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0+
0002 /*
0003  *  Serial Device Initialisation for Lasi/Asp/Wax/Dino
0004  *
0005  *  (c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
0006  */
0007 
0008 #include <linux/errno.h>
0009 #include <linux/init.h>
0010 #include <linux/interrupt.h>
0011 #include <linux/ioport.h>
0012 #include <linux/module.h>
0013 #include <linux/serial_core.h>
0014 #include <linux/signal.h>
0015 #include <linux/types.h>
0016 
0017 #include <asm/hardware.h>
0018 #include <asm/parisc-device.h>
0019 #include <asm/io.h>
0020 
0021 #include "8250.h"
0022 
0023 static int __init serial_init_chip(struct parisc_device *dev)
0024 {
0025     struct uart_8250_port uart;
0026     unsigned long address;
0027     int err;
0028 
0029 #if defined(CONFIG_64BIT) && defined(CONFIG_IOSAPIC)
0030     if (!dev->irq && (dev->id.sversion == 0xad))
0031         dev->irq = iosapic_serial_irq(dev);
0032 #endif
0033 
0034     if (!dev->irq) {
0035         /* We find some unattached serial ports by walking native
0036          * busses.  These should be silently ignored.  Otherwise,
0037          * what we have here is a missing parent device, so tell
0038          * the user what they're missing.
0039          */
0040         if (parisc_parent(dev)->id.hw_type != HPHW_IOA)
0041             dev_info(&dev->dev,
0042                 "Serial: device 0x%llx not configured.\n"
0043                 "Enable support for Wax, Lasi, Asp or Dino.\n",
0044                 (unsigned long long)dev->hpa.start);
0045         return -ENODEV;
0046     }
0047 
0048     address = dev->hpa.start;
0049     if (dev->id.sversion != 0x8d)
0050         address += 0x800;
0051 
0052     memset(&uart, 0, sizeof(uart));
0053     uart.port.iotype    = UPIO_MEM;
0054     /* 7.272727MHz on Lasi.  Assumed the same for Dino, Wax and Timi. */
0055     uart.port.uartclk   = (dev->id.sversion != 0xad) ?
0056                     7272727 : 1843200;
0057     uart.port.mapbase   = address;
0058     uart.port.membase   = ioremap(address, 16);
0059     if (!uart.port.membase) {
0060         dev_warn(&dev->dev, "Failed to map memory\n");
0061         return -ENOMEM;
0062     }
0063     uart.port.irq   = dev->irq;
0064     uart.port.flags = UPF_BOOT_AUTOCONF;
0065     uart.port.dev   = &dev->dev;
0066 
0067     err = serial8250_register_8250_port(&uart);
0068     if (err < 0) {
0069         dev_warn(&dev->dev,
0070             "serial8250_register_8250_port returned error %d\n",
0071             err);
0072         iounmap(uart.port.membase);
0073         return err;
0074     }
0075 
0076     return 0;
0077 }
0078 
0079 static const struct parisc_device_id serial_tbl[] __initconst = {
0080     { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
0081     { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
0082     { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
0083     { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x000ad },
0084     { 0 }
0085 };
0086 
0087 /* Hack.  Some machines have SERIAL_0 attached to Lasi and SERIAL_1
0088  * attached to Dino.  Unfortunately, Dino appears before Lasi in the device
0089  * tree.  To ensure that ttyS0 == SERIAL_0, we register two drivers; one
0090  * which only knows about Lasi and then a second which will find all the
0091  * other serial ports.  HPUX ignores this problem.
0092  */
0093 static const struct parisc_device_id lasi_tbl[] __initconst = {
0094     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
0095     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
0096     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
0097     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
0098     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
0099     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
0100     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
0101     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
0102     { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
0103     { 0 }
0104 };
0105 
0106 
0107 MODULE_DEVICE_TABLE(parisc, serial_tbl);
0108 
0109 static struct parisc_driver lasi_driver __refdata = {
0110     .name       = "serial_1",
0111     .id_table   = lasi_tbl,
0112     .probe      = serial_init_chip,
0113 };
0114 
0115 static struct parisc_driver serial_driver __refdata = {
0116     .name       = "serial",
0117     .id_table   = serial_tbl,
0118     .probe      = serial_init_chip,
0119 };
0120 
0121 static int __init probe_serial_gsc(void)
0122 {
0123     register_parisc_driver(&lasi_driver);
0124     register_parisc_driver(&serial_driver);
0125     return 0;
0126 }
0127 
0128 module_init(probe_serial_gsc);
0129 
0130 MODULE_LICENSE("GPL");