mc146818var.h revision 201009
1234353Sdim/*- 2193323Sed * Copyright (c) 2003 Izumi Tsutsui. All rights reserved. 3193323Sed * 4193323Sed * Redistribution and use in source and binary forms, with or without 5193323Sed * modification, are permitted provided that the following conditions 6193323Sed * are met: 7193323Sed * 1. Redistributions of source code must retain the above copyright 8193323Sed * notice, this list of conditions and the following disclaimer. 9193323Sed * 2. Redistributions in binary form must reproduce the above copyright 10193323Sed * notice, this list of conditions and the following disclaimer in the 11193323Sed * documentation and/or other materials provided with the distribution. 12193323Sed * 13193323Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14193323Sed * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15193323Sed * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16193323Sed * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17193323Sed * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18193323Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19193323Sed * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20193323Sed * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21193323Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22193323Sed * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23193323Sed * 24193323Sed * $NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $ 25193323Sed * 26193323Sed * $FreeBSD: head/sys/dev/mc146818/mc146818var.h 201009 2009-12-25 22:58:43Z marius $ 27193323Sed */ 28193323Sed 29193323Sedstruct mc146818_softc { 30200581Srdivacky bus_space_tag_t sc_bst; /* bus space tag */ 31200581Srdivacky bus_space_handle_t sc_bsh; /* bus space handle */ 32200581Srdivacky 33193323Sed struct mtx sc_mtx; /* hardware mutex */ 34193323Sed 35193323Sed u_char sc_rega; /* register A */ 36193323Sed u_char sc_regb; /* register B */ 37193323Sed 38193323Sed u_int sc_year0; /* year counter offset */ 39198090Srdivacky 40193323Sed u_int sc_flag; /* MD flags */ 41193323Sed#define MC146818_NO_CENT_ADJUST 0x0001 /* don't adjust century */ 42193323Sed#define MC146818_BCD 0x0002 /* use BCD mode */ 43193323Sed#define MC146818_12HR 0x0004 /* use AM/PM mode */ 44193323Sed 45193323Sed /* MD chip register read/write functions */ 46193323Sed u_int (*sc_mcread)(device_t dev, u_int reg); 47193323Sed void (*sc_mcwrite)(device_t dev, u_int reg, u_int val); 48193323Sed /* MD century get/set functions */ 49193323Sed u_int (*sc_getcent)(device_t dev); 50200581Srdivacky void (*sc_setcent)(device_t dev, u_int cent); 51193323Sed}; 52193323Sed 53193323Sed/* Default read/write functions */ 54193323Sedu_int mc146818_def_read(device_t dev, u_int reg); 55193323Sedvoid mc146818_def_write(device_t dev, u_int reg, u_int val); 56193323Sed 57193323Sed/* Chip attach function */ 58193323Sedint mc146818_attach(device_t); 59193323Sed 60200581Srdivacky/* Methods for the clock interface */ 61193323Sed#ifdef notyet 62200581Srdivackyint mc146818_getsecs(device_t dev, int *secp); 63200581Srdivacky#endif 64200581Srdivackyint mc146818_gettime(device_t dev, struct timespec *ts); 65200581Srdivackyint mc146818_settime(device_t dev, struct timespec *ts); 66193323Sed