MK48TXX(4)

NAME
mk48txx - Mostek time-of-day clock driver

SYNOPSIS
#include <sys/eventhandler.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <dev/mk48txx/mk48txxvar.h>

To compile this driver into the kernel, place the following line in your kernel configuration file:

device mk48txx

DESCRIPTION
The mk48txx driver is a back-end for several models of Mostek time-of-day clock chips. It provides access methods to retrieve and set date and time for use with the “clock” KOBJ interface.

To tie an instance of this device to the system, use the mk48txx_attach() function and the mk48txx_softc structure defined as follows:

int mk48txx_attach(device_t dev)

    typedef uint8_t (*mk48txx_nvrd_t)(device_t dev, int off);
    typedef void (*mk48txx_nvwr_t)(device_t dev, int off, uint8_t v);

    struct mk48txx_softc {
    	struct resource	sc_res;
    	struct mtx	sc_mtx;
    	eventhandler_tag	sc_wet;
    	const char	*sc_model;
    	bus_size_t	sc_nvramsz;
    	bus_size_t	sc_clkoffset;
    	u_int		sc_year0;
    	u_int		sc_flag;
    	mk48txx_nvrd_t	sc_nvrd;
    	mk48txx_nvwr_t	sc_nvwr;
    };

sc_res
    The bus resource used for accessing the chip's non-volatile memory (including the clock registers), which must be supplied by the front-end when using the default access methods (see below). Otherwise this member is optional.

sc_mtx
    The hardware mutex used when accessing the chip's non-volatile memory (including the clock registers), which must be initialized with MTX_DEF by the front-end.

sc_wet
    The event handler tag for the watchdog functionality, which is registered by the mk48txx_attach() function if supported by the chip and specified as part of the machine-dependent features (see below).

sc_model
    The chip model which this instance should serve. This member must be set to one of “mk48t02”, “mk48t08”, “mk48t18”, or “mk48t59” by the front-end.

sc_nvramsz
    The size of the non-volatile RAM in the Mostek chip, which is set by the mk48txx_attach() function.

sc_clkoffset
    The offset into the control registers of the Mostek chip, which is set by the mk48txx_attach() function.

sc_year0
    The year offset to be used with the ‘year’ counter of the clock, which must be set by the front-end. This value is generally dependent on the system configuration in which the clock device is mounted. For instance, on Sun Microsystems machines the convention is to have clock's two-digit year represent the year since 1968.

sc_flag
    This flag is used to specify machine-dependent features. The following flags are supported:

    MK48TXX_NO_CENT_ADJUST
        If the resulting date retrieved with the “clock_gettime() method” would be earlier than January 1, 1970, the driver will assume that the chip's year counter actually represents a year in the 21st century. This behavior can be overridden by setting this flag, which causes the mk48txx driver to respect the clock's century bit instead.

    MK48TXX_WDOG_REGISTER
        When this flag is set, the mk48txx driver will register as a watchdog via the interface defined in watchdog(9) if supported by the specific chip model.

    MK48TXX_WDOG_ENABLE_WDS
        When this flag is set, the mk48txx driver will set the watchdog steering (WDS) bit when enabling the watchdog functionality of the chip. enabled (see the chip documentation for further information regarding the WDS bit).

sc_nvread

sc_nvwrite
    These members specify the access methods for reading respectively writing clock device registers. The default, when NULL is passed as an access method, is to access the chip memory (and clock registers) as if they were direct-mapped using the specified bus resource.

    Otherwise, the driver will call the respective function supplied by the front-end to perform the access, passing it the offset off of the chip memory (or clock register) location to be read from or written to, respectively.

HARDWARE
The following models are supported:

Mostek MK48T02
Mostek MK48T08
Mostek MK48T18
Mostek MK48T59

SEE ALSO
intro(4), watchdog(9)

HISTORY
The mk48txx driver appeared in NetBSD 1.5. The first FreeBSD version to include it was FreeBSD 5.0.

AUTHORS
-nosplit The mk48txx driver was written for NetBSD by Paul Kranenburg <pk@NetBSD.org>. It was ported to FreeBSD by Thomas Moestl <tmm@FreeBSD.org> and later on improved by Marius Strobl <marius@FreeBSD.org>.