Home | History | Annotate | Line # | Download | only in isa
slhci_isa.c revision 1.1
      1  1.1  isaki /*	$NetBSD: slhci_isa.c,v 1.1 2002/08/11 13:17:54 isaki Exp $	*/
      2  1.1  isaki 
      3  1.1  isaki /*
      4  1.1  isaki  * Copyright (c) 2001 Kiyoshi Ikehara. All rights reserved.
      5  1.1  isaki  *
      6  1.1  isaki  * Redistribution and use in source and binary forms, with or without
      7  1.1  isaki  * modification, are permitted provided that the following conditions
      8  1.1  isaki  * are met:
      9  1.1  isaki  * 1. Redistributions of source code must retain the above copyright
     10  1.1  isaki  *    notice, this list of conditions and the following disclaimer.
     11  1.1  isaki  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  isaki  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  isaki  *    documentation and/or other materials provided with the distribution.
     14  1.1  isaki  * 3. All advertising materials mentioning features or use of this software
     15  1.1  isaki  *    must display the following acknowledgement:
     16  1.1  isaki  *      This product includes software developed by Kiyoshi Ikehara.
     17  1.1  isaki  * 4. The name of the author may not be used to endorse or promote products
     18  1.1  isaki  *    derived from this software without specific prior written permission
     19  1.1  isaki  *
     20  1.1  isaki  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1  isaki  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1  isaki  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1  isaki  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1  isaki  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     25  1.1  isaki  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     26  1.1  isaki  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     27  1.1  isaki  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     28  1.1  isaki  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     29  1.1  isaki  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     30  1.1  isaki  * SUCH DAMAGE.
     31  1.1  isaki  */
     32  1.1  isaki 
     33  1.1  isaki /*
     34  1.1  isaki  * ISA-USB host board
     35  1.1  isaki  */
     36  1.1  isaki 
     37  1.1  isaki #include <sys/cdefs.h>
     38  1.1  isaki __KERNEL_RCSID(0, "$NetBSD: slhci_isa.c,v 1.1 2002/08/11 13:17:54 isaki Exp $");
     39  1.1  isaki 
     40  1.1  isaki #include <sys/param.h>
     41  1.1  isaki #include <sys/systm.h>
     42  1.1  isaki #include <sys/device.h>
     43  1.1  isaki 
     44  1.1  isaki #include <machine/bus.h>
     45  1.1  isaki #include <machine/cpu.h>
     46  1.1  isaki 
     47  1.1  isaki #include <dev/usb/usb.h>
     48  1.1  isaki #include <dev/usb/usbdi.h>
     49  1.1  isaki #include <dev/usb/usbdivar.h>
     50  1.1  isaki 
     51  1.1  isaki #include <dev/ic/sl811hsreg.h>
     52  1.1  isaki #include <dev/ic/sl811hsvar.h>
     53  1.1  isaki 
     54  1.1  isaki #include <dev/isa/isavar.h>
     55  1.1  isaki 
     56  1.1  isaki struct slhci_isa_softc {
     57  1.1  isaki 	struct slhci_softc sc;
     58  1.1  isaki 	isa_chipset_tag_t sc_ic;
     59  1.1  isaki 	void	*sc_ih;
     60  1.1  isaki };
     61  1.1  isaki 
     62  1.1  isaki static int  slhci_isa_match(struct device *, struct cfdata *, void *);
     63  1.1  isaki static void slhci_isa_attach(struct device *, struct device *, void *);
     64  1.1  isaki 
     65  1.1  isaki struct cfattach slhci_isa_ca = {
     66  1.1  isaki 	sizeof(struct slhci_isa_softc), slhci_isa_match, slhci_isa_attach
     67  1.1  isaki };
     68  1.1  isaki 
     69  1.1  isaki static int
     70  1.1  isaki slhci_isa_match(struct device *parent, struct cfdata *cf, void *aux)
     71  1.1  isaki {
     72  1.1  isaki 	struct slhci_softc sc;
     73  1.1  isaki 	struct isa_attach_args *ia = aux;
     74  1.1  isaki 	bus_space_tag_t iot = ia->ia_iot;
     75  1.1  isaki 	bus_space_handle_t ioh;
     76  1.1  isaki 	int result = 0;
     77  1.1  isaki 
     78  1.1  isaki 	if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh))
     79  1.1  isaki 		goto out;
     80  1.1  isaki 
     81  1.1  isaki 	memset(&sc, 0, sizeof(sc));
     82  1.1  isaki 	sc.sc_iot = iot;
     83  1.1  isaki 	sc.sc_ioh = ioh;
     84  1.1  isaki 	if (sl811hs_find(&sc) >= 0)
     85  1.1  isaki 		result = 1;
     86  1.1  isaki 
     87  1.1  isaki 	bus_space_unmap(iot, ioh, SL11_PORTSIZE);
     88  1.1  isaki 
     89  1.1  isaki  out:
     90  1.1  isaki 	return (result);
     91  1.1  isaki }
     92  1.1  isaki 
     93  1.1  isaki static void
     94  1.1  isaki slhci_isa_attach(struct device *parent, struct device *self, void *aux)
     95  1.1  isaki {
     96  1.1  isaki 	struct slhci_isa_softc *isc = (struct slhci_isa_softc *)self;
     97  1.1  isaki 	struct slhci_softc *sc = &isc->sc;
     98  1.1  isaki 	struct isa_attach_args *ia = aux;
     99  1.1  isaki 	bus_space_tag_t iot = ia->ia_iot;
    100  1.1  isaki 	bus_space_handle_t ioh;
    101  1.1  isaki 
    102  1.1  isaki 	printf("\n");
    103  1.1  isaki 
    104  1.1  isaki 	/* Map I/O space */
    105  1.1  isaki 	if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh)) {
    106  1.1  isaki 		printf("%s: can't map I/O space\n",
    107  1.1  isaki 			sc->sc_bus.bdev.dv_xname);
    108  1.1  isaki 		return;
    109  1.1  isaki 	}
    110  1.1  isaki 
    111  1.1  isaki 	/* Initialize sc */
    112  1.1  isaki 	sc->sc_iot = iot;
    113  1.1  isaki 	sc->sc_ioh = ioh;
    114  1.1  isaki 	sc->sc_dmat = ia->ia_dmat;
    115  1.1  isaki 	sc->sc_enable_power = NULL;
    116  1.1  isaki 	sc->sc_enable_intr  = NULL;
    117  1.1  isaki 	sc->sc_arg = isc;
    118  1.1  isaki 
    119  1.1  isaki 	/* Establish the interrupt handler */
    120  1.1  isaki 	isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
    121  1.1  isaki 					IST_EDGE, IPL_USB, slhci_intr, sc);
    122  1.1  isaki 	if (isc->sc_ih == NULL) {
    123  1.1  isaki 		printf("%s: can't establish interrupt\n",
    124  1.1  isaki 			sc->sc_bus.bdev.dv_xname);
    125  1.1  isaki 		return;
    126  1.1  isaki 	}
    127  1.1  isaki 
    128  1.1  isaki 	/* Attach SL811HS/T */
    129  1.1  isaki 	if (slhci_attach(sc, self))
    130  1.1  isaki 		return;
    131  1.1  isaki }
    132