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