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