mc146818var.h revision 201008
1251881Speter/*- 2251881Speter * Copyright (c) 2003 Izumi Tsutsui. All rights reserved. 3251881Speter * 4251881Speter * Redistribution and use in source and binary forms, with or without 5251881Speter * modification, are permitted provided that the following conditions 6251881Speter * are met: 7251881Speter * 1. Redistributions of source code must retain the above copyright 8251881Speter * notice, this list of conditions and the following disclaimer. 9251881Speter * 2. Redistributions in binary form must reproduce the above copyright 10251881Speter * notice, this list of conditions and the following disclaimer in the 11251881Speter * documentation and/or other materials provided with the distribution. 12251881Speter * 3. The name of the author may not be used to endorse or promote products 13251881Speter * derived from this software without specific prior written permission. 14251881Speter * 15251881Speter * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16251881Speter * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17251881Speter * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18251881Speter * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19251881Speter * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20251881Speter * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21251881Speter * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22251881Speter * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23251881Speter * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24251881Speter * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25251881Speter * 26251881Speter * from: NetBSD: mc146818var.h,v 1.3 2003/11/24 06:20:40 tsutsui Exp 27251881Speter * 28251881Speter * $FreeBSD: head/sys/dev/mc146818/mc146818var.h 201008 2009-12-25 22:53:46Z marius $ 29251881Speter */ 30251881Speter 31251881Speterstruct mc146818_softc { 32251881Speter bus_space_tag_t sc_bst; /* bus space tag */ 33251881Speter bus_space_handle_t sc_bsh; /* bus space handle */ 34251881Speter 35251881Speter struct mtx sc_mtx; /* hardware mutex */ 36251881Speter 37251881Speter u_char sc_rega; /* register A */ 38251881Speter u_char sc_regb; /* register B */ 39251881Speter 40251881Speter u_int sc_year0; /* year counter offset */ 41251881Speter 42251881Speter u_int sc_flag; /* MD flags */ 43251881Speter#define MC146818_NO_CENT_ADJUST 0x0001 /* don't adjust century */ 44251881Speter#define MC146818_BCD 0x0002 /* use BCD mode */ 45251881Speter#define MC146818_12HR 0x0004 /* use AM/PM mode */ 46251881Speter 47251881Speter /* MD chip register read/write functions */ 48251881Speter u_int (*sc_mcread)(device_t dev, u_int reg); 49251881Speter void (*sc_mcwrite)(device_t dev, u_int reg, u_int val); 50251881Speter /* MD century get/set functions */ 51251881Speter u_int (*sc_getcent)(device_t dev); 52251881Speter void (*sc_setcent)(device_t dev, u_int cent); 53251881Speter}; 54251881Speter 55251881Speter/* Default read/write functions */ 56251881Speteru_int mc146818_def_read(device_t dev, u_int reg); 57251881Spetervoid mc146818_def_write(device_t dev, u_int reg, u_int val); 58251881Speter 59251881Speter/* Chip attach function */ 60251881Speterint mc146818_attach(device_t); 61251881Speter 62251881Speter/* Methods for the clock interface */ 63251881Speter#ifdef notyet 64251881Speterint mc146818_getsecs(device_t dev, int *secp); 65251881Speter#endif 66251881Speterint mc146818_gettime(device_t dev, struct timespec *ts); 67251881Speterint mc146818_settime(device_t dev, struct timespec *ts); 68251881Speter