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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
#include <linux/input/input_booster.h>
#include <linux/device.h>
#include <linux/syscalls.h>
int current_hmp_boost = 0;
struct pm_qos_request lpm_bias_pm_qos_request;
static struct device *dev;
struct icc_path *path_touch_bw;
int register_ddr;
#define MHZ_TO_BPS(mhz, w) ((uint64_t)mhz * 1000 * 1000 * w)
#define MHZ_TO_KBPS(mhz, w) ((uint64_t)mhz * 1000 * w)
//Refer to "include/dt-bindings/interconnect/qcom,lahaina.h"
#define MASTER_APPSS_PROC 2
#define SLAVE_EBI1 512
void set_hmp(int level);
#ifndef CONFIG_CPU_FREQ_LIMIT
#define DVFS_TOUCH_ID 0
int set_freq_limit(unsigned long id, unsigned int freq)
{
pr_err("%s is not yet implemented\n", __func__);
return 0;
}
#else
/* TEMP: for KPI */
#define DVFS_TOUCH_ID 1
#endif
#if defined(CONFIG_ARCH_LAHAINA)
#define NUM_BUS_TABLE 14
#define BUS_W 4 /* SM8350 DDR Voting('w' for DDR is 4) */
int ab_ib_bus_vectors[NUM_BUS_TABLE][2] = {
//{ab, ib}
{0, 0}, /* 0 */
{0, 200}, /* 1 */
{0, 451}, /* 2 */
{0, 547}, /* 3 */
{0, 681}, /* 4 */
{0, 768}, /* 5 */
{0, 1017}, /* 6 */
{0, 1353}, /* 7 */
{0, 1555}, /* 8 */
{0, 1708}, /* 9 */
{0, 2092}, /* 10 */
{0, 2133}, /* 11 */
{0, 2736}, /* 12 */
{0, 3196} /* 13 */
};
#else
#define NUM_BUS_TABLE 1
#define BUS_W 0
int ab_ib_bus_vectors[NUM_BUS_TABLE][2] = {
{0, 0}, /* 0 */
};
#endif //set null for other chipset
struct msm_touch_bus_vector_bps {
uint32_t ab;
uint32_t ib;
};
struct msm_touch_bus_vector_bps touch_bus_vectors_bps[NUM_BUS_TABLE];
void fill_bus_vector(void)
{
int i = 0;
for (i = 0; i < NUM_BUS_TABLE; i++) {
touch_bus_vectors_bps[i].ab = ab_ib_bus_vectors[i][0];
touch_bus_vectors_bps[i].ib = MHZ_TO_KBPS(ab_ib_bus_vectors[i][1], BUS_W);
}
}
int trans_freq_to_idx(long request_ddr_freq)
{
int i = 0;
if (request_ddr_freq <= 0) {
return 0;
}
// in case of null table, return 0
if (NUM_BUS_TABLE == 1) {
return 0;
}
for (i = 0; i < NUM_BUS_TABLE-1; i++) {
if (request_ddr_freq > ab_ib_bus_vectors[i][1] &&
request_ddr_freq <= ab_ib_bus_vectors[i+1][1]) {
return (i+1);
}
}
return i+1;
}
void ib_set_booster(long* qos_values)
{
long value = -1;
int ddr_idx = 0;
int res_type =0;
int cur_res_idx;
int rc = 0;
for (res_type = 0; res_type < allowed_res_count; res_type++) {
cur_res_idx = allowed_resources[res_type];
value = qos_values[cur_res_idx];
if (value <= 0)
continue;
switch (cur_res_idx) {
case CPUFREQ:
set_freq_limit(DVFS_TOUCH_ID, value);
pr_booster("%s :: cpufreq value : %ld", __func__, value);
break;
case DDRFREQ:
ddr_idx = trans_freq_to_idx(value);
pr_booster("%s :: bus value : %ld, %u", __func__, value, touch_bus_vectors_bps[ddr_idx].ib);
if (register_ddr)
rc = icc_set_bw(path_touch_bw,
touch_bus_vectors_bps[ddr_idx].ab, touch_bus_vectors_bps[ddr_idx].ib);
break;
case HMPBOOST:
set_hmp(value);
pr_booster("%s :: hmpboost value : %ld", __func__, value);
break;
case LPMBIAS:
pm_qos_update_request(&lpm_bias_pm_qos_request, value);
pr_booster("%s :: LPM Bias value : %ld", __func__, value);
break;
default:
break;
}
}
}
void ib_release_booster(long *rel_flags)
{
//cpufreq : -1, ddrfreq : 0, HMP : 0, lpm_bias = 0
int ddr_idx;
int flag;
int rc = 0;
int value;
int res_type = 0;
int cur_res_idx;
for (res_type = 0; res_type < allowed_res_count; res_type++) {
cur_res_idx = allowed_resources[res_type];
flag = rel_flags[cur_res_idx];
if (flag <= 0)
continue;
value = release_val[cur_res_idx];
switch (cur_res_idx) {
case CPUFREQ:
set_freq_limit(DVFS_TOUCH_ID, value);
break;
case DDRFREQ:
ddr_idx = trans_freq_to_idx(value);
if (register_ddr)
rc = icc_set_bw(path_touch_bw,
touch_bus_vectors_bps[ddr_idx].ab, touch_bus_vectors_bps[ddr_idx].ib);
break;
case HMPBOOST:
set_hmp(value);
break;
case LPMBIAS:
pm_qos_update_request(&lpm_bias_pm_qos_request, value);
break;
default:
break;
}
}
}
#ifdef USE_HMP_BOOST
void set_hmp(int level)
{
if (level != current_hmp_boost) {
if (level == 0) {
level = -current_hmp_boost;
current_hmp_boost = 0;
} else {
current_hmp_boost = level;
}
pr_booster("[Input Booster2] ****** hmp_boost : %d ( %s )\n", level, __func__);
if (sched_set_boost(level) < 0)
pr_err("[Input Booster2] ****** !!! fail to HMP !!!\n");
}
}
#else
void set_hmp(int level)
{
pr_booster("It does not use hmp\n", level, __func__);
}
#endif
static void icc_release(struct device *dev)
{
pr_booster("Release icc path of device\n");
}
int input_booster_init_vendor(void)
{
int bus_ret = 0;
//Bus boost factors initailized
dev = kzalloc(sizeof(struct device), GFP_KERNEL);
dev_set_name(dev, "input_booster");
dev->release = icc_release;
device_register(dev);
if (!register_ddr) {
path_touch_bw = icc_get(dev, MASTER_APPSS_PROC, SLAVE_EBI1);
if (IS_ERR(path_touch_bw)) {
bus_ret = PTR_ERR(path_touch_bw);
if (bus_ret != -EPROBE_DEFER)
pr_err("Failed to get path from input bus booster. ret=%d\n", bus_ret);
} else {
pr_info(ITAG" Making icc path for bus success");
register_ddr = 1;
}
}
fill_bus_vector();
pm_qos_add_request(&lpm_bias_pm_qos_request,
PM_QOS_BIAS_HYST, PM_QOS_BIAS_HYST_DEFAULT_VALUE);
return 1;
}
void input_booster_exit_vendor(void)
{
if (register_ddr)
icc_put(path_touch_bw);
device_unregister(dev);
kfree(dev);
pm_qos_remove_request(&lpm_bias_pm_qos_request);
}
MODULE_LICENSE("GPL");
|