hd64461pcmcia.c revision 1.26 1 /* $NetBSD: hd64461pcmcia.c,v 1.26 2004/07/11 16:04:58 uch Exp $ */
2
3 /*-
4 * Copyright (c) 2001, 2002, 2004 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: hd64461pcmcia.c,v 1.26 2004/07/11 16:04:58 uch Exp $");
41
42 #include "debug_hpcsh.h"
43
44 #include <sys/param.h>
45 #include <sys/systm.h>
46 #include <sys/device.h>
47 #include <sys/malloc.h>
48 #include <sys/kthread.h>
49 #include <sys/boot_flag.h>
50
51 #include <machine/bus.h>
52 #include <machine/intr.h>
53
54 #include <dev/pcmcia/pcmciareg.h>
55 #include <dev/pcmcia/pcmciavar.h>
56 #include <dev/pcmcia/pcmciachip.h>
57
58 #include <sh3/bscreg.h>
59
60 #include <hpcsh/dev/hd64461/hd64461reg.h>
61 #include <hpcsh/dev/hd64461/hd64461var.h>
62 #include <hpcsh/dev/hd64461/hd64461intcreg.h>
63 #include <hpcsh/dev/hd64461/hd64461gpioreg.h>
64 #include <hpcsh/dev/hd64461/hd64461pcmciavar.h>
65 #include <hpcsh/dev/hd64461/hd64461pcmciareg.h>
66
67 #include "locators.h"
68
69 #ifdef HD64461PCMCIA_DEBUG
70 #define DPRINTF_ENABLE
71 #define DPRINTF_DEBUG hd64461pcmcia_debug
72 #endif
73 #include <machine/debug.h>
74
75 enum controller_channel {
76 CHANNEL_0 = 0,
77 CHANNEL_1 = 1,
78 CHANNEL_MAX = 2
79 };
80
81 enum memory_window_mode {
82 MEMWIN_16M_MODE,
83 MEMWIN_32M_MODE
84 };
85
86 enum memory_window_16 {
87 MEMWIN_16M_COMMON_0,
88 MEMWIN_16M_COMMON_1,
89 MEMWIN_16M_COMMON_2,
90 MEMWIN_16M_COMMON_3,
91 };
92 #define MEMWIN_16M_MAX 4
93
94 enum memory_window_32 {
95 MEMWIN_32M_ATTR,
96 MEMWIN_32M_COMMON_0,
97 MEMWIN_32M_COMMON_1,
98 };
99 #define MEMWIN_32M_MAX 3
100
101 enum hd64461pcmcia_event_type {
102 EVENT_NONE,
103 EVENT_INSERT,
104 EVENT_REMOVE,
105 };
106 #define EVENT_QUEUE_MAX 5
107
108 struct hd64461pcmcia_softc; /* forward declaration */
109
110 struct hd64461pcmcia_window_cookie {
111 bus_space_tag_t wc_tag;
112 bus_space_handle_t wc_handle;
113 int wc_size;
114 int wc_window;
115 };
116
117 struct hd64461pcmcia_channel {
118 struct hd64461pcmcia_softc *ch_parent;
119 struct device *ch_pcmcia;
120 enum controller_channel ch_channel;
121
122 /* memory space */
123 enum memory_window_mode ch_memory_window_mode;
124 bus_space_tag_t ch_memt;
125 bus_space_handle_t ch_memh;
126 bus_addr_t ch_membase_addr;
127 bus_size_t ch_memsize;
128 bus_space_tag_t ch_cmemt[MEMWIN_16M_MAX];
129
130 /* I/O space */
131 bus_space_tag_t ch_iot;
132 bus_addr_t ch_iobase;
133 bus_size_t ch_iosize;
134
135 /* card interrupt */
136 int (*ch_ih_card_func)(void *);
137 void *ch_ih_card_arg;
138 int ch_attached;
139 };
140
141 struct hd64461pcmcia_event {
142 int __queued;
143 enum hd64461pcmcia_event_type pe_type;
144 struct hd64461pcmcia_channel *pe_ch;
145 SIMPLEQ_ENTRY(hd64461pcmcia_event) pe_link;
146 };
147
148 struct hd64461pcmcia_softc {
149 struct device sc_dev;
150 enum hd64461_module_id sc_module_id;
151 int sc_shutdown;
152
153 /* CSC event */
154 struct proc *sc_event_thread;
155 struct hd64461pcmcia_event sc_event_pool[EVENT_QUEUE_MAX];
156 SIMPLEQ_HEAD (, hd64461pcmcia_event) sc_event_head;
157
158 struct hd64461pcmcia_channel sc_ch[CHANNEL_MAX];
159 };
160
161 STATIC int hd64461pcmcia_chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
162 struct pcmcia_mem_handle *);
163 STATIC void hd64461pcmcia_chip_mem_free(pcmcia_chipset_handle_t,
164 struct pcmcia_mem_handle *);
165 STATIC int hd64461pcmcia_chip_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t,
166 bus_size_t, struct pcmcia_mem_handle *, bus_size_t *, int *);
167 STATIC void hd64461pcmcia_chip_mem_unmap(pcmcia_chipset_handle_t, int);
168 STATIC int hd64461pcmcia_chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t,
169 bus_size_t, bus_size_t, struct pcmcia_io_handle *);
170 STATIC void hd64461pcmcia_chip_io_free(pcmcia_chipset_handle_t,
171 struct pcmcia_io_handle *);
172 STATIC int hd64461pcmcia_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t,
173 bus_size_t, struct pcmcia_io_handle *, int *);
174 STATIC void hd64461pcmcia_chip_io_unmap(pcmcia_chipset_handle_t, int);
175 STATIC void hd64461pcmcia_chip_socket_enable(pcmcia_chipset_handle_t);
176 STATIC void hd64461pcmcia_chip_socket_disable(pcmcia_chipset_handle_t);
177 STATIC void *hd64461pcmcia_chip_intr_establish(pcmcia_chipset_handle_t,
178 struct pcmcia_function *, int, int (*)(void *), void *);
179 STATIC void hd64461pcmcia_chip_intr_disestablish(pcmcia_chipset_handle_t,
180 void *);
181
182 STATIC struct pcmcia_chip_functions hd64461pcmcia_functions = {
183 hd64461pcmcia_chip_mem_alloc,
184 hd64461pcmcia_chip_mem_free,
185 hd64461pcmcia_chip_mem_map,
186 hd64461pcmcia_chip_mem_unmap,
187 hd64461pcmcia_chip_io_alloc,
188 hd64461pcmcia_chip_io_free,
189 hd64461pcmcia_chip_io_map,
190 hd64461pcmcia_chip_io_unmap,
191 hd64461pcmcia_chip_intr_establish,
192 hd64461pcmcia_chip_intr_disestablish,
193 hd64461pcmcia_chip_socket_enable,
194 hd64461pcmcia_chip_socket_disable,
195 };
196
197 STATIC int hd64461pcmcia_match(struct device *, struct cfdata *, void *);
198 STATIC void hd64461pcmcia_attach(struct device *, struct device *, void *);
199 STATIC int hd64461pcmcia_print(void *, const char *);
200 STATIC int hd64461pcmcia_submatch(struct device *, struct cfdata *, void *);
201
202 CFATTACH_DECL(hd64461pcmcia, sizeof(struct hd64461pcmcia_softc),
203 hd64461pcmcia_match, hd64461pcmcia_attach, NULL, NULL);
204
205 STATIC void hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *,
206 enum controller_channel);
207 /* hot plug */
208 STATIC void hd64461pcmcia_create_event_thread(void *);
209 STATIC void hd64461pcmcia_event_thread(void *);
210 STATIC void queue_event(struct hd64461pcmcia_channel *,
211 enum hd64461pcmcia_event_type);
212 /* interrupt handler */
213 STATIC int hd64461pcmcia_channel0_intr(void *);
214 STATIC int hd64461pcmcia_channel1_intr(void *);
215 /* card status */
216 STATIC enum hd64461pcmcia_event_type detect_card(enum controller_channel);
217 STATIC void hd64461pcmcia_power_off(enum controller_channel)
218 __attribute__((__unused__));
219 STATIC void hd64461pcmcia_power_on(enum controller_channel)
220 __attribute__((__unused__));
221 /* memory window access ops */
222 STATIC void hd64461pcmcia_memory_window_mode(enum controller_channel,
223 enum memory_window_mode)__attribute__((__unused__));
224 STATIC void hd64461pcmcia_memory_window_16(enum controller_channel,
225 enum memory_window_16);
226 /* bus width */
227 STATIC void hd64461_set_bus_width(enum controller_channel, int);
228 #ifdef HD64461PCMCIA_DEBUG
229 STATIC void hd64461pcmcia_info(struct hd64461pcmcia_softc *);
230 #endif
231 /* fix SH3 Area[56] bug */
232 STATIC void fixup_sh3_pcmcia_area(bus_space_tag_t);
233 #define _BUS_SPACE_ACCESS_HOOK() \
234 do { \
235 u_int8_t dummy __attribute__((__unused__)) = \
236 *(volatile u_int8_t *)0xba000000; \
237 } while (/*CONSTCOND*/0)
238 _BUS_SPACE_WRITE(_sh3_pcmcia_bug, 1, 8)
239 _BUS_SPACE_WRITE_MULTI(_sh3_pcmcia_bug, 1, 8)
240 _BUS_SPACE_WRITE_REGION(_sh3_pcmcia_bug, 1, 8)
241 _BUS_SPACE_SET_MULTI(_sh3_pcmcia_bug, 1, 8)
242 #undef _BUS_SPACE_ACCESS_HOOK
243
244 #define DELAY_MS(x) delay((x) * 1000)
245
246 int
247 hd64461pcmcia_match(struct device *parent, struct cfdata *cf, void *aux)
248 {
249 struct hd64461_attach_args *ha = aux;
250
251 return (ha->ha_module_id == HD64461_MODULE_PCMCIA);
252 }
253
254 void
255 hd64461pcmcia_attach(struct device *parent, struct device *self, void *aux)
256 {
257 struct hd64461_attach_args *ha = aux;
258 struct hd64461pcmcia_softc *sc = (struct hd64461pcmcia_softc *)self;
259
260 sc->sc_module_id = ha->ha_module_id;
261
262 printf("\n");
263
264 #ifdef HD64461PCMCIA_DEBUG
265 hd64461pcmcia_info(sc);
266 #endif
267 /* Channel 0/1 common CSC event queue */
268 SIMPLEQ_INIT (&sc->sc_event_head);
269 kthread_create(hd64461pcmcia_create_event_thread, sc);
270
271 #if !defined(HD64461PCMCIA_REORDER_ATTACH)
272 hd64461pcmcia_attach_channel(sc, CHANNEL_0);
273 hd64461pcmcia_attach_channel(sc, CHANNEL_1);
274 #else
275 hd64461pcmcia_attach_channel(sc, CHANNEL_1);
276 hd64461pcmcia_attach_channel(sc, CHANNEL_0);
277 #endif
278 }
279
280 void
281 hd64461pcmcia_create_event_thread(void *arg)
282 {
283 struct hd64461pcmcia_softc *sc = arg;
284 int error;
285
286 error = kthread_create1(hd64461pcmcia_event_thread, sc,
287 &sc->sc_event_thread, "%s",
288 sc->sc_dev.dv_xname);
289 KASSERT(error == 0);
290 }
291
292 void
293 hd64461pcmcia_event_thread(void *arg)
294 {
295 struct hd64461pcmcia_softc *sc = arg;
296 struct hd64461pcmcia_event *pe;
297 int s;
298
299 while (!sc->sc_shutdown) {
300 tsleep(sc, PWAIT, "CSC wait", 0);
301 s = splhigh();
302 while ((pe = SIMPLEQ_FIRST(&sc->sc_event_head))) {
303 splx(s);
304 switch (pe->pe_type) {
305 default:
306 printf("%s: unknown event.\n", __FUNCTION__);
307 break;
308 case EVENT_INSERT:
309 DPRINTF("insert event.\n");
310 pcmcia_card_attach(pe->pe_ch->ch_pcmcia);
311 break;
312 case EVENT_REMOVE:
313 DPRINTF("remove event.\n");
314 pcmcia_card_detach(pe->pe_ch->ch_pcmcia,
315 DETACH_FORCE);
316 break;
317 }
318 s = splhigh();
319 SIMPLEQ_REMOVE_HEAD(&sc->sc_event_head, pe_link);
320 pe->__queued = 0;
321 }
322 splx(s);
323 }
324 /* NOTREACHED */
325 }
326
327 int
328 hd64461pcmcia_print(void *arg, const char *pnp)
329 {
330
331 if (pnp)
332 aprint_normal("pcmcia at %s", pnp);
333
334 return (UNCONF);
335 }
336
337 int
338 hd64461pcmcia_submatch(struct device *parent, struct cfdata *cf, void *aux)
339 {
340 struct pcmciabus_attach_args *paa = aux;
341 struct hd64461pcmcia_channel *ch =
342 (struct hd64461pcmcia_channel *)paa->pch;
343
344 if (ch->ch_channel == CHANNEL_0) {
345 if (cf->cf_loc[PCMCIABUSCF_CONTROLLER] !=
346 PCMCIABUSCF_CONTROLLER_DEFAULT &&
347 cf->cf_loc[PCMCIABUSCF_CONTROLLER] != 0)
348 return 0;
349 } else {
350 if (cf->cf_loc[PCMCIABUSCF_CONTROLLER] !=
351 PCMCIABUSCF_CONTROLLER_DEFAULT &&
352 cf->cf_loc[PCMCIABUSCF_CONTROLLER] != 1)
353 return 0;
354 }
355 paa->pct = (pcmcia_chipset_tag_t)&hd64461pcmcia_functions;
356
357 return (config_match(parent, cf, aux));
358 }
359
360 void
361 hd64461pcmcia_attach_channel(struct hd64461pcmcia_softc *sc,
362 enum controller_channel channel)
363 {
364 struct device *parent = (struct device *)sc;
365 struct hd64461pcmcia_channel *ch = &sc->sc_ch[channel];
366 struct pcmciabus_attach_args paa;
367 bus_addr_t membase;
368 bus_addr_t gcr;
369 uint8_t r;
370 int i;
371
372 ch->ch_parent = sc;
373 ch->ch_channel = channel;
374
375 /*
376 * DRV (external buffer) high level
377 *
378 * XXX: This hack makes pcmcia cards "being used" at the boot
379 * time (by WinCE or NetBSD) correctly detected.
380 */
381 gcr = HD64461_PCCGCR(channel);
382 r = hd64461_reg_read_1(gcr);
383 if (r & HD64461_PCCGCR_DRVE) {
384 r &= ~HD64461_PCCGCR_DRVE;
385 hd64461_reg_write_1(gcr, r);
386 }
387
388 /*
389 * Continuous 16-MB Area Mode
390 */
391 /* Attibute/Common memory extent */
392 membase = (channel == CHANNEL_0)
393 ? HD64461_PCC0_MEMBASE : HD64461_PCC1_MEMBASE;
394
395 ch->ch_memt = bus_space_create(0, "PCMCIA attribute memory",
396 membase, 0x01000000); /* 16MB */
397 bus_space_alloc(ch->ch_memt, 0, 0x00ffffff, 0x01000000,
398 0x01000000, 0x01000000, 0, &ch->ch_membase_addr,
399 &ch->ch_memh);
400 fixup_sh3_pcmcia_area(ch->ch_memt);
401
402 /* Common memory space extent */
403 ch->ch_memsize = 0x01000000;
404 for (i = 0; i < MEMWIN_16M_MAX; i++) {
405 ch->ch_cmemt[i] = bus_space_create(0, "PCMCIA common memory",
406 membase + 0x01000000,
407 ch->ch_memsize);
408 fixup_sh3_pcmcia_area(ch->ch_cmemt[i]);
409 }
410
411 /* I/O port extent and interrupt staff */
412 hd64461pcmcia_chip_socket_disable(ch); /* enable CSC interrupt only */
413
414 if (channel == CHANNEL_0) {
415 ch->ch_iobase = 0;
416 ch->ch_iosize = HD64461_PCC0_IOSIZE;
417 ch->ch_iot = bus_space_create(0, "PCMCIA I/O port",
418 HD64461_PCC0_IOBASE,
419 ch->ch_iosize);
420 fixup_sh3_pcmcia_area(ch->ch_iot);
421
422 hd6446x_intr_establish(HD64461_INTC_PCC0, IST_LEVEL, IPL_TTY,
423 hd64461pcmcia_channel0_intr, ch);
424 } else {
425 hd64461_set_bus_width(CHANNEL_1, PCMCIA_WIDTH_IO16);
426 hd6446x_intr_establish(HD64461_INTC_PCC1, IST_EDGE, IPL_TTY,
427 hd64461pcmcia_channel1_intr, ch);
428 }
429
430 paa.paa_busname = "pcmcia";
431 paa.pch = (pcmcia_chipset_handle_t)ch;
432 paa.iobase = ch->ch_iobase;
433 paa.iosize = ch->ch_iosize;
434
435 ch->ch_pcmcia = config_found_sm(parent, &paa, hd64461pcmcia_print,
436 hd64461pcmcia_submatch);
437
438 if (ch->ch_pcmcia && (detect_card(ch->ch_channel) == EVENT_INSERT)) {
439 ch->ch_attached = 1;
440 pcmcia_card_attach(ch->ch_pcmcia);
441 }
442 }
443
444 int
445 hd64461pcmcia_channel0_intr(void *arg)
446 {
447 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg;
448 u_int8_t r;
449 int ret = 0;
450
451 r = hd64461_reg_read_1(HD64461_PCC0CSCR_REG8);
452 /* clear interrtupt (edge source only) */
453 hd64461_reg_write_1(HD64461_PCC0CSCR_REG8, 0);
454
455 if (r & HD64461_PCC0CSCR_P0IREQ) {
456 if (ch->ch_ih_card_func) {
457 ret = (*ch->ch_ih_card_func)(ch->ch_ih_card_arg);
458 } else
459 DPRINTF("spurious IREQ interrupt.\n");
460 }
461
462 if (r & HD64461_PCC0CSCR_P0CDC)
463 queue_event(ch, detect_card(ch->ch_channel));
464
465 return ret;
466 }
467
468 int
469 hd64461pcmcia_channel1_intr(void *arg)
470 {
471 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)arg;
472 u_int8_t r;
473 int ret = 0;
474
475 r = hd64461_reg_read_1(HD64461_PCC1CSCR_REG8);
476 /* clear interrtupt */
477 hd64461_reg_write_1(HD64461_PCC1CSCR_REG8, 0);
478
479 if (r & HD64461_PCC1CSCR_P1RC) {
480 if (ch->ch_ih_card_func)
481 ret = (*ch->ch_ih_card_func)(ch->ch_ih_card_arg);
482 else
483 DPRINTF("spurious READY interrupt.\n");
484 }
485
486 if (r & HD64461_PCC1CSCR_P1CDC)
487 queue_event(ch, detect_card(ch->ch_channel));
488
489 return ret;
490 }
491
492 void
493 queue_event(struct hd64461pcmcia_channel *ch,
494 enum hd64461pcmcia_event_type type)
495 {
496 struct hd64461pcmcia_event *pe, *pool;
497 struct hd64461pcmcia_softc *sc = ch->ch_parent;
498 int i;
499 int s = splhigh();
500
501 if (type == EVENT_NONE)
502 goto out;
503
504 pe = 0;
505 pool = sc->sc_event_pool;
506 for (i = 0; i < EVENT_QUEUE_MAX; i++) {
507 if (!pool[i].__queued) {
508 pe = &pool[i];
509 break;
510 }
511 }
512
513 if (pe == 0) {
514 printf("%s: event FIFO overflow (max %d).\n", __FUNCTION__,
515 EVENT_QUEUE_MAX);
516 goto out;
517 }
518
519 if ((ch->ch_attached && (type == EVENT_INSERT)) ||
520 (!ch->ch_attached && (type == EVENT_REMOVE))) {
521 DPRINTF("spurious CSC interrupt.\n");
522 goto out;
523 }
524
525 ch->ch_attached = (type == EVENT_INSERT);
526 pe->__queued = 1;
527 pe->pe_type = type;
528 pe->pe_ch = ch;
529 SIMPLEQ_INSERT_TAIL(&sc->sc_event_head, pe, pe_link);
530 wakeup(sc);
531 out:
532 splx(s);
533 }
534
535 /*
536 * interface for pcmcia driver.
537 */
538 void *
539 hd64461pcmcia_chip_intr_establish(pcmcia_chipset_handle_t pch,
540 struct pcmcia_function *pf,
541 int ipl, int (*ih_func)(void *), void *ih_arg)
542 {
543 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
544 int channel = ch->ch_channel;
545 bus_addr_t cscier = HD64461_PCCCSCIER(channel);
546 int s = splhigh();
547 u_int8_t r;
548
549 ch->ch_ih_card_func = ih_func;
550 ch->ch_ih_card_arg = ih_arg;
551
552 /* enable card interrupt */
553 r = hd64461_reg_read_1(cscier);
554 if (channel == CHANNEL_0) {
555 /* set level mode */
556 r &= ~HD64461_PCC0CSCIER_P0IREQE_MASK;
557 r |= HD64461_PCC0CSCIER_P0IREQE_LEVEL;
558 hd6446x_intr_priority(HD64461_INTC_PCC0, ipl);
559 } else {
560 /* READY-pin LOW to HIGH changes generates interrupt */
561 r |= HD64461_PCC1CSCIER_P1RE;
562 hd6446x_intr_priority(HD64461_INTC_PCC1, ipl);
563 }
564 hd64461_reg_write_1(cscier, r);
565
566 splx(s);
567
568 return (void *)ih_func;
569 }
570
571 void
572 hd64461pcmcia_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
573 {
574 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
575 int channel = ch->ch_channel;
576 bus_addr_t cscier = HD64461_PCCCSCIER(channel);
577 int s = splhigh();
578 u_int8_t r;
579
580 /* disable card interrupt */
581 r = hd64461_reg_read_1(cscier);
582 if (channel == CHANNEL_0) {
583 r &= ~HD64461_PCC0CSCIER_P0IREQE_MASK;
584 r |= HD64461_PCC0CSCIER_P0IREQE_NONE;
585 hd6446x_intr_priority(HD64461_INTC_PCC0, IPL_TTY);
586 } else {
587 r &= ~HD64461_PCC1CSCIER_P1RE;
588 hd6446x_intr_priority(HD64461_INTC_PCC1, IPL_TTY);
589 }
590 hd64461_reg_write_1(cscier, r);
591
592 ch->ch_ih_card_func = 0;
593
594 splx(s);
595 }
596
597 int
598 hd64461pcmcia_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
599 struct pcmcia_mem_handle *pcmhp)
600 {
601 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
602
603 pcmhp->memt = ch->ch_memt;
604 pcmhp->addr = ch->ch_membase_addr;
605 pcmhp->memh = ch->ch_memh;
606 pcmhp->size = size;
607 pcmhp->realsize = size;
608
609 DPRINTF("base 0x%08lx size %#lx\n", pcmhp->addr, size);
610
611 return (0);
612 }
613
614 void
615 hd64461pcmcia_chip_mem_free(pcmcia_chipset_handle_t pch,
616 struct pcmcia_mem_handle *pcmhp)
617 {
618 /* nothing to do */
619 }
620
621 int
622 hd64461pcmcia_chip_mem_map(pcmcia_chipset_handle_t pch, int kind,
623 bus_addr_t card_addr,
624 bus_size_t size, struct pcmcia_mem_handle *pcmhp,
625 bus_size_t *offsetp, int *windowp)
626 {
627 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
628 struct hd64461pcmcia_window_cookie *cookie;
629 bus_addr_t ofs;
630
631 cookie = malloc(sizeof(struct hd64461pcmcia_window_cookie),
632 M_DEVBUF, M_NOWAIT);
633 KASSERT(cookie);
634 memset(cookie, 0, sizeof(struct hd64461pcmcia_window_cookie));
635
636 /* Address */
637 if ((kind & ~PCMCIA_WIDTH_MEM_MASK) == PCMCIA_MEM_ATTR) {
638 cookie->wc_tag = ch->ch_memt;
639 if (bus_space_subregion(ch->ch_memt, ch->ch_memh, card_addr,
640 size, &cookie->wc_handle) != 0)
641 goto bad;
642
643 *offsetp = card_addr;
644 cookie->wc_window = -1;
645 } else {
646 int window = card_addr / ch->ch_memsize;
647 KASSERT(window < MEMWIN_16M_MAX);
648
649 cookie->wc_tag = ch->ch_cmemt[window];
650 ofs = card_addr - window * ch->ch_memsize;
651 if (bus_space_map(cookie->wc_tag, ofs, size, 0,
652 &cookie->wc_handle) != 0)
653 goto bad;
654
655 /* XXX bogus. check window per common memory access. */
656 hd64461pcmcia_memory_window_16(ch->ch_channel, window);
657 *offsetp = ofs + 0x01000000; /* skip attribute area */
658 cookie->wc_window = window;
659 }
660 cookie->wc_size = size;
661 *windowp = (int)cookie;
662
663 DPRINTF("(%s) %#lx+%#lx-> %#lx+%#lx\n", kind == PCMCIA_MEM_ATTR ?
664 "attribute" : "common", ch->ch_memh, card_addr, *offsetp,
665 size);
666
667 return (0);
668 bad:
669 DPRINTF("%#lx-%#lx map failed.\n", card_addr, size);
670 free(cookie, M_DEVBUF);
671
672 return (1);
673 }
674
675 void
676 hd64461pcmcia_chip_mem_unmap(pcmcia_chipset_handle_t pch, int window)
677 {
678 struct hd64461pcmcia_window_cookie *cookie = (void *)window;
679
680 if (cookie->wc_window != -1)
681 bus_space_unmap(cookie->wc_tag, cookie->wc_handle,
682 cookie->wc_size);
683 DPRINTF("%#lx-%#x\n", cookie->wc_handle, cookie->wc_size);
684 free(cookie, M_DEVBUF);
685 }
686
687 int
688 hd64461pcmcia_chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start,
689 bus_size_t size, bus_size_t align, struct pcmcia_io_handle *pcihp)
690 {
691 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
692
693 if (ch->ch_channel == CHANNEL_1)
694 return (1);
695
696 if (start) {
697 if (bus_space_map(ch->ch_iot, start, size, 0, &pcihp->ioh)) {
698 DPRINTF("couldn't map %#lx+%#lx\n", start, size);
699 return (1);
700 }
701 DPRINTF("map %#lx+%#lx\n", start, size);
702 } else {
703 if (bus_space_alloc(ch->ch_iot, ch->ch_iobase,
704 ch->ch_iobase + ch->ch_iosize - 1,
705 size, align, 0, 0, &pcihp->addr,
706 &pcihp->ioh)) {
707 DPRINTF("couldn't allocate %#lx\n", size);
708 return (1);
709 }
710 pcihp->flags = PCMCIA_IO_ALLOCATED;
711 DPRINTF("%#lx from %#lx\n", size, pcihp->addr);
712 }
713
714 pcihp->iot = ch->ch_iot;
715 pcihp->size = size;
716
717 return (0);
718 }
719
720 int
721 hd64461pcmcia_chip_io_map(pcmcia_chipset_handle_t pch, int width,
722 bus_addr_t offset,
723 bus_size_t size, struct pcmcia_io_handle *pcihp, int *windowp)
724 {
725 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
726 #ifdef HD64461PCMCIA_DEBUG
727 static char *width_names[] = { "auto", "io8", "io16" };
728 #endif
729 if (ch->ch_channel == CHANNEL_1)
730 return (1);
731
732 hd64461_set_bus_width(CHANNEL_0, width);
733
734 /* fake. drivers init that to -1 and check if it was changed. */
735 *windowp = 0;
736
737 DPRINTF("%#lx:%#lx+%#lx %s\n", pcihp->ioh, offset, size,
738 width_names[width]);
739
740 return (0);
741 }
742
743 void
744 hd64461pcmcia_chip_io_free(pcmcia_chipset_handle_t pch,
745 struct pcmcia_io_handle *pcihp)
746 {
747 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
748
749 if (ch->ch_channel == CHANNEL_1)
750 return;
751
752 if (pcihp->flags & PCMCIA_IO_ALLOCATED)
753 bus_space_free(pcihp->iot, pcihp->ioh, pcihp->size);
754 else
755 bus_space_unmap(pcihp->iot, pcihp->ioh, pcihp->size);
756
757 DPRINTF("%#lx+%#lx\n", pcihp->ioh, pcihp->size);
758 }
759
760 void
761 hd64461pcmcia_chip_io_unmap(pcmcia_chipset_handle_t pch, int window)
762 {
763 /* nothing to do */
764 }
765
766 void
767 hd64461pcmcia_chip_socket_enable(pcmcia_chipset_handle_t pch)
768 {
769 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
770 int channel = ch->ch_channel;
771 bus_addr_t isr, gcr;
772 u_int8_t r;
773 int cardtype;
774
775 DPRINTF("enable channel %d\n", channel);
776 isr = HD64461_PCCISR(channel);
777 gcr = HD64461_PCCGCR(channel);
778
779 hd64461pcmcia_power_off(channel);
780 hd64461pcmcia_power_on(channel);
781 #if notyet
782 {
783 int i;
784 /* assert reset */
785 r = hd64461_reg_read_1(gcr);
786 r |= HD64461_PCCGCR_PCCR;
787 hd64461_reg_write_1(gcr, r);
788
789 /*
790 * hold RESET at least 10us.
791 */
792 DELAY_MS(20);
793
794 /* clear the reset flag */
795 r &= ~HD64461_PCCGCR_PCCR;
796 hd64461_reg_write_1(gcr, r);
797 DELAY_MS(2000);
798
799 /* wait for the chip to finish initializing */
800 for (i = 0; i < 10000; i++) {
801 if ((hd64461_reg_read_1(isr) & HD64461_PCCISR_READY))
802 goto reset_ok;
803 DELAY_MS(500);
804
805 if ((i > 5000) && (i % 100 == 99))
806 printf(".");
807 }
808 printf("reset failed.\n");
809 hd64461pcmcia_power_off(channel);
810 return;
811 reset_ok:
812 }
813 #endif /* notyet */
814 /* set Continuous 16-MB Area Mode */
815 ch->ch_memory_window_mode = MEMWIN_16M_MODE;
816 hd64461pcmcia_memory_window_mode(channel, ch->ch_memory_window_mode);
817
818 /*
819 * set Common memory area.
820 */
821 hd64461pcmcia_memory_window_16(channel, MEMWIN_16M_COMMON_0);
822
823 /* set the card type */
824 r = hd64461_reg_read_1(gcr);
825 if (channel == CHANNEL_0) {
826 cardtype = pcmcia_card_gettype(ch->ch_pcmcia);
827 if (cardtype == PCMCIA_IFTYPE_IO)
828 r |= HD64461_PCC0GCR_P0PCCT;
829 else
830 r &= ~HD64461_PCC0GCR_P0PCCT;
831 } else {
832 /* reserved bit must be 0 */
833 r &= ~HD64461_PCC1GCR_RESERVED;
834 }
835 hd64461_reg_write_1(gcr, r);
836
837 DPRINTF("OK.\n");
838 }
839
840 void
841 hd64461pcmcia_chip_socket_disable(pcmcia_chipset_handle_t pch)
842 {
843 struct hd64461pcmcia_channel *ch = (struct hd64461pcmcia_channel *)pch;
844 int channel = ch->ch_channel;
845
846 /* dont' disable CSC interrupt */
847 hd64461_reg_write_1(HD64461_PCCCSCIER(channel), HD64461_PCCCSCIER_CDE);
848 hd64461_reg_write_1(HD64461_PCCCSCR(channel), 0);
849
850 /* power down the socket */
851 hd64461pcmcia_power_off(channel);
852 }
853
854 /*
855 * Card detect
856 */
857 void
858 hd64461pcmcia_power_off(enum controller_channel channel)
859 {
860 #if notyet
861 u_int8_t r;
862 u_int16_t r16;
863 bus_addr_t scr, gcr;
864
865 gcr = HD64461_PCCGCR(channel);
866 scr = HD64461_PCCSCR(channel);
867
868 /* DRV (external buffer) high level */
869 r = hd64461_reg_read_1(gcr);
870 r &= ~HD64461_PCCGCR_DRVE;
871 hd64461_reg_write_1(gcr, r);
872
873 /* stop power */
874 r = hd64461_reg_read_1(scr);
875 r |= HD64461_PCCSCR_VCC1; /* VCC1 high */
876 hd64461_reg_write_1(scr, r);
877 r = hd64461_reg_read_1(gcr);
878 r |= HD64461_PCCGCR_VCC0; /* VCC0 high */
879 hd64461_reg_write_1(gcr, r);
880 /*
881 * wait 300ms until power fails (Tpf). Then, wait 100ms since
882 * we are changing Vcc (Toff).
883 */
884 DELAY_MS(300 + 100);
885
886 /* stop clock */
887 r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16);
888 r16 |= (channel == CHANNEL_0 ? HD64461_SYSSTBCR_SPC0ST :
889 HD64461_SYSSTBCR_SPC1ST);
890 hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16);
891
892 if (channel == CHANNEL_0) {
893 /* GPIO Port A XXX Jornada690 specific? */
894 r16 = hd64461_reg_read_2(HD64461_GPADR_REG16);
895 r16 |= 0xf;
896 hd64461_reg_write_2(HD64461_GPADR_REG16, r16);
897 }
898
899 #endif /* notyet */
900 }
901
902 void
903 hd64461pcmcia_power_on(enum controller_channel channel)
904 {
905 u_int8_t r;
906 u_int16_t r16;
907 bus_addr_t scr, gcr, isr;
908
909 isr = HD64461_PCCISR(channel);
910 gcr = HD64461_PCCGCR(channel);
911 scr = HD64461_PCCSCR(channel);
912
913 /*
914 * XXX to access attribute memory, this is required.
915 */
916 if (channel == CHANNEL_0) {
917 /* GPIO Port A XXX Jonanada690 specific? */
918 r16 = hd64461_reg_read_2(HD64461_GPADR_REG16);
919 r16 &= ~0xf;
920 r16 |= 0x5;
921 hd64461_reg_write_2(HD64461_GPADR_REG16, r16);
922 }
923
924 if (channel == CHANNEL_1) {
925 /* GPIO Port C, Port D XXX HP620LX specific? */
926 hd64461_reg_write_2(HD64461_GPCCR_REG16, 0xa800);
927 hd64461_reg_write_2(HD64461_GPDCR_REG16, 0xaa0a);
928 }
929
930 /* supply clock */
931 r16 = hd64461_reg_read_2(HD64461_SYSSTBCR_REG16);
932 r16 &= ~(channel == CHANNEL_0 ? HD64461_SYSSTBCR_SPC0ST :
933 HD64461_SYSSTBCR_SPC1ST);
934 hd64461_reg_write_2(HD64461_SYSSTBCR_REG16, r16);
935 DELAY_MS(200);
936
937 /* detect voltage and supply VCC */
938 r = hd64461_reg_read_1(isr);
939
940 switch (r & (HD64461_PCCISR_VS1 | HD64461_PCCISR_VS2)) {
941 case (HD64461_PCCISR_VS1 | HD64461_PCCISR_VS2): /* 5 V */
942 DPRINTF("5V card\n");
943 hd64461pcmcia_power(channel, V_5, 1);
944 break;
945 case HD64461_PCCISR_VS2: /* 3.3 / 5 V */
946 /* FALLTHROUGH */
947 case 0: /* x.x / 3.3 / 5 V */
948 DPRINTF("3.3V card\n");
949 hd64461pcmcia_power(channel, V_3_3, 1);
950 break;
951 case HD64461_PCCISR_VS1: /* x.x V */
952 /* FALLTHROUGH */
953 DPRINTF("x.x V card\n");
954 hd64461pcmcia_power(channel, V_X_X, 1);
955 return;
956 default:
957 printf("\nunknown Voltage. don't attach.\n");
958 return;
959 }
960
961 /*
962 * wait 100ms until power raise (Tpr) and 20ms to become
963 * stable (Tsu(Vcc)).
964 *
965 * some machines require some more time to be settled
966 * (300ms is added here).
967 */
968 DELAY_MS(100 + 20 + 300);
969
970 /* DRV (external buffer) low level */
971 r = hd64461_reg_read_1(gcr);
972 r |= HD64461_PCCGCR_DRVE;
973 hd64461_reg_write_1(gcr, r);
974
975 /* clear interrupt */
976 hd64461_reg_write_1(channel == CHANNEL_0 ? HD64461_PCC0CSCR_REG8 :
977 HD64461_PCC1CSCR_REG8, 0);
978 }
979
980 enum hd64461pcmcia_event_type
981 detect_card(enum controller_channel channel)
982 {
983 u_int8_t r;
984
985 r = hd64461_reg_read_1(HD64461_PCCISR(channel)) &
986 (HD64461_PCCISR_CD2 | HD64461_PCCISR_CD1);
987
988 if (r == (HD64461_PCCISR_CD2 | HD64461_PCCISR_CD1)) {
989 DPRINTF("remove\n");
990 return EVENT_REMOVE;
991 }
992 if (r == 0) {
993 DPRINTF("insert\n");
994 return EVENT_INSERT;
995 }
996 DPRINTF("transition\n");
997
998 return EVENT_NONE;
999 }
1000
1001 /*
1002 * Memory window access ops.
1003 */
1004 void
1005 hd64461pcmcia_memory_window_mode(enum controller_channel channel,
1006 enum memory_window_mode mode)
1007 {
1008 bus_addr_t a = HD64461_PCCGCR(channel);
1009 u_int8_t r = hd64461_reg_read_1(a);
1010
1011 r &= ~HD64461_PCCGCR_MMOD;
1012 r |= (mode == MEMWIN_16M_MODE) ? HD64461_PCCGCR_MMOD_16M :
1013 HD64461_PCCGCR_MMOD_32M;
1014 hd64461_reg_write_1(a, r);
1015 }
1016
1017 void
1018 hd64461pcmcia_memory_window_16(enum controller_channel channel,
1019 enum memory_window_16 window)
1020 {
1021 bus_addr_t a = HD64461_PCCGCR(channel);
1022 u_int8_t r;
1023
1024 r = hd64461_reg_read_1(a);
1025 r &= ~(HD64461_PCCGCR_PA25 | HD64461_PCCGCR_PA24);
1026
1027 switch (window) {
1028 case MEMWIN_16M_COMMON_0:
1029 break;
1030 case MEMWIN_16M_COMMON_1:
1031 r |= HD64461_PCCGCR_PA24;
1032 break;
1033 case MEMWIN_16M_COMMON_2:
1034 r |= HD64461_PCCGCR_PA25;
1035 break;
1036 case MEMWIN_16M_COMMON_3:
1037 r |= (HD64461_PCCGCR_PA25 | HD64461_PCCGCR_PA24);
1038 break;
1039 }
1040
1041 hd64461_reg_write_1(a, r);
1042 }
1043
1044 #if unused
1045 void
1046 memory_window_32(enum controller_channel channel, enum memory_window_32 window)
1047 {
1048 bus_addr_t a = HD64461_PCCGCR(channel);
1049 u_int8_t r;
1050
1051 r = hd64461_reg_read_1(a);
1052 r &= ~(HD64461_PCCGCR_PA25 | HD64461_PCCGCR_PREG);
1053
1054 switch (window) {
1055 case MEMWIN_32M_ATTR:
1056 break;
1057 case MEMWIN_32M_COMMON_0:
1058 r |= HD64461_PCCGCR_PREG;
1059 break;
1060 case MEMWIN_32M_COMMON_1:
1061 r |= (HD64461_PCCGCR_PA25 | HD64461_PCCGCR_PREG);
1062 break;
1063 }
1064
1065 hd64461_reg_write_1(a, r);
1066 }
1067 #endif
1068
1069 void
1070 hd64461_set_bus_width(enum controller_channel channel, int width)
1071 {
1072 u_int16_t r16;
1073
1074 r16 = _reg_read_2(SH3_BCR2);
1075 if (channel == CHANNEL_0) {
1076 r16 &= ~((1 << 13)|(1 << 12));
1077 r16 |= 1 << (width == PCMCIA_WIDTH_IO8 ? 12 : 13);
1078 } else {
1079 r16 &= ~((1 << 11)|(1 << 10));
1080 r16 |= 1 << (width == PCMCIA_WIDTH_IO8 ? 10 : 11);
1081 }
1082 _reg_write_2(SH3_BCR2, r16);
1083 }
1084
1085 void
1086 fixup_sh3_pcmcia_area(bus_space_tag_t t)
1087 {
1088 struct hpcsh_bus_space *hbs = (void *)t;
1089
1090 hbs->hbs_w_1 = _sh3_pcmcia_bug_write_1;
1091 hbs->hbs_wm_1 = _sh3_pcmcia_bug_write_multi_1;
1092 hbs->hbs_wr_1 = _sh3_pcmcia_bug_write_region_1;
1093 hbs->hbs_sm_1 = _sh3_pcmcia_bug_set_multi_1;
1094 }
1095
1096 #ifdef HD64461PCMCIA_DEBUG
1097 void
1098 hd64461pcmcia_info(struct hd64461pcmcia_softc *sc)
1099 {
1100 u_int8_t r8;
1101
1102 dbg_banner_function();
1103 /*
1104 * PCC0
1105 */
1106 printf("[PCC0 memory and I/O card (SH3 Area 6)]\n");
1107 printf("PCC0 Interface Status Register\n");
1108 r8 = hd64461_reg_read_1(HD64461_PCC0ISR_REG8);
1109
1110 #define _(m) dbg_bitmask_print(r8, HD64461_PCC0ISR_##m, #m)
1111 _(P0READY);_(P0MWP);_(P0VS2);_(P0VS1);_(P0CD2);_(P0CD1);
1112 _(P0BVD2);_(P0BVD1);
1113 #undef _
1114 printf("\n");
1115
1116 printf("PCC0 General Control Register\n");
1117 r8 = hd64461_reg_read_1(HD64461_PCC0GCR_REG8);
1118 #define _(m) dbg_bitmask_print(r8, HD64461_PCC0GCR_##m, #m)
1119 _(P0DRVE);_(P0PCCR);_(P0PCCT);_(P0VCC0);_(P0MMOD);
1120 _(P0PA25);_(P0PA24);_(P0REG);
1121 #undef _
1122 printf("\n");
1123
1124 printf("PCC0 Card Status Change Register\n");
1125 r8 = hd64461_reg_read_1(HD64461_PCC0CSCR_REG8);
1126 #define _(m) dbg_bitmask_print(r8, HD64461_PCC0CSCR_##m, #m)
1127 _(P0SCDI);_(P0IREQ);_(P0SC);_(P0CDC);_(P0RC);_(P0BW);_(P0BD);
1128 #undef _
1129 printf("\n");
1130
1131 printf("PCC0 Card Status Change Interrupt Enable Register\n");
1132 r8 = hd64461_reg_read_1(HD64461_PCC0CSCIER_REG8);
1133 #define _(m) dbg_bitmask_print(r8, HD64461_PCC0CSCIER_##m, #m)
1134 _(P0CRE);_(P0SCE);_(P0CDE);_(P0RE);_(P0BWE);_(P0BDE);
1135 #undef _
1136 printf("\ninterrupt type: ");
1137 switch (r8 & HD64461_PCC0CSCIER_P0IREQE_MASK) {
1138 case HD64461_PCC0CSCIER_P0IREQE_NONE:
1139 printf("none\n");
1140 break;
1141 case HD64461_PCC0CSCIER_P0IREQE_LEVEL:
1142 printf("level\n");
1143 break;
1144 case HD64461_PCC0CSCIER_P0IREQE_FEDGE:
1145 printf("falling edge\n");
1146 break;
1147 case HD64461_PCC0CSCIER_P0IREQE_REDGE:
1148 printf("rising edge\n");
1149 break;
1150 }
1151
1152 printf("PCC0 Software Control Register\n");
1153 r8 = hd64461_reg_read_1(HD64461_PCC0SCR_REG8);
1154 #define _(m) dbg_bitmask_print(r8, HD64461_PCC0SCR_##m, #m)
1155 _(P0VCC1);_(P0SWP);
1156 #undef _
1157 printf("\n");
1158
1159 /*
1160 * PCC1
1161 */
1162 printf("[PCC1 memory card only (SH3 Area 5)]\n");
1163 printf("PCC1 Interface Status Register\n");
1164 r8 = hd64461_reg_read_1(HD64461_PCC1ISR_REG8);
1165 #define _(m) dbg_bitmask_print(r8, HD64461_PCC1ISR_##m, #m)
1166 _(P1READY);_(P1MWP);_(P1VS2);_(P1VS1);_(P1CD2);_(P1CD1);
1167 _(P1BVD2);_(P1BVD1);
1168 #undef _
1169 printf("\n");
1170
1171 printf("PCC1 General Contorol Register\n");
1172 r8 = hd64461_reg_read_1(HD64461_PCC1GCR_REG8);
1173 #define _(m) dbg_bitmask_print(r8, HD64461_PCC1GCR_##m, #m)
1174 _(P1DRVE);_(P1PCCR);_(P1VCC0);_(P1MMOD);_(P1PA25);_(P1PA24);_(P1REG);
1175 #undef _
1176 printf("\n");
1177
1178 printf("PCC1 Card Status Change Register\n");
1179 r8 = hd64461_reg_read_1(HD64461_PCC1CSCR_REG8);
1180 #define _(m) dbg_bitmask_print(r8, HD64461_PCC1CSCR_##m, #m)
1181 _(P1SCDI);_(P1CDC);_(P1RC);_(P1BW);_(P1BD);
1182 #undef _
1183 printf("\n");
1184
1185 printf("PCC1 Card Status Change Interrupt Enable Register\n");
1186 r8 = hd64461_reg_read_1(HD64461_PCC1CSCIER_REG8);
1187 #define _(m) dbg_bitmask_print(r8, HD64461_PCC1CSCIER_##m, #m)
1188 _(P1CRE);_(P1CDE);_(P1RE);_(P1BWE);_(P1BDE);
1189 #undef _
1190 printf("\n");
1191
1192 printf("PCC1 Software Control Register\n");
1193 r8 = hd64461_reg_read_1(HD64461_PCC1SCR_REG8);
1194 #define _(m) dbg_bitmask_print(r8, HD64461_PCC1SCR_##m, #m)
1195 _(P1VCC1);_(P1SWP);
1196 #undef _
1197 printf("\n");
1198
1199 /*
1200 * General Control
1201 */
1202 printf("[General Control]\n");
1203 printf("PCC0 Output pins Control Register\n");
1204 r8 = hd64461_reg_read_1(HD64461_PCCP0OCR_REG8);
1205 #define _(m) dbg_bitmask_print(r8, HD64461_PCCP0OCR_##m, #m)
1206 _(P0DEPLUP);_(P0AEPLUP);
1207 #undef _
1208 printf("\n");
1209
1210 printf("PCC1 Output pins Control Register\n");
1211 r8 = hd64461_reg_read_1(HD64461_PCCP1OCR_REG8);
1212 #define _(m) dbg_bitmask_print(r8, HD64461_PCCP1OCR_##m, #m)
1213 _(P1RST8MA);_(P1RST4MA);_(P1RAS8MA);_(P1RAS4MA);
1214 #undef _
1215 printf("\n");
1216
1217 printf("PC Card General Control Register\n");
1218 r8 = hd64461_reg_read_1(HD64461_PCCPGCR_REG8);
1219 #define _(m) dbg_bitmask_print(r8, HD64461_PCCPGCR_##m, #m)
1220 _(PSSDIR);_(PSSRDWR);
1221 #undef _
1222 printf("\n");
1223
1224 dbg_banner_line();
1225 }
1226 #endif /* HD64461PCMCIA_DEBUG */
1227