10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5107Seota * Common Development and Distribution License (the "License"). 6*5107Seota * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5107Seota * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _TODDS1307_H 270Sstevel@tonic-gate #define _TODDS1307_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #ifdef __cplusplus 320Sstevel@tonic-gate extern "C" { 330Sstevel@tonic-gate #endif 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <sys/i2c/clients/i2c_client.h> 360Sstevel@tonic-gate 370Sstevel@tonic-gate extern char *v_rtc_addr_reg; 380Sstevel@tonic-gate extern volatile uint8_t *v_rtc_data_reg; 390Sstevel@tonic-gate 400Sstevel@tonic-gate #define DS1307_ADDR_REG *(volatile uint8_t *)v_rtc_addr_reg 410Sstevel@tonic-gate #define DS1307_DATA_REG *(volatile uint8_t *)v_rtc_data_reg 420Sstevel@tonic-gate #define DS1307_NODE_TYPE "ddi_i2c:tod" 430Sstevel@tonic-gate 440Sstevel@tonic-gate struct rtc_t { 450Sstevel@tonic-gate uint8_t rtc_sec; /* Seconds[0-60] */ 460Sstevel@tonic-gate uint8_t rtc_min; /* Minutes[0-60] */ 470Sstevel@tonic-gate uint8_t rtc_hrs; /* Hours[(1-12)/(0-23)] */ 480Sstevel@tonic-gate uint8_t rtc_dow; /* Day of week[1-7] */ 490Sstevel@tonic-gate uint8_t rtc_dom; /* Day of month[(1-28/29/30/31)] */ 500Sstevel@tonic-gate uint8_t rtc_mon; /* Month[1-12] */ 510Sstevel@tonic-gate uint8_t rtc_year; /* Year[00-99] */ 520Sstevel@tonic-gate uint8_t rtc_ctl; /* DS1307 Control register */ 530Sstevel@tonic-gate }; 540Sstevel@tonic-gate 550Sstevel@tonic-gate 560Sstevel@tonic-gate /* 570Sstevel@tonic-gate * Register definitions for RTC driver (DS1307 chip) 580Sstevel@tonic-gate */ 590Sstevel@tonic-gate 600Sstevel@tonic-gate #define RTC_SEC 0x00 /* 00h Second */ 610Sstevel@tonic-gate #define RTC_MIN 0x01 /* 01h Minutes */ 620Sstevel@tonic-gate #define RTC_HRS 0x02 /* 02h Hours */ 630Sstevel@tonic-gate #define RTC_DOW 0x03 /* 03h Day-of-week */ 640Sstevel@tonic-gate #define RTC_DOM 0x04 /* 04h Day-of-month */ 650Sstevel@tonic-gate #define RTC_MON 0x05 /* 05h Month */ 660Sstevel@tonic-gate #define RTC_YEAR 0x06 /* 06h Year */ 670Sstevel@tonic-gate #define RTC_CTL 0x07 /* 07h Control reg. */ 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* Oscillator */ 700Sstevel@tonic-gate 710Sstevel@tonic-gate #define OSCILLATOR_REG 0x00 /* Oscillator Reg Addr */ 720Sstevel@tonic-gate #define OSCILLATOR_DISABLE 0x80 730Sstevel@tonic-gate 740Sstevel@tonic-gate /* per instance based */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate #define TOD_DETACHED 0x00 /* TOD detached */ 770Sstevel@tonic-gate #define TOD_ATTACHED 0x01 /* TOD attached */ 780Sstevel@tonic-gate 790Sstevel@tonic-gate typedef struct ds1307_state { 800Sstevel@tonic-gate i2c_client_hdl_t ds1307_i2c_hdl; 810Sstevel@tonic-gate char i2ctod_name[MAXNAMELEN]; /* node name */ 820Sstevel@tonic-gate kmutex_t i2ctod_mutex; /* protects soft state */ 830Sstevel@tonic-gate int instance; 840Sstevel@tonic-gate dev_info_t *dip; 850Sstevel@tonic-gate uint32_t state; 86*5107Seota ddi_periodic_t cycid; /* periodical callback */ 870Sstevel@tonic-gate struct rtc_t rtc; 880Sstevel@tonic-gate i2c_transfer_t *i2c_tp; 890Sstevel@tonic-gate ddi_softintr_t soft_intr_id; 900Sstevel@tonic-gate uint32_t progress; 910Sstevel@tonic-gate }ds1307_state_t; 920Sstevel@tonic-gate 930Sstevel@tonic-gate #ifdef __cplusplus 940Sstevel@tonic-gate } 950Sstevel@tonic-gate #endif 960Sstevel@tonic-gate 970Sstevel@tonic-gate #endif /* _TODDS1307_H */ 98