Home | History | Annotate | Line # | Download | only in cortex
      1  1.3  skrll /*	$NetBSD: a9tmr_reg.h,v 1.3 2021/10/02 20:52:09 skrll Exp $	*/
      2  1.1   matt /*-
      3  1.1   matt  * Copyright (c) 2012 The NetBSD Foundation, Inc.
      4  1.1   matt  * All rights reserved.
      5  1.1   matt  *
      6  1.1   matt  * This code is derived from software contributed to The NetBSD Foundation
      7  1.1   matt  * by Matt Thomas of 3am Software Foundry.
      8  1.1   matt  *
      9  1.1   matt  * Redistribution and use in source and binary forms, with or without
     10  1.1   matt  * modification, are permitted provided that the following conditions
     11  1.1   matt  * are met:
     12  1.1   matt  * 1. Redistributions of source code must retain the above copyright
     13  1.1   matt  *    notice, this list of conditions and the following disclaimer.
     14  1.1   matt  * 2. Redistributions in binary form must reproduce the above copyright
     15  1.1   matt  *    notice, this list of conditions and the following disclaimer in the
     16  1.1   matt  *    documentation and/or other materials provided with the distribution.
     17  1.1   matt  *
     18  1.1   matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  1.1   matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  1.1   matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  1.1   matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  1.1   matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  1.1   matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  1.1   matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  1.1   matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  1.1   matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  1.1   matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  1.1   matt  * POSSIBILITY OF SUCH DAMAGE.
     29  1.1   matt  */
     30  1.1   matt 
     31  1.1   matt /*
     32  1.1   matt  * ARM MPCORE Global Timer Register Definitions
     33  1.1   matt  *
     34  1.1   matt  * These registers are accessible through a dedicated internal bus.
     35  1.1   matt  * All accesses must be done in a little-endian manner.
     36  1.1   matt  * The base address of the pages containing these registers is defined
     37  1.1   matt  * by the pins PERIPHBASE[31:13] which can be obtained by doing a
     38  1.1   matt  *	MRC p15,4,<Rd>,c15,c0,0; Read Configuration Base Address Register
     39  1.1   matt  *	(except cortex-A9 uniprocessor)
     40  1.1   matt  *
     41  1.1   matt  */
     42  1.1   matt 
     43  1.1   matt #ifndef _ARM_CORTEX_A9TMR_REG_H_
     44  1.1   matt #define	_ARM_CORTEX_A9TMR_REG_H_
     45  1.1   matt 
     46  1.1   matt #define	TMR_GLOBAL_BASE		0x0200	// Offset in PeriphBase
     47  1.1   matt #define	TMR_PRIVATE_BASE	0x0600
     48  1.1   matt #define	TMR_WDOG_BASE		0x0620
     49  1.1   matt #define	TMR_GLOBAL_SIZE		0x0100
     50  1.1   matt #define	TMR_PRIVATE_SIZE	0x0020
     51  1.1   matt #define	TMR_WDOG_SIZE		0x0020
     52  1.1   matt 
     53  1.1   matt /*
     54  1.1   matt  * F(timer) = PeriphClk / ((PreScaler_Value + 1) * Load_Value + 1))
     55  1.1   matt  */
     56  1.1   matt #define	TMR_LOAD		0x0000	// Timer Load Register
     57  1.1   matt #define	TMR_CTR			0x0004	// Timer Counter Register
     58  1.1   matt #define	TMR_CTL			0x0008	// Timer Control Register
     59  1.1   matt #define	TMR_INT			0x000C	// Timer Interrupt Status
     60  1.2  skrll #define	TMR_WDOGRST		0x0010  // Timer Reset Status (WDOG only)
     61  1.1   matt #define	TMR_WDOGDIS		0x0014  // [WO] Timer Disable (WDOG only)
     62  1.1   matt 
     63  1.1   matt #define	TMR_CTL_PRESCALER	__BITS(15,8)
     64  1.1   matt #define	TMR_CTL_WDOG_MODE	__BIT(3) // WDOG mode
     65  1.1   matt #define	TMR_CTL_INT_ENABLE	__BIT(2) // INT 29/30 is enabled
     66  1.1   matt #define	TMR_CTL_AUTO_RELOAD	__BIT(1)
     67  1.1   matt #define	TMR_CTL_ENABLE		__BIT(0)
     68  1.1   matt 
     69  1.1   matt #define	TMR_INT_EVENT		__BIT(0) // [W1C] timer reached 0
     70  1.1   matt #define	TMR_RST_EVENT		__BIT(0) // [W1C] wdog timer reached 0
     71  1.1   matt 
     72  1.1   matt #define	TMR_WDOG_DISABLE_MAGIC1	0x12345678
     73  1.1   matt #define	TMR_WDOG_DISABLE_MAGIC2	0x87654321
     74  1.1   matt 
     75  1.1   matt /*
     76  1.1   matt  * Global Timer is a 64-bit incrementing counter.  As much as we'd like to
     77  1.1   matt  * be able to use LDRD for loading the 64-bit counter, we aren't allowed to.
     78  1.1   matt  */
     79  1.1   matt #define	TMR_GBL_CTR_L		0x000 // Global Timer 64-bit Lower Value
     80  1.1   matt #define	TMR_GBL_CTR_U		0x004 // Global Timer 64-bit Upper Timer
     81  1.1   matt #define	TMR_GBL_CTL		0x008 // Global Timer Control
     82  1.1   matt #define	TMR_GBL_INT		0x00c // [L] Global Timer Interrupt Status
     83  1.1   matt #define	TMR_GBL_CMP_L		0x010 // [L] Global Timer 64-bit Comparator Low
     84  1.1   matt #define	TMR_GBL_CMP_H		0x014 // [L] Global Timer 64-bit Comparator High
     85  1.1   matt #define	TMR_GBL_AUTOINC		0x018 // [L] Global Timer Auto-Increment
     86  1.1   matt 
     87  1.1   matt #define	TMR_GBL_CTL_PRESCALER	__BIT(15,8)
     88  1.1   matt #define	TMR_GBL_CTL_AUTO_INC	__BIT(3) // Auto Increment is enabled
     89  1.1   matt #define	TMR_GBL_CTL_INT_ENABLE	__BIT(2) // [banked] INT 27 is enabled
     90  1.3  skrll #define	TMR_GBL_CTL_CMP_ENABLE	__BIT(1) // [banked]
     91  1.1   matt #define	TMR_GBL_CTL_ENABLE	__BIT(0)
     92  1.1   matt 
     93  1.1   matt #endif /* !_ARM_CORTEX_A9TMR_REG_H_ */
     94