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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/* linux/arch/arm64/mach-exynos/include/mach/cpufreq.h
*
* Copyright (c) 2014 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* EXYNOS - CPUFreq support
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __ARCH_CPUFREQ_H
#define __ARCH_CPUFREQ_H __FILE__
#include <linux/notifier.h>
#include <linux/cpufreq.h>
/*
* Common definitions and structures
*/
#define APLL_FREQ(f, a0, a1, a2, a3, a4, a5, a6, a7, b0, b1, b2, m, p, s) \
{ \
.freq = (f) * 1000, \
.clk_div_cpu0 = ((a0) | (a1) << 4 | (a2) << 8 | (a3) << 12 | \
(a4) << 16 | (a5) << 20 | (a6) << 24 | (a7) << 28), \
.clk_div_cpu1 = (b0 << 0 | b1 << 4 | b2 << 8), \
.mps = ((m) << 16 | (p) << 8 | (s)), \
}
/* APLL Macro for Atlas Frequency in ISTOR */
#define APLL_ATLAS_FREQ(f, a0, a1, a2, a3, a4, a5, b0, b1, b2, m, p, s) \
{ \
.freq = (f) * 1000, \
.clk_div_cpu0 = ((a0) | (a1) << 4 | (a2) << 8 | (a3) << 12 | \
(a4) << 20 | (a5) << 26), \
.clk_div_cpu1 = (b0 << 0 | b1 << 4 | b2 << 8), \
.mps = ((m) << 16 | (p) << 8 | (s)), \
}
enum cpufreq_level_index {
L0, L1, L2, L3, L4,
L5, L6, L7, L8, L9,
L10, L11, L12, L13, L14,
L15, L16, L17, L18, L19,
L20, L21, L22, L23, L24,
};
struct apll_freq {
unsigned int freq;
u32 clk_div_cpu0;
u32 clk_div_cpu1;
u32 mps;
};
struct exynos_dvfs_info {
unsigned long mpll_freq_khz;
unsigned int pll_safe_idx;
unsigned int max_support_idx;
unsigned int min_support_idx;
unsigned int cluster_num;
unsigned int reboot_limit_freq;
unsigned int boost_freq; /* use only KFC when enable HMP */
unsigned int boot_freq;
unsigned int boot_cpu_min_qos;
unsigned int boot_cpu_max_qos;
unsigned int boot_cpu_min_qos_timeout;
unsigned int boot_cpu_max_qos_timeout;
#ifdef CONFIG_SEC_PM
unsigned int jig_boot_cpu_max_qos;
unsigned int low_boot_cpu_max_qos; /* low freq */
#endif
unsigned int resume_freq;
int boot_freq_idx;
int *bus_table;
bool blocked;
unsigned int cur_volt;
struct clk *cpu_clk;
unsigned int *volt_table;
unsigned int *abb_table;
const unsigned int *max_op_freqs;
struct cpufreq_frequency_table *freq_table;
struct regulator *regulator;
#ifdef CONFIG_PMU_COREMEM_RATIO
int (*region_bus_table)[6];
int region;
#endif
void (*set_freq)(unsigned int, unsigned int);
void (*set_ema)(unsigned int);
bool (*need_apll_change)(unsigned int, unsigned int);
bool (*is_alive)(void);
void (*set_int_skew)(int);
int (*check_smpl)(void);
};
struct cpufreq_clkdiv {
unsigned int index;
unsigned int clkdiv0;
unsigned int clkdiv1;
};
/*
* common interfaces for IPA
*/
/* interfaces for IPA */
#if defined(CONFIG_ARM_EXYNOS_MP_CPUFREQ) || defined(CONFIG_ARM_EXYNOS_CPUFREQ)
void exynos_set_max_freq(int max_freq, unsigned int cpu);
void ipa_set_clamp(int cpu, unsigned int clamp_freq, unsigned int gov_target);
#else
static inline void exynos_set_max_freq(int max_freq, unsigned int cpu) {}
static inline void ipa_set_clamp(int cpu, unsigned int clamp_freq, unsigned int gov_target) {}
#endif
/* interface for THERMAL */
extern void exynos_thermal_throttle(void);
extern void exynos_thermal_unthrottle(void);
/*
* CPUFREQ init events and notifiers
*/
#define CPUFREQ_INIT_COMPLETE 0x0001
#if defined(CONFIG_ARM_EXYNOS_MP_CPUFREQ) || defined(CONFIG_ARM_EXYNOS_CPUFREQ)
extern int exynos_cpufreq_init_register_notifier(struct notifier_block *nb);
extern int exynos_cpufreq_init_unregister_notifier(struct notifier_block *nb);
#else
static inline int exynos_cpufreq_init_register_notifier(struct notifier_block *nb)
{return 0;}
static inline int exynos_cpufreq_init_unregister_notifier(struct notifier_block *nb)
{return 0;}
#endif
#if defined(CONFIG_ARM_EXYNOS5433_CPUFREQ) || defined(CONFIG_ARM_EXYNOS7420_CPUFREQ)
extern int exynos_cpufreq_smpl_warn_notify_call_chain(void);
#else
static inline int exynos_cpufreq_smpl_warn_notify_call_chain(void)
{
return 0;
}
#endif
/*
* Soc specific definitions
*/
#if defined(CONFIG_SOC_EXYNOS5422)
#define EMA_VAL_0 0x4
#define EMA_VAL_1 0x3
#define EMA_VAL_2 0x1
#define EMA_VAL_3 0x1
#define EMA_VOLT_LEV_0 900000
#define EMA_VOLT_LEV_1 950000
#define EMA_VOLT_LEV_2 1045000
#define EMA_VOLT_LEV_3 1155000
#define EMA_ON_CHANGE 0x11
#endif
#if defined(CONFIG_CPU_FREQ)
#if defined(CONFIG_ARM_EXYNOS_CPUFREQ)
extern int exynos4210_cpufreq_init(struct exynos_dvfs_info *);
extern int exynos4x12_cpufreq_init(struct exynos_dvfs_info *);
static inline int exynos5250_cpufreq_init(struct exynos_dvfs_info *info)
{return 0;}
#elif defined(CONFIG_ARM_EXYNOS_MP_CPUFREQ)
extern int exynos_cpufreq_cluster0_init(struct exynos_dvfs_info *);
extern int exynos_cpufreq_cluster1_init(struct exynos_dvfs_info *);
typedef enum {
CL_ZERO,
CL_ONE,
CL_END,
} cluster_type;
#define COLD_VOLT_OFFSET 37500
#define LIMIT_COLD_VOLTAGE 1350000
#define MIN_COLD_VOLTAGE 950000
#define NR_CLUST0_CPUS 4
#define NR_CLUST1_CPUS 4
#if defined(CONFIG_ARM_EXYNOS5422_CPUFREQ)
#define ENABLE_MIN_COLD 1
#else
#define ENABLE_MIN_COLD 0
#endif
enum op_state {
NORMAL, /* Operation : Normal */
SUSPEND, /* Direct API will be blocked in this state */
RESUME, /* Re-enabling DVFS using direct API after resume */
};
/*
* Keep frequency value for counterpart cluster DVFS
* cur, min, max : Frequency (KHz),
* c_id : Counter cluster with booting cluster, if booting cluster is
* A15, c_id will be A7.
*/
struct cpu_info_alter {
unsigned int cur;
unsigned int min;
unsigned int max;
cluster_type boot_cluster;
cluster_type c_id;
};
extern cluster_type exynos_boot_cluster;
extern void (*disable_c3_idle)(bool disable);
#ifdef CONFIG_EXYNOS5_DYNAMIC_CPU_HOTPLUG
extern void force_dynamic_hotplug(bool out_flag, int delay_msec);
#endif
#if defined(CONFIG_SCHED_HMP) && defined(CONFIG_EXYNOS5_DYNAMIC_CPU_HOTPLUG)
int cluster1_cores_hotplug(bool out_flag);
int cluster0_core1_hotplug_in(bool in_flag);
void event_hotplug_in(void);
bool is_cluster1_hotplugged(void);
#else
static inline int cluster1_cores_hotplug(bool out_flag) {return 0;}
static inline int cluster0_core1_hotplug_in(bool in_flag) {return 0;}
static inline void event_hotplug_in(void) {}
static inline bool is_cluster1_hotplugged(void) {return 0;}
#endif
#elif defined(CONFIG_SOC_EXYNOS7580)
#else
#warning "Should define CONFIG_ARM_EXYNOS_(MP_)CPUFREQ\n"
#endif
#if defined(CONFIG_PMU_COREMEM_RATIO)
void coremem_region_bus_lock(int region, struct cpufreq_policy *policy);
#else
static inline
void coremem_region_bus_lock(int region, struct cpufreq_policy *policy)
{
return;
}
#endif /* CONFIG_PMU_COREMEM_RATIO */
#endif
#endif /* __ARCH_CPUFREQ_H */
|