sio_puc.c revision 119419
1/*-
2 * Copyright (c) 2002 JF Hay.  All rights reserved.
3 * Copyright (c) 2001 M. Warner Losh.  All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/dev/sio/sio_puc.c 119419 2003-08-24 18:03:45Z obrien $");
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/dev/sio/sio_puc.c 119419 2003-08-24 18:03:45Z obrien $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/bus.h>
35#include <sys/conf.h>
36#include <sys/kernel.h>
37#include <sys/lock.h>
38#include <sys/malloc.h>
39#include <sys/mutex.h>
40#include <sys/module.h>
41#include <sys/tty.h>
42#include <machine/bus_pio.h>
43#include <machine/bus.h>
44#include <sys/timepps.h>
45
46#include <dev/pci/pcivar.h>
47#include <dev/puc/pucvar.h>
48#include <dev/sio/siovar.h>
49#include <dev/sio/sioreg.h>
50
51static	int	sio_puc_attach(device_t dev);
52static	int	sio_puc_probe(device_t dev);
53
54static device_method_t sio_puc_methods[] = {
55	/* Device interface */
56	DEVMETHOD(device_probe,		sio_puc_probe),
57	DEVMETHOD(device_attach,	sio_puc_attach),
58
59	{ 0, 0 }
60};
61
62static driver_t sio_puc_driver = {
63	sio_driver_name,
64	sio_puc_methods,
65	0,
66};
67
68static int
69sio_puc_attach(dev)
70	device_t	dev;
71{
72	uintptr_t rclk;
73
74	if (BUS_READ_IVAR(device_get_parent(dev), dev, PUC_IVAR_FREQ,
75	    &rclk) != 0)
76		rclk = DEFAULT_RCLK;
77	return (sioattach(dev, 0, rclk));
78}
79
80static int
81sio_puc_probe(dev)
82	device_t	dev;
83{
84	uintptr_t rclk;
85
86	if (BUS_READ_IVAR(device_get_parent(dev), dev, PUC_IVAR_FREQ,
87	    &rclk) != 0)
88		rclk = DEFAULT_RCLK;
89#ifdef PC98
90	SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550));
91#endif
92	return (sioprobe(dev, 0, rclk, 1));
93}
94
95DRIVER_MODULE(sio, puc, sio_puc_driver, sio_devclass, 0, 0);
96