* [PATCH] platform/x86: panasonic-laptop: add fan speed mode for newer models
@ 2026-06-03 1:19 Alex Yeo
2026-06-08 13:25 ` Ilpo Järvinen
0 siblings, 1 reply; 5+ messages in thread
From: Alex Yeo @ 2026-06-03 1:19 UTC (permalink / raw)
To: platform-driver-x86
Cc: alexyeo362, Kenneth Chan, Hans de Goede, Ilpo Järvinen,
linux-kernel
I have a CF-SR4 and Linux works out of the box. Compared to
previous models, this one seems to have the fans running at high speed
by default when the computer starts.
When Windows 11 is booted up, the high fan speeds persist just until the
login screen. Once the login screen shows up, the fan spins down.
I had suspected that this might be the laptop ramping down the fans when
the OS declares that it is Windows but this does not seem to be the
case.
After analyzing the DSDT and SSDT of the computer, I have found the
following:
File ssdt10.dsl under \_SB.PC00.LPCB.EC0:
Name (CEFM, Zero)
Method (SEFM, 1, Serialized)
{
CEFM = Arg0
REFM ()
}
Method (REFM, 0, Serialized)
{
If ((\S0IX == 0x03))
{
Local0 = 0x05
}
ElseIf ((CEFM == Zero))
{
Local0 = Zero
}
Else
{
Local0 = 0x02
}
\_SB.PC00.LPCB.EC0.EC88 (0xB5, 0x79, Local0, Zero)
}
\_SB.PC00.LPCB.EC0.CEFM would seem be the current value
for the fan profile. On startup, this is set to 0.
Based on the code SEFM seems the be the method to set the fan
profile and REFM is executed right after.
I don't have access to information as to what the argument officially
means but based on testing, any number above zero makes the fans spin
down and behave like the older models where it stops or runs at low
speed when its cool and ramps up when the processor gets hot.
The only relevant values for CEFM seem to be just 0 and any number above
that just gets treated the same. I personally use just 0 and 1.
0 seems to be the high fan speed mode and 1 makes it behave like
Windows.
Giving 0 as an argument reverts the fan back to the way it was during
startup where the lowest fan speed is quite high and when load is
applied, it seems to ramp up to an even higher speed which I think would
be its 100%.
A value of 1 seems to have its max speed capped lower than 0.
For both modes, fan management is still automatic.
fan_mode only shows up in sysfs only if \_SB.PC00.LPCB.EC0.CEFM and
\_SB.PC00.LPCB.EC0.SEFM are both present which should mean it should not
show up on unsupported models. I have tried not hiding it and it just
outputs a generic error when the value is read.
I also saw that variables such as eco_mode are kept in memory, however
for fan_mode I rely on getting and setting the value via ACPI.
Signed-off-by: Alex Yeo <alexyeo362@gmail.com>
---
drivers/platform/x86/panasonic-laptop.c | 98 +++++++++++++++++++++++++
1 file changed, 98 insertions(+)
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index b83113c26f88..3a8bbd633fd1 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -507,6 +507,76 @@ static int set_optd_power_state(int new_state)
return result;
}
+/* on newer models (ex: CF-SR4), fan mode can be set */
+/* check if this is available */
+
+static acpi_status check_fan_mode_present(void)
+{
+ acpi_status status = AE_OK;
+ acpi_handle handle;
+
+ /* check if read and set are available */
+ /* read fan speed profile */
+ status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", &handle);
+ if (ACPI_FAILURE(status))
+ goto out;
+ /* set fan speed profile */
+ status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.SEFM", &handle);
+ if (ACPI_FAILURE(status))
+ goto out;
+
+out:
+ return status;
+}
+
+/* get fan mode state */
+
+static int get_fan_mode_state(void)
+{
+ acpi_status status;
+ unsigned long long state;
+
+ /* bios default is zero which seems to be some sort of performance mode */
+ status = acpi_evaluate_integer(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", NULL, &state);
+ if (ACPI_FAILURE(status)) {
+ pr_err("evaluation error _SB.PC00.LPCB.EC0.CEFM\n");
+ state = -EIO;
+ }
+ int result = (int)state;
+ return result;
+}
+
+/* set fan mode */
+
+static int set_fan_mode_state(int new_state)
+{
+ int result;
+ acpi_status status;
+
+ result = get_fan_mode_state();
+ if (result < 0)
+ goto out;
+ if (new_state == result)
+ goto out;
+
+ union acpi_object param[1];
+ struct acpi_object_list input;
+
+ param[0].type = ACPI_TYPE_INTEGER;
+ param[0].integer.value = new_state;
+ input.count = 1; /* takes one arg */
+ input.pointer = param;
+
+ status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.SEFM",
+ &input, NULL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("_SB.PC00.LPCB.EC0.SEFM evaluation failed\n");
+ return -EINVAL;
+ }
+out:
+ return result;
+}
+
/* sysfs user interface functions */
@@ -778,6 +848,29 @@ static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
return count;
}
+static ssize_t fan_mode_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ int state = get_fan_mode_state();
+
+ if (state < 0)
+ return state;
+
+ return sysfs_emit(buf, "%d\n", state);
+}
+
+static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int err, val;
+
+ err = kstrtoint(buf, 10, &val);
+ if (err)
+ return err;
+ set_fan_mode_state(val);
+ return count;
+}
+
static DEVICE_ATTR_RO(numbatt);
static DEVICE_ATTR_RO(lcdtype);
static DEVICE_ATTR_RW(mute);
@@ -787,6 +880,7 @@ static DEVICE_ATTR_RW(ac_brightness);
static DEVICE_ATTR_RW(dc_brightness);
static DEVICE_ATTR_RW(current_brightness);
static DEVICE_ATTR_RW(cdpower);
+static DEVICE_ATTR_RW(fan_mode);
static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
{
@@ -803,6 +897,9 @@ static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr
if (attr == &dev_attr_current_brightness.attr)
return (pcc->num_sifr > SINF_CUR_BRIGHT) ? attr->mode : 0;
+ if (attr == &dev_attr_fan_mode.attr) /* mostly present on newer models */
+ return (ACPI_SUCCESS(check_fan_mode_present())) ? attr->mode : 0;
+
return attr->mode;
}
@@ -816,6 +913,7 @@ static struct attribute *pcc_sysfs_entries[] = {
&dev_attr_dc_brightness.attr,
&dev_attr_current_brightness.attr,
&dev_attr_cdpower.attr,
+ &dev_attr_fan_mode.attr,
NULL,
};
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] platform/x86: panasonic-laptop: add fan speed mode for newer models
2026-06-03 1:19 [PATCH] platform/x86: panasonic-laptop: add fan speed mode for newer models Alex Yeo
@ 2026-06-08 13:25 ` Ilpo Järvinen
2026-06-10 3:17 ` [RFC PATCH v2] " Alex Yeo
0 siblings, 1 reply; 5+ messages in thread
From: Ilpo Järvinen @ 2026-06-08 13:25 UTC (permalink / raw)
To: Alex Yeo, Hans de Goede
Cc: platform-driver-x86, Kenneth Chan, Ilpo Järvinen, LKML
On Wed, 3 Jun 2026, Alex Yeo wrote:
> I have a CF-SR4 and Linux works out of the box. Compared to
> previous models, this one seems to have the fans running at high speed
> by default when the computer starts.
>
> When Windows 11 is booted up, the high fan speeds persist just until the
> login screen. Once the login screen shows up, the fan spins down.
>
> I had suspected that this might be the laptop ramping down the fans when
> the OS declares that it is Windows but this does not seem to be the
> case.
>
> After analyzing the DSDT and SSDT of the computer, I have found the
> following:
>
> File ssdt10.dsl under \_SB.PC00.LPCB.EC0:
>
> Name (CEFM, Zero)
> Method (SEFM, 1, Serialized)
> {
> CEFM = Arg0
> REFM ()
> }
>
> Method (REFM, 0, Serialized)
> {
> If ((\S0IX == 0x03))
> {
> Local0 = 0x05
> }
> ElseIf ((CEFM == Zero))
> {
> Local0 = Zero
> }
> Else
> {
> Local0 = 0x02
> }
>
> \_SB.PC00.LPCB.EC0.EC88 (0xB5, 0x79, Local0, Zero)
> }
>
> \_SB.PC00.LPCB.EC0.CEFM would seem be the current value
> for the fan profile. On startup, this is set to 0.
>
> Based on the code SEFM seems the be the method to set the fan
> profile and REFM is executed right after.
>
> I don't have access to information as to what the argument officially
> means but based on testing, any number above zero makes the fans spin
> down and behave like the older models where it stops or runs at low
> speed when its cool and ramps up when the processor gets hot.
>
> The only relevant values for CEFM seem to be just 0 and any number above
> that just gets treated the same. I personally use just 0 and 1.
> 0 seems to be the high fan speed mode and 1 makes it behave like
> Windows.
>
> Giving 0 as an argument reverts the fan back to the way it was during
> startup where the lowest fan speed is quite high and when load is
> applied, it seems to ramp up to an even higher speed which I think would
> be its 100%.
>
> A value of 1 seems to have its max speed capped lower than 0.
>
> For both modes, fan management is still automatic.
>
> fan_mode only shows up in sysfs only if \_SB.PC00.LPCB.EC0.CEFM and
> \_SB.PC00.LPCB.EC0.SEFM are both present which should mean it should not
> show up on unsupported models. I have tried not hiding it and it just
> outputs a generic error when the value is read.
>
> I also saw that variables such as eco_mode are kept in memory, however
> for fan_mode I rely on getting and setting the value via ACPI.
>
> Signed-off-by: Alex Yeo <alexyeo362@gmail.com>
> ---
> drivers/platform/x86/panasonic-laptop.c | 98 +++++++++++++++++++++++++
> 1 file changed, 98 insertions(+)
>
> diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
> index b83113c26f88..3a8bbd633fd1 100644
> --- a/drivers/platform/x86/panasonic-laptop.c
> +++ b/drivers/platform/x86/panasonic-laptop.c
> @@ -507,6 +507,76 @@ static int set_optd_power_state(int new_state)
> return result;
> }
>
> +/* on newer models (ex: CF-SR4), fan mode can be set */
> +/* check if this is available */
> +
> +static acpi_status check_fan_mode_present(void)
> +{
> + acpi_status status = AE_OK;
Unnecessary initialization.
> + acpi_handle handle;
> +
> + /* check if read and set are available */
> + /* read fan speed profile */
The second comment line and the one below seems mostly duplicate
information so please drop them. If you want, you can to the first line:
/* Check if read (CEFM) and set (SEFM) are available */
> + status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", &handle);
> + if (ACPI_FAILURE(status))
> + goto out;
You should return directly from here.
And please return something else than acpi_status from this function.
> + /* set fan speed profile */
> + status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.SEFM", &handle);
> + if (ACPI_FAILURE(status))
> + goto out;
> +
> +out:
> + return status;
> +}
> +
> +/* get fan mode state */
> +
Remove blank line.
> +static int get_fan_mode_state(void)
> +{
> + acpi_status status;
> + unsigned long long state;
Please use reverse xmas-tree order.
> +
> + /* bios default is zero which seems to be some sort of performance mode */
BIOS
> + status = acpi_evaluate_integer(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", NULL, &state);
> + if (ACPI_FAILURE(status)) {
> + pr_err("evaluation error _SB.PC00.LPCB.EC0.CEFM\n");
> + state = -EIO;
Just return directly.
> + }
> + int result = (int)state;
This intermediate variable doesn't seem useful and is declared in wrong
place anyway.
> + return result;
> +}
> +
> +/* set fan mode */
> +
> +static int set_fan_mode_state(int new_state)
> +{
> + int result;
> + acpi_status status;
xmas-tree order.
> +
> + result = get_fan_mode_state();
> + if (result < 0)
> + goto out;
> + if (new_state == result)
> + goto out;
> +
> + union acpi_object param[1];
> + struct acpi_object_list input;
> +
> + param[0].type = ACPI_TYPE_INTEGER;
> + param[0].integer.value = new_state;
> + input.count = 1; /* takes one arg */
> + input.pointer = param;
> +
> + status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.SEFM",
> + &input, NULL);
Please align to (
> + if (ACPI_FAILURE(status)) {
> + pr_err("_SB.PC00.LPCB.EC0.SEFM evaluation failed\n");
Please write the error messages so that they are meaningful for
non-technical users.
Include for pr_err() is missing it seems.
> + return -EINVAL;
> + }
> +out:
> + return result;
> +}
> +
>
> /* sysfs user interface functions */
>
> @@ -778,6 +848,29 @@ static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
> return count;
> }
>
> +static ssize_t fan_mode_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + int state = get_fan_mode_state();
> +
> + if (state < 0)
As per kernel's coding style, call and its error handling should not have
an empty line in between them (and a blank line is required after local
var declarations) so you need to declarate variable first without
assigning to it on the same line.
> + return state;
> +
> + return sysfs_emit(buf, "%d\n", state);
This file seems to be lacking sysfs.h, please add the include now.
> +}
> +
> +static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + int err, val;
> +
> + err = kstrtoint(buf, 10, &val);
kstrtouint()?
But I'm unsure whether sysfs is right place for this interface. acer-wmi
driver seems to have fan mode auto/turbo selection using hwmon interface
but this driver doesn't have hwmon as is...
> + if (err)
> + return err;
> + set_fan_mode_state(val);
> + return count;
> +}
> +
> static DEVICE_ATTR_RO(numbatt);
> static DEVICE_ATTR_RO(lcdtype);
> static DEVICE_ATTR_RW(mute);
> @@ -787,6 +880,7 @@ static DEVICE_ATTR_RW(ac_brightness);
> static DEVICE_ATTR_RW(dc_brightness);
> static DEVICE_ATTR_RW(current_brightness);
> static DEVICE_ATTR_RW(cdpower);
> +static DEVICE_ATTR_RW(fan_mode);
>
> static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
> {
> @@ -803,6 +897,9 @@ static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr
> if (attr == &dev_attr_current_brightness.attr)
> return (pcc->num_sifr > SINF_CUR_BRIGHT) ? attr->mode : 0;
>
> + if (attr == &dev_attr_fan_mode.attr) /* mostly present on newer models */
> + return (ACPI_SUCCESS(check_fan_mode_present())) ? attr->mode : 0;
> +
> return attr->mode;
> }
>
> @@ -816,6 +913,7 @@ static struct attribute *pcc_sysfs_entries[] = {
> &dev_attr_dc_brightness.attr,
> &dev_attr_current_brightness.attr,
> &dev_attr_cdpower.attr,
> + &dev_attr_fan_mode.attr,
> NULL,
> };
>
>
--
i.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v2] platform/x86: panasonic-laptop: add fan speed mode for newer models
2026-06-08 13:25 ` Ilpo Järvinen
@ 2026-06-10 3:17 ` Alex Yeo
2026-06-10 9:12 ` Ilpo Järvinen
0 siblings, 1 reply; 5+ messages in thread
From: Alex Yeo @ 2026-06-10 3:17 UTC (permalink / raw)
To: platform-driver-x86
Cc: alexyeo362, Kenneth Chan, Hans de Goede, Ilpo Järvinen,
linux-kernel
I have a CF-SR4 and Linux works out of the box. Compared to
previous models, this one seems to have the fans running at high speed
by default when the computer starts.
When Windows 11 is booted up, the high fan speeds persist just until the
login screen. Once the login screen shows up, the fan spins down.
I had suspected that this might be the laptop ramping down the fans when
the OS declares that it is Windows but this does not seem to be the
case.
After analyzing the DSDT and SSDT of the computer, I have found the
following:
File ssdt10.dsl under \_SB.PC00.LPCB.EC0:
Name (CEFM, Zero)
Method (SEFM, 1, Serialized)
{
CEFM = Arg0
REFM ()
}
Method (REFM, 0, Serialized)
{
If ((\S0IX == 0x03))
{
Local0 = 0x05
}
ElseIf ((CEFM == Zero))
{
Local0 = Zero
}
Else
{
Local0 = 0x02
}
\_SB.PC00.LPCB.EC0.EC88 (0xB5, 0x79, Local0, Zero)
}
\_SB.PC00.LPCB.EC0.CEFM would seem be the current value
for the fan profile. On startup, this is set to 0.
Based on the code SEFM seems the be the method to set the fan
profile and REFM is executed right after.
I don't have access to information as to what the argument officially
means but based on testing, any number above zero makes the fans spin
down and behave like the older models where it stops or runs at low
speed when its cool and ramps up when the processor gets hot.
The only relevant values for CEFM seem to be just 0 and any number above
that just gets treated the same. I personally use just 0 and 1.
0 seems to be the high fan speed mode and 1 makes it behave like
Windows.
Giving 0 as an argument reverts the fan back to the way it was during
startup where the lowest fan speed is quite high and when load is
applied, it seems to ramp up to an even higher speed which I think would
be its 100%.
A value of 1 seems to have its max speed capped lower than 0.
For both modes, fan management is still automatic.
fan_mode only shows up in sysfs only if \_SB.PC00.LPCB.EC0.CEFM and
\_SB.PC00.LPCB.EC0.SEFM are both present which should mean it should not
show up on unsupported models. I have tried not hiding it and it just
outputs a generic error when the value is read.
I also saw that variables such as eco_mode are kept in memory, however
for fan_mode I rely on getting and setting the value via ACPI.
Signed-off-by: Alex Yeo <alexyeo362@gmail.com>
---
Thank you for taking the time to read the patch and give feedback.
I have revised the patch according to the comments.
However, for some parts I would like to clarify the following:
>Include for pr_err() is missing it seems.
>This file seems to be lacking sysfs.h, please add the include now.
For both pr_err() and sysfs.h they should be included as both are
referenced/used multiple times within the same file.
>kstrtouint()?
It takes in input via sysfs
something like:
$ echo 1 | sudo tee "/sys/devices/LNXSYSTM:00/LNXSYBUS:00/MAT0019:00/fan_mode"
and based on the other functions within the same file, the input
is expected to be a string which is converted into an int via kstrtouint()
as CEFM is an int
>But I'm unsure whether sysfs is right place for this interface. acer-wmi
>driver seems to have fan mode auto/turbo selection using hwmon interface
>but this driver doesn't have hwmon as is...
I do get what you mean. My personal goal is to have this work smoothly
with software like thermald as the vendor appears to use Intel Dynamic
Tuning Technology with non-standard ACPI methods to control the fan.
I will take a look into that and see if exposing the control via a
different way works better.
To summarize, it appears the OS calls SEFM to let the EC know the OS
has taken control of the fan. The fan then spins down until
it stops completely (level 0). This then allows the OS to set
the fan level from 0 to 100. If the processor gets too hot,
the EC intervenes and ramps up the fan.
From what I can gather, when running Windows, the vendor's driver
together with Intel DTT work together to control the fan.
Given this, I would like to ask what is the most appropriate
place in the kernel to expose this functionality?
I understand that hwmon was mentioned but I also see that
interacting with /sys/class/thermal may also be an option.
Thank you for your time.
drivers/platform/x86/panasonic-laptop.c | 99 +++++++++++++++++++++++++
1 file changed, 99 insertions(+)
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index b83113c26f88..b05f11c223f9 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -507,6 +507,72 @@ static int set_optd_power_state(int new_state)
return result;
}
+/* on newer models (ex: CF-SR4), fan mode can be set */
+/* check if this is available */
+
+static acpi_status check_fan_mode_present(void)
+{
+ acpi_handle handle;
+
+ /* check if read (CEFM) and set (SEFM) are available */
+ status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", &handle);
+ if (ACPI_FAILURE(status))
+ return -ENOENT;
+ status = acpi_get_handle(NULL, "\\_SB.PC00.LPCB.EC0.SEFM", &handle);
+ if (ACPI_FAILURE(status))
+ return -ENOENT;
+
+ return 0;
+}
+
+/* get fan mode state */
+
+static int get_fan_mode_state(void)
+{
+ unsigned long long state;
+ acpi_status status;
+
+ /* BIOS default is zero which seems to be some sort of performance mode */
+ status = acpi_evaluate_integer(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", NULL, &state);
+ if (ACPI_FAILURE(status)) {
+ pr_err("evaluation error _SB.PC00.LPCB.EC0.CEFM\n");
+ return -EIO;
+ }
+
+ return (int)state;
+}
+
+/* set fan mode */
+
+static int set_fan_mode_state(int new_state)
+{
+ acpi_status status;
+ int result;
+
+ result = get_fan_mode_state();
+ if (result < 0)
+ return result;
+ if (new_state == result)
+ return result;
+
+ union acpi_object param[1];
+ struct acpi_object_list input;
+
+ param[0].type = ACPI_TYPE_INTEGER;
+ param[0].integer.value = new_state;
+ input.count = 1; /* takes one arg */
+ input.pointer = param;
+
+ status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.SEFM",
+ &input, NULL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("Setting of fan mode via _SB.PC00.LPCB.EC0.SEFM evaluation failed. You may have an unsupported model.\n");
+ return -EINVAL;
+ }
+
+ return result;
+}
+
/* sysfs user interface functions */
@@ -778,6 +844,34 @@ static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
return count;
}
+static ssize_t fan_mode_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ int state;
+
+ state = get_fan_mode_state();
+ if (state < 0)
+ return state;
+
+ return sysfs_emit(buf, "%d\n", state);
+}
+
+static ssize_t fan_mode_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ int status;
+ int err;
+ int val;
+
+ err = kstrtoint(buf, 10, &val);
+ if (err)
+ return err;
+
+ status = set_fan_mode_state(val);
+
+ return status;
+}
+
static DEVICE_ATTR_RO(numbatt);
static DEVICE_ATTR_RO(lcdtype);
static DEVICE_ATTR_RW(mute);
@@ -787,6 +881,7 @@ static DEVICE_ATTR_RW(ac_brightness);
static DEVICE_ATTR_RW(dc_brightness);
static DEVICE_ATTR_RW(current_brightness);
static DEVICE_ATTR_RW(cdpower);
+static DEVICE_ATTR_RW(fan_mode);
static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr, int idx)
{
@@ -803,6 +898,9 @@ static umode_t pcc_sysfs_is_visible(struct kobject *kobj, struct attribute *attr
if (attr == &dev_attr_current_brightness.attr)
return (pcc->num_sifr > SINF_CUR_BRIGHT) ? attr->mode : 0;
+ if (attr == &dev_attr_fan_mode.attr) /* mostly present on newer models */
+ return (ACPI_SUCCESS(check_fan_mode_present())) ? attr->mode : 0;
+
return attr->mode;
}
@@ -816,6 +914,7 @@ static struct attribute *pcc_sysfs_entries[] = {
&dev_attr_dc_brightness.attr,
&dev_attr_current_brightness.attr,
&dev_attr_cdpower.attr,
+ &dev_attr_fan_mode.attr,
NULL,
};
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC PATCH v2] platform/x86: panasonic-laptop: add fan speed mode for newer models
2026-06-10 3:17 ` [RFC PATCH v2] " Alex Yeo
@ 2026-06-10 9:12 ` Ilpo Järvinen
2026-06-25 11:50 ` [RFC PATCH v3] " Alex Yeo
0 siblings, 1 reply; 5+ messages in thread
From: Ilpo Järvinen @ 2026-06-10 9:12 UTC (permalink / raw)
To: Alex Yeo; +Cc: platform-driver-x86, Kenneth Chan, Hans de Goede, LKML
On Wed, 10 Jun 2026, Alex Yeo wrote:
> I have a CF-SR4 and Linux works out of the box. Compared to
> previous models, this one seems to have the fans running at high speed
> by default when the computer starts.
>
> When Windows 11 is booted up, the high fan speeds persist just until the
> login screen. Once the login screen shows up, the fan spins down.
>
> I had suspected that this might be the laptop ramping down the fans when
> the OS declares that it is Windows but this does not seem to be the
> case.
>
> After analyzing the DSDT and SSDT of the computer, I have found the
> following:
>
> File ssdt10.dsl under \_SB.PC00.LPCB.EC0:
>
> Name (CEFM, Zero)
> Method (SEFM, 1, Serialized)
> {
> CEFM = Arg0
> REFM ()
> }
>
> Method (REFM, 0, Serialized)
> {
> If ((\S0IX == 0x03))
> {
> Local0 = 0x05
> }
> ElseIf ((CEFM == Zero))
> {
> Local0 = Zero
> }
> Else
> {
> Local0 = 0x02
> }
>
> \_SB.PC00.LPCB.EC0.EC88 (0xB5, 0x79, Local0, Zero)
> }
>
> \_SB.PC00.LPCB.EC0.CEFM would seem be the current value
> for the fan profile. On startup, this is set to 0.
>
> Based on the code SEFM seems the be the method to set the fan
> profile and REFM is executed right after.
>
> I don't have access to information as to what the argument officially
> means but based on testing, any number above zero makes the fans spin
> down and behave like the older models where it stops or runs at low
> speed when its cool and ramps up when the processor gets hot.
>
> The only relevant values for CEFM seem to be just 0 and any number above
> that just gets treated the same. I personally use just 0 and 1.
> 0 seems to be the high fan speed mode and 1 makes it behave like
> Windows.
>
> Giving 0 as an argument reverts the fan back to the way it was during
> startup where the lowest fan speed is quite high and when load is
> applied, it seems to ramp up to an even higher speed which I think would
> be its 100%.
>
> A value of 1 seems to have its max speed capped lower than 0.
>
> For both modes, fan management is still automatic.
>
> fan_mode only shows up in sysfs only if \_SB.PC00.LPCB.EC0.CEFM and
> \_SB.PC00.LPCB.EC0.SEFM are both present which should mean it should not
> show up on unsupported models. I have tried not hiding it and it just
> outputs a generic error when the value is read.
>
> I also saw that variables such as eco_mode are kept in memory, however
> for fan_mode I rely on getting and setting the value via ACPI.
>
> Signed-off-by: Alex Yeo <alexyeo362@gmail.com>
> ---
> Thank you for taking the time to read the patch and give feedback.
>
> I have revised the patch according to the comments.
>
> However, for some parts I would like to clarify the following:
>
> >Include for pr_err() is missing it seems.
> >This file seems to be lacking sysfs.h, please add the include now.
>
> For both pr_err() and sysfs.h they should be included as both are
> referenced/used multiple times within the same file.
I know those are pre-existing problems. But they are still missing as
direct includes and only become included indirectly through some other
header which is fragile if somebody wants to refactor those headers.
Thus, you should simply add the missing includes finally now when you add
more code that uses stuff from those includes.
Obviously it would have been better to have the includes right from the
beginning but we lack automatic tools to detect that and human reviewers
are very fallible in checking them.
> >kstrtouint()?
>
> It takes in input via sysfs
> something like:
> $ echo 1 | sudo tee "/sys/devices/LNXSYSTM:00/LNXSYBUS:00/MAT0019:00/fan_mode"
> and based on the other functions within the same file, the input
> is expected to be a string which is converted into an int via kstrtouint()
> as CEFM is an int
So what happens if you do echo -1 instead? Your changelog only talked
about positive values.
It may well be other sysfs functions could use unsigned conversion variant
too (I've not checked), but here you're adding new interface and it should
be designed the best way possible. If negative numbers are not valid
input, kstrtouint() does check that for you for free so why not use it?
Also, please leave more context visible next time when replying, I had to
look it up from the other mail!
> >But I'm unsure whether sysfs is right place for this interface. acer-wmi
> >driver seems to have fan mode auto/turbo selection using hwmon interface
> >but this driver doesn't have hwmon as is...
>
> I do get what you mean. My personal goal is to have this work smoothly
> with software like thermald as the vendor appears to use Intel Dynamic
> Tuning Technology with non-standard ACPI methods to control the fan.
> I will take a look into that and see if exposing the control via a
> different way works better.
>
> To summarize, it appears the OS calls SEFM to let the EC know the OS
> has taken control of the fan. The fan then spins down until
> it stops completely (level 0). This then allows the OS to set
> the fan level from 0 to 100. If the processor gets too hot,
> the EC intervenes and ramps up the fan.
Sounds like pwm control to me. (Though, you haven't exactly described how
that 0-100 control is done in OS but only about getting it to spin at low
speed to match the speed user/you expected.)
> >From what I can gather, when running Windows, the vendor's driver
> together with Intel DTT work together to control the fan.
>
> Given this, I would like to ask what is the most appropriate
> place in the kernel to expose this functionality?
> I understand that hwmon was mentioned but I also see that
> interacting with /sys/class/thermal may also be an option.
Can we somehow read how fast the fan currently spins so the information
could be exposed through hwmon?
You may want to look more information about hwmon and pwm as to me it
sounds pretty a good match to the fan control (based on your explanation
about about OS controlling fan speed in 0-100 range).
--
i.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [RFC PATCH v3] platform/x86: panasonic-laptop: add fan speed mode for newer models
2026-06-10 9:12 ` Ilpo Järvinen
@ 2026-06-25 11:50 ` Alex Yeo
0 siblings, 0 replies; 5+ messages in thread
From: Alex Yeo @ 2026-06-25 11:50 UTC (permalink / raw)
To: platform-driver-x86
Cc: alexyeo362, Kenneth Chan, Hans de Goede, Ilpo Järvinen,
Guenter Roeck, linux-kernel, linux-hwmon
I have a CF-SR4 and Linux works out of the box. Compared to
previous models, this one seems to have the fans running at high speed
by default when the computer starts.
When Windows 11 is booted up, the high fan speeds persist just until the
login screen. Once the login screen shows up, the fan spins down.
I had suspected that this might be the laptop ramping down the fans when
the OS declares that it is Windows but this does not seem to be the
case.
After analyzing the DSDT and SSDT of the computer, I have found the
following:
File ssdt10.dsl under \_SB.PC00.LPCB.EC0:
Name (CEFM, Zero)
Method (SEFM, 1, Serialized)
{
CEFM = Arg0
REFM ()
}
Method (REFM, 0, Serialized)
{
If ((\S0IX == 0x03))
{
Local0 = 0x05
}
ElseIf ((CEFM == Zero))
{
Local0 = Zero
}
Else
{
Local0 = 0x02
}
\_SB.PC00.LPCB.EC0.EC88 (0xB5, 0x79, Local0, Zero)
}
\_SB.PC00.LPCB.EC0.CEFM would seem be the current value
for the fan profile. On startup, this is set to 0.
Based on the code SEFM seems the be the method to set the fan
profile and REFM is executed right after.
I don't have access to information as to what the argument officially
means but based on testing, any number above zero makes the fans spin
down and behave like the older models where it stops or runs at low
speed when its cool and ramps up when the processor gets hot.
The only relevant values for CEFM seem to be just 0 and any number above
that just gets treated the same. I personally use just 0 and 1.
0 seems to be the high fan speed mode and 1 makes it behave like
Windows.
Giving 0 as an argument reverts the fan back to the way it was during
startup where the lowest fan speed is quite high and when load is
applied, it seems to ramp up to an even higher speed which I think would
be its 100%.
A value of 1 seems to have its max speed capped lower than 0.
For both modes, fan management is still automatic.
fan_mode only shows up in sysfs only if \_SB.PC00.LPCB.EC0.CEFM and
\_SB.PC00.LPCB.EC0.SEFM are both present which should mean it should not
show up on unsupported models. I have tried not hiding it and it just
outputs a generic error when the value is read.
I also saw that variables such as eco_mode are kept in memory, however
for fan_mode I rely on getting and setting the value via ACPI.
Signed-off-by: Alex Yeo <alexyeo362@gmail.com>
---
> Can we somehow read how fast the fan currently spins so the information
> could be exposed through hwmon?
>
> You may want to look more information about hwmon and pwm as to me it
> sounds pretty a good match to the fan control (based on your explanation
> about about OS controlling fan speed in 0-100 range).
Thank you for pointing out hwmon and pwm. I have made significant
changes and rewrote the fan control so its registered as an hwmon pwm
device. I have also added it to the thermal subsystem.
All the fan sysfs functions have been removed.
> Thus, you should simply add the missing includes finally now when you add
> more code that uses stuff from those includes.
I have also added the missing includes:
> +#include <linux/printk.h>
> +#include <linux/sysfs.h>
And I have added the following as I intend to use hwmon, thermal and
DMI:
> +#include <linux/hwmon.h>
> +#include <linux/hwmon-sysfs.h>
> +#include <linux/thermal.h>
> +#include <linux/dmi.h>
I have added this for the errors I used such as EOPNOTSUPP:
> +#include <asm-generic/errno.h>
To play it safe, I think I should only assume that the fan works for my
specific model. I have looked into the other drivers and how this can be
implemented . Using quirks seems to be the standard way.
> +/* DMI matching for quirks copied from asus-nb-wmi.c */
> +static int dmi_matched(const struct dmi_system_id *dmi)
> +{
> + pr_info("Identified laptop model '%s'\n", dmi->ident);
> + quirks = dmi->driver_data;
> + return 1;
> +}
> +
> +static const struct dmi_system_id pcc_quirks[] = {
> + {
> + .callback = dmi_matched,
> + .ident = "Panasonic Connect Co., Ltd. CFSR4-1",
> + .matches = {
> + DMI_MATCH(DMI_SYS_VENDOR, "Panasonic Connect Co., Ltd."),
> + DMI_MATCH(DMI_PRODUCT_NAME, "CFSR4-1"),
> + },
> + .driver_data = &quirk_cf_sr4,
> + },
> + {},
> };
I had based it from asus-nb-wmi.c
The hwmon and thermal cooling (cdev) device registration will not happen
unless the vendor and product name match.
> + /* use hwmon convention for pwm_mode */
> + if (state == ACPI_PCC_FAN_PWM_AUTO) {
> + *pwm_mode = HWMON_PCC_FAN_PWM_AUTO;
> + } else if (state != 0 && state > 0) {
> + *pwm_mode = HWMON_PCC_FAN_PWM_MANUAL;
> + } else {
In this part, I originally used the actual numerical values for the fan
being in EC mode and in manual mode. However, it may be confusing so I
declared it:
> +#define ACPI_PCC_FAN_PWM_AUTO 0x00
> +#define ACPI_PCC_FAN_PWM_MANUAL 0x01
> +#define HWMON_PCC_FAN_PWM_AUTO 0x00
> +#define HWMON_PCC_FAN_PWM_MANUAL 0x01
The values are the same but I made the distinction between the hwmon
standard value and what the ACPI function returns.
This might be useful for readability or if it is changed
or modified in the future.
> + struct thermal_cooling_device *pwm_fan_cdev;
While I did register the hwmon device with devm so it does not need
cleanup, this is not the case with the thermal cooling device. I added
it to the pcc_acpi struct so it can be properly cleaned up when the
driver is unloaded.
Currently, with an unmodified driver, there is a fan exposed by ACPI but
it always reads N/A when viewed using the sensors command:
acpi_fan-isa-0000
Adapter: ISA adapter
fan1: N/A
The output is the same regardless of whether or not the fan is
controlled by the EC or manually.
When the computer starts up, control is always handed over to the
EC. Even on a restart, the BIOS will switch it back to EC control.
When a Linux OS boots up, it is expected that the PWM fan will read
N/A as the value from _FST (fan status) is not related at all to the
actual speed the fan is running.
panasonic_pwm_fan-isa-0000
Adapter: ISA adapter
pwm1: N/A
When in manual mode, it will look like the ff:
panasonic_pwm_fan-isa-0000
Adapter: ISA adapter
pwm1: 0% MANUAL CONTROL
I do have a question I want to ask regarding fan control. There is an
ACPI command that needs to be called first to set the fan to manual
control. When in EC mode, setting the fan speed via _FSL will not do
anything. This is why the code will check the current fan mode first
before setting the fan level.
Should the code automatically set the fan to manual mode first when the
fan speed is set?
For example,
$ echo 50 | sudo tee "/sys/devices/platform/MAT0019:00/hwmon/hwmon6/pwm1"
If the following is executed and the fan is still controlled by the EC,
should the driver automatically run the command to switch the fan into
manual mode? The current behavior is it does for both hwmon and thermal.
For the hwmon and thermal device I have named it the following:
hwmon: "panasonic_pwm_fan"
> + hwmon_dev = devm_hwmon_device_register_with_info(
> + &pdev->dev, "panasonic_pwm_fan", NULL,
> + &pcc_pwm_fan_hwmon_chip_info, NULL);
thermal: "Panasonic_PWM_Fan"
> + pcc->pwm_fan_cdev = thermal_cooling_device_register(
> + "Panasonic_PWM_Fan", NULL, &pcc_pwm_fan_cdev_ops);
If it would be more helpful I can put these into a #define at the top of
the file.
I am currently using this patch on my computer and it works with
thermald. Though I need to specify which cooling device type to use.
The way the fan works:
\_SB.PC00.LPCB.EC0.SEFM - 0 for EC and 1 for manual (there is a 5 but
that seems to be reserved for S01X sleep)
\_SB.PC00.LPCB.EC0.TFN1._FSL - accepts 0-100 and appears to be the
standard _FSL function defined in the ACPI spec but in a non-standard
path. If set without setting the fan mode, it is ignored by the system.
0 turns off the fan and 100 sets it to full speed. When the command is
given, the EC slowly ramps up the fan speed (not instant).
\_SB.PC00.LPCB.EC0.TFN1._FST - the second element contains the current
fan speed. This is only reflective of actual speed when the fan mode is
set to manual.
When in manual mode, the EC intervenes to turn the fan on if the
processor gets hot (around ~90 degrees Celsius).
The fan would be controlled like this from the OS:
In the case of hwmon:
$ echo 0 | sudo tee /sys/class/hwmon/hwmon6/pwm1 # turn fan off
$ echo 255 | sudo tee /sys/class/hwmon/hwmon6/pwm1 # full speed
$ echo 70 | sudo tee /sys/class/hwmon/hwmon6/pwm1 # any value in between
$ echo 0 | sudo tee /sys/class/hwmon/hwmon6/pwm1_enable # EC mode
$ echo 1 | sudo tee /sys/class/hwmon/hwmon6/pwm1_enable # manual mode
Setting a speed via hwmon will automatically put the fan into manual
mode. This will be reflected when pwm1_enable is called.
For thermal:
$ echo 0 | sudo tee /sys/class/thermal/cooling_device14/cur_state # off
$ echo 100 | sudo tee /sys/class/thermal/cooling_device14/cur_state # max
$ echo 50 | sudo tee /sys/class/thermal/cooling_device14/cur_state # 50%
The driver always queries the current state of the fan (both the fan
speed and the fan mode) from ACPI and does not retain the state within
the module.
To summarize, I have added hwmon and thermal for the fan. To prevent
this from affecting other models, I have implemented quirks that use DMI
vendor and product name.
For thermald I currently use the thermal subsystem to control the fan
via trip points. With this patch and thermald, it is now set and forget on my
computer (the fan is not stuck at ~80% anymore).
I have also added one more modification that was not mentioned
earlier.
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
I have added this at the top of the file so that messages from this
module are more easily identified.
> [93927.430133] Unknown hotkey event: 0x0031
I get a lot of these on dmesg and having it be:
> [93927.430133] panasonic_laptop: Unknown hotkey event: 0x0031
instead makes it easier to determine where this is from.
(happens when I press the fn key)
> So what happens if you do echo -1 instead? Your changelog only talked
> about positive values.
> + /* check if within bounds */
> + if (set_pwm_speed < 0 || set_pwm_speed > 100) {
> + pr_err("%s: error: fan speed level out of bounds\n", __func__);
> + result = -EIO;
> + goto out;
> + }
For this one I have added checks to make sure only values 0-100 are set.
Its not sysfs input so kstrtouint is not used anymore.
Thank you for taking a look.
drivers/platform/x86/panasonic-laptop.c | 461 +++++++++++++++++++++++-
1 file changed, 447 insertions(+), 14 deletions(-)
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
index b83113c26f88..59419cdd857e 100644
--- a/drivers/platform/x86/panasonic-laptop.c
+++ b/drivers/platform/x86/panasonic-laptop.c
@@ -119,6 +119,9 @@
* - v0.1 start from toshiba_acpi driver written by John Belmonte
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/printk.h>
#include <linux/acpi.h>
#include <linux/backlight.h>
#include <linux/bits.h>
@@ -136,6 +139,12 @@
#include <linux/types.h>
#include <linux/uaccess.h>
#include <acpi/video.h>
+#include <linux/sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/thermal.h>
+#include <linux/dmi.h>
+#include <asm-generic/errno.h>
MODULE_AUTHOR("Hiroshi Miura <miura@da-cha.org>");
MODULE_AUTHOR("David Bronaugh <dbronaugh@linuxboxen.org>");
@@ -164,6 +173,17 @@ MODULE_LICENSE("GPL");
#define ACPI_PCC_INPUT_PHYS "panasonic/hkey0"
+/* Define fan PWM modes */
+#define ACPI_PCC_FAN_PWM_AUTO 0x00
+#define ACPI_PCC_FAN_PWM_MANUAL 0x01
+#define HWMON_PCC_FAN_PWM_AUTO 0x00
+#define HWMON_PCC_FAN_PWM_MANUAL 0x01
+
+/* Define quirks for this driver */
+struct quirk_entry {
+ bool has_ospm_pwm_fan;
+};
+
/* LCD_TYPEs: 0 = Normal, 1 = Semi-transparent
ECO_MODEs: 0x03 = off, 0x83 = on
*/
@@ -238,19 +258,50 @@ static const struct key_entry panasonic_keymap[] = {
};
struct pcc_acpi {
- acpi_handle handle;
- unsigned long num_sifr;
- int sticky_key;
- int eco_mode;
- int mute;
- int ac_brightness;
- int dc_brightness;
- int current_brightness;
- u32 *sinf;
- struct acpi_device *device;
- struct input_dev *input_dev;
- struct backlight_device *backlight;
- struct platform_device *platform;
+ acpi_handle handle;
+ unsigned long num_sifr;
+ int sticky_key;
+ int eco_mode;
+ int mute;
+ int ac_brightness;
+ int dc_brightness;
+ int current_brightness;
+ u32 *sinf;
+ struct acpi_device *device;
+ struct input_dev *input_dev;
+ struct backlight_device *backlight;
+ struct platform_device *platform;
+ struct thermal_cooling_device *pwm_fan_cdev;
+};
+
+/*
+ * Declare quirks and apply matches
+ */
+static struct quirk_entry *quirks;
+
+static struct quirk_entry quirk_cf_sr4 = {
+ .has_ospm_pwm_fan = true,
+};
+
+/* DMI matching for quirks copied from asus-nb-wmi.c */
+static int dmi_matched(const struct dmi_system_id *dmi)
+{
+ pr_info("Identified laptop model '%s'\n", dmi->ident);
+ quirks = dmi->driver_data;
+ return 1;
+}
+
+static const struct dmi_system_id pcc_quirks[] = {
+ {
+ .callback = dmi_matched,
+ .ident = "Panasonic Connect Co., Ltd. CFSR4-1",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Panasonic Connect Co., Ltd."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "CFSR4-1"),
+ },
+ .driver_data = &quirk_cf_sr4,
+ },
+ {},
};
/*
@@ -415,7 +466,6 @@ static const struct backlight_ops pcc_backlight_ops = {
.update_status = bl_set_status,
};
-
/* returns ACPI_SUCCESS if methods to control optical drive are present */
static acpi_status check_optd_present(void)
@@ -507,6 +557,179 @@ static int set_optd_power_state(int new_state)
return result;
}
+/* get OSPM fan mode */
+
+static int pcc_pwm_fan_mode_read(int *pwm_mode)
+{
+ unsigned long long state;
+ acpi_status status;
+ int result;
+
+ /* BIOS default is zero which seems to be some sort of failsafe mode */
+ status = acpi_evaluate_integer(NULL, "\\_SB.PC00.LPCB.EC0.CEFM", NULL,
+ &state);
+ if (ACPI_FAILURE(status)) {
+ pr_err("error: cannot get fan mode via CEFM\n");
+ result = -EIO;
+ goto out;
+ }
+
+ /* use hwmon convention for pwm_mode */
+ if (state == ACPI_PCC_FAN_PWM_AUTO) {
+ *pwm_mode = HWMON_PCC_FAN_PWM_AUTO;
+ } else if (state != 0 && state > 0) {
+ *pwm_mode = HWMON_PCC_FAN_PWM_MANUAL;
+ } else {
+ /* unknown */
+ result = -EINVAL;
+ goto out;
+ }
+
+ result = AE_OK;
+
+out:
+ return result;
+}
+
+/* set OSPM fan mode */
+
+static int pcc_pwm_fan_mode_set(int pwm_mode)
+{
+ acpi_status status;
+ int result;
+
+ union acpi_object param[1];
+ struct acpi_object_list input;
+
+ param[0].type = ACPI_TYPE_INTEGER;
+ param[0].integer.value = pwm_mode;
+ input.count = 1; /* takes one arg */
+ input.pointer = param;
+
+ status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.SEFM", &input,
+ NULL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("error: cannot set fan mode via SEFM\n");
+ result = -EINVAL;
+ goto out;
+ }
+
+ result = AE_OK;
+
+out:
+ return result;
+}
+
+/* read PWM fan speed */
+
+static int pcc_pwm_fan_speed_read(int *pwm_speed)
+{
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ union acpi_object *obj;
+ acpi_status status;
+ int pwm_mode;
+ int result;
+
+
+ /* Get fan status first */
+ /* If fan is not in manual mode, it will return a bogus value */
+ status = pcc_pwm_fan_mode_read(&pwm_mode);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan status\n", __func__);
+ result = -EIO;
+ goto out;
+ }
+
+ if (pwm_mode == HWMON_PCC_FAN_PWM_AUTO) {
+ result = -ENODATA; /* Indeterminate value */
+ goto out;
+ }
+
+ /* get pwm speed */
+ status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.TFN1._FST",
+ NULL, &buffer);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get pwm speed\n", __func__);
+ result = -EIO;
+ goto out;
+ }
+
+ obj = buffer.pointer;
+
+ /* the structure should have 3 values */
+ if (!obj || obj->type != ACPI_TYPE_PACKAGE || obj->package.count < 2) {
+ pr_err("Invalid _FST package structure (expected 3)\n");
+ result = -EINVAL;
+ goto out;
+ }
+
+ /* the second element should be the pwm speed as an int */
+ if (obj->package.elements[1].type != ACPI_TYPE_INTEGER) {
+ pr_err("_FST element at index 1 is not an integer\n");
+ result = -EINVAL;
+ goto out;
+ }
+
+ *pwm_speed = obj->package.elements[1].integer.value;
+ result = AE_OK;
+
+out:
+ kfree(buffer.pointer);
+ return result;
+}
+
+/* set PWM fan speed */
+
+static int pcc_pwm_fan_speed_set(int set_pwm_speed)
+{
+ struct acpi_object_list input;
+ union acpi_object param[1];
+ acpi_status status;
+ int pwm_mode;
+ int result;
+
+ /* Get fan status. set to manual if not set */
+ status = pcc_pwm_fan_mode_read(&pwm_mode);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan status\n", __func__);
+ result = -EIO;
+ goto out;
+ }
+
+ if (pwm_mode == HWMON_PCC_FAN_PWM_AUTO) {
+ status = pcc_pwm_fan_mode_set(HWMON_PCC_FAN_PWM_MANUAL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: set fan PWM to manual failed\n", __func__);
+ result = -EIO;
+ goto out;
+ }
+ }
+
+ /* check if within bounds */
+ if (set_pwm_speed < 0 || set_pwm_speed > 100) {
+ pr_err("%s: error: fan speed level out of bounds\n", __func__);
+ result = -EIO;
+ goto out;
+ }
+
+ param[0].type = ACPI_TYPE_INTEGER;
+ param[0].integer.value = set_pwm_speed;
+ input.count = 1; /* takes one arg */
+ input.pointer = param;
+
+ status = acpi_evaluate_object(NULL, "\\_SB.PC00.LPCB.EC0.TFN1._FSL",
+ &input, NULL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("Setting of fan speed via ._FSL failed.\n");
+ result = -EINVAL;
+ goto out;
+ }
+
+ result = AE_OK;
+
+out:
+ return result;
+}
/* sysfs user interface functions */
@@ -676,6 +899,7 @@ static ssize_t ac_brightness_show(struct device *dev, struct device_attribute *a
return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_AC_CUR_BRIGHT]);
}
+
static ssize_t ac_brightness_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
@@ -825,6 +1049,178 @@ static const struct attribute_group pcc_attr_group = {
.is_visible = pcc_sysfs_is_visible,
};
+/* hwmon */
+
+static const struct hwmon_channel_info *const pcc_pwm_fan_hwmon_info[] = {
+ HWMON_CHANNEL_INFO(pwm, HWMON_PWM_INPUT | HWMON_PWM_ENABLE), NULL
+};
+
+static int pcc_pwm_fan_hwmon_read(struct device *dev,
+ enum hwmon_sensor_types type, u32 attr,
+ int channel, long *val)
+{
+ acpi_status status;
+ int pwm_speed;
+ int pwm_mode;
+
+ if (type != hwmon_pwm)
+ return -EOPNOTSUPP;
+
+ switch (attr) {
+ case hwmon_pwm_input:
+ status = pcc_pwm_fan_speed_read(&pwm_speed);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan pwm speed\n", __func__);
+ return -ENODATA;
+ }
+ *val = (pwm_speed * 255) / 100;
+ return 0;
+ case hwmon_pwm_enable:
+ status = pcc_pwm_fan_mode_read(&pwm_mode);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan pwm mode\n", __func__);
+ return -ENODATA;
+ }
+ if (pwm_mode == HWMON_PCC_FAN_PWM_AUTO) {
+ *val = HWMON_PCC_FAN_PWM_AUTO;
+ } else if (pwm_mode == HWMON_PCC_FAN_PWM_MANUAL) {
+ *val = HWMON_PCC_FAN_PWM_MANUAL;
+ } else { /* Invalid value */
+ return -EIO;
+ }
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static int pcc_pwm_fan_hwmon_write(struct device *dev,
+ enum hwmon_sensor_types type, u32 attr,
+ int channel, long val)
+{
+ int pwm_speed_vendor_val;
+ acpi_status status;
+
+ if (type != hwmon_pwm)
+ return -EOPNOTSUPP;
+
+ switch (attr) {
+ case hwmon_pwm_enable:
+ if (val == HWMON_PCC_FAN_PWM_AUTO) {
+ status = pcc_pwm_fan_mode_set(HWMON_PCC_FAN_PWM_AUTO);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to set fan to auto mode\n", __func__);
+ return -EIO;
+ }
+ return 0;
+ } else if (val == HWMON_PCC_FAN_PWM_MANUAL) {
+ status = pcc_pwm_fan_mode_set(HWMON_PCC_FAN_PWM_MANUAL);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to set fan to manual mode\n", __func__);
+ return -EIO;
+ }
+ return 0;
+ }
+ return -EINVAL;
+ case hwmon_pwm_input:
+ val = clamp_val(val, 0, 255);
+ pwm_speed_vendor_val = (val * 100) / 255;
+
+ status = pcc_pwm_fan_speed_set(pwm_speed_vendor_val);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to set fan pwm\n", __func__);
+ return -EIO;
+ }
+ return 0;
+ default:
+ return -EOPNOTSUPP;
+ }
+}
+
+static umode_t pcc_pwm_fan_hwmon_is_visible(const void *data,
+ enum hwmon_sensor_types type,
+ u32 attr, int channel)
+{
+ if (type != hwmon_pwm)
+ return 0;
+
+ return 0644;
+}
+
+static const struct hwmon_ops pcc_pwm_fan_hwmon_ops = {
+ .is_visible = pcc_pwm_fan_hwmon_is_visible,
+ .read = pcc_pwm_fan_hwmon_read,
+ .write = pcc_pwm_fan_hwmon_write,
+};
+
+static const struct hwmon_chip_info pcc_pwm_fan_hwmon_chip_info = {
+ .ops = &pcc_pwm_fan_hwmon_ops,
+ .info = pcc_pwm_fan_hwmon_info,
+};
+
+/* thermal interface */
+static int pcc_pwm_fan_thermal_max_state(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ *state = 100; /* range of 0-100 as per UEFI spec */
+ return 0;
+}
+static int
+pcc_pwm_fan_thermal_get_current_pwm(struct thermal_cooling_device *cdev,
+ unsigned long *state)
+{
+ acpi_status status;
+ int current_pwm;
+ int pwm_mode;
+
+ status = pcc_pwm_fan_mode_read(&pwm_mode);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan pwm mode\n", __func__);
+ return -ENODATA;
+ }
+ if (pwm_mode == HWMON_PCC_FAN_PWM_AUTO) {
+ *state = 100; /* Return failsafe value on EC mode */
+ return 0;
+ }
+
+ status = pcc_pwm_fan_speed_read(¤t_pwm);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to get fan pwm mode\n", __func__);
+ return -ENODATA;
+ }
+
+ if (current_pwm > 100)
+ current_pwm = 100;
+ if (current_pwm < 0)
+ return -EINVAL;
+
+ *state = current_pwm;
+
+ return 0;
+}
+static int pcc_pwm_fan_thermal_set_fan_pwm(struct thermal_cooling_device *cdev,
+ unsigned long state)
+{
+ acpi_status status;
+ int set_pwm;
+
+ if (state > 100 || state < 0)
+ return -EINVAL;
+
+ set_pwm = state;
+ status = pcc_pwm_fan_speed_set(set_pwm);
+ if (ACPI_FAILURE(status)) {
+ pr_err("%s: failed to set fan speed pwm\n", __func__);
+ return -EIO;
+ }
+
+ return 0;
+}
+static const struct thermal_cooling_device_ops pcc_pwm_fan_cdev_ops = {
+ .get_max_state = pcc_pwm_fan_thermal_max_state,
+ .get_cur_state = pcc_pwm_fan_thermal_get_current_pwm,
+ .set_cur_state = pcc_pwm_fan_thermal_set_fan_pwm,
+};
/* hotkey input device driver */
@@ -981,8 +1377,10 @@ static int acpi_pcc_hotkey_resume(struct device *dev)
static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
{
+ const struct dmi_system_id *dmi_id;
struct backlight_properties props;
struct acpi_device *device;
+ struct device *hwmon_dev;
struct pcc_acpi *pcc;
int num_sifr, result;
@@ -1026,6 +1424,17 @@ static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
strscpy(acpi_device_name(device), ACPI_PCC_DEVICE_NAME);
strscpy(acpi_device_class(device), ACPI_PCC_CLASS);
+ /*
+ * Perform quirk detection
+ */
+ dmi_id = dmi_first_match(pcc_quirks);
+ if (dmi_id) {
+ pcc->quirks = dmi_id->driver_data;
+ pr_info("Quirk detect: Enabled quirks for %s\n", dmi_id->ident);
+ } else {
+ pcc->quirks = NULL;
+ }
+
result = acpi_pcc_init_input(pcc);
if (result) {
pr_err("Error installing keyinput handler\n");
@@ -1097,6 +1506,27 @@ static int acpi_pcc_hotkey_probe(struct platform_device *pdev)
}
i8042_install_filter(panasonic_i8042_filter, NULL);
+
+ /* has_ospm_pwm_fan - add hwmon and thermal if present */
+ if (pcc->quirks->has_ospm_pwm_fan) {
+ pr_info("has_ospm_pwm_fan quirk: adding hwmon for %s\n", dmi_id->ident);
+ hwmon_dev = devm_hwmon_device_register_with_info(
+ &pdev->dev, "panasonic_pwm_fan", NULL,
+ &pcc_pwm_fan_hwmon_chip_info, NULL);
+ if (IS_ERR(hwmon_dev)) {
+ pr_err("has_ospm_pwm_fan: Failed to register hwmon device\n");
+ return PTR_ERR(hwmon_dev);
+ }
+
+ pr_info("has_ospm_pwm_fan quirk: adding thermal for %s\n", dmi_id->ident);
+ pcc->pwm_fan_cdev = thermal_cooling_device_register(
+ "Panasonic_PWM_Fan", NULL, &pcc_pwm_fan_cdev_ops);
+ if (IS_ERR(pcc->pwm_fan_cdev)) {
+ pr_warn("has_ospm_pwm_fan: Failed to register thermal cdev\n");
+ pcc->pwm_fan_cdev = NULL;
+ }
+ }
+
return 0;
out_platform:
@@ -1124,6 +1554,9 @@ static void acpi_pcc_hotkey_remove(struct platform_device *pdev)
struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
struct pcc_acpi *pcc = acpi_driver_data(device);
+ if (pcc->pwm_fan_cdev)
+ thermal_cooling_device_unregister(pcc->pwm_fan_cdev);
+
i8042_remove_filter(panasonic_i8042_filter);
if (pcc->platform) {
--
2.54.0
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-06-25 11:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03 1:19 [PATCH] platform/x86: panasonic-laptop: add fan speed mode for newer models Alex Yeo
2026-06-08 13:25 ` Ilpo Järvinen
2026-06-10 3:17 ` [RFC PATCH v2] " Alex Yeo
2026-06-10 9:12 ` Ilpo Järvinen
2026-06-25 11:50 ` [RFC PATCH v3] " Alex Yeo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome