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