diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c index dc128fa9f99cd..bf585f976b30f 100644 --- a/drivers/platform/x86/lenovo/wmi-other.c +++ b/drivers/platform/x86/lenovo/wmi-other.c @@ -26,7 +26,6 @@ * - binding to Capability Data 00 and Fan */ -#include #include #include #include @@ -47,6 +46,8 @@ #include #include +#include + #include "wmi-capdata.h" #include "wmi-events.h" #include "wmi-gamezone.h" @@ -64,7 +65,6 @@ enum lwmi_feature_id_cpu { LWMI_FEATURE_ID_CPU_APU = 0x05, LWMI_FEATURE_ID_CPU_CL = 0x06, LWMI_FEATURE_ID_CPU_TAU = 0x07, - LWMI_FEATURE_ID_CPU_OC = 0x08, LWMI_FEATURE_ID_CPU_IPL = 0x09, }; @@ -73,7 +73,6 @@ enum lwmi_feature_id_gpu { LWMI_FEATURE_ID_GPU_NV_CTGP = 0x02, LWMI_FEATURE_ID_GPU_TEMP = 0x03, LWMI_FEATURE_ID_GPU_AC_OFFSET = 0x04, - LWMI_FEATURE_ID_GPU_OC = 0x05, LWMI_FEATURE_ID_DGPU_BOOST_CLK = 0x06, LWMI_FEATURE_ID_DGPU_EN = 0x07, LWMI_FEATURE_ID_GPU_MODE = 0x08, @@ -100,6 +99,7 @@ enum lwmi_feature_id_psu { #define LWMI_FAN_ID_BASE 1 #define LWMI_FAN_NR 4 #define LWMI_FAN_ID(x) ((x) + LWMI_FAN_ID_BASE) + #define LWMI_FAN_DIV 100 #define LWMI_CHARGE_MODE_ENABLED 0x00 @@ -113,7 +113,8 @@ enum lwmi_feature_id_psu { LWMI_ATTR_ID(LWMI_DEVICE_ID_PSU, feat, \ LWMI_GZ_THERMAL_MODE_NONE, type) -#define LWMI_OM_NAME "lenovo-wmi-other" +#define LWMI_OM_SYSFS_NAME "lenovo-wmi-other" +#define LWMI_OM_HWMON_NAME "lenovo_wmi_other" static BLOCKING_NOTIFIER_HEAD(om_chain_head); static DEFINE_IDA(lwmi_om_ida); @@ -470,7 +471,7 @@ static void lwmi_om_hwmon_add(struct lwmi_om_priv *priv) } priv->hwmon_dev = hwmon_device_register_with_info(&priv->wdev->dev, - LWMI_OM_NAME, priv, + LWMI_OM_HWMON_NAME, priv, &lwmi_om_hwmon_chip_info, NULL); if (IS_ERR(priv->hwmon_dev)) { @@ -582,7 +583,7 @@ static void lwmi_om_fan_info_collect_cd_fan(struct device *dev, struct cd_list * /* ======== Power Supply Extension (component: lenovo-wmi-capdata 00) ======== */ /** - * lwmi_psy_prop_is_writeable() - Get a power_supply_ext property + * lwmi_psy_ext_get_prop() - Get a power_supply_ext property * @ps: The battery that was extended * @ext: The extension * @ext_data: Pointer the lwmi_om_priv drvdata @@ -595,11 +596,11 @@ static void lwmi_om_fan_info_collect_cd_fan(struct device *dev, struct cd_list * */ static int lwmi_psy_ext_get_prop(struct power_supply *ps, const struct power_supply_ext *ext, - void *data, + void *ext_data, enum power_supply_property prop, union power_supply_propval *val) { - struct lwmi_om_priv *priv = data; + struct lwmi_om_priv *priv = ext_data; struct wmi_method_args_32 args; u32 retval; int ret; @@ -623,7 +624,7 @@ static int lwmi_psy_ext_get_prop(struct power_supply *ps, } /** - * lwmi_psy_prop_is_writeable() - Set a power_supply_ext property + * lwmi_psy_ext_set_prop() - Set a power_supply_ext property * @ps: The battery that was extended * @ext: The extension * @ext_data: Pointer the lwmi_om_priv drvdata @@ -692,7 +693,7 @@ static const enum power_supply_property lwmi_psy_ext_props[] = { }; static const struct power_supply_ext lwmi_psy_ext = { - .name = LWMI_OM_NAME, + .name = LWMI_OM_SYSFS_NAME, .properties = lwmi_psy_ext_props, .num_properties = ARRAY_SIZE(lwmi_psy_ext_props), .charge_types = (BIT(POWER_SUPPLY_CHARGE_TYPE_STANDARD) | @@ -731,13 +732,13 @@ static int lwmi_remove_battery(struct power_supply *battery, struct acpi_battery /** * lwmi_acpi_match() - Attempts to return the ideapad acpi handle - * @acpi_handle: The ACPI handle that manages battery charging + * @handle: The ACPI handle that manages battery charging * @lvl: Unused * @context: Void pointer to the acpi_handle object to return * @retval: Unused * * Checks if the ideapad_laptop driver is going to manage charge_type first, - * thenm if not, hooks the battery to our WMI methods. + * then if not, hooks the battery to our WMI methods. * * Return: AE_CTRL_TERMINATE if found, AE_OK if not found. */ @@ -758,7 +759,7 @@ static acpi_status lwmi_acpi_match(acpi_handle handle, u32 lvl, * @priv: Driver private data * * Checks if the ideapad_laptop driver is going to manage charge_type first, - * thenm if not, hooks the battery to our WMI methods. + * then if not, hooks the battery to our WMI methods. */ static void lwmi_om_ps_ext_init(struct lwmi_om_priv *priv) { @@ -860,12 +861,6 @@ static struct tunable_attr_01 ppt_pl1_tau = { .type_id = LWMI_TYPE_ID_NONE, }; -static struct tunable_attr_01 cpu_oc_stat = { - .device_id = LWMI_DEVICE_ID_CPU, - .feature_id = LWMI_FEATURE_ID_CPU_OC, - .type_id = LWMI_TYPE_ID_NONE, -}; - static struct tunable_attr_01 ppt_pl4_ipl = { .device_id = LWMI_DEVICE_ID_CPU, .feature_id = LWMI_FEATURE_ID_CPU_IPL, @@ -902,12 +897,6 @@ static struct tunable_attr_01 gpu_nv_ac_offset = { .type_id = LWMI_TYPE_ID_NONE, }; -static struct tunable_attr_01 gpu_oc_stat = { - .device_id = LWMI_DEVICE_ID_GPU, - .feature_id = LWMI_FEATURE_ID_GPU_OC, - .type_id = LWMI_TYPE_ID_NONE, -}; - static struct tunable_attr_01 dgpu_boost_clk = { .device_id = LWMI_DEVICE_ID_GPU, .feature_id = LWMI_FEATURE_ID_DGPU_BOOST_CLK, @@ -1383,6 +1372,12 @@ static int lwmi_attr_01_is_supported(struct tunable_attr_01 *tunable_attr) } /* CPU tunable attributes */ +LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp", + "Set the CPU thermal load limit"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl", + "Set the CPU cross loading power limit"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_apu_spl, "ppt_pl1_apu_spl", + "Set the APU sustained power limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl, "ppt_pl1_spl", "Set the CPU sustained power limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_spl_cl, "ppt_pl1_spl_cl", @@ -1395,69 +1390,58 @@ LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt, "ppt_pl3_fppt", "Set the CPU fast package power tracking limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl3_fppt_cl, "ppt_pl3_fppt_cl", "Set the CPU cross loading fast package power tracking limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_temp, "cpu_temp", - "Set the CPU thermal load limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_apu_spl, "ppt_pl1_apu_spl", - "Set the APU sustained power limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_cpu_cl, "ppt_cpu_cl", - "Set the CPU cross loading power limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl1_tau, "ppt_pl1_tau", "Set the CPU sustained power limit exceed duration"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(cpu_oc_stat, "cpu_oc_stat", - "Set the CPU overclocking status"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl, "ppt_pl4_ipl", "Set the CPU instantaneous power limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(ppt_pl4_ipl_cl, "ppt_pl4_ipl_cl", "Set the CPU cross loading instantaneous power limit"); /* GPU tunable attributes */ -LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab", - "Set the Nvidia GPU power performance aware boost limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp", - "Set the GPU configurable total graphics power"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp", - "Set the GPU thermal load limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset", - "Set the Nvidia GPU AC total processing power baseline offset"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_oc_stat, "gpu_oc_stat", - "Set the GPU overclocking status"); LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_boost_clk, "gpu_boost_clk", "Set the dedicated GPU boost clock"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid", + "Get the GPU device identifier and vendor identifier"); LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_enable, "dgpu_enable", "Set the dedicated Nvidia GPU enabled status"); LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_mode, "gpu_mode", "Set the GPU mode by power limit"); -LWMI_ATTR_GROUP_TUNABLE_CAP01(dgpu_didvid, "gpu_didvid", - "Get the GPU device identifier and vendor identifier"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ac_offset, "gpu_nv_ac_offset", + "Set the Nvidia GPU AC total processing power baseline offset"); LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_bpl, "gpu_nv_bpl", "Set the Nvidia GPU base power limit"); LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_cpu_boost, "gpu_nv_cpu_boost", "Set the Nvidia GPU to CPU dynamic boost limit"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ctgp, "gpu_nv_ctgp", + "Set the GPU configurable total graphics power"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_nv_ppab, "gpu_nv_ppab", + "Set the Nvidia GPU power performance aware boost limit"); +LWMI_ATTR_GROUP_TUNABLE_CAP01(gpu_temp, "gpu_temp", + "Set the GPU thermal load limit"); static struct capdata01_attr_group cd01_attr_groups[] = { + { &cpu_temp_attr_group, &cpu_temp }, + { &dgpu_boost_clk_attr_group, &dgpu_boost_clk }, + { &dgpu_didvid_attr_group, &dgpu_didvid }, + { &dgpu_enable_attr_group, &dgpu_enable }, + { &gpu_mode_attr_group, &gpu_mode }, + { &gpu_nv_ac_offset_attr_group, &gpu_nv_ac_offset }, + { &gpu_nv_bpl_attr_group, &gpu_nv_bpl }, + { &gpu_nv_cpu_boost_attr_group, &gpu_nv_cpu_boost }, + { &gpu_nv_ctgp_attr_group, &gpu_nv_ctgp }, + { &gpu_nv_ppab_attr_group, &gpu_nv_ppab }, + { &gpu_temp_attr_group, &gpu_temp }, + { &ppt_cpu_cl_attr_group, &ppt_cpu_cl }, + { &ppt_pl1_apu_spl_attr_group, &ppt_pl1_apu_spl }, { &ppt_pl1_spl_attr_group, &ppt_pl1_spl }, { &ppt_pl1_spl_cl_attr_group, &ppt_pl1_spl_cl }, + { &ppt_pl1_tau_attr_group, &ppt_pl1_tau }, { &ppt_pl2_sppt_attr_group, &ppt_pl2_sppt }, { &ppt_pl2_sppt_cl_attr_group, &ppt_pl2_sppt_cl }, { &ppt_pl3_fppt_attr_group, &ppt_pl3_fppt }, { &ppt_pl3_fppt_cl_attr_group, &ppt_pl3_fppt_cl }, - { &cpu_temp_attr_group, &cpu_temp }, - { &ppt_pl1_apu_spl_attr_group, &ppt_pl1_apu_spl }, - { &ppt_cpu_cl_attr_group, &ppt_cpu_cl }, - { &ppt_pl1_tau_attr_group, &ppt_pl1_tau }, - { &cpu_oc_stat_attr_group, &cpu_oc_stat }, { &ppt_pl4_ipl_attr_group, &ppt_pl4_ipl }, { &ppt_pl4_ipl_cl_attr_group, &ppt_pl4_ipl_cl }, - { &gpu_nv_ppab_attr_group, &gpu_nv_ppab }, - { &gpu_nv_ctgp_attr_group, &gpu_nv_ctgp }, - { &gpu_temp_attr_group, &gpu_temp }, - { &gpu_nv_ac_offset_attr_group, &gpu_nv_ac_offset }, - { &gpu_oc_stat_attr_group, &gpu_oc_stat }, - { &dgpu_boost_clk_attr_group, &dgpu_boost_clk }, - { &dgpu_enable_attr_group, &dgpu_enable }, - { &dgpu_didvid_attr_group, &dgpu_didvid }, - { &gpu_nv_bpl_attr_group, &gpu_nv_bpl }, - { &gpu_nv_cpu_boost_attr_group, &gpu_nv_cpu_boost }, {}, }; @@ -1478,7 +1462,7 @@ static int lwmi_om_fw_attr_add(struct lwmi_om_priv *priv) priv->fw_attr_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0), NULL, "%s-%u", - LWMI_OM_NAME, priv->ida_id); + LWMI_OM_SYSFS_NAME, priv->ida_id); if (IS_ERR(priv->fw_attr_dev)) { err = PTR_ERR(priv->fw_attr_dev); goto err_free_ida;