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