fdc_cbus.c revision 132103
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 132103 2004-07-13 13:14:37Z 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 <machine/bus.h> 41 42#include <pc98/pc98/fdcvar.h> 43#include <pc98/pc98/fdreg.h> 44 45#include <isa/isavar.h> 46#include <pc98/pc98/pc98.h> 47 48static int 49fdc_cbus_probe(device_t dev) 50{ 51 int error; 52 struct fdc_data *fdc; 53 54 fdc = device_get_softc(dev); 55 fdc->fdc_dev = dev; 56 57 /* Check pnp ids */ 58 if (isa_get_vendorid(dev)) 59 return (ENXIO); 60 61 /* Attempt to allocate our resources for the duration of the probe */ 62 error = fdc_alloc_resources(fdc); 63 if (!error) 64 error = fdc_initial_reset(fdc); 65 66 fdc_release_resources(fdc); 67 return (error); 68} 69 70static device_method_t fdc_methods[] = { 71 /* Device interface */ 72 DEVMETHOD(device_probe, fdc_cbus_probe), 73 DEVMETHOD(device_attach, fdc_attach), 74 DEVMETHOD(device_detach, fdc_detach), 75 DEVMETHOD(device_shutdown, bus_generic_shutdown), 76 DEVMETHOD(device_suspend, bus_generic_suspend), 77 DEVMETHOD(device_resume, bus_generic_resume), 78 79 /* Bus interface */ 80 DEVMETHOD(bus_print_child, fdc_print_child), 81 DEVMETHOD(bus_read_ivar, fdc_read_ivar), 82 DEVMETHOD(bus_write_ivar, fdc_write_ivar), 83 /* Our children never use any other bus interface methods. */ 84 85 { 0, 0 } 86}; 87 88static driver_t fdc_driver = { 89 "fdc", 90 fdc_methods, 91 sizeof(struct fdc_data) 92}; 93 94DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0); 95