xref: /netbsd-src/share/man/man4/mk48txx.4 (revision 4b896b232495b7a9b8b94a1cf1e21873296d53b8)
1.\"	$NetBSD: mk48txx.4,v 1.13 2003/11/02 09:08:16 wiz Exp $
2.\"
3.\" Copyright (c) 2000, 2002 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Paul Kranenburg.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. All advertising materials mentioning features or use of this software
18.\"    must display the following acknowledgement:
19.\"        This product includes software developed by the NetBSD
20.\"        Foundation, Inc. and its contributors.
21.\" 4. Neither the name of The NetBSD Foundation nor the names of its
22.\"    contributors may be used to endorse or promote products derived
23.\"    from this software without specific prior written permission.
24.\"
25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35.\" POSSIBILITY OF SUCH DAMAGE.
36.\"
37.Dd November 1, 2003
38.Dt MK48TXX 4
39.Os
40.Sh NAME
41.Nm mk48txx
42.Nd
43.Tn Mostek
44time-of-day clock driver
45.Sh SYNOPSIS
46.In dev/ic/mk48txxreg.h
47.In dev/ic/mk48txxvar.h
48.Cd "define mk48txx"
49.Cd "file   dev/ic/mk48txx.c    mk48txx"
50.Sh DESCRIPTION
51The
52.Nm
53driver provides access to several models of
54.Tn Mostek
55time-of-day clock chips.
56Access methods to retrieve and set date and time
57are provided through the
58.Em TODR
59interface defined in
60.Xr todr 9 .
61.Pp
62To tie an instance of this device to the system, use the
63.Fn mk48txx_attach
64function and the mk48txx_softc structure defined as follows:
65.Pp
66.nr nS 1
67.Ft "void"
68.Fn mk48txx_attach "struct mk48txx_softc"
69.Pp
70.Bd -literal
71typedef uint8_t (*mk48txx_nvrd_t)(struct mk48txx_softc, int off);
72typedef void (*mk48txx_nvwr_t)(struct mk48txx_softc, int off,
73    uint8_t datum);
74.Ed
75.Bd -literal
76struct mk48txx_softc {
77	struct device   sc_dev;
78	bus_space_tag_t sc_bst;
79	bus_space_handle_t sc_bsh;
80	struct todr_chip_handle sc_handle;
81	const char	*sc_model;
82	bus_size_t	sc_nvramsz;
83	bus_size_t	sc_clkoffset;
84	u_int		sc_year0;
85	u_int		sc_flag;
86	mk48txx_nvrd_t	sc_nvrd;
87	mk48txx_nvwr_t	sc_nvwr;
88};
89.Ed
90.Pp
91.Bl -tag -width Dv -offset indent
92.It Fa sc_bst
93.It Fa sc_bsh
94Specify bus space access to the chip's non-volatile memory
95.Pq including the clock registers .
96.It Fa sc_handle
97TODR handle passed to the
98.Fn todr_attach
99function to register
100.Xr todr 9
101interface.
102.It Fa sc_model
103The chip model which this instance should serve.
104Must be one of
105.Dq mk48t02 ,
106.Dq mk48t08 ,
107.Dq mk48t18 ,
108or
109.Dq mk48t59 .
110.It Fa sc_nvramsz
111Size of non-volatile RAM in the
112.Tn Mostek
113chip.
114This value is set by
115.Fn mk48txx_attach .
116.It Fa sc_clkoffset
117Offset into the control registers of the
118.Tn Mostek
119chip.
120This value is set by
121.Fn mk48txx_attach .
122.It Fa sc_year0
123The actual year represented by the clock's
124.Sq year
125counter.
126This is generally dependent on the system configuration in which
127the clock device is mounted.
128For instance, on
129.Tn Sun Microsystems
130machines the convention is to have clock's two-digit year represent
131the year 1968.
132.It Fa sc_flag
133This flag is used to specify machine-dependent features.
134.It Fa sc_nvread
135.It Fa sc_nvwrite
136Specify alternate access methods for reading resp. writing clock
137device registers.
138The default, when
139.Dv NULL
140is passed as an access method, is to access the chip memory
141.Pq and clock registers
142as if they were direct-mapped with using the specified bus space.
143.Pp
144Otherwise, the driver will call the respective function to perform the
145access, passing it the specified bus space and the offset
146.Va off
147of the chip memory
148.Pq or clock register
149location to be read from or written to, respectively.
150.El
151.Pp
152Note that if the resulting date retrieved with the todr_gettime() method
153is earlier that January 1, 1970, the driver will assume that the chip's
154year counter actually represents a year in the 21st century.
155This behaviour can be overridden by setting the
156.Va MK48TXX_NO_CENT_ADJUST
157flag in
158.Fa sc_flag .
159.Sh HARDWARE
160The following models are supported:
161.Pp
162.Bl -tag -width indent -offset indent -compact
163.It Tn Mostek MK48T02
164.It Tn Mostek MK48T08
165.It Tn Mostek MK48T18
166.It Tn Mostek MK48T59
167.El
168.Sh SEE ALSO
169.Xr intro 4 ,
170.Xr todr 9
171.Sh HISTORY
172The
173.Nm mk48txx
174driver first appeared in
175.Nx 1.5 .
176.Sh AUTHORS
177The
178.Nm
179driver was written by
180.An Paul Kranenburg
181.Aq pk@NetBSD.org .
182