fdc_cbus.c revision 131819
1/*
2 * Copyright (c) 2004 Yoshihiro TAKAHASHI
3 * 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 *    without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in
13 *    the documentation and/or other materials provided with the
14 *    distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
20 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/pc98/cbus/fdc_cbus.c 131819 2004-07-08 13:56:17Z nyan $");
31
32#include <sys/param.h>
33#include <sys/bio.h>
34#include <sys/bus.h>
35#include <sys/kernel.h>
36#include <sys/module.h>
37#include <sys/rman.h>
38#include <sys/systm.h>
39
40#include <pc98/pc98/fdcvar.h>
41#include <pc98/pc98/fdreg.h>
42
43#include <isa/isavar.h>
44#include <pc98/pc98/pc98.h>
45
46static int
47fdc_cbus_probe(device_t dev)
48{
49	int	error;
50	struct	fdc_data *fdc;
51
52	fdc = device_get_softc(dev);
53	bzero(fdc, sizeof *fdc);
54	fdc->fdc_dev = dev;
55
56	/* Check pnp ids */
57	if (isa_get_vendorid(dev))
58		return (ENXIO);
59
60	/* Attempt to allocate our resources for the duration of the probe */
61	error = fdc_alloc_resources(fdc);
62	if (error)
63		goto out;
64
65	/* see if it can handle a command */
66	if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(4, 240),
67		   NE7_SPEC_2(2, 0), 0)) {
68		error = ENXIO;
69	}
70
71out:
72	fdc_release_resources(fdc);
73	return (error);
74}
75
76static device_method_t fdc_methods[] = {
77	/* Device interface */
78	DEVMETHOD(device_probe,		fdc_cbus_probe),
79	DEVMETHOD(device_attach,	fdc_attach),
80	DEVMETHOD(device_detach,	fdc_detach),
81	DEVMETHOD(device_shutdown,	bus_generic_shutdown),
82	DEVMETHOD(device_suspend,	bus_generic_suspend),
83	DEVMETHOD(device_resume,	bus_generic_resume),
84
85	/* Bus interface */
86	DEVMETHOD(bus_print_child,	fdc_print_child),
87	DEVMETHOD(bus_read_ivar,	fdc_read_ivar),
88	/* Our children never use any other bus interface methods. */
89
90	{ 0, 0 }
91};
92
93static driver_t fdc_driver = {
94	"fdc",
95	fdc_methods,
96	sizeof(struct fdc_data)
97};
98
99DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0);
100