itesio_isa.c revision 1.16 1 /* $NetBSD: itesio_isa.c,v 1.16 2008/04/26 12:59:24 xtraeme Exp $ */
2 /* Derived from $OpenBSD: it.c,v 1.19 2006/04/10 00:57:54 deraadt Exp $ */
3
4 /*
5 * Copyright (c) 2006-2007 Juan Romero Pardines <xtraeme (at) netbsd.org>
6 * Copyright (c) 2003 Julien Bordet <zejames (at) greyhats.org>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITD TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITD TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31 * Driver for the iTE IT87xxF Super I/O. Currently supporting
32 * the Environmental Controller to monitor the sensors and the
33 * Watchdog Timer.
34 */
35
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.16 2008/04/26 12:59:24 xtraeme Exp $");
38
39 #include <sys/param.h>
40 #include <sys/kernel.h>
41 #include <sys/device.h>
42
43 #include <sys/bus.h>
44
45 #include <dev/isa/isareg.h>
46 #include <dev/isa/isavar.h>
47
48 #include <dev/sysmon/sysmonvar.h>
49
50 #include <dev/isa/itesio_isavar.h>
51
52 #define IT_VOLTSTART_IDX 3 /* voltage start index */
53 #define IT_FANSTART_IDX 12 /* fan start index */
54
55 #if defined(ITESIO_DEBUG)
56 #define DPRINTF(x) do { printf x; } while (0)
57 #else
58 #define DPRINTF(x)
59 #endif
60
61 /*
62 * IT87-compatible chips can typically measure voltages up to 4.096 V.
63 * To measure higher voltages the input is attenuated with (external)
64 * resistors. Negative voltages are measured using a reference
65 * voltage. So we have to convert the sensor values back to real
66 * voltages by applying the appropriate resistor factor.
67 */
68 #define RFACT_NONE 10000
69 #define RFACT(x, y) (RFACT_NONE * ((x) + (y)) / (y))
70
71 /* autoconf(9) functions */
72 static int itesio_isa_match(device_t, cfdata_t, void *);
73 static void itesio_isa_attach(device_t, device_t, void *);
74 static int itesio_isa_detach(device_t, int);
75
76 CFATTACH_DECL_NEW(itesio, sizeof(struct itesio_softc),
77 itesio_isa_match, itesio_isa_attach, itesio_isa_detach, NULL);
78
79 /* driver functions */
80 static uint8_t itesio_ecreadreg(struct itesio_softc *, int);
81 static void itesio_ecwritereg(struct itesio_softc *, int, int);
82 static uint8_t itesio_readreg(bus_space_tag_t, bus_space_handle_t, int);
83 static void itesio_writereg(bus_space_tag_t, bus_space_handle_t, int, int);
84 static void itesio_enter(bus_space_tag_t, bus_space_handle_t);
85 static void itesio_exit(bus_space_tag_t, bus_space_handle_t);
86
87 /* sysmon_envsys(9) glue */
88 static void itesio_setup_sensors(struct itesio_softc *);
89 static void itesio_refresh_temp(struct itesio_softc *, envsys_data_t *);
90 static void itesio_refresh_volts(struct itesio_softc *, envsys_data_t *);
91 static void itesio_refresh_fans(struct itesio_softc *, envsys_data_t *);
92 static void itesio_refresh(struct sysmon_envsys *, envsys_data_t *);
93
94 /* sysmon_wdog glue */
95 static int itesio_wdt_setmode(struct sysmon_wdog *);
96 static int itesio_wdt_tickle(struct sysmon_wdog *);
97
98 /* rfact values for voltage sensors */
99 static const int itesio_vrfact[] = {
100 RFACT_NONE, /* VCORE_A */
101 RFACT_NONE, /* VCORE_B */
102 RFACT_NONE, /* +3.3V */
103 RFACT(68, 100), /* +5V */
104 RFACT(30, 10), /* +12V */
105 RFACT(21, 10), /* -5V */
106 RFACT(83, 20), /* -12V */
107 RFACT(68, 100), /* STANDBY */
108 RFACT_NONE /* VBAT */
109 };
110
111 static int
112 itesio_isa_match(device_t parent, cfdata_t match, void *aux)
113 {
114 struct isa_attach_args *ia = aux;
115 bus_space_handle_t ioh;
116 uint16_t cr;
117
118 /* Must supply an address */
119 if (ia->ia_nio < 1)
120 return 0;
121
122 if (ISA_DIRECT_CONFIG(ia))
123 return 0;
124
125 if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
126 return 0;
127
128 if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 2, 0, &ioh))
129 return 0;
130
131 itesio_enter(ia->ia_iot, ioh);
132 cr = (itesio_readreg(ia->ia_iot, ioh, ITESIO_CHIPID1) << 8);
133 cr |= itesio_readreg(ia->ia_iot, ioh, ITESIO_CHIPID2);
134 itesio_exit(ia->ia_iot, ioh);
135 bus_space_unmap(ia->ia_iot, ioh, 2);
136
137 switch (cr) {
138 case ITESIO_ID8705:
139 case ITESIO_ID8712:
140 case ITESIO_ID8716:
141 case ITESIO_ID8718:
142 ia->ia_nio = 1;
143 ia->ia_io[0].ir_size = 2;
144 ia->ia_niomem = 0;
145 ia->ia_nirq = 0;
146 ia->ia_ndrq = 0;
147 return 1;
148 default:
149 return 0;
150 }
151 }
152
153 static void
154 itesio_isa_attach(device_t parent, device_t self, void *aux)
155 {
156 struct itesio_softc *sc = device_private(self);
157 struct isa_attach_args *ia = aux;
158 int i;
159 uint8_t cr;
160
161 sc->sc_iot = ia->ia_iot;
162
163 if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 2, 0,
164 &sc->sc_ioh)) {
165 aprint_error(": can't map i/o space\n");
166 return;
167 }
168
169 aprint_naive("\n");
170
171 /*
172 * Enter to the Super I/O MB PNP mode.
173 */
174 itesio_enter(sc->sc_iot, sc->sc_ioh);
175 /*
176 * Get info from the Super I/O Global Configuration Registers:
177 * Chip IDs and Device Revision.
178 */
179 sc->sc_chipid = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
180 ITESIO_CHIPID1) << 8);
181 sc->sc_chipid |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
182 ITESIO_CHIPID2);
183 sc->sc_devrev = (itesio_readreg(sc->sc_iot, sc->sc_ioh,
184 ITESIO_DEVREV) & 0x0f);
185 /*
186 * Select the EC LDN to get the Base Address.
187 */
188 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_EC_LDN);
189 sc->sc_hwmon_baseaddr =
190 (itesio_readreg(sc->sc_iot, sc->sc_ioh, ITESIO_EC_MSB) << 8);
191 sc->sc_hwmon_baseaddr |= itesio_readreg(sc->sc_iot, sc->sc_ioh,
192 ITESIO_EC_LSB);
193 /*
194 * We are done, exit MB PNP mode.
195 */
196 itesio_exit(sc->sc_iot, sc->sc_ioh);
197
198 aprint_normal(": iTE IT%4xF Super I/O (rev %d)\n",
199 sc->sc_chipid, sc->sc_devrev);
200 aprint_normal_dev(self, "Hardware Monitor registers at 0x%x\n",
201 sc->sc_hwmon_baseaddr);
202
203 if (bus_space_map(sc->sc_ec_iot, sc->sc_hwmon_baseaddr, 8, 0,
204 &sc->sc_ec_ioh)) {
205 aprint_error_dev(self, "cannot map hwmon i/o space\n");
206 goto out2;
207 }
208
209 sc->sc_hwmon_mapped = true;
210
211 /* Activate monitoring */
212 cr = itesio_ecreadreg(sc, ITESIO_EC_CONFIG);
213 SET(cr, 0x01);
214 itesio_ecwritereg(sc, ITESIO_EC_CONFIG, cr);
215
216 #ifdef notyet
217 /* Enable beep alarms */
218 cr = itesio_ecreadreg(sc, ITESIO_EC_BEEPEER);
219 SET(cr, 0x02); /* Voltage exceeds limit */
220 SET(cr, 0x04); /* Temperature exceeds limit */
221 itesio_ecwritereg(sc, ITESIO_EC_BEEPEER, cr);
222 #endif
223
224 /*
225 * Initialize and attach sensors.
226 */
227 itesio_setup_sensors(sc);
228 sc->sc_sme = sysmon_envsys_create();
229 for (i = 0; i < IT_NUM_SENSORS; i++) {
230 if (sysmon_envsys_sensor_attach(sc->sc_sme,
231 &sc->sc_sensor[i])) {
232 sysmon_envsys_destroy(sc->sc_sme);
233 goto out;
234 }
235 }
236 /*
237 * Hook into the system monitor.
238 */
239 sc->sc_sme->sme_name = device_xname(self);
240 sc->sc_sme->sme_cookie = sc;
241 sc->sc_sme->sme_refresh = itesio_refresh;
242
243 if ((i = sysmon_envsys_register(sc->sc_sme))) {
244 aprint_error_dev(self,
245 "unable to register with sysmon (%d)\n", i);
246 sysmon_envsys_destroy(sc->sc_sme);
247 goto out;
248 }
249 sc->sc_hwmon_enabled = true;
250
251 if (!pmf_device_register(self, NULL, NULL))
252 aprint_error_dev(self, "couldn't establish power handler\n");
253
254 /* The IT8705 doesn't support the WDT */
255 if (sc->sc_chipid == ITESIO_ID8705)
256 goto out2;
257
258 /*
259 * Initialize the watchdog timer.
260 */
261 sc->sc_smw.smw_name = device_xname(self);
262 sc->sc_smw.smw_cookie = sc;
263 sc->sc_smw.smw_setmode = itesio_wdt_setmode;
264 sc->sc_smw.smw_tickle = itesio_wdt_tickle;
265 sc->sc_smw.smw_period = 60;
266
267 if (sysmon_wdog_register(&sc->sc_smw)) {
268 aprint_error_dev(self, "unable to register watchdog timer\n");
269 goto out2;
270 }
271 sc->sc_wdt_enabled = true;
272 aprint_normal_dev(self, "Watchdog Timer present\n");
273 return;
274
275 out:
276 bus_space_unmap(sc->sc_ec_iot, sc->sc_ec_ioh, 8);
277 out2:
278 bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
279 }
280
281 static int
282 itesio_isa_detach(device_t self, int flags)
283 {
284 struct itesio_softc *sc = device_private(self);
285
286 if (sc->sc_hwmon_enabled)
287 sysmon_envsys_unregister(sc->sc_sme);
288 if (sc->sc_hwmon_mapped)
289 bus_space_unmap(sc->sc_ec_iot, sc->sc_ec_ioh, 8);
290 if (sc->sc_wdt_enabled) {
291 sysmon_wdog_unregister(&sc->sc_smw);
292 bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
293 }
294
295 return 0;
296 }
297
298 /*
299 * Functions to read/write to the Environmental Controller.
300 */
301 static uint8_t
302 itesio_ecreadreg(struct itesio_softc *sc, int reg)
303 {
304 bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
305 return bus_space_read_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_DATA);
306 }
307
308 static void
309 itesio_ecwritereg(struct itesio_softc *sc, int reg, int val)
310 {
311 bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_ADDR, reg);
312 bus_space_write_1(sc->sc_ec_iot, sc->sc_ec_ioh, ITESIO_EC_DATA, val);
313 }
314
315 /*
316 * Functions to enter/exit/read/write to the Super I/O.
317 */
318 static uint8_t
319 itesio_readreg(bus_space_tag_t iot, bus_space_handle_t ioh, int reg)
320 {
321 bus_space_write_1(iot, ioh, ITESIO_ADDR, reg);
322 return bus_space_read_1(iot, ioh, ITESIO_DATA);
323 }
324
325 static void
326 itesio_writereg(bus_space_tag_t iot, bus_space_handle_t ioh, int reg, int val)
327 {
328 bus_space_write_1(iot, ioh, ITESIO_ADDR, reg);
329 bus_space_write_1(iot, ioh, ITESIO_DATA, val);
330 }
331
332 static void
333 itesio_enter(bus_space_tag_t iot, bus_space_handle_t ioh)
334 {
335 bus_space_write_1(iot, ioh, ITESIO_ADDR, 0x87);
336 bus_space_write_1(iot, ioh, ITESIO_ADDR, 0x01);
337 bus_space_write_1(iot, ioh, ITESIO_ADDR, 0x55);
338 bus_space_write_1(iot, ioh, ITESIO_ADDR, 0x55);
339 }
340
341 static void
342 itesio_exit(bus_space_tag_t iot, bus_space_handle_t ioh)
343 {
344 bus_space_write_1(iot, ioh, ITESIO_ADDR, 0x02);
345 bus_space_write_1(iot, ioh, ITESIO_DATA, 0x02);
346 }
347
348
349 #define COPYDESCR(x, y) \
350 do { \
351 strlcpy((x), (y), sizeof(x)); \
352 } while (0)
353 /*
354 * sysmon_envsys(9) glue.
355 */
356 static void
357 itesio_setup_sensors(struct itesio_softc *sc)
358 {
359 int i;
360
361 /* temperatures */
362 for (i = 0; i < IT_VOLTSTART_IDX; i++)
363 sc->sc_sensor[i].units = ENVSYS_STEMP;
364
365 COPYDESCR(sc->sc_sensor[0].desc, "CPU Temp");
366 COPYDESCR(sc->sc_sensor[1].desc, "System Temp");
367 COPYDESCR(sc->sc_sensor[2].desc, "Aux Temp");
368
369 /* voltages */
370 for (i = IT_VOLTSTART_IDX; i < IT_FANSTART_IDX; i++) {
371 sc->sc_sensor[i].units = ENVSYS_SVOLTS_DC;
372 sc->sc_sensor[i].flags = ENVSYS_FCHANGERFACT;
373 }
374
375 COPYDESCR(sc->sc_sensor[3].desc, "VCORE_A");
376 COPYDESCR(sc->sc_sensor[4].desc, "VCORE_B");
377 COPYDESCR(sc->sc_sensor[5].desc, "+3.3V");
378 COPYDESCR(sc->sc_sensor[6].desc, "+5V");
379 COPYDESCR(sc->sc_sensor[7].desc, "+12V");
380 COPYDESCR(sc->sc_sensor[8].desc, "-5V");
381 COPYDESCR(sc->sc_sensor[9].desc, "-12V");
382 COPYDESCR(sc->sc_sensor[10].desc, "STANDBY");
383 COPYDESCR(sc->sc_sensor[11].desc, "VBAT");
384
385 /* fans */
386 for (i = IT_FANSTART_IDX; i < IT_NUM_SENSORS; i++)
387 sc->sc_sensor[i].units = ENVSYS_SFANRPM;
388
389 COPYDESCR(sc->sc_sensor[12].desc, "CPU Fan");
390 COPYDESCR(sc->sc_sensor[13].desc, "System Fan");
391 COPYDESCR(sc->sc_sensor[14].desc, "Aux Fan");
392 }
393 #undef COPYDESCR
394
395 static void
396 itesio_refresh_temp(struct itesio_softc *sc, envsys_data_t *edata)
397 {
398 int sdata;
399
400 sdata = itesio_ecreadreg(sc, ITESIO_EC_SENSORTEMPBASE + edata->sensor);
401 /* sensor is not connected or reporting invalid data */
402 if (sdata == 0 || sdata >= 0xfa) {
403 edata->state = ENVSYS_SINVALID;
404 return;
405 }
406
407 DPRINTF(("%s: sdata[temp%d] 0x%x\n", __func__, edata->sensor, sdata));
408 /* Convert temperature to uK */
409 edata->value_cur = sdata * 1000000 + 273150000;
410 edata->state = ENVSYS_SVALID;
411 }
412
413 static void
414 itesio_refresh_volts(struct itesio_softc *sc, envsys_data_t *edata)
415 {
416 uint8_t vbatcr = 0;
417 int i, sdata;
418
419 i = edata->sensor - IT_VOLTSTART_IDX;
420
421 sdata = itesio_ecreadreg(sc, ITESIO_EC_SENSORVOLTBASE + i);
422 /* not connected */
423 if (sdata == 0 || sdata == 0xff) {
424 edata->state = ENVSYS_SINVALID;
425 return;
426 }
427
428 /*
429 * update VBAT voltage reading every time we read it, to get
430 * latest value.
431 */
432 if (i == 8) {
433 vbatcr = itesio_ecreadreg(sc, ITESIO_EC_CONFIG);
434 SET(vbatcr, ITESIO_EC_UPDATEVBAT);
435 itesio_ecwritereg(sc, ITESIO_EC_CONFIG, vbatcr);
436 }
437
438 DPRINTF(("%s: sdata[volt%d] 0x%x\n", __func__, i, sdata));
439
440 /* voltage returned as (mV << 4) */
441 edata->value_cur = (sdata << 4);
442 /* negative values */
443 if (i == 5 || i == 6)
444 edata->value_cur -= ITESIO_EC_VREF;
445 /* rfact is (factor * 10^4) */
446 edata->value_cur *= itesio_vrfact[i];
447 if (edata->rfact)
448 edata->value_cur += edata->rfact;
449 /* division by 10 gets us back to uVDC */
450 edata->value_cur /= 10;
451 if (i == 5 || i == 6)
452 edata->value_cur += ITESIO_EC_VREF * 1000;
453
454 edata->state = ENVSYS_SVALID;
455 }
456
457 static void
458 itesio_refresh_fans(struct itesio_softc *sc, envsys_data_t *edata)
459 {
460 uint8_t mode = 0;
461 uint16_t sdata = 0;
462 int i, divisor, odivisor, ndivisor;
463
464 i = edata->sensor - IT_FANSTART_IDX;
465 divisor = odivisor = ndivisor = 0;
466
467 if (sc->sc_chipid == ITESIO_ID8705 || sc->sc_chipid == ITESIO_ID8712) {
468 /*
469 * Use the Fan Tachometer Divisor Register for
470 * IT8705F and IT8712F.
471 */
472 divisor = odivisor = ndivisor =
473 itesio_ecreadreg(sc, ITESIO_EC_FAN_TDR);
474 sdata = itesio_ecreadreg(sc, ITESIO_EC_SENSORFANBASE + i);
475 if (sdata == 0xff) {
476 edata->state = ENVSYS_SINVALID;
477 if (i == 2)
478 ndivisor |= 0x40;
479 else {
480 ndivisor &= ~(7 << (i * 3));
481 ndivisor |= ((divisor + 1) & 7) << (i * 3);
482 }
483 } else {
484 if (i == 2)
485 divisor = divisor & 1 ? 3 : 1;
486
487 if ((sdata << (divisor & 7)) == 0)
488 edata->state = ENVSYS_SINVALID;
489 else {
490 edata->value_cur =
491 1350000 / (sdata << (divisor & 7));
492 edata->state = ENVSYS_SVALID;
493 }
494 }
495 DPRINTF(("%s: 8bit sdata[fan%d] 0x%x div: 0x%x\n", __func__,
496 i, sdata, divisor));
497 if (ndivisor != odivisor)
498 itesio_ecwritereg(sc, ITESIO_EC_FAN_TDR, ndivisor);
499 } else {
500 mode = itesio_ecreadreg(sc, ITESIO_EC_FAN16_CER);
501 sdata = itesio_ecreadreg(sc, ITESIO_EC_SENSORFANBASE + i);
502 if (mode & (1 << i))
503 sdata += (itesio_ecreadreg(sc,
504 ITESIO_EC_SENSORFANEXTBASE + i) << 8);
505 edata->state = ENVSYS_SVALID;
506 if (sdata == 0 ||
507 sdata == ((mode & (1 << i)) ? 0xffff : 0xff))
508 edata->state = ENVSYS_SINVALID;
509 else {
510 edata->value_cur = 1350000 / 2 / sdata;
511 edata->state = ENVSYS_SVALID;
512 }
513 DPRINTF(("%s: 16bit sdata[fan%d] 0x%x\n", __func__, i, sdata));
514 }
515 }
516
517 static void
518 itesio_refresh(struct sysmon_envsys *sme, struct envsys_data *edata)
519 {
520 struct itesio_softc *sc = sme->sme_cookie;
521
522 if (edata->sensor < IT_VOLTSTART_IDX)
523 itesio_refresh_temp(sc, edata);
524 else if (edata->sensor >= IT_VOLTSTART_IDX &&
525 edata->sensor < IT_FANSTART_IDX)
526 itesio_refresh_volts(sc, edata);
527 else
528 itesio_refresh_fans(sc, edata);
529 }
530
531 static int
532 itesio_wdt_setmode(struct sysmon_wdog *smw)
533 {
534 struct itesio_softc *sc = smw->smw_cookie;
535 int period = smw->smw_period;
536
537 /* Enter MB PNP mode and select the WDT LDN */
538 itesio_enter(sc->sc_iot, sc->sc_ioh);
539 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_WDT_LDN);
540
541 if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
542 /* Disable the watchdog */
543 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CTL, 0);
544 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CNF, 0);
545 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB, 0);
546 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB, 0);
547 } else {
548 /* Enable the watchdog */
549 if (period > ITESIO_WDT_MAXTIMO || period < 1)
550 period = smw->smw_period = ITESIO_WDT_MAXTIMO;
551
552 period *= 2;
553
554 /* set the timeout and start the watchdog */
555 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB,
556 period >> 8);
557 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB,
558 period & 0xff);
559 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_CNF,
560 ITESIO_WDT_CNF_SECS | ITESIO_WDT_CNF_KRST |
561 ITESIO_WDT_CNF_PWROK);
562 }
563 /* we are done, exit MB PNP mode */
564 itesio_exit(sc->sc_iot, sc->sc_ioh);
565
566 return 0;
567 }
568
569 static int
570 itesio_wdt_tickle(struct sysmon_wdog *smw)
571 {
572 struct itesio_softc *sc = smw->smw_cookie;
573 int period = smw->smw_period * 2;
574
575 /* refresh timeout value and exit */
576 itesio_enter(sc->sc_iot, sc->sc_ioh);
577 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_LDNSEL, ITESIO_WDT_LDN);
578 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_MSB,
579 period >> 8);
580 itesio_writereg(sc->sc_iot, sc->sc_ioh, ITESIO_WDT_TMO_LSB,
581 period & 0xff);
582 itesio_exit(sc->sc_iot, sc->sc_ioh);
583
584 return 0;
585 }
586