1 /*
2  * Copyright (C) 2017-2020 Alibaba Group Holding Limited
3  */
4 
5 /******************************************************************************
6  * @file     drv/sasc.h
7  * @brief    Header File for SASC driver
8  * @version  V1.0
9  * @date     02. June 2020
10  * @model    sasc
11  ******************************************************************************/
12 #ifndef _DRV_SASC_H_
13 #define _DRV_SASC_H_
14 
15 
16 #include <stdint.h>
17 #include <drv/common.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 typedef enum {
23     SASC_RW = 0,
24     SASC_RO = 1,
25     SASC_WO = 2,
26     SASC_AP_DENY = 3
27 } csi_sasc_ap_t;
28 
29 typedef enum {
30     SASC_DI = 0,
31     SASC_DO = 1,
32     SASC_IO = 2,
33     SASC_DI_DENY = 3
34 } csi_sasc_di_t;
35 
36 typedef enum {
37     SASC_RAM_4B = 5,
38     SASC_RAM_8B = 6,
39     SASC_RAM_16B = 7,
40     SASC_RAM_32B = 8,
41     SASC_RAM_64B = 9,
42     SASC_RAM_128B = 10,
43     SASC_RAM_256B = 11,
44     SASC_RAM_512B = 12,
45     SASC_RAM_1KB = 13,
46     SASC_RAM_2KB = 14,
47     SASC_RAM_4KB = 15,
48     SASC_RAM_8KB = 16,
49     SASC_RAM_16KB = 17,
50     SASC_RAM_32KB = 18,
51     SASC_RAM_64KB = 19,
52     SASC_RAM_128KB = 20,
53 } csi_sasc_ram_size_t;
54 
55 typedef enum {
56     SASC_FLASH_1S = 0,
57     SASC_FLASH_2S,
58     SASC_FLASH_4S,
59     SASC_FLASH_8S,
60     SASC_FLASH_16S,
61     SASC_FLASH_32S,
62     SASC_FLASH_64S,
63     SASC_FLASH_128S,
64     SASC_FLASH_256S,
65     SASC_FLASH_512S,
66     SASC_FLASH_1024S,
67     SASC_FLASH_2048S
68 } csi_sasc_flash_size_t;
69 
70 typedef struct {
71     csi_sasc_ap_t   super_ap;
72     csi_sasc_ap_t   user_ap;
73     csi_sasc_di_t   super_di;
74     csi_sasc_di_t   user_di;
75     bool            is_secure;
76 } csi_sasc_attr_t;
77 
78 /**
79   \brief       Config the sasc ram region attribute.
80   \param[in]   region_id  Config region index
81   \param[in]   base_addr  Config region base address.
82   \param[in]   size  config region size.
83   \param[in]   attr  Region attr.
84   \return      Error code
85 */
86 csi_error_t csi_sasc_ram_config(uint8_t region_id, uint32_t base_addr, csi_sasc_ram_size_t size, csi_sasc_attr_t attr);
87 
88 /**
89   \brief       Config the sasc flash region attribute.
90   \param[in]   region_id  Config region index
91   \param[in]   base_addr  Config region base address.
92   \param[in]   size  Config region size.
93   \param[in]   attr  Region attr.
94   \return      Error code
95 */
96 csi_error_t csi_sasc_flash_config(uint8_t region_id, uint32_t base_addr, csi_sasc_flash_size_t size, csi_sasc_attr_t attr);
97 
98 /**
99   \brief       Enable sasc ram config.
100   \param[in]   region_id  Region index
101   \return      error code
102 */
103 csi_error_t csi_sasc_ram_enable(uint8_t region_id);
104 
105 /**
106   \brief       Enable sasc flash config
107   \param[in]   region_id  Config region index
108   \return      error code
109 */
110 csi_error_t csi_sasc_flash_enable(uint8_t region_id);
111 
112 /**
113   \brief       Disable sasc ram config.
114   \param[in]   region_id  Region index
115   \return      error code
116 */
117 csi_error_t csi_sasc_ram_disable(uint8_t region_id);
118 
119 /**
120   \brief       Disable sasc flash config
121   \param[in]   region_id  Region index
122   \return      error code
123 */
124 csi_error_t csi_sasc_flash_disable(uint8_t region_id);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* _DRV_SASC_H_ */
131