Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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/slab.h> |
| 20 | #include <linux/types.h> |
| 21 | |
| 22 | #include <asm/hardware.h> |
| 23 | #include <asm/parisc-device.h> |
| 24 | #include <asm/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | #include "8250.h" |
| 27 | |
Alan Cox | 8b4a483 | 2008-02-08 04:18:50 -0800 | [diff] [blame] | 28 | static int __init serial_init_chip(struct parisc_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | struct uart_port port; |
| 31 | unsigned long address; |
| 32 | int err; |
| 33 | |
| 34 | 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 Cox | 8b4a483 | 2008-02-08 04:18:50 -0800 | [diff] [blame] | 40 | if (parisc_parent(dev)->id.hw_type != HPHW_IOA) |
| 41 | printk(KERN_INFO |
| 42 | "Serial: device 0x%lx not configured.\n" |
Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 43 | "Enable support for Wax, Lasi, Asp or Dino.\n", |
| 44 | dev->hpa.start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | return -ENODEV; |
| 46 | } |
| 47 | |
Matthew Wilcox | 53f01bb | 2005-10-21 22:36:40 -0400 | [diff] [blame] | 48 | address = dev->hpa.start; |
Alan Cox | 8b4a483 | 2008-02-08 04:18:50 -0800 | [diff] [blame] | 49 | if (dev->id.sversion != 0x8d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | address += 0x800; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Helge Deller | 5076c15 | 2006-03-27 12:52:15 -0700 | [diff] [blame] | 52 | memset(&port, 0, sizeof(port)); |
| 53 | port.iotype = UPIO_MEM; |
Matthew Wilcox | 136ce40 | 2006-08-28 11:53:30 -0600 | [diff] [blame] | 54 | /* 7.272727MHz on Lasi. Assumed the same for Dino, Wax and Timi. */ |
| 55 | port.uartclk = 7272727; |
Helge Deller | 5076c15 | 2006-03-27 12:52:15 -0700 | [diff] [blame] | 56 | port.mapbase = address; |
| 57 | port.membase = ioremap_nocache(address, 16); |
| 58 | port.irq = dev->irq; |
| 59 | port.flags = UPF_BOOT_AUTOCONF; |
| 60 | port.dev = &dev->dev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
| 62 | err = serial8250_register_port(&port); |
| 63 | if (err < 0) { |
Alan Cox | 8b4a483 | 2008-02-08 04:18:50 -0800 | [diff] [blame] | 64 | printk(KERN_WARNING |
| 65 | "serial8250_register_port returned error %d\n", err); |
Amol Lad | d9964d5 | 2006-09-30 23:29:21 -0700 | [diff] [blame] | 66 | iounmap(port.membase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | return err; |
| 68 | } |
Alan Cox | 8b4a483 | 2008-02-08 04:18:50 -0800 | [diff] [blame] | 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | static struct parisc_device_id serial_tbl[] = { |
| 74 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 }, |
| 75 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c }, |
| 76 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d }, |
| 77 | { 0 } |
| 78 | }; |
| 79 | |
| 80 | /* Hack. Some machines have SERIAL_0 attached to Lasi and SERIAL_1 |
| 81 | * attached to Dino. Unfortunately, Dino appears before Lasi in the device |
| 82 | * tree. To ensure that ttyS0 == SERIAL_0, we register two drivers; one |
| 83 | * which only knows about Lasi and then a second which will find all the |
| 84 | * other serial ports. HPUX ignores this problem. |
| 85 | */ |
| 86 | static struct parisc_device_id lasi_tbl[] = { |
| 87 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */ |
| 88 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */ |
| 89 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */ |
| 90 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */ |
| 91 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */ |
| 92 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */ |
| 93 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */ |
| 94 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */ |
| 95 | { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */ |
| 96 | { 0 } |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | MODULE_DEVICE_TABLE(parisc, serial_tbl); |
| 101 | |
| 102 | static struct parisc_driver lasi_driver = { |
| 103 | .name = "serial_1", |
| 104 | .id_table = lasi_tbl, |
| 105 | .probe = serial_init_chip, |
| 106 | }; |
| 107 | |
| 108 | static struct parisc_driver serial_driver = { |
| 109 | .name = "serial", |
| 110 | .id_table = serial_tbl, |
| 111 | .probe = serial_init_chip, |
| 112 | }; |
| 113 | |
Adrian Bunk | 9f561df | 2008-10-18 20:27:45 -0700 | [diff] [blame] | 114 | static int __init probe_serial_gsc(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
| 116 | register_parisc_driver(&lasi_driver); |
| 117 | register_parisc_driver(&serial_driver); |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | module_init(probe_serial_gsc); |
Adrian Bunk | 920519c | 2008-07-23 21:29:44 -0700 | [diff] [blame] | 122 | |
| 123 | MODULE_LICENSE("GPL"); |