freebsd-dev/sys/arm/ti/ti_wdt.h
Rui Paulo 2ffc65f982 Add a driver for the TI watchdog.
The TI watchdog timer is present on BeagleBone's.  Since 2014, U-Boot
has been booting the BeagleBone with the watchdog enabled.  We need to
disable it on boot to avoid a spurious reset.
The timer isn't exactly precise, but it will do as a watchdog.  This
is also a reflection of the watchdog(9) API.

In the future, we could handle interrupts, but the watchdog(9) API
needs to be a bit smarter before that can happen.

Differential Revision:	https://reviews.freebsd.org/D965
Reviewed by:	andrew
MFC after:	1 week
Relnotes:	yes
2014-10-18 16:59:21 +00:00

75 lines
3.1 KiB
C

/*-
* Copyright (c) 2014 Rui Paulo <rpaulo@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _TI_WDT_H_
#define _TI_WDT_H_
/* TI WDT registers */
#define TI_WDT_WIDR 0x00 /* Watchdog Identification Register */
#define TI_WDT_WDSC 0x10 /* Watchdog System Control Register */
#define TI_WDT_WDST 0x14 /* Watchdog Status Register */
#define TI_WDT_WISR 0x18 /* Watchdog Interrupt Status Register */
#define TI_WDT_WIER 0x1c /* Watchdog Interrupt Enable Register */
#define TI_WDT_WCLR 0x24 /* Watchdog Control Register */
#define TI_WDT_WCRR 0x28 /* Watchdog Counter Register */
#define TI_WDT_WLDR 0x2c /* Watchdog Load Register */
#define TI_WDT_WTGR 0x30 /* Watchdog Trigger Register */
#define TI_WDT_WWPS 0x34 /* Watchdog Write Posting Register */
#define TI_WDT_WDLY 0x44 /* Watchdog Delay Configuration Reg */
#define TI_WDT_WSPR 0x48 /* Watchdog Start/Stop Register */
#define TI_WDT_WIRQSTATRAW 0x54 /* Watchdog Raw Interrupt Status Reg. */
#define TI_WDT_WIRQSTAT 0x58 /* Watchdog Int. Status Register */
#define TI_WDT_WIRQENSET 0x5c /* Watchdog Int. Enable Set Register */
#define TI_WDT_WIRQENCLR 0x60 /* Watchdog Int. Enable Clear Reg. */
/* WDT_WDSC Register */
#define TI_WDSC_SR (1 << 1) /* Soft reset */
/*
* WDT_WWPS Register
*
* Writes to some registers require synchronisation with a different clock
* domain. The WDT_WWPS register is the place where this synchronisation
* happens.
*/
#define TI_W_PEND_WCLR (1 << 0)
#define TI_W_PEND_WCRR (1 << 1)
#define TI_W_PEND_WLDR (1 << 2)
#define TI_W_PEND_WTGR (1 << 3)
#define TI_W_PEND_WSPR (1 << 4)
#define TI_W_PEND_WDLY (1 << 5)
/* WDT_WIRQENSET Register */
#define TI_IRQ_EN_OVF (1 << 0) /* Overflow interrupt */
#define TI_IRQ_EN_DLY (1 << 1) /* Delay interrupt */
/* WDT_WIRQSTAT Register */
#define TI_IRQ_EV_OVF (1 << 0) /* Overflow event */
#define TI_IRQ_EV_DLY (1 << 1) /* Delay event */
#endif /* _TI_WDT_H_ */