@@ -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;
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@kernel.org> --- drivers/staging/nuc-led/nuc-wmi.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)