Provide a utility routine to configure/write the watchdog.

XXX This watchdog should eventually be integrated into the generic
    watchdog framework.
This commit is contained in:
briggs 2009-01-09 16:09:43 +00:00
parent 4f13ce5106
commit c43973de4b
2 changed files with 62 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: m41st84.c,v 1.13 2008/06/08 03:49:26 tsutsui Exp $ */
/* $NetBSD: m41st84.c,v 1.14 2009/01/09 16:09:43 briggs Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.13 2008/06/08 03:49:26 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.14 2009/01/09 16:09:43 briggs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -51,6 +51,7 @@ __KERNEL_RCSID(0, "$NetBSD: m41st84.c,v 1.13 2008/06/08 03:49:26 tsutsui Exp $")
#include <dev/i2c/i2cvar.h>
#include <dev/i2c/m41st84reg.h>
#include <dev/i2c/m41st84var.h>
struct strtc_softc {
device_t sc_dev;
@ -414,3 +415,28 @@ strtc_clock_write(struct strtc_softc *sc, struct clock_ymdhms *dt)
return (1);
}
void
strtc_wdog_config(void *arg, uint8_t wd)
{
struct strtc_softc *sc = arg;
uint8_t cmdbuf[2];
if (iic_acquire_bus(sc->sc_tag, I2C_F_POLL)) {
aprint_error_dev(sc->sc_dev,
"strtc_wdog_config: failed to acquire I2C bus\n");
return;
}
cmdbuf[0] = M41ST84_REG_WATCHDOG;
cmdbuf[1] = wd;
if (iic_exec(sc->sc_tag, I2C_OP_WRITE_WITH_STOP, sc->sc_address,
cmdbuf, 1, &cmdbuf[1], 1, I2C_F_POLL)) {
aprint_error_dev(sc->sc_dev,
"strtc_wdog_config: failed to write watchdog\n");
return;
}
iic_release_bus(sc->sc_tag, I2C_F_POLL);
}

34
sys/dev/i2c/m41st84var.h Normal file
View File

@ -0,0 +1,34 @@
/* $NetBSD: m41st84var.h,v 1.1 2009/01/09 16:09:43 briggs Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_I2C_M41ST84VAR_H_
#define _DEV_I2C_M41ST84VAR_H_
void strtc_wdog_config(void *, uint8_t);
#endif /* _DEV_I2C_M41ST84VAR_H_ */