1139749Simp/*-
2137821Smarius * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
3137821Smarius *
4137821Smarius * Redistribution and use in source and binary forms, with or without
5137821Smarius * modification, are permitted provided that the following conditions
6137821Smarius * are met:
7137821Smarius * 1. Redistributions of source code must retain the above copyright
8137821Smarius *    notice, this list of conditions and the following disclaimer.
9137821Smarius * 2. Redistributions in binary form must reproduce the above copyright
10137821Smarius *    notice, this list of conditions and the following disclaimer in the
11137821Smarius *    documentation and/or other materials provided with the distribution.
12137821Smarius *
13137821Smarius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14137821Smarius * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15137821Smarius * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16137821Smarius * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17137821Smarius * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18137821Smarius * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19137821Smarius * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20137821Smarius * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21137821Smarius * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22137821Smarius * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23137821Smarius *
24201009Smarius *	$NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $
25137821Smarius *
26137821Smarius * $FreeBSD: releng/10.2/sys/dev/mc146818/mc146818var.h 201009 2009-12-25 22:58:43Z marius $
27137821Smarius */
28137821Smarius
29137821Smariusstruct mc146818_softc {
30137821Smarius	bus_space_tag_t	sc_bst;			/* bus space tag */
31137821Smarius	bus_space_handle_t sc_bsh;		/* bus space handle */
32137821Smarius
33146417Smarius	struct mtx sc_mtx;			/* hardware mutex */
34146417Smarius
35137821Smarius	u_char sc_rega;				/* register A */
36137821Smarius	u_char sc_regb;				/* register B */
37137821Smarius
38137821Smarius	u_int sc_year0;				/* year counter offset */
39201008Smarius
40137821Smarius	u_int sc_flag;				/* MD flags */
41201008Smarius#define	MC146818_NO_CENT_ADJUST	0x0001		/* don't adjust century */
42201008Smarius#define	MC146818_BCD		0x0002		/* use BCD mode */
43201008Smarius#define	MC146818_12HR		0x0004		/* use AM/PM mode */
44137821Smarius
45137821Smarius	/* MD chip register read/write functions */
46201008Smarius	u_int (*sc_mcread)(device_t dev, u_int reg);
47201008Smarius	void (*sc_mcwrite)(device_t dev, u_int reg, u_int val);
48137821Smarius	/* MD century get/set functions */
49201008Smarius	u_int (*sc_getcent)(device_t dev);
50201008Smarius	void (*sc_setcent)(device_t dev, u_int cent);
51137821Smarius};
52137821Smarius
53170844Smarius/* Default read/write functions */
54201008Smariusu_int mc146818_def_read(device_t dev, u_int reg);
55201008Smariusvoid mc146818_def_write(device_t dev, u_int reg, u_int val);
56170844Smarius
57137821Smarius/* Chip attach function */
58137821Smariusint mc146818_attach(device_t);
59137821Smarius
60137821Smarius/* Methods for the clock interface */
61137821Smarius#ifdef notyet
62201008Smariusint mc146818_getsecs(device_t dev, int *secp);
63137821Smarius#endif
64201008Smariusint mc146818_gettime(device_t dev, struct timespec *ts);
65201008Smariusint mc146818_settime(device_t dev, struct timespec *ts);
66