huangcm
2025-07-03 a76b2fadf6ad4adf86e241e3753a63efe03ef80c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
*********************************************************************************************************
*                                                AR100 SYSTEM
*                                     AR100 Software System Develop Kits
*                                                cpucfg module
*
*                                    (c) Copyright 2012-2016, Sunny China
*                                             All Rights Reserved
*
* File    : cpucfg.h
* By      : Sunny
* Version : v1.0
* Date    : 2012-4-28
* Descript: cpu config module public header.
* Update  : date                auther      ver     notes
*           2012-4-28 14:48:38  Sunny       1.0     Create this file.
*********************************************************************************************************
*/
 
#ifndef __CPUCFG_H__
#define __CPUCFG_H__
 
#ifdef FPGA_PLATFORM
#define L2CACHE_IS_WFI_MODE(cluster)  (1)
#define CPU_IS_WFI_MODE(cluster, cpu) (1)
#else
#define L2CACHE_IS_WFI_MODE(cluster)  (readl(SUNXI_CLUSTER_CPU_STATUS(cluster)) & (1 << 0))
#define CPU_IS_WFI_MODE(cluster, cpu) (readl(SUNXI_CLUSTER_CPU_STATUS(cluster)) & (1 << (16 + cpu)))
#endif
 
/* the reset status of cpu */
typedef enum cpu_reset_status {
   CPU_RESET_ASSERT    = 0x0,
   CPU_RESET_DEASSERT  = 0x3,
} cpu_reset_status_e;
 
/* the status of cluster0 */
typedef enum cluster_reset_status {
   CLUSTER_RESET_ASSERT    = 0x0,
   CLUSTER_RESET_DEASSERT  = 0x1,
} cluster_reset_status_e;
 
/* the status of acinactm */
typedef enum acinactm_status {
   ACINACTM_LOW    = 0x0,
   ACINACTM_HIGH   = 0x1,
} acinactm_status_e;
 
/* L1 & L2 reset by hardware status */
typedef enum l1l2_reset_by_hardware_status {
   L1_EN_L2_EN     = 0x0,
   L1_DIS_L2_EN    = 0xf,
   L1_EN_L2_DIS    = 0x10,
   L1_DIS_L2_DIS   = 0x1f
} l1l2_reset_by_hardware_status_e;
 
extern void cpucfg_cpu_suspend(void);
extern void cpucfg_cpu_suspend_late(void);
extern s32 cpucfg_cpu_resume_early(u32 resume_addr);
extern s32 cpucfg_cpu_resume(u32 resume_addr);
 
/*
*********************************************************************************************************
*                                       INITIALIZE CPUCFG
*
* Description:  initialize cpu configure module.
*
* Arguments  :  none.
*
* Returns    :  OK if initialize cpu configure succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_init(void);
 
/*
*********************************************************************************************************
*                                       EXIT CPUCFG
*
* Description:  exit cpu configure module.
*
* Arguments  :  none.
*
* Returns    :  OK if exit cpu configure succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_exit(void);
 
/*
*********************************************************************************************************
*                                       SET SUPER-STANDBY FLAG
*
* Description:  set super-standby flag.
*
* Arguments  :  none.
*
* Returns    :  OK if set super-standby flag succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_set_super_standby_flag(void);
 
/*
*********************************************************************************************************
*                                       CLEAR SUPER-STANDBY FLAG
*
* Description:  clear super-standby flag.
*
* Arguments  :  none.
*
* Returns    :  OK if clear super-standby flag succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_clear_super_standby_flag(void);
 
/*
*********************************************************************************************************
*                                       GET CPU STATUS
*
* Description:  get the cpu status.
*
* Arguments  :  none.
*
* Returns    :  OK if get status succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_get_cpu_state(u32 cpu_num);
 
/*
*********************************************************************************************************
*                                      SET LE ADDRESS SPACE
*
* Description:  set little-endian address space.
*
* Arguments  :  start   : the start address of little-endian space.
*               end     : the end address of little-endian space.
*
* Returns    :  OK if set little-endian succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_set_little_endian_address(void *start, void *end);
extern s32 cpucfg_remove_little_endian_address(void *start, void *end);
 
/*
*********************************************************************************************************
*                                      CLEAR 64BIT COUNTER
*
* Description:  clear 64bit counter, after this operation,
*               the value of conuter will reset to zero.
*
* Arguments  :  none.
*
* Returns    :  OK if clear counter succeeded, others if failed.
*********************************************************************************************************
*/
s32 cpucfg_counter_clear(void);
 
/*
*********************************************************************************************************
*                                      READ 64BIT COUNTER
*
* Description:  read 64bit counter, the counter value base on us.
*
* Arguments  :  none.
*
* Returns    :  the value of counter, base on us.
*********************************************************************************************************
*/
u64 cpucfg_counter_read(void);
 
s32 cpucfg_set_cpux_jump_addr(u32 addr);
 
s32 cpucfg_cpu_power_off_pre_process(void);
s32 cpucfg_cpu_power_on_post_process(void);
 
extern void cpucfg_mcpm_init(void);
void set_secondary_entry(u32 entry, u32 cpu);
void sun50i_set_AA32nAA64(u32 cluster, u32 cpu, bool is_aa64);
void cpu_power_up(u32 cluster, u32 cpu);
void cpu_power_down(u32 cluster, u32 cpu);
void cpucfg_counter_ctrl(bool enable);
 
#endif /* __CPUCFG_H__ */