ds1553_reg.h revision 194632
10SN/A/*-
22362SN/A * Copyright (C) 2006-2008 Semihalf, Grzegorz Bernacki
30SN/A * All rights reserved.
40SN/A *
50SN/A * Redistribution and use in source and binary forms, with or without
60SN/A * modification, are permitted provided that the following conditions
72362SN/A * are met:
80SN/A * 1. Redistributions of source code must retain the above copyright
92362SN/A *    notice, this list of conditions and the following disclaimer.
100SN/A * 2. Redistributions in binary form must reproduce the above copyright
110SN/A *    notice, this list of conditions and the following disclaimer in the
120SN/A *    documentation and/or other materials provided with the distribution.
130SN/A *
140SN/A * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
150SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
160SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
170SN/A * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
180SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
190SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
200SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
212362SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
222362SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
232362SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
240SN/A * SUCH DAMAGE.
250SN/A *
260SN/A * $FreeBSD: head/sys/powerpc/mpc85xx/ds1553_reg.h 194632 2009-06-22 15:48:47Z raj $
270SN/A */
280SN/A
290SN/A#ifndef _DEV_RTC_DS1553_H_
300SN/A#define _DEV_RTC_DS1553_H_
310SN/A
320SN/A/* DS1553 registers */
330SN/A#define DS1553_NVRAM_SIZE		0x1ff0
340SN/A#define DS1553_OFF_FLAGS		0x1ff0
350SN/A#define DS1553_OFF_ALARM_SECONDS	0x1ff2
360SN/A#define DS1553_OFF_ALARM_MINUTES	0x1ff3
370SN/A#define DS1553_OFF_ALARM_HOURS		0x1ff4
380SN/A#define DS1553_OFF_ALARM_DATE		0x1ff5
3913629Savstepan#define DS1553_OFF_INTERRUPTS		0x1ff6
400SN/A#define DS1553_OFF_WATCHDOG		0x1ff7
410SN/A#define DS1553_OFF_CONTROL		0x1ff8
4213629Savstepan#define DS1553_OFF_SECONDS		0x1ff9
430SN/A#define DS1553_OFF_MINUTES		0x1ffa
440SN/A#define DS1553_OFF_HOURS		0x1ffb
450SN/A#define DS1553_OFF_DAYOFWEEK		0x1ffc
460SN/A#define DS1553_OFF_DATE			0x1ffd
4713629Savstepan#define DS1553_OFF_MONTH		0x1ffe
480SN/A#define DS1553_OFF_YEAR			0x1fff
4913629Savstepan
500SN/A/* dayofweek register's bits */
510SN/A#define DS1553_BIT_FREQ_TEST		0x40 /* frequency test bit */
520SN/A
530SN/A/* seconds register's bit */
540SN/A#define DS1553_BIT_OSC			0x80 /* oscillator start/stop bit */
550SN/A
560SN/A/* control register's bits */
570SN/A#define DS1553_BIT_WRITE		0x80 /* write */
580SN/A#define DS1553_BIT_READ			0x40 /* read */
590SN/A
600SN/A/* watchdog register's bits */
610SN/A#define DS1553_BIT_WATCHDOG		0x80 /* watchdog steering bit */
620SN/A#define DS1553_BIT_BMB4			0x40 /* watchdog multiplier bit4 */
630SN/A#define DS1553_BIT_BMB3			0x20 /* watchdog multiplier bit3 */
640SN/A#define DS1553_BIT_BMB2			0x10 /* watchdog multiplier bit2 */
650SN/A#define DS1553_BIT_BMB1			0x8  /* watchdog multiplier bit1 */
660SN/A#define DS1553_BIT_BMB0			0x4  /* watchdog multiplier bit0 */
6713629Savstepan#define DS1553_BIT_RB1			0x2  /* watchdog resolution bit1 */
680SN/A#define DS1553_BIT_RB0			0x1  /* watchdog resolution bit0 */
6913629Savstepan
700SN/A/* alarm seconds/minutes/hours/date register's bit */
710SN/A#define DS1553_BIT_AM			0x80 /* alarm mask bit */
720SN/A
730SN/A/* flag register's bits */
740SN/A#define DS1553_BIT_BLF			0x10 /* battery flag */
750SN/A#define DS1553_BIT_WF			0x80 /* watchdog flag */
760SN/A
7713629Savstepan/* register's mask */
780SN/A#define DS1553_MASK_MONTH		0x1f
790SN/A#define DS1553_MASK_DATE		0x3f
800SN/A#define DS1553_MASK_DAYOFWEEK		0x7
8113629Savstepan#define DS1553_MASK_HOUR		0x3f
820SN/A#define DS1553_MASK_MINUTES		0x7f
830SN/A#define DS1553_MASK_SECONDS		0x7f
840SN/A
850SN/Astruct ds1553_softc {
860SN/A
870SN/A	bus_space_tag_t		sc_bst;	/* bus space tag */
880SN/A	bus_space_handle_t	sc_bsh;	/* bus space handle */
890SN/A
900SN/A	int			rid;	/* resource id */
910SN/A	struct resource		*res;
920SN/A	struct mtx		sc_mtx;	/* hardware mutex */
930SN/A
940SN/A	uint32_t		year_offset;
950SN/A	/* read/write functions */
960SN/A	uint8_t			(*sc_read)(device_t, bus_size_t);
970SN/A	void			(*sc_write)(device_t, bus_size_t, uint8_t);
980SN/A};
990SN/A
1000SN/A/* device interface */
1010SN/Aint ds1553_attach(device_t);
1020SN/A
1030SN/A/* clock interface */
1040SN/Aint ds1553_gettime(device_t, struct timespec *);
1050SN/Aint ds1553_settime(device_t, struct timespec *);
1060SN/A
1070SN/A#endif /* _DEV_RTC_DS1553_H_ */
1080SN/A