Home | History | Annotate | Line # | Download | only in vr
vrip.c revision 1.12
      1  1.12       uch /*	$NetBSD: vrip.c,v 1.12 2001/09/16 05:32:21 uch 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.7      sato #include "opt_vr41xx.h"
     37   1.7      sato #include "opt_tx39xx.h"
     38   1.7      sato 
     39   1.1  takemura #include <sys/param.h>
     40   1.1  takemura #include <sys/systm.h>
     41   1.1  takemura #include <sys/device.h>
     42   1.1  takemura #include <sys/reboot.h>
     43   1.1  takemura 
     44   1.1  takemura #include <machine/cpu.h>
     45   1.1  takemura #include <machine/bus.h>
     46   1.1  takemura #include <machine/autoconf.h>
     47   1.8      sato #include <machine/platid.h>
     48   1.8      sato #include <machine/platid_mask.h>
     49   1.1  takemura 
     50   1.1  takemura #include <hpcmips/vr/vr.h>
     51   1.9      sato #include <hpcmips/vr/vrcpudef.h>
     52   1.1  takemura #include <hpcmips/vr/vripreg.h>
     53   1.1  takemura #include <hpcmips/vr/vripvar.h>
     54   1.1  takemura #include <hpcmips/vr/icureg.h>
     55   1.1  takemura #include "locators.h"
     56   1.1  takemura 
     57   1.3  takemura #define VRIPDEBUG
     58   1.3  takemura #ifdef VRIPDEBUG
     59   1.6      sato #ifndef VRIPDEBUG_CONF
     60   1.6      sato #define VRIPDEBUG_CONF 0
     61   1.6      sato #endif /* VRIPDEBUG_CONF */
     62   1.6      sato int	vrip_debug = VRIPDEBUG_CONF;
     63   1.6      sato #define DPRINTF(arg) if (vrip_debug) printf arg;
     64   1.6      sato #define DBITDISP32(reg) if (vrip_debug) bitdisp32(reg);
     65   1.6      sato #define DDUMP_LEVEL2MASK(sc,arg) if (vrip_debug) vrip_dump_level2mask(sc,arg)
     66   1.3  takemura #else
     67   1.6      sato #define DPRINTF(arg)
     68   1.6      sato #define DBITDISP32(arg)
     69   1.6      sato #define DDUMP_LEVEL2MASK(sc,arg)
     70   1.3  takemura #endif
     71   1.3  takemura 
     72  1.12       uch int	vripmatch(struct device *, struct cfdata *, void *);
     73  1.12       uch void	vripattach(struct device *, struct device *, void *);
     74  1.12       uch int	vrip_print(void *, const char *);
     75  1.12       uch int	vrip_search(struct device *, struct cfdata *, void *);
     76  1.12       uch int	vrip_intr(void *, u_int32_t, u_int32_t);
     77   1.1  takemura 
     78  1.12       uch static void vrip_dump_level2mask(vrip_chipset_tag_t, void *);
     79   1.1  takemura 
     80   1.1  takemura struct cfattach vrip_ca = {
     81   1.1  takemura 	sizeof(struct vrip_softc), vripmatch, vripattach
     82   1.1  takemura };
     83   1.1  takemura 
     84   1.1  takemura #define MAX_LEVEL1 32
     85   1.1  takemura 
     86   1.2  takemura struct vrip_softc *the_vrip_sc = NULL;
     87   1.2  takemura 
     88   1.1  takemura static struct intrhand {
     89  1.12       uch 	int	(*ih_fun)(void *);
     90  1.11     enami 	void	*ih_arg;
     91  1.11     enami 	int	ih_l1line;
     92   1.1  takemura 	int	ih_ipl;
     93   1.1  takemura 	bus_addr_t	ih_lreg;
     94   1.1  takemura 	bus_addr_t	ih_mlreg;
     95   1.1  takemura 	bus_addr_t	ih_hreg;
     96   1.1  takemura 	bus_addr_t	ih_mhreg;
     97   1.1  takemura } intrhand[MAX_LEVEL1] = {
     98  1.12       uch 	[VRIP_INTR_PIU] = { 0, 0, 0, 0, ICUPIUINT_REG_W,MPIUINT_REG_W	},
     99   1.9      sato 	[VRIP_INTR_AIU] = { 0, 0, 0, 0, AIUINT_REG_W,	MAIUINT_REG_W	},
    100   1.9      sato 	[VRIP_INTR_KIU] = { 0, 0, 0, 0, KIUINT_REG_W,	MKIUINT_REG_W	},
    101  1.12       uch 	[VRIP_INTR_GIU] = { 0, 0, 0, 0, GIUINT_L_REG_W,	MGIUINT_L_REG_W,
    102  1.12       uch 			    GIUINT_H_REG_W,	MGIUINT_H_REG_W	},
    103   1.9      sato 	[VRIP_INTR_FIR] = { 0, 0, 0, 0, FIRINT_REG_W,	MFIRINT_REG_W	},
    104   1.9      sato 	[VRIP_INTR_DSIU] = { 0, 0, 0, 0, DSIUINT_REG_W,	MDSIUINT_REG_W	},
    105   1.9      sato 	[VRIP_INTR_PCI] = { 0, 0, 0, 0, PCIINT_REG_W,	MPCIINT_REG_W	},
    106   1.9      sato 	[VRIP_INTR_SCU] = { 0, 0, 0, 0, SCUINT_REG_W,	MSCUINT_REG_W	},
    107   1.9      sato 	[VRIP_INTR_CSI] = { 0, 0, 0, 0, CSIINT_REG_W,	MCSIINT_REG_W	},
    108   1.9      sato 	[VRIP_INTR_BCU] = { 0, 0, 0, 0, BCUINT_REG_W,	MBCUINT_REG_W	}
    109   1.1  takemura };
    110   1.9      sato 
    111   1.1  takemura #define	LEGAL_LEVEL1(x)	((x) >= 0 && (x) < MAX_LEVEL1)
    112   1.1  takemura 
    113   1.1  takemura void
    114  1.12       uch bitdisp16(u_int16_t a)
    115   1.1  takemura {
    116   1.1  takemura 	u_int16_t j;
    117  1.12       uch 
    118   1.1  takemura 	for (j = 0x8000; j > 0; j >>=1)
    119   1.1  takemura 		printf ("%c", a&j ?'|':'.');
    120   1.1  takemura 	printf ("\n");
    121   1.1  takemura }
    122   1.1  takemura 
    123   1.1  takemura void
    124  1.12       uch bitdisp32(u_int32_t a)
    125   1.1  takemura {
    126   1.1  takemura 	u_int32_t j;
    127  1.12       uch 
    128   1.1  takemura 	for (j = 0x80000000; j > 0; j >>=1)
    129   1.1  takemura 		printf ("%c" , a&j ? '|' : '.');
    130   1.1  takemura 	printf ("\n");
    131   1.1  takemura }
    132   1.1  takemura 
    133   1.1  takemura void
    134   1.1  takemura bitdisp64(u_int32_t a[2])
    135   1.1  takemura {
    136   1.1  takemura 	u_int32_t j;
    137  1.12       uch 
    138   1.1  takemura 	for( j = 0x80000000 ; j > 0 ; j >>=1 )
    139   1.1  takemura 		printf("%c" , a[1]&j ?';':',' );
    140   1.1  takemura 	for( j = 0x80000000 ; j > 0 ; j >>=1 )
    141   1.1  takemura 		printf("%c" , a[0]&j ?'|':'.' );
    142   1.1  takemura 	printf("\n");
    143   1.1  takemura }
    144   1.1  takemura 
    145   1.1  takemura int
    146  1.12       uch vripmatch(struct device *parent, struct cfdata *match, void *aux)
    147   1.1  takemura {
    148   1.1  takemura 	struct mainbus_attach_args *ma = aux;
    149   1.7      sato 
    150   1.7      sato #ifdef TX39XX
    151   1.7      sato 	if (!platid_match(&platid, &platid_mask_CPU_MIPS_VR_41XX))
    152  1.12       uch 		return (1);
    153   1.7      sato #endif /* !TX39XX */
    154   1.1  takemura 	if (strcmp(ma->ma_name, match->cf_driver->cd_name))
    155  1.12       uch 		return (0);
    156  1.12       uch 
    157  1.12       uch 	return (1);
    158   1.1  takemura }
    159   1.1  takemura 
    160   1.1  takemura void
    161  1.12       uch vripattach(struct device *parent, struct device *self, void *aux)
    162   1.1  takemura {
    163   1.1  takemura 	struct mainbus_attach_args *ma = aux;
    164   1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc*)self;
    165   1.1  takemura 
    166   1.1  takemura 	printf("\n");
    167   1.1  takemura 	/*
    168   1.1  takemura 	 *  Map ICU (Interrupt Control Unit) register space.
    169   1.1  takemura 	 */
    170   1.1  takemura 	sc->sc_iot = ma->ma_iot;
    171  1.12       uch 	if (bus_space_map(sc->sc_iot, VRIP_ICU_ADDR,
    172  1.12       uch 	    0x20	/*XXX lower area only*/,
    173  1.12       uch 	    0,		/* no flags */
    174  1.12       uch 	    &sc->sc_ioh)) {
    175   1.1  takemura 		printf("vripattach: can't map ICU register.\n");
    176   1.1  takemura 		return;
    177   1.1  takemura 	}
    178   1.1  takemura 
    179   1.1  takemura 	/*
    180   1.1  takemura 	 *  Disable all Level 1 interrupts.
    181   1.1  takemura 	 */
    182   1.2  takemura 	sc->sc_intrmask = 0;
    183   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, MSYSINT1_REG_W, 0x0000);
    184   1.1  takemura 	bus_space_write_2(sc->sc_iot, sc->sc_ioh, MSYSINT2_REG_W, 0x0000);
    185   1.1  takemura 	/*
    186   1.1  takemura 	 *  Level 1 interrupts are redirected to HwInt0
    187   1.1  takemura 	 */
    188   1.1  takemura 	vr_intr_establish(VR_INTR0, vrip_intr, self);
    189   1.2  takemura 	the_vrip_sc = sc;
    190   1.1  takemura 	/*
    191   1.1  takemura 	 *  Attach each devices
    192  1.12       uch 	 *	GIU CMU interface interface is used by other system device.
    193  1.12       uch 	 *	so attach first
    194   1.1  takemura 	 */
    195   1.1  takemura 	sc->sc_pri = 2;
    196   1.1  takemura 	config_search(vrip_search, self, vrip_print);
    197   1.1  takemura 	/* Other system devices. */
    198   1.1  takemura 	sc->sc_pri = 1;
    199   1.1  takemura 	config_search(vrip_search, self, vrip_print);
    200   1.1  takemura }
    201   1.1  takemura 
    202   1.1  takemura int
    203  1.12       uch vrip_print(void *aux, const char *hoge)
    204   1.1  takemura {
    205   1.1  takemura 	struct vrip_attach_args *va = (struct vrip_attach_args*)aux;
    206   1.1  takemura 
    207   1.1  takemura 	if (va->va_addr)
    208   1.5  takemura 		printf(" addr 0x%lx", va->va_addr);
    209   1.1  takemura 	if (va->va_size > 1)
    210   1.5  takemura 		printf("-0x%lx", va->va_addr + va->va_size - 1);
    211   1.1  takemura 	if (va->va_intr != VRIPCF_INTR_DEFAULT)
    212   1.1  takemura 		printf(" intr %d", va->va_intr);
    213  1.12       uch 
    214   1.1  takemura 	return (UNCONF);
    215   1.1  takemura }
    216   1.1  takemura 
    217   1.1  takemura int
    218  1.12       uch vrip_search(struct device *parent, struct cfdata *cf, void *aux)
    219   1.1  takemura {
    220   1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc *)parent;
    221   1.1  takemura 	struct vrip_attach_args va;
    222   1.1  takemura 
    223   1.1  takemura 	va.va_vc = sc;
    224   1.1  takemura 	va.va_iot = sc->sc_iot;
    225   1.1  takemura 	va.va_addr = cf->cf_loc[VRIPCF_ADDR];
    226   1.1  takemura 	va.va_size = cf->cf_loc[VRIPCF_SIZE];
    227   1.1  takemura 	va.va_intr = cf->cf_loc[VRIPCF_INTR];
    228   1.1  takemura 	va.va_addr2 = cf->cf_loc[VRIPCF_ADDR2];
    229   1.1  takemura 	va.va_size2 = cf->cf_loc[VRIPCF_SIZE2];
    230  1.10  takemura 	va.va_gpio_chips = sc->sc_gpio_chips;
    231   1.1  takemura 	va.va_cc = sc->sc_cc;
    232   1.1  takemura 	va.va_cf = sc->sc_cf;
    233   1.1  takemura 	if (((*cf->cf_attach->ca_match)(parent, cf, &va) == sc->sc_pri))
    234   1.1  takemura 		config_attach(parent, cf, &va, vrip_print);
    235   1.1  takemura 
    236  1.12       uch 	return (0);
    237   1.1  takemura }
    238   1.1  takemura 
    239   1.1  takemura void *
    240  1.12       uch vrip_intr_establish(vrip_chipset_tag_t vc, int intr, int level,
    241  1.12       uch     int (*ih_fun)(void *), void *ih_arg)
    242   1.1  takemura {
    243   1.1  takemura 	struct intrhand *ih;
    244   1.1  takemura 
    245   1.1  takemura 	if (!LEGAL_LEVEL1(intr))
    246  1.12       uch 		return (0);
    247   1.1  takemura 	ih = &intrhand[intr];
    248   1.1  takemura 	if (ih->ih_fun) /* Can't share level 1 interrupt */
    249  1.12       uch 		return (0);
    250   1.1  takemura 	ih->ih_l1line = intr;
    251   1.1  takemura 	ih->ih_fun = ih_fun;
    252   1.1  takemura 	ih->ih_arg = ih_arg;
    253   1.1  takemura 
    254   1.1  takemura 	/* Mask level 2 interrupt mask register. (disable interrupt) */
    255   1.1  takemura 	vrip_intr_setmask2(vc, ih, ~0, 0);
    256   1.1  takemura 	/* Unmask  Level 1 interrupt mask register (enable interrupt) */
    257   1.1  takemura 	vrip_intr_setmask1(vc, ih, 1);
    258   1.1  takemura 
    259  1.12       uch 	return ((void *)ih);
    260   1.1  takemura }
    261   1.1  takemura 
    262   1.1  takemura void
    263  1.12       uch vrip_intr_disestablish(vrip_chipset_tag_t vc, void *arg)
    264   1.1  takemura {
    265   1.1  takemura 	struct intrhand *ih = arg;
    266  1.12       uch 
    267   1.1  takemura 	ih->ih_fun = NULL;
    268   1.1  takemura 	ih->ih_arg = NULL;
    269   1.1  takemura 	/* Mask level 2 interrupt mask register(if any). (disable interrupt) */
    270   1.1  takemura 	vrip_intr_setmask2(vc, ih, ~0, 0);
    271   1.1  takemura 	/* Mask  Level 1 interrupt mask register (disable interrupt) */
    272   1.1  takemura 	vrip_intr_setmask1(vc, ih, 0);
    273   1.1  takemura }
    274   1.1  takemura 
    275   1.2  takemura void
    276   1.2  takemura vrip_intr_suspend()
    277   1.2  takemura {
    278   1.2  takemura 	bus_space_tag_t iot = the_vrip_sc->sc_iot;
    279   1.2  takemura 	bus_space_handle_t ioh = the_vrip_sc->sc_ioh;
    280   1.2  takemura 
    281   1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, (1<<VRIP_INTR_POWER));
    282   1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, 0);
    283   1.2  takemura }
    284   1.2  takemura 
    285   1.2  takemura void
    286   1.2  takemura vrip_intr_resume()
    287   1.2  takemura {
    288   1.2  takemura 	u_int32_t reg = the_vrip_sc->sc_intrmask;
    289   1.2  takemura 	bus_space_tag_t iot = the_vrip_sc->sc_iot;
    290   1.2  takemura 	bus_space_handle_t ioh = the_vrip_sc->sc_ioh;
    291   1.2  takemura 
    292   1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, reg & 0xffff);
    293   1.2  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, (reg >> 16) & 0xffff);
    294   1.2  takemura }
    295   1.2  takemura 
    296   1.1  takemura /* Set level 1 interrupt mask. */
    297   1.1  takemura void
    298  1.12       uch vrip_intr_setmask1(vrip_chipset_tag_t vc, void *arg, int enable)
    299   1.1  takemura {
    300   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    301   1.1  takemura 	struct intrhand *ih = arg;
    302   1.1  takemura 	int level1 = ih->ih_l1line;
    303   1.1  takemura 	bus_space_tag_t iot = sc->sc_iot;
    304   1.1  takemura 	bus_space_handle_t ioh = sc->sc_ioh;
    305   1.2  takemura 	u_int32_t reg = sc->sc_intrmask;
    306   1.1  takemura 
    307   1.1  takemura 	reg = (bus_space_read_2 (iot, ioh, MSYSINT1_REG_W)&0xffff) |
    308  1.12       uch 	    ((bus_space_read_2 (iot, ioh, MSYSINT2_REG_W)<< 16)&0xffff0000);
    309   1.1  takemura 	if (enable)
    310   1.1  takemura 		reg |= (1 << level1);
    311   1.1  takemura 	else {
    312   1.1  takemura 		reg &= ~(1 << level1);
    313   1.1  takemura 	}
    314   1.2  takemura 	sc->sc_intrmask = reg;
    315   1.1  takemura 	bus_space_write_2 (iot, ioh, MSYSINT1_REG_W, reg & 0xffff);
    316   1.1  takemura 	bus_space_write_2 (iot, ioh, MSYSINT2_REG_W, (reg >> 16) & 0xffff);
    317   1.6      sato 	DBITDISP32(reg);
    318   1.1  takemura 
    319   1.1  takemura 	return;
    320   1.1  takemura }
    321   1.1  takemura 
    322   1.1  takemura static void
    323  1.12       uch vrip_dump_level2mask(vrip_chipset_tag_t vc, void *arg)
    324   1.1  takemura {
    325   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    326   1.1  takemura 	struct intrhand *ih = arg;
    327   1.1  takemura 	u_int32_t reg;
    328   1.1  takemura 
    329   1.1  takemura 	if (ih->ih_mlreg) {
    330   1.1  takemura 		printf ("level1[%d] level2 mask:", ih->ih_l1line);
    331   1.1  takemura 		reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg);
    332   1.1  takemura 		if (ih->ih_mhreg) { /* GIU [16:31] case only */
    333   1.1  takemura 			reg |= (bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mhreg) << 16);
    334   1.1  takemura 			bitdisp32(reg);
    335   1.1  takemura 		} else
    336   1.1  takemura 			bitdisp16(reg);
    337   1.1  takemura 	}
    338   1.1  takemura }
    339   1.1  takemura 
    340   1.1  takemura /* Get level 2 interrupt status */
    341   1.1  takemura void
    342  1.12       uch vrip_intr_get_status2(vrip_chipset_tag_t vc, void *arg,
    343  1.12       uch     u_int32_t *mask /* Level 2 mask */)
    344   1.1  takemura {
    345   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    346   1.1  takemura 	struct intrhand *ih = arg;
    347   1.1  takemura 	u_int32_t reg;
    348  1.12       uch 
    349   1.1  takemura 	reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    350  1.12       uch 	    ih->ih_lreg);
    351   1.1  takemura 	reg |= ((bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    352  1.12       uch 	    ih->ih_hreg) << 16)&0xffff0000);
    353   1.1  takemura /*    bitdisp32(reg);*/
    354   1.1  takemura 	*mask = reg;
    355   1.1  takemura }
    356   1.1  takemura 
    357   1.1  takemura /* Set level 2 interrupt mask. */
    358   1.1  takemura void
    359  1.12       uch vrip_intr_setmask2(vrip_chipset_tag_t vc, void *arg,
    360  1.12       uch     u_int32_t mask /* Level 2 mask */, int onoff)
    361   1.1  takemura {
    362   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    363   1.1  takemura 	struct intrhand *ih = arg;
    364   1.1  takemura 	u_int16_t reg;
    365   1.3  takemura 
    366   1.6      sato 	DPRINTF(("vrip_intr_setmask2:\n"));
    367   1.6      sato 	DDUMP_LEVEL2MASK(vc, arg);
    368   1.1  takemura #ifdef WINCE_DEFAULT_SETTING
    369   1.1  takemura #warning WINCE_DEFAULT_SETTING
    370   1.1  takemura #else
    371   1.1  takemura 	if (ih->ih_mlreg) {
    372   1.1  takemura 		reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg);
    373   1.1  takemura 		if (onoff)
    374   1.1  takemura 			reg |= (mask&0xffff);
    375   1.1  takemura 		else
    376   1.1  takemura 			reg &= ~(mask&0xffff);
    377   1.1  takemura 		bus_space_write_2(sc->sc_iot, sc->sc_ioh, ih->ih_mlreg, reg);
    378   1.1  takemura 		if (ih->ih_mhreg != -1) { /* GIU [16:31] case only */
    379  1.12       uch 			reg = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
    380  1.12       uch 			    ih->ih_mhreg);
    381   1.1  takemura 			if (onoff)
    382   1.1  takemura 				reg |= ((mask >> 16) & 0xffff);
    383   1.1  takemura 			else
    384  1.12       uch 				reg &= ~((mask >> 16) & 0xffff);
    385   1.1  takemura 			bus_space_write_2(sc->sc_iot, sc->sc_ioh,
    386  1.12       uch 			    ih->ih_mhreg, reg);
    387   1.1  takemura 		}
    388   1.1  takemura 	}
    389   1.1  takemura #endif /* WINCE_DEFAULT_SETTING */
    390   1.6      sato 	DDUMP_LEVEL2MASK(vc, arg);
    391   1.3  takemura 
    392   1.1  takemura 	return;
    393   1.1  takemura }
    394   1.1  takemura 
    395   1.1  takemura int
    396  1.12       uch vrip_intr(void *arg, u_int32_t pc, u_int32_t statusReg)
    397   1.1  takemura {
    398   1.1  takemura 	struct vrip_softc *sc = (struct vrip_softc*)arg;
    399   1.1  takemura 	bus_space_tag_t iot = sc->sc_iot;
    400   1.1  takemura 	bus_space_handle_t ioh = sc->sc_ioh;
    401   1.1  takemura 	int i;
    402   1.1  takemura 	u_int32_t reg, mask;
    403   1.1  takemura 	/*
    404   1.1  takemura 	 *  Read level1 interrupt status.
    405   1.1  takemura 	 */
    406   1.1  takemura 	reg = (bus_space_read_2 (iot, ioh, SYSINT1_REG_W)&0xffff) |
    407  1.12       uch 	    ((bus_space_read_2 (iot, ioh, SYSINT2_REG_W)<< 16)&0xffff0000);
    408   1.1  takemura 	mask = (bus_space_read_2 (iot, ioh, MSYSINT1_REG_W)&0xffff) |
    409  1.12       uch 	    ((bus_space_read_2 (iot, ioh, MSYSINT2_REG_W)<< 16)&0xffff0000);
    410   1.1  takemura 	reg &= mask;
    411   1.1  takemura 
    412   1.1  takemura 	/*
    413   1.1  takemura 	 *  Dispatch each handler.
    414   1.1  takemura 	 */
    415   1.1  takemura 	for (i = 0; i < 32; i++) {
    416   1.1  takemura 		register struct intrhand *ih = &intrhand[i];
    417   1.1  takemura 		if (ih->ih_fun && (reg & (1 << i))) {
    418   1.1  takemura 			ih->ih_fun(ih->ih_arg);
    419   1.1  takemura 		}
    420   1.1  takemura 	}
    421  1.12       uch 
    422  1.12       uch 	return (1);
    423   1.1  takemura }
    424   1.1  takemura 
    425   1.1  takemura void
    426  1.12       uch vrip_cmu_function_register(vrip_chipset_tag_t vc, vrcmu_function_tag_t func,
    427  1.12       uch     vrcmu_chipset_tag_t arg)
    428   1.1  takemura {
    429   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    430  1.12       uch 
    431   1.1  takemura 	sc->sc_cf = func;
    432   1.1  takemura 	sc->sc_cc = arg;
    433   1.1  takemura }
    434   1.1  takemura 
    435   1.1  takemura void
    436  1.12       uch vrip_gpio_register(vrip_chipset_tag_t vc, hpcio_chip_t chip)
    437   1.1  takemura {
    438   1.1  takemura 	struct vrip_softc *sc = (void*)vc;
    439  1.10  takemura 
    440  1.10  takemura 	if (chip->hc_chipid < 0 || VRIP_NIOCHIPS <= chip->hc_chipid)
    441  1.10  takemura 		panic("%s: '%s' has unknown id, %d", __FUNCTION__,
    442  1.10  takemura 		    chip->hc_name, chip->hc_chipid);
    443  1.10  takemura 	sc->sc_gpio_chips[chip->hc_chipid] = chip;
    444   1.1  takemura }
    445