isa_machdep.c revision 1.42 1 1.42 thorpej /* $NetBSD: isa_machdep.c,v 1.42 2021/04/24 23:36:30 thorpej Exp $ */
2 1.1 leo
3 1.1 leo /*
4 1.1 leo * Copyright (c) 1997 Leo Weppelman. All rights reserved.
5 1.1 leo * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
6 1.10 mycroft * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
7 1.1 leo *
8 1.1 leo * Redistribution and use in source and binary forms, with or without
9 1.1 leo * modification, are permitted provided that the following conditions
10 1.1 leo * are met:
11 1.1 leo * 1. Redistributions of source code must retain the above copyright
12 1.1 leo * notice, this list of conditions and the following disclaimer.
13 1.1 leo * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 leo * notice, this list of conditions and the following disclaimer in the
15 1.1 leo * documentation and/or other materials provided with the distribution.
16 1.1 leo * 3. All advertising materials mentioning features or use of this software
17 1.1 leo * must display the following acknowledgement:
18 1.10 mycroft * This product includes software developed by Charles M. Hannum.
19 1.1 leo * 4. The name of the author may not be used to endorse or promote products
20 1.1 leo * derived from this software without specific prior written permission.
21 1.1 leo *
22 1.1 leo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 leo * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 leo * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 leo * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 leo * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 leo * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 leo * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 leo * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 leo * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 leo * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 leo */
33 1.27 lukem
34 1.27 lukem #include <sys/cdefs.h>
35 1.42 thorpej __KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.42 2021/04/24 23:36:30 thorpej Exp $");
36 1.1 leo
37 1.1 leo #include <sys/types.h>
38 1.1 leo #include <sys/param.h>
39 1.1 leo #include <sys/systm.h>
40 1.1 leo #include <sys/device.h>
41 1.1 leo
42 1.21 leo #define _ATARI_BUS_DMA_PRIVATE
43 1.39 dyoung #include <sys/bus.h>
44 1.1 leo #include <dev/isa/isavar.h>
45 1.1 leo #include <dev/isa/isareg.h>
46 1.1 leo
47 1.23 leo #include "pckbc.h"
48 1.23 leo #if (NPCKBC > 0)
49 1.23 leo #include <dev/ic/pckbcvar.h>
50 1.23 leo #include <dev/ic/i8042reg.h>
51 1.23 leo #endif /* NPCKBC > 0 */
52 1.23 leo
53 1.1 leo #include <machine/iomap.h>
54 1.1 leo #include <machine/mfp.h>
55 1.1 leo #include <atari/atari/device.h>
56 1.1 leo
57 1.21 leo #include "isadma.h"
58 1.21 leo
59 1.21 leo #if NISADMA == 0
60 1.21 leo
61 1.21 leo /*
62 1.21 leo * Entry points for ISA DMA while no DMA capable devices are attached.
63 1.21 leo * This must be a serious error. Cause a panic...
64 1.21 leo */
65 1.21 leo struct atari_bus_dma_tag isa_bus_dma_tag = {
66 1.21 leo 0
67 1.21 leo };
68 1.21 leo #endif /* NISADMA == 0 */
69 1.21 leo
70 1.38 tsutsui static int atariisabusprint(void *, const char *);
71 1.38 tsutsui static int isabusmatch(device_t, cfdata_t, void *);
72 1.38 tsutsui static void isabusattach(device_t, device_t, void *);
73 1.1 leo
74 1.8 thorpej struct isabus_softc {
75 1.38 tsutsui device_t sc_dev;
76 1.8 thorpej struct atari_isa_chipset sc_chipset;
77 1.8 thorpej };
78 1.8 thorpej
79 1.38 tsutsui CFATTACH_DECL_NEW(isab, sizeof(struct isabus_softc),
80 1.25 thorpej isabusmatch, isabusattach, NULL, NULL);
81 1.1 leo
82 1.23 leo /*
83 1.23 leo * We need some static storage to attach a console keyboard on the Milan
84 1.23 leo * during early console init.
85 1.23 leo */
86 1.23 leo static struct atari_bus_space bs_storage[2]; /* 1 iot, 1 memt */
87 1.23 leo
88 1.1 leo int
89 1.38 tsutsui isabusmatch(device_t parent, cfdata_t cf, void *aux)
90 1.1 leo {
91 1.20 leo static int nmatched = 0;
92 1.20 leo
93 1.38 tsutsui if (strcmp((char *)aux, "isab"))
94 1.37 tsutsui return 0; /* Wrong number... */
95 1.20 leo
96 1.37 tsutsui if (atari_realconfig == 0)
97 1.37 tsutsui return 1;
98 1.20 leo
99 1.20 leo if (machineid & (ATARI_HADES|ATARI_MILAN)) {
100 1.20 leo /*
101 1.20 leo * The Hades and Milan have only one pci bus
102 1.20 leo */
103 1.20 leo if (nmatched)
104 1.37 tsutsui return 0;
105 1.20 leo nmatched++;
106 1.37 tsutsui return 1;
107 1.20 leo }
108 1.37 tsutsui return 0;
109 1.1 leo }
110 1.1 leo
111 1.1 leo void
112 1.38 tsutsui isabusattach(device_t parent, device_t self, void *aux)
113 1.1 leo {
114 1.41 tsutsui struct isabus_softc *sc;
115 1.1 leo struct isabus_attach_args iba;
116 1.21 leo extern struct atari_bus_dma_tag isa_bus_dma_tag;
117 1.22 leo extern void isa_bus_init(void);
118 1.1 leo
119 1.21 leo iba.iba_dmat = &isa_bus_dma_tag;
120 1.23 leo iba.iba_iot = leb_alloc_bus_space_tag(&bs_storage[0]);
121 1.23 leo iba.iba_memt = leb_alloc_bus_space_tag(&bs_storage[1]);
122 1.5 leo if ((iba.iba_iot == NULL) || (iba.iba_memt == NULL)) {
123 1.5 leo printf("leb_alloc_bus_space_tag failed!\n");
124 1.5 leo return;
125 1.5 leo }
126 1.5 leo iba.iba_iot->base = ISA_IOSTART;
127 1.5 leo iba.iba_memt->base = ISA_MEMSTART;
128 1.1 leo
129 1.22 leo if (machineid & ATARI_HADES)
130 1.22 leo MFP->mf_aer |= (IO_ISA1|IO_ISA2); /* ISA interrupts: LOW->HIGH */
131 1.22 leo isa_bus_init();
132 1.38 tsutsui if (self == NULL) { /* Early init */
133 1.23 leo #if (NPCKBC > 0)
134 1.40 jdc pckbc_cnattach(iba.iba_iot, IO_KBD, KBCMDP, PCKBC_KBD_SLOT, 0);
135 1.23 leo #endif
136 1.23 leo return;
137 1.23 leo }
138 1.1 leo
139 1.41 tsutsui sc = device_private(self);
140 1.41 tsutsui sc->sc_dev = self;
141 1.41 tsutsui iba.iba_ic = &sc->sc_chipset;
142 1.41 tsutsui
143 1.1 leo printf("\n");
144 1.42 thorpej config_found(self, &iba, atariisabusprint, CFARG_EOL);
145 1.1 leo }
146 1.1 leo
147 1.1 leo int
148 1.38 tsutsui atariisabusprint(void *aux, const char *name)
149 1.1 leo {
150 1.37 tsutsui
151 1.37 tsutsui if (name == NULL)
152 1.37 tsutsui return UNCONF;
153 1.37 tsutsui return QUIET;
154 1.1 leo }
155 1.1 leo
156 1.1 leo void
157 1.38 tsutsui isa_attach_hook(device_t parent, device_t self, struct isabus_attach_args *iba)
158 1.1 leo {
159 1.1 leo }
160 1.1 leo
161 1.34 dyoung void
162 1.36 mrg isa_detach_hook(isa_chipset_tag_t ic, device_t self)
163 1.34 dyoung {
164 1.34 dyoung }
165 1.34 dyoung
166 1.17 cgd const struct evcnt *
167 1.17 cgd isa_intr_evcnt(isa_chipset_tag_t ic, int irq)
168 1.17 cgd {
169 1.17 cgd
170 1.17 cgd /* XXX for now, no evcnt parent reported */
171 1.17 cgd return NULL;
172 1.1 leo }
173