tx39io.c revision 1.5       1  1.5  uch /*	$NetBSD: tx39io.c,v 1.5 2000/01/16 21:47:00 uch Exp $ */
      2  1.1  uch 
      3  1.1  uch /*
      4  1.5  uch  * Copyright (c) 1999, 2000, by UCHIYAMA Yasushi
      5  1.1  uch  * All rights reserved.
      6  1.1  uch  *
      7  1.1  uch  * Redistribution and use in source and binary forms, with or without
      8  1.1  uch  * modification, are permitted provided that the following conditions
      9  1.1  uch  * are met:
     10  1.1  uch  * 1. Redistributions of source code must retain the above copyright
     11  1.1  uch  *    notice, this list of conditions and the following disclaimer.
     12  1.1  uch  * 2. The name of the developer may NOT be used to endorse or promote products
     13  1.1  uch  *    derived from this software without specific prior written permission.
     14  1.1  uch  *
     15  1.1  uch  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     16  1.1  uch  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     17  1.1  uch  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18  1.1  uch  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19  1.1  uch  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20  1.1  uch  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21  1.1  uch  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1  uch  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23  1.1  uch  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24  1.1  uch  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25  1.1  uch  * SUCH DAMAGE.
     26  1.1  uch  *
     27  1.1  uch  */
     28  1.1  uch #include "opt_tx39_debug.h"
     29  1.1  uch #include "opt_tx39iodebug.h"
     30  1.1  uch 
     31  1.1  uch #include <sys/param.h>
     32  1.1  uch #include <sys/systm.h>
     33  1.1  uch #include <sys/device.h>
     34  1.1  uch 
     35  1.1  uch #include <machine/bus.h>
     36  1.1  uch 
     37  1.1  uch #include <hpcmips/tx/tx39var.h>
     38  1.5  uch #include <hpcmips/tx/tx39iovar.h>
     39  1.1  uch #include <hpcmips/tx/tx39ioreg.h>
     40  1.1  uch #include <hpcmips/tx/tx39icureg.h>
     41  1.1  uch 
     42  1.5  uch #include <hpcmips/tx/txiomanvar.h>
     43  1.5  uch 
     44  1.1  uch #define TX39IO_ATTACH_DUMMYHANDLER 0
     45  1.1  uch #undef TX39IO_MFIOOUTPORT_ON
     46  1.3  uch #undef TX39IO_MFIOOUTPORT_OFF
     47  1.1  uch 
     48  1.5  uch int	tx39io_match	__P((struct device*, struct cfdata*, void*));
     49  1.5  uch void	tx39io_attach	__P((struct device*, struct device*, void*));
     50  1.5  uch int	tx39io_print	__P((void*, const char*));
     51  1.1  uch 
     52  1.1  uch struct tx39io_softc {
     53  1.1  uch 	struct	device sc_dev;
     54  1.1  uch 	tx_chipset_tag_t sc_tc;
     55  1.1  uch };
     56  1.1  uch 
     57  1.1  uch struct cfattach tx39io_ca = {
     58  1.1  uch 	sizeof(struct tx39io_softc), tx39io_match, tx39io_attach
     59  1.1  uch };
     60  1.1  uch 
     61  1.5  uch #ifdef TX39IODEBUG
     62  1.1  uch int	tx39io_intr __P((void*));
     63  1.1  uch int	tx39mfio_intr __P((void*));
     64  1.5  uch void	tx39io_dump __P((struct tx39io_softc*));
     65  1.1  uch void	tx39io_dump_and_attach_handler __P((struct tx39io_softc*, int));
     66  1.5  uch void	__dump_and_attach_handler __P((tx_chipset_tag_t, u_int32_t,
     67  1.5  uch 				       u_int32_t, u_int32_t, u_int32_t,
     68  1.5  uch 				       int, int, int (*) __P((void*)),
     69  1.5  uch 				       void*, int));
     70  1.5  uch #endif /* TX39IODEBUG */
     71  1.1  uch 
     72  1.1  uch #define ISSET(x, s)	((x) & (1 << (s)))
     73  1.1  uch #define STD_IN		1
     74  1.1  uch #define STD_OUT		2
     75  1.1  uch #define STD_INOUT	3
     76  1.1  uch 
     77  1.3  uch const struct {
     78  1.1  uch 	char *std_pin_name;
     79  1.1  uch 	int  std_type;
     80  1.1  uch } mfio_map[TX39_IO_MFIO_MAX] = {
     81  1.1  uch   [31] = {"CHIFS",	STD_INOUT},
     82  1.1  uch   [30] = {"CHICLK",	STD_INOUT},
     83  1.1  uch   [29] = {"CHIDOUT",	STD_OUT},
     84  1.1  uch   [28] = {"CHIDIN",	STD_IN},
     85  1.1  uch   [27] = {"DREQ",	STD_IN},
     86  1.1  uch   [26] = {"DGRINT",	STD_OUT},
     87  1.1  uch   [25] = {"BC32K",	STD_OUT},
     88  1.1  uch   [24] = {"TXD",	STD_OUT},
     89  1.1  uch   [23] = {"RXD",	STD_IN},
     90  1.1  uch   [22] = {"CS1",	STD_OUT},
     91  1.1  uch   [21] = {"CS2",	STD_OUT},
     92  1.1  uch   [20] = {"CS3",	STD_OUT},
     93  1.1  uch   [19] = {"MCS0",	STD_OUT},
     94  1.1  uch   [18] = {"MCS1",	STD_OUT},
     95  1.1  uch #ifdef TX391X
     96  1.1  uch   [17] = {"MCS2",	STD_OUT},
     97  1.1  uch   [16] = {"MCS3",	STD_OUT},
     98  1.1  uch #endif /* TX391X */
     99  1.1  uch #ifdef TX392X
    100  1.1  uch   [17] = {"RXPWR",	STD_OUT},
    101  1.1  uch   [16] = {"IROUT",	STD_OUT},
    102  1.1  uch #endif /* TX392X */
    103  1.1  uch   [15] = {"SPICLK",	STD_OUT},
    104  1.1  uch   [14] = {"SPIOUT",	STD_OUT},
    105  1.1  uch   [13] = {"SPIN",	STD_IN},
    106  1.1  uch   [12] = {"SIBMCLK",	STD_INOUT},
    107  1.1  uch   [11] = {"CARDREG",	STD_OUT},
    108  1.1  uch   [10] = {"CARDIOWR",	STD_OUT},
    109  1.1  uch    [9] = {"CARDIORD",	STD_OUT},
    110  1.1  uch    [8] = {"CARD1CSL",	STD_OUT},
    111  1.1  uch    [7] = {"CARD1CSH",	STD_OUT},
    112  1.1  uch    [6] = {"CARD2CSL",	STD_OUT},
    113  1.1  uch    [5] = {"CARD2CSH",	STD_OUT},
    114  1.1  uch    [4] = {"CARD1WAIT",	STD_IN},
    115  1.1  uch    [3] = {"CARD2WAIT",	STD_IN},
    116  1.1  uch    [2] = {"CARDDIR",	STD_OUT},
    117  1.1  uch #ifdef TX391X
    118  1.1  uch    [1] = {"MFIO[1]",	0},
    119  1.1  uch    [0] = {"MFIO[0]",	0}
    120  1.1  uch #endif /* TX391X */
    121  1.1  uch #ifdef TX392X
    122  1.1  uch    [1] = {"MCS1WAIT",	0},
    123  1.1  uch    [0] = {"MCS0WAIT",	0}
    124  1.1  uch #endif /* TX392X */
    125  1.1  uch };
    126  1.1  uch 
    127  1.1  uch int
    128  1.1  uch tx39io_match(parent, cf, aux)
    129  1.1  uch 	struct device *parent;
    130  1.1  uch 	struct cfdata *cf;
    131  1.1  uch 	void *aux;
    132  1.1  uch {
    133  1.5  uch 	return 2; /* 1st attach group of txsim */
    134  1.5  uch }
    135  1.5  uch 
    136  1.5  uch void
    137  1.5  uch tx39io_attach(parent, self, aux)
    138  1.5  uch 	struct device *parent;
    139  1.5  uch 	struct device *self;
    140  1.5  uch 	void *aux;
    141  1.5  uch {
    142  1.5  uch 	struct txsim_attach_args *ta = aux;
    143  1.5  uch 	struct tx39io_softc *sc = (void*)self;
    144  1.5  uch 	struct txioman_attach_args tia;
    145  1.5  uch 
    146  1.5  uch 	sc->sc_tc = ta->ta_tc;
    147  1.1  uch 
    148  1.5  uch 	printf("\n");
    149  1.5  uch #ifdef TX39IODEBUG
    150  1.5  uch 	tx39io_dump(sc);
    151  1.5  uch #endif /* TX39IODEBUG */
    152  1.5  uch 
    153  1.5  uch 	/*
    154  1.5  uch 	 * attach platform dependent io manager
    155  1.5  uch 	 */
    156  1.5  uch 	tia.tia_tc = sc->sc_tc;
    157  1.5  uch 	config_found(self, &tia, tx39io_print);
    158  1.1  uch }
    159  1.1  uch 
    160  1.1  uch int
    161  1.5  uch tx39io_print(aux, pnp)
    162  1.5  uch 	void *aux;
    163  1.5  uch 	const char *pnp;
    164  1.5  uch {
    165  1.5  uch 	return pnp ? QUIET : UNCONF;
    166  1.5  uch }
    167  1.5  uch 
    168  1.5  uch void
    169  1.5  uch tx39io_portout(tc, port, onoff)
    170  1.5  uch 	tx_chipset_tag_t tc;
    171  1.5  uch 	int port, onoff;
    172  1.5  uch {
    173  1.5  uch 	txreg_t reg;
    174  1.5  uch 
    175  1.5  uch 	/* XXX check port is output or not */
    176  1.5  uch 
    177  1.5  uch 	if (port >= TXIO) { /* XXX TX3922 case */
    178  1.5  uch #ifdef TX391X
    179  1.5  uch 		txreg_t  iostat;
    180  1.5  uch 		/* IO */
    181  1.5  uch 		reg = tx_conf_read(tc, TX39_IOCTRL_REG);
    182  1.5  uch 		iostat = TX39_IOCTRL_IODOUT(reg);
    183  1.5  uch 		if (onoff)
    184  1.5  uch 			iostat |= (1 << (port - TXIO));
    185  1.5  uch 		else
    186  1.5  uch 			iostat &= ~(1 << (port - TXIO));
    187  1.5  uch 
    188  1.5  uch 		TX39_IOCTRL_IODOUT_CLR(reg);
    189  1.5  uch 		reg = TX39_IOCTRL_IODOUT_SET(reg, iostat);
    190  1.5  uch 		tx_conf_write(tc, TX39_IOCTRL_REG, reg);
    191  1.5  uch #endif /* TX391X */
    192  1.5  uch 	} else {
    193  1.5  uch 		/* MFIO */
    194  1.5  uch 		reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
    195  1.5  uch 		if (onoff)
    196  1.5  uch 			reg |= (1 << port);
    197  1.5  uch 		else
    198  1.5  uch 			reg &= ~(1 << port);
    199  1.5  uch 
    200  1.5  uch 		tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
    201  1.5  uch 	}
    202  1.5  uch }
    203  1.5  uch 
    204  1.5  uch #ifdef TX39IODEBUG
    205  1.5  uch int
    206  1.1  uch tx39io_intr(arg)
    207  1.1  uch 	void *arg;
    208  1.1  uch {
    209  1.1  uch 	printf("io (%d:%d)\n", (tx39intrvec >> 16) & 0xffff,
    210  1.1  uch 	       tx39intrvec & 0xfff);
    211  1.5  uch 
    212  1.1  uch 	return 0;
    213  1.1  uch }
    214  1.1  uch 
    215  1.1  uch int
    216  1.1  uch tx39mfio_intr(arg)
    217  1.1  uch 	void *arg;
    218  1.1  uch {
    219  1.1  uch 	printf("mfio (%d:%d)\n", (tx39intrvec >> 16) & 0xffff,
    220  1.1  uch 	       tx39intrvec & 0xfff);
    221  1.5  uch 
    222  1.1  uch 	return 0;
    223  1.1  uch }
    224  1.1  uch 
    225  1.1  uch void
    226  1.5  uch tx39io_dump(sc)
    227  1.5  uch 	struct tx39io_softc *sc;
    228  1.1  uch {
    229  1.5  uch #ifdef COMPAQ_LOCAL_INTR /* for debug */
    230  1.1  uch 	/* 2010c Rec button */
    231  1.1  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<6)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    232  1.1  uch 	/* Play button */
    233  1.1  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<5)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    234  1.5  uch 	/* Power connector */
    235  1.5  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<28)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    236  1.5  uch 	tx_intr_establish(tc, MAKEINTR(4, (1<<28)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    237  1.5  uch 	/* UARTA carrier */
    238  1.1  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    239  1.5  uch 	tx_intr_establish(tc, MAKEINTR(4, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    240  1.5  uch 	/* --> then turn off MFIO 31 */
    241  1.1  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<5)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    242  1.1  uch 	tx_intr_establish(tc, MAKEINTR(4, (1<<5)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    243  1.5  uch 	/* --> then turn off MFIO 6 */
    244  1.5  uch 	/* green LED:  MFIO 3 off */
    245  1.5  uch 	/* orange LED: not connected to TX39IO ??? */
    246  1.5  uch 	/* Backlight: UCB1200 GPIO port ??? */
    247  1.2  uch #endif
    248  1.5  uch #ifdef MOBILON_LOCAL_INTR /* for debug */
    249  1.5  uch 	/* Rec button */
    250  1.5  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<0)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    251  1.5  uch 	/* Play button */
    252  1.5  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<31)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    253  1.5  uch 	/* Battery cover open */
    254  1.5  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<29)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    255  1.5  uch 	/* Serial DCD */
    256  1.5  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<4)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    257  1.5  uch 	/* --> then turn off IO 3 ??? */
    258  1.5  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<6)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    259  1.5  uch 	/* --> then turn off IO 5 ??? */
    260  1.5  uch 	/* keyboard */
    261  1.5  uch 	tx_intr_establish(tc, MAKEINTR(5, (1<<13)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    262  1.5  uch 	/* Back light: MFIO 14 on */
    263  1.5  uch #endif
    264  1.5  uch #ifdef VICTOR_INTERLINK_INTR /* for debug */
    265  1.2  uch 	/* open panel */
    266  1.2  uch 	tx_intr_establish(tc, MAKEINTR(8, (1<<20)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    267  1.2  uch 	/* close panel */
    268  1.2  uch 	tx_intr_establish(tc, MAKEINTR(8, (1<<4)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    269  1.2  uch 	/* serial session */
    270  1.2  uch 	tx_intr_establish(tc, MAKEINTR(4, (1<<29)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    271  1.2  uch 	tx_intr_establish(tc, MAKEINTR(4, (1<<30)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    272  1.2  uch 	/* REC button */
    273  1.2  uch 	tx_intr_establish(tc, MAKEINTR(8, (1<<7)), IST_EDGE, IPL_CLOCK, tx39io_intr, sc);
    274  1.2  uch 	/* kbd */
    275  1.2  uch 	tx_intr_establish(tc, MAKEINTR(3, (1<<7)), IST_EDGE, IPL_CLOCK, tx39mfio_intr, sc);
    276  1.1  uch #endif
    277  1.1  uch 
    278  1.1  uch 	tx39io_dump_and_attach_handler(sc, TX39IO_ATTACH_DUMMYHANDLER);
    279  1.1  uch }
    280  1.1  uch 
    281  1.1  uch void
    282  1.1  uch tx39io_dump_and_attach_handler(sc, dummy)
    283  1.1  uch 	struct tx39io_softc *sc;
    284  1.1  uch 	int dummy;
    285  1.1  uch {
    286  1.1  uch 	tx_chipset_tag_t tc;
    287  1.1  uch 	u_int32_t reg, reg_out, reg_dir, reg_in, reg_sel, reg_pwr, reg_deb;
    288  1.1  uch 	int i;
    289  1.1  uch 	int (*iointr) __P((void*));
    290  1.1  uch 	int (*mfiointr) __P((void*));
    291  1.1  uch 
    292  1.1  uch 	tc = sc->sc_tc;
    293  1.1  uch 	if (dummy) {
    294  1.1  uch 		iointr =  tx39io_intr;
    295  1.1  uch 		mfiointr = tx39mfio_intr;
    296  1.1  uch 	} else {
    297  1.1  uch 		iointr = mfiointr = 0;
    298  1.1  uch 	}
    299  1.1  uch 
    300  1.1  uch 	printf("--------------------------------------------------------------\n");
    301  1.1  uch 	printf("	 Debounce Direction DataOut DataIn PowerDown Select\n");
    302  1.1  uch 	printf("--------------------------------------------------------------\n");
    303  1.1  uch 	/* IO */
    304  1.1  uch 	reg = tx_conf_read(tc, TX39_IOCTRL_REG);
    305  1.1  uch 	reg_deb = TX39_IOCTRL_IODEBSEL(reg);
    306  1.1  uch 	reg_dir = TX39_IOCTRL_IODIREC(reg);
    307  1.1  uch #ifdef TX391X
    308  1.1  uch 	reg_out = TX39_IOCTRL_IODOUT(reg);
    309  1.1  uch 	reg_in  = TX39_IOCTRL_IODIN(reg);
    310  1.1  uch #endif /* TX391X */
    311  1.1  uch #ifdef TX392X
    312  1.1  uch 	reg = tx_conf_read(tc, TX39_IODATAINOUT_REG);
    313  1.1  uch 	reg_out = TX39_IODATAINOUT_DOUT(reg);
    314  1.1  uch 	reg_in  = TX39_IODATAINOUT_DIN(reg);
    315  1.1  uch #endif /* TX392X */
    316  1.1  uch 	reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
    317  1.1  uch 	reg_pwr = TX39_IOIOPOWERDWN_IOPD(reg);
    318  1.1  uch 	for (i = TX39_IO_IO_MAX - 1; i >= 0 ; i--) {
    319  1.1  uch 		printf("IO   %2d:    ", i);
    320  1.1  uch 		printf("%s", ISSET(reg_dir, i) ? "On " : "Off");
    321  1.1  uch 		printf("      ");
    322  1.1  uch 		__dump_and_attach_handler(tc, reg_dir, reg_out, reg_in,
    323  1.5  uch 					  reg_pwr, i, 1, iointr, sc, 1);
    324  1.1  uch 
    325  1.1  uch 		printf("    -");
    326  1.1  uch 		printf("\n");
    327  1.1  uch 	}
    328  1.1  uch 	/* MFIO */
    329  1.1  uch 	printf("--------------------------------------------------------------\n");
    330  1.1  uch 	reg_out = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
    331  1.1  uch 	reg_dir = tx_conf_read(tc, TX39_IOMFIODATADIR_REG);
    332  1.1  uch 	reg_in  = tx_conf_read(tc, TX39_IOMFIODATAIN_REG);
    333  1.1  uch 	reg_sel = tx_conf_read(tc, TX39_IOMFIODATASEL_REG);
    334  1.1  uch 	reg_pwr = tx_conf_read(tc, TX39_IOMFIOPOWERDWN_REG);
    335  1.1  uch 	for (i = TX39_IO_MFIO_MAX - 1; i >= 0 ; i--) {
    336  1.1  uch 		printf("MFIO %2d:     -       ", i);
    337  1.1  uch 		__dump_and_attach_handler(tc, reg_dir, reg_out, reg_in,
    338  1.5  uch 					  reg_pwr, i, 0, mfiointr, sc,
    339  1.5  uch 					  ISSET(reg_sel, i));
    340  1.1  uch 		printf("  ");
    341  1.1  uch 		printf(ISSET(reg_sel, i) ? "MFIO(%s)" : "%s",
    342  1.1  uch 		       mfio_map[i].std_pin_name);
    343  1.1  uch 		printf("\n");
    344  1.1  uch 	}
    345  1.1  uch 	printf("--------------------------------------------------------------\n");
    346  1.1  uch }
    347  1.1  uch 
    348  1.1  uch void
    349  1.1  uch __dump_and_attach_handler(tc, reg_dir, reg_out, reg_in, reg_pwr,
    350  1.5  uch 			  i, io, func, arg, mf)
    351  1.1  uch 	tx_chipset_tag_t tc;
    352  1.1  uch 	u_int32_t reg_dir, reg_out, reg_in, reg_pwr;
    353  1.1  uch 	int i, io;
    354  1.1  uch 	int (*func) __P((void*));
    355  1.1  uch 	void *arg;
    356  1.5  uch 	int mf;
    357  1.1  uch {
    358  1.1  uch 	int pset, nset, pofs, nofs;
    359  1.1  uch 
    360  1.1  uch 	if (io) {
    361  1.1  uch #ifdef TX391X
    362  1.1  uch 		pset = nset = 5;
    363  1.1  uch 		pofs = i + 7;
    364  1.1  uch 		nofs = i;
    365  1.1  uch #endif
    366  1.1  uch #ifdef TX392X
    367  1.1  uch 		pset = nset = 8;
    368  1.1  uch 		pofs = i + 16;
    369  1.1  uch 		nofs = i;
    370  1.1  uch #endif
    371  1.1  uch 	} else {
    372  1.1  uch 		pset = 3;
    373  1.1  uch 		nset = 4;
    374  1.1  uch 		pofs = nofs = i;
    375  1.1  uch 	}
    376  1.1  uch 
    377  1.1  uch 	if (ISSET(reg_dir, i)) {
    378  1.3  uch #if defined TX39IO_MFIOOUTPORT_ON || defined TX39IO_MFIOOUTPORT_OFF
    379  1.1  uch 		txreg_t reg;
    380  1.4  uch #ifdef TX392X
    381  1.1  uch 		if (io) {
    382  1.1  uch 			reg = tx_conf_read(tc, TX39_IODATAINOUT_REG);
    383  1.3  uch #ifdef TX39IO_MFIOOUTPORT_ON
    384  1.1  uch 			reg |= (1 << (i + 16));
    385  1.4  uch 			printf("on.");
    386  1.3  uch #else
    387  1.3  uch 			reg &= ~(1 << (i + 16));
    388  1.4  uch 			printf("off.");
    389  1.3  uch #endif
    390  1.1  uch 			tx_conf_write(tc, TX39_IODATAINOUT_REG, reg);
    391  1.4  uch 		} else
    392  1.1  uch #endif /* TX392X */
    393  1.4  uch 		{
    394  1.1  uch 			reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
    395  1.3  uch #ifdef TX39IO_MFIOOUTPORT_ON
    396  1.1  uch 			reg |= (1 << i);
    397  1.4  uch 			printf("on.");
    398  1.3  uch #else
    399  1.3  uch 			reg &= ~(1 << i);
    400  1.4  uch 			printf("off.");
    401  1.3  uch #endif
    402  1.1  uch 			tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
    403  1.1  uch 		}
    404  1.1  uch #endif /* TX39IO_MFIOOUTPORT_ON */
    405  1.1  uch 		printf("Out");
    406  1.1  uch 	} else {
    407  1.1  uch 		printf("In ");
    408  1.5  uch 		if (mf && func) {
    409  1.1  uch 			/* Positive Edge */
    410  1.1  uch 			tx_intr_establish(
    411  1.1  uch 				tc, MAKEINTR(pset, (1 << pofs)),
    412  1.1  uch 				IST_EDGE, IPL_TTY, func, arg);
    413  1.1  uch 			/* Negative Edge */
    414  1.1  uch 			tx_intr_establish(
    415  1.1  uch 				tc, MAKEINTR(nset, (1 << nofs)),
    416  1.1  uch 				IST_EDGE, IPL_TTY, func, arg);
    417  1.1  uch 		}
    418  1.1  uch 	}
    419  1.1  uch 	printf("       ");
    420  1.1  uch 	printf("%d", ISSET(reg_out, i) ? 1 : 0);
    421  1.1  uch 	printf("       ");
    422  1.1  uch 	printf("%d", ISSET(reg_in, i) ? 1 : 0);
    423  1.1  uch 	printf("     ");
    424  1.1  uch 	printf("%s", ISSET(reg_pwr, i) ? "Down  ": "Active");
    425  1.1  uch };
    426  1.1  uch 
    427  1.1  uch #endif /* TX39IODEBUG */
    428