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