slhci_isa.c revision 1.3 1 1.3 thorpej /* $NetBSD: slhci_isa.c,v 1.3 2002/10/02 02:09:20 thorpej 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.3 thorpej __KERNEL_RCSID(0, "$NetBSD: slhci_isa.c,v 1.3 2002/10/02 02:09:20 thorpej 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.3 thorpej CFATTACH_DECL(slhci_isa, sizeof(struct slhci_isa_softc),
66 1.3 thorpej slhci_isa_match, slhci_isa_attach, NULL, NULL);
67 1.1 isaki
68 1.1 isaki static int
69 1.1 isaki slhci_isa_match(struct device *parent, struct cfdata *cf, void *aux)
70 1.1 isaki {
71 1.1 isaki struct slhci_softc sc;
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.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.1 isaki memset(&sc, 0, sizeof(sc));
81 1.1 isaki sc.sc_iot = iot;
82 1.1 isaki sc.sc_ioh = ioh;
83 1.1 isaki if (sl811hs_find(&sc) >= 0)
84 1.1 isaki result = 1;
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.1 isaki slhci_isa_attach(struct device *parent, struct device *self, void *aux)
94 1.1 isaki {
95 1.1 isaki struct slhci_isa_softc *isc = (struct slhci_isa_softc *)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.1 isaki printf("\n");
102 1.1 isaki
103 1.1 isaki /* Map I/O space */
104 1.1 isaki if (bus_space_map(iot, ia->ia_io[0].ir_addr, SL11_PORTSIZE, 0, &ioh)) {
105 1.1 isaki printf("%s: can't map I/O space\n",
106 1.1 isaki sc->sc_bus.bdev.dv_xname);
107 1.1 isaki return;
108 1.1 isaki }
109 1.1 isaki
110 1.1 isaki /* Initialize sc */
111 1.1 isaki sc->sc_iot = iot;
112 1.1 isaki sc->sc_ioh = ioh;
113 1.1 isaki sc->sc_dmat = ia->ia_dmat;
114 1.1 isaki sc->sc_enable_power = NULL;
115 1.1 isaki sc->sc_enable_intr = NULL;
116 1.1 isaki sc->sc_arg = isc;
117 1.1 isaki
118 1.1 isaki /* Establish the interrupt handler */
119 1.1 isaki isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
120 1.1 isaki IST_EDGE, IPL_USB, slhci_intr, sc);
121 1.1 isaki if (isc->sc_ih == NULL) {
122 1.1 isaki printf("%s: can't establish interrupt\n",
123 1.1 isaki sc->sc_bus.bdev.dv_xname);
124 1.1 isaki return;
125 1.1 isaki }
126 1.1 isaki
127 1.1 isaki /* Attach SL811HS/T */
128 1.1 isaki if (slhci_attach(sc, self))
129 1.1 isaki return;
130 1.1 isaki }
131