sio_cbus.c revision 104142
186912Snyan/*
286912Snyan * Copyright (c) 2001 Yoshihiro TAKAHASHI.  All rights reserved.
386912Snyan *
486912Snyan * Redistribution and use in source and binary forms, with or without
586912Snyan * modification, are permitted provided that the following conditions
686912Snyan * are met:
786912Snyan * 1. Redistributions of source code must retain the above copyright
886912Snyan *    notice, this list of conditions and the following disclaimer.
986912Snyan * 2. Redistributions in binary form must reproduce the above copyright
1086912Snyan *    notice, this list of conditions and the following disclaimer in the
1186912Snyan *    documentation and/or other materials provided with the distribution.
1286912Snyan *
1386912Snyan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1486912Snyan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1586912Snyan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1686912Snyan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1786912Snyan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1886912Snyan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1986912Snyan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2086912Snyan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2186912Snyan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2286912Snyan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2386912Snyan *
2486912Snyan * $FreeBSD: head/sys/pc98/cbus/sio_cbus.c 104142 2002-09-29 13:31:26Z nyan $
2586912Snyan */
2686912Snyan
2786912Snyan#include <sys/param.h>
2886912Snyan#include <sys/systm.h>
2986912Snyan#include <sys/bus.h>
3086912Snyan#include <sys/conf.h>
3186912Snyan#include <sys/kernel.h>
3286912Snyan#include <sys/lock.h>
3386912Snyan#include <sys/malloc.h>
3486912Snyan#include <sys/mutex.h>
3586912Snyan#include <sys/module.h>
3686912Snyan#include <sys/tty.h>
3786912Snyan#include <machine/bus_pio.h>
3886912Snyan#include <machine/bus.h>
3986912Snyan#include <sys/timepps.h>
4086912Snyan
4186912Snyan#include <dev/sio/siovar.h>
4286912Snyan
4386912Snyan#include <isa/isavar.h>
4486912Snyan
4592793Skatostatic	int	sio_isa_attach(device_t dev);
4692793Skatostatic	int	sio_isa_probe(device_t dev);
4786912Snyan
4886912Snyanstatic device_method_t sio_isa_methods[] = {
4986912Snyan	/* Device interface */
5086912Snyan	DEVMETHOD(device_probe,		sio_isa_probe),
5186912Snyan	DEVMETHOD(device_attach,	sio_isa_attach),
5286912Snyan
5386912Snyan	{ 0, 0 }
5486912Snyan};
5586912Snyan
5686912Snyanstatic driver_t sio_isa_driver = {
5786912Snyan	sio_driver_name,
5886912Snyan	sio_isa_methods,
5986912Snyan	0,
6086912Snyan};
6186912Snyan
6286912Snyanstatic struct isa_pnp_id sio_ids[] = {
6386912Snyan	{0x0100e4a5, "RSA-98III"},
64104142Snyan	{0x11802fbf, NULL},	/* OYO8011 - PC-9801-12X */
65104142Snyan	{0x4180a3b8, NULL},	/* NEC8041 - PC-9821CB-B04 */
66104142Snyan	{0x4182a3b8, NULL},	/* NEC8241 - (Nw150) */
67104142Snyan	{0x5181a3b8, NULL},	/* NEC8151 - PC-9821CB2-B04 */
68104142Snyan	{0x5182a3b8, NULL},	/* NEC8251 - PC-9801-12X */
69104142Snyan	{0x7182a3b8, NULL},	/* NEC8271 - PC-9801-12X */
70104142Snyan	{0x9181a3b8, NULL},	/* NEC8191 - PC-9801-120 */
7186912Snyan	{0}
7286912Snyan};
7386912Snyan
7486912Snyanstatic int
7586912Snyansio_isa_probe(dev)
7686912Snyan	device_t	dev;
7786912Snyan{
7886912Snyan	int	logical_id;
79104142Snyan
8086912Snyan	/* Check isapnp ids */
8186912Snyan	if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
8286912Snyan		return (ENXIO);
83104142Snyan
8486912Snyan	logical_id = isa_get_logicalid(dev);
8586912Snyan	switch (logical_id) {
8686912Snyan	case 0x0100e4a5:	/* RSA-98III */
8786912Snyan		SET_FLAG(dev, SET_IFTYPE(COM_IF_RSA98III));
8886912Snyan		break;
89104142Snyan	case 0x11802fbf:	/* PC-9801-12X */
90104142Snyan	case 0x4180a3b8:	/* PC-9821CB-B04 */
91104142Snyan	case 0x4182a3b8:	/* (Nw150) */
92104142Snyan	case 0x5181a3b8:	/* PC-9821CB2-B04 */
93104142Snyan	case 0x5182a3b8:	/* PC-9801-12X */
94104142Snyan	case 0x7182a3b8:	/* PC-9801-12X */
95104142Snyan	case 0x9181a3b8:	/* PC-9801-120 */
96104142Snyan		SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
97104142Snyan		break;
9886912Snyan	}
99104142Snyan
10090011Snyan	return (sioprobe(dev, 0, 0UL, 0));
10186912Snyan}
10286912Snyan
10386912Snyanstatic int
10486912Snyansio_isa_attach(dev)
10586912Snyan	device_t	dev;
10686912Snyan{
10790011Snyan	return (sioattach(dev, 0, 0UL));
10886912Snyan}
10986912Snyan
11086912SnyanDRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
111