• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Bestechnic (Shanghai) Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef __REG_TIMER_H_
16 #define __REG_TIMER_H_
17 
18 #include "plat_types.h"
19 
20 /* ================================================================================ */
21 /* ================                   Timer (TIM)                  ================ */
22 /* ================================================================================ */
23 struct DUAL_TIMER_T {
24     struct TIMER_T {
25         __IO uint32_t Load;       /* Offset: 0x000 (R/W)  Timer X Load */
26         __I  uint32_t Value;      /* Offset: 0x004 (R/ )  Timer X Counter Current Value */
27         __IO uint32_t Control;    /* Offset: 0x008 (R/W)  Timer X Control */
28         __O  uint32_t IntClr;     /* Offset: 0x00C ( /W)  Timer X Interrupt Clear */
29         __I  uint32_t RIS;        /* Offset: 0x010 (R/ )  Timer X Raw Interrupt Status */
30         __I  uint32_t MIS;        /* Offset: 0x014 (R/ )  Timer X Masked Interrupt Status */
31         __IO uint32_t BGLoad;     /* Offset: 0x018 (R/W)  Background Load Register */
32              uint32_t RESERVED0[1];
33     } timer[2];
34     struct ELAPSED_TIMER_T {
35         __IO uint32_t ElapsedCtrl;
36         __I  uint32_t ElapsedVal;
37              uint32_t RESERVED1[6];
38     } elapsed_timer[2];
39 };
40 
41 #define TIMER_CTRL_EN                   (1 << 7)
42 #define TIMER_CTRL_MODE_PERIODIC        (1 << 6)
43 #define TIMER_CTRL_INTEN                (1 << 5)
44 #define TIMER_CTRL_PRESCALE_DIV_1       (0 << 2)
45 #define TIMER_CTRL_PRESCALE_DIV_16      (1 << 2)
46 #define TIMER_CTRL_PRESCALE_DIV_256     (2 << 2)
47 #define TIMER_CTRL_PRESCALE_MASK        (3 << 2)
48 #define TIMER_CTRL_SIZE_32_BIT          (1 << 1)
49 #define TIMER_CTRL_ONESHOT              (1 << 0)
50 
51 #define TIMER_RIS_RIS                   (1 << 0)
52 
53 #define TIMER_MIS_MIS                   (1 << 0)
54 
55 #define TIMER_ELAPSED_CTRL_EN           (1 << 0)
56 #define TIMER_ELAPSED_CTRL_CLR          (1 << 1)
57 
58 #endif
59 
60