mk48txx(4): remove obsolete driver
It's no longer used since 58aa35d429
and r357455 respectively.
This commit is contained in:
parent
d141239c56
commit
9cca83b6db
@ -36,6 +36,9 @@
|
||||
# xargs -n1 | sort | uniq -d;
|
||||
# done
|
||||
|
||||
# 20201224: mk48txx(4) removed
|
||||
OLD_FILES+=usr/share/man/man4/mk48txx.4.gz
|
||||
|
||||
# 20201215: in-tree gdb removed
|
||||
OLD_FILES+=usr/libexec/gdb
|
||||
OLD_FILES+=usr/libexec/kgdb
|
||||
|
@ -286,7 +286,6 @@ MAN= aac.4 \
|
||||
meteor.4 \
|
||||
mfi.4 \
|
||||
miibus.4 \
|
||||
mk48txx.4 \
|
||||
mld.4 \
|
||||
mlx.4 \
|
||||
mlx4en.4 \
|
||||
|
@ -1,225 +0,0 @@
|
||||
.\" $NetBSD: mk48txx.4,v 1.16 2009/04/10 17:14:07 joerg Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This code is derived from software contributed to The NetBSD Foundation
|
||||
.\" by Paul Kranenburg.
|
||||
.\"
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd December 25, 2009
|
||||
.Dt MK48TXX 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm mk48txx
|
||||
.Nd
|
||||
.Tn Mostek
|
||||
time-of-day clock driver
|
||||
.Sh SYNOPSIS
|
||||
.In sys/eventhandler.h
|
||||
.In sys/lock.h
|
||||
.In sys/mutex.h
|
||||
.In dev/mk48txx/mk48txxvar.h
|
||||
.Pp
|
||||
To compile this driver into the kernel,
|
||||
place the following line in your
|
||||
kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "device mk48txx"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver is a back-end for several models of
|
||||
.Tn Mostek
|
||||
time-of-day clock chips.
|
||||
It provides access methods to retrieve and set date and time for use with the
|
||||
.Dq Li clock
|
||||
KOBJ interface.
|
||||
.Pp
|
||||
To tie an instance of this device to the system, use the
|
||||
.Fn mk48txx_attach
|
||||
function and the mk48txx_softc structure defined as follows:
|
||||
.Pp
|
||||
.Ft "int"
|
||||
.Fn mk48txx_attach "device_t dev"
|
||||
.Bd -literal
|
||||
typedef uint8_t (*mk48txx_nvrd_t)(device_t dev, int off);
|
||||
typedef void (*mk48txx_nvwr_t)(device_t dev, int off, uint8_t v);
|
||||
.Ed
|
||||
.Bd -literal
|
||||
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;
|
||||
};
|
||||
.Ed
|
||||
.Bl -tag -width indent
|
||||
.It Fa sc_res
|
||||
The bus resource used for accessing the chip's non-volatile memory
|
||||
.Pq including the clock registers ,
|
||||
which must be supplied by the front-end when using the default access methods
|
||||
.Pq see below .
|
||||
Otherwise this member is optional.
|
||||
.It Fa sc_mtx
|
||||
The hardware mutex used when accessing the chip's non-volatile memory
|
||||
.Pq including the clock registers ,
|
||||
which must be initialized with
|
||||
.Dv MTX_DEF
|
||||
by the front-end.
|
||||
.It 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
|
||||
.Pq see below .
|
||||
.It Fa sc_model
|
||||
The chip model which this instance should serve.
|
||||
This member must be set to one of
|
||||
.Dq mk48t02 ,
|
||||
.Dq mk48t08 ,
|
||||
.Dq mk48t18 ,
|
||||
or
|
||||
.Dq mk48t59
|
||||
by the front-end.
|
||||
.It Fa sc_nvramsz
|
||||
The size of the non-volatile RAM in the
|
||||
.Tn Mostek
|
||||
chip,
|
||||
which is set by the
|
||||
.Fn mk48txx_attach
|
||||
function.
|
||||
.It Fa sc_clkoffset
|
||||
The offset into the control registers of the
|
||||
.Tn Mostek
|
||||
chip,
|
||||
which is set by the
|
||||
.Fn mk48txx_attach
|
||||
function.
|
||||
.It Fa sc_year0
|
||||
The year offset to be used with the
|
||||
.Sq 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
|
||||
.Tn Sun Microsystems
|
||||
machines the convention is to have clock's two-digit year represent
|
||||
the year since 1968.
|
||||
.It Fa sc_flag
|
||||
This flag is used to specify machine-dependent features.
|
||||
The following flags are supported:
|
||||
.Bl -tag -width ".Dv MK48TXX_WDOG_ENABLE_WDS"
|
||||
.It Dv MK48TXX_NO_CENT_ADJUST
|
||||
If the resulting date retrieved with the
|
||||
.Dq Li 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
|
||||
.Nm
|
||||
driver to respect the clock's century bit instead.
|
||||
.It Dv MK48TXX_WDOG_REGISTER
|
||||
When this flag is set,
|
||||
the
|
||||
.Nm
|
||||
driver will register as a watchdog via the interface defined in
|
||||
.Xr watchdog 9
|
||||
if supported by the specific chip model.
|
||||
.It Dv MK48TXX_WDOG_ENABLE_WDS
|
||||
When this flag is set,
|
||||
the
|
||||
.Nm
|
||||
driver will set the watchdog steering
|
||||
.Pq WDS
|
||||
bit when enabling the watchdog functionality of the chip.
|
||||
enabled
|
||||
.Pq see the chip documentation for further information regarding the WDS bit .
|
||||
.El
|
||||
.It Fa sc_nvread
|
||||
.It Fa sc_nvwrite
|
||||
These members specify the access methods for reading respectively writing
|
||||
clock device registers.
|
||||
The default,
|
||||
when
|
||||
.Dv NULL
|
||||
is passed as an access method,
|
||||
is to access the chip memory
|
||||
.Pq and clock registers
|
||||
as if they were direct-mapped using the specified bus resource.
|
||||
.Pp
|
||||
Otherwise, the driver will call the respective function supplied by the
|
||||
front-end to perform the access,
|
||||
passing it the offset
|
||||
.Va off
|
||||
of the chip memory
|
||||
.Pq or clock register
|
||||
location to be read from or written to, respectively.
|
||||
.El
|
||||
.Sh HARDWARE
|
||||
The following models are supported:
|
||||
.Pp
|
||||
.Bl -tag -width indent -offset indent -compact
|
||||
.It Tn Mostek MK48T02
|
||||
.It Tn Mostek MK48T08
|
||||
.It Tn Mostek MK48T18
|
||||
.It Tn Mostek MK48T59
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr intro 4 ,
|
||||
.Xr watchdog 9
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm mk48txx
|
||||
driver appeared in
|
||||
.Nx 1.5 .
|
||||
The first
|
||||
.Fx
|
||||
version to include it was
|
||||
.Fx 5.0 .
|
||||
.Sh AUTHORS
|
||||
.An -nosplit
|
||||
The
|
||||
.Nm
|
||||
driver was written for
|
||||
.Nx
|
||||
by
|
||||
.An Paul Kranenburg Aq Mt pk@NetBSD.org .
|
||||
It was ported to
|
||||
.Fx
|
||||
by
|
||||
.An Thomas Moestl Aq Mt tmm@FreeBSD.org
|
||||
and later on improved by
|
||||
.An Marius Strobl Aq Mt marius@FreeBSD.org .
|
@ -2439,7 +2439,6 @@ dev/mii/ukphy.c optional miibus | mii
|
||||
dev/mii/ukphy_subr.c optional miibus | mii
|
||||
dev/mii/vscphy.c optional miibus | vscphy
|
||||
dev/mii/xmphy.c optional miibus | xmphy
|
||||
dev/mk48txx/mk48txx.c optional mk48txx
|
||||
dev/mlxfw/mlxfw_fsm.c optional mlxfw \
|
||||
compile-with "${MLXFW_C}"
|
||||
dev/mlxfw/mlxfw_mfa2.c optional mlxfw \
|
||||
|
@ -1,332 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Paul Kranenburg.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $NetBSD: mk48txx.c,v 1.25 2008/04/28 20:23:50 martin Exp $
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
/*
|
||||
* Mostek MK48T02, MK48T08, MK48T18, MK48T37 and MK48T59 time-of-day chip
|
||||
* subroutines
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/clock.h>
|
||||
#include <sys/eventhandler.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/watchdog.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/mk48txx/mk48txxreg.h>
|
||||
#include <dev/mk48txx/mk48txxvar.h>
|
||||
|
||||
#include "clock_if.h"
|
||||
|
||||
static uint8_t mk48txx_def_nvrd(device_t dev, int off);
|
||||
static void mk48txx_def_nvwr(device_t dev, int off, uint8_t v);
|
||||
static void mk48txx_watchdog(void *arg, u_int cmd, int *error);
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
bus_size_t nvramsz;
|
||||
bus_size_t clkoff;
|
||||
u_int flags;
|
||||
#define MK48TXX_EXT_REGISTERS 1 /* Has extended register set. */
|
||||
} mk48txx_models[] = {
|
||||
{ "mk48t02", MK48T02_CLKSZ, MK48T02_CLKOFF, 0 },
|
||||
{ "mk48t08", MK48T08_CLKSZ, MK48T08_CLKOFF, 0 },
|
||||
{ "mk48t18", MK48T18_CLKSZ, MK48T18_CLKOFF, 0 },
|
||||
{ "mk48t37", MK48T37_CLKSZ, MK48T37_CLKOFF, MK48TXX_EXT_REGISTERS },
|
||||
{ "mk48t59", MK48T59_CLKSZ, MK48T59_CLKOFF, MK48TXX_EXT_REGISTERS },
|
||||
};
|
||||
|
||||
int
|
||||
mk48txx_attach(device_t dev)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
int i;
|
||||
uint8_t wday;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
if (mtx_initialized(&sc->sc_mtx) == 0) {
|
||||
device_printf(dev, "%s: mutex not initialized\n", __func__);
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
device_printf(dev, "model %s", sc->sc_model);
|
||||
i = sizeof(mk48txx_models) / sizeof(mk48txx_models[0]);
|
||||
while (--i >= 0) {
|
||||
if (strcmp(sc->sc_model, mk48txx_models[i].name) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
device_printf(dev, " (unsupported)\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
printf("\n");
|
||||
sc->sc_nvramsz = mk48txx_models[i].nvramsz;
|
||||
sc->sc_clkoffset = mk48txx_models[i].clkoff;
|
||||
|
||||
if (sc->sc_nvrd == NULL)
|
||||
sc->sc_nvrd = mk48txx_def_nvrd;
|
||||
if (sc->sc_nvwr == NULL)
|
||||
sc->sc_nvwr = mk48txx_def_nvwr;
|
||||
|
||||
if (mk48txx_models[i].flags & MK48TXX_EXT_REGISTERS) {
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
if ((*sc->sc_nvrd)(dev, sc->sc_clkoffset + MK48TXX_FLAGS) &
|
||||
MK48TXX_FLAGS_BL) {
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
device_printf(dev, "%s: battery low\n", __func__);
|
||||
return (ENXIO);
|
||||
}
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
||||
|
||||
if (sc->sc_flag & MK48TXX_NO_CENT_ADJUST) {
|
||||
/*
|
||||
* Use MK48TXX_WDAY_CB instead of manually adjusting the
|
||||
* century.
|
||||
*/
|
||||
if (!(mk48txx_models[i].flags & MK48TXX_EXT_REGISTERS)) {
|
||||
device_printf(dev, "%s: no century bit\n", __func__);
|
||||
return (ENXIO);
|
||||
} else {
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
wday = (*sc->sc_nvrd)
|
||||
(dev, sc->sc_clkoffset + MK48TXX_IWDAY);
|
||||
wday |= MK48TXX_WDAY_CEB;
|
||||
(*sc->sc_nvwr)
|
||||
(dev, sc->sc_clkoffset + MK48TXX_IWDAY, wday);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
||||
}
|
||||
|
||||
clock_register(dev, 1000000); /* 1 second resolution */
|
||||
|
||||
if ((sc->sc_flag & MK48TXX_WDOG_REGISTER) &&
|
||||
(mk48txx_models[i].flags & MK48TXX_EXT_REGISTERS)) {
|
||||
sc->sc_wet = EVENTHANDLER_REGISTER(watchdog_list,
|
||||
mk48txx_watchdog, dev, 0);
|
||||
device_printf(dev,
|
||||
"watchdog registered, timeout interval max. 128 sec\n");
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get time-of-day and convert to a `struct timespec'
|
||||
* Return 0 on success; an error number otherwise.
|
||||
*/
|
||||
int
|
||||
mk48txx_gettime(device_t dev, struct timespec *ts)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
bus_size_t clkoff;
|
||||
struct clocktime ct;
|
||||
int year;
|
||||
uint8_t csr;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
clkoff = sc->sc_clkoffset;
|
||||
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
/* enable read (stop time) */
|
||||
csr = (*sc->sc_nvrd)(dev, clkoff + MK48TXX_ICSR);
|
||||
csr |= MK48TXX_CSR_READ;
|
||||
(*sc->sc_nvwr)(dev, clkoff + MK48TXX_ICSR, csr);
|
||||
|
||||
#define FROMREG(reg, mask) ((*sc->sc_nvrd)(dev, clkoff + (reg)) & (mask))
|
||||
|
||||
ct.nsec = 0;
|
||||
ct.sec = FROMBCD(FROMREG(MK48TXX_ISEC, MK48TXX_SEC_MASK));
|
||||
ct.min = FROMBCD(FROMREG(MK48TXX_IMIN, MK48TXX_MIN_MASK));
|
||||
ct.hour = FROMBCD(FROMREG(MK48TXX_IHOUR, MK48TXX_HOUR_MASK));
|
||||
ct.day = FROMBCD(FROMREG(MK48TXX_IDAY, MK48TXX_DAY_MASK));
|
||||
#if 0
|
||||
/* Map dow from 1 - 7 to 0 - 6; FROMBCD() isn't necessary here. */
|
||||
ct.dow = FROMREG(MK48TXX_IWDAY, MK48TXX_WDAY_MASK) - 1;
|
||||
#else
|
||||
/*
|
||||
* Set dow = -1 because some drivers (for example the NetBSD and
|
||||
* OpenBSD mk48txx(4)) don't set it correctly.
|
||||
*/
|
||||
ct.dow = -1;
|
||||
#endif
|
||||
ct.mon = FROMBCD(FROMREG(MK48TXX_IMON, MK48TXX_MON_MASK));
|
||||
year = FROMBCD(FROMREG(MK48TXX_IYEAR, MK48TXX_YEAR_MASK));
|
||||
year += sc->sc_year0;
|
||||
if (sc->sc_flag & MK48TXX_NO_CENT_ADJUST)
|
||||
year += (FROMREG(MK48TXX_IWDAY, MK48TXX_WDAY_CB) >>
|
||||
MK48TXX_WDAY_CB_SHIFT) * 100;
|
||||
else if (year < POSIX_BASE_YEAR)
|
||||
year += 100;
|
||||
|
||||
#undef FROMREG
|
||||
|
||||
ct.year = year;
|
||||
|
||||
/* time wears on */
|
||||
csr = (*sc->sc_nvrd)(dev, clkoff + MK48TXX_ICSR);
|
||||
csr &= ~MK48TXX_CSR_READ;
|
||||
(*sc->sc_nvwr)(dev, clkoff + MK48TXX_ICSR, csr);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
|
||||
return (clock_ct_to_ts(&ct, ts));
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the time-of-day clock based on the value of the `struct timespec' arg.
|
||||
* Return 0 on success; an error number otherwise.
|
||||
*/
|
||||
int
|
||||
mk48txx_settime(device_t dev, struct timespec *ts)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
bus_size_t clkoff;
|
||||
struct clocktime ct;
|
||||
uint8_t csr;
|
||||
int cent, year;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
clkoff = sc->sc_clkoffset;
|
||||
|
||||
/* Accuracy is only one second. */
|
||||
if (ts->tv_nsec >= 500000000)
|
||||
ts->tv_sec++;
|
||||
ts->tv_nsec = 0;
|
||||
clock_ts_to_ct(ts, &ct);
|
||||
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
/* enable write */
|
||||
csr = (*sc->sc_nvrd)(dev, clkoff + MK48TXX_ICSR);
|
||||
csr |= MK48TXX_CSR_WRITE;
|
||||
(*sc->sc_nvwr)(dev, clkoff + MK48TXX_ICSR, csr);
|
||||
|
||||
#define TOREG(reg, mask, val) \
|
||||
((*sc->sc_nvwr)(dev, clkoff + (reg), \
|
||||
((*sc->sc_nvrd)(dev, clkoff + (reg)) & ~(mask)) | \
|
||||
((val) & (mask))))
|
||||
|
||||
TOREG(MK48TXX_ISEC, MK48TXX_SEC_MASK, TOBCD(ct.sec));
|
||||
TOREG(MK48TXX_IMIN, MK48TXX_MIN_MASK, TOBCD(ct.min));
|
||||
TOREG(MK48TXX_IHOUR, MK48TXX_HOUR_MASK, TOBCD(ct.hour));
|
||||
/* Map dow from 0 - 6 to 1 - 7; TOBCD() isn't necessary here. */
|
||||
TOREG(MK48TXX_IWDAY, MK48TXX_WDAY_MASK, ct.dow + 1);
|
||||
TOREG(MK48TXX_IDAY, MK48TXX_DAY_MASK, TOBCD(ct.day));
|
||||
TOREG(MK48TXX_IMON, MK48TXX_MON_MASK, TOBCD(ct.mon));
|
||||
|
||||
year = ct.year - sc->sc_year0;
|
||||
if (sc->sc_flag & MK48TXX_NO_CENT_ADJUST) {
|
||||
cent = year / 100;
|
||||
TOREG(MK48TXX_IWDAY, MK48TXX_WDAY_CB,
|
||||
cent << MK48TXX_WDAY_CB_SHIFT);
|
||||
year -= cent * 100;
|
||||
} else if (year > 99)
|
||||
year -= 100;
|
||||
TOREG(MK48TXX_IYEAR, MK48TXX_YEAR_MASK, TOBCD(year));
|
||||
|
||||
#undef TOREG
|
||||
|
||||
/* load them up */
|
||||
csr = (*sc->sc_nvrd)(dev, clkoff + MK48TXX_ICSR);
|
||||
csr &= ~MK48TXX_CSR_WRITE;
|
||||
(*sc->sc_nvwr)(dev, clkoff + MK48TXX_ICSR, csr);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static uint8_t
|
||||
mk48txx_def_nvrd(device_t dev, int off)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
return (bus_read_1(sc->sc_res, off));
|
||||
}
|
||||
|
||||
static void
|
||||
mk48txx_def_nvwr(device_t dev, int off, uint8_t v)
|
||||
{
|
||||
struct mk48txx_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
bus_write_1(sc->sc_res, off, v);
|
||||
}
|
||||
|
||||
static void
|
||||
mk48txx_watchdog(void *arg, u_int cmd, int *error)
|
||||
{
|
||||
device_t dev;
|
||||
struct mk48txx_softc *sc;
|
||||
uint8_t t, wdog;
|
||||
|
||||
dev = arg;
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
t = cmd & WD_INTERVAL;
|
||||
if (t >= 26 && t <= 37) {
|
||||
wdog = 0;
|
||||
if (t <= WD_TO_2SEC) {
|
||||
wdog |= MK48TXX_WDOG_RB_1_16;
|
||||
t -= 26;
|
||||
} else if (t <= WD_TO_8SEC) {
|
||||
wdog |= MK48TXX_WDOG_RB_1_4;
|
||||
t -= WD_TO_250MS;
|
||||
} else if (t <= WD_TO_32SEC) {
|
||||
wdog |= MK48TXX_WDOG_RB_1;
|
||||
t -= WD_TO_1SEC;
|
||||
} else {
|
||||
wdog |= MK48TXX_WDOG_RB_4;
|
||||
t -= WD_TO_4SEC;
|
||||
}
|
||||
wdog |= (min(1 << t,
|
||||
MK48TXX_WDOG_BMB_MASK >> MK48TXX_WDOG_BMB_SHIFT)) <<
|
||||
MK48TXX_WDOG_BMB_SHIFT;
|
||||
if (sc->sc_flag & MK48TXX_WDOG_ENABLE_WDS)
|
||||
wdog |= MK48TXX_WDOG_WDS;
|
||||
*error = 0;
|
||||
} else {
|
||||
wdog = 0;
|
||||
}
|
||||
mtx_lock(&sc->sc_mtx);
|
||||
(*sc->sc_nvwr)(dev, sc->sc_clkoffset + MK48TXX_WDOG, wdog);
|
||||
mtx_unlock(&sc->sc_mtx);
|
||||
}
|
@ -1,161 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Paul Kranenburg.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $NetBSD: mk48txxreg.h,v 1.10 2008/04/28 20:23:50 martin Exp $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mostek MK48Txx clocks.
|
||||
*
|
||||
* The MK48T02 has 2KB of non-volatile memory. The time-of-day clock
|
||||
* registers start at offset 0x7f8.
|
||||
*
|
||||
* The MK48T08 and MK48T18 have 8KB of non-volatile memory
|
||||
*
|
||||
* The MK48T59 also has 8KB of non-volatile memory but in addition it
|
||||
* has a battery low detection bit and a power supply wakeup alarm for
|
||||
* power management. It's at offset 0x1ff0 in the NVRAM.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Mostek MK48TXX register definitions
|
||||
*/
|
||||
|
||||
/*
|
||||
* The first bank of eight registers at offset (nvramsz - 16) is
|
||||
* available only on recenter (which?) MK48Txx models.
|
||||
*/
|
||||
#define MK48TXX_FLAGS 0 /* flags register */
|
||||
#define MK48TXX_UNUSED 1 /* unused */
|
||||
#define MK48TXX_ASEC 2 /* alarm seconds (0..59; BCD) */
|
||||
#define MK48TXX_AMIN 3 /* alarm minutes (0..59; BCD) */
|
||||
#define MK48TXX_AHOUR 4 /* alarm hours (0..23; BCD) */
|
||||
#define MK48TXX_ADAY 5 /* alarm day in month (1..31; BCD) */
|
||||
#define MK48TXX_INTR 6 /* interrupts register */
|
||||
#define MK48TXX_WDOG 7 /* watchdog register */
|
||||
|
||||
#define MK48TXX_ICSR 8 /* control register */
|
||||
#define MK48TXX_ISEC 9 /* seconds (0..59; BCD) */
|
||||
#define MK48TXX_IMIN 10 /* minutes (0..59; BCD) */
|
||||
#define MK48TXX_IHOUR 11 /* hours (0..23; BCD) */
|
||||
#define MK48TXX_IWDAY 12 /* weekday (1..7) */
|
||||
#define MK48TXX_IDAY 13 /* day in month (1..31; BCD) */
|
||||
#define MK48TXX_IMON 14 /* month (1..12; BCD) */
|
||||
#define MK48TXX_IYEAR 15 /* year (0..99; BCD) */
|
||||
|
||||
/*
|
||||
* Note that some of the bits below that are not in the first eight
|
||||
* registers are also only available on models with an extended
|
||||
* register set.
|
||||
*/
|
||||
|
||||
/* Bits in the flags register (extended only) */
|
||||
#define MK48TXX_FLAGS_BL 0x10 /* battery low (read only) */
|
||||
#define MK48TXX_FLAGS_AF 0x40 /* alarm flag (read only) */
|
||||
#define MK48TXX_FLAGS_WDF 0x80 /* watchdog flag (read only) */
|
||||
|
||||
/* Bits in the alarm seconds register (extended only) */
|
||||
#define MK48TXX_ASEC_MASK 0x7f /* mask for alarm seconds */
|
||||
#define MK48TXX_ASEC_RPT1 0x80 /* alarm repeat mode bit 1 */
|
||||
|
||||
/* Bits in the alarm minutes register (extended only) */
|
||||
#define MK48TXX_AMIN_MASK 0x7f /* mask for alarm minutes */
|
||||
#define MK48TXX_AMIN_RPT2 0x80 /* alarm repeat mode bit 2 */
|
||||
|
||||
/* Bits in the alarm hours register (extended only) */
|
||||
#define MK48TXX_AHOUR_MASK 0x3f /* mask for alarm hours */
|
||||
#define MK48TXX_AHOUR_RPT3 0x80 /* alarm repeat mode bit 3 */
|
||||
|
||||
/* Bits in the alarm day in month register (extended only) */
|
||||
#define MK48TXX_ADAY_MASK 0x3f /* mask for alarm day in month */
|
||||
#define MK48TXX_ADAY_RPT4 0x80 /* alarm repeat mode bit 4 */
|
||||
|
||||
/* Bits in the interrupts register (extended only) */
|
||||
#define MK48TXX_INTR_ABE 0x20 /* alarm in battery back-up mode */
|
||||
#define MK48TXX_INTR_AFE 0x80 /* alarm flag enable */
|
||||
|
||||
/* Bits in the watchdog register (extended only) */
|
||||
#define MK48TXX_WDOG_RB_1_16 0x00 /* watchdog resolution 1/16 second */
|
||||
#define MK48TXX_WDOG_RB_1_4 0x01 /* watchdog resolution 1/4 second */
|
||||
#define MK48TXX_WDOG_RB_1 0x02 /* watchdog resolution 1 second */
|
||||
#define MK48TXX_WDOG_RB_4 0x03 /* watchdog resolution 4 seconds */
|
||||
#define MK48TXX_WDOG_BMB_MASK 0x7c /* mask for watchdog multiplier */
|
||||
#define MK48TXX_WDOG_BMB_SHIFT 2 /* shift for watchdog multiplier */
|
||||
#define MK48TXX_WDOG_WDS 0x80 /* watchdog steering bit */
|
||||
|
||||
/* Bits in the control register */
|
||||
#define MK48TXX_CSR_CALIB_MASK 0x1f /* mask for calibration step width */
|
||||
#define MK48TXX_CSR_SIGN 0x20 /* sign of above calibration witdh */
|
||||
#define MK48TXX_CSR_READ 0x40 /* want to read (freeze clock) */
|
||||
#define MK48TXX_CSR_WRITE 0x80 /* want to write */
|
||||
|
||||
/* Bits in the seconds register */
|
||||
#define MK48TXX_SEC_MASK 0x7f /* mask for seconds */
|
||||
#define MK48TXX_SEC_ST 0x80 /* stop oscillator */
|
||||
|
||||
/* Bits in the minutes register */
|
||||
#define MK48TXX_MIN_MASK 0x7f /* mask for minutes */
|
||||
|
||||
/* Bits in the hours register */
|
||||
#define MK48TXX_HOUR_MASK 0x3f /* mask for hours */
|
||||
|
||||
/* Bits in the century/weekday register */
|
||||
#define MK48TXX_WDAY_MASK 0x07 /* mask for weekday */
|
||||
#define MK48TXX_WDAY_CB 0x10 /* century bit (extended only) */
|
||||
#define MK48TXX_WDAY_CB_SHIFT 4 /* shift for century bit */
|
||||
#define MK48TXX_WDAY_CEB 0x20 /* century enable bit (extended only) */
|
||||
#define MK48TXX_WDAY_FT 0x40 /* frequency test */
|
||||
|
||||
/* Bits in the day in month register */
|
||||
#define MK48TXX_DAY_MASK 0x3f /* mask for day in month */
|
||||
|
||||
/* Bits in the month register */
|
||||
#define MK48TXX_MON_MASK 0x1f /* mask for month */
|
||||
|
||||
/* Bits in the year register */
|
||||
#define MK48TXX_YEAR_MASK 0xff /* mask for year */
|
||||
|
||||
/* Model specific NVRAM sizes and clock offsets */
|
||||
#define MK48T02_CLKSZ 2048
|
||||
#define MK48T02_CLKOFF 0x7f0
|
||||
|
||||
#define MK48T08_CLKSZ 8192
|
||||
#define MK48T08_CLKOFF 0x1ff0
|
||||
|
||||
#define MK48T18_CLKSZ 8192
|
||||
#define MK48T18_CLKOFF 0x1ff0
|
||||
|
||||
#define MK48T37_CLKSZ 32768
|
||||
#define MK48T37_CLKOFF 0x1ff0
|
||||
|
||||
#define MK48T59_CLKSZ 8192
|
||||
#define MK48T59_CLKOFF 0x1ff0
|
@ -1,63 +0,0 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||
*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Paul Kranenburg.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* $NetBSD: mk48txxvar.h,v 1.6 2008/04/28 20:23:50 martin Exp $
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
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;/* bus resource */
|
||||
|
||||
struct mtx sc_mtx; /* hardware mutex */
|
||||
eventhandler_tag sc_wet; /* watchdog event handler tag */
|
||||
|
||||
const char *sc_model; /* chip model name */
|
||||
bus_size_t sc_nvramsz; /* Size of NVRAM on the chip */
|
||||
bus_size_t sc_clkoffset; /* Offset in NVRAM to clock bits */
|
||||
u_int sc_year0; /* year counter offset */
|
||||
u_int sc_flag; /* MD flags */
|
||||
#define MK48TXX_NO_CENT_ADJUST 0x0001 /* don't manually adjust century */
|
||||
#define MK48TXX_WDOG_REGISTER 0x0002 /* register watchdog */
|
||||
#define MK48TXX_WDOG_ENABLE_WDS 0x0004 /* enable watchdog steering bit */
|
||||
|
||||
mk48txx_nvrd_t sc_nvrd; /* NVRAM/RTC read function */
|
||||
mk48txx_nvwr_t sc_nvwr; /* NVRAM/RTC write function */
|
||||
};
|
||||
|
||||
/* Chip attach function */
|
||||
int mk48txx_attach(device_t dev);
|
||||
|
||||
/* Methods for the clock interface */
|
||||
int mk48txx_gettime(device_t dev, struct timespec *ts);
|
||||
int mk48txx_settime(device_t dev, struct timespec *ts);
|
@ -1,21 +0,0 @@
|
||||
# Doxyfile 1.5.2
|
||||
|
||||
# $FreeBSD$
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = "FreeBSD kernel MK48TXX device code"
|
||||
OUTPUT_DIRECTORY = $(DOXYGEN_DEST_PATH)/dev_mk48txx/
|
||||
EXTRACT_ALL = YES # for undocumented src, no warnings enabled
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = $(DOXYGEN_SRC_PATH)/dev/mk48txx/ \
|
||||
$(NOTREVIEWED)
|
||||
|
||||
GENERATE_TAGFILE = dev_mk48txx/dev_mk48txx.tag
|
||||
|
||||
@INCLUDE_PATH = $(DOXYGEN_INCLUDE_PATH)
|
||||
@INCLUDE = common-Doxyfile
|
||||
|
Loading…
Reference in New Issue
Block a user