Home | History | Annotate | Line # | Download | only in isa
slhci_isa.c revision 1.9
      1  1.9  drochner /*	$NetBSD: slhci_isa.c,v 1.9 2008/03/28 17:14:45 drochner 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.9  drochner __KERNEL_RCSID(0, "$NetBSD: slhci_isa.c,v 1.9 2008/03/28 17:14:45 drochner 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.8        ad #include <sys/bus.h>
     45  1.8        ad #include <sys/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.9  drochner CFATTACH_DECL_NEW(slhci_isa, sizeof(struct slhci_isa_softc),
     66  1.7  kiyohara     slhci_isa_match, slhci_isa_attach, NULL, slhci_activate);
     67  1.1     isaki 
     68  1.1     isaki static int
     69  1.6  christos slhci_isa_match(struct device *parent, struct cfdata *cf,
     70  1.5  christos     void *aux)
     71  1.1     isaki {
     72  1.1     isaki 	struct isa_attach_args *ia = aux;
     73  1.1     isaki 	bus_space_tag_t iot = ia->ia_iot;
     74  1.1     isaki 	bus_space_handle_t ioh;
     75  1.1     isaki 	int result = 0;
     76  1.7  kiyohara 	uint8_t sltype;
     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.7  kiyohara 	bus_space_write_1(iot, ioh, SL11_IDX_ADDR, SL11_REV);
     82  1.7  kiyohara 	sltype = SL11_GET_REV(bus_space_read_1(iot, ioh, SL11_IDX_DATA));
     83  1.7  kiyohara 
     84  1.7  kiyohara 	result = slhci_supported_rev(sltype);
     85  1.1     isaki 
     86  1.1     isaki 	bus_space_unmap(iot, ioh, SL11_PORTSIZE);
     87  1.1     isaki 
     88  1.1     isaki  out:
     89  1.1     isaki 	return (result);
     90  1.1     isaki }
     91  1.1     isaki 
     92  1.1     isaki static void
     93  1.6  christos slhci_isa_attach(struct device *parent, struct device *self, void *aux)
     94  1.1     isaki {
     95  1.9  drochner 	struct slhci_isa_softc *isc = device_private(self);
     96  1.1     isaki 	struct slhci_softc *sc = &isc->sc;
     97  1.1     isaki 	struct isa_attach_args *ia = aux;
     98  1.1     isaki 	bus_space_tag_t iot = ia->ia_iot;
     99  1.1     isaki 	bus_space_handle_t ioh;
    100  1.1     isaki 
    101  1.9  drochner 	sc->sc_dev = self;
    102  1.9  drochner 	sc->sc_bus.hci_private = self;
    103  1.9  drochner 
    104  1.7  kiyohara 	printf("\n"); /* XXX still needed? */
    105  1.1     isaki 
    106  1.1     isaki 	/* Map I/O space */
    107  1.1     isaki 	if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh)) {
    108  1.7  kiyohara 		printf("%s: can't map I/O space\n", SC_NAME(sc));
    109  1.1     isaki 		return;
    110  1.1     isaki 	}
    111  1.1     isaki 
    112  1.7  kiyohara 	/* Initialize sc XXX power value unconfirmed */
    113  1.7  kiyohara 	slhci_preinit(sc, NULL, iot, ioh, 30, SL11_IDX_DATA);
    114  1.1     isaki 
    115  1.1     isaki 	/* Establish the interrupt handler */
    116  1.1     isaki 	isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
    117  1.1     isaki 					IST_EDGE, IPL_USB, slhci_intr, sc);
    118  1.1     isaki 	if (isc->sc_ih == NULL) {
    119  1.7  kiyohara 		printf("%s: can't establish interrupt\n", SC_NAME(sc));
    120  1.1     isaki 		return;
    121  1.1     isaki 	}
    122  1.1     isaki 
    123  1.1     isaki 	/* Attach SL811HS/T */
    124  1.7  kiyohara 	if (slhci_attach(sc))
    125  1.7  kiyohara 		printf("%s: slhci_attach failed\n", SC_NAME(sc));
    126  1.1     isaki }
    127