hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/soc/rockchip/rockchip_system_monitor.c
....@@ -4,7 +4,6 @@
44 * Author: Finley Xiao <finley.xiao@rock-chips.com>
55 */
66
7
-#include <dt-bindings/soc/rockchip-system-status.h>
87 #include <linux/clk-provider.h>
98 #include <linux/cpu.h>
109 #include <linux/cpufreq.h>
....@@ -24,6 +23,7 @@
2423 #include <linux/regulator/driver.h>
2524 #include <linux/regulator/machine.h>
2625 #include <linux/reboot.h>
26
+#include <linux/rockchip/rockchip_sip.h>
2727 #include <linux/slab.h>
2828 #include <linux/suspend.h>
2929 #include <linux/thermal.h>
....@@ -246,34 +246,6 @@
246246 return video_info;
247247 }
248248
249
-static struct video_info *rockchip_find_video_info(const char *buf)
250
-{
251
- struct video_info *info, *video_info;
252
-
253
- video_info = rockchip_parse_video_info(buf);
254
-
255
- if (!video_info)
256
- return NULL;
257
-
258
- mutex_lock(&video_info_mutex);
259
- list_for_each_entry(info, &video_info_list, node) {
260
- if (info->width == video_info->width &&
261
- info->height == video_info->height &&
262
- info->ishevc == video_info->ishevc &&
263
- info->videoFramerate == video_info->videoFramerate &&
264
- info->streamBitrate == video_info->streamBitrate) {
265
- mutex_unlock(&video_info_mutex);
266
- kfree(video_info);
267
- return info;
268
- }
269
- }
270
-
271
- mutex_unlock(&video_info_mutex);
272
- kfree(video_info);
273
-
274
- return NULL;
275
-}
276
-
277249 static void rockchip_add_video_info(struct video_info *video_info)
278250 {
279251 if (video_info) {
....@@ -285,12 +257,25 @@
285257
286258 static void rockchip_del_video_info(struct video_info *video_info)
287259 {
288
- if (video_info) {
289
- mutex_lock(&video_info_mutex);
290
- list_del(&video_info->node);
291
- mutex_unlock(&video_info_mutex);
292
- kfree(video_info);
260
+ struct video_info *info, *tmp;
261
+
262
+ if (!video_info)
263
+ return;
264
+
265
+ mutex_lock(&video_info_mutex);
266
+ list_for_each_entry_safe(info, tmp, &video_info_list, node) {
267
+ if (info->width == video_info->width &&
268
+ info->height == video_info->height &&
269
+ info->ishevc == video_info->ishevc &&
270
+ info->videoFramerate == video_info->videoFramerate &&
271
+ info->streamBitrate == video_info->streamBitrate) {
272
+ list_del(&info->node);
273
+ kfree(info);
274
+ break;
275
+ }
293276 }
277
+ kfree(video_info);
278
+ mutex_unlock(&video_info_mutex);
294279 }
295280
296281 static void rockchip_update_video_info(void)
....@@ -338,7 +323,7 @@
338323 switch (buf[0]) {
339324 case '0':
340325 /* clear video flag */
341
- video_info = rockchip_find_video_info(buf);
326
+ video_info = rockchip_parse_video_info(buf);
342327 if (video_info) {
343328 rockchip_del_video_info(video_info);
344329 rockchip_update_video_info();
....@@ -920,6 +905,7 @@
920905 bool is_low)
921906 {
922907 struct monitor_dev_profile *devp = info->devp;
908
+ struct arm_smccc_res res;
923909 int ret = 0;
924910
925911 dev_dbg(info->dev, "low_temp %d\n", is_low);
....@@ -934,6 +920,17 @@
934920
935921 if (devp->update_volt)
936922 devp->update_volt(info);
923
+
924
+ if (devp->opp_info && devp->opp_info->pvtpll_low_temp) {
925
+ res = sip_smc_pvtpll_config(PVTPLL_LOW_TEMP,
926
+ devp->opp_info->pvtpll_clk_id,
927
+ is_low, 0, 0, 0, 0);
928
+ if (res.a0)
929
+ dev_err(info->dev,
930
+ "%s: error cfg id=%u low temp %d (%d)\n",
931
+ __func__, devp->opp_info->pvtpll_clk_id,
932
+ is_low, (int)res.a0);
933
+ }
937934 }
938935
939936 static void rockchip_high_temp_adjust(struct monitor_dev_info *info,
....@@ -1338,6 +1335,15 @@
13381335 rockchip_set_intermediate_rate(dev, opp_info, info->clk,
13391336 old_rate, new_rate,
13401337 true, is_set_clk);
1338
+
1339
+ if (old_volt > new_volt) {
1340
+ ret = regulator_set_voltage(vdd_reg, new_volt, INT_MAX);
1341
+ if (ret) {
1342
+ dev_err(dev, "%s: failed to set volt: %lu\n",
1343
+ __func__, new_volt);
1344
+ goto restore_voltage;
1345
+ }
1346
+ }
13411347 if (info->regulator_count > 1) {
13421348 ret = regulator_set_voltage(mem_reg, new_mem_volt,
13431349 INT_MAX);
....@@ -1347,11 +1353,13 @@
13471353 goto restore_voltage;
13481354 }
13491355 }
1350
- ret = regulator_set_voltage(vdd_reg, new_volt, INT_MAX);
1351
- if (ret) {
1352
- dev_err(dev, "%s: failed to set volt: %lu\n",
1353
- __func__, new_volt);
1354
- goto restore_voltage;
1356
+ if (old_volt <= new_volt) {
1357
+ ret = regulator_set_voltage(vdd_reg, new_volt, INT_MAX);
1358
+ if (ret) {
1359
+ dev_err(dev, "%s: failed to set volt: %lu\n",
1360
+ __func__, new_volt);
1361
+ goto restore_voltage;
1362
+ }
13551363 }
13561364 rockchip_set_read_margin(dev, opp_info, target_rm, is_set_rm);
13571365 if (is_set_clk && clk_set_rate(info->clk, new_rate)) {
....@@ -1396,9 +1404,12 @@
13961404 rockchip_get_read_margin(dev, opp_info, old_volt, &target_rm);
13971405 rockchip_set_read_margin(dev, opp_info, target_rm, is_set_rm);
13981406 restore_voltage:
1407
+ if (old_volt <= new_volt)
1408
+ regulator_set_voltage(vdd_reg, old_volt, INT_MAX);
13991409 if (info->regulator_count > 1)
14001410 regulator_set_voltage(mem_reg, old_mem_volt, INT_MAX);
1401
- regulator_set_voltage(vdd_reg, old_volt, INT_MAX);
1411
+ if (old_volt > new_volt)
1412
+ regulator_set_voltage(vdd_reg, old_volt, INT_MAX);
14021413 disable_clk:
14031414 rockchip_monitor_disable_opp_clk(dev, opp_info);
14041415 unlock: