8250_gsc.c revision 5076c15862644edb91d2e3436b2fa3e07b28385d
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/*
21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	Serial Device Initialisation for Lasi/Asp/Wax/Dino
31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	(c) Copyright Matthew Wilcox <willy@debian.org> 2001-2002
51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *
61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	This program is free software; you can redistribute it and/or modify
71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *	it under the terms of the GNU General Public License as published by
81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *      the Free Software Foundation; either version 2 of the License, or
91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds *      (at your option) any later version.
101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/errno.h>
131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/init.h>
141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/interrupt.h>
151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/ioport.h>
161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/module.h>
171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/serial_core.h>
181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/signal.h>
191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/slab.h>
201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/types.h>
211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/hardware.h>
231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/parisc-device.h>
241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/io.h>
251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/serial.h> /* for LASI_BASE_BAUD */
261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "8250.h"
281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int __init
301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsserial_init_chip(struct parisc_device *dev)
311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	struct uart_port port;
331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	unsigned long address;
341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	int err;
351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (!dev->irq) {
371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		/* We find some unattached serial ports by walking native
381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * busses.  These should be silently ignored.  Otherwise,
391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * what we have here is a missing parent device, so tell
401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 * the user what they're missing.
411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		 */
421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		if (parisc_parent(dev)->id.hw_type != HPHW_IOA) {
431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds			printk(KERN_INFO "Serial: device 0x%lx not configured.\n"
4453f01bba49938f115237fe43a261c31ac13ae5c6Matthew Wilcox				"Enable support for Wax, Lasi, Asp or Dino.\n",
4553f01bba49938f115237fe43a261c31ac13ae5c6Matthew Wilcox				dev->hpa.start);
461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		}
471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return -ENODEV;
481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
5053f01bba49938f115237fe43a261c31ac13ae5c6Matthew Wilcox	address = dev->hpa.start;
511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (dev->id.sversion != 0x8d) {
521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		address += 0x800;
531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
555076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	memset(&port, 0, sizeof(port));
565076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.iotype	= UPIO_MEM;
575076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.uartclk	= LASI_BASE_BAUD * 16;
585076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.mapbase	= address;
595076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.membase	= ioremap_nocache(address, 16);
605076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.irq	= dev->irq;
615076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.flags	= UPF_BOOT_AUTOCONF;
625076c15862644edb91d2e3436b2fa3e07b28385dHelge Deller	port.dev	= &dev->dev;
631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	err = serial8250_register_port(&port);
651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	if (err < 0) {
661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		printk(KERN_WARNING "serial8250_register_port returned error %d\n", err);
671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds		return err;
681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	}
691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return 0;
711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct parisc_device_id serial_tbl[] = {
741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x00075 },
751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008c },
761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0008d },
771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ 0 }
781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* Hack.  Some machines have SERIAL_0 attached to Lasi and SERIAL_1
811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * attached to Dino.  Unfortunately, Dino appears before Lasi in the device
821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * tree.  To ensure that ttyS0 == SERIAL_0, we register two drivers; one
831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * which only knows about Lasi and then a second which will find all the
841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * other serial ports.  HPUX ignores this problem.
851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */
861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct parisc_device_id lasi_tbl[] = {
871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03B, 0x0008C }, /* C1xx/C1xxL */
881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03C, 0x0008C }, /* B132L */
891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03D, 0x0008C }, /* B160L */
901da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03E, 0x0008C }, /* B132L+ */
911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x03F, 0x0008C }, /* B180L+ */
921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x046, 0x0008C }, /* Rocky2 120 */
931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x047, 0x0008C }, /* Rocky2 150 */
941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x04E, 0x0008C }, /* Kiji L2 132 */
951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ HPHW_FIO, HVERSION_REV_ANY_ID, 0x056, 0x0008C }, /* Raven+ */
961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	{ 0 }
971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus TorvaldsMODULE_DEVICE_TABLE(parisc, serial_tbl);
1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct parisc_driver lasi_driver = {
1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.name		= "serial_1",
1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.id_table	= lasi_tbl,
1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.probe		= serial_init_chip,
1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic struct parisc_driver serial_driver = {
1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.name		= "serial",
1101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.id_table	= serial_tbl,
1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	.probe		= serial_init_chip,
1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds};
1131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint __init probe_serial_gsc(void)
1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{
1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	register_parisc_driver(&lasi_driver);
1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	register_parisc_driver(&serial_driver);
1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds	return 0;
1191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds}
1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds
1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsmodule_init(probe_serial_gsc);
122