1219019Sgabor/*	$NetBSD: mc146818var.h,v 1.8 2024/03/06 02:31:44 thorpej Exp $	*/
2219019Sgabor
3219019Sgabor/*-
4219019Sgabor * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
5219019Sgabor *
6219019Sgabor * Redistribution and use in source and binary forms, with or without
7219019Sgabor * modification, are permitted provided that the following conditions
8219019Sgabor * are met:
9219019Sgabor * 1. Redistributions of source code must retain the above copyright
10219019Sgabor *    notice, this list of conditions and the following disclaimer.
11219019Sgabor * 2. Redistributions in binary form must reproduce the above copyright
12219019Sgabor *    notice, this list of conditions and the following disclaimer in the
13219019Sgabor *    documentation and/or other materials provided with the distribution.
14219019Sgabor *
15219019Sgabor * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16219019Sgabor * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17219019Sgabor * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18219019Sgabor * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19219019Sgabor * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20219019Sgabor * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21219019Sgabor * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22219019Sgabor * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23219019Sgabor * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24219019Sgabor * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25219019Sgabor */
26219019Sgabor
27219019Sgabor#ifndef _DEV_IC_MC146818VAR_H_
28219019Sgabor#define	_DEV_IC_MC146818VAR_H_
29219019Sgabor
30219019Sgaborstruct mc146818_softc {
31219019Sgabor	device_t sc_dev;
32219019Sgabor
33219019Sgabor	bus_space_tag_t sc_bst;			/* bus space tag */
34219019Sgabor	bus_space_handle_t sc_bsh;		/* bus space handle */
35219019Sgabor
36219019Sgabor	struct todr_chip_handle sc_handle;	/* TODR handle */
37219019Sgabor	u_int sc_year0;				/* year counter offset */
38219019Sgabor	u_int sc_flag;				/* MD flags */
39219019Sgabor#define MC146818_NO_CENT_ADJUST	0x0001		/* don't adjust century */
40219019Sgabor#define MC146818_BCD		0x0002		/* use BCD mode */
41219019Sgabor#define MC146818_12HR		0x0004		/* use AM/PM mode */
42219019Sgabor
43219019Sgabor	/* MD chip register read/write functions */
44219019Sgabor	u_int (*sc_mcread)(struct mc146818_softc *, u_int);
45219019Sgabor	void (*sc_mcwrite)(struct mc146818_softc *, u_int, u_int);
46219019Sgabor	/* MD century get/set functions */
47219019Sgabor	u_int (*sc_getcent)(struct mc146818_softc *);
48219019Sgabor	void (*sc_setcent)(struct mc146818_softc *, u_int);
49219019Sgabor};
50219019Sgabor
51219019Sgaborvoid	mc146818_attach(struct mc146818_softc *);
52219019Sgaborint	mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
53219019Sgaborint	mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
54219019Sgabor
55219019Sgabor#endif /* _DEV_IC_MC146818VAR_H_ */
56219019Sgabor