1/* $NetBSD: intersil7170reg.h,v 1.1 2006/10/04 15:04:43 tsutsui Exp $ */ 2 3/*- 4 * Copyright (c) 1996 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Adam Glass. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef _INTERSIL7170REG_H_ 33#define _INTERSIL7170REG_H_ 34 35/* 36 * Driver support for the intersil7170 used in sun[34]s to provide 37 * real time clock and time-of-day support. 38 * 39 * Derived from: datasheet "ICM7170 a uP-Compatible Real-Time Clock" 40 * document #301680-005, Dec 85 41 * 42 * Note that this device provides both time-of-day and interval timer 43 * functionality. Both functions use the same control registers. On top 44 * of that, the command control register is write-only. Currently, this 45 * driver assumes that the interval timer is to be enabled, and hence 46 * always sets/restores the INTERSIL_CMD_IENABLE control bit when 47 * manipulating the TOD. 48 */ 49 50struct intersil_dt { /* from p. 7 of 10 */ 51 uint8_t dt_csec; 52 uint8_t dt_hour; 53 uint8_t dt_min; 54 uint8_t dt_sec; 55 uint8_t dt_month; 56 uint8_t dt_day; 57 uint8_t dt_year; 58 uint8_t dt_dow; 59}; 60 61struct intersil7170 { 62 struct intersil_dt counters; 63 struct intersil_dt clk_ram; /* should be ok as both are word aligned */ 64 uint8_t clk_intr_reg; 65 uint8_t clk_cmd_reg; 66}; 67 68/* Indices to time-of-day clock registers */ 69#define INTERSIL_ICSEC 0 70#define INTERSIL_IHOUR 1 71#define INTERSIL_IMIN 2 72#define INTERSIL_ISEC 3 73#define INTERSIL_IMON 4 74#define INTERSIL_IDAY 5 75#define INTERSIL_IYEAR 6 76#define INTERSIL_IDOW 7 77 78#define INTERSIL_IINTR 16 79#define INTERSIL_ICMD 17 80 81/* bit assignments for command register, p. 6 of 10, write-only */ 82#define INTERSIL_CMD_FREQ_32K 0x0 83#define INTERSIL_CMD_FREQ_1M 0x1 84#define INTERSIL_CMD_FREQ_2M 0x2 85#define INTERSIL_CMD_FREQ_4M 0x3 86 87#define INTERSIL_CMD_12HR_MODE 0x0 88#define INTERSIL_CMD_24HR_MODE 0x4 89 90#define INTERSIL_CMD_STOP 0x0 91#define INTERSIL_CMD_RUN 0x8 92 93#define INTERSIL_CMD_IDISABLE 0x0 94#define INTERSIL_CMD_IENABLE 0x10 95 96#define INTERSIL_CMD_TEST_MODE 0x20 97#define INTERSIL_CMD_NORMAL_MODE 0x0 98 99#define INTERSIL_COMMAND(run, interrupt) \ 100 ((run) | (interrupt) | INTERSIL_CMD_FREQ_32K | \ 101 INTERSIL_CMD_24HR_MODE | INTERSIL_CMD_NORMAL_MODE) 102 103/* bit assignments for interrupt register r/w, p 7 of 10 */ 104 105#define INTERSIL_INTER_ALARM 0x1 /* r/w */ 106#define INTERSIL_INTER_CSECONDS 0x2 /* r/w */ 107#define INTERSIL_INTER_DSECONDS 0x4 /* r/w */ 108#define INTERSIL_INTER_SECONDS 0x8 /* r/w */ 109#define INTERSIL_INTER_MINUTES 0x10 /* r/w */ 110#define INTERSIL_INTER_HOURS 0x20 /* r/w */ 111#define INTERSIL_INTER_DAYS 0x40 /* r/w */ 112#define INTERSIL_INTER_PENDING 0x80 /* read-only */ 113 114#define INTERSIL_INTER_BITS \ 115 "\20\10PENDING\7DAYS\6HRS\5MIN\4SCDS\3DSEC\2CSEC\1ALARM" 116 117#endif /* _INTERSIL7170REG_H_ */ 118