tx39io.c revision 1.7.2.2 1 1.7.2.2 bouyer /* $NetBSD: tx39io.c,v 1.7.2.2 2000/11/20 20:47:21 bouyer Exp $ */
2 1.7.2.2 bouyer
3 1.7.2.2 bouyer /*-
4 1.7.2.2 bouyer * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
5 1.7.2.2 bouyer * All rights reserved.
6 1.7.2.2 bouyer *
7 1.7.2.2 bouyer * This code is derived from software contributed to The NetBSD Foundation
8 1.7.2.2 bouyer * by UCHIYAMA Yasushi.
9 1.7.2.2 bouyer *
10 1.7.2.2 bouyer * Redistribution and use in source and binary forms, with or without
11 1.7.2.2 bouyer * modification, are permitted provided that the following conditions
12 1.7.2.2 bouyer * are met:
13 1.7.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
14 1.7.2.2 bouyer * notice, this list of conditions and the following disclaimer.
15 1.7.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
16 1.7.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
17 1.7.2.2 bouyer * documentation and/or other materials provided with the distribution.
18 1.7.2.2 bouyer * 3. All advertising materials mentioning features or use of this software
19 1.7.2.2 bouyer * must display the following acknowledgement:
20 1.7.2.2 bouyer * This product includes software developed by the NetBSD
21 1.7.2.2 bouyer * Foundation, Inc. and its contributors.
22 1.7.2.2 bouyer * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.7.2.2 bouyer * contributors may be used to endorse or promote products derived
24 1.7.2.2 bouyer * from this software without specific prior written permission.
25 1.7.2.2 bouyer *
26 1.7.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.7.2.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.7.2.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.7.2.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.7.2.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.7.2.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.7.2.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.7.2.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.7.2.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.7.2.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.7.2.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
37 1.7.2.2 bouyer */
38 1.7.2.2 bouyer #undef TX39IODEBUG
39 1.7.2.2 bouyer #include "opt_tx39_debug.h"
40 1.7.2.2 bouyer
41 1.7.2.2 bouyer #include <sys/param.h>
42 1.7.2.2 bouyer #include <sys/systm.h>
43 1.7.2.2 bouyer #include <sys/device.h>
44 1.7.2.2 bouyer
45 1.7.2.2 bouyer #include <machine/bus.h>
46 1.7.2.2 bouyer
47 1.7.2.2 bouyer #include <hpcmips/tx/tx39var.h>
48 1.7.2.2 bouyer #include <hpcmips/tx/tx39icureg.h>
49 1.7.2.2 bouyer #define __TX39IO_PRIVATE
50 1.7.2.2 bouyer #include <hpcmips/tx/tx39iovar.h>
51 1.7.2.2 bouyer #include <hpcmips/tx/tx39ioreg.h>
52 1.7.2.2 bouyer
53 1.7.2.2 bouyer #ifdef TX39IODEBUG
54 1.7.2.2 bouyer #define DPRINTF(arg) printf arg
55 1.7.2.2 bouyer #else
56 1.7.2.2 bouyer #define DPRINTF(arg)
57 1.7.2.2 bouyer #endif
58 1.7.2.2 bouyer
59 1.7.2.2 bouyer #define ISSET(x, s) ((x) & (1 << (s)))
60 1.7.2.2 bouyer
61 1.7.2.2 bouyer int tx39io_match(struct device *, struct cfdata *, void *);
62 1.7.2.2 bouyer void tx39io_attach(struct device *, struct device *, void *);
63 1.7.2.2 bouyer
64 1.7.2.2 bouyer struct cfattach tx39io_ca = {
65 1.7.2.2 bouyer sizeof(struct tx39io_softc), tx39io_match, tx39io_attach
66 1.7.2.2 bouyer };
67 1.7.2.2 bouyer
68 1.7.2.2 bouyer /* IO/MFIO common */
69 1.7.2.2 bouyer static void *port_intr_establish(void *, int, int (*)(void *), void *);
70 1.7.2.2 bouyer static void port_intr_disestablish(void *, void *);
71 1.7.2.2 bouyer /* MFIO */
72 1.7.2.2 bouyer static int mfio_in(void *, int);
73 1.7.2.2 bouyer static void mfio_out(void *, int, int);
74 1.7.2.2 bouyer static void mfio_intr_map(void *, int, int *, int *);
75 1.7.2.2 bouyer static void mfio_dump(void *);
76 1.7.2.2 bouyer static void mfio_update(void *);
77 1.7.2.2 bouyer /* IO */
78 1.7.2.2 bouyer #ifdef TX391X
79 1.7.2.2 bouyer static int tx391x_io_in(void *, int);
80 1.7.2.2 bouyer static void tx391x_io_out(void *, int, int);
81 1.7.2.2 bouyer static void tx391x_io_update(void *);
82 1.7.2.2 bouyer static void tx391x_io_intr_map(void *, int, int *, int *);
83 1.7.2.2 bouyer #endif
84 1.7.2.2 bouyer #ifdef TX392X
85 1.7.2.2 bouyer static int tx392x_io_in(void *, int);
86 1.7.2.2 bouyer static void tx392x_io_out(void *, int, int);
87 1.7.2.2 bouyer static void tx392x_io_update(void *);
88 1.7.2.2 bouyer static void tx392x_io_intr_map(void *, int, int *, int *);
89 1.7.2.2 bouyer #endif
90 1.7.2.2 bouyer static void io_dump(void *);
91 1.7.2.2 bouyer
92 1.7.2.2 bouyer static void __print_port_status(struct tx39io_port_status *, int);
93 1.7.2.2 bouyer
94 1.7.2.2 bouyer int
95 1.7.2.2 bouyer tx39io_match(struct device *parent, struct cfdata *cf, void *aux)
96 1.7.2.2 bouyer {
97 1.7.2.2 bouyer return ATTACH_FIRST; /* 1st attach group of txsim */
98 1.7.2.2 bouyer }
99 1.7.2.2 bouyer
100 1.7.2.2 bouyer void
101 1.7.2.2 bouyer tx39io_attach(struct device *parent, struct device *self, void *aux)
102 1.7.2.2 bouyer {
103 1.7.2.2 bouyer struct txsim_attach_args *ta = aux;
104 1.7.2.2 bouyer struct tx39io_softc *sc = (void *)self;
105 1.7.2.2 bouyer tx_chipset_tag_t tc;
106 1.7.2.2 bouyer struct txio_ops *ops_io = &sc->sc_io_ops;
107 1.7.2.2 bouyer struct txio_ops *ops_mfio = &sc->sc_mfio_ops;
108 1.7.2.2 bouyer
109 1.7.2.2 bouyer tc = sc->sc_tc = ta->ta_tc;
110 1.7.2.2 bouyer
111 1.7.2.2 bouyer printf("\n");
112 1.7.2.2 bouyer sc->sc_stat_io_mask = ~(1 << 5); /* exclude Plum2 INT */
113 1.7.2.2 bouyer sc->sc_stat_mfio_mask = ~(0x3|(0x3 << 23));
114 1.7.2.2 bouyer
115 1.7.2.2 bouyer /* IO */
116 1.7.2.2 bouyer ops_io->_v = sc;
117 1.7.2.2 bouyer ops_io->_group = IO;
118 1.7.2.2 bouyer ops_io->_intr_establish = port_intr_establish;
119 1.7.2.2 bouyer ops_io->_intr_disestablish = port_intr_disestablish;
120 1.7.2.2 bouyer ops_io->_dump = io_dump;
121 1.7.2.2 bouyer if (IS_TX391X(tc)) {
122 1.7.2.2 bouyer #ifdef TX391X
123 1.7.2.2 bouyer ops_io->_in = tx391x_io_in;
124 1.7.2.2 bouyer ops_io->_out = tx391x_io_out;
125 1.7.2.2 bouyer ops_io->_intr_map = tx391x_io_intr_map;
126 1.7.2.2 bouyer ops_io->_update = tx391x_io_update;
127 1.7.2.2 bouyer #endif
128 1.7.2.2 bouyer } else if (IS_TX392X(tc)) {
129 1.7.2.2 bouyer #ifdef TX392X
130 1.7.2.2 bouyer ops_io->_in = tx392x_io_in;
131 1.7.2.2 bouyer ops_io->_out = tx392x_io_out;
132 1.7.2.2 bouyer ops_io->_intr_map = tx392x_io_intr_map;
133 1.7.2.2 bouyer ops_io->_update = tx392x_io_update;
134 1.7.2.2 bouyer #endif
135 1.7.2.2 bouyer }
136 1.7.2.2 bouyer tx_conf_register_ioman(tc, ops_io);
137 1.7.2.2 bouyer
138 1.7.2.2 bouyer /* MFIO */
139 1.7.2.2 bouyer ops_mfio->_v = sc;
140 1.7.2.2 bouyer ops_mfio->_group = MFIO;
141 1.7.2.2 bouyer ops_mfio->_in = mfio_in;
142 1.7.2.2 bouyer ops_mfio->_out = mfio_out;
143 1.7.2.2 bouyer ops_mfio->_intr_map = mfio_intr_map;
144 1.7.2.2 bouyer ops_mfio->_intr_establish = port_intr_establish;
145 1.7.2.2 bouyer ops_mfio->_intr_disestablish = port_intr_disestablish;
146 1.7.2.2 bouyer ops_mfio->_update = mfio_update;
147 1.7.2.2 bouyer ops_mfio->_dump = mfio_dump;
148 1.7.2.2 bouyer
149 1.7.2.2 bouyer tx_conf_register_ioman(tc, ops_mfio);
150 1.7.2.2 bouyer
151 1.7.2.2 bouyer tx_ioman_update(IO);
152 1.7.2.2 bouyer tx_ioman_update(MFIO);
153 1.7.2.2 bouyer
154 1.7.2.2 bouyer #ifdef TX39IODEBUG
155 1.7.2.2 bouyer tx_ioman_dump(IO);
156 1.7.2.2 bouyer tx_ioman_dump(MFIO);
157 1.7.2.2 bouyer #else
158 1.7.2.2 bouyer printf("IO i0x%08x o0x%08x MFIO i0x%08x o0x%08x\n",
159 1.7.2.2 bouyer sc->sc_stat_io.in, sc->sc_stat_io.out,
160 1.7.2.2 bouyer sc->sc_stat_mfio.in, sc->sc_stat_mfio.out);
161 1.7.2.2 bouyer #endif
162 1.7.2.2 bouyer }
163 1.7.2.2 bouyer
164 1.7.2.2 bouyer /*
165 1.7.2.2 bouyer * TX391X, TX392X common
166 1.7.2.2 bouyer */
167 1.7.2.2 bouyer static void *
168 1.7.2.2 bouyer port_intr_establish(void *arg, int edge, int (*func)(void *), void *func_arg)
169 1.7.2.2 bouyer {
170 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
171 1.7.2.2 bouyer return tx_intr_establish(sc->sc_tc, edge, IST_EDGE, IPL_CLOCK, func,
172 1.7.2.2 bouyer func_arg);
173 1.7.2.2 bouyer }
174 1.7.2.2 bouyer
175 1.7.2.2 bouyer static void
176 1.7.2.2 bouyer port_intr_disestablish(void *arg, void *ih)
177 1.7.2.2 bouyer {
178 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
179 1.7.2.2 bouyer tx_intr_disestablish(sc->sc_tc, ih);
180 1.7.2.2 bouyer }
181 1.7.2.2 bouyer
182 1.7.2.2 bouyer static void
183 1.7.2.2 bouyer mfio_out(void *arg, int port, int onoff)
184 1.7.2.2 bouyer {
185 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
186 1.7.2.2 bouyer tx_chipset_tag_t tc;
187 1.7.2.2 bouyer txreg_t reg, pos;
188 1.7.2.2 bouyer
189 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
190 1.7.2.2 bouyer tc = sc->sc_tc;
191 1.7.2.2 bouyer /* MFIO */
192 1.7.2.2 bouyer pos = 1 << port;
193 1.7.2.2 bouyer #ifdef DIAGNOSTIC
194 1.7.2.2 bouyer if (!(sc->sc_stat_mfio.dir & pos)) {
195 1.7.2.2 bouyer panic("%s: MFIO%d is not output port.\n",
196 1.7.2.2 bouyer sc->sc_dev.dv_xname, port);
197 1.7.2.2 bouyer }
198 1.7.2.2 bouyer #endif
199 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
200 1.7.2.2 bouyer if (onoff)
201 1.7.2.2 bouyer reg |= pos;
202 1.7.2.2 bouyer else
203 1.7.2.2 bouyer reg &= ~pos;
204 1.7.2.2 bouyer tx_conf_write(tc, TX39_IOMFIODATAOUT_REG, reg);
205 1.7.2.2 bouyer }
206 1.7.2.2 bouyer
207 1.7.2.2 bouyer static int
208 1.7.2.2 bouyer mfio_in(void *arg, int port)
209 1.7.2.2 bouyer {
210 1.7.2.2 bouyer struct tx39io_softc *sc __attribute__((__unused__)) = arg ;
211 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
212 1.7.2.2 bouyer return tx_conf_read(sc->sc_tc, TX39_IOMFIODATAIN_REG) & (1 << port);
213 1.7.2.2 bouyer }
214 1.7.2.2 bouyer
215 1.7.2.2 bouyer static void
216 1.7.2.2 bouyer mfio_intr_map(void *arg, int port, int *pedge, int *nedge)
217 1.7.2.2 bouyer {
218 1.7.2.2 bouyer if (pedge)
219 1.7.2.2 bouyer *pedge = MAKEINTR(3, (1 << port));
220 1.7.2.2 bouyer if (nedge)
221 1.7.2.2 bouyer *nedge = MAKEINTR(4, (1 << port));
222 1.7.2.2 bouyer }
223 1.7.2.2 bouyer
224 1.7.2.2 bouyer static void
225 1.7.2.2 bouyer mfio_update(void *arg)
226 1.7.2.2 bouyer {
227 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
228 1.7.2.2 bouyer tx_chipset_tag_t tc = sc->sc_tc;
229 1.7.2.2 bouyer struct tx39io_port_status *stat_mfio = &sc->sc_stat_mfio;
230 1.7.2.2 bouyer
231 1.7.2.2 bouyer sc->sc_ostat_mfio = *stat_mfio; /* save old status */
232 1.7.2.2 bouyer stat_mfio->dir = tx_conf_read(tc, TX39_IOMFIODATADIR_REG);
233 1.7.2.2 bouyer stat_mfio->in = tx_conf_read(tc, TX39_IOMFIODATAIN_REG);
234 1.7.2.2 bouyer stat_mfio->out = tx_conf_read(tc, TX39_IOMFIODATAOUT_REG);
235 1.7.2.2 bouyer stat_mfio->power = tx_conf_read(tc, TX39_IOMFIOPOWERDWN_REG);
236 1.7.2.2 bouyer stat_mfio->u.select = tx_conf_read(tc, TX39_IOMFIODATASEL_REG);
237 1.7.2.2 bouyer }
238 1.7.2.2 bouyer
239 1.7.2.2 bouyer #ifdef TX391X
240 1.7.2.2 bouyer /*
241 1.7.2.2 bouyer * TMPR3912 specific
242 1.7.2.2 bouyer */
243 1.7.2.2 bouyer int
244 1.7.2.2 bouyer tx391x_io_in(void *arg, int port)
245 1.7.2.2 bouyer {
246 1.7.2.2 bouyer struct tx39io_softc *sc __attribute__((__unused__)) = arg;
247 1.7.2.2 bouyer txreg_t reg = tx_conf_read(sc->sc_tc, TX39_IOCTRL_REG);
248 1.7.2.2 bouyer
249 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
250 1.7.2.2 bouyer return TX391X_IOCTRL_IODIN(reg) & (1 << port);
251 1.7.2.2 bouyer }
252 1.7.2.2 bouyer
253 1.7.2.2 bouyer void
254 1.7.2.2 bouyer tx391x_io_out(void *arg, int port, int onoff)
255 1.7.2.2 bouyer {
256 1.7.2.2 bouyer #ifdef DIAGNOSTIC
257 1.7.2.2 bouyer const char *devname;
258 1.7.2.2 bouyer #endif
259 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
260 1.7.2.2 bouyer tx_chipset_tag_t tc;
261 1.7.2.2 bouyer txreg_t reg, pos, iostat;
262 1.7.2.2 bouyer
263 1.7.2.2 bouyer KASSERT(sc);
264 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
265 1.7.2.2 bouyer
266 1.7.2.2 bouyer devname = sc->sc_dev.dv_xname;
267 1.7.2.2 bouyer tc = sc->sc_tc;
268 1.7.2.2 bouyer
269 1.7.2.2 bouyer /* IO [0:6] */
270 1.7.2.2 bouyer pos = 1 << port;
271 1.7.2.2 bouyer #ifdef DIAGNOSTIC
272 1.7.2.2 bouyer if (!(sc->sc_stat_io.dir & pos))
273 1.7.2.2 bouyer panic("%s: IO%d is not output port.\n", devname, port);
274 1.7.2.2 bouyer #endif
275 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOCTRL_REG);
276 1.7.2.2 bouyer iostat = TX391X_IOCTRL_IODOUT(reg);
277 1.7.2.2 bouyer if (onoff)
278 1.7.2.2 bouyer iostat |= pos;
279 1.7.2.2 bouyer else
280 1.7.2.2 bouyer iostat &= ~pos;
281 1.7.2.2 bouyer TX391X_IOCTRL_IODOUT_CLR(reg);
282 1.7.2.2 bouyer reg = TX391X_IOCTRL_IODOUT_SET(reg, iostat);
283 1.7.2.2 bouyer tx_conf_write(tc, TX39_IOCTRL_REG, reg);
284 1.7.2.2 bouyer }
285 1.7.2.2 bouyer
286 1.7.2.2 bouyer void
287 1.7.2.2 bouyer tx391x_io_intr_map(void *arg, int port, int *pedge, int *nedge)
288 1.7.2.2 bouyer {
289 1.7.2.2 bouyer if (pedge)
290 1.7.2.2 bouyer *pedge = MAKEINTR(5, (1 << (port + 7)));
291 1.7.2.2 bouyer if (nedge)
292 1.7.2.2 bouyer *nedge = MAKEINTR(5, (1 << port));
293 1.7.2.2 bouyer }
294 1.7.2.2 bouyer
295 1.7.2.2 bouyer void
296 1.7.2.2 bouyer tx391x_io_update(void *arg)
297 1.7.2.2 bouyer {
298 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
299 1.7.2.2 bouyer struct tx39io_port_status *stat_io = &sc->sc_stat_io;
300 1.7.2.2 bouyer tx_chipset_tag_t tc = sc->sc_tc;
301 1.7.2.2 bouyer txreg_t reg;
302 1.7.2.2 bouyer
303 1.7.2.2 bouyer /* IO [0:6] */
304 1.7.2.2 bouyer sc->sc_ostat_io = *stat_io; /* save old status */
305 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOCTRL_REG);
306 1.7.2.2 bouyer stat_io->dir = TX391X_IOCTRL_IODIREC(reg);
307 1.7.2.2 bouyer stat_io->in = TX391X_IOCTRL_IODIN(reg);
308 1.7.2.2 bouyer stat_io->out = TX391X_IOCTRL_IODOUT(reg);
309 1.7.2.2 bouyer stat_io->u.debounce = TX391X_IOCTRL_IODEBSEL(reg);
310 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
311 1.7.2.2 bouyer stat_io->power = TX391X_IOIOPOWERDWN_IOPD(reg);
312 1.7.2.2 bouyer }
313 1.7.2.2 bouyer #endif /* TX391X */
314 1.7.2.2 bouyer
315 1.7.2.2 bouyer #ifdef TX392X
316 1.7.2.2 bouyer /*
317 1.7.2.2 bouyer * TMPR3922 specific
318 1.7.2.2 bouyer */
319 1.7.2.2 bouyer int
320 1.7.2.2 bouyer tx392x_io_in(void *arg, int port)
321 1.7.2.2 bouyer {
322 1.7.2.2 bouyer struct tx39io_softc *sc __attribute__((__unused__)) = arg;
323 1.7.2.2 bouyer txreg_t reg = tx_conf_read(sc->sc_tc, TX392X_IODATAINOUT_REG);
324 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
325 1.7.2.2 bouyer
326 1.7.2.2 bouyer return TX392X_IODATAINOUT_DIN(reg) & (1 << port);
327 1.7.2.2 bouyer }
328 1.7.2.2 bouyer
329 1.7.2.2 bouyer void
330 1.7.2.2 bouyer tx392x_io_out(void *arg, int port, int onoff)
331 1.7.2.2 bouyer {
332 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
333 1.7.2.2 bouyer #ifdef DIAGNOSTIC
334 1.7.2.2 bouyer const char *devname = sc->sc_dev.dv_xname;
335 1.7.2.2 bouyer #endif
336 1.7.2.2 bouyer tx_chipset_tag_t tc = sc->sc_tc;
337 1.7.2.2 bouyer txreg_t reg, pos, iostat;
338 1.7.2.2 bouyer
339 1.7.2.2 bouyer DPRINTF(("%s: port #%d\n", __FUNCTION__, port));
340 1.7.2.2 bouyer /* IO [0:15] */
341 1.7.2.2 bouyer pos = 1 << port;
342 1.7.2.2 bouyer #ifdef DIAGNOSTIC
343 1.7.2.2 bouyer if (!(sc->sc_status.dir_io & pos))
344 1.7.2.2 bouyer panic("%s: IO%d is not output port.\n", devname, port);
345 1.7.2.2 bouyer #endif
346 1.7.2.2 bouyer reg = tx_conf_read(tc, TX392X_IODATAINOUT_REG);
347 1.7.2.2 bouyer iostat = TX392X_IODATAINOUT_DOUT(reg);
348 1.7.2.2 bouyer if (onoff)
349 1.7.2.2 bouyer iostat |= pos;
350 1.7.2.2 bouyer else
351 1.7.2.2 bouyer iostat &= ~pos;
352 1.7.2.2 bouyer TX392X_IODATAINOUT_DOUT_CLR(reg);
353 1.7.2.2 bouyer reg = TX392X_IODATAINOUT_DOUT_SET(reg, iostat);
354 1.7.2.2 bouyer tx_conf_write(tc, TX392X_IODATAINOUT_REG, reg);
355 1.7.2.2 bouyer }
356 1.7.2.2 bouyer
357 1.7.2.2 bouyer void
358 1.7.2.2 bouyer tx392x_io_intr_map(void *arg, int port, int *pedge, int *nedge)
359 1.7.2.2 bouyer {
360 1.7.2.2 bouyer if (pedge)
361 1.7.2.2 bouyer *pedge = MAKEINTR(8, (1 << (port + 16)));
362 1.7.2.2 bouyer if (nedge)
363 1.7.2.2 bouyer *nedge = MAKEINTR(8, (1 << port));
364 1.7.2.2 bouyer }
365 1.7.2.2 bouyer
366 1.7.2.2 bouyer void
367 1.7.2.2 bouyer tx392x_io_update(void *arg)
368 1.7.2.2 bouyer {
369 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
370 1.7.2.2 bouyer struct tx39io_port_status *stat_io = &sc->sc_stat_io;
371 1.7.2.2 bouyer tx_chipset_tag_t tc = sc->sc_tc;
372 1.7.2.2 bouyer txreg_t reg;
373 1.7.2.2 bouyer
374 1.7.2.2 bouyer sc->sc_ostat_io = *stat_io; /* save old status */
375 1.7.2.2 bouyer /* IO [0:15] */
376 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOCTRL_REG);
377 1.7.2.2 bouyer stat_io->dir = TX392X_IOCTRL_IODIREC(reg);
378 1.7.2.2 bouyer stat_io->u.debounce = TX392X_IOCTRL_IODEBSEL(reg);
379 1.7.2.2 bouyer reg = tx_conf_read(tc, TX392X_IODATAINOUT_REG);
380 1.7.2.2 bouyer stat_io->in = TX392X_IODATAINOUT_DIN(reg);
381 1.7.2.2 bouyer stat_io->out = TX392X_IODATAINOUT_DOUT(reg);
382 1.7.2.2 bouyer reg = tx_conf_read(tc, TX39_IOIOPOWERDWN_REG);
383 1.7.2.2 bouyer stat_io->power = TX392X_IOIOPOWERDWN_IOPD(reg);
384 1.7.2.2 bouyer }
385 1.7.2.2 bouyer
386 1.7.2.2 bouyer #endif /* TX392X */
387 1.7.2.2 bouyer
388 1.7.2.2 bouyer static const char *line = "--------------------------------------------------"
389 1.7.2.2 bouyer "------------\n";
390 1.7.2.2 bouyer static void
391 1.7.2.2 bouyer mfio_dump(void *arg)
392 1.7.2.2 bouyer {
393 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
394 1.7.2.2 bouyer const struct tx39io_mfio_map *map = tx39io_get_mfio_map(tc);
395 1.7.2.2 bouyer struct tx39io_port_status *stat;
396 1.7.2.2 bouyer int i;
397 1.7.2.2 bouyer
398 1.7.2.2 bouyer printf("%s", line);
399 1.7.2.2 bouyer stat = &sc->sc_stat_mfio;
400 1.7.2.2 bouyer for (i = TX39_IO_MFIO_MAX - 1; i >= 0 ; i--) {
401 1.7.2.2 bouyer /* MFIO port has power down state */
402 1.7.2.2 bouyer printf("MFIO %2d: - ", i);
403 1.7.2.2 bouyer __print_port_status(stat, i);
404 1.7.2.2 bouyer printf(ISSET(stat->u.select, i) ? " MFIO(%s)\n" : " %s\n",
405 1.7.2.2 bouyer map[i].std_pin_name);
406 1.7.2.2 bouyer }
407 1.7.2.2 bouyer printf("%s", line);
408 1.7.2.2 bouyer }
409 1.7.2.2 bouyer
410 1.7.2.2 bouyer static void
411 1.7.2.2 bouyer io_dump(void *arg)
412 1.7.2.2 bouyer {
413 1.7.2.2 bouyer struct tx39io_softc *sc = arg;
414 1.7.2.2 bouyer struct tx39io_port_status *stat;
415 1.7.2.2 bouyer int i;
416 1.7.2.2 bouyer
417 1.7.2.2 bouyer printf("%s Debounce Direction DataOut DataIn PowerDown Select"
418 1.7.2.2 bouyer "\n%s", line, line);
419 1.7.2.2 bouyer stat = &sc->sc_stat_io;
420 1.7.2.2 bouyer for (i = tx39io_get_io_max(tc) - 1; i >= 0 ; i--) {
421 1.7.2.2 bouyer /* IO port has debouncer */
422 1.7.2.2 bouyer printf("IO %2d: %s ", i,
423 1.7.2.2 bouyer ISSET(stat->u.debounce, i) ? "On " : "Off");
424 1.7.2.2 bouyer __print_port_status(stat, i);
425 1.7.2.2 bouyer printf(" -\n");
426 1.7.2.2 bouyer }
427 1.7.2.2 bouyer }
428 1.7.2.2 bouyer
429 1.7.2.2 bouyer static void
430 1.7.2.2 bouyer __print_port_status(struct tx39io_port_status *stat, int i)
431 1.7.2.2 bouyer {
432 1.7.2.2 bouyer printf("%s %d %d %s",
433 1.7.2.2 bouyer ISSET(stat->dir, i) ? "Out" : "In ",
434 1.7.2.2 bouyer ISSET(stat->out, i) ? 1 : 0,
435 1.7.2.2 bouyer ISSET(stat->in, i) ? 1 : 0,
436 1.7.2.2 bouyer ISSET(stat->power, i) ? "Down ": "Active");
437 1.7.2.2 bouyer }
438 1.7.2.2 bouyer
439