vrpiu.c revision 1.18 1 1.18 takemura /* $NetBSD: vrpiu.c,v 1.18 2002/01/27 14:18:13 takemura Exp $ */
2 1.1 takemura
3 1.1 takemura /*
4 1.14 sato * Copyright (c) 1999-2001 Shin Takemura All rights reserved.
5 1.14 sato * Copyright (c) 2000-2001 SATO Kazumi, All rights reserved.
6 1.14 sato * Copyright (c) 1999-2001 PocketBSD Project. All rights reserved.
7 1.1 takemura *
8 1.1 takemura * Redistribution and use in source and binary forms, with or without
9 1.1 takemura * modification, are permitted provided that the following conditions
10 1.1 takemura * are met:
11 1.1 takemura * 1. Redistributions of source code must retain the above copyright
12 1.1 takemura * notice, this list of conditions and the following disclaimer.
13 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 takemura * notice, this list of conditions and the following disclaimer in the
15 1.1 takemura * documentation and/or other materials provided with the distribution.
16 1.1 takemura *
17 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 1.1 takemura * SUCH DAMAGE.
28 1.1 takemura *
29 1.1 takemura */
30 1.1 takemura
31 1.6 sato /*
32 1.6 sato * A/D polling part written by SATO Kazumi.
33 1.6 sato */
34 1.6 sato
35 1.1 takemura #include <sys/param.h>
36 1.1 takemura #include <sys/systm.h>
37 1.1 takemura #include <sys/device.h>
38 1.1 takemura #include <sys/kernel.h>
39 1.6 sato #include <sys/callout.h>
40 1.6 sato #include <sys/boot_flag.h>
41 1.1 takemura
42 1.1 takemura #include <dev/wscons/wsconsio.h>
43 1.1 takemura #include <dev/wscons/wsmousevar.h>
44 1.1 takemura
45 1.1 takemura #include <machine/bus.h>
46 1.5 matt #include <machine/platid.h>
47 1.5 matt #include <machine/platid_mask.h>
48 1.6 sato #include <machine/config_hook.h>
49 1.1 takemura
50 1.11 uch #include <dev/hpc/tpcalibvar.h>
51 1.11 uch
52 1.14 sato #include <dev/hpc/hpcbatteryvar.h>
53 1.14 sato #include <dev/hpc/hpcbatterytable.h>
54 1.14 sato
55 1.6 sato #include <hpcmips/hpcmips/machdep.h>
56 1.17 sato #include <hpcmips/vr/vrcpudef.h>
57 1.18 takemura #include <hpcmips/vr/vripif.h>
58 1.1 takemura #include <hpcmips/vr/cmureg.h>
59 1.1 takemura #include <hpcmips/vr/vrpiuvar.h>
60 1.1 takemura #include <hpcmips/vr/vrpiureg.h>
61 1.1 takemura
62 1.1 takemura /*
63 1.1 takemura * contant and macro definitions
64 1.1 takemura */
65 1.1 takemura #define VRPIUDEBUG
66 1.1 takemura #ifdef VRPIUDEBUG
67 1.1 takemura int vrpiu_debug = 0;
68 1.1 takemura #define DPRINTF(arg) if (vrpiu_debug) printf arg;
69 1.6 sato #define VPRINTF(arg) if (bootverbose || vrpiu_debug) printf arg;
70 1.1 takemura #else
71 1.1 takemura #define DPRINTF(arg)
72 1.6 sato #define VPRINTF(arg) if (bootverbose) printf arg;
73 1.1 takemura #endif
74 1.1 takemura
75 1.14 sato #ifndef VRPIU_NO_ADHOC_BATTERY_EVENT
76 1.14 sato #define VRPIU_ADHOC_BATTERY_EVENT /* currently... */
77 1.14 sato #endif /* VRPIU_NO_ADHOC_BATTERY_EVENT */
78 1.14 sato
79 1.6 sato #ifndef VRPIU_AD_POLL_INTERVAL
80 1.6 sato #define VRPIU_AD_POLL_INTERVAL 60 /* interval is 60 sec */
81 1.6 sato #endif /* VRPIU_AD_POLL_INTERTVAL */
82 1.8 takemura
83 1.8 takemura #define PIUSIVL_SCANINTVAL_MIN 333 /* 10msec */
84 1.8 takemura #define PIUSIVL_SCANINTVAL_MAX PIUSIVL_SCANINTVAL_MASK /* 60msec */
85 1.10 takemura #define VRPIU_TP_SCAN_TIMEOUT (hz/10) /* timeout is 100msec */
86 1.8 takemura
87 1.8 takemura #define TP_INTR (PIUINT_ALLINTR & ~PIUINT_PADADPINTR)
88 1.8 takemura #define AD_INTR (PIUINT_PADADPINTR)
89 1.8 takemura
90 1.1 takemura /*
91 1.1 takemura * data types
92 1.1 takemura */
93 1.1 takemura /* struct vrpiu_softc is defined in vrpiuvar.h */
94 1.1 takemura
95 1.1 takemura /*
96 1.1 takemura * function prototypes
97 1.1 takemura */
98 1.15 uch static int vrpiumatch(struct device *, struct cfdata *, void *);
99 1.15 uch static void vrpiuattach(struct device *, struct device *, void *);
100 1.1 takemura
101 1.15 uch static void vrpiu_write(struct vrpiu_softc *, int, unsigned short);
102 1.15 uch static u_short vrpiu_read(struct vrpiu_softc *, int);
103 1.1 takemura
104 1.15 uch static int vrpiu_intr(void *);
105 1.15 uch static void vrpiu_tp_intr(struct vrpiu_softc *);
106 1.15 uch static void vrpiu_ad_intr(struct vrpiu_softc *);
107 1.1 takemura #ifdef DEBUG
108 1.15 uch static void vrpiu_dump_cntreg(unsigned int);
109 1.1 takemura #endif
110 1.1 takemura
111 1.15 uch static int vrpiu_tp_enable(void *);
112 1.15 uch static int vrpiu_tp_ioctl(void *, u_long, caddr_t, int, struct proc *);
113 1.15 uch static void vrpiu_tp_disable(void *);
114 1.15 uch static void vrpiu_tp_up(struct vrpiu_softc *);
115 1.15 uch static void vrpiu_tp_timeout(void *);
116 1.15 uch int vrpiu_ad_enable(void *);
117 1.15 uch void vrpiu_ad_disable(void *);
118 1.15 uch static void vrpiu_start_powerstate(void *);
119 1.15 uch static void vrpiu_calc_powerstate(struct vrpiu_softc *);
120 1.15 uch static void vrpiu_send_battery_event(struct vrpiu_softc *);
121 1.15 uch static void vrpiu_power(int, void *);
122 1.15 uch static u_int scan_interval(u_int data);
123 1.1 takemura
124 1.1 takemura /* mra is defined in mra.c */
125 1.15 uch int mra_Y_AX1_BX2_C(int *y, int ys, int *x1, int x1s, int *x2, int x2s,
126 1.15 uch int n, int scale, int *a, int *b, int *c);
127 1.1 takemura
128 1.1 takemura /*
129 1.1 takemura * static or global variables
130 1.1 takemura */
131 1.1 takemura struct cfattach vrpiu_ca = {
132 1.1 takemura sizeof(struct vrpiu_softc), vrpiumatch, vrpiuattach
133 1.1 takemura };
134 1.1 takemura
135 1.1 takemura const struct wsmouse_accessops vrpiu_accessops = {
136 1.6 sato vrpiu_tp_enable,
137 1.6 sato vrpiu_tp_ioctl,
138 1.6 sato vrpiu_tp_disable,
139 1.1 takemura };
140 1.1 takemura
141 1.6 sato int vrpiu_ad_poll_interval = VRPIU_AD_POLL_INTERVAL;
142 1.6 sato
143 1.1 takemura /*
144 1.1 takemura * function definitions
145 1.1 takemura */
146 1.1 takemura static inline void
147 1.15 uch vrpiu_write(struct vrpiu_softc *sc, int port, unsigned short val)
148 1.1 takemura {
149 1.15 uch
150 1.1 takemura bus_space_write_2(sc->sc_iot, sc->sc_ioh, port, val);
151 1.1 takemura }
152 1.1 takemura
153 1.1 takemura static inline u_short
154 1.15 uch vrpiu_read(struct vrpiu_softc *sc, int port)
155 1.1 takemura {
156 1.15 uch
157 1.15 uch return (bus_space_read_2(sc->sc_iot, sc->sc_ioh, port));
158 1.1 takemura }
159 1.1 takemura
160 1.1 takemura static int
161 1.15 uch vrpiumatch(struct device *parent, struct cfdata *cf, void *aux)
162 1.1 takemura {
163 1.15 uch
164 1.15 uch return (1);
165 1.1 takemura }
166 1.1 takemura
167 1.1 takemura static void
168 1.15 uch vrpiuattach(struct device *parent, struct device *self, void *aux)
169 1.1 takemura {
170 1.1 takemura struct vrpiu_softc *sc = (struct vrpiu_softc *)self;
171 1.1 takemura struct vrip_attach_args *va = aux;
172 1.1 takemura struct wsmousedev_attach_args wsmaa;
173 1.1 takemura
174 1.1 takemura bus_space_tag_t iot = va->va_iot;
175 1.1 takemura bus_space_handle_t ioh;
176 1.14 sato struct platid_data *p;
177 1.1 takemura
178 1.1 takemura if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
179 1.15 uch printf(": can't map bus space\n");
180 1.15 uch return;
181 1.1 takemura }
182 1.1 takemura
183 1.1 takemura sc->sc_iot = iot;
184 1.1 takemura sc->sc_ioh = ioh;
185 1.1 takemura sc->sc_vrip = va->va_vc;
186 1.1 takemura
187 1.8 takemura sc->sc_interval = scan_interval(WSMOUSE_RES_DEFAULT);
188 1.16 takemura if ((p = platid_search_data(&platid, hpcbattery_parameters)) == NULL)
189 1.14 sato sc->sc_battery_spec = NULL;
190 1.14 sato else
191 1.14 sato sc->sc_battery_spec = p->data;
192 1.8 takemura
193 1.1 takemura /*
194 1.1 takemura * disable device until vrpiu_enable called
195 1.1 takemura */
196 1.6 sato sc->sc_tpstat = VRPIU_TP_STAT_DISABLE;
197 1.1 takemura
198 1.10 takemura /* initialize touch panel timeout structure */
199 1.10 takemura callout_init(&sc->sc_tptimeout);
200 1.10 takemura
201 1.10 takemura /* initialize calibration context */
202 1.3 takemura tpcalib_init(&sc->sc_tpcalib);
203 1.1 takemura #if 1
204 1.1 takemura /*
205 1.1 takemura * XXX, calibrate parameters
206 1.1 takemura */
207 1.1 takemura {
208 1.15 uch int i;
209 1.15 uch static const struct {
210 1.15 uch platid_mask_t *mask;
211 1.15 uch struct wsmouse_calibcoords coords;
212 1.15 uch } calibrations[] = {
213 1.15 uch { &platid_mask_MACH_NEC_MCR_700,
214 1.15 uch { 0, 0, 799, 599,
215 1.15 uch 4,
216 1.15 uch { { 115, 80, 0, 0 },
217 1.15 uch { 115, 966, 0, 599 },
218 1.15 uch { 912, 80, 799, 0 },
219 1.15 uch { 912, 966, 799, 599 } } } },
220 1.15 uch { &platid_mask_MACH_NEC_MCR_700A,
221 1.15 uch { 0, 0, 799, 599,
222 1.15 uch 4,
223 1.15 uch { { 115, 80, 0, 0 },
224 1.15 uch { 115, 966, 0, 599 },
225 1.15 uch { 912, 80, 799, 0 },
226 1.15 uch { 912, 966, 799, 599 } } } },
227 1.15 uch { &platid_mask_MACH_NEC_MCR_730,
228 1.15 uch { 0, 0, 799, 599,
229 1.15 uch 4,
230 1.15 uch { { 115, 80, 0, 0 },
231 1.15 uch { 115, 966, 0, 599 },
232 1.15 uch { 912, 80, 799, 0 },
233 1.15 uch { 912, 966, 799, 599 } } } },
234 1.15 uch { NULL, /* samples got on my MC-R500 */
235 1.15 uch { 0, 0, 639, 239,
236 1.15 uch 5,
237 1.15 uch { { 502, 486, 320, 120 },
238 1.15 uch { 55, 109, 0, 0 },
239 1.15 uch { 54, 913, 0, 239 },
240 1.15 uch { 973, 924, 639, 239 },
241 1.15 uch { 975, 123, 639, 0 } } } },
242 1.15 uch };
243 1.15 uch for (i = 0; ; i++) {
244 1.15 uch if (calibrations[i].mask == NULL
245 1.15 uch || platid_match(&platid, calibrations[i].mask))
246 1.15 uch break;
247 1.15 uch }
248 1.15 uch tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
249 1.15 uch (caddr_t)&calibrations[i].coords, 0, 0);
250 1.1 takemura }
251 1.1 takemura #endif
252 1.1 takemura
253 1.1 takemura /* install interrupt handler and enable interrupt */
254 1.1 takemura if (!(sc->sc_handler =
255 1.18 takemura vrip_intr_establish(va->va_vc, va->va_unit, 0, IPL_TTY,
256 1.15 uch vrpiu_intr, sc))) {
257 1.15 uch printf (": can't map interrupt line.\n");
258 1.15 uch return;
259 1.1 takemura }
260 1.1 takemura
261 1.1 takemura /* mask level2 interrupt, stop scan sequencer and mask clock to piu */
262 1.6 sato vrpiu_tp_disable(sc);
263 1.1 takemura
264 1.1 takemura printf("\n");
265 1.1 takemura
266 1.1 takemura wsmaa.accessops = &vrpiu_accessops;
267 1.1 takemura wsmaa.accesscookie = sc;
268 1.1 takemura
269 1.1 takemura /*
270 1.1 takemura * attach the wsmouse
271 1.1 takemura */
272 1.1 takemura sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
273 1.6 sato
274 1.6 sato /*
275 1.6 sato * power management events
276 1.6 sato */
277 1.6 sato sc->sc_power_hook = powerhook_establish(vrpiu_power, sc);
278 1.6 sato
279 1.6 sato /*
280 1.6 sato * init A/D port polling.
281 1.6 sato */
282 1.6 sato sc->sc_battery.n_values = 3;
283 1.6 sato sc->sc_battery.value[0] = -1;
284 1.6 sato sc->sc_battery.value[1] = -1;
285 1.6 sato sc->sc_battery.value[2] = -1;
286 1.6 sato sc->sc_battery.nextpoll = hz*vrpiu_ad_poll_interval;
287 1.6 sato callout_init(&sc->sc_adpoll);
288 1.9 takemura callout_reset(&sc->sc_adpoll, hz, vrpiu_start_powerstate, sc);
289 1.1 takemura }
290 1.1 takemura
291 1.8 takemura /*
292 1.8 takemura * calculate interval value
293 1.8 takemura * input: WSMOUSE_RES_MIN - WSMOUSE_RES_MAX
294 1.8 takemura * output: value for PIUSIVL_REG
295 1.8 takemura */
296 1.8 takemura static u_int
297 1.8 takemura scan_interval(u_int data)
298 1.8 takemura {
299 1.8 takemura int scale;
300 1.8 takemura
301 1.8 takemura if (data < WSMOUSE_RES_MIN)
302 1.15 uch data = WSMOUSE_RES_MIN;
303 1.8 takemura
304 1.8 takemura if (WSMOUSE_RES_MAX < data)
305 1.15 uch data = WSMOUSE_RES_MAX;
306 1.8 takemura
307 1.8 takemura scale = WSMOUSE_RES_MAX - WSMOUSE_RES_MIN;
308 1.8 takemura data += WSMOUSE_RES_MIN;
309 1.8 takemura
310 1.8 takemura return PIUSIVL_SCANINTVAL_MIN +
311 1.8 takemura (PIUSIVL_SCANINTVAL_MAX - PIUSIVL_SCANINTVAL_MIN) *
312 1.8 takemura (scale - data) / scale;
313 1.8 takemura }
314 1.8 takemura
315 1.1 takemura int
316 1.15 uch vrpiu_ad_enable(void *v)
317 1.1 takemura {
318 1.1 takemura struct vrpiu_softc *sc = v;
319 1.1 takemura int s;
320 1.1 takemura unsigned int cnt;
321 1.1 takemura
322 1.8 takemura DPRINTF(("%s(%d): vrpiu_ad_enable(): interval=0x%03x\n",
323 1.15 uch __FILE__, __LINE__, sc->sc_interval));
324 1.6 sato if (sc->sc_adstat != VRPIU_AD_STAT_DISABLE)
325 1.15 uch return EBUSY;
326 1.1 takemura
327 1.1 takemura /* supply clock to PIU */
328 1.17 sato __vrcmu_supply(CMUMASK_PIU, 1);
329 1.1 takemura
330 1.8 takemura /* set scan interval */
331 1.8 takemura vrpiu_write(sc, PIUSIVL_REG_W, sc->sc_interval);
332 1.1 takemura
333 1.1 takemura s = spltty();
334 1.1 takemura
335 1.1 takemura /* clear interrupt status */
336 1.8 takemura vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
337 1.1 takemura
338 1.1 takemura /* Disable -> Standby */
339 1.1 takemura cnt = PIUCNT_PIUPWR |
340 1.15 uch PIUCNT_PIUMODE_COORDINATE |
341 1.15 uch PIUCNT_PADATSTART | PIUCNT_PADATSTOP;
342 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, cnt);
343 1.1 takemura
344 1.6 sato /* Level2 interrupt register setting */
345 1.8 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, AD_INTR, 1);
346 1.6 sato
347 1.1 takemura /* save pen status, touch or release */
348 1.1 takemura cnt = vrpiu_read(sc, PIUCNT_REG_W);
349 1.1 takemura
350 1.6 sato /*
351 1.6 sato * Enable scan sequencer operation
352 1.6 sato * Standby -> WaitPenTouch
353 1.6 sato */
354 1.6 sato cnt |= PIUCNT_PIUSEQEN;
355 1.6 sato vrpiu_write(sc, PIUCNT_REG_W, cnt);
356 1.6 sato
357 1.6 sato sc->sc_adstat = VRPIU_AD_STAT_ENABLE;
358 1.6 sato
359 1.6 sato splx(s);
360 1.6 sato
361 1.6 sato return 0;
362 1.6 sato }
363 1.6 sato
364 1.6 sato void
365 1.15 uch vrpiu_ad_disable(void *v)
366 1.6 sato {
367 1.6 sato struct vrpiu_softc *sc = v;
368 1.6 sato
369 1.6 sato DPRINTF(("%s(%d): vrpiu_ad_disable()\n", __FILE__, __LINE__));
370 1.6 sato
371 1.6 sato /* Set level2 interrupt register to mask interrupts */
372 1.8 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, AD_INTR, 0);
373 1.6 sato
374 1.6 sato sc->sc_adstat = VRPIU_AD_STAT_DISABLE;
375 1.6 sato
376 1.6 sato if (sc->sc_tpstat == VRPIU_TP_STAT_DISABLE){
377 1.15 uch /* Disable scan sequencer operation and power off */
378 1.15 uch vrpiu_write(sc, PIUCNT_REG_W, 0);
379 1.6 sato
380 1.15 uch /* mask clock to PIU */
381 1.17 sato __vrcmu_supply(CMUMASK_PIU, 0);
382 1.6 sato }
383 1.6 sato }
384 1.6 sato
385 1.6 sato int
386 1.15 uch vrpiu_tp_enable(void *v)
387 1.6 sato {
388 1.6 sato struct vrpiu_softc *sc = v;
389 1.6 sato int s;
390 1.6 sato unsigned int cnt;
391 1.6 sato
392 1.8 takemura DPRINTF(("%s(%d): vrpiu_tp_enable(): interval=0x%03x\n",
393 1.15 uch __FILE__, __LINE__, sc->sc_interval));
394 1.6 sato if (sc->sc_tpstat != VRPIU_TP_STAT_DISABLE)
395 1.15 uch return EBUSY;
396 1.6 sato
397 1.6 sato /* supply clock to PIU */
398 1.17 sato __vrcmu_supply(CMUMASK_PIU, 1);
399 1.6 sato
400 1.8 takemura /* set scan interval */
401 1.8 takemura vrpiu_write(sc, PIUSIVL_REG_W, sc->sc_interval);
402 1.6 sato
403 1.6 sato s = spltty();
404 1.6 sato
405 1.6 sato /* clear interrupt status */
406 1.8 takemura vrpiu_write(sc, PIUINT_REG_W, TP_INTR);
407 1.6 sato
408 1.6 sato /* Disable -> Standby */
409 1.6 sato cnt = PIUCNT_PIUPWR |
410 1.15 uch PIUCNT_PIUMODE_COORDINATE |
411 1.15 uch PIUCNT_PADATSTART | PIUCNT_PADATSTOP;
412 1.6 sato vrpiu_write(sc, PIUCNT_REG_W, cnt);
413 1.6 sato
414 1.1 takemura /* Level2 interrupt register setting */
415 1.8 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, TP_INTR, 1);
416 1.6 sato
417 1.6 sato /* save pen status, touch or release */
418 1.6 sato cnt = vrpiu_read(sc, PIUCNT_REG_W);
419 1.1 takemura
420 1.1 takemura /*
421 1.1 takemura * Enable scan sequencer operation
422 1.1 takemura * Standby -> WaitPenTouch
423 1.1 takemura */
424 1.1 takemura cnt |= PIUCNT_PIUSEQEN;
425 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, cnt);
426 1.1 takemura
427 1.1 takemura /* transit status DISABLE -> TOUCH or RELEASE */
428 1.6 sato sc->sc_tpstat = (cnt & PIUCNT_PENSTC) ?
429 1.15 uch VRPIU_TP_STAT_TOUCH : VRPIU_TP_STAT_RELEASE;
430 1.1 takemura
431 1.1 takemura splx(s);
432 1.1 takemura
433 1.1 takemura return 0;
434 1.1 takemura }
435 1.1 takemura
436 1.1 takemura void
437 1.15 uch vrpiu_tp_disable(void *v)
438 1.1 takemura {
439 1.1 takemura struct vrpiu_softc *sc = v;
440 1.1 takemura
441 1.6 sato DPRINTF(("%s(%d): vrpiu_tp_disable()\n", __FILE__, __LINE__));
442 1.1 takemura
443 1.1 takemura /* Set level2 interrupt register to mask interrupts */
444 1.8 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, TP_INTR, 0);
445 1.1 takemura
446 1.6 sato sc->sc_tpstat = VRPIU_TP_STAT_DISABLE;
447 1.1 takemura
448 1.6 sato if (sc->sc_adstat == VRPIU_AD_STAT_DISABLE){
449 1.15 uch /* Disable scan sequencer operation and power off */
450 1.15 uch vrpiu_write(sc, PIUCNT_REG_W, 0);
451 1.1 takemura
452 1.15 uch /* mask clock to PIU */
453 1.17 sato __vrcmu_supply(CMUMASK_PIU, 0);
454 1.6 sato }
455 1.1 takemura }
456 1.1 takemura
457 1.1 takemura int
458 1.15 uch vrpiu_tp_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
459 1.1 takemura {
460 1.1 takemura struct vrpiu_softc *sc = v;
461 1.1 takemura
462 1.6 sato DPRINTF(("%s(%d): vrpiu_tp_ioctl(%08lx)\n", __FILE__, __LINE__, cmd));
463 1.1 takemura
464 1.1 takemura switch (cmd) {
465 1.1 takemura case WSMOUSEIO_GTYPE:
466 1.15 uch *(u_int *)data = WSMOUSE_TYPE_TPANEL;
467 1.15 uch break;
468 1.1 takemura
469 1.1 takemura case WSMOUSEIO_SRES:
470 1.15 uch {
471 1.8 takemura int tp_enable;
472 1.8 takemura int ad_enable;
473 1.8 takemura
474 1.8 takemura tp_enable = (sc->sc_tpstat != VRPIU_TP_STAT_DISABLE);
475 1.8 takemura ad_enable = (sc->sc_adstat != VRPIU_AD_STAT_DISABLE);
476 1.8 takemura
477 1.8 takemura if (tp_enable)
478 1.15 uch vrpiu_tp_disable(sc);
479 1.8 takemura if (ad_enable)
480 1.15 uch vrpiu_ad_disable(sc);
481 1.8 takemura
482 1.8 takemura sc->sc_interval = scan_interval(*(u_int *)data);
483 1.8 takemura DPRINTF(("%s(%d): WSMOUSEIO_SRES: *data=%d, interval=0x%03x\n",
484 1.8 takemura __FILE__, __LINE__, *(u_int *)data, sc->sc_interval));
485 1.8 takemura
486 1.8 takemura if (sc->sc_interval < PIUSIVL_SCANINTVAL_MIN)
487 1.15 uch sc->sc_interval = PIUSIVL_SCANINTVAL_MIN;
488 1.8 takemura
489 1.8 takemura if (PIUSIVL_SCANINTVAL_MAX < sc->sc_interval)
490 1.15 uch sc->sc_interval = PIUSIVL_SCANINTVAL_MAX;
491 1.8 takemura
492 1.8 takemura if (tp_enable)
493 1.15 uch vrpiu_tp_enable(sc);
494 1.8 takemura if (ad_enable)
495 1.15 uch vrpiu_ad_enable(sc);
496 1.15 uch }
497 1.15 uch break;
498 1.3 takemura
499 1.3 takemura case WSMOUSEIO_SCALIBCOORDS:
500 1.3 takemura case WSMOUSEIO_GCALIBCOORDS:
501 1.15 uch return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, p);
502 1.1 takemura
503 1.1 takemura default:
504 1.15 uch return (-1);
505 1.1 takemura }
506 1.1 takemura return (0);
507 1.1 takemura }
508 1.1 takemura
509 1.1 takemura /*
510 1.6 sato * PIU AD interrupt handler.
511 1.6 sato */
512 1.6 sato void
513 1.15 uch vrpiu_ad_intr(struct vrpiu_softc *sc)
514 1.6 sato {
515 1.6 sato unsigned int i;
516 1.6 sato unsigned int intrstat;
517 1.6 sato
518 1.6 sato intrstat = vrpiu_read(sc, PIUINT_REG_W);
519 1.6 sato
520 1.6 sato if (sc->sc_adstat == VRPIU_AD_STAT_DISABLE) {
521 1.15 uch /*
522 1.15 uch * the device isn't enabled. just clear interrupt.
523 1.15 uch */
524 1.15 uch vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
525 1.15 uch return;
526 1.6 sato }
527 1.6 sato
528 1.6 sato if (intrstat & PIUINT_PADADPINTR) {
529 1.15 uch sc->sc_battery.value[0] = (unsigned int)
530 1.15 uch vrpiu_read(sc, PIUAB(0));
531 1.15 uch sc->sc_battery.value[1] = (unsigned int)
532 1.15 uch vrpiu_read(sc, PIUAB(1));
533 1.15 uch sc->sc_battery.value[2] = (unsigned int)
534 1.15 uch vrpiu_read(sc, PIUAB(2));
535 1.6 sato }
536 1.6 sato
537 1.6 sato if (intrstat & PIUINT_PADADPINTR) {
538 1.15 uch for (i = 0; i < 3; i++) {
539 1.15 uch if (sc->sc_battery.value[i] & PIUAB_VALID)
540 1.15 uch sc->sc_battery.value[i] &= PIUAB_PADDATA_MASK;
541 1.15 uch else
542 1.15 uch sc->sc_battery.value[i] = 0;
543 1.15 uch }
544 1.15 uch vrpiu_calc_powerstate(sc);
545 1.6 sato }
546 1.8 takemura vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
547 1.6 sato
548 1.6 sato return;
549 1.6 sato }
550 1.6 sato /*
551 1.6 sato * PIU TP interrupt handler.
552 1.1 takemura */
553 1.6 sato void
554 1.15 uch vrpiu_tp_intr(struct vrpiu_softc *sc)
555 1.1 takemura {
556 1.1 takemura unsigned int cnt, i;
557 1.1 takemura unsigned int intrstat, page;
558 1.1 takemura int tpx0, tpx1, tpy0, tpy1;
559 1.1 takemura int x, y, xraw, yraw;
560 1.1 takemura
561 1.1 takemura intrstat = vrpiu_read(sc, PIUINT_REG_W);
562 1.1 takemura
563 1.6 sato if (sc->sc_tpstat == VRPIU_TP_STAT_DISABLE) {
564 1.15 uch /*
565 1.15 uch * the device isn't enabled. just clear interrupt.
566 1.15 uch */
567 1.15 uch vrpiu_write(sc, PIUINT_REG_W, intrstat & TP_INTR);
568 1.15 uch return;
569 1.1 takemura }
570 1.1 takemura
571 1.1 takemura page = (intrstat & PIUINT_OVP) ? 1 : 0;
572 1.1 takemura if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
573 1.15 uch tpx0 = vrpiu_read(sc, PIUPB(page, 0));
574 1.15 uch tpx1 = vrpiu_read(sc, PIUPB(page, 1));
575 1.15 uch tpy0 = vrpiu_read(sc, PIUPB(page, 2));
576 1.15 uch tpy1 = vrpiu_read(sc, PIUPB(page, 3));
577 1.1 takemura }
578 1.1 takemura
579 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR) {
580 1.15 uch page = page ? 0 : 1;
581 1.15 uch for (i = 0; i < 4; i++)
582 1.15 uch vrpiu_read(sc, PIUPB(page, i));
583 1.1 takemura }
584 1.1 takemura
585 1.1 takemura cnt = vrpiu_read(sc, PIUCNT_REG_W);
586 1.1 takemura #ifdef DEBUG
587 1.1 takemura if (vrpiu_debug)
588 1.15 uch vrpiu_dump_cntreg(cnt);
589 1.1 takemura #endif
590 1.1 takemura
591 1.1 takemura /* clear interrupt status */
592 1.8 takemura vrpiu_write(sc, PIUINT_REG_W, intrstat & TP_INTR);
593 1.1 takemura
594 1.1 takemura #if 0
595 1.1 takemura DPRINTF(("vrpiu_intr: OVP=%d", page));
596 1.1 takemura if (intrstat & PIUINT_PADCMDINTR)
597 1.15 uch DPRINTF((" CMD"));
598 1.1 takemura if (intrstat & PIUINT_PADADPINTR)
599 1.15 uch DPRINTF((" A/D"));
600 1.1 takemura if (intrstat & PIUINT_PADPAGE1INTR)
601 1.15 uch DPRINTF((" PAGE1"));
602 1.1 takemura if (intrstat & PIUINT_PADPAGE0INTR)
603 1.15 uch DPRINTF((" PAGE0"));
604 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR)
605 1.15 uch DPRINTF((" DLOST"));
606 1.1 takemura if (intrstat & PIUINT_PENCHGINTR)
607 1.15 uch DPRINTF((" PENCHG"));
608 1.1 takemura DPRINTF(("\n"));
609 1.1 takemura #endif
610 1.1 takemura if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
611 1.15 uch /*
612 1.15 uch * just ignore scan data if status isn't Touch.
613 1.15 uch */
614 1.15 uch if (sc->sc_tpstat == VRPIU_TP_STAT_TOUCH) {
615 1.15 uch /* reset tp scan timeout */
616 1.15 uch callout_reset(&sc->sc_tptimeout, VRPIU_TP_SCAN_TIMEOUT,
617 1.15 uch vrpiu_tp_timeout, sc);
618 1.15 uch
619 1.15 uch if (!((tpx0 & PIUPB_VALID) && (tpx1 & PIUPB_VALID) &&
620 1.15 uch (tpy0 & PIUPB_VALID) && (tpy1 & PIUPB_VALID))) {
621 1.15 uch printf("vrpiu: internal error,"
622 1.15 uch " data is not valid!\n");
623 1.15 uch } else {
624 1.15 uch tpx0 &= PIUPB_PADDATA_MASK;
625 1.15 uch tpx1 &= PIUPB_PADDATA_MASK;
626 1.15 uch tpy0 &= PIUPB_PADDATA_MASK;
627 1.15 uch tpy1 &= PIUPB_PADDATA_MASK;
628 1.1 takemura #define ISVALID(n, c, m) ((c) - (m) < (n) && (n) < (c) + (m))
629 1.15 uch if (ISVALID(tpx0 + tpx1, 1024, 200) &&
630 1.15 uch ISVALID(tpy0 + tpy1, 1024, 200)) {
631 1.1 takemura #if 0
632 1.15 uch DPRINTF(("%04x %04x %04x %04x\n",
633 1.15 uch tpx0, tpx1, tpy0, tpy1));
634 1.15 uch DPRINTF(("%3d %3d (%4d %4d)->", tpx0,
635 1.15 uch tpy0, tpx0 + tpx1, tpy0 + tpy1));
636 1.1 takemura #endif
637 1.15 uch xraw = tpy1 * 1024 / (tpy0 + tpy1);
638 1.15 uch yraw = tpx1 * 1024 / (tpx0 + tpx1);
639 1.15 uch DPRINTF(("%3d %3d", xraw, yraw));
640 1.15 uch
641 1.15 uch tpcalib_trans(&sc->sc_tpcalib, xraw,
642 1.15 uch yraw, &x, &y);
643 1.15 uch
644 1.15 uch DPRINTF(("->%4d %4d", x, y));
645 1.15 uch wsmouse_input(sc->sc_wsmousedev,
646 1.15 uch 1, /* button 0 down */
647 1.15 uch x, /* x */
648 1.15 uch y, /* y */
649 1.15 uch 0, /* z */
650 1.15 uch WSMOUSE_INPUT_ABSOLUTE_X |
651 1.15 uch WSMOUSE_INPUT_ABSOLUTE_Y);
652 1.15 uch DPRINTF(("\n"));
653 1.15 uch }
654 1.15 uch }
655 1.4 takemura }
656 1.4 takemura }
657 1.4 takemura
658 1.4 takemura if (cnt & PIUCNT_PENSTC) {
659 1.15 uch if (sc->sc_tpstat == VRPIU_TP_STAT_RELEASE) {
660 1.15 uch /*
661 1.15 uch * pen touch
662 1.15 uch */
663 1.15 uch DPRINTF(("PEN TOUCH\n"));
664 1.15 uch sc->sc_tpstat = VRPIU_TP_STAT_TOUCH;
665 1.15 uch /*
666 1.15 uch * We should not report button down event while
667 1.15 uch * we don't know where it occur.
668 1.15 uch */
669 1.15 uch
670 1.15 uch /* set tp scan timeout */
671 1.15 uch callout_reset(&sc->sc_tptimeout, VRPIU_TP_SCAN_TIMEOUT,
672 1.15 uch vrpiu_tp_timeout, sc);
673 1.15 uch }
674 1.4 takemura } else {
675 1.15 uch vrpiu_tp_up(sc);
676 1.1 takemura }
677 1.1 takemura
678 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR) {
679 1.15 uch cnt |= PIUCNT_PIUSEQEN;
680 1.15 uch vrpiu_write(sc, PIUCNT_REG_W, cnt);
681 1.1 takemura }
682 1.1 takemura
683 1.6 sato return;
684 1.10 takemura }
685 1.10 takemura
686 1.10 takemura void
687 1.15 uch vrpiu_tp_up(struct vrpiu_softc *sc)
688 1.10 takemura {
689 1.10 takemura if (sc->sc_tpstat == VRPIU_TP_STAT_TOUCH) {
690 1.15 uch /*
691 1.15 uch * pen release
692 1.15 uch */
693 1.15 uch DPRINTF(("RELEASE\n"));
694 1.15 uch sc->sc_tpstat = VRPIU_TP_STAT_RELEASE;
695 1.10 takemura
696 1.15 uch /* clear tp scan timeout */
697 1.15 uch callout_stop(&sc->sc_tptimeout);
698 1.10 takemura
699 1.15 uch /* button 0 UP */
700 1.15 uch wsmouse_input(sc->sc_wsmousedev, 0, 0, 0, 0, 0);
701 1.10 takemura }
702 1.10 takemura }
703 1.10 takemura
704 1.10 takemura /* touch panel timeout handler */
705 1.10 takemura void
706 1.15 uch vrpiu_tp_timeout(void *v)
707 1.10 takemura {
708 1.10 takemura struct vrpiu_softc *sc = (struct vrpiu_softc *)v;
709 1.10 takemura
710 1.10 takemura #ifdef VRPIUDEBUG
711 1.10 takemura {
712 1.15 uch unsigned int cnt = vrpiu_read(sc, PIUCNT_REG_W);
713 1.15 uch DPRINTF(("TIMEOUT: stat=%s reg=%s\n",
714 1.15 uch (sc->sc_tpstat == VRPIU_TP_STAT_TOUCH)?"touch":"release",
715 1.15 uch (cnt & PIUCNT_PENSTC)?"touch":"release"));
716 1.10 takemura }
717 1.10 takemura #endif
718 1.10 takemura vrpiu_tp_up(sc);
719 1.6 sato }
720 1.6 sato
721 1.6 sato /*
722 1.6 sato * PIU interrupt handler.
723 1.6 sato */
724 1.6 sato int
725 1.15 uch vrpiu_intr(void *arg)
726 1.6 sato {
727 1.6 sato struct vrpiu_softc *sc = arg;
728 1.6 sato
729 1.6 sato vrpiu_ad_intr(sc);
730 1.6 sato vrpiu_tp_intr(sc);
731 1.6 sato
732 1.1 takemura return 0;
733 1.6 sato }
734 1.6 sato
735 1.6 sato void
736 1.15 uch vrpiu_start_powerstate(void *v)
737 1.6 sato {
738 1.6 sato int mask;
739 1.6 sato struct vrpiu_softc *sc = (struct vrpiu_softc *)v;
740 1.6 sato
741 1.6 sato vrpiu_ad_enable(sc);
742 1.6 sato mask = vrpiu_read(sc, PIUAMSK_REG_W);
743 1.6 sato mask &= 0xff8f; /* XXX */
744 1.6 sato vrpiu_write(sc, PIUAMSK_REG_W, mask);
745 1.6 sato vrpiu_write(sc, PIUASCN_REG_W, PIUACN_ADPSSTART);
746 1.6 sato /*
747 1.6 sato * restart next A/D polling
748 1.6 sato */
749 1.6 sato callout_reset(&sc->sc_adpoll, hz*vrpiu_ad_poll_interval,
750 1.15 uch vrpiu_start_powerstate, sc);
751 1.6 sato }
752 1.6 sato
753 1.6 sato void
754 1.15 uch vrpiu_calc_powerstate(struct vrpiu_softc *sc)
755 1.6 sato {
756 1.15 uch extern void vrgiu_diff_io(void);
757 1.6 sato vrpiu_ad_disable(sc);
758 1.6 sato VPRINTF(("vrpiu:AD: %d, %d, %d\n",
759 1.15 uch sc->sc_battery.value[0],
760 1.15 uch sc->sc_battery.value[1],
761 1.15 uch sc->sc_battery.value[2]));
762 1.6 sato sc->sc_battery.nextpoll = hz*vrpiu_ad_poll_interval;
763 1.14 sato vrpiu_send_battery_event(sc);
764 1.6 sato /*
765 1.6 sato * restart next A/D polling if change polling timming.
766 1.6 sato */
767 1.6 sato if (sc->sc_battery.nextpoll != hz*vrpiu_ad_poll_interval)
768 1.15 uch callout_reset(&sc->sc_adpoll, sc->sc_battery.nextpoll,
769 1.15 uch vrpiu_start_powerstate, sc);
770 1.6 sato if (bootverbose)
771 1.15 uch vrgiu_diff_io();
772 1.6 sato
773 1.6 sato }
774 1.6 sato
775 1.6 sato static void
776 1.15 uch vrpiu_power(int why, void *arg)
777 1.6 sato {
778 1.6 sato struct vrpiu_softc *sc = arg;
779 1.6 sato
780 1.6 sato switch (why) {
781 1.6 sato case PWR_STANDBY:
782 1.6 sato case PWR_SUSPEND:
783 1.15 uch break;
784 1.6 sato case PWR_RESUME:
785 1.15 uch callout_reset(&sc->sc_adpoll, hz,
786 1.15 uch vrpiu_start_powerstate, sc);
787 1.15 uch break;
788 1.6 sato }
789 1.14 sato }
790 1.14 sato
791 1.14 sato static void
792 1.15 uch vrpiu_send_battery_event(struct vrpiu_softc *sc)
793 1.14 sato {
794 1.14 sato #ifdef VRPIU_ADHOC_BATTERY_EVENT
795 1.14 sato static int batteryhigh = 0;
796 1.14 sato static int batterylow = 0;
797 1.14 sato static int critical = 0;
798 1.14 sato
799 1.14 sato if (sc->sc_battery_spec == NULL
800 1.15 uch || sc->sc_battery_spec->main_port == -1)
801 1.14 sato return;
802 1.14 sato
803 1.14 sato if (sc->sc_battery.value[sc->sc_battery_spec->main_port]
804 1.15 uch <= sc->sc_battery_spec->dc_critical) {
805 1.15 uch batteryhigh = 0;
806 1.15 uch config_hook_call(CONFIG_HOOK_PMEVENT,
807 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
808 1.15 uch (void *)CONFIG_HOOK_BATT_CRITICAL);
809 1.15 uch batterylow = 3;
810 1.15 uch if (critical) {
811 1.14 sato config_hook_call(CONFIG_HOOK_PMEVENT,
812 1.15 uch CONFIG_HOOK_PMEVENT_SUSPENDREQ,
813 1.15 uch (void *)0);
814 1.15 uch critical = 0;
815 1.15 uch batterylow = 0;
816 1.15 uch }
817 1.15 uch critical++;
818 1.14 sato } else if (sc->sc_battery.value[sc->sc_battery_spec->main_port]
819 1.15 uch <= sc->sc_battery_spec->dc_20p) {
820 1.15 uch batteryhigh = 0;
821 1.15 uch if (batterylow == 1)
822 1.14 sato config_hook_call(CONFIG_HOOK_PMEVENT,
823 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
824 1.15 uch (void *)CONFIG_HOOK_BATT_20P);
825 1.15 uch config_hook_call(CONFIG_HOOK_PMEVENT,
826 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
827 1.15 uch (void *)CONFIG_HOOK_BATT_LOW);
828 1.15 uch batterylow = 2;
829 1.14 sato } else if (sc->sc_battery.value[sc->sc_battery_spec->main_port]
830 1.15 uch <= sc->sc_battery_spec->dc_50p) {
831 1.15 uch batteryhigh = 0;
832 1.15 uch if (batterylow == 0) {
833 1.15 uch batterylow = 1;
834 1.15 uch config_hook_call(CONFIG_HOOK_PMEVENT,
835 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
836 1.15 uch (void *)CONFIG_HOOK_BATT_50P);
837 1.15 uch }
838 1.14 sato } else if (sc->sc_battery.value[sc->sc_battery_spec->main_port]
839 1.15 uch >= sc->sc_battery_spec->ac_80p) {
840 1.15 uch batterylow = 0;
841 1.15 uch if (batteryhigh == 0) {
842 1.15 uch batteryhigh = 1;
843 1.15 uch config_hook_call(CONFIG_HOOK_PMEVENT,
844 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
845 1.15 uch (void *)CONFIG_HOOK_BATT_80P);
846 1.15 uch config_hook_call(CONFIG_HOOK_PMEVENT,
847 1.15 uch CONFIG_HOOK_PMEVENT_BATTERY,
848 1.15 uch (void *)CONFIG_HOOK_BATT_HIGH);
849 1.15 uch }
850 1.14 sato }
851 1.14 sato #else /* VRPIU_ADHOC_BATTERY_EVENT */
852 1.14 sato config_hook_call(CONFIG_HOOK_SET,
853 1.15 uch CONFIG_HOOK_BATTERYVAL,
854 1.15 uch (void *)&sc->sc_battery);
855 1.14 sato #endif /* VRPIU_ADHOC_BATTERY_EVENT */
856 1.1 takemura }
857 1.1 takemura
858 1.1 takemura #ifdef DEBUG
859 1.1 takemura void
860 1.15 uch vrpiu_dump_cntreg(unsigned int cnt)
861 1.1 takemura {
862 1.1 takemura printf("%s", (cnt & PIUCNT_PENSTC) ? "Touch" : "Release");
863 1.1 takemura printf(" state=");
864 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_CmdScan)
865 1.15 uch printf("CmdScan");
866 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_IntervalNextScan)
867 1.15 uch printf("IntervalNextScan");
868 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_PenDataScan)
869 1.15 uch printf("PenDataScan");
870 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_WaitPenTouch)
871 1.15 uch printf("WaitPenTouch");
872 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_RFU)
873 1.15 uch printf("???");
874 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_ADPortScan)
875 1.15 uch printf("ADPortScan");
876 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Standby)
877 1.15 uch printf("Standby");
878 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Disable)
879 1.15 uch printf("Disable");
880 1.1 takemura if (cnt & PIUCNT_PADATSTOP)
881 1.15 uch printf(" AutoStop");
882 1.1 takemura if (cnt & PIUCNT_PADATSTART)
883 1.15 uch printf(" AutoStart");
884 1.1 takemura if (cnt & PIUCNT_PADSCANSTOP)
885 1.15 uch printf(" Stop");
886 1.1 takemura if (cnt & PIUCNT_PADSCANSTART)
887 1.15 uch printf(" Start");
888 1.1 takemura if (cnt & PIUCNT_PADSCANTYPE)
889 1.15 uch printf(" ScanPressure");
890 1.1 takemura if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_ADCONVERTER)
891 1.15 uch printf(" A/D");
892 1.1 takemura if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_COORDINATE)
893 1.15 uch printf(" Coordinate");
894 1.1 takemura if (cnt & PIUCNT_PIUSEQEN)
895 1.15 uch printf(" SeqEn");
896 1.1 takemura if ((cnt & PIUCNT_PIUPWR) == 0)
897 1.15 uch printf(" PowerOff");
898 1.1 takemura if ((cnt & PIUCNT_PADRST) == 0)
899 1.15 uch printf(" Reset");
900 1.1 takemura printf("\n");
901 1.1 takemura }
902 1.1 takemura #endif
903