gayle_pcmcia.c revision 1.3 1 1.3 mrg /* $NetBSD: gayle_pcmcia.c,v 1.3 2000/06/26 14:20:30 mrg Exp $ */
2 1.1 aymeric
3 1.1 aymeric /* PCMCIA front-end driver for A1200's and A600's. */
4 1.1 aymeric
5 1.1 aymeric #include <sys/param.h>
6 1.1 aymeric #include <sys/cdefs.h>
7 1.1 aymeric #include <sys/device.h>
8 1.1 aymeric #include <sys/kernel.h>
9 1.1 aymeric #include <sys/kthread.h>
10 1.1 aymeric #include <sys/systm.h>
11 1.1 aymeric
12 1.1 aymeric #include <vm/vm.h>
13 1.3 mrg
14 1.1 aymeric #include <uvm/uvm.h>
15 1.3 mrg
16 1.1 aymeric #include <dev/pcmcia/pcmciareg.h>
17 1.1 aymeric #include <dev/pcmcia/pcmciavar.h>
18 1.1 aymeric
19 1.1 aymeric #include <machine/cpu.h>
20 1.1 aymeric #include <amiga/amiga/custom.h>
21 1.1 aymeric #include <amiga/amiga/device.h>
22 1.1 aymeric #include <amiga/amiga/gayle.h>
23 1.1 aymeric #include <amiga/amiga/isr.h>
24 1.1 aymeric
25 1.1 aymeric
26 1.1 aymeric /*
27 1.1 aymeric * There is one of these for each slot. This is useless since we have only one,
28 1.1 aymeric * but it makes it clearer if someone wants to understand better the NetBSD
29 1.1 aymeric * device drivers scheme.
30 1.1 aymeric */
31 1.1 aymeric struct pccard_slot {
32 1.1 aymeric struct pccard_softc *sc; /* refer to `parent' */
33 1.1 aymeric int (*intr_func)(void *);
34 1.1 aymeric void * intr_arg;
35 1.1 aymeric struct device *card;
36 1.1 aymeric int flags;
37 1.1 aymeric #define SLOT_OCCUPIED 0x01
38 1.1 aymeric #define SLOT_NEW_CARD_EVENT 0x02
39 1.1 aymeric };
40 1.1 aymeric
41 1.1 aymeric struct pccard_softc {
42 1.1 aymeric struct device sc_dev;
43 1.1 aymeric struct bus_space_tag io_space;
44 1.1 aymeric struct bus_space_tag attr_space;
45 1.1 aymeric struct bus_space_tag mem_space;
46 1.1 aymeric struct pccard_slot devs[1];
47 1.1 aymeric struct isr intr6;
48 1.1 aymeric struct isr intr2;
49 1.1 aymeric };
50 1.1 aymeric
51 1.1 aymeric static int pccard_probe __P((struct device *, struct cfdata *, void *));
52 1.1 aymeric static void pccard_attach __P((struct device *, struct device *, void *));
53 1.1 aymeric static void pccard_attach_slot __P((struct pccard_slot *));
54 1.1 aymeric static int pccard_intr6 __P((void *));
55 1.1 aymeric static int pccard_intr2 __P((void *));
56 1.1 aymeric static void pccard_create_kthread __P((void *));
57 1.1 aymeric static void pccard_kthread __P((void *));
58 1.1 aymeric
59 1.1 aymeric static int pcf_mem_alloc __P((pcmcia_chipset_handle_t, bus_size_t,
60 1.1 aymeric struct pcmcia_mem_handle *));
61 1.1 aymeric static void pcf_mem_free __P((pcmcia_chipset_handle_t,
62 1.1 aymeric struct pcmcia_mem_handle *));
63 1.1 aymeric static int pcf_mem_map __P((pcmcia_chipset_handle_t, int, bus_addr_t,
64 1.1 aymeric bus_size_t, struct pcmcia_mem_handle *, bus_addr_t *, int *));
65 1.1 aymeric static void pcf_mem_unmap __P((pcmcia_chipset_handle_t, int));
66 1.1 aymeric static int pcf_io_alloc __P((pcmcia_chipset_handle_t, bus_addr_t, bus_size_t,
67 1.1 aymeric bus_size_t, struct pcmcia_io_handle *));
68 1.1 aymeric static void pcf_io_free __P((pcmcia_chipset_handle_t,
69 1.1 aymeric struct pcmcia_io_handle *));
70 1.1 aymeric static int pcf_io_map __P((pcmcia_chipset_handle_t, int, bus_addr_t,
71 1.1 aymeric bus_size_t, struct pcmcia_io_handle *, int *));
72 1.1 aymeric static void pcf_io_unmap __P((pcmcia_chipset_handle_t, int));
73 1.1 aymeric static void *pcf_intr_establish __P((pcmcia_chipset_handle_t,
74 1.1 aymeric struct pcmcia_function *, int, int (*)(void *), void *));
75 1.1 aymeric static void pcf_intr_disestablish __P((pcmcia_chipset_handle_t, void *));
76 1.1 aymeric static void pcf_socket_enable __P((pcmcia_chipset_handle_t));
77 1.1 aymeric static void pcf_socket_disable __P((pcmcia_chipset_handle_t));
78 1.1 aymeric
79 1.1 aymeric static bsr(pcmio_bsr1, u_int8_t);
80 1.1 aymeric static bsw(pcmio_bsw1, u_int8_t);
81 1.1 aymeric static bsrm(pcmio_bsrm1, u_int8_t);
82 1.1 aymeric static bswm(pcmio_bswm1, u_int8_t);
83 1.1 aymeric static bsrm(pcmio_bsrr1, u_int8_t);
84 1.1 aymeric static bswm(pcmio_bswr1, u_int8_t);
85 1.1 aymeric static bssr(pcmio_bssr1, u_int8_t);
86 1.1 aymeric static bscr(pcmio_bscr1, u_int8_t);
87 1.1 aymeric
88 1.1 aymeric static u_int8_t *reset_card_reg;
89 1.1 aymeric
90 1.1 aymeric struct cfattach pccard_ca = {
91 1.1 aymeric sizeof(struct pccard_softc), pccard_probe, pccard_attach
92 1.1 aymeric };
93 1.1 aymeric
94 1.1 aymeric struct pcmcia_chip_functions chip_functions = {
95 1.1 aymeric pcf_mem_alloc, pcf_mem_free,
96 1.1 aymeric pcf_mem_map, pcf_mem_unmap,
97 1.1 aymeric pcf_io_alloc, pcf_io_free,
98 1.1 aymeric pcf_io_map, pcf_io_unmap,
99 1.1 aymeric pcf_intr_establish, pcf_intr_disestablish,
100 1.1 aymeric pcf_socket_enable, pcf_socket_disable
101 1.1 aymeric };
102 1.1 aymeric
103 1.1 aymeric struct amiga_bus_space_methods pcmio_bs_methods;
104 1.1 aymeric
105 1.1 aymeric static int
106 1.1 aymeric pccard_probe(dev, cfd, aux)
107 1.1 aymeric struct device *dev;
108 1.1 aymeric struct cfdata *cfd;
109 1.1 aymeric void *aux;
110 1.1 aymeric {
111 1.1 aymeric return (/*is_a600() || */is_a1200()) && matchname(aux, "pccard");
112 1.1 aymeric }
113 1.1 aymeric
114 1.1 aymeric static void
115 1.1 aymeric pccard_attach(parent, myself, aux)
116 1.1 aymeric struct device *parent, *myself;
117 1.1 aymeric void *aux;
118 1.1 aymeric {
119 1.1 aymeric struct pccard_softc *self = (struct pccard_softc *) myself;
120 1.1 aymeric struct pcmciabus_attach_args paa;
121 1.1 aymeric vaddr_t pcmcia_base = GAYLE_PCMCIA_START;
122 1.1 aymeric vaddr_t i;
123 1.1 aymeric int ret;
124 1.1 aymeric
125 1.1 aymeric printf("\n");
126 1.1 aymeric
127 1.1 aymeric gayle_init();
128 1.1 aymeric
129 1.1 aymeric ret = uvm_map(kernel_map, &pcmcia_base,
130 1.1 aymeric GAYLE_PCMCIA_END - GAYLE_PCMCIA_START, NULL,
131 1.1 aymeric UVM_UNKNOWN_OFFSET, UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE,
132 1.1 aymeric UVM_INH_NONE, UVM_ADV_RANDOM, 0));
133 1.1 aymeric if (ret != KERN_SUCCESS) {
134 1.1 aymeric printf("attach failed (no virtual memory)\n");
135 1.1 aymeric return;
136 1.1 aymeric }
137 1.1 aymeric
138 1.1 aymeric for (i = GAYLE_PCMCIA_START; i < GAYLE_PCMCIA_END; i += PAGE_SIZE)
139 1.1 aymeric pmap_enter(kernel_map->pmap,
140 1.1 aymeric i - GAYLE_PCMCIA_START + pcmcia_base, i,
141 1.1 aymeric VM_PROT_READ | VM_PROT_WRITE, TRUE);
142 1.1 aymeric
143 1.1 aymeric /* override the one-byte access methods for I/O space */
144 1.1 aymeric pcmio_bs_methods = amiga_bus_stride_1;
145 1.1 aymeric pcmio_bs_methods.bsr1 = pcmio_bsr1;
146 1.1 aymeric pcmio_bs_methods.bsw1 = pcmio_bsw1;
147 1.1 aymeric pcmio_bs_methods.bsrm1 = pcmio_bsrm1;
148 1.1 aymeric pcmio_bs_methods.bswm1 = pcmio_bswm1;
149 1.1 aymeric pcmio_bs_methods.bsrr1 = pcmio_bsrr1;
150 1.1 aymeric pcmio_bs_methods.bswr1 = pcmio_bswr1;
151 1.1 aymeric pcmio_bs_methods.bssr1 = pcmio_bssr1;
152 1.1 aymeric pcmio_bs_methods.bscr1 = pcmio_bscr1;
153 1.1 aymeric
154 1.1 aymeric reset_card_reg = (u_int8_t *) pcmcia_base - GAYLE_PCMCIA_START +
155 1.1 aymeric GAYLE_PCMCIA_RESET;
156 1.1 aymeric
157 1.1 aymeric self->io_space.base = (u_int) pcmcia_base - GAYLE_PCMCIA_START +
158 1.1 aymeric GAYLE_PCMCIA_IO_START;
159 1.1 aymeric self->io_space.absm = &pcmio_bs_methods;
160 1.1 aymeric
161 1.1 aymeric self->attr_space.base = (u_int) pcmcia_base - GAYLE_PCMCIA_START +
162 1.1 aymeric GAYLE_PCMCIA_ATTR_START;
163 1.1 aymeric self->attr_space.absm = &amiga_bus_stride_1;
164 1.1 aymeric
165 1.1 aymeric /* XXX should be invalid */
166 1.1 aymeric self->mem_space.base = (u_int) pcmcia_base;
167 1.1 aymeric self->mem_space.absm = &amiga_bus_stride_1;
168 1.1 aymeric
169 1.1 aymeric self->devs[0].sc = self;
170 1.1 aymeric self->devs[0].intr_func = NULL;
171 1.1 aymeric self->devs[0].intr_arg = NULL;
172 1.1 aymeric self->devs[0].flags = 0;
173 1.1 aymeric
174 1.1 aymeric gayle.pcc_status = 0;
175 1.1 aymeric gayle.intreq = 0;
176 1.1 aymeric gayle.pcc_config = 0;
177 1.1 aymeric gayle.intena &= GAYLE_INT_IDE;
178 1.1 aymeric
179 1.1 aymeric paa.paa_busname = "pcmcia";
180 1.1 aymeric paa.pct = &chip_functions;
181 1.1 aymeric paa.pch = &self->devs[0];
182 1.1 aymeric paa.iobase = 0;
183 1.1 aymeric paa.iosize = 0;
184 1.1 aymeric self->devs[0].card =
185 1.1 aymeric config_found_sm(myself, &paa, simple_devprint, NULL);
186 1.1 aymeric if (self->devs[0].card == NULL) {
187 1.1 aymeric printf("attach failed, config_found_sm() returned NULL\n");
188 1.1 aymeric return;
189 1.1 aymeric }
190 1.1 aymeric
191 1.1 aymeric self->intr6.isr_intr = pccard_intr6;
192 1.1 aymeric self->intr6.isr_arg = self;
193 1.1 aymeric self->intr6.isr_ipl = 6;
194 1.1 aymeric add_isr(&self->intr6);
195 1.1 aymeric
196 1.1 aymeric self->intr2.isr_intr = pccard_intr2;
197 1.1 aymeric self->intr2.isr_arg = self;
198 1.1 aymeric self->intr2.isr_ipl = 2;
199 1.1 aymeric add_isr(&self->intr2);
200 1.1 aymeric
201 1.1 aymeric kthread_create(pccard_create_kthread, self);
202 1.1 aymeric
203 1.1 aymeric gayle.intena |= GAYLE_INT_DETECT | GAYLE_INT_IREQ;
204 1.1 aymeric
205 1.1 aymeric /* reset the card if it's already there */
206 1.1 aymeric if (gayle.pcc_status & GAYLE_CCMEM_DETECT) {
207 1.1 aymeric volatile u_int8_t x;
208 1.1 aymeric *reset_card_reg = 0x0;
209 1.1 aymeric delay(1000);
210 1.1 aymeric x = *reset_card_reg;
211 1.1 aymeric gayle.pcc_status = GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR;
212 1.1 aymeric }
213 1.1 aymeric
214 1.1 aymeric pccard_attach_slot(&self->devs[0]);
215 1.1 aymeric }
216 1.1 aymeric
217 1.1 aymeric /* This is called as soon as it is possible to create a kernel thread */
218 1.1 aymeric static void
219 1.1 aymeric pccard_create_kthread(arg)
220 1.1 aymeric void *arg;
221 1.1 aymeric {
222 1.1 aymeric struct pccard_softc *self = arg;
223 1.1 aymeric
224 1.1 aymeric if (kthread_create1(pccard_kthread, self, NULL, "pccard thread")) {
225 1.1 aymeric printf("%s: can't create kernel thread\n",
226 1.1 aymeric self->sc_dev.dv_xname);
227 1.1 aymeric panic("pccard kthread_create() failed");
228 1.1 aymeric }
229 1.1 aymeric }
230 1.1 aymeric
231 1.1 aymeric static int
232 1.1 aymeric pccard_intr6(arg)
233 1.1 aymeric void *arg;
234 1.1 aymeric {
235 1.1 aymeric struct pccard_softc *self = arg;
236 1.1 aymeric
237 1.1 aymeric if (gayle.intreq & GAYLE_INT_DETECT) {
238 1.2 aymeric gayle.intreq = GAYLE_INT_IDE | GAYLE_INT_STSCHG |
239 1.2 aymeric GAYLE_INT_SPKR | GAYLE_INT_WP | GAYLE_INT_IREQ;
240 1.1 aymeric self->devs[0].flags |= SLOT_NEW_CARD_EVENT;
241 1.1 aymeric return 1;
242 1.1 aymeric }
243 1.1 aymeric return 0;
244 1.1 aymeric }
245 1.1 aymeric
246 1.1 aymeric static int
247 1.1 aymeric pccard_intr2(arg)
248 1.1 aymeric void *arg;
249 1.1 aymeric {
250 1.1 aymeric struct pccard_softc *self = arg;
251 1.1 aymeric struct pccard_slot *slot = &self->devs[0];
252 1.1 aymeric
253 1.1 aymeric if (slot->flags & SLOT_NEW_CARD_EVENT) {
254 1.1 aymeric slot->flags &= ~SLOT_NEW_CARD_EVENT;
255 1.1 aymeric
256 1.1 aymeric /* reset the registers */
257 1.1 aymeric gayle.intreq = GAYLE_INT_IDE | GAYLE_INT_DETECT;
258 1.1 aymeric gayle.pcc_status = GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR;
259 1.1 aymeric gayle.pcc_config = 0;
260 1.1 aymeric pccard_attach_slot(&self->devs[0]);
261 1.1 aymeric } else {
262 1.2 aymeric int intreq = gayle.intreq &
263 1.2 aymeric (GAYLE_INT_STSCHG | GAYLE_INT_WP | GAYLE_INT_IREQ);
264 1.2 aymeric if (intreq) {
265 1.2 aymeric gayle.intreq = (intreq ^ 0x2c) | 0xc0;
266 1.1 aymeric
267 1.1 aymeric if (slot->flags & SLOT_OCCUPIED &&
268 1.1 aymeric slot->intr_func != NULL)
269 1.1 aymeric slot->intr_func(slot->intr_arg);
270 1.1 aymeric
271 1.1 aymeric return 1;
272 1.1 aymeric }
273 1.1 aymeric }
274 1.1 aymeric return 0;
275 1.1 aymeric }
276 1.1 aymeric
277 1.1 aymeric static void
278 1.1 aymeric pccard_kthread(arg)
279 1.1 aymeric void *arg;
280 1.1 aymeric {
281 1.1 aymeric struct pccard_softc *self = arg;
282 1.1 aymeric struct pccard_slot *slot = &self->devs[0];
283 1.1 aymeric
284 1.1 aymeric for (;;) {
285 1.1 aymeric int s = spl2();
286 1.1 aymeric
287 1.1 aymeric if (slot->flags & SLOT_NEW_CARD_EVENT) {
288 1.1 aymeric slot->flags &= ~SLOT_NEW_CARD_EVENT;
289 1.1 aymeric gayle.intreq = 0xc0;
290 1.1 aymeric
291 1.1 aymeric /* reset the registers */
292 1.1 aymeric gayle.intreq = GAYLE_INT_IDE | GAYLE_INT_DETECT;
293 1.1 aymeric gayle.pcc_status = GAYLE_CCMEM_WP | GAYLE_CCIO_SPKR;
294 1.1 aymeric gayle.pcc_config = 0;
295 1.1 aymeric pccard_attach_slot(&self->devs[0]);
296 1.1 aymeric }
297 1.1 aymeric splx(s);
298 1.1 aymeric
299 1.1 aymeric tsleep(slot, PWAIT, "pccthread", hz);
300 1.1 aymeric }
301 1.1 aymeric }
302 1.1 aymeric
303 1.1 aymeric static void
304 1.1 aymeric pccard_attach_slot(slot)
305 1.1 aymeric struct pccard_slot *slot;
306 1.1 aymeric {
307 1.1 aymeric if (!(slot->flags & SLOT_OCCUPIED) &&
308 1.1 aymeric gayle.pcc_status & GAYLE_CCMEM_DETECT) {
309 1.1 aymeric if (pcmcia_card_attach(slot->card) == 0)
310 1.1 aymeric slot->flags |= SLOT_OCCUPIED;
311 1.1 aymeric }
312 1.1 aymeric }
313 1.1 aymeric
314 1.1 aymeric static int
315 1.1 aymeric pcf_mem_alloc(pch, bsz, pcmh)
316 1.1 aymeric pcmcia_chipset_handle_t pch;
317 1.1 aymeric bus_size_t bsz;
318 1.1 aymeric struct pcmcia_mem_handle *pcmh;
319 1.1 aymeric {
320 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) pch;
321 1.1 aymeric pcmh->memt = &slot->sc->attr_space;
322 1.1 aymeric pcmh->memh = pcmh->memt->base;
323 1.1 aymeric return 0;
324 1.1 aymeric }
325 1.1 aymeric
326 1.1 aymeric static void
327 1.1 aymeric pcf_mem_free(pch, memh)
328 1.1 aymeric pcmcia_chipset_handle_t pch;
329 1.1 aymeric struct pcmcia_mem_handle *memh;
330 1.1 aymeric {
331 1.1 aymeric }
332 1.1 aymeric
333 1.1 aymeric static int
334 1.1 aymeric pcf_mem_map(pch, kind, addr, size, pcmh, offsetp, windowp)
335 1.1 aymeric pcmcia_chipset_handle_t pch;
336 1.1 aymeric int kind;
337 1.1 aymeric bus_addr_t addr;
338 1.1 aymeric bus_size_t size;
339 1.1 aymeric struct pcmcia_mem_handle *pcmh;
340 1.1 aymeric bus_addr_t *offsetp;
341 1.1 aymeric int *windowp;
342 1.1 aymeric {
343 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) pch;
344 1.1 aymeric
345 1.1 aymeric switch (kind) {
346 1.1 aymeric case PCMCIA_MEM_ATTR:
347 1.1 aymeric pcmh->memt = &slot->sc->attr_space;
348 1.1 aymeric break;
349 1.1 aymeric case PCMCIA_MEM_COMMON:
350 1.1 aymeric pcmh->memt = &slot->sc->mem_space;
351 1.1 aymeric break;
352 1.1 aymeric default:
353 1.1 aymeric /* This means that this code needs an update/a bugfix */
354 1.1 aymeric printf("Unknown kind of PCMCIA memory (amiga/dev/pccard.c)\n");
355 1.1 aymeric return 1;
356 1.1 aymeric }
357 1.1 aymeric
358 1.1 aymeric bus_space_map(pcmh->memt, addr, size, 0, &pcmh->memh);
359 1.1 aymeric *offsetp = 0;
360 1.1 aymeric *windowp = 0; /* unused */
361 1.1 aymeric
362 1.1 aymeric return 0;
363 1.1 aymeric }
364 1.1 aymeric
365 1.1 aymeric static void
366 1.1 aymeric pcf_mem_unmap(pch, win)
367 1.1 aymeric pcmcia_chipset_handle_t pch;
368 1.1 aymeric int win;
369 1.1 aymeric {
370 1.1 aymeric }
371 1.1 aymeric
372 1.1 aymeric static int
373 1.1 aymeric pcf_io_alloc(pch, start, size, align, pcihp)
374 1.1 aymeric pcmcia_chipset_handle_t pch;
375 1.1 aymeric bus_addr_t start;
376 1.1 aymeric bus_size_t size;
377 1.1 aymeric bus_size_t align;
378 1.1 aymeric struct pcmcia_io_handle *pcihp;
379 1.1 aymeric {
380 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) pch;
381 1.1 aymeric
382 1.1 aymeric pcihp->iot = &slot->sc->io_space;
383 1.1 aymeric pcihp->ioh = pcihp->iot->base;
384 1.1 aymeric return 0;
385 1.1 aymeric }
386 1.1 aymeric
387 1.1 aymeric static void
388 1.1 aymeric pcf_io_free(pch, pcihp)
389 1.1 aymeric pcmcia_chipset_handle_t pch;
390 1.1 aymeric struct pcmcia_io_handle *pcihp;
391 1.1 aymeric {
392 1.1 aymeric }
393 1.1 aymeric
394 1.1 aymeric static int
395 1.1 aymeric pcf_io_map(pch, width, offset, size, pcihp, windowp)
396 1.1 aymeric pcmcia_chipset_handle_t pch;
397 1.1 aymeric int width;
398 1.1 aymeric bus_addr_t offset;
399 1.1 aymeric bus_size_t size;
400 1.1 aymeric struct pcmcia_io_handle *pcihp;
401 1.1 aymeric int *windowp;
402 1.1 aymeric {
403 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) pch;
404 1.1 aymeric
405 1.1 aymeric pcihp->iot = &slot->sc->io_space;
406 1.1 aymeric pcihp->ioh = offset;
407 1.1 aymeric
408 1.1 aymeric *windowp = 0; /* unused */
409 1.1 aymeric return 0;
410 1.1 aymeric }
411 1.1 aymeric
412 1.1 aymeric static void
413 1.1 aymeric pcf_io_unmap(pch, win)
414 1.1 aymeric pcmcia_chipset_handle_t pch;
415 1.1 aymeric int win;
416 1.1 aymeric {
417 1.1 aymeric }
418 1.1 aymeric
419 1.1 aymeric static void *
420 1.1 aymeric pcf_intr_establish(pch, pf, ipl, func, arg)
421 1.1 aymeric pcmcia_chipset_handle_t pch;
422 1.1 aymeric struct pcmcia_function *pf;
423 1.1 aymeric int ipl;
424 1.1 aymeric int (*func)(void *);
425 1.1 aymeric void *arg;
426 1.1 aymeric {
427 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) pch;
428 1.1 aymeric int s;
429 1.1 aymeric
430 1.1 aymeric s = splhigh();
431 1.1 aymeric if (slot->intr_func == NULL) {
432 1.1 aymeric slot->intr_func = func;
433 1.1 aymeric slot->intr_arg = arg;
434 1.1 aymeric } else {
435 1.1 aymeric /* if we are here, we need to put intrs into a list */
436 1.1 aymeric printf("ARGH! see arch/amiga/dev/pccard.c\n");
437 1.1 aymeric slot = NULL;
438 1.1 aymeric }
439 1.1 aymeric splx(s);
440 1.1 aymeric
441 1.1 aymeric return slot;
442 1.1 aymeric }
443 1.1 aymeric
444 1.1 aymeric static void
445 1.1 aymeric pcf_intr_disestablish(pch, intr_handler)
446 1.1 aymeric pcmcia_chipset_handle_t pch;
447 1.1 aymeric void *intr_handler;
448 1.1 aymeric {
449 1.1 aymeric struct pccard_slot *slot = (struct pccard_slot *) intr_handler;
450 1.1 aymeric
451 1.1 aymeric if (slot != NULL) {
452 1.1 aymeric slot->intr_func = NULL;
453 1.1 aymeric slot->intr_arg = NULL;
454 1.1 aymeric }
455 1.1 aymeric }
456 1.1 aymeric
457 1.1 aymeric static void
458 1.1 aymeric pcf_socket_enable(pch)
459 1.1 aymeric pcmcia_chipset_handle_t pch;
460 1.1 aymeric {
461 1.1 aymeric }
462 1.1 aymeric
463 1.1 aymeric static void
464 1.1 aymeric pcf_socket_disable(pch)
465 1.1 aymeric pcmcia_chipset_handle_t pch;
466 1.1 aymeric {
467 1.1 aymeric }
468 1.1 aymeric
469 1.1 aymeric
470 1.1 aymeric static u_int8_t
471 1.1 aymeric pcmio_bsr1(h, o)
472 1.1 aymeric bus_space_handle_t h;
473 1.1 aymeric bus_size_t o;
474 1.1 aymeric {
475 1.1 aymeric return *((volatile u_int8_t *) h + o + (o & 1 ? 0xffff : 0));
476 1.1 aymeric }
477 1.1 aymeric
478 1.1 aymeric static void
479 1.1 aymeric pcmio_bsw1(h, o, v)
480 1.1 aymeric bus_space_handle_t h;
481 1.1 aymeric bus_size_t o;
482 1.1 aymeric unsigned v;
483 1.1 aymeric {
484 1.1 aymeric *((volatile u_int8_t *) h + o + (o & 1 ? 0xffff : 0)) = v;
485 1.1 aymeric }
486 1.1 aymeric
487 1.1 aymeric static void
488 1.1 aymeric pcmio_bsrm1(h, o, p, c)
489 1.1 aymeric bus_space_handle_t h;
490 1.1 aymeric bus_size_t o;
491 1.1 aymeric u_int8_t *p;
492 1.1 aymeric bus_size_t c;
493 1.1 aymeric {
494 1.1 aymeric volatile u_int8_t *src = (volatile u_int8_t *) (h + o +
495 1.1 aymeric (o & 1 ? 0xffff : 0));
496 1.1 aymeric
497 1.1 aymeric
498 1.1 aymeric /* XXX we can (should, must) optimize this if c >= 4 */
499 1.1 aymeric for (; c > 0; c--)
500 1.1 aymeric *p++ = *src;
501 1.1 aymeric }
502 1.1 aymeric
503 1.1 aymeric
504 1.1 aymeric static void
505 1.1 aymeric pcmio_bswm1(h, o, p, c)
506 1.1 aymeric bus_space_handle_t h;
507 1.1 aymeric bus_size_t o;
508 1.1 aymeric const u_int8_t *p;
509 1.1 aymeric bus_size_t c;
510 1.1 aymeric {
511 1.1 aymeric volatile u_int8_t *dst = (volatile u_int8_t *) (h + o +
512 1.1 aymeric (o & 1 ? 0xffff : 0));
513 1.1 aymeric
514 1.1 aymeric
515 1.1 aymeric /* XXX we can (should, must) optimize this if c >= 4 */
516 1.1 aymeric for (; c > 0; c--)
517 1.1 aymeric *dst = *p++;
518 1.1 aymeric }
519 1.1 aymeric
520 1.1 aymeric static void
521 1.1 aymeric pcmio_bsrr1(h, o, p, c)
522 1.1 aymeric bus_space_handle_t h;
523 1.1 aymeric bus_size_t o;
524 1.1 aymeric u_int8_t *p;
525 1.1 aymeric bus_size_t c;
526 1.1 aymeric {
527 1.1 aymeric volatile u_int8_t *cp1;
528 1.1 aymeric volatile u_int8_t *cp2;
529 1.1 aymeric volatile u_int8_t *temp;
530 1.1 aymeric
531 1.1 aymeric if (o & 1) {
532 1.1 aymeric cp1 = (volatile u_int8_t *) h + o + 0x10000;
533 1.1 aymeric cp2 = (volatile u_int8_t *) h + o;
534 1.1 aymeric } else {
535 1.1 aymeric cp1 = (volatile u_int8_t *) h + o;
536 1.1 aymeric cp2 = (volatile u_int8_t *) h + o + 0x10000 + 2;
537 1.1 aymeric }
538 1.1 aymeric
539 1.1 aymeric /* XXX we can (should, must) optimize this if c >= 4 */
540 1.1 aymeric for (; c > 0; c--) {
541 1.1 aymeric *p++ = *cp1;
542 1.1 aymeric cp1 += 2;
543 1.1 aymeric
544 1.1 aymeric /* swap pointers - hope gcc generates exg for this ;) */
545 1.1 aymeric temp = cp1;
546 1.1 aymeric cp1 = cp2;
547 1.1 aymeric cp2 = temp;
548 1.1 aymeric }
549 1.1 aymeric }
550 1.1 aymeric
551 1.1 aymeric
552 1.1 aymeric static void
553 1.1 aymeric pcmio_bswr1(h, o, p, c)
554 1.1 aymeric bus_space_handle_t h;
555 1.1 aymeric bus_size_t o;
556 1.1 aymeric const u_int8_t *p;
557 1.1 aymeric bus_size_t c;
558 1.1 aymeric {
559 1.1 aymeric volatile u_int8_t *cp1;
560 1.1 aymeric volatile u_int8_t *cp2;
561 1.1 aymeric volatile u_int8_t *temp;
562 1.1 aymeric
563 1.1 aymeric if (o & 1) {
564 1.1 aymeric cp1 = (volatile u_int8_t *) h + o + 0x10000;
565 1.1 aymeric cp2 = (volatile u_int8_t *) h + o;
566 1.1 aymeric } else {
567 1.1 aymeric cp1 = (volatile u_int8_t *) h + o;
568 1.1 aymeric cp2 = (volatile u_int8_t *) h + o + 0x10000 + 2;
569 1.1 aymeric }
570 1.1 aymeric
571 1.1 aymeric /* XXX we can (should, must) optimize this if c >= 4 */
572 1.1 aymeric for (; c > 0; c--) {
573 1.1 aymeric *cp1 = *p++;
574 1.1 aymeric cp1 += 2;
575 1.1 aymeric
576 1.1 aymeric /* swap pointers - hope gcc generates exg for this ;) */
577 1.1 aymeric temp = cp1;
578 1.1 aymeric cp1 = cp2;
579 1.1 aymeric cp2 = temp;
580 1.1 aymeric }
581 1.1 aymeric }
582 1.1 aymeric
583 1.1 aymeric void
584 1.1 aymeric pcmio_bssr1(h, o, v, c)
585 1.1 aymeric bus_space_handle_t h;
586 1.1 aymeric bus_size_t o;
587 1.1 aymeric unsigned v;
588 1.1 aymeric bus_size_t c;
589 1.1 aymeric {
590 1.1 aymeric panic("pcmio_bssr1 is not defined (" __FILE__ ")");
591 1.1 aymeric }
592 1.1 aymeric
593 1.1 aymeric void
594 1.1 aymeric pcmio_bscr1(h, o, g, q, c)
595 1.1 aymeric bus_space_handle_t h;
596 1.1 aymeric bus_size_t o;
597 1.1 aymeric bus_space_handle_t g;
598 1.1 aymeric bus_size_t q;
599 1.1 aymeric bus_size_t c;
600 1.1 aymeric {
601 1.1 aymeric panic("pcmio_bscr1 is not defined (" __FILE__ ")");
602 1.1 aymeric }
603