|
@@ -15,7 +15,7 @@ Patchset: surface-sam
|
|
|
1 file changed, 3 insertions(+)
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
-index 0fe5be5396525..0d8c8395c5886 100644
|
|
|
+index 0fe5be539652..0d8c8395c588 100644
|
|
|
--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
@@ -367,6 +367,9 @@ static const struct acpi_device_id ssam_platform_hub_match[] = {
|
|
@@ -29,7 +29,7 @@ index 0fe5be5396525..0d8c8395c5886 100644
|
|
|
{ "MSHW0123", (unsigned long)ssam_node_group_sls },
|
|
|
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From 04a113aa335b566860380818090ed0ce606377c0 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
@@ -49,7 +49,7 @@ Patchset: surface-sam
|
|
|
1 file changed, 21 insertions(+), 4 deletions(-)
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
-index 0d8c8395c5886..530db4db71aba 100644
|
|
|
+index 0d8c8395c588..530db4db71ab 100644
|
|
|
--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
@@ -247,8 +247,8 @@ static const struct software_node *ssam_node_group_sl5[] = {
|
|
@@ -99,7 +99,7 @@ index 0d8c8395c5886..530db4db71aba 100644
|
|
|
{ },
|
|
|
};
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From 31253c1714eef54d147ff70886be3e0b86301656 Mon Sep 17 00:00:00 2001
|
|
|
From: Ivor Wanders <ivor@iwanders.net>
|
|
@@ -119,7 +119,7 @@ Patchset: surface-sam
|
|
|
1 file changed, 7 insertions(+)
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
-index 530db4db71aba..b0db25886c996 100644
|
|
|
+index 530db4db71ab..b0db25886c99 100644
|
|
|
--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
@@ -74,6 +74,12 @@ static const struct software_node ssam_node_tmp_pprof = {
|
|
@@ -144,7 +144,7 @@ index 530db4db71aba..b0db25886c996 100644
|
|
|
&ssam_node_hid_kip_keyboard,
|
|
|
&ssam_node_hid_kip_penstash,
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From ba442037211d245c84dcd4cd1ec81a09468305e6 Mon Sep 17 00:00:00 2001
|
|
|
From: Ivor Wanders <ivor@iwanders.net>
|
|
@@ -170,7 +170,7 @@ Patchset: surface-sam
|
|
|
create mode 100644 drivers/hwmon/surface_fan.c
|
|
|
|
|
|
diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst
|
|
|
-index 88dadea85cfcd..266edff78972d 100644
|
|
|
+index 88dadea85cfc..266edff78972 100644
|
|
|
--- a/Documentation/hwmon/index.rst
|
|
|
+++ b/Documentation/hwmon/index.rst
|
|
|
@@ -202,6 +202,7 @@ Hardware Monitoring Kernel Drivers
|
|
@@ -183,7 +183,7 @@ index 88dadea85cfcd..266edff78972d 100644
|
|
|
tc74
|
|
|
diff --git a/Documentation/hwmon/surface_fan.rst b/Documentation/hwmon/surface_fan.rst
|
|
|
new file mode 100644
|
|
|
-index 0000000000000..07942574c4f0c
|
|
|
+index 000000000000..07942574c4f0
|
|
|
--- /dev/null
|
|
|
+++ b/Documentation/hwmon/surface_fan.rst
|
|
|
@@ -0,0 +1,25 @@
|
|
@@ -213,7 +213,7 @@ index 0000000000000..07942574c4f0c
|
|
|
+``fan1_input`` RO Current fan speed in RPM.
|
|
|
+======================= ======= =========================================
|
|
|
diff --git a/MAINTAINERS b/MAINTAINERS
|
|
|
-index dd5de540ec0b5..63c3f93279277 100644
|
|
|
+index dd5de540ec0b..63c3f9327927 100644
|
|
|
--- a/MAINTAINERS
|
|
|
+++ b/MAINTAINERS
|
|
|
@@ -14203,6 +14203,14 @@ F: Documentation/driver-api/surface_aggregator/clients/dtx.rst
|
|
@@ -232,7 +232,7 @@ index dd5de540ec0b5..63c3f93279277 100644
|
|
|
M: Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
L: platform-driver-x86@vger.kernel.org
|
|
|
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
|
|
|
-index ec38c88921589..b5267a2fbe5f3 100644
|
|
|
+index ec38c8892158..b5267a2fbe5f 100644
|
|
|
--- a/drivers/hwmon/Kconfig
|
|
|
+++ b/drivers/hwmon/Kconfig
|
|
|
@@ -1961,6 +1961,19 @@ config SENSORS_SFCTEMP
|
|
@@ -256,7 +256,7 @@ index ec38c88921589..b5267a2fbe5f3 100644
|
|
|
tristate "Texas Instruments ADC128D818"
|
|
|
depends on I2C
|
|
|
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
|
|
|
-index 4ac9452b54304..208f7345f296e 100644
|
|
|
+index 4ac9452b5430..208f7345f296 100644
|
|
|
--- a/drivers/hwmon/Makefile
|
|
|
+++ b/drivers/hwmon/Makefile
|
|
|
@@ -198,6 +198,7 @@ obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o
|
|
@@ -269,7 +269,7 @@ index 4ac9452b54304..208f7345f296e 100644
|
|
|
obj-$(CONFIG_SENSORS_TC74) += tc74.o
|
|
|
diff --git a/drivers/hwmon/surface_fan.c b/drivers/hwmon/surface_fan.c
|
|
|
new file mode 100644
|
|
|
-index 0000000000000..7c2e3ae3eb40e
|
|
|
+index 000000000000..7c2e3ae3eb40
|
|
|
--- /dev/null
|
|
|
+++ b/drivers/hwmon/surface_fan.c
|
|
|
@@ -0,0 +1,93 @@
|
|
@@ -367,7 +367,7 @@ index 0000000000000..7c2e3ae3eb40e
|
|
|
+MODULE_DESCRIPTION("Fan Driver for Surface System Aggregator Module");
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From e44dd763f976360449d9f15ed2bb756cc18d843b Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
@@ -391,7 +391,7 @@ Patchset: surface-sam
|
|
|
create mode 100644 drivers/hwmon/surface_temp.c
|
|
|
|
|
|
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
|
|
|
-index b5267a2fbe5f3..2eedbe85d18ab 100644
|
|
|
+index b5267a2fbe5f..2eedbe85d18a 100644
|
|
|
--- a/drivers/hwmon/Kconfig
|
|
|
+++ b/drivers/hwmon/Kconfig
|
|
|
@@ -1974,6 +1974,16 @@ config SENSORS_SURFACE_FAN
|
|
@@ -412,7 +412,7 @@ index b5267a2fbe5f3..2eedbe85d18ab 100644
|
|
|
tristate "Texas Instruments ADC128D818"
|
|
|
depends on I2C
|
|
|
diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile
|
|
|
-index 208f7345f296e..310d7a2e0f069 100644
|
|
|
+index 208f7345f296..310d7a2e0f06 100644
|
|
|
--- a/drivers/hwmon/Makefile
|
|
|
+++ b/drivers/hwmon/Makefile
|
|
|
@@ -199,6 +199,7 @@ obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o
|
|
@@ -425,7 +425,7 @@ index 208f7345f296e..310d7a2e0f069 100644
|
|
|
obj-$(CONFIG_SENSORS_TC74) += tc74.o
|
|
|
diff --git a/drivers/hwmon/surface_temp.c b/drivers/hwmon/surface_temp.c
|
|
|
new file mode 100644
|
|
|
-index 0000000000000..48c3e826713f6
|
|
|
+index 000000000000..48c3e826713f
|
|
|
--- /dev/null
|
|
|
+++ b/drivers/hwmon/surface_temp.c
|
|
|
@@ -0,0 +1,165 @@
|
|
@@ -595,7 +595,7 @@ index 0000000000000..48c3e826713f6
|
|
|
+MODULE_DESCRIPTION("Thermal sensor subsystem driver for Surface System Aggregator Module");
|
|
|
+MODULE_LICENSE("GPL");
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From 41399077b077cff19e9b9133955ed81b6d7aa527 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
@@ -615,7 +615,7 @@ Patchset: surface-sam
|
|
|
1 file changed, 96 insertions(+), 17 deletions(-)
|
|
|
|
|
|
diff --git a/drivers/hwmon/surface_temp.c b/drivers/hwmon/surface_temp.c
|
|
|
-index 48c3e826713f6..4c08926139dbf 100644
|
|
|
+index 48c3e826713f..4c08926139db 100644
|
|
|
--- a/drivers/hwmon/surface_temp.c
|
|
|
+++ b/drivers/hwmon/surface_temp.c
|
|
|
@@ -17,6 +17,27 @@
|
|
@@ -790,7 +790,7 @@ index 48c3e826713f6..4c08926139dbf 100644
|
|
|
"surface_thermal", ssam_temp, &ssam_temp_hwmon_chip_info,
|
|
|
NULL);
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
|
|
|
From 37894568dd6a0bfb6422ce7c18df757fcb449512 Mon Sep 17 00:00:00 2001
|
|
|
From: Maximilian Luz <luzmaximilian@gmail.com>
|
|
@@ -808,7 +808,7 @@ Patchset: surface-sam
|
|
|
1 file changed, 7 insertions(+)
|
|
|
|
|
|
diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
-index b0db25886c996..797802d16f319 100644
|
|
|
+index b0db25886c99..797802d16f31 100644
|
|
|
--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
@@ -74,6 +74,12 @@ static const struct software_node ssam_node_tmp_pprof = {
|
|
@@ -833,5 +833,331 @@ index b0db25886c996..797802d16f319 100644
|
|
|
&ssam_node_pos_tablet_switch,
|
|
|
&ssam_node_hid_kip_keyboard,
|
|
|
--
|
|
|
-2.43.0
|
|
|
+2.44.0
|
|
|
+
|
|
|
+From b4fd0fc401f445f3946a53e94a94d8bc8386a91f Mon Sep 17 00:00:00 2001
|
|
|
+From: Ivor Wanders <ivor@iwanders.net>
|
|
|
+Date: Sat, 16 Dec 2023 15:56:39 -0500
|
|
|
+Subject: [PATCH] platform/surface: platform_profile: add fan profile switching
|
|
|
+
|
|
|
+Change naming from tmp to platform profile to clarify the module may
|
|
|
+interact with both the TMP and FAN subystems. Add functionality that
|
|
|
+switches the fan profile when the platform profile is changed.
|
|
|
+
|
|
|
+Signed-off-by: Ivor Wanders <ivor@iwanders.net>
|
|
|
+---
|
|
|
+ .../surface/surface_aggregator_registry.c | 38 +++++---
|
|
|
+ .../surface/surface_platform_profile.c | 86 ++++++++++++++++---
|
|
|
+ 2 files changed, 100 insertions(+), 24 deletions(-)
|
|
|
+
|
|
|
+diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+index 797802d16f31..7540d8736664 100644
|
|
|
+--- a/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
++++ b/drivers/platform/surface/surface_aggregator_registry.c
|
|
|
+@@ -68,8 +68,8 @@ static const struct software_node ssam_node_bat_sb3base = {
|
|
|
+ .parent = &ssam_node_hub_base,
|
|
|
+ };
|
|
|
+
|
|
|
+-/* Platform profile / performance-mode device. */
|
|
|
+-static const struct software_node ssam_node_tmp_pprof = {
|
|
|
++/* Platform profile / performance-mode device without a fan. */
|
|
|
++static const struct software_node ssam_node_tmp_perf_profile = {
|
|
|
+ .name = "ssam:01:03:01:00:01",
|
|
|
+ .parent = &ssam_node_root,
|
|
|
+ };
|
|
|
+@@ -86,6 +86,20 @@ static const struct software_node ssam_node_fan_speed = {
|
|
|
+ .parent = &ssam_node_root,
|
|
|
+ };
|
|
|
+
|
|
|
++/* Platform profile / performance-mode device with a fan, such that
|
|
|
++ * the fan controller profile can also be switched.
|
|
|
++ */
|
|
|
++static const struct property_entry ssam_node_tmp_perf_profile_has_fan[] = {
|
|
|
++ PROPERTY_ENTRY_BOOL("has_fan"),
|
|
|
++ { }
|
|
|
++};
|
|
|
++
|
|
|
++static const struct software_node ssam_node_tmp_perf_profile_with_fan = {
|
|
|
++ .name = "ssam:01:03:01:00:01",
|
|
|
++ .parent = &ssam_node_root,
|
|
|
++ .properties = ssam_node_tmp_perf_profile_has_fan,
|
|
|
++};
|
|
|
++
|
|
|
+ /* Tablet-mode switch via KIP subsystem. */
|
|
|
+ static const struct software_node ssam_node_kip_tablet_switch = {
|
|
|
+ .name = "ssam:01:0e:01:00:01",
|
|
|
+@@ -214,7 +228,7 @@ static const struct software_node ssam_node_pos_tablet_switch = {
|
|
|
+ */
|
|
|
+ static const struct software_node *ssam_node_group_gen5[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ NULL,
|
|
|
+ };
|
|
|
+
|
|
|
+@@ -225,7 +239,7 @@ static const struct software_node *ssam_node_group_sb3[] = {
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+ &ssam_node_bat_sb3base,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_bas_dtx,
|
|
|
+ &ssam_node_hid_base_keyboard,
|
|
|
+ &ssam_node_hid_base_touchpad,
|
|
|
+@@ -239,7 +253,7 @@ static const struct software_node *ssam_node_group_sl3[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_hid_main_keyboard,
|
|
|
+ &ssam_node_hid_main_touchpad,
|
|
|
+ &ssam_node_hid_main_iid5,
|
|
|
+@@ -251,7 +265,7 @@ static const struct software_node *ssam_node_group_sl5[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_hid_main_keyboard,
|
|
|
+ &ssam_node_hid_main_touchpad,
|
|
|
+ &ssam_node_hid_main_iid5,
|
|
|
+@@ -264,7 +278,7 @@ static const struct software_node *ssam_node_group_sls1[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_pos_tablet_switch,
|
|
|
+ &ssam_node_hid_sam_keyboard,
|
|
|
+ &ssam_node_hid_sam_penstash,
|
|
|
+@@ -280,7 +294,7 @@ static const struct software_node *ssam_node_group_sls2[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_pos_tablet_switch,
|
|
|
+ &ssam_node_hid_sam_keyboard,
|
|
|
+ &ssam_node_hid_sam_penstash,
|
|
|
+@@ -294,7 +308,7 @@ static const struct software_node *ssam_node_group_slg1[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ NULL,
|
|
|
+ };
|
|
|
+
|
|
|
+@@ -303,7 +317,7 @@ static const struct software_node *ssam_node_group_sp7[] = {
|
|
|
+ &ssam_node_root,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ NULL,
|
|
|
+ };
|
|
|
+
|
|
|
+@@ -313,7 +327,7 @@ static const struct software_node *ssam_node_group_sp8[] = {
|
|
|
+ &ssam_node_hub_kip,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile,
|
|
|
+ &ssam_node_kip_tablet_switch,
|
|
|
+ &ssam_node_hid_kip_keyboard,
|
|
|
+ &ssam_node_hid_kip_penstash,
|
|
|
+@@ -330,7 +344,7 @@ static const struct software_node *ssam_node_group_sp9[] = {
|
|
|
+ &ssam_node_hub_kip,
|
|
|
+ &ssam_node_bat_ac,
|
|
|
+ &ssam_node_bat_main,
|
|
|
+- &ssam_node_tmp_pprof,
|
|
|
++ &ssam_node_tmp_perf_profile_with_fan,
|
|
|
+ &ssam_node_tmp_sensors,
|
|
|
+ &ssam_node_fan_speed,
|
|
|
+ &ssam_node_pos_tablet_switch,
|
|
|
+diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
|
|
|
+index a5a3941b3f43..e54d0a8f7daa 100644
|
|
|
+--- a/drivers/platform/surface/surface_platform_profile.c
|
|
|
++++ b/drivers/platform/surface/surface_platform_profile.c
|
|
|
+@@ -1,7 +1,7 @@
|
|
|
+ // SPDX-License-Identifier: GPL-2.0+
|
|
|
+ /*
|
|
|
+ * Surface Platform Profile / Performance Mode driver for Surface System
|
|
|
+- * Aggregator Module (thermal subsystem).
|
|
|
++ * Aggregator Module (thermal and fan subsystem).
|
|
|
+ *
|
|
|
+ * Copyright (C) 2021-2022 Maximilian Luz <luzmaximilian@gmail.com>
|
|
|
+ */
|
|
|
+@@ -14,6 +14,7 @@
|
|
|
+
|
|
|
+ #include <linux/surface_aggregator/device.h>
|
|
|
+
|
|
|
++// Enum for the platform performance profile sent to the TMP module.
|
|
|
+ enum ssam_tmp_profile {
|
|
|
+ SSAM_TMP_PROFILE_NORMAL = 1,
|
|
|
+ SSAM_TMP_PROFILE_BATTERY_SAVER = 2,
|
|
|
+@@ -21,15 +22,26 @@ enum ssam_tmp_profile {
|
|
|
+ SSAM_TMP_PROFILE_BEST_PERFORMANCE = 4,
|
|
|
+ };
|
|
|
+
|
|
|
++// Enum for the fan profile sent to the FAN module. This fan profile is
|
|
|
++// only sent to the EC if the 'has_fan' property is set. The integers are
|
|
|
++// not a typo, they differ from the performance profile indices.
|
|
|
++enum ssam_fan_profile {
|
|
|
++ SSAM_FAN_PROFILE_NORMAL = 2,
|
|
|
++ SSAM_FAN_PROFILE_BATTERY_SAVER = 1,
|
|
|
++ SSAM_FAN_PROFILE_BETTER_PERFORMANCE = 3,
|
|
|
++ SSAM_FAN_PROFILE_BEST_PERFORMANCE = 4,
|
|
|
++};
|
|
|
++
|
|
|
+ struct ssam_tmp_profile_info {
|
|
|
+ __le32 profile;
|
|
|
+ __le16 unknown1;
|
|
|
+ __le16 unknown2;
|
|
|
+ } __packed;
|
|
|
+
|
|
|
+-struct ssam_tmp_profile_device {
|
|
|
++struct ssam_platform_profile_device {
|
|
|
+ struct ssam_device *sdev;
|
|
|
+ struct platform_profile_handler handler;
|
|
|
++ bool has_fan;
|
|
|
+ };
|
|
|
+
|
|
|
+ SSAM_DEFINE_SYNC_REQUEST_CL_R(__ssam_tmp_profile_get, struct ssam_tmp_profile_info, {
|
|
|
+@@ -42,6 +54,13 @@ SSAM_DEFINE_SYNC_REQUEST_CL_W(__ssam_tmp_profile_set, __le32, {
|
|
|
+ .command_id = 0x03,
|
|
|
+ });
|
|
|
+
|
|
|
++SSAM_DEFINE_SYNC_REQUEST_W(__ssam_fan_profile_set, char, {
|
|
|
++ .target_category = SSAM_SSH_TC_FAN,
|
|
|
++ .target_id = SSAM_SSH_TID_SAM,
|
|
|
++ .command_id = 0x0e,
|
|
|
++ .instance_id = 0x01,
|
|
|
++});
|
|
|
++
|
|
|
+ static int ssam_tmp_profile_get(struct ssam_device *sdev, enum ssam_tmp_profile *p)
|
|
|
+ {
|
|
|
+ struct ssam_tmp_profile_info info;
|
|
|
+@@ -62,7 +81,14 @@ static int ssam_tmp_profile_set(struct ssam_device *sdev, enum ssam_tmp_profile
|
|
|
+ return ssam_retry(__ssam_tmp_profile_set, sdev, &profile_le);
|
|
|
+ }
|
|
|
+
|
|
|
+-static int convert_ssam_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p)
|
|
|
++static int ssam_fan_profile_set(struct ssam_device *sdev, enum ssam_fan_profile p)
|
|
|
++{
|
|
|
++ char profile = p;
|
|
|
++
|
|
|
++ return ssam_retry(__ssam_fan_profile_set, sdev->ctrl, &profile);
|
|
|
++}
|
|
|
++
|
|
|
++static int convert_ssam_tmp_to_profile(struct ssam_device *sdev, enum ssam_tmp_profile p)
|
|
|
+ {
|
|
|
+ switch (p) {
|
|
|
+ case SSAM_TMP_PROFILE_NORMAL:
|
|
|
+@@ -83,7 +109,8 @@ static int convert_ssam_to_profile(struct ssam_device *sdev, enum ssam_tmp_profi
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+-static int convert_profile_to_ssam(struct ssam_device *sdev, enum platform_profile_option p)
|
|
|
++
|
|
|
++static int convert_profile_to_ssam_tmp(struct ssam_device *sdev, enum platform_profile_option p)
|
|
|
+ {
|
|
|
+ switch (p) {
|
|
|
+ case PLATFORM_PROFILE_LOW_POWER:
|
|
|
+@@ -105,20 +132,42 @@ static int convert_profile_to_ssam(struct ssam_device *sdev, enum platform_profi
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
++static int convert_profile_to_ssam_fan(struct ssam_device *sdev, enum platform_profile_option p)
|
|
|
++{
|
|
|
++ switch (p) {
|
|
|
++ case PLATFORM_PROFILE_LOW_POWER:
|
|
|
++ return SSAM_FAN_PROFILE_BATTERY_SAVER;
|
|
|
++
|
|
|
++ case PLATFORM_PROFILE_BALANCED:
|
|
|
++ return SSAM_FAN_PROFILE_NORMAL;
|
|
|
++
|
|
|
++ case PLATFORM_PROFILE_BALANCED_PERFORMANCE:
|
|
|
++ return SSAM_FAN_PROFILE_BETTER_PERFORMANCE;
|
|
|
++
|
|
|
++ case PLATFORM_PROFILE_PERFORMANCE:
|
|
|
++ return SSAM_FAN_PROFILE_BEST_PERFORMANCE;
|
|
|
++
|
|
|
++ default:
|
|
|
++ /* This should have already been caught by platform_profile_store(). */
|
|
|
++ WARN(true, "unsupported platform profile");
|
|
|
++ return -EOPNOTSUPP;
|
|
|
++ }
|
|
|
++}
|
|
|
++
|
|
|
+ static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
|
|
|
+ enum platform_profile_option *profile)
|
|
|
+ {
|
|
|
+- struct ssam_tmp_profile_device *tpd;
|
|
|
++ struct ssam_platform_profile_device *tpd;
|
|
|
+ enum ssam_tmp_profile tp;
|
|
|
+ int status;
|
|
|
+
|
|
|
+- tpd = container_of(pprof, struct ssam_tmp_profile_device, handler);
|
|
|
++ tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
|
|
|
+
|
|
|
+ status = ssam_tmp_profile_get(tpd->sdev, &tp);
|
|
|
+ if (status)
|
|
|
+ return status;
|
|
|
+
|
|
|
+- status = convert_ssam_to_profile(tpd->sdev, tp);
|
|
|
++ status = convert_ssam_tmp_to_profile(tpd->sdev, tp);
|
|
|
+ if (status < 0)
|
|
|
+ return status;
|
|
|
+
|
|
|
+@@ -129,21 +178,32 @@ static int ssam_platform_profile_get(struct platform_profile_handler *pprof,
|
|
|
+ static int ssam_platform_profile_set(struct platform_profile_handler *pprof,
|
|
|
+ enum platform_profile_option profile)
|
|
|
+ {
|
|
|
+- struct ssam_tmp_profile_device *tpd;
|
|
|
++ struct ssam_platform_profile_device *tpd;
|
|
|
+ int tp;
|
|
|
+
|
|
|
+- tpd = container_of(pprof, struct ssam_tmp_profile_device, handler);
|
|
|
++ tpd = container_of(pprof, struct ssam_platform_profile_device, handler);
|
|
|
++
|
|
|
++ tp = convert_profile_to_ssam_tmp(tpd->sdev, profile);
|
|
|
++ if (tp < 0)
|
|
|
++ return tp;
|
|
|
+
|
|
|
+- tp = convert_profile_to_ssam(tpd->sdev, profile);
|
|
|
++ tp = ssam_tmp_profile_set(tpd->sdev, tp);
|
|
|
+ if (tp < 0)
|
|
|
+ return tp;
|
|
|
+
|
|
|
+- return ssam_tmp_profile_set(tpd->sdev, tp);
|
|
|
++ if (tpd->has_fan) {
|
|
|
++ tp = convert_profile_to_ssam_fan(tpd->sdev, profile);
|
|
|
++ if (tp < 0)
|
|
|
++ return tp;
|
|
|
++ tp = ssam_fan_profile_set(tpd->sdev, tp);
|
|
|
++ }
|
|
|
++
|
|
|
++ return tp;
|
|
|
+ }
|
|
|
+
|
|
|
+ static int surface_platform_profile_probe(struct ssam_device *sdev)
|
|
|
+ {
|
|
|
+- struct ssam_tmp_profile_device *tpd;
|
|
|
++ struct ssam_platform_profile_device *tpd;
|
|
|
+
|
|
|
+ tpd = devm_kzalloc(&sdev->dev, sizeof(*tpd), GFP_KERNEL);
|
|
|
+ if (!tpd)
|
|
|
+@@ -154,6 +214,8 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
|
|
|
+ tpd->handler.profile_get = ssam_platform_profile_get;
|
|
|
+ tpd->handler.profile_set = ssam_platform_profile_set;
|
|
|
+
|
|
|
++ tpd->has_fan = device_property_read_bool(&sdev->dev, "has_fan");
|
|
|
++
|
|
|
+ set_bit(PLATFORM_PROFILE_LOW_POWER, tpd->handler.choices);
|
|
|
+ set_bit(PLATFORM_PROFILE_BALANCED, tpd->handler.choices);
|
|
|
+ set_bit(PLATFORM_PROFILE_BALANCED_PERFORMANCE, tpd->handler.choices);
|
|
|
+--
|
|
|
+2.44.0
|
|
|
|