summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Wolf <W_Armin@gmx.de>2026-03-24 23:32:08 +0300
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>2026-03-31 17:27:24 +0300
commitf3660b13495ae47d0ab2755a7b32999fb718ee5c (patch)
tree6d6186b1ee632f2b8dcc91420a1a87801778140a
parenta67a469cece4c46a729c1bb0fbe19e9572cda405 (diff)
downloadlinux-f3660b13495ae47d0ab2755a7b32999fb718ee5c.tar.xz
platform/x86: uniwill-laptop: Rework hwmon feature defines
Split hwmon feature define in smaller parts to accommodate for diverse hardware. You can now specify the presence of a cpu and/or a gpu temp sensor separately and if one or 2 fans exists. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Reviewed-by: Werner Sembach <wse@tuxedocomputers.com> Tested-by: Werner Sembach <wse@tuxedocomputers.com> Signed-off-by: Werner Sembach <wse@tuxedocomputers.com> Link: https://patch.msgid.link/20260324203413.454361-2-wse@tuxedocomputers.com Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
-rw-r--r--drivers/platform/x86/uniwill/uniwill-acpi.c68
1 files changed, 61 insertions, 7 deletions
diff --git a/drivers/platform/x86/uniwill/uniwill-acpi.c b/drivers/platform/x86/uniwill/uniwill-acpi.c
index 6341dca20b76..048b265bff37 100644
--- a/drivers/platform/x86/uniwill/uniwill-acpi.c
+++ b/drivers/platform/x86/uniwill/uniwill-acpi.c
@@ -319,8 +319,11 @@
#define UNIWILL_FEATURE_TOUCHPAD_TOGGLE BIT(2)
#define UNIWILL_FEATURE_LIGHTBAR BIT(3)
#define UNIWILL_FEATURE_BATTERY BIT(4)
-#define UNIWILL_FEATURE_HWMON BIT(5)
-#define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL BIT(6)
+#define UNIWILL_FEATURE_CPU_TEMP BIT(5)
+#define UNIWILL_FEATURE_GPU_TEMP BIT(6)
+#define UNIWILL_FEATURE_PRIMARY_FAN BIT(7)
+#define UNIWILL_FEATURE_SECONDARY_FAN BIT(8)
+#define UNIWILL_FEATURE_NVIDIA_CTGP_CONTROL BIT(9)
struct uniwill_data {
struct device *dev;
@@ -427,7 +430,7 @@ static const struct key_entry uniwill_keymap[] = {
{ KE_END }
};
-static inline bool uniwill_device_supports(struct uniwill_data *data,
+static inline bool uniwill_device_supports(const struct uniwill_data *data,
unsigned int features)
{
return (data->features & features) == features;
@@ -937,6 +940,48 @@ static const struct attribute_group *uniwill_groups[] = {
NULL
};
+static umode_t uniwill_is_visible(const void *drvdata, enum hwmon_sensor_types type, u32 attr,
+ int channel)
+{
+ const struct uniwill_data *data = drvdata;
+ unsigned int feature;
+
+ switch (type) {
+ case hwmon_temp:
+ switch (channel) {
+ case 0:
+ feature = UNIWILL_FEATURE_CPU_TEMP;
+ break;
+ case 1:
+ feature = UNIWILL_FEATURE_GPU_TEMP;
+ break;
+ default:
+ return 0;
+ }
+ break;
+ case hwmon_fan:
+ case hwmon_pwm:
+ switch (channel) {
+ case 0:
+ feature = UNIWILL_FEATURE_PRIMARY_FAN;
+ break;
+ case 1:
+ feature = UNIWILL_FEATURE_SECONDARY_FAN;
+ break;
+ default:
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+
+ if (uniwill_device_supports(data, feature))
+ return 0444;
+
+ return 0;
+}
+
static int uniwill_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, int channel,
long *val)
{
@@ -1020,7 +1065,7 @@ static int uniwill_read_string(struct device *dev, enum hwmon_sensor_types type,
}
static const struct hwmon_ops uniwill_ops = {
- .visible = 0444,
+ .is_visible = uniwill_is_visible,
.read = uniwill_read,
.read_string = uniwill_read_string,
};
@@ -1048,7 +1093,10 @@ static int uniwill_hwmon_init(struct uniwill_data *data)
{
struct device *hdev;
- if (!uniwill_device_supports(data, UNIWILL_FEATURE_HWMON))
+ if (!uniwill_device_supports(data, UNIWILL_FEATURE_CPU_TEMP) &&
+ !uniwill_device_supports(data, UNIWILL_FEATURE_GPU_TEMP) &&
+ !uniwill_device_supports(data, UNIWILL_FEATURE_PRIMARY_FAN) &&
+ !uniwill_device_supports(data, UNIWILL_FEATURE_SECONDARY_FAN))
return 0;
hdev = devm_hwmon_device_register_with_info(data->dev, "uniwill", data,
@@ -1687,7 +1735,10 @@ static struct uniwill_device_descriptor lapac71h_descriptor __initdata = {
UNIWILL_FEATURE_SUPER_KEY |
UNIWILL_FEATURE_TOUCHPAD_TOGGLE |
UNIWILL_FEATURE_BATTERY |
- UNIWILL_FEATURE_HWMON,
+ UNIWILL_FEATURE_CPU_TEMP |
+ UNIWILL_FEATURE_GPU_TEMP |
+ UNIWILL_FEATURE_PRIMARY_FAN |
+ UNIWILL_FEATURE_SECONDARY_FAN,
};
static struct uniwill_device_descriptor lapkc71f_descriptor __initdata = {
@@ -1696,7 +1747,10 @@ static struct uniwill_device_descriptor lapkc71f_descriptor __initdata = {
UNIWILL_FEATURE_TOUCHPAD_TOGGLE |
UNIWILL_FEATURE_LIGHTBAR |
UNIWILL_FEATURE_BATTERY |
- UNIWILL_FEATURE_HWMON,
+ UNIWILL_FEATURE_CPU_TEMP |
+ UNIWILL_FEATURE_GPU_TEMP |
+ UNIWILL_FEATURE_PRIMARY_FAN |
+ UNIWILL_FEATURE_SECONDARY_FAN,
};
static int phxarx1_phxaqf1_probe(struct uniwill_data *data)