17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*dd4eeefdSeota * Common Development and Distribution License (the "License"). 6*dd4eeefdSeota * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*dd4eeefdSeota * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _TODDS1337_H 277c478bd9Sstevel@tonic-gate #define _TODDS1337_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/i2c/clients/i2c_client.h> 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate extern char *v_rtc_addr_reg; 387c478bd9Sstevel@tonic-gate extern volatile uint8_t *v_rtc_data_reg; 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #define DS1337_ADDR_REG *(volatile uint8_t *)v_rtc_addr_reg 417c478bd9Sstevel@tonic-gate #define DS1337_DATA_REG *(volatile uint8_t *)v_rtc_data_reg 427c478bd9Sstevel@tonic-gate #define DS1337_NODE_TYPE "ddi_i2c:tod" 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate struct rtc_t { 457c478bd9Sstevel@tonic-gate uint8_t rtc_sec; /* Seconds[0-60] */ 467c478bd9Sstevel@tonic-gate uint8_t rtc_min; /* Minutes[0-60] */ 477c478bd9Sstevel@tonic-gate uint8_t rtc_hrs; /* Hours[(1-12)/(0-23)] */ 487c478bd9Sstevel@tonic-gate uint8_t rtc_dow; /* Day of week[1-7] */ 497c478bd9Sstevel@tonic-gate uint8_t rtc_dom; /* Day of month[(1-28/29/30/31)] */ 507c478bd9Sstevel@tonic-gate uint8_t rtc_mon; /* Month[1-12] */ 517c478bd9Sstevel@tonic-gate uint8_t rtc_year; /* Year[00-99] */ 527c478bd9Sstevel@tonic-gate uint8_t rtc_asec; /* Alarm #1 seconds */ 537c478bd9Sstevel@tonic-gate uint8_t rtc_amin; /* Alarm #1 minutes */ 547c478bd9Sstevel@tonic-gate uint8_t rtc_ahrs; /* Alarm #1 hours */ 557c478bd9Sstevel@tonic-gate uint8_t rtc_aday; /* Alarm #1 day [month/week] */ 567c478bd9Sstevel@tonic-gate uint8_t rtc_a2min; /* Alarm #2 minutes */ 577c478bd9Sstevel@tonic-gate uint8_t rtc_a2hrs; /* Alarm #2 hours */ 587c478bd9Sstevel@tonic-gate uint8_t rtc_a2day; /* Alarm #2 day [month/week] */ 597c478bd9Sstevel@tonic-gate uint8_t rtc_ctl; /* DS1337 Control register */ 607c478bd9Sstevel@tonic-gate uint8_t rtc_status; /* DS1337 Status register */ 617c478bd9Sstevel@tonic-gate }; 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * Register definitions for RTC driver (DS1337 chip) 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #define RTC_SEC 0x00 /* 00h Second */ 697c478bd9Sstevel@tonic-gate #define RTC_MIN 0x01 /* 01h Minutes */ 707c478bd9Sstevel@tonic-gate #define RTC_HRS 0x02 /* 02h Hours */ 717c478bd9Sstevel@tonic-gate #define RTC_DOW 0x03 /* 03h Day-of-week */ 727c478bd9Sstevel@tonic-gate #define RTC_DOM 0x04 /* 04h Day-of-month */ 737c478bd9Sstevel@tonic-gate #define RTC_MON 0x05 /* 05h Month */ 747c478bd9Sstevel@tonic-gate #define RTC_YEAR 0x06 /* 06h Year */ 757c478bd9Sstevel@tonic-gate #define RTC_ALARM_SEC 0x07 /* 07h Alarm #1 Second */ 767c478bd9Sstevel@tonic-gate #define RTC_ALARM_MIN 0x08 /* 08h Alarm #1 Minutes */ 777c478bd9Sstevel@tonic-gate #define RTC_ALARM_HRS 0x09 /* 09h Alarm #1 Hours */ 787c478bd9Sstevel@tonic-gate #define RTC_ALARM_DAY 0x0a /* 0Ah Alarm #1 Day [month/week] */ 797c478bd9Sstevel@tonic-gate #define RTC_CTL 0x0e /* 0Eh Control register */ 807c478bd9Sstevel@tonic-gate #define RTC_STATUS 0x0f /* 0Fh Status register */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate #define RTC_DYDT_MASK 0x40 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * Control register definitions 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate #define RTC_CTL_EOSC 0x80 /* Active low */ 897c478bd9Sstevel@tonic-gate #define RTC_CTL_RS2 0x10 907c478bd9Sstevel@tonic-gate #define RTC_CTL_RS1 0x08 917c478bd9Sstevel@tonic-gate #define RTC_CTL_INTCN 0x04 927c478bd9Sstevel@tonic-gate #define RTC_CTL_A2IE 0x02 937c478bd9Sstevel@tonic-gate #define RTC_CTL_A1IE 0x01 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * Status register definitions 987c478bd9Sstevel@tonic-gate */ 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #define RTC_STATUS_OSF 0x80 1017c478bd9Sstevel@tonic-gate #define RTC_STATUS_A2F 0x02 1027c478bd9Sstevel@tonic-gate #define RTC_STATUS_A1F 0x01 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* per instance based */ 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate #define TOD_DETACHED 0x00 /* TOD detached */ 1077c478bd9Sstevel@tonic-gate #define TOD_ATTACHED 0x01 /* TOD attached */ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate typedef struct ds1337_state { 1107c478bd9Sstevel@tonic-gate i2c_client_hdl_t ds1337_i2c_hdl; 1117c478bd9Sstevel@tonic-gate char i2ctod_name[MAXNAMELEN]; /* node name */ 1127c478bd9Sstevel@tonic-gate kmutex_t i2ctod_mutex; /* protects soft state */ 1137c478bd9Sstevel@tonic-gate int instance; 1147c478bd9Sstevel@tonic-gate dev_info_t *dip; 1157c478bd9Sstevel@tonic-gate uint32_t state; 116*dd4eeefdSeota ddi_periodic_t cycid; /* periodical callback */ 1177c478bd9Sstevel@tonic-gate struct rtc_t rtc; 1187c478bd9Sstevel@tonic-gate i2c_transfer_t *i2c_tp; 1197c478bd9Sstevel@tonic-gate ddi_softintr_t soft_intr_id; 1207c478bd9Sstevel@tonic-gate uint32_t progress; 1217c478bd9Sstevel@tonic-gate }ds1337_state_t; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1247c478bd9Sstevel@tonic-gate } 1257c478bd9Sstevel@tonic-gate #endif 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate #endif /* _TODDS1337_H */ 128