1/* 2 * Serial Device Initialisation for LASI/ASP/WAX/DINO 3 * 4 * (c) Copyright 2000 The Puffin Group Inc. 5 * (c) Copyright 2000-2001 Helge Deller <deller@gmx.de> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 */ 13 14#include <linux/config.h> 15#include <linux/errno.h> 16#include <linux/init.h> 17#include <linux/signal.h> 18#include <linux/types.h> 19#include <linux/sched.h> 20#include <linux/interrupt.h> 21#include <linux/kernel_stat.h> 22#include <linux/ioport.h> 23#include <linux/timex.h> 24#include <linux/module.h> 25#include <linux/serial.h> 26#include <linux/slab.h> 27 28#include <asm/serial.h> 29#include <asm/io.h> 30#include <asm/hardware.h> 31#include <asm/gsc.h> 32 33#include "busdevice.h" 34 35static void setup_parisc_serial(struct serial_struct *serial, 36 unsigned long address, int irq, int line) 37{ 38 memset(serial, 0, sizeof(struct serial_struct)); 39 40 /* autoconfig() sets state->type. This sets info->type */ 41 serial->type = PORT_16550A; 42 43 serial->line = line; 44 serial->iomem_base = ioremap(address, 0x8); 45 46 serial->irq = irq; 47 serial->io_type = SERIAL_IO_MEM; /* define access method */ 48 serial->flags = 0; 49 serial->xmit_fifo_size = 16; 50 serial->custom_divisor = 0; 51 serial->baud_base = LASI_BASE_BAUD; 52} 53 54static int __init 55serial_init_chip(struct parisc_device *dev) 56{ 57 static int serial_line_nr; 58 unsigned long address; 59 60 struct serial_struct *serial; 61 62 if (!dev->irq) { 63 if (dev->parent->id.hw_type != HPHW_IOA) { 64 printk(KERN_INFO "Serial: device 0x%lx not configured.\n" 65 "Enable support for Wax, Lasi, Asp or Dino.\n", dev->hpa); 66 } 67 return -ENODEV; 68 } 69 70 serial = kmalloc(sizeof(*serial), GFP_KERNEL); 71 if (!serial) 72 return -ENOMEM; 73 74 address = dev->hpa; 75 if (dev->id.sversion != 0x8d) { 76 address += 0x800; 77 } 78 79 setup_parisc_serial(serial, address, dev->irq, serial_line_nr++); 80 81 if (register_serial(serial) < 0) { 82 printk(KERN_WARNING "register_serial returned error\n"); 83 kfree(serial); 84 return -ENODEV; 85 } 86 87 return 0; 88} 89 90static struct parisc_device_id serial_tbl[] = { 91 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 }, 92 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c }, 93 { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d }, 94 { 0 } 95}; 96 97/* Hack. Dino's serial port will get listed first on some machines. 98 * So we register this driver first which knows about Lasi's serial port. 99 * This needs to get fixed properly somehow. 100 */ 101static struct parisc_device_id serial1_tbl[] = { 102 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */ 103 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */ 104 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */ 105 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */ 106 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */ 107 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */ 108 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */ 109 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */ 110 { HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */ 111 { 0 } 112}; 113 114 115MODULE_DEVICE_TABLE(parisc, serial_tbl); 116 117static struct parisc_driver serial1_driver = { 118 name: "Serial RS232", 119 id_table: serial1_tbl, 120 probe: serial_init_chip, 121}; 122 123static struct parisc_driver serial_driver = { 124 name: "Serial RS232", 125 id_table: serial_tbl, 126 probe: serial_init_chip, 127}; 128 129void __init probe_serial_gsc(void) 130{ 131 register_parisc_driver(&serial1_driver); 132 register_parisc_driver(&serial_driver); 133} 134