Home | History | Annotate | Line # | Download | only in isa
isapnp_machdep.c revision 1.9
      1  1.9   dyoung /*	$NetBSD: isapnp_machdep.c,v 1.9 2011/07/01 19:25:41 dyoung Exp $	*/
      2  1.1     soda /*	$OpenBSD: isapnp_machdep.c,v 1.1 1997/12/27 12:13:11 niklas Exp $	*/
      3  1.2     soda /*	NetBSD: isapnp_machdep.c,v 1.5 1997/10/04 17:32:30 thorpej Exp 	*/
      4  1.1     soda 
      5  1.1     soda /*-
      6  1.1     soda  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
      7  1.1     soda  * All rights reserved.
      8  1.1     soda  *
      9  1.1     soda  * This code is derived from software contributed to The NetBSD Foundation
     10  1.1     soda  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
     11  1.5  tsutsui  * NASA Ames Research Center and by Christos Zoulas.
     12  1.1     soda  *
     13  1.1     soda  * Redistribution and use in source and binary forms, with or without
     14  1.1     soda  * modification, are permitted provided that the following conditions
     15  1.1     soda  * are met:
     16  1.1     soda  * 1. Redistributions of source code must retain the above copyright
     17  1.1     soda  *    notice, this list of conditions and the following disclaimer.
     18  1.1     soda  * 2. Redistributions in binary form must reproduce the above copyright
     19  1.1     soda  *    notice, this list of conditions and the following disclaimer in the
     20  1.1     soda  *    documentation and/or other materials provided with the distribution.
     21  1.1     soda  *
     22  1.1     soda  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     23  1.1     soda  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     24  1.1     soda  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     25  1.1     soda  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     26  1.1     soda  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     27  1.1     soda  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     28  1.1     soda  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     29  1.1     soda  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     30  1.1     soda  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     31  1.1     soda  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     32  1.1     soda  * POSSIBILITY OF SUCH DAMAGE.
     33  1.1     soda  */
     34  1.1     soda 
     35  1.1     soda /*
     36  1.1     soda  * Machine-dependent portions of ISA PnP bus autoconfiguration.
     37  1.1     soda  *
     38  1.1     soda  * N.B. This file exists mostly to get around some lameness surrounding
     39  1.1     soda  * the PnP spec.  ISA PnP registers live where some `normal' ISA
     40  1.1     soda  * devices do, but are e.g. write-only registers where the normal
     41  1.1     soda  * device has a read-only register.  This breaks in the presence of
     42  1.1     soda  * i/o port accounting.  This file takes care of mapping ISA PnP
     43  1.1     soda  * registers without actually allocating them in extent maps.
     44  1.1     soda  *
     45  1.1     soda  * Since this is a machine-dependent file, we make all sorts of
     46  1.1     soda  * assumptions about bus.h's guts.  Beware!
     47  1.1     soda  */
     48  1.1     soda 
     49  1.5  tsutsui #include <sys/cdefs.h>
     50  1.9   dyoung __KERNEL_RCSID(0, "$NetBSD: isapnp_machdep.c,v 1.9 2011/07/01 19:25:41 dyoung Exp $");
     51  1.5  tsutsui 
     52  1.1     soda #include <sys/param.h>
     53  1.1     soda #include <sys/systm.h>
     54  1.1     soda #include <sys/device.h>
     55  1.1     soda #include <sys/malloc.h>
     56  1.1     soda 
     57  1.9   dyoung #include <sys/bus.h>
     58  1.1     soda 
     59  1.5  tsutsui #include <dev/isa/isavar.h>
     60  1.1     soda 
     61  1.5  tsutsui #include <dev/isapnp/isapnpreg.h>
     62  1.5  tsutsui #include <dev/isapnp/isapnpvar.h>
     63  1.1     soda 
     64  1.1     soda /* isapnp_map():
     65  1.1     soda  *	Map I/O regions used by PnP
     66  1.1     soda  */
     67  1.1     soda int
     68  1.6  tsutsui isapnp_map(struct isapnp_softc *sc)
     69  1.1     soda {
     70  1.5  tsutsui 	bus_space_tag_t bst;
     71  1.3     soda 
     72  1.5  tsutsui 	bst = sc->sc_iot;
     73  1.5  tsutsui 	sc->sc_addr_ioh = bst->bs_vbase + ISAPNP_ADDR - bst->bs_start;
     74  1.5  tsutsui 	sc->sc_wrdata_ioh = bst->bs_vbase + ISAPNP_WRDATA - bst->bs_start;
     75  1.5  tsutsui 	return 0;
     76  1.1     soda }
     77  1.1     soda 
     78  1.1     soda /* isapnp_unmap():
     79  1.1     soda  *	Unmap I/O regions used by PnP
     80  1.1     soda  */
     81  1.1     soda void
     82  1.6  tsutsui isapnp_unmap(struct isapnp_softc *sc)
     83  1.1     soda {
     84  1.5  tsutsui 
     85  1.1     soda 	/* Do nothing. */
     86  1.1     soda }
     87  1.1     soda 
     88  1.1     soda /* isapnp_map_readport():
     89  1.1     soda  *	Called to map the PnP `read port', which is mapped independently
     90  1.1     soda  *	of the `write' and `addr' ports.
     91  1.1     soda  *
     92  1.1     soda  *	NOTE: assumes the caller has filled in sc->sc_read_port!
     93  1.1     soda  */
     94  1.1     soda int
     95  1.6  tsutsui isapnp_map_readport(struct isapnp_softc *sc)
     96  1.1     soda {
     97  1.1     soda #ifdef _KERNEL
     98  1.1     soda 	int error;
     99  1.5  tsutsui #endif
    100  1.1     soda 
    101  1.5  tsutsui #ifdef _KERNEL
    102  1.1     soda 	/* Check if some other device has already claimed this port. */
    103  1.1     soda 	if ((error = bus_space_map(sc->sc_iot, sc->sc_read_port, 1, 0,
    104  1.1     soda 	    &sc->sc_read_ioh)) != 0)
    105  1.1     soda 		return error;
    106  1.1     soda 
    107  1.1     soda 	/*
    108  1.1     soda 	 * XXX: We unmap the port because it can and will be used by other
    109  1.1     soda 	 *	devices such as a joystick. We need a better port accounting
    110  1.1     soda 	 *	scheme with read and write ports.
    111  1.1     soda 	 */
    112  1.1     soda 	bus_space_unmap(sc->sc_iot, sc->sc_read_ioh, 1);
    113  1.1     soda #endif
    114  1.1     soda 	return 0;
    115  1.1     soda }
    116  1.1     soda 
    117  1.1     soda /* isapnp_unmap_readport():
    118  1.1     soda  *	Pretend to unmap a previously mapped `read port'.
    119  1.1     soda  */
    120  1.1     soda void
    121  1.6  tsutsui isapnp_unmap_readport(struct isapnp_softc *sc)
    122  1.1     soda {
    123  1.5  tsutsui 
    124  1.5  tsutsui 	/* Do nothing. */
    125  1.1     soda }
    126