1 /* $NetBSD: ioasic.c,v 1.18 2009/03/14 21:04:14 dsl Exp $ */
4 * Copyright (c) 1994, 1995 Carnegie-Mellon University.
7 * Author: Keith Bostic, Chris G. Demetriou, Jonathan Stone
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
31 __KERNEL_RCSID(0, "$NetBSD: ioasic.c,v 1.18 2009/03/14 21:04:14 dsl Exp $");
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/device.h>
37 #include <dev/tc/tcvar.h>
38 #include <dev/tc/ioasicreg.h>
39 #include <dev/tc/ioasicvar.h>
41 #include <machine/sysconf.h>
43 #include <pmax/pmax/pmaxtype.h>
44 #include <pmax/pmax/kmin.h>
45 #include <pmax/pmax/maxine.h>
46 #include <pmax/pmax/kn03.h>
48 #include "opt_dec_3min.h"
49 #include "opt_dec_maxine.h"
50 #include "opt_dec_3maxplus.h"
52 #define ARRAY_SIZEOF(x) (sizeof((x)) / sizeof((x)[0]))
55 static struct ioasic_dev kmin_ioasic_devs
[] = {
56 { "PMAD-BA ", 0x0C0000, C(SYS_DEV_LANCE
), },
57 { "scc", 0x100000, C(SYS_DEV_SCC0
), },
58 { "scc", 0x180000, C(SYS_DEV_SCC1
), },
59 { "mc146818", 0x200000, C(SYS_DEV_BOGUS
), },
60 { "asc", 0x300000, C(SYS_DEV_SCSI
), },
62 static int kmin_builtin_ndevs
= ARRAY_SIZEOF(kmin_ioasic_devs
);
63 static int kmin_ioasic_ndevs
= ARRAY_SIZEOF(kmin_ioasic_devs
);
66 #if defined(DEC_MAXINE)
67 static struct ioasic_dev xine_ioasic_devs
[] = {
68 { "PMAD-BA ", 0x0C0000, C(SYS_DEV_LANCE
), },
69 { "scc", 0x100000, C(SYS_DEV_SCC0
), },
70 { "mc146818", 0x200000, C(SYS_DEV_BOGUS
), },
71 { "isdn", 0x240000, C(SYS_DEV_ISDN
), },
72 { "dtop", 0x280000, C(SYS_DEV_DTOP
), },
73 { "fdc", 0x2C0000, C(SYS_DEV_FDC
), },
74 { "asc", 0x300000, C(SYS_DEV_SCSI
), },
75 { "(TC0)", 0x0, C(SYS_DEV_OPT0
), },
76 { "(TC1)", 0x0, C(SYS_DEV_OPT1
), },
77 { "(TC2)", 0x0, C(SYS_DEV_OPT2
), },
79 static int xine_builtin_ndevs
= ARRAY_SIZEOF(xine_ioasic_devs
) - 3;
80 static int xine_ioasic_ndevs
= ARRAY_SIZEOF(xine_ioasic_devs
);
83 #if defined(DEC_3MAXPLUS)
84 static struct ioasic_dev kn03_ioasic_devs
[] = {
85 { "PMAD-BA ", 0x0C0000, C(SYS_DEV_LANCE
), },
86 { "z8530 ", 0x100000, C(SYS_DEV_SCC0
), },
87 { "z8530 ", 0x180000, C(SYS_DEV_SCC1
), },
88 { "mc146818", 0x200000, C(SYS_DEV_BOGUS
), },
89 { "asc", 0x300000, C(SYS_DEV_SCSI
), },
90 { "(TC0)", 0x0, C(SYS_DEV_OPT0
), },
91 { "(TC1)", 0x0, C(SYS_DEV_OPT1
), },
92 { "(TC2)", 0x0, C(SYS_DEV_OPT2
), },
94 static int kn03_builtin_ndevs
= ARRAY_SIZEOF(kn03_ioasic_devs
) - 3;
95 static int kn03_ioasic_ndevs
= ARRAY_SIZEOF(kn03_ioasic_devs
);
98 static int ioasicmatch(struct device
*, struct cfdata
*, void *);
99 static void ioasicattach(struct device
*, struct device
*, void *);
101 CFATTACH_DECL(ioasic
, sizeof(struct ioasic_softc
),
102 ioasicmatch
, ioasicattach
, NULL
, NULL
);
104 tc_addr_t ioasic_base
; /* XXX XXX XXX */
106 /* There can be only one. */
110 ioasicmatch(struct device
*parent
, struct cfdata
*cfdata
, void *aux
)
112 struct tc_attach_args
*ta
= aux
;
114 /* Make sure that we're looking for this type of device. */
115 if (strncmp("IOCTL ", ta
->ta_modname
, TC_ROM_LLEN
))
125 ioasicattach(struct device
*parent
, struct device
*self
, void *aux
)
127 struct ioasic_softc
*sc
= (struct ioasic_softc
*)self
;
128 struct tc_attach_args
*ta
= aux
;
129 struct ioasic_dev
*ioasic_devs
;
130 int ioasic_ndevs
, builtin_ndevs
;
134 sc
->sc_bst
= ta
->ta_memt
;
135 if (bus_space_map(ta
->ta_memt
, ta
->ta_addr
,
136 0x400000, 0, &sc
->sc_bsh
)) {
137 printf("%s: unable to map device\n", sc
->sc_dv
.dv_xname
);
140 sc
->sc_dmat
= ta
->ta_dmat
;
142 sc
->sc_base
= ta
->ta_addr
; /* XXX XXX XXX */
147 #if defined(DEC_3MIN)
149 ioasic_devs
= kmin_ioasic_devs
;
150 ioasic_ndevs
= kmin_ioasic_ndevs
;
151 builtin_ndevs
= kmin_builtin_ndevs
;
154 #if defined(DEC_MAXINE)
156 ioasic_devs
= xine_ioasic_devs
;
157 ioasic_ndevs
= xine_ioasic_ndevs
;
158 builtin_ndevs
= xine_builtin_ndevs
;
161 #if defined(DEC_3MAXPLUS)
163 ioasic_devs
= kn03_ioasic_devs
;
164 ioasic_ndevs
= kn03_ioasic_ndevs
;
165 builtin_ndevs
= kn03_builtin_ndevs
;
169 panic("ioasicmatch: how did we get here?");
172 #if 0 /* IMSK has been sanitized */
174 * Turn off all device interrupt bits.
175 * (This _does_ include TC option slot bits.)
177 imsk
= bus_space_read_4(sc
->sc_bst
, sc
->sc_bsh
, IOASIC_IMSK
);
178 for (i
= 0; i
< ioasic_ndevs
; i
++)
179 imsk
&= ~ioasic_devs
[i
].iad_intrbits
;
180 bus_space_write_4(sc
->sc_bst
, sc
->sc_bsh
, IOASIC_IMSK
, imsk
);
184 * Try to configure each device.
186 ioasic_attach_devs(sc
, ioasic_devs
, builtin_ndevs
);
190 ioasic_intr_evcnt(struct device
*dev
, void *cookie
)
193 /* XXX for now, no evcnt parent reported */
198 ioasic_intr_establish(struct device
*dev
, void *cookie
, int level
, int (*handler
)(void *), void *val
)
200 (*platform
.intr_establish
)(dev
, cookie
, level
, handler
, val
);