mc146818var.h revision 201008
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 * 3. The name of the author may not be used to endorse or promote products 13137821Smarius * derived from this software without specific prior written permission. 14137821Smarius * 15137821Smarius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16137821Smarius * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17137821Smarius * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18137821Smarius * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19137821Smarius * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20137821Smarius * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21137821Smarius * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22137821Smarius * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23137821Smarius * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24137821Smarius * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25137821Smarius * 26137821Smarius * from: NetBSD: mc146818var.h,v 1.3 2003/11/24 06:20:40 tsutsui Exp 27137821Smarius * 28137821Smarius * $FreeBSD: head/sys/dev/mc146818/mc146818var.h 201008 2009-12-25 22:53:46Z marius $ 29137821Smarius */ 30137821Smarius 31137821Smariusstruct mc146818_softc { 32137821Smarius bus_space_tag_t sc_bst; /* bus space tag */ 33137821Smarius bus_space_handle_t sc_bsh; /* bus space handle */ 34137821Smarius 35146417Smarius struct mtx sc_mtx; /* hardware mutex */ 36146417Smarius 37137821Smarius u_char sc_rega; /* register A */ 38137821Smarius u_char sc_regb; /* register B */ 39137821Smarius 40137821Smarius u_int sc_year0; /* year counter offset */ 41201008Smarius 42137821Smarius u_int sc_flag; /* MD flags */ 43201008Smarius#define MC146818_NO_CENT_ADJUST 0x0001 /* don't adjust century */ 44201008Smarius#define MC146818_BCD 0x0002 /* use BCD mode */ 45201008Smarius#define MC146818_12HR 0x0004 /* use AM/PM mode */ 46137821Smarius 47137821Smarius /* MD chip register read/write functions */ 48201008Smarius u_int (*sc_mcread)(device_t dev, u_int reg); 49201008Smarius void (*sc_mcwrite)(device_t dev, u_int reg, u_int val); 50137821Smarius /* MD century get/set functions */ 51201008Smarius u_int (*sc_getcent)(device_t dev); 52201008Smarius void (*sc_setcent)(device_t dev, u_int cent); 53137821Smarius}; 54137821Smarius 55170844Smarius/* Default read/write functions */ 56201008Smariusu_int mc146818_def_read(device_t dev, u_int reg); 57201008Smariusvoid mc146818_def_write(device_t dev, u_int reg, u_int val); 58170844Smarius 59137821Smarius/* Chip attach function */ 60137821Smariusint mc146818_attach(device_t); 61137821Smarius 62137821Smarius/* Methods for the clock interface */ 63137821Smarius#ifdef notyet 64201008Smariusint mc146818_getsecs(device_t dev, int *secp); 65137821Smarius#endif 66201008Smariusint mc146818_gettime(device_t dev, struct timespec *ts); 67201008Smariusint mc146818_settime(device_t dev, struct timespec *ts); 68