summaryrefstree
path: root/kernel/arch/arm/mach-exynos/include/mach/cpufreq.h
blob: 796390e1a2b227b3f643a9fc9fea1a1ff201ec7a (plain)
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
/* linux/arch/arm/mach-exynos/include/mach/cpufreq.h
 *
 * Copyright (c) 2010 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.
*/

#include <linux/notifier.h>

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,
};

#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)), \
	}

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;
	unsigned int	resume_freq;
	int		boot_freq_idx;
	int		*bus_table;
	bool		blocked;
	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;
	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);
};

struct cpufreq_clkdiv {
	unsigned int	index;
	unsigned int	clkdiv0;
	unsigned int	clkdiv1;
};

#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_ARCH_EXYNOS4)
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;
}

static inline int exynos5410_cpufreq_CA7_init(struct exynos_dvfs_info *info)
{
	return 0;
}

static inline int exynos5410_cpufreq_CA15_init(struct exynos_dvfs_info *info)
{
	return 0;
}

#elif defined(CONFIG_ARCH_EXYNOS5)
static inline int exynos4210_cpufreq_init(struct exynos_dvfs_info *info)
{
	return 0;
}

static inline int exynos4x12_cpufreq_init(struct exynos_dvfs_info *info)
{
	return 0;
}

extern int exynos5250_cpufreq_init(struct exynos_dvfs_info *);
extern int exynos5_cpufreq_CA7_init(struct exynos_dvfs_info *);
extern int exynos5_cpufreq_CA15_init(struct exynos_dvfs_info *);
#else
	#warning "Should define CONFIG_ARCH_EXYNOS4(5)\n"
#endif
extern void exynos_thermal_throttle(void);
extern void exynos_thermal_unthrottle(void);

/* CPUFREQ init events */
#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_ARCH_EXYNOS5)
typedef enum {
	CA7,
	CA15,
	CA_END,
} cluster_type;

#if defined(CONFIG_ARM_EXYNOS5430_CPUFREQ) || defined(CONFIG_ARM_EXYNOS5433_CPUFREQ) || defined(CONFIG_ARM_EXYNOS7420_CPUFREQ)
#define COLD_VOLT_OFFSET	37500
#define ENABLE_MIN_COLD		0
#define LIMIT_COLD_VOLTAGE	1350000
#define MIN_COLD_VOLTAGE	950000
#define NR_CA7			4
#define NR_CA15			4
#elif defined(CONFIG_ARM_EXYNOS5422_CPUFREQ)
#define COLD_VOLT_OFFSET	37500
#define ENABLE_MIN_COLD		1
#define LIMIT_COLD_VOLTAGE	1350000
#define MIN_COLD_VOLTAGE	950000
#define NR_CA7			4
#define NR_CA15			4
#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;
#ifdef CONFIG_ARM_EXYNOS_MP_CPUFREQ
extern void (*disable_c3_idle)(bool disable);
#endif
#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 big_cores_hotplug(bool out_flag);
int little_core1_hotplug_in(bool in_flag);
void event_hotplug_in(void);
bool is_big_hotpluged(void);
#else
static inline int big_cores_hotplug(bool out_flag)
{
	return 0;
}

static inline int little_core1_hotplug_in(bool in_flag)
{
	return 0;
}

static inline void event_hotplug_in(void)
{
	return;
}

static inline bool is_big_hotpluged(void)
{
	return 0;
}
#endif

/*
 * interface 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
#endif