• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics 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 
16 #ifndef __WM_SASC_H_
17 #define __WM_SASC_H_
18 
19 #include <core_804.h>
20 #include "wm_regs.h"
21 
22 #define HR_SASC_B1_BASE         (DEVICE_BASE_ADDR + 0xB000)
23 #define HR_SASC_FLASH_BASE      (DEVICE_BASE_ADDR + 0xB100)
24 #define HR_SASC_B2_BASE         (DEVICE_BASE_ADDR + 0xB200)
25 
26 #define _R1_Pos(val, rgn)    (((val)&0x1) << (rgn))
27 #define _R1_Msk(rgn)         (0x1 << (rgn))
28 #define _R2_Pos(val, rgn)    (((val)&0x3) << (2*(rgn)))
29 #define _R2_Msk(rgn)         (0x3 << (2*(rgn)))
30 
31 typedef enum {
32     SASC_UN_SE_USER  =  0,
33     SASC_UN_SE_SUPER,
34     SASC_SE_USER,
35     SASC_SE_SUPER
36 } sasc_car_e;
37 
38 typedef enum {
39     SASC_AP_RW  =  0,
40     SASC_AP_RO,
41     SASC_AP_WO,
42     SASC_AP_DENYALL
43 } sasc_ap_e;
44 
45 typedef enum {
46     SASC_CD_DA_OF  =  0,
47     SASC_CD_DA,
48     SASC_CD_OF,
49     SASC_CD_DENYALL
50 } sasc_cd_e;
51 
52 typedef enum {
53     SASC_REGION_SIZE_4B = 0x5,
54     SASC_REGION_SIZE_8B,
55     SASC_REGION_SIZE_16B,
56     SASC_REGION_SIZE_32B,
57     SASC_REGION_SIZE_64B,
58     SASC_REGION_SIZE_128B,
59     SASC_REGION_SIZE_256B,
60     SASC_REGION_SIZE_512B,
61     SASC_REGION_SIZE_1KB,
62     SASC_REGION_SIZE_2KB,
63     SASC_REGION_SIZE_4KB,
64     SASC_REGION_SIZE_8KB,
65     SASC_REGION_SIZE_16KB,
66     SASC_REGION_SIZE_32KB,
67     SASC_REGION_SIZE_64KB,
68     SASC_REGION_SIZE_128KB,
69     SASC_REGION_SIZE_256KB,
70     SASC_REGION_SIZE_512KB,
71     SASC_REGION_SIZE_1MB,
72     SASC_REGION_SIZE_2MB,
73     SASC_REGION_SIZE_4MB,
74     SASC_REGION_SIZE_8MB
75 } sasc_region_size_e;
76 
77 typedef struct {
78     sasc_car_e car;               /* security and user or super */
79     sasc_ap_e ap;                /* super user and normal user access. */
80     sasc_cd_e cd;                /* instruction fetched excution */
81 } sasc_region_attr_t;
82 
83 typedef struct {
84     __IOM uint32_t CAR;
85     __IOM uint32_t CR;
86     __IOM uint32_t AP0;
87     __IOM uint32_t CD0;
88     __IOM uint32_t AP1;
89     __IOM uint32_t CD1;
90     __IOM uint32_t AP2;
91     __IOM uint32_t CD2;
92     __IOM uint32_t REGION[8];
93 } SASC_Type;
94 
95 #define SASC_B1                 ((SASC_Type    *) HR_SASC_B1_BASE)
96 #define SASC_FLASH              ((SASC_Type    *) HR_SASC_FLASH_BASE)
97 #define SASC_B2                 ((SASC_Type    *) HR_SASC_B2_BASE)
98 
99 /**
100  * @defgroup Driver_APIs Driver APIs
101  * @brief Driver APIs
102  */
103 
104 /**
105  * @addtogroup Driver_APIs
106  * @{
107  */
108 
109 /**
110  * @defgroup SASC_Driver_APIs SASC Driver APIs
111  * @brief SASC driver APIs
112  */
113 
114 /**
115  * @addtogroup SASC_Driver_APIs
116  * @{
117  */
118 
119 /**
120  * @brief          This function is used enable region.
121  *
122  * @param[in]      block    sasc type
123  * @param[in]      idx      index
124  *
125  * @return         None
126  *
127  * @note           None
128  */
129 void wm_sasc_enable_region(SASC_Type *block, uint32_t idx);
130 
131 /**
132  * @brief          This function is used disable region.
133  *
134  * @param[in]      block    sasc type
135  * @param[in]      idx      index
136  *
137  * @return         None
138  *
139  * @note           None
140  */
141 void wm_sasc_disable_region(SASC_Type *block, uint32_t idx);
142 
143 /**
144  * @brief          This function is used set region protect.
145  *
146  * @param[in]      base_addr    base address
147  * @param[in]      idx          index
148  * @param[in]      size         size
149  * @param[in]      attr         attribute
150  *
151  * @return         None
152  *
153  * @note           None
154  */
155 void set_region_protect(uint32_t base_addr, uint32_t idx, sasc_region_size_e size, sasc_region_attr_t *attr);
156 
157 /**
158  * @}
159  */
160 
161 /**
162  * @}
163  */
164 
165 #endif
166