1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _TODM5819_H 28*0Sstevel@tonic-gate #define _TODM5819_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate extern char *v_rtc_addr_reg; 37*0Sstevel@tonic-gate extern volatile uint8_t *v_rtc_data_reg; 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate #ifdef DEBUG 40*0Sstevel@tonic-gate #include <sys/promif.h> 41*0Sstevel@tonic-gate #define DPRINTF if (m5819_debug_flags) prom_printf 42*0Sstevel@tonic-gate #else 43*0Sstevel@tonic-gate #define DPRINTF 44*0Sstevel@tonic-gate #endif /* DEBUG */ 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate #define M5819_ADDR_REG *(volatile uint8_t *)v_rtc_addr_reg 47*0Sstevel@tonic-gate #define M5819_DATA_REG *(volatile uint8_t *)v_rtc_data_reg 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Definitions for Real Time Clock driver (m5819 chip). 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate /* 55*0Sstevel@tonic-gate * Common registers between Banks 0, 1, and 2. 56*0Sstevel@tonic-gate */ 57*0Sstevel@tonic-gate #define RTC_SEC 0x0 /* Seconds */ 58*0Sstevel@tonic-gate #define RTC_ASEC 0x1 /* Seconds Alarm */ 59*0Sstevel@tonic-gate #define RTC_MIN 0x2 /* Minutes */ 60*0Sstevel@tonic-gate #define RTC_AMIN 0x3 /* Minutes Alarm */ 61*0Sstevel@tonic-gate #define RTC_HRS 0x4 /* Hours */ 62*0Sstevel@tonic-gate #define RTC_AHRS 0x5 /* Hours Alarm */ 63*0Sstevel@tonic-gate #define RTC_DOW 0x6 /* Day-of-Week */ 64*0Sstevel@tonic-gate #define RTC_DOM 0x7 /* Day-of-Month */ 65*0Sstevel@tonic-gate #define RTC_MON 0x8 /* Month */ 66*0Sstevel@tonic-gate #define RTC_YEAR 0x9 /* Year */ 67*0Sstevel@tonic-gate #define RTC_A 0xa /* Control Register A */ 68*0Sstevel@tonic-gate #define RTC_B 0xb /* Control Register B */ 69*0Sstevel@tonic-gate #define RTC_C 0xc /* Control Register C */ 70*0Sstevel@tonic-gate #define RTC_D 0xd /* Control Register D */ 71*0Sstevel@tonic-gate #define RTC_CENTURY 0x32 /* Century */ 72*0Sstevel@tonic-gate 73*0Sstevel@tonic-gate /* 74*0Sstevel@tonic-gate * Control register A definitions 75*0Sstevel@tonic-gate */ 76*0Sstevel@tonic-gate #define RTC_DIV0 0x10 /* Bank Select */ 77*0Sstevel@tonic-gate #define RTC_DIV1 0x20 /* Oscillator enable */ 78*0Sstevel@tonic-gate #define RTC_DIV2 0x40 /* Countdown chain */ 79*0Sstevel@tonic-gate #define RTC_UIP 0x80 /* Update in progress bit */ 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* 82*0Sstevel@tonic-gate * Control register B definitions 83*0Sstevel@tonic-gate */ 84*0Sstevel@tonic-gate #define RTC_DSE 0x01 /* Daylight Savings Enable */ 85*0Sstevel@tonic-gate #define RTC_HM 0x02 /* Hour mode, 1 = 24 hour, 0 = 12 hour */ 86*0Sstevel@tonic-gate #define RTC_DM 0x04 /* Date mode, 1 = binary, 0 = BCD */ 87*0Sstevel@tonic-gate #define RTC_UIE 0x10 /* Update-ended Interrupt Enable */ 88*0Sstevel@tonic-gate #define RTC_AIE 0x20 /* Alarm Interrupt Enable */ 89*0Sstevel@tonic-gate #define RTC_PIE 0x40 /* Periodic Interrupt Enable */ 90*0Sstevel@tonic-gate #define RTC_SET 0x80 /* Stop updates for time set */ 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* 93*0Sstevel@tonic-gate * Control Register C definitions 94*0Sstevel@tonic-gate */ 95*0Sstevel@tonic-gate #define RTC_UF 0x10 /* UF flag bit */ 96*0Sstevel@tonic-gate #define RTC_AF 0x20 /* AF flag bit */ 97*0Sstevel@tonic-gate #define RTC_PF 0x40 /* PF flag bit */ 98*0Sstevel@tonic-gate #define RTC_IRQF 0x80 /* IRQ flag */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* 101*0Sstevel@tonic-gate * Control Register D definitions 102*0Sstevel@tonic-gate */ 103*0Sstevel@tonic-gate #define RTC_VRT 0x80 /* Valid RAM and time bit */ 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate /* 107*0Sstevel@tonic-gate * Bank 2 Registers 108*0Sstevel@tonic-gate */ 109*0Sstevel@tonic-gate #define APC_APCR1 0x40 /* APC Control Register 1 */ 110*0Sstevel@tonic-gate #define APC_APCR2 0x41 /* APC Control Register 2 */ 111*0Sstevel@tonic-gate #define APC_APSR 0x42 /* APC Status Register */ 112*0Sstevel@tonic-gate #define APC_WDWR 0x43 /* Wake up Day of Week */ 113*0Sstevel@tonic-gate #define APC_WDMR 0x44 /* Wake up Date of Month */ 114*0Sstevel@tonic-gate #define APC_WMR 0x45 /* Wake up Month */ 115*0Sstevel@tonic-gate #define APC_WYR 0x46 /* Wake up Year */ 116*0Sstevel@tonic-gate #define APC_WCR 0x48 /* Wake up Century */ 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate #define RTC_CADDR 0x51 /* Century address register */ 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate /* 121*0Sstevel@tonic-gate * APC Control Register 1 (APCR1) definitions 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate #define APC_FSTRC 0x40 /* Fail-safe Timer Reset Command */ 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate /* 126*0Sstevel@tonic-gate * APC Control Register 2 (APCR2) definitions 127*0Sstevel@tonic-gate */ 128*0Sstevel@tonic-gate #define APC_TME 0x01 /* Timer Match Enable */ 129*0Sstevel@tonic-gate 130*0Sstevel@tonic-gate /* 131*0Sstevel@tonic-gate * The following two defintions are used in conjuction to wait 132*0Sstevel@tonic-gate * for the UIP bit to clear. 133*0Sstevel@tonic-gate */ 134*0Sstevel@tonic-gate #define TODM5819_UIP_RETRY_THRESH 6 135*0Sstevel@tonic-gate #define TODM5819_UIP_WAIT_USEC 56 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate struct rtc_t { 139*0Sstevel@tonic-gate uint8_t rtc_sec; /* seconds */ 140*0Sstevel@tonic-gate uint8_t rtc_asec; /* alarm seconds */ 141*0Sstevel@tonic-gate uint8_t rtc_min; /* mins */ 142*0Sstevel@tonic-gate uint8_t rtc_amin; /* alarm mins */ 143*0Sstevel@tonic-gate uint8_t rtc_hrs; /* hours */ 144*0Sstevel@tonic-gate uint8_t rtc_ahrs; /* alarm hours */ 145*0Sstevel@tonic-gate uint8_t rtc_dow; /* day of the week */ 146*0Sstevel@tonic-gate uint8_t rtc_dom; /* day of the month */ 147*0Sstevel@tonic-gate uint8_t rtc_mon; /* month */ 148*0Sstevel@tonic-gate uint8_t rtc_year; /* year */ 149*0Sstevel@tonic-gate uint8_t rtc_rega; /* REG A */ 150*0Sstevel@tonic-gate uint8_t rtc_regb; /* REG B */ 151*0Sstevel@tonic-gate uint8_t rtc_regc; /* REG C */ 152*0Sstevel@tonic-gate uint8_t rtc_regd; /* REG D */ 153*0Sstevel@tonic-gate uint8_t rtc_century; /* century */ 154*0Sstevel@tonic-gate uint8_t rtc_adom; /* alarm day */ 155*0Sstevel@tonic-gate uint8_t rtc_amon; /* alarm mon */ 156*0Sstevel@tonic-gate uint8_t apc_apcr1; /* APC Control register 1 */ 157*0Sstevel@tonic-gate uint8_t apc_apcr2; /* APC Control register 2 */ 158*0Sstevel@tonic-gate uint8_t apc_apsr; /* APC Status register */ 159*0Sstevel@tonic-gate uint8_t apc_wdwr; /* Wakeup date of the month */ 160*0Sstevel@tonic-gate uint8_t apc_wdmr; /* Wakeup day of month */ 161*0Sstevel@tonic-gate uint8_t apc_wmr; /* Wakeup month register */ 162*0Sstevel@tonic-gate uint8_t apc_wyr; /* Wakeup year register */ 163*0Sstevel@tonic-gate uint8_t apc_wcr; /* Wakeup Century reg. */ 164*0Sstevel@tonic-gate }; 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate #define RTC_GET8(offset) (M5819_ADDR_REG = (offset), M5819_DATA_REG) 168*0Sstevel@tonic-gate #define RTC_PUT8(offset, value) ( \ 169*0Sstevel@tonic-gate M5819_ADDR_REG = (offset), \ 170*0Sstevel@tonic-gate M5819_DATA_REG = (value)) 171*0Sstevel@tonic-gate 172*0Sstevel@tonic-gate #ifdef __cplusplus 173*0Sstevel@tonic-gate } 174*0Sstevel@tonic-gate #endif 175*0Sstevel@tonic-gate 176*0Sstevel@tonic-gate #endif /* _TODM5819_H */ 177