gscbus.c revision 1.2 1 /* $NetBSD: gscbus.c,v 1.2 2021/04/24 23:36:39 thorpej Exp $ */
2
3 /* $OpenBSD: gscbus.c,v 1.13 2001/08/01 20:32:04 miod Exp $ */
4
5 /*
6 * Copyright (c) 1998 Michael Shalayeff
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 /*
32 * Sample IO layouts:
33 * 712:
34 *
35 * f0100000 -- lasi0
36 * f0102000 -- lpt0
37 * f0104000 -- audio0
38 * f0105000 -- com0
39 * f0106000 -- siop0
40 * f0107000 -- ie0
41 * f0108000 -- kbd0
42 * f0108100 -- pms0
43 * f010a000 -- fdc0
44 * f010c000 -- *lasi0
45 * f0200000 -- wax0
46 * f8000000 -- sti0
47 * fffbe000 -- cpu0
48 * fffbf000 -- mem0
49 *
50 * 725/50:
51 *
52 * f0820000 -- dma
53 * f0821000 -- hil
54 * f0822000 -- com1
55 * f0823000 -- com0
56 * f0824000 -- lpt0
57 * f0825000 -- siop0
58 * f0826000 -- ie0
59 * f0827000 -- dma reset
60 * f0828000 -- timers
61 * f0829000 -- domain kbd
62 * f082f000 -- asp0
63 * f1000000 -- audio0
64 * fc000000 -- eisa0
65 * fffbe000 -- cpu0
66 * fffbf000 -- mem0
67 *
68 */
69
70 #include <sys/cdefs.h>
71 __KERNEL_RCSID(0, "$NetBSD: gscbus.c,v 1.2 2021/04/24 23:36:39 thorpej Exp $");
72
73 #define GSCDEBUG
74
75 #include "opt_kgdb.h"
76
77 #include <sys/param.h>
78 #include <sys/systm.h>
79 #include <sys/device.h>
80 #include <sys/malloc.h>
81 #include <sys/mbuf.h>
82 #include <sys/reboot.h>
83
84 #include <machine/iomod.h>
85 #include <machine/autoconf.h>
86 #include <machine/cpufunc.h>
87
88 #include <hppa/gsc/gscbusvar.h>
89 #include <hppa/hppa/machdep.h>
90
91 int gscmatch(device_t, cfdata_t, void *);
92 void gscattach(device_t, device_t, void *);
93
94 struct gsc_softc {
95 device_t sc_dev;
96 struct gsc_attach_args sc_ga;
97 void *sc_ih;
98 };
99
100 CFATTACH_DECL_NEW(gsc, sizeof(struct gsc_softc),
101 gscmatch, gscattach, NULL, NULL);
102
103 /*
104 * pdc_scanbus calls this function back with each module
105 * it finds on the GSC bus. We call the IC-specific function
106 * to fix up the module's attach arguments, then we match
107 * and attach it.
108 */
109 static device_t gsc_module_callback(device_t, struct confargs *);
110 static device_t
111 gsc_module_callback(device_t self, struct confargs *ca)
112 {
113 struct gsc_softc *sc = device_private(self);
114 struct gsc_attach_args ga;
115
116 /* Make the GSC attach args. */
117 ga = sc->sc_ga;
118 ga.ga_ca = *ca;
119 ga.ga_iot = sc->sc_ga.ga_iot;
120 ga.ga_dmatag = sc->sc_ga.ga_dmatag;
121 (*sc->sc_ga.ga_fix_args)(sc->sc_ga.ga_fix_args_cookie, &ga);
122
123 return config_found(self, &ga, mbprint,
124 CFARG_SUBMATCH, mbsubmatch,
125 CFARG_EOL);
126 }
127
128 int
129 gscmatch(device_t parent, cfdata_t cf, void *aux)
130 {
131 struct gsc_attach_args *ga = aux;
132
133 return !strcmp(ga->ga_name, "gsc");
134 }
135
136 void
137 gscattach(device_t parent, device_t self, void *aux)
138 {
139 struct gsc_softc *sc = device_private(self);
140 struct gsc_attach_args *ga = aux;
141 struct cpu_info *ci = &cpus[0];
142
143 sc->sc_dev = self;
144 sc->sc_ga = *ga;
145
146 #ifdef USELEDS
147 if (machine_ledaddr)
148 aprint_normal(": %sleds", machine_ledword? "word" : "");
149 #endif
150
151 aprint_normal("\n");
152
153 /* Add the I/O subsystem's interrupt register. */
154 ga->ga_ir->ir_name = device_xname(self);
155 sc->sc_ih = hppa_intr_establish(IPL_NONE, NULL, ga->ga_ir,
156 &ci->ci_ir, ga->ga_irq);
157
158 ga->ga_ca.ca_nmodules = MAXMODBUS;
159 ga->ga_ca.ca_hpabase = 0;
160 pdc_scanbus(self, &ga->ga_ca, gsc_module_callback);
161 }
162
163 int
164 gscprint(void *aux, const char *pnp)
165 {
166
167 return (UNCONF);
168 }
169