11.15Stron/* $NetBSD: joy_pnpbios.c,v 1.15 2011/11/26 14:06:44 tron Exp $ */ 21.1Snathanw 31.1Snathanw/*- 41.14Sjmcneill * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc. 51.1Snathanw * All rights reserved. 61.1Snathanw * 71.1Snathanw * This code is derived from software contributed to The NetBSD Foundation 81.1Snathanw * by Nathan J. Williams. 91.1Snathanw * 101.1Snathanw * Redistribution and use in source and binary forms, with or without 111.1Snathanw * modification, are permitted provided that the following conditions 121.1Snathanw * are met: 131.1Snathanw * 1. Redistributions of source code must retain the above copyright 141.1Snathanw * notice, this list of conditions and the following disclaimer. 151.1Snathanw * 2. Redistributions in binary form must reproduce the above copyright 161.1Snathanw * notice, this list of conditions and the following disclaimer in the 171.1Snathanw * documentation and/or other materials provided with the distribution. 181.1Snathanw * 191.1Snathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Snathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Snathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Snathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Snathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Snathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Snathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Snathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Snathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Snathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Snathanw * POSSIBILITY OF SUCH DAMAGE. 301.1Snathanw */ 311.1Snathanw 321.2Slukem#include <sys/cdefs.h> 331.15Stron__KERNEL_RCSID(0, "$NetBSD: joy_pnpbios.c,v 1.15 2011/11/26 14:06:44 tron Exp $"); 341.1Snathanw 351.1Snathanw#include <sys/param.h> 361.1Snathanw#include <sys/systm.h> 371.1Snathanw#include <sys/kernel.h> 381.1Snathanw#include <sys/device.h> 391.1Snathanw 401.13Sdyoung#include <sys/bus.h> 411.1Snathanw 421.1Snathanw#include <dev/isa/isavar.h> 431.1Snathanw#include <dev/isa/isadmavar.h> 441.1Snathanw 451.1Snathanw#include <i386/pnpbios/pnpbiosvar.h> 461.1Snathanw 471.3Sjdolecek#include <dev/ic/joyvar.h> 481.1Snathanw 491.14Sjmcneillstruct joy_pnpbios_softc { 501.14Sjmcneill struct joy_softc sc_joy; 511.14Sjmcneill kmutex_t sc_lock; 521.15Stron}; 531.14Sjmcneill 541.11Sxtraemestatic int joy_pnpbios_match(device_t, cfdata_t, void *); 551.11Sxtraemestatic void joy_pnpbios_attach(device_t, device_t, void *); 561.1Snathanw 571.14SjmcneillCFATTACH_DECL_NEW(joy_pnpbios, sizeof(struct joy_pnpbios_softc), 581.6Sthorpej joy_pnpbios_match, joy_pnpbios_attach, NULL, NULL); 591.1Snathanw 601.11Sxtraemestatic int 611.11Sxtraemejoy_pnpbios_match(device_t parent, cfdata_t match, void *aux) 621.1Snathanw{ 631.1Snathanw struct pnpbiosdev_attach_args *aa = aux; 641.1Snathanw 651.1Snathanw if (strcmp(aa->idstr, "PNPB02F")) 661.11Sxtraeme return 0; 671.1Snathanw 681.11Sxtraeme return 1; 691.1Snathanw} 701.1Snathanw 711.11Sxtraemestatic void 721.11Sxtraemejoy_pnpbios_attach(device_t parent, device_t self, void *aux) 731.1Snathanw{ 741.11Sxtraeme struct joy_softc *sc = device_private(self); 751.14Sjmcneill struct joy_pnpbios_softc *psc = device_private(self); 761.1Snathanw struct pnpbiosdev_attach_args *aa = aux; 771.1Snathanw 781.1Snathanw if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) { 791.11Sxtraeme aprint_error(": can't map i/o space\n"); 801.1Snathanw return; 811.1Snathanw } 821.1Snathanw 831.11Sxtraeme aprint_normal("\n"); 841.11Sxtraeme sc->sc_dev = self; 851.1Snathanw pnpbios_print_devres(self, aa); 861.1Snathanw 871.14Sjmcneill mutex_init(&psc->sc_lock, MUTEX_DEFAULT, IPL_NONE); 881.14Sjmcneill sc->sc_lock = &psc->sc_lock; 891.14Sjmcneill 901.1Snathanw joyattach(sc); 911.1Snathanw} 92