• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Chipsea Technologies (Shenzhen) Corp., 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_DMA_H_
16 #define _REG_DMA_H_
17 
18 #include "chip.h"
19 #include "compiler.h"
20 #include "dbg_assert.h"
21 
22 /* ========================================================================== */
23 /* ================         Direct Memory Access (DMA)       ================ */
24 /* ========================================================================== */
25 typedef struct {
26     __I  uint32_t RESERVED0[6];         /* 0x000 (R)   : Reserved */
27     __I  uint32_t RSR;                  /* 0x018 (R)   : Req St Reg */
28     __I  uint32_t RESERVED1[1017];      /* 0x01C (R)   : Reserved */
29 
30     struct {
31         __IO uint32_t HLTR;             /* 0x000 (R/W) : Hlt Reg */
32         __IO uint32_t RQR;              /* 0x004 (R/W) : ReQ Reg */
33         __IO uint32_t CTLR;             /* 0x008 (R/W) : Ctrl Reg */
34         __IO uint32_t ICSR;             /* 0x00C (R/W) : Int Ctrl & St Reg */
35         __IO uint32_t SAR;              /* 0x010 (R/W) : Src Addr Reg */
36         __IO uint32_t DAR;              /* 0x014 (R/W) : Dest Addr Reg */
37         __IO uint32_t TBL0CR;           /* 0x018 (R/W) : Trans Blk Lvl-0 Cnt Reg */
38         __IO uint32_t TBL1CR;           /* 0x01C (R/W) : Trans Blk Lvl-1 Cnt Reg */
39         __IO uint32_t TBL2CR;           /* 0x020 (R/W) : Trans Blk Lvl-2 Cnt Reg */
40         __IO uint32_t TSR;              /* 0x024 (R/W) : Trans Sz Reg */
41         __IO uint32_t WMAR;             /* 0x028 (R/W) : Wrp Match Addr Reg */
42         __IO uint32_t WJAR;             /* 0x02C (R/W) : Wrp Jump Addr Reg */
43         __IO uint32_t LNAR;             /* 0x030 (R/W) : Lli Node Addr Reg (DWord Align) */
44         __IO uint32_t TBL0SR;           /* 0x034 (R/W) : Trans Blk Lvl-0 Sz Reg */
45         __IO uint32_t TBL1SSR;          /* 0x038 (R/W) : Trans Blk Lvl-1 Src Sz Reg */
46         __IO uint32_t TBL1DSR;          /* 0x03C (R/W) : Trans Blk Lvl-1 Dest Sz Reg */
47     } CH[14];
48     __I  uint32_t RESERVED3[800];       /* 0x380 (R)   : Reserved */
49 
50     __IO uint32_t ERQCSR[24];           /* 0x000 (R/W) : Ex ReQ Ch Sel Reg */
51     __I  uint32_t RESERVED4[40];        /* 0x060 (R)   : Reserved */
52 
53     struct {
54         __I  uint32_t RDMR;             /* 0x100 (R)   : Rd Mon Reg */
55         __I  uint32_t WRMR;             /* 0x104 (R)   : Wr Mon Reg */
56     } CH_ADDR[14];
57 
58     __I  uint32_t RESERVED5[36];        /* 0x170 (R)   : Reserved */
59     __IO uint32_t LLINCR[14];           /* 0x200 (R/W) : LLI Node Cnt Reg */
60 } CS_DMA_TypeDef;
61 
62 /* ========================================================================== */
63 /* ====================         Crypto Engine (CE)       ==================== */
64 /* ========================================================================== */
65 typedef struct {
66     __IO uint32_t AES_KEY_0_ADDR;       /* 0x044 (R/W) : */
67     __IO uint32_t AES_KEY_1_ADDR;       /* 0x048 (R/W) : */
68     __IO uint32_t AES_KEY_2_ADDR;       /* 0x04C (R/W) : */
69     __IO uint32_t AES_KEY_3_ADDR;       /* 0x050 (R/W) : */
70     __IO uint32_t AES_KEY_4_ADDR;       /* 0x054 (R/W) : */
71     __IO uint32_t AES_KEY_5_ADDR;       /* 0x058 (R/W) : */
72     __IO uint32_t AES_KEY_6_ADDR;       /* 0x05C (R/W) : */
73     __IO uint32_t AES_KEY_7_ADDR;       /* 0x060 (R/W) : */
74     __IO uint32_t AES_IV_0_ADDR;        /* 0x064 (R/W) : */
75     __IO uint32_t AES_IV_1_ADDR;        /* 0x068 (R/W) : */
76     __IO uint32_t AES_IV_2_ADDR;        /* 0x06C (R/W) : */
77     __IO uint32_t AES_IV_3_ADDR;        /* 0x070 (R/W) : */
78     __IO uint32_t AES_PLAIN_LEN_H_ADDR; /* 0x074 (R/W) : */
79     __IO uint32_t AES_PLAIN_LEN_L_ADDR; /* 0x078 (R/W) : */
80     __IO uint32_t AES_A_LEN_H_ADDR;     /* 0x07C (R/W) : */
81     __IO uint32_t AES_A_LEN_L_ADDR;     /* 0x080 (R/W) : */
82     __IO uint32_t CE_CTRL_ADDR;         /* 0x084 (R/W) : */
83     __IO uint32_t PKA_REG0_ADDR;        /* 0x088 (R/W) : */
84     __IO uint32_t CE_CLOCK_GATE_CTRL;   /* 0x08C (R/W) : */
85     __I  uint32_t RESERVED0[3];         /* 0x090 (R)   : */
86     __IO uint32_t DMA_MON_SEL;          /* 0x09C (R/W) : */
87     __I  uint32_t RESERVED1[6];         /* 0x0A0 (R)   : */
88     __IO uint32_t CHKSUM_CTRL_ADDR;     /* 0x0B8 (R/W) : */
89     __IO uint32_t CHKSUM_RES_ADDR;      /* 0x0BC (R/W) : */
90     __IO uint32_t HASH_LEN_ADDR;        /* 0x0C0 (R/W) : */
91     __IO uint32_t CE_CTRL2_ADDR;        /* 0x0C4 (R/W) : */
92 } CS_CE_TypeDef;
93 
94 /* ========================================================================== */
95 /* ========================           TRANS          ======================== */
96 /* ========================================================================== */
97 typedef struct {
98     __IO uint32_t TRANS_CTRL0_ADDR;     /* 0x090 (R/W) : */
99     __IO uint32_t TRANS_CTRL1_ADDR;     /* 0x094 (R/W) : */
100     __IO uint32_t TRANS_CLOCK_GATE_CTRL;/* 0x098 (R/W) : */
101 } CS_TRANS_TypeDef;
102 
103 #define CS_CE_OFST     (0x0044)
104 #define CS_TRANS_OFST  (0x0090)
105 
106 static CS_DMA_TypeDef   * const CS_DMA   = ((CS_DMA_TypeDef   *) CS_DMA_BASE);
107 static CS_CE_TypeDef    * const CS_CE    = ((CS_CE_TypeDef    *)(CS_DMA_BASE + CS_CE_OFST));
108 static CS_TRANS_TypeDef * const CS_TRANS = ((CS_TRANS_TypeDef *)(CS_DMA_BASE + CS_TRANS_OFST));
109 
110 /**
111  * CH_HLTR
112  */
113 
114 #define DMA_CH_HALT_SET_POS             (0)
115 #define DMA_CH_HALT_SET_BIT             (0x01UL << DMA_CH_HALT_SET_POS)
116 #define DMA_CH_HALT_STAT_POS            (16)
117 #define DMA_CH_HALT_STAT_BIT            (0x01UL << DMA_CH_HALT_STAT_POS)
118 
dma_ch_hltr_halt_set_getb(int ch_idx)119 __STATIC_INLINE uint32_t dma_ch_hltr_halt_set_getb(int ch_idx)
120 {
121     return (CS_DMA->CH[ch_idx].HLTR & DMA_CH_HALT_SET_BIT);
122 }
123 
dma_ch_hltr_halt_set_setb(int ch_idx)124 __STATIC_INLINE void dma_ch_hltr_halt_set_setb(int ch_idx)
125 {
126     CS_DMA->CH[ch_idx].HLTR |= DMA_CH_HALT_SET_BIT;
127 }
128 
dma_ch_hltr_halt_set_clrb(int ch_idx)129 __STATIC_INLINE void dma_ch_hltr_halt_set_clrb(int ch_idx)
130 {
131     CS_DMA->CH[ch_idx].HLTR &= ~DMA_CH_HALT_SET_BIT;
132 }
133 
dma_ch_hltr_halt_stat_getb(int ch_idx)134 __STATIC_INLINE uint32_t dma_ch_hltr_halt_stat_getb(int ch_idx)
135 {
136     return (CS_DMA->CH[ch_idx].HLTR & DMA_CH_HALT_STAT_BIT);
137 }
138 
139 /**
140  * CH_RQR
141  */
142 
143 #define DMA_CH_SRQ_POS                  (0)
144 #define DMA_CH_SRQ_BIT                  (0x01UL << DMA_CH_SRQ_POS)
145 #define DMA_CH_ERQM_POS                 (1)
146 #define DMA_CH_ERQM_BIT                 (0x01UL << DMA_CH_ERQM_POS)
147 #define DMA_CH_ERQL_POS                 (2)
148 #define DMA_CH_ERQL_BIT                 (0x01UL << DMA_CH_ERQL_POS)
149 
dma_ch_rqr_srq_getb(int ch_idx)150 __STATIC_INLINE uint32_t dma_ch_rqr_srq_getb(int ch_idx)
151 {
152     return (CS_DMA->CH[ch_idx].RQR & DMA_CH_SRQ_BIT);
153 }
154 
dma_ch_rqr_srq_setb(int ch_idx)155 __STATIC_INLINE void dma_ch_rqr_srq_setb(int ch_idx)
156 {
157     CS_DMA->CH[ch_idx].RQR |= DMA_CH_SRQ_BIT;
158 }
159 
dma_ch_rqr_srq_clrb(int ch_idx)160 __STATIC_INLINE void dma_ch_rqr_srq_clrb(int ch_idx)
161 {
162     CS_DMA->CH[ch_idx].RQR &= ~DMA_CH_SRQ_BIT;
163 }
164 
dma_ch_rqr_erqm_getb(int ch_idx)165 __STATIC_INLINE uint32_t dma_ch_rqr_erqm_getb(int ch_idx)
166 {
167     return (CS_DMA->CH[ch_idx].RQR & DMA_CH_ERQM_BIT);
168 }
169 
dma_ch_rqr_erqm_setb(int ch_idx)170 __STATIC_INLINE void dma_ch_rqr_erqm_setb(int ch_idx)
171 {
172     CS_DMA->CH[ch_idx].RQR |= DMA_CH_ERQM_BIT;
173 }
174 
dma_ch_rqr_erqm_clrb(int ch_idx)175 __STATIC_INLINE void dma_ch_rqr_erqm_clrb(int ch_idx)
176 {
177     CS_DMA->CH[ch_idx].RQR &= ~DMA_CH_ERQM_BIT;
178 }
179 
dma_ch_rqr_erql_getb(int ch_idx)180 __STATIC_INLINE uint32_t dma_ch_rqr_erql_getb(int ch_idx)
181 {
182     return (CS_DMA->CH[ch_idx].RQR & DMA_CH_ERQL_BIT);
183 }
184 
dma_ch_rqr_erql_setb(int ch_idx)185 __STATIC_INLINE void dma_ch_rqr_erql_setb(int ch_idx)
186 {
187     CS_DMA->CH[ch_idx].RQR |= DMA_CH_ERQL_BIT;
188 }
189 
dma_ch_rqr_erql_clrb(int ch_idx)190 __STATIC_INLINE void dma_ch_rqr_erql_clrb(int ch_idx)
191 {
192     CS_DMA->CH[ch_idx].RQR &= ~DMA_CH_ERQL_BIT;
193 }
194 
195 /**
196  * CH_CTLR
197  */
198 
199 #define DMA_CH_CHENA_POS                (0)
200 #define DMA_CH_CHENA_BIT                (0x01UL << DMA_CH_CHENA_POS)
201 #define DMA_CH_LSTENA_POS               (4)
202 #define DMA_CH_LSTENA_BIT               (0x01UL << DMA_CH_LSTENA_POS)
203 #define DMA_CH_BUSBU_LSB                (16)
204 #define DMA_CH_BUSBU_WIDTH              (0x02UL)
205 #define DMA_CH_BUSBU_MASK               (((0x01UL << DMA_CH_BUSBU_WIDTH) - 1) << DMA_CH_BUSBU_LSB)
206 
dma_ch_ctlr_get(int ch_idx)207 __STATIC_INLINE uint32_t dma_ch_ctlr_get(int ch_idx)
208 {
209     return (CS_DMA->CH[ch_idx].CTLR);
210 }
211 
dma_ch_ctlr_set(int ch_idx,uint32_t reg_val)212 __STATIC_INLINE void dma_ch_ctlr_set(int ch_idx, uint32_t reg_val)
213 {
214     CS_DMA->CH[ch_idx].CTLR = reg_val;
215 }
216 
dma_ch_ctlr_chena_getb(int ch_idx)217 __STATIC_INLINE uint32_t dma_ch_ctlr_chena_getb(int ch_idx)
218 {
219     return (CS_DMA->CH[ch_idx].CTLR & DMA_CH_CHENA_BIT);
220 }
221 
dma_ch_ctlr_chena_setb(int ch_idx)222 __STATIC_INLINE void dma_ch_ctlr_chena_setb(int ch_idx)
223 {
224     CS_DMA->CH[ch_idx].CTLR |= DMA_CH_CHENA_BIT;
225 }
226 
dma_ch_ctlr_chena_clrb(int ch_idx)227 __STATIC_INLINE void dma_ch_ctlr_chena_clrb(int ch_idx)
228 {
229     CS_DMA->CH[ch_idx].CTLR &= ~DMA_CH_CHENA_BIT;
230 }
231 
232 /**
233  * CH_ICSR
234  */
235 
236 #define DMA_CH_TBL0_IENA_POS                    (0)
237 #define DMA_CH_TBL1_IENA_POS                    (1)
238 #define DMA_CH_TBL2_IENA_POS                    (2)
239 #define DMA_CH_TLL_IENA_POS                     (3)
240 #define DMA_CH_CE_IENA_POS                      (4)
241 #define DMA_CH_TBL0_IRST_POS                    (8)
242 #define DMA_CH_TBL1_IRST_POS                    (9)
243 #define DMA_CH_TBL2_IRST_POS                    (10)
244 #define DMA_CH_TLL_IRST_POS                     (11)
245 #define DMA_CH_CE_IRST_POS                      (12)
246 #define DMA_CH_TBL0_IMST_POS                    (16)
247 #define DMA_CH_TBL1_IMST_POS                    (17)
248 #define DMA_CH_TBL2_IMST_POS                    (18)
249 #define DMA_CH_TLL_IMST_POS                     (19)
250 #define DMA_CH_CE_IMST_POS                      (20)
251 #define DMA_CH_PKAD_IMST_POS                    (22)
252 #define DMA_CH_TBL0_ICLR_POS                    (24)
253 #define DMA_CH_TBL1_ICLR_POS                    (25)
254 #define DMA_CH_TBL2_ICLR_POS                    (26)
255 #define DMA_CH_TLL_ICLR_POS                     (27)
256 #define DMA_CH_CE_ICLR_POS                      (28)
257 #define DMA_CH_PKAD_ICLR_POS                    (30)
258 
259 #define DMA_CH_TBL0_IENA_BIT                    (0x01UL << DMA_CH_TBL0_IENA_POS             )
260 #define DMA_CH_TBL1_IENA_BIT                    (0x01UL << DMA_CH_TBL1_IENA_POS             )
261 #define DMA_CH_TBL2_IENA_BIT                    (0x01UL << DMA_CH_TBL2_IENA_POS             )
262 #define DMA_CH_TLL_IENA_BIT                     (0x01UL << DMA_CH_TLL_IENA_POS              )
263 #define DMA_CH_CE_IENA_BIT                      (0x01UL << DMA_CH_CE_IENA_POS               )
264 #define DMA_CH_TBL0_IRST_BIT                    (0x01UL << DMA_CH_TBL0_IRST_POS     )
265 #define DMA_CH_TBL1_IRST_BIT                    (0x01UL << DMA_CH_TBL1_IRST_POS     )
266 #define DMA_CH_TBL2_IRST_BIT                    (0x01UL << DMA_CH_TBL2_IRST_POS     )
267 #define DMA_CH_TLL_IRST_BIT                     (0x01UL << DMA_CH_TLL_IRST_POS      )
268 #define DMA_CH_CE_IRST_BIT                      (0x01UL << DMA_CH_CE_IRST_POS       )
269 #define DMA_CH_TBL0_IMST_BIT                    (0x01UL << DMA_CH_TBL0_IMST_POS     )
270 #define DMA_CH_TBL1_IMST_BIT                    (0x01UL << DMA_CH_TBL1_IMST_POS     )
271 #define DMA_CH_TBL2_IMST_BIT                    (0x01UL << DMA_CH_TBL2_IMST_POS     )
272 #define DMA_CH_TLL_IMST_BIT                     (0x01UL << DMA_CH_TLL_IMST_POS      )
273 #define DMA_CH_CE_IMST_BIT                      (0x01UL << DMA_CH_CE_IMST_POS       )
274 #define DMA_CH_PKAD_IMST_BIT                    (0x01UL << DMA_CH_PKAD_IMST_POS     )
275 #define DMA_CH_TBL0_ICLR_BIT                    (0x01UL << DMA_CH_TBL0_ICLR_POS     )
276 #define DMA_CH_TBL1_ICLR_BIT                    (0x01UL << DMA_CH_TBL1_ICLR_POS     )
277 #define DMA_CH_TBL2_ICLR_BIT                    (0x01UL << DMA_CH_TBL2_ICLR_POS     )
278 #define DMA_CH_TLL_ICLR_BIT                     (0x01UL << DMA_CH_TLL_ICLR_POS      )
279 #define DMA_CH_CE_ICLR_BIT                      (0x01UL << DMA_CH_CE_ICLR_POS       )
280 #define DMA_CH_PKAD_ICLR_BIT                    (0x01UL << DMA_CH_PKAD_ICLR_POS     )
281 
dma_ch_icsr_get(int ch_idx)282 __STATIC_INLINE uint32_t dma_ch_icsr_get(int ch_idx)
283 {
284     return (CS_DMA->CH[ch_idx].ICSR);
285 }
286 
dma_ch_icsr_set(int ch_idx,uint32_t reg_val)287 __STATIC_INLINE void dma_ch_icsr_set(int ch_idx, uint32_t reg_val)
288 {
289     CS_DMA->CH[ch_idx].ICSR = reg_val;
290 }
291 
dma_ch_icsr_tbl0_iena_getb(int ch_idx)292 __STATIC_INLINE uint32_t dma_ch_icsr_tbl0_iena_getb(int ch_idx)
293 {
294     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL0_IENA_BIT);
295 }
296 
dma_ch_icsr_tbl0_iena_setb(int ch_idx)297 __STATIC_INLINE void dma_ch_icsr_tbl0_iena_setb(int ch_idx)
298 {
299     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL0_IENA_BIT;
300 }
301 
dma_ch_icsr_tbl0_iena_clrb(int ch_idx)302 __STATIC_INLINE void dma_ch_icsr_tbl0_iena_clrb(int ch_idx)
303 {
304     CS_DMA->CH[ch_idx].ICSR &= ~DMA_CH_TBL0_IENA_BIT;
305 }
306 
dma_ch_icsr_tbl1_iena_getb(int ch_idx)307 __STATIC_INLINE uint32_t dma_ch_icsr_tbl1_iena_getb(int ch_idx)
308 {
309     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL1_IENA_BIT);
310 }
311 
dma_ch_icsr_tbl1_iena_setb(int ch_idx)312 __STATIC_INLINE void dma_ch_icsr_tbl1_iena_setb(int ch_idx)
313 {
314     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL1_IENA_BIT;
315 }
316 
dma_ch_icsr_tbl1_iena_clrb(int ch_idx)317 __STATIC_INLINE void dma_ch_icsr_tbl1_iena_clrb(int ch_idx)
318 {
319     CS_DMA->CH[ch_idx].ICSR &= ~DMA_CH_TBL1_IENA_BIT;
320 }
321 
dma_ch_icsr_tbl2_iena_getb(int ch_idx)322 __STATIC_INLINE uint32_t dma_ch_icsr_tbl2_iena_getb(int ch_idx)
323 {
324     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL2_IENA_BIT);
325 }
326 
dma_ch_icsr_tbl2_iena_setb(int ch_idx)327 __STATIC_INLINE void dma_ch_icsr_tbl2_iena_setb(int ch_idx)
328 {
329     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL2_IENA_BIT;
330 }
331 
dma_ch_icsr_tbl2_iena_clrb(int ch_idx)332 __STATIC_INLINE void dma_ch_icsr_tbl2_iena_clrb(int ch_idx)
333 {
334     CS_DMA->CH[ch_idx].ICSR &= ~DMA_CH_TBL2_IENA_BIT;
335 }
336 
dma_ch_icsr_tll_iena_getb(int ch_idx)337 __STATIC_INLINE uint32_t dma_ch_icsr_tll_iena_getb(int ch_idx)
338 {
339     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TLL_IENA_BIT);
340 }
341 
dma_ch_icsr_tll_iena_setb(int ch_idx)342 __STATIC_INLINE void dma_ch_icsr_tll_iena_setb(int ch_idx)
343 {
344     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TLL_IENA_BIT;
345 }
346 
dma_ch_icsr_tll_iena_clrb(int ch_idx)347 __STATIC_INLINE void dma_ch_icsr_tll_iena_clrb(int ch_idx)
348 {
349     CS_DMA->CH[ch_idx].ICSR &= ~DMA_CH_TLL_IENA_BIT;
350 }
351 
dma_ch_icsr_ce_iena_getb(int ch_idx)352 __STATIC_INLINE uint32_t dma_ch_icsr_ce_iena_getb(int ch_idx)
353 {
354     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_CE_IENA_BIT);
355 }
356 
dma_ch_icsr_ce_iena_setb(int ch_idx)357 __STATIC_INLINE void dma_ch_icsr_ce_iena_setb(int ch_idx)
358 {
359     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_CE_IENA_BIT;
360 }
361 
dma_ch_icsr_ce_iena_clrb(int ch_idx)362 __STATIC_INLINE void dma_ch_icsr_ce_iena_clrb(int ch_idx)
363 {
364     CS_DMA->CH[ch_idx].ICSR &= ~DMA_CH_CE_IENA_BIT;
365 }
366 
dma_ch_icsr_tbl0_irst_getb(int ch_idx)367 __STATIC_INLINE uint32_t dma_ch_icsr_tbl0_irst_getb(int ch_idx)
368 {
369     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL0_IRST_BIT);
370 }
371 
dma_ch_icsr_tbl1_irst_getb(int ch_idx)372 __STATIC_INLINE uint32_t dma_ch_icsr_tbl1_irst_getb(int ch_idx)
373 {
374     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL1_IRST_BIT);
375 }
376 
dma_ch_icsr_tbl2_irst_getb(int ch_idx)377 __STATIC_INLINE uint32_t dma_ch_icsr_tbl2_irst_getb(int ch_idx)
378 {
379     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL2_IRST_BIT);
380 }
381 
dma_ch_icsr_tll_irst_getb(int ch_idx)382 __STATIC_INLINE uint32_t dma_ch_icsr_tll_irst_getb(int ch_idx)
383 {
384     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TLL_IRST_BIT);
385 }
386 
dma_ch_icsr_ce_irst_getb(int ch_idx)387 __STATIC_INLINE uint32_t dma_ch_icsr_ce_irst_getb(int ch_idx)
388 {
389     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_CE_IRST_BIT);
390 }
391 
dma_ch_icsr_tbl0_imst_getb(int ch_idx)392 __STATIC_INLINE uint32_t dma_ch_icsr_tbl0_imst_getb(int ch_idx)
393 {
394     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL0_IMST_BIT);
395 }
396 
dma_ch_icsr_tbl1_imst_getb(int ch_idx)397 __STATIC_INLINE uint32_t dma_ch_icsr_tbl1_imst_getb(int ch_idx)
398 {
399     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL1_IMST_BIT);
400 }
401 
dma_ch_icsr_tbl2_imst_getb(int ch_idx)402 __STATIC_INLINE uint32_t dma_ch_icsr_tbl2_imst_getb(int ch_idx)
403 {
404     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TBL2_IMST_BIT);
405 }
406 
dma_ch_icsr_tll_imst_getb(int ch_idx)407 __STATIC_INLINE uint32_t dma_ch_icsr_tll_imst_getb(int ch_idx)
408 {
409     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_TLL_IMST_BIT);
410 }
411 
dma_ch_icsr_cfgerr_int_mask_status_getb(int ch_idx)412 __STATIC_INLINE uint32_t dma_ch_icsr_cfgerr_int_mask_status_getb(int ch_idx)
413 {
414     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_CE_IMST_BIT);
415 }
416 
dma_ch_icsr_pkad_imst_getb(int ch_idx)417 __STATIC_INLINE uint32_t dma_ch_icsr_pkad_imst_getb(int ch_idx)
418 {
419     return (CS_DMA->CH[ch_idx].ICSR & DMA_CH_PKAD_IMST_BIT);
420 }
421 
dma_ch_icsr_tbl0_iclr_setb(int ch_idx)422 __STATIC_INLINE void dma_ch_icsr_tbl0_iclr_setb(int ch_idx)
423 {
424     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL0_ICLR_BIT;
425 }
426 
dma_ch_icsr_tbl1_iclr_setb(int ch_idx)427 __STATIC_INLINE void dma_ch_icsr_tbl1_iclr_setb(int ch_idx)
428 {
429     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL1_ICLR_BIT;
430 }
431 
dma_ch_icsr_tbl2_iclr_setb(int ch_idx)432 __STATIC_INLINE void dma_ch_icsr_tbl2_iclr_setb(int ch_idx)
433 {
434     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TBL2_ICLR_BIT;
435 }
436 
dma_ch_icsr_tll_iclr_setb(int ch_idx)437 __STATIC_INLINE void dma_ch_icsr_tll_iclr_setb(int ch_idx)
438 {
439     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_TLL_ICLR_BIT;
440 }
441 
dma_ch_icsr_ce_iclr_setb(int ch_idx)442 __STATIC_INLINE void dma_ch_icsr_ce_iclr_setb(int ch_idx)
443 {
444     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_CE_ICLR_BIT;
445 }
446 
dma_ch_icsr_pkad_iclr_setb(int ch_idx)447 __STATIC_INLINE void dma_ch_icsr_pkad_iclr_setb(int ch_idx)
448 {
449     CS_DMA->CH[ch_idx].ICSR |= DMA_CH_PKAD_ICLR_BIT;
450 }
451 
452 /**
453  * CH_SAR
454  */
455 
dma_ch_sar_get(int ch_idx)456 __STATIC_INLINE uint32_t dma_ch_sar_get(int ch_idx)
457 {
458     return (CS_DMA->CH[ch_idx].SAR);
459 }
460 
dma_ch_sar_set(int ch_idx,uint32_t reg_val)461 __STATIC_INLINE void dma_ch_sar_set(int ch_idx, uint32_t reg_val)
462 {
463     CS_DMA->CH[ch_idx].SAR = reg_val;
464 }
465 
466 /**
467  * CH_DAR
468  */
469 
dma_ch_dar_get(int ch_idx)470 __STATIC_INLINE uint32_t dma_ch_dar_get(int ch_idx)
471 {
472     return (CS_DMA->CH[ch_idx].DAR);
473 }
474 
dma_ch_dar_set(int ch_idx,uint32_t reg_val)475 __STATIC_INLINE void dma_ch_dar_set(int ch_idx, uint32_t reg_val)
476 {
477     CS_DMA->CH[ch_idx].DAR = reg_val;
478 }
479 
480 /**
481  * CH_TBL0CR
482  */
483 
484 #define DMA_CH_TBL0_CNT_LSB         (0)
485 #define DMA_CH_TBL0_CNT_WIDTH       (0x11UL)
486 #define DMA_CH_TBL0_CNT_MASK        (((0x01UL << DMA_CH_TBL0_CNT_WIDTH) - 1) << DMA_CH_TBL0_CNT_LSB)
487 #define DMA_CH_LASTLLI_POS          (19)
488 #define DMA_CH_LASTLLI_BIT          (0x01UL << DMA_CH_LASTLLI_POS)
489 #define DMA_CH_CONSTSA_POS          (20)
490 #define DMA_CH_CONSTSA_BIT          (0x01UL << DMA_CH_CONSTSA_POS)
491 #define DMA_CH_CONSTDA_POS          (21)
492 #define DMA_CH_CONSTDA_BIT          (0x01UL << DMA_CH_CONSTDA_POS)
493 #define DMA_CH_RQTYP_LSB            (24)
494 #define DMA_CH_RQTYP_WIDTH          (0x02UL)
495 #define DMA_CH_RQTYP_MASK           (((0x01UL << DMA_CH_RQTYP_WIDTH) - 1) << DMA_CH_RQTYP_LSB)
496 #define DMA_CH_DBUSU_LSB            (28)
497 #define DMA_CH_DBUSU_WIDTH          (0x02UL)
498 #define DMA_CH_DBUSU_MASK           (((0x01UL << DMA_CH_DBUSU_WIDTH) - 1) << DMA_CH_DBUSU_LSB)
499 #define DMA_CH_SBUSU_LSB            (30)
500 #define DMA_CH_SBUSU_WIDTH          (0x02UL)
501 #define DMA_CH_SBUSU_MASK           (((0x01UL << DMA_CH_SBUSU_WIDTH) - 1) << DMA_CH_SBUSU_LSB)
502 
dma_ch_tbl0cr_get(int ch_idx)503 __STATIC_INLINE uint32_t dma_ch_tbl0cr_get(int ch_idx)
504 {
505     return (CS_DMA->CH[ch_idx].TBL0CR);
506 }
507 
dma_ch_tbl0cr_set(int ch_idx,uint32_t reg_val)508 __STATIC_INLINE void dma_ch_tbl0cr_set(int ch_idx, uint32_t reg_val)
509 {
510     CS_DMA->CH[ch_idx].TBL0CR = reg_val;
511 }
512 
dma_ch_tbl0cr_tbl0_cnt_getf(int ch_idx)513 __STATIC_INLINE uint32_t dma_ch_tbl0cr_tbl0_cnt_getf(int ch_idx)
514 {
515     return ((CS_DMA->CH[ch_idx].TBL0CR & DMA_CH_TBL0_CNT_MASK) >> DMA_CH_TBL0_CNT_LSB);
516 }
517 
dma_ch_tbl0cr_tbl0_cnt_setf(int ch_idx,uint32_t cnt)518 __STATIC_INLINE void dma_ch_tbl0cr_tbl0_cnt_setf(int ch_idx, uint32_t cnt)
519 {
520     uint32_t local_val;
521     local_val = CS_DMA->CH[ch_idx].TBL0CR & ~DMA_CH_TBL0_CNT_MASK;
522     CS_DMA->CH[ch_idx].TBL0CR = local_val | ((cnt << DMA_CH_TBL0_CNT_LSB) & DMA_CH_TBL0_CNT_MASK);
523 }
524 
dma_ch_tbl0cr_lastlli_getb(int ch_idx)525 __STATIC_INLINE uint32_t dma_ch_tbl0cr_lastlli_getb(int ch_idx)
526 {
527     return (CS_DMA->CH[ch_idx].TBL0CR & DMA_CH_LASTLLI_BIT);
528 }
529 
dma_ch_tbl0cr_lastlli_setb(int ch_idx)530 __STATIC_INLINE void dma_ch_tbl0cr_lastlli_setb(int ch_idx)
531 {
532     CS_DMA->CH[ch_idx].TBL0CR |= DMA_CH_LASTLLI_BIT;
533 }
534 
dma_ch_tbl0cr_lastlli_clrb(int ch_idx)535 __STATIC_INLINE void dma_ch_tbl0cr_lastlli_clrb(int ch_idx)
536 {
537     CS_DMA->CH[ch_idx].TBL0CR &= ~DMA_CH_LASTLLI_BIT;
538 }
539 
540 /**
541  * CH_TBL1CR
542  */
543 
544 #define DMA_CH_TBL1_CNT_LSB             (0)
545 #define DMA_CH_TBL1_CNT_WIDTH           (0x11UL)
546 #define DMA_CH_TBL1_CNT_MASK            (((0x01UL << DMA_CH_TBL1_CNT_WIDTH) - 1) << DMA_CH_TBL1_CNT_LSB)
547 
dma_ch_tbl1cr_get(int ch_idx)548 __STATIC_INLINE uint32_t dma_ch_tbl1cr_get(int ch_idx)
549 {
550     return (CS_DMA->CH[ch_idx].TBL1CR);
551 }
552 
dma_ch_tbl1cr_set(int ch_idx,uint32_t reg_val)553 __STATIC_INLINE void dma_ch_tbl1cr_set(int ch_idx, uint32_t reg_val)
554 {
555     CS_DMA->CH[ch_idx].TBL1CR = reg_val;
556 }
557 
558 /**
559  * CH_TBL2CR
560  */
561 
562 #define DMA_CH_TBL2_CNT_LSB                 (0)
563 #define DMA_CH_TBL2_CNT_WIDTH               (0x1CUL)
564 #define DMA_CH_TBL2_CNT_MASK                (((0x01UL << DMA_CH_TBL2_CNT_WIDTH) - 1) << DMA_CH_TBL2_CNT_LSB)
565 #define DMA_CH_LLI_DEDIC_INT_EN_POS         (28)
566 #define DMA_CH_LLI_DEDIC_INT_EN_BIT         (0x01UL << DMA_CH_LLI_DEDIC_INT_EN_POS)
567 #define DMA_CH_LLI_DEDIC_COUNTER_EN_POS     (29)
568 #define DMA_CH_LLI_DEDIC_COUNTER_EN_BIT     (0x01UL << DMA_CH_LLI_DEDIC_COUNTER_EN_POS)
569 
dma_ch_tbl2cr_get(int ch_idx)570 __STATIC_INLINE uint32_t dma_ch_tbl2cr_get(int ch_idx)
571 {
572     return (CS_DMA->CH[ch_idx].TBL2CR);
573 }
574 
dma_ch_tbl2cr_set(int ch_idx,uint32_t reg_val)575 __STATIC_INLINE void dma_ch_tbl2cr_set(int ch_idx, uint32_t reg_val)
576 {
577     CS_DMA->CH[ch_idx].TBL2CR = reg_val;
578 }
579 
580 /**
581  * CH_TSR
582  */
583 
584 #define DMA_CH_STRANSZ_LSB          (0)
585 #define DMA_CH_STRANSZ_WIDTH        (0x10UL)
586 #define DMA_CH_STRANSZ_MASK         (((0x01UL << DMA_CH_STRANSZ_WIDTH) - 1) << DMA_CH_STRANSZ_LSB)
587 #define DMA_CH_DTRANSZ_LSB          (16)
588 #define DMA_CH_DTRANSZ_WIDTH        (0x10UL)
589 #define DMA_CH_DTRANSZ_MASK         (((0x01UL << DMA_CH_DTRANSZ_WIDTH) - 1) << DMA_CH_DTRANSZ_LSB)
590 
dma_ch_tsr_get(int ch_idx)591 __STATIC_INLINE uint32_t dma_ch_tsr_get(int ch_idx)
592 {
593     return (CS_DMA->CH[ch_idx].TSR);
594 }
595 
dma_ch_tsr_set(int ch_idx,uint32_t reg_val)596 __STATIC_INLINE void dma_ch_tsr_set(int ch_idx, uint32_t reg_val)
597 {
598     CS_DMA->CH[ch_idx].TSR = reg_val;
599 }
600 
601 /**
602  * CH_WMAR
603  */
604 
dma_ch_wmar_get(int ch_idx)605 __STATIC_INLINE uint32_t dma_ch_wmar_get(int ch_idx)
606 {
607     return (CS_DMA->CH[ch_idx].WMAR);
608 }
609 
dma_ch_wmar_set(int ch_idx,uint32_t reg_val)610 __STATIC_INLINE void dma_ch_wmar_set(int ch_idx, uint32_t reg_val)
611 {
612     CS_DMA->CH[ch_idx].WMAR = reg_val;
613 }
614 
615 /**
616  * CH_WJAR
617  */
618 
dma_ch_wjar_get(int ch_idx)619 __STATIC_INLINE uint32_t dma_ch_wjar_get(int ch_idx)
620 {
621     return (CS_DMA->CH[ch_idx].WJAR);
622 }
623 
dma_ch_wjar_set(int ch_idx,uint32_t reg_val)624 __STATIC_INLINE void dma_ch_wjar_set(int ch_idx, uint32_t reg_val)
625 {
626     CS_DMA->CH[ch_idx].WJAR = reg_val;
627 }
628 
629 /**
630  * CH_LNAR
631  */
632 
dma_ch_lnar_get(int ch_idx)633 __STATIC_INLINE uint32_t dma_ch_lnar_get(int ch_idx)
634 {
635     return (CS_DMA->CH[ch_idx].LNAR);
636 }
637 
dma_ch_lnar_set(int ch_idx,uint32_t reg_val)638 __STATIC_INLINE void dma_ch_lnar_set(int ch_idx, uint32_t reg_val)
639 {
640     CS_DMA->CH[ch_idx].LNAR = reg_val;
641 }
642 
643 /**
644  * CH_TBL0SR
645  */
646 
647 #define DMA_CH_STBL0SZ_LSB              (0)
648 #define DMA_CH_STBL0SZ_WIDTH            (0x10UL)
649 #define DMA_CH_STBL0SZ_MASK             (((0x01UL << DMA_CH_STBL0SZ_WIDTH) - 1) << DMA_CH_STBL0SZ_LSB)
650 #define DMA_CH_DTBL0SZ_LSB              (16)
651 #define DMA_CH_DTBL0SZ_WIDTH            (0x10UL)
652 #define DMA_CH_DTBL0SZ_MASK             (((0x01UL << DMA_CH_DTBL0SZ_WIDTH) - 1) << DMA_CH_DTBL0SZ_LSB)
653 
dma_ch_tbl0sr_get(int ch_idx)654 __STATIC_INLINE uint32_t dma_ch_tbl0sr_get(int ch_idx)
655 {
656     return (CS_DMA->CH[ch_idx].TBL0SR);
657 }
658 
dma_ch_tbl0sr_set(int ch_idx,uint32_t reg_val)659 __STATIC_INLINE void dma_ch_tbl0sr_set(int ch_idx, uint32_t reg_val)
660 {
661     CS_DMA->CH[ch_idx].TBL0SR = reg_val;
662 }
663 
664 /**
665  * CH_TBL1SSR
666  */
667 
dma_ch_tbl1ssr_get(int ch_idx)668 __STATIC_INLINE uint32_t dma_ch_tbl1ssr_get(int ch_idx)
669 {
670     return (CS_DMA->CH[ch_idx].TBL1SSR);
671 }
672 
dma_ch_tbl1ssr_set(int ch_idx,uint32_t reg_val)673 __STATIC_INLINE void dma_ch_tbl1ssr_set(int ch_idx, uint32_t reg_val)
674 {
675     CS_DMA->CH[ch_idx].TBL1SSR = reg_val;
676 }
677 
678 /**
679  * CH_TBL1DSR
680  */
681 
dma_ch_tbl1dsr_get(int ch_idx)682 __STATIC_INLINE uint32_t dma_ch_tbl1dsr_get(int ch_idx)
683 {
684     return (CS_DMA->CH[ch_idx].TBL1DSR);
685 }
686 
dma_ch_tbl1dsr_set(int ch_idx,uint32_t reg_val)687 __STATIC_INLINE void dma_ch_tbl1dsr_set(int ch_idx, uint32_t reg_val)
688 {
689     CS_DMA->CH[ch_idx].TBL1DSR = reg_val;
690 }
691 
692 /**
693  * ERQCSR
694  */
695 
dma_erqcsr_set(int erq_idx,int ch_idx)696 __STATIC_INLINE void dma_erqcsr_set(int erq_idx, int ch_idx)
697 {
698     CS_DMA->ERQCSR[erq_idx] = ch_idx + 1;
699 }
700 
701 /**
702  * RSR
703  */
704 
dma_req_status_get(int ch_idx)705 __STATIC_INLINE uint32_t dma_req_status_get(int ch_idx)
706 {
707     return (CS_DMA->RSR & (1 << ch_idx));
708 }
709 
710 /**
711  * CH_LLINCR
712  */
713 
dma_ch_llincr_get(int ch_idx)714 __STATIC_INLINE uint32_t dma_ch_llincr_get(int ch_idx)
715 {
716     return (CS_DMA->LLINCR[ch_idx]);
717 }
718 
719 #define RSA_EN_OFFSET             0
720 #define ECC_EN_OFFSET             1
721 #define RSA_MODE_OFFSET           2
722 #define ECC_MODE_OFFSET           3
723 #define ECC_A_EQ_P3_EN_OFFSET     6
724 #define RSA_KEY_LEN_OFFSET        7
725 #define AES_EN_OFFSET             13
726 #define AES_ENC_DEC_SEL_OFFEST    14
727 #define AES_MODE_OFFEST           15
728 #define AES_KEY_192_OFFEST        18
729 #define AES_KEY_256_OFFEST        19
730 #define HASH_EN_OFFSET            20
731 #define CYPT_CHN_SEL_OFFSET       21
732 #define HASH_ENDIAN_SEL_OFFSET    28
733 #define AES_ENDIAN_SEL_OFFSET     29
734 #define HASH_HW_PAD_EN_OFFSET     0
735 #define HASH_MODE_SEL_OFFSET      1
736 
737 #define DMA_RSA_EN_SET            (0x01UL << RSA_EN_OFFSET)
738 #define DMA_ECC_EN_SET            (0x01UL << ECC_EN_OFFSET)
739 #define DMA_AES_EN_SET            (0x01UL << AES_EN_OFFSET)
740 #define DMA_HASH_EN_SET           (0x01UL << HASH_EN_OFFSET)
741 
742 #define FFT_LEN_OFFSET            0
743 #define FFT_SCALE_OFFSET          3
744 #define FFT_DIR_OFFSET            6
745 #define FFT_EN_OFFSET             7
746 #define TRANS_CHN_SEL_OFFSET      8
747 #define FFT_IN_FORMAT_SEL_OFFSET  14
748 #define FFT_OUT_FORMAT_SEL_OFFSET 15
749 #define FLT_EN_OFFSET             0
750 #define FIR_COFSHW_UPD_OFFSET     1
751 #define SBC_MODE_EN_OFFSET        2
752 #define FIR_COFCOS_UPD_OFFSET     3
753 #define FIR_COFLEN_OFFSET         4
754 #define FLT_LEN_OFFSET            5
755 #define FLT_ORDER_OFFSET          19
756 #define FLT_COFINIT_SEL_OFFSET    24
757 #define FLT_SBC_CHN_SEL_OFFSET    25
758 #define FLT_IN_FORMAT_SEL_OFFSET  26
759 #define FLT_OUT_FORMAT_SEL_OFFSET 27
760 #define SBC_SSAT_EN_OFFSET        28
761 
762 #define DMA_FFT_EN_SET            (0x01UL << FFT_EN_OFFSET)
763 #define DMA_FLT_EN_SET            (0x01UL << FLT_EN_OFFSET)
764 
765 #define CHKSUM_LEN_OFFSET         0
766 #define CHKSUM_EN_OFFSET          16
767 #define CHKSUM_CHN_SEL_OFFSET     17
768 #define CHKSUM_ENDIAN_SEL_OFFSET  23
769 #define CHKSUM_DEST_BYPASS_OFFSET 24
770 #define CHKSUM_CLK_GATE_EN        25
771 #define CHKSUM_CLR_OFFSET         30
772 #define DMA_CHKSUM_EN_SET          (0x01UL << CHKSUM_EN_OFFSET)
773 #define DMA_CHKSUM_CLK_GATE_EN_SET (0x01UL << CHKSUM_CLK_GATE_EN)
774 
775 #define DMA_PKA_CLK_GATE_EN_OFFSET 0
776 #define DMA_AES_CLK_GATE_EN_OFFSET 1
777 #define DMA_HASH_CLK_GATE_EN_OFFSET 2
778 #endif /* _REG_DMA_H_ */
779