mk48txx(4) Mostek

SYNOPSIS

In sys/eventhandler.h In sys/lock.h In sys/mutex.h In dev/mk48txx/mk48txxvar.h

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

device mk48txx

DESCRIPTION

The 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 Fn mk48txx_attach function and the mk48txx_softc structure defined as follows:

Ft int Fn 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;
};

Fa 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.
Fa 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.
Fa sc_wet
The event handler tag for the watchdog functionality, which is registered by the Fn mk48txx_attach function if supported by the chip and specified as part of the machine-dependent features (see below)
Fa 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.
Fa sc_nvramsz
The size of the non-volatile RAM in the Mostek chip, which is set by the Fn mk48txx_attach function.
Fa sc_clkoffset
The offset into the control registers of the Mostek chip, which is set by the Fn mk48txx_attach function.
Fa 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.
Fa 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 driver to respect the clock's century bit instead.
MK48TXX_WDOG_REGISTER
When this flag is set, the 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 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)

Fa sc_nvread
Fa 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

HISTORY

The mk48txx driver appeared in Nx 1.5 . The first Fx version to include it was Fx 5.0 .

AUTHORS

An -nosplit The driver was written for Nx by An Paul Kranenburg Aq [email protected] . It was ported to Fx by An Thomas Moestl Aq [email protected] and later on improved by An Marius Strobl Aq [email protected] .