I have created some code in lm78.c to handle the W83792D watchdog portion
of the chip. A diff is pasted at the end of this message. There is one
problem with it though. Under OpenBSD 4.1, if sysctl.kern.period is set to
anything other than 0 while sysctl.kern.auto is set to 1, after a few
seconds a panic occurs with the following trace:

panic: process context required
lockmgr
ichiic_ic2_acquire_bus
lm_i2c_writereg
wb_w83792d_wdg_cb
wdog_tickle
softclock
Bad Frame Pointer: ...

The problem is that lockmgr requires the caller to have a process id, but
the wdog tickler is not associated with a process. So either lockmgr needs
to be changed to handle a caller with no process, or the tickler needs to
be associated with a context.

The problem is different on current. The trace I get for that is:

kernel: page fault trap, code = 0
Stooped at sleep_setup + 0x1d: cmpb $0x7, 0x35(%ebx)
ddb> trace
sleep_setup(d0xd9cdc, d1901700, 10, d071e656, cba8d6aa) at sleep_setup+0x1d
tsleep(d1901700, 10, d071e656, 64) at tsleep+0x5c
ichiic_i2c_exec(d1901700, 1, 2f, d08d9dae, 1) at ichiic_i2c_exec+0x27d
iic_exec(d1901740, 1, 2f, d08d9dae, 1, d08d9daf, 1, 9, d1901764, 10) at
iic_exec+0x177
lm_i2c_writereg(d191b800, 4, d07555f0d0, d08d8000, 0) at
lm_i2c_readreg+0x40
wb_w83792d_wdg_cb(d191b800) at wb_w83792_wdb_cb+0x17
wdog_tickle(0, 0, 0, 5305, 0) at wdog_tickle+0x25
sofclock(d0650058, 10, 380010, d080010, d08d9e6c) at softclock+0x23c
Bad Frame Pointer: 0xd08d9e14

I only looked at the problem on current for a short period of time. I'm
going to be using the watchdogd so I don't actually need the
sysctl.watchdog.auto functionality. But if this is going to get committed,
than I would be more than happy in testing any changes that may arise due
to the issues above.


On another note, about five months I submitted a driver for the W83627HF
watchdog in a new file called wbwdg.c. I have been coordinating with an
OpenBSD developer to get it committed, and last I heard it was going to
get committed. But it has not been committed, and I seem to have lost
contact with the developer. So I was wondering if this code could get
committed?

Thanks

Jonathan Steel

Diff for W83792D watchdog

--- lm78.c      Mon Jun 25 16:50:18 2007
+++ lm78.c_old  Mon Jan 29 08:06:01 2007
@@ -69,6 +69,9 @@

 void as_refresh_temp(struct lm_softc *, int);

+void wb_w83792d_wdg_init(struct lm_softc *);
+int wb_w83792d_wdg_cb(void *, int);
+
 struct lm_chip {
        int (*chip_match)(struct lm_softc *);
 };
@@ -555,6 +558,7 @@
                else
                        printf(": W83792D rev 0x%x\n", devid);
                lm_setup_sensors(sc, w83792d_sensors);
+               wb_w83792d_wdg_init(sc);
                break;
        case WB_CHIPID_AS99127F:
                if (vendid == WB_VENDID_ASUS) {
@@ -885,3 +889,36 @@
                sensor->value = sdata * 500000 + 273150000;
        }
 }
+
+void
+wb_w83792d_wdg_init(struct lm_softc *sc)
+{
+        int control = sc->lm_readreg(sc, 0x40);
+
+        /* Enable watchdog in configuration register */
+        control |= 0x10;
+        sc->lm_writereg(sc, 0x40, control);
+
+        /*
+         * Enable hard watch dog timer with period 0
+        * so that its initially disabled
+         */
+        sc->lm_writereg(sc, 0x04, 0x00);
+        sc->lm_writereg(sc, 0x01, 0xAA);
+        sc->lm_writereg(sc, 0x01, 0x33);
+
+        wdog_register(sc, wb_w83792d_wdg_cb);
+
+        return;
+}
+
+int
+wb_w83792d_wdg_cb(void *arg, int period)
+{
+        struct lm_softc *sc = arg;
+
+        sc->lm_writereg(sc, 0x04, period);
+
+        return period;
+}



--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Reply via email to