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