xref: /titanic_51/usr/src/uts/sun4u/snowbird/sys/todds1307.h (revision dd4eeefdb8e4583c47e28a7f315db6087931ef06)
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	_TODDS1307_H
277c478bd9Sstevel@tonic-gate #define	_TODDS1307_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	DS1307_ADDR_REG		*(volatile uint8_t *)v_rtc_addr_reg
417c478bd9Sstevel@tonic-gate #define	DS1307_DATA_REG		*(volatile uint8_t *)v_rtc_data_reg
427c478bd9Sstevel@tonic-gate #define	DS1307_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_ctl;	/* DS1307 Control register */
537c478bd9Sstevel@tonic-gate };
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Register definitions for RTC driver (DS1307 chip)
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate #define	RTC_SEC		0x00	/* 00h Second */
617c478bd9Sstevel@tonic-gate #define	RTC_MIN		0x01	/* 01h Minutes */
627c478bd9Sstevel@tonic-gate #define	RTC_HRS		0x02	/* 02h Hours */
637c478bd9Sstevel@tonic-gate #define	RTC_DOW		0x03	/* 03h Day-of-week */
647c478bd9Sstevel@tonic-gate #define	RTC_DOM		0x04	/* 04h Day-of-month */
657c478bd9Sstevel@tonic-gate #define	RTC_MON		0x05	/* 05h Month */
667c478bd9Sstevel@tonic-gate #define	RTC_YEAR	0x06	/* 06h Year */
677c478bd9Sstevel@tonic-gate #define	RTC_CTL		0x07	/* 07h Control reg. */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* Oscillator */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	OSCILLATOR_REG		0x00	/* Oscillator Reg Addr */
727c478bd9Sstevel@tonic-gate #define	OSCILLATOR_DISABLE	0x80
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* per instance based */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate #define	TOD_DETACHED		0x00	/* TOD detached */
777c478bd9Sstevel@tonic-gate #define	TOD_ATTACHED		0x01	/* TOD attached */
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate typedef struct ds1307_state {
807c478bd9Sstevel@tonic-gate 	i2c_client_hdl_t	ds1307_i2c_hdl;
817c478bd9Sstevel@tonic-gate 	char			i2ctod_name[MAXNAMELEN];  /* node name */
827c478bd9Sstevel@tonic-gate 	kmutex_t		i2ctod_mutex;   /* protects soft state */
837c478bd9Sstevel@tonic-gate 	int			instance;
847c478bd9Sstevel@tonic-gate 	dev_info_t		*dip;
857c478bd9Sstevel@tonic-gate 	uint32_t		state;
86*dd4eeefdSeota 	ddi_periodic_t		cycid; /* periodical callback */
877c478bd9Sstevel@tonic-gate 	struct rtc_t		rtc;
887c478bd9Sstevel@tonic-gate 	i2c_transfer_t		*i2c_tp;
897c478bd9Sstevel@tonic-gate 	ddi_softintr_t   	soft_intr_id;
907c478bd9Sstevel@tonic-gate 	uint32_t		progress;
917c478bd9Sstevel@tonic-gate }ds1307_state_t;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
947c478bd9Sstevel@tonic-gate }
957c478bd9Sstevel@tonic-gate #endif
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #endif	/* _TODDS1307_H */
98