Home | History | Annotate | Line # | Download | only in dev
it8368.c revision 1.18
      1  1.18     lukem /*	$NetBSD: it8368.c,v 1.18 2003/07/15 02:29:29 lukem Exp $ */
      2   1.1       uch 
      3  1.10       uch /*-
      4  1.10       uch  * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
      5   1.1       uch  * All rights reserved.
      6   1.1       uch  *
      7  1.10       uch  * This code is derived from software contributed to The NetBSD Foundation
      8  1.10       uch  * by UCHIYAMA Yasushi.
      9  1.10       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.10       uch  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.10       uch  *    notice, this list of conditions and the following disclaimer in the
     17  1.10       uch  *    documentation and/or other materials provided with the distribution.
     18  1.10       uch  * 3. All advertising materials mentioning features or use of this software
     19  1.10       uch  *    must display the following acknowledgement:
     20  1.10       uch  *        This product includes software developed by the NetBSD
     21  1.10       uch  *        Foundation, Inc. and its contributors.
     22  1.10       uch  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.10       uch  *    contributors may be used to endorse or promote products derived
     24  1.10       uch  *    from this software without specific prior written permission.
     25   1.1       uch  *
     26  1.10       uch  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.10       uch  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.10       uch  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.10       uch  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.10       uch  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.10       uch  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.10       uch  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.10       uch  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.10       uch  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.10       uch  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.10       uch  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1       uch  */
     38  1.18     lukem 
     39  1.18     lukem #include <sys/cdefs.h>
     40  1.18     lukem __KERNEL_RCSID(0, "$NetBSD: it8368.c,v 1.18 2003/07/15 02:29:29 lukem Exp $");
     41  1.10       uch 
     42   1.8       uch #undef WINCE_DEFAULT_SETTING /* for debug */
     43   1.8       uch #undef IT8368DEBUG
     44   1.1       uch 
     45   1.1       uch #include <sys/param.h>
     46   1.1       uch #include <sys/systm.h>
     47   1.1       uch #include <sys/device.h>
     48   1.1       uch 
     49   1.1       uch #include <machine/bus.h>
     50   1.1       uch 
     51   1.1       uch #include <dev/pcmcia/pcmciareg.h>
     52   1.1       uch #include <dev/pcmcia/pcmciavar.h>
     53   1.1       uch #include <dev/pcmcia/pcmciachip.h>
     54   1.1       uch 
     55   1.1       uch #include <hpcmips/tx/tx39var.h>
     56   1.1       uch #include <hpcmips/tx/txcsbusvar.h>
     57   1.6       uch #include <hpcmips/tx/tx39biureg.h> /* legacy mode requires BIU access */
     58   1.6       uch #include <hpcmips/dev/it8368var.h>
     59   1.1       uch #include <hpcmips/dev/it8368reg.h>
     60   1.1       uch 
     61   1.1       uch #ifdef IT8368DEBUG
     62   1.8       uch int	it8368debug = 1;
     63   1.8       uch #define	DPRINTF(arg) if (it8368debug) printf arg;
     64   1.8       uch #define	DPRINTFN(n, arg) if (it8368debug > (n)) printf arg;
     65   1.1       uch #else
     66   1.1       uch #define	DPRINTF(arg)
     67   1.8       uch #define DPRINTFN(n, arg)
     68   1.1       uch #endif
     69   1.1       uch 
     70  1.10       uch int it8368e_match(struct device *, struct cfdata *, void *);
     71  1.10       uch void it8368e_attach(struct device *, struct device *, void *);
     72  1.10       uch int it8368_print(void *, const char *);
     73  1.10       uch int it8368_submatch(struct device *, struct cfdata *, void *);
     74   1.1       uch 
     75   1.4       uch #define IT8368_LASTSTATE_PRESENT	0x0002
     76   1.4       uch #define IT8368_LASTSTATE_HALF		0x0001
     77   1.7       uch #define IT8368_LASTSTATE_EMPTY		0x0000
     78   1.4       uch 
     79   1.1       uch struct it8368e_softc {
     80   1.1       uch 	struct device	sc_dev;
     81   1.1       uch 	struct device	*sc_pcmcia;
     82   1.1       uch 	tx_chipset_tag_t sc_tc;
     83   1.1       uch 
     84   1.1       uch 	/* Register space */
     85   1.4       uch 	bus_space_tag_t		sc_csregt;
     86   1.4       uch 	bus_space_handle_t	sc_csregh;
     87   1.1       uch 	/* I/O, attribute space */
     88   1.4       uch 	bus_space_tag_t		sc_csiot;
     89   1.4       uch 	bus_addr_t		sc_csiobase;
     90   1.4       uch 	bus_size_t		sc_csiosize;
     91   1.3       uch 	/*
     92   1.3       uch 	 *  XXX theses means attribute memory. not memory space.
     93   1.3       uch 	 *	memory space is 0x64000000.
     94   1.3       uch 	 */
     95   1.4       uch 	bus_space_tag_t		sc_csmemt;
     96   1.4       uch 	bus_addr_t		sc_csmembase;
     97   1.4       uch 	bus_size_t		sc_csmemsize;
     98   1.1       uch 
     99   1.1       uch 	/* Separate I/O and attribute space mode */
    100   1.1       uch 	int sc_fixattr;
    101   1.1       uch 
    102   1.1       uch 	/* Card interrupt handler */
    103  1.10       uch 	int	(*sc_card_fun)(void *);
    104   1.4       uch 	void	*sc_card_arg;
    105   1.4       uch 	void	*sc_card_ih;
    106   1.4       uch 	int	sc_card_irq;
    107   1.4       uch 
    108   1.4       uch 	/* Card status change */
    109   1.4       uch 	int	sc_irq;
    110   1.4       uch 	void	*sc_ih;
    111   1.4       uch 	int	sc_laststate;
    112   1.1       uch };
    113   1.1       uch 
    114  1.10       uch void it8368_init_socket(struct it8368e_softc*);
    115  1.10       uch void it8368_attach_socket(struct it8368e_softc *);
    116  1.10       uch int it8368_intr(void *);
    117  1.10       uch int it8368_chip_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
    118  1.10       uch     struct pcmcia_mem_handle *);
    119  1.10       uch void it8368_chip_mem_free(pcmcia_chipset_handle_t, struct pcmcia_mem_handle *);
    120  1.11     soren int it8368_chip_mem_map(pcmcia_chipset_handle_t, int, bus_size_t, bus_size_t,
    121  1.10       uch     struct pcmcia_mem_handle *, bus_addr_t *, int *);
    122  1.10       uch void it8368_chip_mem_unmap(pcmcia_chipset_handle_t, int);
    123  1.10       uch int it8368_chip_io_alloc(pcmcia_chipset_handle_t, bus_addr_t, bus_size_t,
    124  1.10       uch     bus_size_t, struct pcmcia_io_handle *);
    125  1.10       uch void it8368_chip_io_free(pcmcia_chipset_handle_t, struct pcmcia_io_handle *);
    126  1.10       uch int it8368_chip_io_map(pcmcia_chipset_handle_t, int, bus_addr_t, bus_size_t,
    127  1.10       uch     struct pcmcia_io_handle *, int *);
    128  1.10       uch void it8368_chip_io_unmap(pcmcia_chipset_handle_t, int);
    129  1.10       uch void it8368_chip_socket_enable(pcmcia_chipset_handle_t);
    130  1.10       uch void it8368_chip_socket_disable(pcmcia_chipset_handle_t);
    131  1.10       uch void *it8368_chip_intr_establish(pcmcia_chipset_handle_t,
    132  1.10       uch     struct pcmcia_function *, int, int (*) (void *), void *);
    133  1.10       uch void it8368_chip_intr_disestablish(pcmcia_chipset_handle_t, void *);
    134   1.1       uch 
    135   1.8       uch #ifdef IT8368DEBUG
    136  1.10       uch void it8368_dump(struct it8368e_softc *);
    137   1.8       uch #endif
    138   1.8       uch 
    139   1.1       uch static struct pcmcia_chip_functions it8368_functions = {
    140   1.1       uch 	it8368_chip_mem_alloc,
    141   1.1       uch 	it8368_chip_mem_free,
    142   1.1       uch 	it8368_chip_mem_map,
    143   1.1       uch 	it8368_chip_mem_unmap,
    144   1.1       uch 	it8368_chip_io_alloc,
    145   1.1       uch 	it8368_chip_io_free,
    146   1.1       uch 	it8368_chip_io_map,
    147   1.1       uch 	it8368_chip_io_unmap,
    148   1.1       uch 	it8368_chip_intr_establish,
    149   1.1       uch 	it8368_chip_intr_disestablish,
    150   1.1       uch 	it8368_chip_socket_enable,
    151   1.1       uch 	it8368_chip_socket_disable
    152   1.1       uch };
    153   1.1       uch 
    154  1.16   thorpej CFATTACH_DECL(it8368e, sizeof(struct it8368e_softc),
    155  1.16   thorpej     it8368e_match, it8368e_attach, NULL, NULL);
    156   1.1       uch 
    157   1.1       uch /*
    158   1.1       uch  *	IT8368 configuration register is big-endian.
    159   1.1       uch  */
    160  1.10       uch static __inline__ u_int16_t it8368_reg_read(bus_space_tag_t,
    161  1.10       uch     bus_space_handle_t, int);
    162  1.10       uch static __inline__ void it8368_reg_write(bus_space_tag_t, bus_space_handle_t,
    163  1.10       uch     int, u_int16_t);
    164   1.1       uch 
    165   1.8       uch #ifdef IT8368E_DESTRUCTIVE_CHECK
    166  1.10       uch int	it8368e_id_check(void *);
    167   1.8       uch 
    168   1.8       uch /*
    169   1.8       uch  *	IT8368E don't have identification method. this is destructive check.
    170   1.8       uch  */
    171   1.8       uch int
    172  1.10       uch it8368e_id_check(void *aux)
    173   1.8       uch {
    174   1.8       uch 	struct cs_attach_args *ca = aux;
    175   1.8       uch 	tx_chipset_tag_t tc;
    176   1.8       uch 	bus_space_tag_t csregt;
    177   1.8       uch 	bus_space_handle_t csregh;
    178   1.8       uch 	u_int16_t oreg, reg;
    179   1.8       uch 	int match = 0;
    180   1.8       uch 
    181   1.8       uch 	tc = ca->ca_tc;
    182   1.8       uch 	csregt = ca->ca_csreg.cstag;
    183   1.8       uch 
    184   1.8       uch 	bus_space_map(csregt, ca->ca_csreg.csbase, ca->ca_csreg.cssize,
    185  1.10       uch 	    0, &csregh);
    186   1.8       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    187   1.8       uch 	oreg = reg;
    188  1.12       uch 	dbg_bit_print(reg);
    189   1.8       uch 
    190   1.8       uch 	reg &= ~IT8368_CTRL_BYTESWAP;
    191   1.8       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, reg);
    192   1.8       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    193   1.8       uch 	if (reg & IT8368_CTRL_BYTESWAP)
    194   1.8       uch 		goto nomatch;
    195   1.8       uch 
    196   1.8       uch 	reg |= IT8368_CTRL_BYTESWAP;
    197   1.8       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, reg);
    198   1.8       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    199   1.8       uch 	if (!(reg & IT8368_CTRL_BYTESWAP))
    200   1.8       uch 		goto nomatch;
    201   1.8       uch 
    202   1.8       uch 	match = 1;
    203   1.8       uch  nomatch:
    204   1.8       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, oreg);
    205   1.8       uch 	bus_space_unmap(csregt, csregh, ca->ca_csreg.cssize);
    206   1.8       uch 
    207   1.8       uch 	return (match);
    208   1.8       uch }
    209   1.8       uch #endif /* IT8368E_DESTRUCTIVE_CHECK */
    210   1.4       uch 
    211   1.1       uch int
    212  1.10       uch it8368e_match(struct device *parent, struct cfdata *cf, void *aux)
    213   1.1       uch {
    214   1.8       uch #ifdef IT8368E_DESTRUCTIVE_CHECK
    215   1.8       uch 	return (it8368e_id_check(aux));
    216   1.8       uch #else
    217   1.8       uch 	return (1);
    218   1.8       uch #endif
    219   1.1       uch }
    220   1.1       uch 
    221   1.1       uch void
    222  1.10       uch it8368e_attach(struct device *parent, struct device *self, void *aux)
    223   1.1       uch {
    224   1.1       uch 	struct cs_attach_args *ca = aux;
    225   1.1       uch 	struct it8368e_softc *sc = (void*)self;
    226   1.1       uch 	tx_chipset_tag_t tc;
    227   1.1       uch 	bus_space_tag_t csregt;
    228   1.1       uch 	bus_space_handle_t csregh;
    229   1.1       uch 	u_int16_t reg;
    230   1.1       uch 
    231   1.1       uch 	sc->sc_tc = tc = ca->ca_tc;
    232   1.1       uch 	sc->sc_csregt = csregt = ca->ca_csreg.cstag;
    233   1.1       uch 
    234   1.1       uch 	bus_space_map(csregt, ca->ca_csreg.csbase, ca->ca_csreg.cssize,
    235  1.10       uch 	    0, &sc->sc_csregh);
    236   1.1       uch 	csregh = sc->sc_csregh;
    237   1.1       uch 	sc->sc_csiot = ca->ca_csio.cstag;
    238   1.1       uch 	sc->sc_csiobase = ca->ca_csio.csbase;
    239   1.1       uch 	sc->sc_csiosize = ca->ca_csio.cssize;
    240   1.1       uch 
    241   1.3       uch #ifdef IT8368DEBUG
    242   1.4       uch 	printf("\n\t[Windows CE setting]\n");
    243   1.1       uch 	it8368_dump(sc); /* print WindowsCE setting */
    244   1.3       uch #endif
    245   1.1       uch 	/* LHA[14:13] <= HA[14:13]	*/
    246   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    247   1.1       uch 	reg &= ~IT8368_CTRL_ADDRSEL;
    248   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, reg);
    249   1.1       uch 
    250   1.1       uch 	/* Set all MFIO direction as LHA[23:13] output pins */
    251   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_MFIODIR_REG);
    252   1.1       uch 	reg |= IT8368_MFIODIR_MASK;
    253   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_MFIODIR_REG, reg);
    254   1.1       uch 
    255   1.1       uch 	/* Set all MFIO functions as LHA */
    256   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_MFIOSEL_REG);
    257   1.1       uch 	reg &= ~IT8368_MFIOSEL_MASK;
    258   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_MFIOSEL_REG, reg);
    259   1.1       uch 
    260   1.1       uch 	/* Disable MFIO interrupt */
    261   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_MFIOPOSINTEN_REG);
    262   1.1       uch 	reg &= ~IT8368_MFIOPOSINTEN_MASK;
    263   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_MFIOPOSINTEN_REG, reg);
    264   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_MFIONEGINTEN_REG);
    265   1.1       uch 	reg &= ~IT8368_MFIONEGINTEN_MASK;
    266   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_MFIONEGINTEN_REG, reg);
    267   1.1       uch 
    268   1.1       uch 	/* Port direction */
    269   1.1       uch 	reg = IT8368_PIN_CRDVCCON1 | IT8368_PIN_CRDVCCON0 |
    270  1.10       uch 	    IT8368_PIN_CRDVPPON1 | IT8368_PIN_CRDVPPON0 |
    271  1.10       uch 	    IT8368_PIN_BCRDRST;
    272   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODIR_REG, reg);
    273   1.5       uch 	printf("\n");
    274   1.5       uch 
    275   1.1       uch 	/*
    276   1.1       uch 	 *	Separate I/O and attribute memory region
    277   1.1       uch 	 */
    278   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    279   1.8       uch 
    280   1.1       uch 	reg |= IT8368_CTRL_FIXATTRIO;
    281   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, reg);
    282   1.8       uch 
    283   1.6       uch 	if (IT8368_CTRL_FIXATTRIO &
    284   1.6       uch 	    it8368_reg_read(csregt, csregh, IT8368_CTRL_REG)) {
    285   1.1       uch 		sc->sc_fixattr = 1;
    286   1.5       uch 		printf("%s: fix attr mode\n", sc->sc_dev.dv_xname);
    287   1.1       uch 	} else {
    288   1.1       uch 		sc->sc_fixattr = 0;
    289   1.6       uch 		printf("%s: legacy attr mode\n", sc->sc_dev.dv_xname);
    290   1.1       uch 	}
    291   1.8       uch 
    292   1.6       uch 	sc->sc_csmemt = sc->sc_csiot;
    293   1.6       uch 	sc->sc_csiosize /= 2;
    294   1.6       uch 	sc->sc_csmemsize = sc->sc_csiosize;
    295   1.6       uch 	sc->sc_csmembase = sc->sc_csiosize;
    296   1.6       uch 
    297   1.7       uch #ifdef IT8368DEBUG
    298   1.1       uch 	it8368_dump(sc);
    299   1.7       uch #endif
    300   1.4       uch 	/* Enable card and interrupt driving. */
    301   1.4       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_CTRL_REG);
    302   1.4       uch 	reg |= (IT8368_CTRL_GLOBALEN | IT8368_CTRL_CARDEN);
    303   1.4       uch 	if (sc->sc_fixattr)
    304   1.4       uch 		reg |= IT8368_CTRL_FIXATTRIO;
    305   1.4       uch 	it8368_reg_write(csregt, csregh, IT8368_CTRL_REG, reg);
    306   1.4       uch 
    307   1.4       uch 	sc->sc_irq = ca->ca_irq1;
    308   1.1       uch 	sc->sc_card_irq = ca->ca_irq3;
    309   1.1       uch 
    310   1.1       uch 	it8368_attach_socket(sc);
    311   1.1       uch }
    312   1.1       uch 
    313   1.7       uch __inline__ u_int16_t
    314  1.10       uch it8368_reg_read(bus_space_tag_t t, bus_space_handle_t h, int ofs)
    315   1.1       uch {
    316   1.1       uch 	u_int16_t val;
    317   1.1       uch 
    318   1.1       uch 	val = bus_space_read_2(t, h, ofs);
    319  1.10       uch 	return (0xffff & (((val >> 8) & 0xff)|((val << 8) & 0xff00)));
    320   1.1       uch }
    321   1.1       uch 
    322   1.7       uch __inline__ void
    323  1.10       uch it8368_reg_write(bus_space_tag_t t, bus_space_handle_t h, int ofs, u_int16_t v)
    324   1.1       uch {
    325   1.1       uch 	u_int16_t val;
    326   1.1       uch 
    327   1.1       uch 	val = 0xffff & (((v >> 8) & 0xff)|((v << 8) & 0xff00));
    328   1.1       uch 	bus_space_write_2(t, h, ofs, val);
    329   1.1       uch }
    330   1.1       uch 
    331   1.1       uch int
    332  1.10       uch it8368_intr(void *arg)
    333   1.1       uch {
    334   1.1       uch 	struct it8368e_softc *sc = arg;
    335   1.4       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    336   1.4       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    337   1.4       uch 	u_int16_t reg;
    338   1.3       uch 
    339   1.4       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIONEGINTSTAT_REG);
    340   1.3       uch 
    341   1.4       uch 	if (reg & IT8368_PIN_BCRDRDY) {
    342   1.4       uch 		if (sc->sc_card_fun) {
    343   1.4       uch 			/* clear interrupt */
    344   1.4       uch 			it8368_reg_write(csregt, csregh,
    345  1.10       uch 			    IT8368_GPIONEGINTSTAT_REG,
    346  1.10       uch 			    IT8368_PIN_BCRDRDY);
    347   1.4       uch 
    348   1.4       uch 			/* Dispatch card interrupt handler */
    349   1.4       uch 			(*sc->sc_card_fun)(sc->sc_card_arg);
    350   1.4       uch 		}
    351   1.4       uch 	} else if (reg & IT8368_PIN_CRDDET2) {
    352   1.4       uch 		it8368_reg_write(csregt, csregh, IT8368_GPIONEGINTSTAT_REG,
    353  1.10       uch 		    IT8368_PIN_CRDDET2);
    354   1.4       uch 		printf("[CSC]\n");
    355   1.7       uch #ifdef IT8368DEBUG
    356   1.4       uch 		it8368_dump(sc);
    357   1.7       uch #endif
    358   1.4       uch 		it8368_chip_socket_disable(sc);
    359   1.4       uch 	} else {
    360   1.7       uch #ifdef IT8368DEBUG
    361   1.8       uch 		u_int16_t reg2;
    362   1.8       uch 		reg2 = reg & ~(IT8368_PIN_BCRDRDY|IT8368_PIN_CRDDET2);
    363   1.8       uch 		printf("unknown it8368 interrupt: ");
    364  1.12       uch 		dbg_bit_print(reg2);
    365   1.8       uch 		it8368_reg_write(csregt, csregh, IT8368_GPIONEGINTSTAT_REG,
    366  1.10       uch 		    reg);
    367   1.7       uch #endif
    368   1.1       uch 	}
    369   1.4       uch 
    370  1.10       uch 	return (0);
    371   1.1       uch }
    372   1.1       uch 
    373   1.1       uch int
    374  1.10       uch it8368_print(void *arg, const char *pnp)
    375   1.1       uch {
    376   1.3       uch 	if (pnp)
    377  1.17   thorpej 		aprint_normal("pcmcia at %s", pnp);
    378   1.1       uch 
    379  1.10       uch 	return (UNCONF);
    380   1.1       uch }
    381   1.1       uch 
    382   1.1       uch int
    383  1.10       uch it8368_submatch(struct device *parent, struct cfdata *cf, void *aux)
    384   1.1       uch {
    385  1.10       uch 
    386  1.14   thorpej 	return (config_match(parent, cf, aux));
    387   1.1       uch }
    388   1.1       uch 
    389   1.1       uch void
    390  1.10       uch it8368_attach_socket(struct it8368e_softc *sc)
    391   1.1       uch {
    392   1.1       uch 	struct pcmciabus_attach_args paa;
    393   1.1       uch 
    394   1.1       uch 	paa.paa_busname = "pcmcia";
    395   1.1       uch 	paa.pct = (pcmcia_chipset_tag_t)&it8368_functions;
    396   1.1       uch 	paa.pch = (pcmcia_chipset_handle_t)sc;
    397   1.9       uch 	paa.iobase = 0;
    398   1.9       uch 	paa.iosize = sc->sc_csiosize;
    399   1.1       uch 
    400   1.1       uch 	if ((sc->sc_pcmcia = config_found_sm((void*)sc, &paa, it8368_print,
    401  1.10       uch 	    it8368_submatch))) {
    402   1.4       uch 
    403   1.4       uch 		it8368_init_socket(sc);
    404   1.4       uch 	}
    405   1.4       uch }
    406   1.4       uch 
    407   1.4       uch void
    408  1.10       uch it8368_init_socket(struct it8368e_softc *sc)
    409   1.4       uch {
    410   1.4       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    411   1.4       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    412   1.4       uch 	u_int16_t reg;
    413   1.4       uch 
    414   1.4       uch 	/*
    415   1.4       uch 	 *  set up the card to interrupt on card detect
    416   1.4       uch 	 */
    417   1.4       uch 	reg = IT8368_PIN_CRDDET2; /* CSC */
    418   1.4       uch 	/* enable negative edge */
    419   1.4       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIONEGINTEN_REG, reg);
    420   1.4       uch 	/* disable positive edge */
    421   1.4       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIOPOSINTEN_REG, 0);
    422   1.4       uch 
    423   1.4       uch 	sc->sc_ih = tx_intr_establish(sc->sc_tc, sc->sc_irq,
    424  1.10       uch 	    IST_EDGE, IPL_BIO, it8368_intr, sc);
    425   1.4       uch 	if (sc->sc_ih == NULL) {
    426   1.4       uch 		printf("%s: can't establish interrupt\n",
    427  1.10       uch 		    sc->sc_dev.dv_xname);
    428   1.4       uch 		return;
    429   1.4       uch 	}
    430   1.4       uch 
    431   1.4       uch 	/*
    432   1.4       uch 	 *  if there's a card there, then attach it.
    433   1.4       uch 	 */
    434   1.4       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAIN_REG);
    435   1.4       uch 
    436   1.4       uch 	if (reg & (IT8368_PIN_CRDDET2|IT8368_PIN_CRDDET1)) {
    437   1.4       uch 		sc->sc_laststate = IT8368_LASTSTATE_EMPTY;
    438   1.4       uch 	} else {
    439   1.4       uch 		pcmcia_card_attach(sc->sc_pcmcia);
    440   1.4       uch 		sc->sc_laststate = IT8368_LASTSTATE_PRESENT;
    441   1.1       uch 	}
    442   1.1       uch }
    443   1.1       uch 
    444   1.1       uch void *
    445  1.10       uch it8368_chip_intr_establish(pcmcia_chipset_handle_t pch,
    446  1.10       uch     struct pcmcia_function *pf, int ipl, int (*ih_fun)(void *), void *ih_arg)
    447   1.1       uch {
    448   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    449   1.4       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    450   1.4       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    451   1.4       uch 	u_int16_t reg;
    452   1.1       uch 
    453   1.4       uch 	if (sc->sc_card_fun)
    454   1.3       uch 		panic("it8368_chip_intr_establish: "
    455  1.10       uch 		    "duplicate card interrupt handler.");
    456   1.4       uch 
    457   1.1       uch 	sc->sc_card_fun = ih_fun;
    458   1.1       uch 	sc->sc_card_arg = ih_arg;
    459   1.1       uch 
    460   1.4       uch 	sc->sc_card_ih = tx_intr_establish(sc->sc_tc, sc->sc_card_irq,
    461  1.10       uch 	    IST_EDGE, IPL_BIO, it8368_intr,
    462  1.10       uch 	    sc);
    463   1.4       uch 
    464   1.4       uch 	/* enable card interrupt */
    465   1.4       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIONEGINTEN_REG);
    466   1.4       uch 	reg |= IT8368_PIN_BCRDRDY;
    467   1.4       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIONEGINTEN_REG, reg);
    468   1.4       uch 
    469  1.10       uch 	return (sc->sc_card_ih);
    470   1.1       uch }
    471   1.1       uch 
    472   1.1       uch void
    473  1.10       uch it8368_chip_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
    474   1.1       uch {
    475   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    476   1.4       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    477   1.4       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    478   1.4       uch 	u_int16_t reg;
    479   1.1       uch 
    480   1.4       uch 	if (!sc->sc_card_fun)
    481   1.3       uch 		panic("it8368_chip_intr_disestablish:"
    482  1.10       uch 		    "no handler established.");
    483   1.4       uch 	assert(ih == sc->sc_card_ih);
    484   1.4       uch 
    485   1.1       uch 	sc->sc_card_fun = 0;
    486   1.1       uch 	sc->sc_card_arg = 0;
    487   1.1       uch 
    488   1.4       uch 	/* disable card interrupt */
    489   1.4       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIONEGINTEN_REG);
    490   1.4       uch 	reg &= ~IT8368_PIN_BCRDRDY;
    491   1.4       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIONEGINTEN_REG, reg);
    492   1.4       uch 
    493   1.1       uch 	tx_intr_disestablish(sc->sc_tc, ih);
    494   1.1       uch }
    495   1.1       uch 
    496   1.1       uch int
    497  1.10       uch it8368_chip_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
    498  1.10       uch     struct pcmcia_mem_handle *pcmhp)
    499   1.1       uch {
    500   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    501   1.1       uch 
    502   1.6       uch 	if (bus_space_alloc(sc->sc_csmemt, sc->sc_csmembase,
    503  1.10       uch 	    sc->sc_csmembase + sc->sc_csmemsize, size,
    504  1.10       uch 	    size, 0, 0, 0, &pcmhp->memh)) {
    505   1.6       uch 		DPRINTF(("it8368_chip_mem_alloc: failed\n"));
    506  1.10       uch 		return (1);
    507   1.1       uch 	}
    508   1.3       uch 
    509   1.6       uch 	if (!sc->sc_fixattr) /* XXX IT8368 brain damaged spec */
    510   1.6       uch 		pcmhp->memh -= sc->sc_csmembase;
    511   1.6       uch 
    512   1.6       uch 	pcmhp->memt = sc->sc_csmemt;
    513   1.1       uch 	pcmhp->addr = pcmhp->memh;
    514   1.1       uch 	pcmhp->size = size;
    515   1.1       uch 	pcmhp->realsize = size;
    516   1.3       uch 
    517   1.8       uch 	DPRINTF(("it8368_chip_mem_alloc: %#x+%#x\n",
    518  1.10       uch 	    (unsigned)pcmhp->memh, (unsigned)size));
    519   1.1       uch 
    520  1.10       uch 	return (0);
    521   1.1       uch }
    522   1.1       uch 
    523   1.1       uch void
    524  1.10       uch it8368_chip_mem_free(pcmcia_chipset_handle_t pch,
    525  1.10       uch     struct pcmcia_mem_handle *pcmhp)
    526   1.1       uch {
    527   1.6       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    528   1.6       uch 
    529   1.8       uch 	DPRINTF(("it8368_chip_mem_free: %#x+%#x\n",
    530  1.10       uch 	    (unsigned)pcmhp->memh, (unsigned)pcmhp->size));
    531   1.8       uch 
    532   1.6       uch 	if (!sc->sc_fixattr) /* XXX IT8368 brain damaged spec */
    533   1.6       uch 		pcmhp->memh += sc->sc_csmembase;
    534   1.6       uch 
    535   1.1       uch 	bus_space_unmap(pcmhp->memt, pcmhp->memh, pcmhp->size);
    536   1.1       uch }
    537   1.1       uch 
    538   1.1       uch int
    539  1.10       uch it8368_chip_mem_map(pcmcia_chipset_handle_t pch, int kind,
    540  1.10       uch     bus_addr_t card_addr, bus_size_t size, struct pcmcia_mem_handle *pcmhp,
    541  1.11     soren     bus_size_t *offsetp, int *windowp)
    542   1.1       uch {
    543   1.6       uch 	/* attribute mode */
    544   1.6       uch 	it8368_mode(pch, IT8368_ATTR_MODE, IT8368_WIDTH_16);
    545   1.1       uch 
    546   1.3       uch 	*offsetp = card_addr;
    547   1.8       uch 	DPRINTF(("it8368_chip_mem_map %#x+%#x\n",
    548  1.10       uch 	    (unsigned)pcmhp->memh, (unsigned)size));
    549   1.3       uch 
    550  1.10       uch 	return (0);
    551   1.1       uch }
    552   1.1       uch 
    553   1.1       uch void
    554  1.10       uch it8368_chip_mem_unmap(pcmcia_chipset_handle_t pch, int window)
    555   1.1       uch {
    556   1.6       uch 	/* return to I/O mode */
    557   1.6       uch 	it8368_mode(pch, IT8368_IO_MODE, IT8368_WIDTH_16);
    558   1.1       uch }
    559   1.1       uch 
    560   1.1       uch void
    561  1.10       uch it8368_mode(pcmcia_chipset_handle_t pch, int io, int width)
    562   1.1       uch {
    563   1.6       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    564   1.1       uch 	txreg_t reg32;
    565   1.1       uch 
    566   1.6       uch 	DPRINTF(("it8368_mode: change access space to "));
    567   1.8       uch 	DPRINTF((io ? "I/O (%dbit)\n" : "attribute (%dbit)...\n",
    568  1.10       uch 	    width == IT8368_WIDTH_8 ? 8 : 16));
    569   1.6       uch 
    570   1.1       uch 	reg32 = tx_conf_read(sc->sc_tc, TX39_MEMCONFIG3_REG);
    571   1.8       uch 
    572   1.6       uch 	if (io) {
    573   1.8       uch 		if (width == IT8368_WIDTH_8)
    574   1.6       uch 			reg32 |= TX39_MEMCONFIG3_PORT8SEL;
    575   1.6       uch 		else
    576   1.6       uch 			reg32 &= ~TX39_MEMCONFIG3_PORT8SEL;
    577   1.1       uch 	}
    578   1.6       uch 
    579   1.1       uch 	if (!sc->sc_fixattr) {
    580   1.6       uch 		if (io)
    581   1.1       uch 			reg32 |= TX39_MEMCONFIG3_CARD1IOEN;
    582   1.6       uch 		else
    583   1.1       uch 			reg32 &= ~TX39_MEMCONFIG3_CARD1IOEN;
    584   1.1       uch 	}
    585   1.1       uch 	tx_conf_write(sc->sc_tc, TX39_MEMCONFIG3_REG, reg32);
    586   1.1       uch 
    587   1.8       uch #ifdef IT8368DEBUG
    588   1.8       uch 	if (sc->sc_fixattr)
    589   1.8       uch 		return; /* No need to report BIU status */
    590   1.8       uch 
    591   1.8       uch 	/* check BIU status */
    592   1.1       uch 	reg32 = tx_conf_read(sc->sc_tc, TX39_MEMCONFIG3_REG);
    593   1.8       uch 	if (reg32 & TX39_MEMCONFIG3_CARD1IOEN) {
    594   1.8       uch 		DPRINTF(("it8368_mode: I/O space (%dbit) enabled\n",
    595  1.10       uch 		    reg32 & TX39_MEMCONFIG3_PORT8SEL ? 8 : 16));
    596   1.8       uch 	} else {
    597   1.6       uch 		DPRINTF(("it8368_mode: atttribute space enabled\n"));
    598   1.8       uch 	}
    599   1.8       uch #endif /* IT8368DEBUG */
    600   1.1       uch }
    601   1.1       uch 
    602   1.1       uch int
    603  1.10       uch it8368_chip_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start,
    604  1.10       uch     bus_size_t size, bus_size_t align, struct pcmcia_io_handle *pcihp)
    605   1.1       uch {
    606   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    607   1.1       uch 
    608   1.1       uch 	if (start) {
    609   1.3       uch 		if (bus_space_map(sc->sc_csiot, start, size, 0,
    610  1.10       uch 		    &pcihp->ioh)) {
    611  1.10       uch 			return (1);
    612   1.1       uch 		}
    613   1.1       uch 		DPRINTF(("it8368_chip_io_alloc map port %#x+%#x\n",
    614  1.10       uch 		    (unsigned)start, (unsigned)size));
    615   1.1       uch 	} else {
    616   1.1       uch 		if (bus_space_alloc(sc->sc_csiot, sc->sc_csiobase,
    617  1.10       uch 		    sc->sc_csiobase + sc->sc_csiosize,
    618  1.10       uch 		    size, align, 0, 0, &pcihp->addr,
    619  1.10       uch 		    &pcihp->ioh)) {
    620   1.3       uch 
    621  1.10       uch 			return (1);
    622   1.1       uch 		}
    623   1.1       uch 		pcihp->flags = PCMCIA_IO_ALLOCATED;
    624   1.1       uch 		DPRINTF(("it8368_chip_io_alloc alloc %#x from %#x\n",
    625  1.10       uch 		    (unsigned)size, (unsigned)pcihp->addr));
    626   1.2       uch 	}
    627   1.1       uch 
    628   1.1       uch 	pcihp->iot = sc->sc_csiot;
    629   1.1       uch 	pcihp->size = size;
    630   1.1       uch 
    631  1.10       uch 	return (0);
    632   1.1       uch }
    633   1.1       uch 
    634   1.1       uch int
    635  1.10       uch it8368_chip_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset,
    636  1.10       uch     bus_size_t size, struct pcmcia_io_handle *pcihp, int *windowp)
    637   1.1       uch {
    638   1.6       uch 	/* I/O mode */
    639   1.6       uch 	it8368_mode(pch, IT8368_IO_MODE, IT8368_WIDTH_16);
    640   1.1       uch 
    641   1.8       uch 	DPRINTF(("it8368_chip_io_map %#x:%#x+%#x\n",
    642  1.10       uch 	    (unsigned)pcihp->ioh, (unsigned)offset, (unsigned)size));
    643   1.1       uch 
    644  1.10       uch 	return (0);
    645   1.1       uch }
    646   1.1       uch 
    647   1.1       uch void
    648  1.10       uch it8368_chip_io_free(pcmcia_chipset_handle_t pch,
    649  1.10       uch     struct pcmcia_io_handle *pcihp)
    650   1.1       uch {
    651   1.6       uch 	if (pcihp->flags & PCMCIA_IO_ALLOCATED)
    652   1.1       uch 		bus_space_free(pcihp->iot, pcihp->ioh, pcihp->size);
    653   1.6       uch 	else
    654   1.1       uch 		bus_space_unmap(pcihp->iot, pcihp->ioh, pcihp->size);
    655   1.6       uch 
    656   1.8       uch 	DPRINTF(("it8368_chip_io_free %#x+%#x\n",
    657  1.10       uch 	    (unsigned)pcihp->ioh, (unsigned)pcihp->size));
    658   1.1       uch }
    659   1.1       uch 
    660   1.1       uch void
    661  1.10       uch it8368_chip_io_unmap(pcmcia_chipset_handle_t pch, int window)
    662   1.1       uch {
    663  1.10       uch 
    664   1.1       uch }
    665   1.1       uch 
    666   1.1       uch void
    667  1.10       uch it8368_chip_socket_enable(pcmcia_chipset_handle_t pch)
    668   1.1       uch {
    669   1.8       uch #ifndef WINCE_DEFAULT_SETTING
    670   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*)pch;
    671   1.1       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    672   1.1       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    673   1.1       uch 	volatile u_int16_t reg;
    674   1.3       uch 
    675   1.1       uch 	/* Power off */
    676   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAOUT_REG);
    677   1.1       uch 	reg &= ~(IT8368_PIN_CRDVCCMASK | IT8368_PIN_CRDVPPMASK);
    678   1.1       uch 	reg |= (IT8368_PIN_CRDVCC_0V | IT8368_PIN_CRDVPP_0V);
    679   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODATAOUT_REG, reg);
    680   1.1       uch 	delay(20000);
    681   1.1       uch 
    682   1.1       uch 	/*
    683   1.1       uch 	 * wait 300ms until power fails (Tpf).  Then, wait 100ms since
    684   1.1       uch 	 * we are changing Vcc (Toff).
    685   1.1       uch 	 */
    686   1.1       uch 	delay((300 + 100) * 1000);
    687   1.1       uch 
    688   1.1       uch 	/* Supply Vcc */
    689   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAOUT_REG);
    690   1.1       uch 	reg &= ~(IT8368_PIN_CRDVCCMASK | IT8368_PIN_CRDVPPMASK);
    691   1.1       uch 	reg |= IT8368_PIN_CRDVCC_5V; /* XXX */
    692   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODATAOUT_REG, reg);
    693   1.1       uch 
    694   1.1       uch 	/*
    695   1.1       uch 	 * wait 100ms until power raise (Tpr) and 20ms to become
    696   1.1       uch 	 * stable (Tsu(Vcc)).
    697   1.1       uch 	 *
    698   1.1       uch 	 * some machines require some more time to be settled
    699   1.1       uch 	 * (300ms is added here).
    700   1.1       uch 	 */
    701   1.1       uch 	delay((100 + 20 + 300) * 1000);
    702   1.1       uch 
    703   1.1       uch 	/* Assert reset signal */
    704   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAOUT_REG);
    705   1.1       uch 	reg |= IT8368_PIN_BCRDRST;
    706   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODATAOUT_REG, reg);
    707   1.4       uch 
    708   1.1       uch 	/*
    709   1.1       uch 	 * hold RESET at least 10us.
    710   1.1       uch 	 */
    711   1.1       uch 	delay(10);
    712   1.4       uch 
    713   1.8       uch 	/* deassert reset signal */
    714   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAOUT_REG);
    715   1.1       uch 	reg &= ~IT8368_PIN_BCRDRST;
    716   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODATAOUT_REG, reg);
    717   1.1       uch 	delay(20000);
    718   1.1       uch 
    719   1.6       uch 	DPRINTF(("it8368_chip_socket_enable: socket enabled\n"));
    720   1.8       uch #endif /* !WINCE_DEFAULT_SETTING */
    721   1.1       uch }
    722   1.1       uch 
    723   1.1       uch void
    724  1.10       uch it8368_chip_socket_disable(pcmcia_chipset_handle_t pch)
    725   1.1       uch {
    726   1.8       uch #ifndef WINCE_DEFAULT_SETTING
    727   1.1       uch 	struct it8368e_softc *sc = (struct it8368e_softc*) pch;
    728   1.1       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    729   1.1       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    730   1.1       uch 	u_int16_t reg;
    731   1.1       uch 
    732   1.1       uch 	/* Power down */
    733   1.1       uch 	reg = it8368_reg_read(csregt, csregh, IT8368_GPIODATAOUT_REG);
    734   1.1       uch 	reg &= ~(IT8368_PIN_CRDVCCMASK | IT8368_PIN_CRDVPPMASK);
    735   1.1       uch 	reg |= (IT8368_PIN_CRDVCC_0V | IT8368_PIN_CRDVPP_0V);
    736   1.1       uch 	it8368_reg_write(csregt, csregh, IT8368_GPIODATAOUT_REG, reg);
    737   1.1       uch 	delay(20000);
    738   1.1       uch 
    739   1.1       uch 	/*
    740   1.1       uch 	 * wait 300ms until power fails (Tpf).
    741   1.1       uch 	 */
    742   1.1       uch 	delay(300 * 1000);
    743   1.4       uch 
    744   1.6       uch 	DPRINTF(("it8368_chip_socket_disable: socket disabled\n"));
    745   1.8       uch #endif /* !WINCE_DEFAULT_SETTING */
    746   1.1       uch }
    747   1.1       uch 
    748   1.7       uch #ifdef IT8368DEBUG
    749  1.12       uch #define PRINTGPIO(m) __dbg_bit_print(it8368_reg_read(csregt, csregh,		\
    750  1.13  takemura 	IT8368_GPIO##m##_REG), 0, IT8368_GPIO_MAX, #m, DBG_BIT_PRINT_COUNT)
    751  1.12       uch #define PRINTMFIO(m) __dbg_bit_print(it8368_reg_read(csregt, csregh,		\
    752  1.13  takemura 	IT8368_MFIO##m##_REG), 0, IT8368_MFIO_MAX, #m, DBG_BIT_PRINT_COUNT)
    753   1.1       uch void
    754  1.10       uch it8368_dump(struct it8368e_softc *sc)
    755   1.1       uch {
    756   1.1       uch 	bus_space_tag_t csregt = sc->sc_csregt;
    757   1.1       uch 	bus_space_handle_t csregh = sc->sc_csregh;
    758   1.1       uch 
    759   1.1       uch 	printf("[GPIO]\n");
    760   1.1       uch 	PRINTGPIO(DIR);
    761   1.1       uch 	PRINTGPIO(DATAIN);
    762   1.1       uch 	PRINTGPIO(DATAOUT);
    763   1.1       uch 	PRINTGPIO(POSINTEN);
    764   1.1       uch 	PRINTGPIO(NEGINTEN);
    765   1.1       uch 	PRINTGPIO(POSINTSTAT);
    766   1.1       uch 	PRINTGPIO(NEGINTSTAT);
    767   1.1       uch 	printf("[MFIO]\n");
    768   1.1       uch 	PRINTMFIO(SEL);
    769   1.1       uch 	PRINTMFIO(DIR);
    770   1.1       uch 	PRINTMFIO(DATAIN);
    771   1.1       uch 	PRINTMFIO(DATAOUT);
    772   1.1       uch 	PRINTMFIO(POSINTEN);
    773   1.1       uch 	PRINTMFIO(NEGINTEN);
    774   1.1       uch 	PRINTMFIO(POSINTSTAT);
    775   1.1       uch 	PRINTMFIO(NEGINTSTAT);
    776  1.12       uch 	__dbg_bit_print(it8368_reg_read(csregt, csregh, IT8368_CTRL_REG), 0, 15,
    777  1.13  takemura 	    "CTRL", DBG_BIT_PRINT_COUNT);
    778  1.12       uch 	__dbg_bit_print(it8368_reg_read(csregt, csregh, IT8368_GPIODATAIN_REG),
    779  1.13  takemura 	    8, 11, "]CRDDET/SENSE[", DBG_BIT_PRINT_COUNT);
    780   1.1       uch }
    781   1.7       uch #endif /* IT8368DEBUG */
    782