1 /* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
2  *
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5  * 1. Redistributions of source code must retain the above copyright
6  * notice, this list of conditions and the following disclaimer.
7  * 2. Redistributions in binary form must reproduce the above copyright
8  * notice, this list of conditions and the following disclaimer in the
9  * documentation and/or other materials provided with the distribution.
10  *
11  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
12  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
13  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
16  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
18  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef DRV_HARDLOCK_H__
27 #define DRV_HARDLOCK_H__
28 #include <rtdef.h>
29 
30 typedef enum k230_hardlock_type
31 {
32     HARDLOCK_GPIO = 0,
33     HARDLOCK_KPU = 1,
34     HARDLOCK_TS = 2,
35     HARDLOCK_DISP = 3,
36     HARDLOCK_DISP_CPU0 = 4,
37     HARDLOCK_DISP_CPU1 = 5,
38     HARDLOCK_HASH = 6,
39     HARDLOCK_AES = 7,
40     HARDLOCK_SM4 = 8,
41     HARDLOCK_PDMA = 9,
42     HARDLOCK_MAX = 128
43 } hardlock_type;
44 
45 #ifdef BSP_USING_HARDLOCK
46 extern int kd_hardlock_lock(hardlock_type num);
47 extern void kd_hardlock_unlock(hardlock_type num);
48 extern int kd_request_lock(hardlock_type num);
49 #else
kd_hardlock_lock(hardlock_type num)50 rt_inline int kd_hardlock_lock(hardlock_type num)
51 { return 0; }
kd_hardlock_unlock(hardlock_type num)52 rt_inline void kd_hardlock_unlock(hardlock_type num)
53 {}
kd_request_lock(hardlock_type num)54 rt_inline int kd_request_lock(hardlock_type num)
55 { return num; }
56 #endif
57 
58 #endif