Lock device to lowest clocks during sleep mode

This commit is contained in:
mason 2023-11-28 23:48:55 +00:00 committed by fewtarius
parent 82e1a91f30
commit c3eb90549a
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
4 changed files with 87 additions and 56 deletions

View file

@ -7,3 +7,8 @@ CPU_FREQ=("/sys/devices/system/cpu/cpufreq/policy0" "/sys/devices/system/cpu/cpu
GPU_FREQ="/sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu"
DMC_FREQ="/sys/devices/platform/memory-controller/devfreq/memory-controller/"
EOF
### Lock in lowest freq we want to use
echo 1008000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo 1008000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
echo 600000000 > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/min_freq

View file

@ -2,11 +2,20 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# Restore previous governors before going to sleep
### Restore previous governors before going to sleep
. /etc/profile
# Grab the old governors.
### Set max/min freq to lowest available value
echo 1008000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo 1008000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
echo 600000000 > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/min_freq
echo 1608000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
echo 2088000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
echo 900000000 > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/max_freq
### Grab the old governors.
OLD_CPU_FREQ=$(get_setting "sleep.cpugovernor")
if [ ! -n "${OLD_CPU_FREQ}" ]; then
OLD_CPU_FREQ="schedutil"

View file

@ -17,3 +17,12 @@ set_setting sleep.cpugovernor "${CUR_GPU_FREQ}"
set_cpu_gov powersave
set_dmc_gov powersave
set_gpu_gov powersave
### Set max/min freq to lowest available value
echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq
echo 600000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_min_freq
echo 200000000 > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/min_freq
echo 600000 > /sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq
echo 600000 > /sys/devices/system/cpu/cpufreq/policy4/scaling_max_freq
echo 200000000 > /sys/devices/platform/ff9a0000.gpu/devfreq/ff9a0000.gpu/max_freq

View file

@ -1,6 +1,6 @@
diff -rupN linux.orig/Makefile linux/Makefile
--- linux.orig/Makefile 2023-11-14 03:58:03.064741025 +0000
+++ linux/Makefile 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/Makefile 2023-11-28 13:54:58.570108474 +0000
+++ linux/Makefile 2023-11-28 19:50:16.215638386 +0000
@@ -826,6 +826,8 @@ KBUILD_CFLAGS += $(call cc-disable-warni
KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
@ -20,8 +20,8 @@ diff -rupN linux.orig/Makefile linux/Makefile
# Require designated initializers for all marked structures
KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boot/dts/rockchip/Makefile
--- linux.orig/arch/arm64/boot/dts/rockchip/Makefile 2023-11-14 03:58:03.288746149 +0000
+++ linux/arch/arm64/boot/dts/rockchip/Makefile 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/arch/arm64/boot/dts/rockchip/Makefile 2023-11-28 13:54:59.138120459 +0000
+++ linux/arch/arm64/boot/dts/rockchip/Makefile 2023-11-28 19:50:16.215638386 +0000
@@ -21,6 +21,7 @@ dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3368-li
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3368-orion-r68-meta.dtb
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3368-px5-evb.dtb
@ -32,8 +32,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/Makefile linux/arch/arm64/boo
dtb-$(CONFIG_ARCH_ROCKCHIP) += rk3399-ficus.dtb
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dtsi linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dtsi
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dtsi 1970-01-01 00:00:00.000000000 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dtsi 2023-11-15 14:15:47.804831632 +0000
@@ -0,0 +1,133 @@
+++ linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dtsi 2023-11-28 23:23:39.023319423 +0000
@@ -0,0 +1,141 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2016-2017 Fuzhou Rockchip Electronics Co., Ltd
@ -46,24 +46,28 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dts
+ opp-shared;
+
+ opp00 {
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <925000>;
+ opp-hz = /bits/ 64 <600000000>;
+ opp-microvolt = <825000>;
+ };
+ opp01 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <1000000>;
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <900000>;
+ };
+ opp02 {
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <1125000>;
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <975000>;
+ };
+ opp03 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <1200000>;
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <1100000>;
+ };
+ opp04 {
+ opp-hz = /bits/ 64 <1512000000>;
+ opp-microvolt = <1150000>;
+ };
+ opp05 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <1225000>;
+ opp-microvolt = <1200000>;
+ };
+ };
+
@ -72,30 +76,34 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dts
+ opp-shared;
+
+ opp00 {
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <875000>;
+ opp-hz = /bits/ 64 <600000000>;
+ opp-microvolt = <825000>;
+ };
+ opp01 {
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <950000>;
+ opp-hz = /bits/ 64 <1008000000>;
+ opp-microvolt = <850000>;
+ };
+ opp02 {
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <1025000>;
+ opp-hz = /bits/ 64 <1200000000>;
+ opp-microvolt = <900000>;
+ };
+ opp03 {
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <1100000>;
+ opp-hz = /bits/ 64 <1416000000>;
+ opp-microvolt = <975000>;
+ };
+ opp04 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <1200000>;
+ opp-hz = /bits/ 64 <1608000000>;
+ opp-microvolt = <1050000>;
+ };
+ opp05 {
+ opp-hz = /bits/ 64 <1800000000>;
+ opp-microvolt = <1150000>;
+ };
+ opp06 {
+ opp-hz = /bits/ 64 <1992000000>;
+ opp-microvolt = <1250000>;
+ };
+ opp06 {
+ opp07 {
+ opp-hz = /bits/ 64 <2088000000>;
+ opp-microvolt = <1250000>;
+ };
@ -105,8 +113,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dts
+ compatible = "operating-points-v2";
+
+ opp00 {
+ opp-hz = /bits/ 64 <500000000>;
+ opp-microvolt = <875000>;
+ opp-hz = /bits/ 64 <200000000>;
+ opp-microvolt = <800000>;
+ };
+ opp01 {
+ opp-hz = /bits/ 64 <600000000>;
@ -114,7 +122,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dts
+ };
+ opp02 {
+ opp-hz = /bits/ 64 <800000000>;
+ opp-microvolt = <1100000>;
+ opp-microvolt = <1075000>;
+ };
+ opp03 {
+ opp-hz = /bits/ 64 <900000000>;
@ -169,7 +177,7 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552-opp.dts
+};
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts 1970-01-01 00:00:00.000000000 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts 2023-11-15 14:10:46.134863088 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts 2023-11-28 19:50:16.215638386 +0000
@@ -0,0 +1,1329 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
@ -1501,8 +1509,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399-anbernic-rg552.dts lin
+ status = "okay";
+};
diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399.dtsi linux/arch/arm64/boot/dts/rockchip/rk3399.dtsi
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3399.dtsi 2023-11-14 03:58:03.288746149 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3399.dtsi 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/arch/arm64/boot/dts/rockchip/rk3399.dtsi 2023-11-28 13:54:59.142120544 +0000
+++ linux/arch/arm64/boot/dts/rockchip/rk3399.dtsi 2023-11-28 19:50:16.215638386 +0000
@@ -1469,7 +1469,7 @@
<1000000000>,
<150000000>, <75000000>,
@ -1513,8 +1521,8 @@ diff -rupN linux.orig/arch/arm64/boot/dts/rockchip/rk3399.dtsi linux/arch/arm64/
<100000000>, <50000000>,
<400000000>, <400000000>,
diff -rupN linux.orig/drivers/gpio/gpio-rockchip.c linux/drivers/gpio/gpio-rockchip.c
--- linux.orig/drivers/gpio/gpio-rockchip.c 2023-11-14 03:58:03.820758323 +0000
+++ linux/drivers/gpio/gpio-rockchip.c 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/gpio/gpio-rockchip.c 2023-11-28 13:55:00.750154472 +0000
+++ linux/drivers/gpio/gpio-rockchip.c 2023-11-28 19:50:16.215638386 +0000
@@ -335,13 +335,13 @@ static void rockchip_irq_demux(struct ir
unsigned long pending;
unsigned int irq;
@ -1532,8 +1540,8 @@ diff -rupN linux.orig/drivers/gpio/gpio-rockchip.c linux/drivers/gpio/gpio-rockc
/*
* Triggering IRQ on both rising and falling edge
diff -rupN linux.orig/drivers/gpu/drm/panel/Kconfig linux/drivers/gpu/drm/panel/Kconfig
--- linux.orig/drivers/gpu/drm/panel/Kconfig 2023-11-14 03:58:04.344770314 +0000
+++ linux/drivers/gpu/drm/panel/Kconfig 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/gpu/drm/panel/Kconfig 2023-11-28 13:55:02.030181481 +0000
+++ linux/drivers/gpu/drm/panel/Kconfig 2023-11-28 19:50:16.215638386 +0000
@@ -588,6 +588,15 @@ config DRM_PANEL_SHARP_LS043T1LE01
Say Y here if you want to enable support for Sharp LS043T1LE01 qHD
(540x960) DSI panel as found on the Qualcomm APQ8074 Dragonboard
@ -1551,8 +1559,8 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/Kconfig linux/drivers/gpu/drm/panel/
tristate "Sharp LS060T1SX01 FullHD video mode panel"
depends on OF
diff -rupN linux.orig/drivers/gpu/drm/panel/Makefile linux/drivers/gpu/drm/panel/Makefile
--- linux.orig/drivers/gpu/drm/panel/Makefile 2023-11-14 03:58:04.344770314 +0000
+++ linux/drivers/gpu/drm/panel/Makefile 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/gpu/drm/panel/Makefile 2023-11-28 13:55:02.030181481 +0000
+++ linux/drivers/gpu/drm/panel/Makefile 2023-11-28 19:50:16.215638386 +0000
@@ -59,6 +59,7 @@ obj-$(CONFIG_DRM_PANEL_SEIKO_43WVF1G) +=
obj-$(CONFIG_DRM_PANEL_SHARP_LQ101R1SX01) += panel-sharp-lq101r1sx01.o
obj-$(CONFIG_DRM_PANEL_SHARP_LS037V7DW01) += panel-sharp-ls037v7dw01.o
@ -1563,7 +1571,7 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/Makefile linux/drivers/gpu/drm/panel
obj-$(CONFIG_DRM_PANEL_SITRONIX_ST7703) += panel-sitronix-st7703.o
diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c linux/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c
--- linux.orig/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c 1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c 2023-11-15 14:10:46.134863088 +0000
+++ linux/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c 2023-11-28 19:50:16.215638386 +0000
@@ -0,0 +1,360 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
@ -1926,8 +1934,8 @@ diff -rupN linux.orig/drivers/gpu/drm/panel/panel-sharp-ls054b3sx01.c linux/driv
+MODULE_DESCRIPTION("Panel driver for Sharp LS054B3SX01 1152x1920 Video Mode DSI Panel");
+MODULE_LICENSE("GPL v2");
diff -rupN linux.orig/drivers/input/Kconfig linux/drivers/input/Kconfig
--- linux.orig/drivers/input/Kconfig 2023-11-14 03:58:04.472773245 +0000
+++ linux/drivers/input/Kconfig 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/input/Kconfig 2023-11-28 13:55:02.446190257 +0000
+++ linux/drivers/input/Kconfig 2023-11-28 19:50:16.215638386 +0000
@@ -51,6 +51,19 @@ config INPUT_FF_MEMLESS
To compile this driver as a module, choose M here: the
module will be called ff-memless.
@ -1949,8 +1957,8 @@ diff -rupN linux.orig/drivers/input/Kconfig linux/drivers/input/Kconfig
tristate "Sparse keymap support library"
help
diff -rupN linux.orig/drivers/input/Makefile linux/drivers/input/Makefile
--- linux.orig/drivers/input/Makefile 2023-11-14 03:58:04.472773245 +0000
+++ linux/drivers/input/Makefile 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/input/Makefile 2023-11-28 13:55:02.446190257 +0000
+++ linux/drivers/input/Makefile 2023-11-28 19:50:16.215638386 +0000
@@ -10,6 +10,7 @@ input-core-y := input.o input-compat.o i
input-core-y += touchscreen.o
@ -1961,7 +1969,7 @@ diff -rupN linux.orig/drivers/input/Makefile linux/drivers/input/Makefile
obj-$(CONFIG_INPUT_VIVALDIFMAP) += vivaldi-fmap.o
diff -rupN linux.orig/drivers/input/input-polldev.c linux/drivers/input/input-polldev.c
--- linux.orig/drivers/input/input-polldev.c 1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/input/input-polldev.c 2023-11-15 14:10:46.134863088 +0000
+++ linux/drivers/input/input-polldev.c 2023-11-28 19:50:16.215638386 +0000
@@ -0,0 +1,362 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
@ -2326,8 +2334,8 @@ diff -rupN linux.orig/drivers/input/input-polldev.c linux/drivers/input/input-po
+}
+EXPORT_SYMBOL(input_unregister_polled_device);
diff -rupN linux.orig/drivers/input/joystick/Kconfig linux/drivers/input/joystick/Kconfig
--- linux.orig/drivers/input/joystick/Kconfig 2023-11-14 03:58:04.472773245 +0000
+++ linux/drivers/input/joystick/Kconfig 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/input/joystick/Kconfig 2023-11-28 13:55:02.446190257 +0000
+++ linux/drivers/input/joystick/Kconfig 2023-11-28 19:50:16.215638386 +0000
@@ -393,6 +393,12 @@ config JOYSTICK_FSIA6B
To compile this driver as a module, choose M here: the
module will be called fsia6b.
@ -2342,8 +2350,8 @@ diff -rupN linux.orig/drivers/input/joystick/Kconfig linux/drivers/input/joystic
bool "N64 controller"
depends on MACH_NINTENDO64
diff -rupN linux.orig/drivers/input/joystick/Makefile linux/drivers/input/joystick/Makefile
--- linux.orig/drivers/input/joystick/Makefile 2023-11-14 03:58:04.472773245 +0000
+++ linux/drivers/input/joystick/Makefile 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/input/joystick/Makefile 2023-11-28 13:55:02.446190257 +0000
+++ linux/drivers/input/joystick/Makefile 2023-11-28 19:50:16.215638386 +0000
@@ -30,6 +30,7 @@ obj-$(CONFIG_JOYSTICK_PXRC) += pxrc.o
obj-$(CONFIG_JOYSTICK_QWIIC) += qwiic-joystick.o
obj-$(CONFIG_JOYSTICK_SENSEHAT) += sensehat-joystick.o
@ -2354,7 +2362,7 @@ diff -rupN linux.orig/drivers/input/joystick/Makefile linux/drivers/input/joysti
obj-$(CONFIG_JOYSTICK_STINGER) += stinger.o
diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/joystick/singleadcjoy.c
--- linux.orig/drivers/input/joystick/singleadcjoy.c 1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/input/joystick/singleadcjoy.c 2023-11-15 14:10:46.134863088 +0000
+++ linux/drivers/input/joystick/singleadcjoy.c 2023-11-28 19:50:16.215638386 +0000
@@ -0,0 +1,1416 @@
+/*----------------------------------------------------------------------------*/
+
@ -3773,8 +3781,8 @@ diff -rupN linux.orig/drivers/input/joystick/singleadcjoy.c linux/drivers/input/
+late_initcall(joypad_init);
+module_exit(joypad_exit);
diff -rupN linux.orig/drivers/input/touchscreen/goodix.c linux/drivers/input/touchscreen/goodix.c
--- linux.orig/drivers/input/touchscreen/goodix.c 2023-11-14 03:58:04.488773611 +0000
+++ linux/drivers/input/touchscreen/goodix.c 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/input/touchscreen/goodix.c 2023-11-28 13:55:02.482191017 +0000
+++ linux/drivers/input/touchscreen/goodix.c 2023-11-28 19:50:16.215638386 +0000
@@ -1037,7 +1037,7 @@ retry_get_irq_gpio:
default:
if (ts->gpiod_int && ts->gpiod_rst) {
@ -3785,8 +3793,8 @@ diff -rupN linux.orig/drivers/input/touchscreen/goodix.c linux/drivers/input/tou
}
}
diff -rupN linux.orig/drivers/power/supply/cw2015_battery.c linux/drivers/power/supply/cw2015_battery.c
--- linux.orig/drivers/power/supply/cw2015_battery.c 2023-11-14 03:58:05.048786424 +0000
+++ linux/drivers/power/supply/cw2015_battery.c 2023-11-15 14:10:46.134863088 +0000
--- linux.orig/drivers/power/supply/cw2015_battery.c 2023-11-28 13:55:04.226227817 +0000
+++ linux/drivers/power/supply/cw2015_battery.c 2023-11-28 19:50:16.215638386 +0000
@@ -553,7 +553,7 @@ static enum power_supply_property cw_bat
};
@ -3798,7 +3806,7 @@ diff -rupN linux.orig/drivers/power/supply/cw2015_battery.c linux/drivers/power/
.num_properties = ARRAY_SIZE(cw_battery_properties),
diff -rupN linux.orig/include/linux/input-polldev.h linux/include/linux/input-polldev.h
--- linux.orig/include/linux/input-polldev.h 1970-01-01 00:00:00.000000000 +0000
+++ linux/include/linux/input-polldev.h 2023-11-15 14:10:46.134863088 +0000
+++ linux/include/linux/input-polldev.h 2023-11-28 19:50:16.215638386 +0000
@@ -0,0 +1,58 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _INPUT_POLLDEV_H