1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _TODDS1337_H 28*7c478bd9Sstevel@tonic-gate #define _TODDS1337_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/cyclic.h> 37*7c478bd9Sstevel@tonic-gate #include <sys/i2c/clients/i2c_client.h> 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate extern char *v_rtc_addr_reg; 40*7c478bd9Sstevel@tonic-gate extern volatile uint8_t *v_rtc_data_reg; 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #define DS1337_ADDR_REG *(volatile uint8_t *)v_rtc_addr_reg 43*7c478bd9Sstevel@tonic-gate #define DS1337_DATA_REG *(volatile uint8_t *)v_rtc_data_reg 44*7c478bd9Sstevel@tonic-gate #define DS1337_NODE_TYPE "ddi_i2c:tod" 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate struct rtc_t { 47*7c478bd9Sstevel@tonic-gate uint8_t rtc_sec; /* Seconds[0-60] */ 48*7c478bd9Sstevel@tonic-gate uint8_t rtc_min; /* Minutes[0-60] */ 49*7c478bd9Sstevel@tonic-gate uint8_t rtc_hrs; /* Hours[(1-12)/(0-23)] */ 50*7c478bd9Sstevel@tonic-gate uint8_t rtc_dow; /* Day of week[1-7] */ 51*7c478bd9Sstevel@tonic-gate uint8_t rtc_dom; /* Day of month[(1-28/29/30/31)] */ 52*7c478bd9Sstevel@tonic-gate uint8_t rtc_mon; /* Month[1-12] */ 53*7c478bd9Sstevel@tonic-gate uint8_t rtc_year; /* Year[00-99] */ 54*7c478bd9Sstevel@tonic-gate uint8_t rtc_asec; /* Alarm #1 seconds */ 55*7c478bd9Sstevel@tonic-gate uint8_t rtc_amin; /* Alarm #1 minutes */ 56*7c478bd9Sstevel@tonic-gate uint8_t rtc_ahrs; /* Alarm #1 hours */ 57*7c478bd9Sstevel@tonic-gate uint8_t rtc_aday; /* Alarm #1 day [month/week] */ 58*7c478bd9Sstevel@tonic-gate uint8_t rtc_a2min; /* Alarm #2 minutes */ 59*7c478bd9Sstevel@tonic-gate uint8_t rtc_a2hrs; /* Alarm #2 hours */ 60*7c478bd9Sstevel@tonic-gate uint8_t rtc_a2day; /* Alarm #2 day [month/week] */ 61*7c478bd9Sstevel@tonic-gate uint8_t rtc_ctl; /* DS1337 Control register */ 62*7c478bd9Sstevel@tonic-gate uint8_t rtc_status; /* DS1337 Status register */ 63*7c478bd9Sstevel@tonic-gate }; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate /* 67*7c478bd9Sstevel@tonic-gate * Register definitions for RTC driver (DS1337 chip) 68*7c478bd9Sstevel@tonic-gate */ 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate #define RTC_SEC 0x00 /* 00h Second */ 71*7c478bd9Sstevel@tonic-gate #define RTC_MIN 0x01 /* 01h Minutes */ 72*7c478bd9Sstevel@tonic-gate #define RTC_HRS 0x02 /* 02h Hours */ 73*7c478bd9Sstevel@tonic-gate #define RTC_DOW 0x03 /* 03h Day-of-week */ 74*7c478bd9Sstevel@tonic-gate #define RTC_DOM 0x04 /* 04h Day-of-month */ 75*7c478bd9Sstevel@tonic-gate #define RTC_MON 0x05 /* 05h Month */ 76*7c478bd9Sstevel@tonic-gate #define RTC_YEAR 0x06 /* 06h Year */ 77*7c478bd9Sstevel@tonic-gate #define RTC_ALARM_SEC 0x07 /* 07h Alarm #1 Second */ 78*7c478bd9Sstevel@tonic-gate #define RTC_ALARM_MIN 0x08 /* 08h Alarm #1 Minutes */ 79*7c478bd9Sstevel@tonic-gate #define RTC_ALARM_HRS 0x09 /* 09h Alarm #1 Hours */ 80*7c478bd9Sstevel@tonic-gate #define RTC_ALARM_DAY 0x0a /* 0Ah Alarm #1 Day [month/week] */ 81*7c478bd9Sstevel@tonic-gate #define RTC_CTL 0x0e /* 0Eh Control register */ 82*7c478bd9Sstevel@tonic-gate #define RTC_STATUS 0x0f /* 0Fh Status register */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate #define RTC_DYDT_MASK 0x40 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * Control register definitions 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate #define RTC_CTL_EOSC 0x80 /* Active low */ 91*7c478bd9Sstevel@tonic-gate #define RTC_CTL_RS2 0x10 92*7c478bd9Sstevel@tonic-gate #define RTC_CTL_RS1 0x08 93*7c478bd9Sstevel@tonic-gate #define RTC_CTL_INTCN 0x04 94*7c478bd9Sstevel@tonic-gate #define RTC_CTL_A2IE 0x02 95*7c478bd9Sstevel@tonic-gate #define RTC_CTL_A1IE 0x01 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate /* 99*7c478bd9Sstevel@tonic-gate * Status register definitions 100*7c478bd9Sstevel@tonic-gate */ 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #define RTC_STATUS_OSF 0x80 103*7c478bd9Sstevel@tonic-gate #define RTC_STATUS_A2F 0x02 104*7c478bd9Sstevel@tonic-gate #define RTC_STATUS_A1F 0x01 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate /* per instance based */ 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #define TOD_DETACHED 0x00 /* TOD detached */ 109*7c478bd9Sstevel@tonic-gate #define TOD_ATTACHED 0x01 /* TOD attached */ 110*7c478bd9Sstevel@tonic-gate 111*7c478bd9Sstevel@tonic-gate typedef struct ds1337_state { 112*7c478bd9Sstevel@tonic-gate i2c_client_hdl_t ds1337_i2c_hdl; 113*7c478bd9Sstevel@tonic-gate char i2ctod_name[MAXNAMELEN]; /* node name */ 114*7c478bd9Sstevel@tonic-gate kmutex_t i2ctod_mutex; /* protects soft state */ 115*7c478bd9Sstevel@tonic-gate int instance; 116*7c478bd9Sstevel@tonic-gate dev_info_t *dip; 117*7c478bd9Sstevel@tonic-gate uint32_t state; 118*7c478bd9Sstevel@tonic-gate cyclic_id_t cycid; 119*7c478bd9Sstevel@tonic-gate struct rtc_t rtc; 120*7c478bd9Sstevel@tonic-gate i2c_transfer_t *i2c_tp; 121*7c478bd9Sstevel@tonic-gate ddi_softintr_t soft_intr_id; 122*7c478bd9Sstevel@tonic-gate uint32_t progress; 123*7c478bd9Sstevel@tonic-gate }ds1337_state_t; 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 126*7c478bd9Sstevel@tonic-gate } 127*7c478bd9Sstevel@tonic-gate #endif 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate #endif /* _TODDS1337_H */ 130