[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <602bd7c90e1e569f52db10bbe451af0436300b78.1621161037.git.mchehab+huawei@kernel.org>
Date: Sun, 16 May 2021 12:53:30 +0200
From: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
To: gregkh@...uxfoundation.org
Cc: linuxarm@...wei.com, mauro.chehab@...wei.com,
Mauro Carvalho Chehab <mchehab+huawei@...nel.org>,
"Pavel Machek" <pavel@....cz>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
linux-leds@...r.kernel.org, linux-staging@...ts.linux.dev
Subject: [PATCH 02/17] staging: nuc-wmi: detect WMI API detection
There are currently 3 known API releases:
- https://www.intel.com/content/www/us/en/support/articles/000023426/intel-nuc/intel-nuc-kits.html
- https://raw.githubusercontent.com/nomego/intel_nuc_led/master/specs/INTEL_WMI_LED_0.64.pdf
- https://www.intel.com/content/dam/support/us/en/documents/intel-nuc/WMI-Spec-Intel-NUC-NUC10ixFNx.pdf
Add a logic to detect between them, preventing the driver
to work with an unsupported version.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
---
drivers/staging/nuc-led/nuc-wmi.c | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/nuc-led/nuc-wmi.c b/drivers/staging/nuc-led/nuc-wmi.c
index 15d956ad8556..b75ddd47e443 100644
--- a/drivers/staging/nuc-led/nuc-wmi.c
+++ b/drivers/staging/nuc-led/nuc-wmi.c
@@ -26,6 +26,13 @@
#define NUM_INPUT_ARGS 4
#define NUM_OUTPUT_ARGS 3
+enum led_api_rev {
+ LED_API_UNKNOWN,
+ LED_API_NUC6,
+ LED_API_REV_0_64,
+ LED_API_REV_1_0,
+};
+
enum led_cmds {
LED_QUERY = 0x03,
LED_NEW_GET_STATUS = 0x04,
@@ -33,6 +40,7 @@ enum led_cmds {
LED_SET_VALUE = 0x06,
LED_NOTIFICATION = 0x07,
LED_SWITCH_TYPE = 0x08,
+ LED_VERSION_CONTROL = 0x09,
};
enum led_query_subcmd {
@@ -195,7 +203,7 @@ static int nuc_wmi_query_leds(struct device *dev)
struct nuc_wmi *priv = dev_get_drvdata(dev);
u8 cmd, input[NUM_INPUT_ARGS] = { 0 };
u8 output[NUM_OUTPUT_ARGS];
- int i, id, ret;
+ int i, id, ret, ver = LED_API_UNKNOWN;
u8 leds;
/*
@@ -209,12 +217,28 @@ static int nuc_wmi_query_leds(struct device *dev)
cmd = LED_QUERY;
input[0] = LED_QUERY_LIST_ALL;
ret = nuc_nmi_cmd(dev, cmd, input, output);
- if (ret) {
+ if (ret == -ENOENT) {
+ ver = LED_API_NUC6;
+ } else if (ret) {
dev_warn(dev, "error %d while listing all LEDs\n", ret);
return ret;
+ } else {
+ leds = output[0];
}
- leds = output[0];
+ if (ver != LED_API_NUC6) {
+ ret = nuc_nmi_cmd(dev, LED_VERSION_CONTROL, input, output);
+ ver = output[0] | output[1] << 16;
+ if (!ver)
+ ver = LED_API_REV_0_64;
+ else if (ver == 0x0126)
+ ver = LED_API_REV_1_0;
+ }
+
+ /* Currently, only API Revision 0.64 is supported */
+ if (ver != LED_API_REV_0_64)
+ return -ENODEV;
+
if (!leds) {
dev_warn(dev, "No LEDs found\n");
return -ENODEV;
--
2.31.1
Powered by blists - more mailing lists