asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs
v3 cover asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs
Hi,
this patch series adds support of ASUS TUF laptops on Ryzen CPUs to existing asus_wmi platform driver and also fixes minor bug.
v2: fixed indentation.
v3: patches 2/3 and 3/3 are refactored.
Leonid Maksymchuk (3):
asus_wmi: Fix return value of fan_boost_mode_store
asus_wmi: Support fan boost mode on FX505DY/FX705DY
asus_wmi: Set default fan boost mode to normal
drivers/platform/x86/asus-wmi.c | 55 ++++++++++++++++------ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 42 insertions(+), 14 deletions(-)
Signature · 1 line
2.23.0
PATCH v3 1/3 asus_wmi: Fix return value of fan_boost_mode_store
Function fan_boost_mode_store should return number of bytes written but instead it returns return value of kstrtou8 which is 0 if conversion is succefull. This leads to infinite loop after any write to it's SysFS entry.
--- drivers/platform/x86/asus-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/asus-wmi.c +1 -1
@@ -1718,7 +1718,7 @@ static ssize_t fan_boost_mode_store(struct device *dev, asus->fan_boost_mode = new_mode;fan_boost_mode_write (asus); -return result; +return count; }// Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
Signature · 1 line
2.23.0
PATCH v3 2/3 asus_wmi: Support fan boost mode on FX505DY/FX705DY
In reply to Leonid MaksymchukOn ASUS FX505DY/FX705DY laptops fan boost mode is same as in other TUF laptop models but have different ACPI device ID and different hotkey code.
--- drivers/platform/x86/asus-wmi.c | 42 +++++++++++++++------- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 31 insertions(+), 12 deletions(-)
drivers/platform/x86/asus-wmi.c +30 -12
@@ -61,6 +61,7 @@ MODULE_LICENSE("GPL");#define NOTIFY_KBD_BRTDWN 0xc5#define NOTIFY_KBD_BRTTOGGLE 0xc7#define NOTIFY_KBD_FBM 0x99 +#define NOTIFY_KBD_FBM_2 0xae#define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0)
@@ -195,6 +196,7 @@ struct asus_wmi {int agfn_pwm;bool fan_boost_mode_available; +u32 fan_boost_mode_dev_id;u8 fan_boost_mode_mask;u8 fan_boost_mode;
@@ -1611,31 +1613,46 @@ static int asus_wmi_fan_init(struct asus_wmi *asus)/* Fan mode *******************************************************************/ -static int fan_boost_mode_check_present (struct asus_wmi *asus) +static int fan_boost_mode_check_device (struct asus_wmi *asus,u32 dev_id) {u32 result;int err; - asus->fan_boost_mode_available = false; + err =asus_wmi_get_devstate (asus, dev_id, &result); - err =asus_wmi_get_devstate (asus,ASUS_WMI_DEVID_FAN_BOOST_MODE , - &result); -if (err) { -if (err == -ENODEV ) -return 0 ; -else -return err; - } +if (err) +return err;if ((result &ASUS_WMI_DSTS_PRESENCE_BIT ) && (result &ASUS_FAN_BOOST_MODES_MASK )) { asus->fan_boost_mode_available = true; + asus->fan_boost_mode_dev_id = dev_id; asus->fan_boost_mode_mask = result &ASUS_FAN_BOOST_MODES_MASK ; }return 0 ; } +static int fan_boost_mode_check_present (struct asus_wmi *asus) +{ +int err; + + asus->fan_boost_mode_available = false; + err =fan_boost_mode_check_device (asus,ASUS_WMI_DEVID_FAN_BOOST_MODE ); + +if (err && err != -ENODEV ) +return err; +else if (asus->fan_boost_mode_available) +return 0 ; + + err =fan_boost_mode_check_device (asus, +ASUS_WMI_DEVID_FAN_BOOST_MODE_2 ); +if (err == -ENODEV ) +return 0 ; + +return err; +} +static int fan_boost_mode_write (struct asus_wmi *asus) {int err;
@@ -1645,7 +1662,7 @@ static int fan_boost_mode_write(struct asus_wmi *asus) value = asus->fan_boost_mode;pr_info ("Set fan boost mode: %u\n" , value); - err =asus_wmi_set_devstate (ASUS_WMI_DEVID_FAN_BOOST_MODE , value, + err =asus_wmi_set_devstate (asus->fan_boost_mode_dev_id, value, &retval);if (err) {pr_warn ("Failed to set fan boost mode: %d\n" , err);
@@ -2000,7 +2017,8 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)return ; } -if (asus->fan_boost_mode_available && code ==NOTIFY_KBD_FBM ) { +if (asus->fan_boost_mode_available && + (code ==NOTIFY_KBD_FBM || code ==NOTIFY_KBD_FBM_2 )) {fan_boost_mode_switch_next (asus);return ; }
include/linux/platform_data/x86/asus-wmi.h +1 -0
@@ -58,6 +58,7 @@#define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022/* ?? */ #define ASUS_WMI_DEVID_LIGHTBAR 0x00050025#define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018 +#define ASUS_WMI_DEVID_FAN_BOOST_MODE_2 0x00120075/* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013
Signature · 1 line
2.23.0
PATCH v3 3/3 asus_wmi: Set default fan boost mode to normal
In reply to Leonid MaksymchukSet default fan boost mode to normal for multiple reasons:
1) existing code assumes that laptop started in normal mode and that is not always correct.
2) FX705DY/FX505DY starts in silent mode and under heavy CPU load it overheats and drops CPU frequency to 399MHz [1]. Setting fan mode to normal avoids overheating.
[1] Link: https://bugzilla.kernel.org/show_bug.cgi?id=203733
--- drivers/platform/x86/asus-wmi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/platform/x86/asus-wmi.c +10 -0
@@ -1678,6 +1678,15 @@ static int fan_boost_mode_write(struct asus_wmi *asus)return 0 ; } +static int fan_boost_mode_set_default (struct asus_wmi *asus) +{ +if (!asus->fan_boost_mode_available) +return 0 ; + + asus->fan_boost_mode =ASUS_FAN_BOOST_MODE_NORMAL ; +return fan_boost_mode_write (asus); +} +static int fan_boost_mode_switch_next (struct asus_wmi *asus) {u8 mask = asus->fan_boost_mode_mask;
@@ -2454,6 +2463,7 @@ static int asus_wmi_add(struct platform_device *pdev) err =fan_boost_mode_check_present (asus);if (err) goto fail_fan_boost_mode; +fan_boost_mode_set_default (asus); err =asus_wmi_sysfs_init (asus->platform_device);if (err)
Signature · 1 line
2.23.0
Please ignore this patch set, I'm working on v4 right now.