Home | History | Annotate | Line # | Download | only in vr
vrip.c revision 1.3
      1  1.3  takemura /*	$NetBSD: vrip.c,v 1.3 1999/12/23 06:26:10 takemura Exp $	*/
      2  1.1  takemura 
      3  1.1  takemura /*-
      4  1.1  takemura  * Copyright (c) 1999
      5  1.1  takemura  *         Shin Takemura and PocketBSD Project. All rights reserved.
      6  1.1  takemura  *
      7  1.1  takemura  * Redistribution and use in source and binary forms, with or without
      8  1.1  takemura  * modification, are permitted provided that the following conditions
      9  1.1  takemura  * are met:
     10  1.1  takemura  * 1. Redistributions of source code must retain the above copyright
     11  1.1  takemura  *    notice, this list of conditions and the following disclaimer.
     12  1.1  takemura  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  takemura  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  takemura  *    documentation and/or other materials provided with the distribution.
     15  1.1  takemura  * 3. All advertising materials mentioning features or use of this software
     16  1.1  takemura  *    must display the following acknowledgement:
     17  1.1  takemura  *	This product includes software developed by the PocketBSD project
     18  1.1  takemura  *	and its contributors.
     19  1.1  takemura  * 4. Neither the name of the project nor the names of its contributors
     20  1.1  takemura  *    may be used to endorse or promote products derived from this software
     21  1.1  takemura  *    without specific prior written permission.
     22  1.1  takemura  *
     23  1.1  takemura  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.1  takemura  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1  takemura  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1  takemura  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.1  takemura  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1  takemura  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1  takemura  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1  takemura  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1  takemura  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1  takemura  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1  takemura  * SUCH DAMAGE.
     34  1.1  takemura  *
     35  1.1  takemura  */
     36  1.1  takemura #include <sys/param.h>
     37  1.1  takemura #include <sys/systm.h>
     38  1.1  takemura #include <sys/device.h>
     39  1.1  takemura #include <sys/reboot.h>
     40  1.1  takemura 
     41  1.1  takemura #include <machine/cpu.h>
     42  1.1  takemura #include <machine/bus.h>
     43  1.1  takemura #include <machine/autoconf.h>
     44  1.1  takemura 
     45  1.1  takemura #include <hpcmips/vr/vr.h>
     46  1.1  takemura #include <hpcmips/vr/vripreg.h>
     47  1.1  takemura #include <hpcmips/vr/vripvar.h>
     48  1.1  takemura #include <hpcmips/vr/icureg.h>
     49  1.1  takemura #include "locators.h"
     50  1.1  takemura 
     51  1.3  takemura #define VRIPDEBUG
     52  1.3  takemura #ifdef VRIPDEBUG
     53  1.3  takemura int	vrip_debug = 0;
     54  1.3  takemura #define	DPRINTF(arg) if (vrip_debug) printf arg;
     55  1.3  takemura #else
     56  1.3  takemura #define	DPRINTF(arg)
     57  1.3  takemura #endif
     58  1.3  takemura 
     59  1.1  takemura int	vripmatch __P((struct device*, struct cfdata*, void*));
     60  1.1  takemura void	vripattach __P((struct device*, struct device*, void*));
     61  1.1  takemura int	vrip_print __P((void*, const char*));
     62  1.1  takemura int	vrip_search __P((struct device*, struct cfdata*, void*));
     63  1.1  takemura int	vrip_intr __P((void*, u_int32_t, u_int32_t));
     64  1.1  takemura 
     65  1.1  takemura static void vrip_dump_level2mask __P((vrip_chipset_tag_t, void*));
     66  1.1  takemura 
     67  1.1  takemura struct cfattach vrip_ca = {
     68  1.1  takemura 	sizeof(struct vrip_softc), vripmatch, vripattach
     69  1.1  takemura };
     70  1.1  takemura 
     71  1.1  takemura #define MAX_LEVEL1 32
     72  1.1  takemura 
     73  1.2  takemura struct vrip_softc *the_vrip_sc = NULL;
     74  1.2  takemura 
     75  1.1  takemura static struct intrhand {
     76  1.1  takemura 	int	 (*ih_fun) __P((void *));
     77  1.1  takemura 	void *ih_arg;
     78  1.1  takemura 	int ih_l1line;
     79  1.1  takemura 	int	ih_ipl;
     80  1.1  takemura 	bus_addr_t	ih_lreg;
     81  1.1  takemura 	bus_addr_t	ih_mlreg;
     82  1.1  takemura 	bus_addr_t	ih_hreg;
     83  1.1  takemura 	bus_addr_t	ih_mhreg;
     84  1.1  takemura } intrhand[MAX_LEVEL1] = {
     85  1.1  takemura 	[5] = { 0, 0, 0, 0, PIUINT_REG_W,	MPIUINT_REG_W	},
     86  1.1  takemura 	[6] = { 0, 0, 0, 0, AIUINT_REG_W,	MAIUINT_REG_W	},
     87  1.1  takemura 	[7] = { 0, 0, 0, 0, KIUINT_REG_W,	MKIUINT_REG_W	},
     88  1.1  takemura 	[8] = { 0, 0, 0, 0, GIUINT_L_REG_W,	MGIUINT_L_REG_W, GIUINT_H_REG_W,	MGIUINT_H_REG_W	},
     89  1.1  takemura 	[20] = { 0, 0, 0, 0, FIRINT_REG_W,	MFIRINT_REG_W	},
     90  1.1  takemura 	[21] = { 0, 0, 0, 0, DSIUINT_REG_W,	MDSIUINT_REG_W	}
     91  1.1  takemura };
     92  1.1  takemura #define	LEGAL_LEVEL1(x)	((x) >= 0 && (x) < MAX_LEVEL1)
     93  1.1  takemura 
     94  1.1  takemura void
     95  1.1  takemura bitdisp16 (u_int16_t a)
     96  1.1  takemura {
     97  1.1  takemura 	u_int16_t j;
     98  1.1  takemura 	for (j = 0x8000; j > 0; j >>=1)
     99  1.1  takemura 		printf ("%c", a&j ?'|':'.');
    100  1.1  takemura 	printf ("\n");
    101  1.1  takemura }
    102  1.1  takemura 
    103  1.1  takemura void
    104  1.1  takemura bitdisp32 (u_int32_t a)
    105  1.1  takemura {
    106  1.1  takemura 	u_int32_t j;
    107  1.1  takemura 	for (j = 0x80000000; j > 0; j >>=1)
    108  1.1  takemura 		printf ("%c" , a&j ? '|' : '.');
    109  1.1  takemura 	printf ("\n");
    110  1.1  takemura }
    111  1.1  takemura 
    112  1.1  takemura void
    113  1.1  takemura bitdisp64(u_int32_t a[2])
    114  1.1  takemura {
    115  1.1  takemura 	u_int32_t j;
    116  1.1  takemura 	for( j = 0x80000000 ; j > 0 ; j >>=1 )
    117  1.1  takemura 		printf("%c" , a[1]&j ?';':',' );
    118  1.1  takemura 	for( j = 0x80000000 ; j > 0 ; j >>=1 )
    119  1.1  takemura 		printf("%c" , a[0]&j ?'|':'.' );
    120  1.1  takemura 	printf("\n");
    121  1.1  takemura }
    122  1.1  takemura 
    123  1.1  takemura int
    124  1.1  takemura vripmatch(parent, match, aux)
    125  1.1  takemura 	struct device *parent;
    126  1.1  takemura 	struct cfdata *match;
    127  1.1  takemura 	void *aux;
    128  1.1  takemura {
    129  1.1  takemura 	struct mainbus_attach_args *ma = aux;
    130  1.1  takemura 
    131  1.1  takemura 	if (strcmp(ma->ma_name, match->cf_driver->cd_name))
    132  1.1  takemura 		return 0;
    133  1.1  takemura 	return 1;
    134  1.1  takemura }
    135  1.1  takemura 
    136  1.1  takemura void
    137  1.1  takemura vripattach(parent, self, aux)
    138  1.1  takemura 	struct device *parent;
    139  1.1  takemura 	struct device *self;
    140  1.1  takemura 	void *aux;
    141  1.1  takemura {
    142  1.1  takemura 	struct mainbus_attach_args *ma = aux;
    143  1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc*)self;
    144  1.1  takemura 
    145  1.1  takemura 	printf("\n");
    146  1.1  takemura 	/*
    147  1.1  takemura 	 *  Map ICU (Interrupt Control Unit) register space.
    148  1.1  takemura 	 */
    149  1.1  takemura 	sc->sc_iot = ma->ma_iot;
    150  1.1  takemura 	if (bus_space_map(sc->sc_iot, VRIP_ICU_ADDR, 0x20/*XXX lower area only*/,
    151  1.1  takemura 			  0, /* no flags */
    152  1.1  takemura 			  &sc->sc_ioh)) {
    153  1.1  takemura 		printf("vripattach: can't map ICU register.\n");
    154  1.1  takemura 		return;
    155  1.1  takemura 	}
    156  1.1  takemura 
    157  1.1  takemura 	/*
    158  1.1  takemura 	 *  Disable all Level 1 interrupts.
    159  1.1  takemura 	 */
    160  1.2  takemura 	sc->sc_intrmask = 0;
    161  1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, MSYSINT1_REG_W, 0x0000);
    162  1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, MSYSINT2_REG_W, 0x0000);
    163  1.1  takemura 	/*
    164  1.1  takemura 	 *  Level 1 interrupts are redirected to HwInt0
    165  1.1  takemura 	 */
    166  1.1  takemura 	vr_intr_establish(VR_INTR0, vrip_intr, self);
    167  1.2  takemura 	the_vrip_sc = sc;
    168  1.1  takemura 	/*
    169  1.1  takemura 	 *  Attach each devices
    170  1.1  takemura 	 */
    171  1.1  takemura 	/* GIU CMU interface interface is used by other system device. so attach first */
    172  1.1  takemura 	sc->sc_pri = 2;
    173  1.1  takemura 	config_search(vrip_search, self, vrip_print);
    174  1.1  takemura 	/* Other system devices. */
    175  1.1  takemura 	sc->sc_pri = 1;
    176  1.1  takemura 	config_search(vrip_search, self, vrip_print);
    177  1.1  takemura }
    178  1.1  takemura 
    179  1.1  takemura int
    180  1.1  takemura vrip_print(aux, hoge)
    181  1.1  takemura 	void *aux;
    182  1.1  takemura 	const char *hoge;
    183  1.1  takemura {
    184  1.1  takemura 	struct vrip_attach_args *va = (struct vrip_attach_args*)aux;
    185  1.1  takemura 
    186  1.1  takemura 	if (va->va_addr)
    187  1.1  takemura 		printf(" addr 0x%x", va->va_addr);
    188  1.1  takemura 	if (va->va_size > 1)
    189  1.1  takemura 		printf("-0x%x", va->va_addr + va->va_size - 1);
    190  1.1  takemura 	if (va->va_intr != VRIPCF_INTR_DEFAULT)
    191  1.1  takemura 		printf(" intr %d", va->va_intr);
    192  1.1  takemura 	return (UNCONF);
    193  1.1  takemura }
    194  1.1  takemura 
    195  1.1  takemura int
    196  1.1  takemura vrip_search(parent, cf, aux)
    197  1.1  takemura 	struct device *parent;
    198  1.1  takemura 	struct cfdata *cf;
    199  1.1  takemura 	void *aux;
    200  1.1  takemura {
    201  1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc *)parent;
    202  1.1  takemura 	struct vrip_attach_args va;
    203  1.1  takemura 
    204  1.1  takemura 	va.va_vc = sc;
    205  1.1  takemura 	va.va_iot = sc->sc_iot;
    206  1.1  takemura 	va.va_addr = cf->cf_loc[VRIPCF_ADDR];
    207  1.1  takemura 	va.va_size = cf->cf_loc[VRIPCF_SIZE];
    208  1.1  takemura 	va.va_intr = cf->cf_loc[VRIPCF_INTR];
    209  1.1  takemura 	va.va_addr2 = cf->cf_loc[VRIPCF_ADDR2];
    210  1.1  takemura 	va.va_size2 = cf->cf_loc[VRIPCF_SIZE2];
    211  1.1  takemura 	va.va_gc = sc->sc_gc;
    212  1.1  takemura 	va.va_gf = sc->sc_gf;
    213  1.1  takemura 	va.va_cc = sc->sc_cc;
    214  1.1  takemura 	va.va_cf = sc->sc_cf;
    215  1.1  takemura 	if (((*cf->cf_attach->ca_match)(parent, cf, &va) == sc->sc_pri))
    216  1.1  takemura 		config_attach(parent, cf, &va, vrip_print);
    217  1.1  takemura 
    218  1.1  takemura 	return 0;
    219  1.1  takemura }
    220  1.1  takemura 
    221  1.1  takemura void *
    222  1.1  takemura vrip_intr_establish(vc, intr, level, ih_fun, ih_arg)
    223  1.1  takemura 	vrip_chipset_tag_t vc;
    224  1.1  takemura 	int intr;
    225  1.1  takemura 	int level; /* XXX not yet */
    226  1.1  takemura 	int (*ih_fun) __P((void *));
    227  1.1  takemura 	void *ih_arg;
    228  1.1  takemura {
    229  1.1  takemura 	struct intrhand *ih;
    230  1.1  takemura 
    231  1.1  takemura 	if (!LEGAL_LEVEL1(intr))
    232  1.1  takemura 		return 0;
    233  1.1  takemura 	ih = &intrhand[intr];
    234  1.1  takemura 	if (ih->ih_fun) /* Can't share level 1 interrupt */
    235  1.1  takemura 		return 0;
    236  1.1  takemura 	ih->ih_l1line = intr;
    237  1.1  takemura 	ih->ih_fun = ih_fun;
    238  1.1  takemura 	ih->ih_arg = ih_arg;
    239  1.1  takemura 
    240  1.1  takemura 	/* Mask level 2 interrupt mask register. (disable interrupt) */
    241  1.1  takemura 	vrip_intr_setmask2(vc, ih, ~0, 0);
    242  1.1  takemura 	/* Unmask  Level 1 interrupt mask register (enable interrupt) */
    243  1.1  takemura 	vrip_intr_setmask1(vc, ih, 1);
    244  1.1  takemura 
    245  1.1  takemura 	return (void *)ih;
    246  1.1  takemura }
    247  1.1  takemura 
    248  1.1  takemura void
    249  1.1  takemura vrip_intr_disestablish(vc, arg)
    250  1.1  takemura 	vrip_chipset_tag_t vc;
    251  1.1  takemura 	void *arg;
    252  1.1  takemura {
    253  1.1  takemura 	struct intrhand *ih = arg;
    254  1.1  takemura 	ih->ih_fun = NULL;
    255  1.1  takemura 	ih->ih_arg = NULL;
    256  1.1  takemura 	/* Mask level 2 interrupt mask register(if any). (disable interrupt) */
    257  1.1  takemura 	vrip_intr_setmask2(vc, ih, ~0, 0);
    258  1.1  takemura 	/* Mask  Level 1 interrupt mask register (disable interrupt) */
    259  1.1  takemura 	vrip_intr_setmask1(vc, ih, 0);
    260  1.1  takemura }
    261  1.1  takemura 
    262  1.2  takemura void
    263  1.2  takemura vrip_intr_suspend()
    264  1.2  takemura {
    265  1.2  takemura 	bus_space_tag_t iot = the_vrip_sc->sc_iot;
    266  1.2  takemura 	bus_space_handle_t ioh = the_vrip_sc->sc_ioh;
    267  1.2  takemura 
    268  1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, (1<<VRIP_INTR_POWER));
    269  1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, 0);
    270  1.2  takemura }
    271  1.2  takemura 
    272  1.2  takemura void
    273  1.2  takemura vrip_intr_resume()
    274  1.2  takemura {
    275  1.2  takemura 	u_int32_t reg = the_vrip_sc->sc_intrmask;
    276  1.2  takemura 	bus_space_tag_t iot = the_vrip_sc->sc_iot;
    277  1.2  takemura 	bus_space_handle_t ioh = the_vrip_sc->sc_ioh;
    278  1.2  takemura 
    279  1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, reg & 0xffff);
    280  1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, (reg >> 16) & 0xffff);
    281  1.2  takemura }
    282  1.2  takemura 
    283  1.1  takemura /* Set level 1 interrupt mask. */
    284  1.1  takemura void
    285  1.1  takemura vrip_intr_setmask1(vc, arg, enable)
    286  1.1  takemura 	vrip_chipset_tag_t vc;
    287  1.1  takemura 	void *arg;
    288  1.1  takemura 	int enable;
    289  1.1  takemura {
    290  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    291  1.1  takemura 	struct intrhand *ih = arg;
    292  1.1  takemura 	int level1 = ih->ih_l1line;
    293  1.1  takemura 	bus_space_tag_t iot = sc->sc_iot;
    294  1.1  takemura 	bus_space_handle_t ioh = sc->sc_ioh;
    295  1.2  takemura 	u_int32_t reg = sc->sc_intrmask;
    296  1.1  takemura 
    297  1.1  takemura 	reg = (bus_space_read_2 (iot, ioh, MSYSINT1_REG_W)&0xffff) |
    298  1.1  takemura 		((bus_space_read_2 (iot, ioh, MSYSINT2_REG_W)<< 16)&0xffff0000);
    299  1.1  takemura 	if (enable)
    300  1.1  takemura 		reg |= (1 << level1);
    301  1.1  takemura 	else {
    302  1.1  takemura 		reg &= ~(1 << level1);
    303  1.1  takemura 	}
    304  1.2  takemura 	sc->sc_intrmask = reg;
    305  1.1  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, reg & 0xffff);
    306  1.1  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, (reg >> 16) & 0xffff);
    307  1.3  takemura #ifdef VRIPDEBUG
    308  1.3  takemura 	if (vrip_debug)
    309  1.3  takemura 		bitdisp32(reg);
    310  1.3  takemura #endif /* VRIPDEBUG */
    311  1.1  takemura 
    312  1.1  takemura 	return;
    313  1.1  takemura }
    314  1.1  takemura 
    315  1.1  takemura static void
    316  1.1  takemura vrip_dump_level2mask (vc, arg)
    317  1.1  takemura 	vrip_chipset_tag_t vc;
    318  1.1  takemura 	void *arg;
    319  1.1  takemura {
    320  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    321  1.1  takemura 	struct intrhand *ih = arg;
    322  1.1  takemura 	u_int32_t reg;
    323  1.1  takemura 
    324  1.1  takemura 	if (ih->ih_mlreg) {
    325  1.1  takemura 		printf ("level1[%d] level2 mask:", ih->ih_l1line);
    326  1.1  takemura 		reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg);
    327  1.1  takemura 		if (ih->ih_mhreg) { /* GIU [16:31] case only */
    328  1.1  takemura 			reg |= (bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mhreg) << 16);
    329  1.1  takemura 			bitdisp32(reg);
    330  1.1  takemura 		} else
    331  1.1  takemura 			bitdisp16(reg);
    332  1.1  takemura 	}
    333  1.1  takemura }
    334  1.1  takemura 
    335  1.1  takemura /* Get level 2 interrupt status */
    336  1.1  takemura void
    337  1.1  takemura vrip_intr_get_status2(vc, arg, mask)
    338  1.1  takemura 	vrip_chipset_tag_t vc;
    339  1.1  takemura 	void *arg;
    340  1.1  takemura 	u_int32_t *mask; /* Level 2 mask */
    341  1.1  takemura {
    342  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    343  1.1  takemura 	struct intrhand *ih = arg;
    344  1.1  takemura 	u_int32_t reg;
    345  1.1  takemura 	reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    346  1.1  takemura 			       ih->ih_lreg);
    347  1.1  takemura 	reg |= ((bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    348  1.1  takemura 				  ih->ih_hreg) << 16)&0xffff0000);
    349  1.1  takemura /*    bitdisp32(reg);*/
    350  1.1  takemura 	*mask = reg;
    351  1.1  takemura }
    352  1.1  takemura 
    353  1.1  takemura /* Set level 2 interrupt mask. */
    354  1.1  takemura void
    355  1.1  takemura vrip_intr_setmask2(vc, arg, mask, onoff)
    356  1.1  takemura 	vrip_chipset_tag_t vc;
    357  1.1  takemura 	void *arg;
    358  1.1  takemura 	u_int32_t mask; /* Level 2 mask */
    359  1.1  takemura {
    360  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    361  1.1  takemura 	struct intrhand *ih = arg;
    362  1.1  takemura 	u_int16_t reg;
    363  1.3  takemura 
    364  1.3  takemura #ifdef VRIPDEBUG
    365  1.3  takemura 	if (vrip_debug) {
    366  1.3  takemura 		printf("vrip_intr_setmask2:\n");
    367  1.3  takemura 		vrip_dump_level2mask (vc, arg);
    368  1.3  takemura 	}
    369  1.3  takemura #endif /* VRIPDEBUG */
    370  1.1  takemura #ifdef WINCE_DEFAULT_SETTING
    371  1.1  takemura #warning WINCE_DEFAULT_SETTING
    372  1.1  takemura #else
    373  1.1  takemura 	if (ih->ih_mlreg) {
    374  1.1  takemura 		reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg);
    375  1.1  takemura 		if (onoff)
    376  1.1  takemura 			reg |= (mask&0xffff);
    377  1.1  takemura 		else
    378  1.1  takemura 			reg &= ~(mask&0xffff);
    379  1.1  takemura 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg, reg);
    380  1.1  takemura 		if (ih->ih_mhreg != -1) { /* GIU [16:31] case only */
    381  1.1  takemura 			reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mhreg);
    382  1.1  takemura 			if (onoff)
    383  1.1  takemura 				reg |= ((mask >> 16) & 0xffff);
    384  1.1  takemura 			else
    385  1.1  takemura 				reg &= ~((mask >> 16) & 0xffff);
    386  1.1  takemura 			bus_space_write_2(sc->sc_iot, sc->sc_ioh,
    387  1.1  takemura 					  ih->ih_mhreg, reg);
    388  1.1  takemura 		}
    389  1.1  takemura 	}
    390  1.1  takemura #endif /* WINCE_DEFAULT_SETTING */
    391  1.3  takemura #ifdef VRIPDEBUG
    392  1.3  takemura 	if (vrip_debug)
    393  1.3  takemura 		vrip_dump_level2mask (vc, arg);
    394  1.3  takemura #endif /* VRIPDEBUG */
    395  1.3  takemura 
    396  1.1  takemura 	return;
    397  1.1  takemura }
    398  1.1  takemura 
    399  1.1  takemura int
    400  1.1  takemura vrip_intr(arg, pc, statusReg)
    401  1.1  takemura 	void *arg;
    402  1.1  takemura 	u_int32_t pc;
    403  1.1  takemura 	u_int32_t statusReg;
    404  1.1  takemura {
    405  1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc*)arg;
    406  1.1  takemura 	bus_space_tag_t iot = sc->sc_iot;
    407  1.1  takemura 	bus_space_handle_t ioh = sc->sc_ioh;
    408  1.1  takemura 	int i;
    409  1.1  takemura 	u_int32_t reg, mask;
    410  1.1  takemura 	/*
    411  1.1  takemura 	 *  Read level1 interrupt status.
    412  1.1  takemura 	 */
    413  1.1  takemura 	reg = (bus_space_read_2 (iot, ioh, SYSINT1_REG_W)&0xffff) |
    414  1.1  takemura 		((bus_space_read_2 (iot, ioh, SYSINT2_REG_W)<< 16)&0xffff0000);
    415  1.1  takemura 	mask = (bus_space_read_2 (iot, ioh, MSYSINT1_REG_W)&0xffff) |
    416  1.1  takemura 		((bus_space_read_2 (iot, ioh, MSYSINT2_REG_W)<< 16)&0xffff0000);
    417  1.1  takemura 	reg &= mask;
    418  1.1  takemura 
    419  1.1  takemura 	/*
    420  1.1  takemura 	 *  Dispatch each handler.
    421  1.1  takemura 	 */
    422  1.1  takemura 	for (i = 0; i < 32; i++) {
    423  1.1  takemura 		register struct intrhand *ih = &intrhand[i];
    424  1.1  takemura 		if (ih->ih_fun && (reg & (1 << i))) {
    425  1.1  takemura 			ih->ih_fun(ih->ih_arg);
    426  1.1  takemura 		}
    427  1.1  takemura 	}
    428  1.1  takemura 	return 1;
    429  1.1  takemura }
    430  1.1  takemura 
    431  1.1  takemura void
    432  1.1  takemura vrip_cmu_function_register(vc, func, arg)
    433  1.1  takemura 	vrip_chipset_tag_t vc;
    434  1.1  takemura 	vrcmu_function_tag_t func;
    435  1.1  takemura 	vrcmu_chipset_tag_t arg;
    436  1.1  takemura {
    437  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    438  1.1  takemura 	sc->sc_cf = func;
    439  1.1  takemura 	sc->sc_cc = arg;
    440  1.1  takemura }
    441  1.1  takemura 
    442  1.1  takemura void
    443  1.1  takemura vrip_giu_function_register(vc, func, arg)
    444  1.1  takemura 	vrip_chipset_tag_t vc;
    445  1.1  takemura 	vrgiu_function_tag_t func;
    446  1.1  takemura 	vrgiu_chipset_tag_t arg;
    447  1.1  takemura {
    448  1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    449  1.1  takemura 	sc->sc_gf = func;
    450  1.1  takemura 	sc->sc_gc = arg;
    451  1.1  takemura }
    452  1.1  takemura 
    453