Xiaohu.Huang | f78b48b | 2022-01-17 10:41:38 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021-2022 Amlogic, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | */ |
| 6 | |
| 7 | #ifndef N200_FUNC_H |
| 8 | #define N200_FUNC_H |
| 9 | |
| 10 | __BEGIN_DECLS |
| 11 | |
| 12 | #include "n200_timer.h" |
bangzheng.liu | 4d71f92 | 2022-09-29 16:12:20 +0800 | [diff] [blame] | 13 | #ifdef CONFIG_N200_REVA |
| 14 | #include "interrupt_control_pic.h" |
| 15 | #else |
| 16 | #include "interrupt_control_eclic.h" |
| 17 | #endif |
xiaohu.huang | 3826210 | 2022-05-06 22:21:48 +0800 | [diff] [blame] | 18 | #include "gcc_compiler_attributes.h" |
Xiaohu.Huang | f78b48b | 2022-01-17 10:41:38 +0800 | [diff] [blame] | 19 | |
bangzheng.liu | ba6936f | 2023-09-20 17:39:09 +0800 | [diff] [blame^] | 20 | #define PMP_CFG_R_NO (0<<0) |
| 21 | #define PMP_CFG_R_EN (1<<0) |
| 22 | |
| 23 | #define PMP_CFG_W_NO (0<<1) |
| 24 | #define PMP_CFG_W_EN (1<<1) |
| 25 | |
| 26 | #define PMP_CFG_X_NO (0<<2) |
| 27 | #define PMP_CFG_X_EN (1<<2) |
| 28 | |
| 29 | #define PMP_CFG_A_OFF (0<<3) |
| 30 | #define PMP_CFG_A_NA4 (2<<3) |
| 31 | #define PMP_CFG_A_NAPOT (3<<3) |
| 32 | |
| 33 | #define PMP_CFG_L_NO (0<<7) |
| 34 | #define PMP_CFG_L_EN (1<<7) |
| 35 | |
| 36 | /* The size should be the number of 2^n */ |
| 37 | #define NAPOT_SIZE(size) (((size) - 1) >> 3) |
| 38 | |
| 39 | extern uint32_t _text; |
| 40 | extern uint32_t _etext; |
| 41 | |
| 42 | uint32_t config_pmp(void); |
| 43 | |
Xiaohu.Huang | f78b48b | 2022-01-17 10:41:38 +0800 | [diff] [blame] | 44 | void pmp_open_all_space(void); |
| 45 | |
| 46 | void switch_m2u_mode(void); |
| 47 | |
| 48 | uint32_t get_mtime_freq(void); |
| 49 | |
| 50 | uint32_t mtime_lo(void); |
| 51 | |
| 52 | uint32_t mtime_hi(void); |
| 53 | |
| 54 | uint64_t get_mtime_value(void); |
| 55 | |
| 56 | uint64_t get_instret_value(void); |
| 57 | |
| 58 | uint64_t get_cycle_value(void); |
| 59 | |
| 60 | uint32_t get_cpu_freq(void); |
| 61 | |
xiaohu.huang | 3826210 | 2022-05-06 22:21:48 +0800 | [diff] [blame] | 62 | uint32_t __noinline measure_cpu_freq(size_t n); |
Xiaohu.Huang | f78b48b | 2022-01-17 10:41:38 +0800 | [diff] [blame] | 63 | |
| 64 | void wfe(void); |
| 65 | |
| 66 | uint64_t get_timer_value(void); |
| 67 | |
| 68 | uint32_t get_timer_freq(void); |
| 69 | |
| 70 | void test_handler(void); |
| 71 | |
| 72 | int EnableIrq(uint32_t ulIrq); |
| 73 | |
| 74 | int DisableIrq(uint32_t ulIrq); |
| 75 | |
| 76 | int SetIrqPriority(uint32_t ulIrq, uint32_t ulProi); |
| 77 | |
| 78 | int ClearPendingIrq(uint32_t ulIrq); |
| 79 | |
| 80 | int RegisterIrq(uint32_t int_num, uint32_t int_priority, function_ptr_t handler); |
| 81 | |
| 82 | int UnRegisterIrq(uint32_t ulIrq); |
| 83 | |
| 84 | unsigned long interrupt_status_get(void); |
| 85 | |
| 86 | void interrupt_disable(void); |
| 87 | |
| 88 | void interrupt_enable(void); |
| 89 | |
Xiaohu.Huang | f78b48b | 2022-01-17 10:41:38 +0800 | [diff] [blame] | 90 | __END_DECLS |
| 91 | |
| 92 | #endif |