Skip to content

Commit c05f67e

Browse files
Rongronggg9ij-intel
authored andcommitted
platform/x86: lenovo-wmi-capdata: Add support for Capability Data 00
Add support for LENOVO_CAPABILITY_DATA_00 WMI data block that comes on "Other Mode" enabled hardware. Provides an interface for querying if a given attribute is supported by the hardware, as well as its default value. capdata00 always presents on devices with capdata01. lenovo-wmi-other now binds to both (no functional change intended). Signed-off-by: Rong Zhang <i@rong.moe> Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Tested-by: Derek J. Clark <derekjohn.clark@gmail.com> Link: https://patch.msgid.link/20260120182104.163424-5-i@rong.moe Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 4ff1a02 commit c05f67e

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

Documentation/wmi/devices/lenovo-wmi-other.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,22 @@ under the following path:
3131

3232
/sys/class/firmware-attributes/lenovo-wmi-other/attributes/<attribute>/
3333

34+
LENOVO_CAPABILITY_DATA_00
35+
-------------------------
36+
37+
WMI GUID ``362A3AFE-3D96-4665-8530-96DAD5BB300E``
38+
39+
The LENOVO_CAPABILITY_DATA_00 interface provides various information that
40+
does not rely on the gamezone thermal mode.
41+
3442
LENOVO_CAPABILITY_DATA_01
3543
-------------------------
3644

3745
WMI GUID ``7A8F5407-CB67-4D6E-B547-39B3BE018154``
3846

39-
The LENOVO_CAPABILITY_DATA_01 interface provides information on various
40-
power limits of integrated CPU and GPU components.
47+
The LENOVO_CAPABILITY_DATA_01 interface provides various information that
48+
relies on the gamezone thermal mode, including power limits of integrated
49+
CPU and GPU components.
4150

4251
Each attribute has the following properties:
4352
- current_value
@@ -48,7 +57,7 @@ Each attribute has the following properties:
4857
- scalar_increment
4958
- type
5059

51-
The following attributes are implemented:
60+
The following firmware-attributes are implemented:
5261
- ppt_pl1_spl: Platform Profile Tracking Sustained Power Limit
5362
- ppt_pl2_sppt: Platform Profile Tracking Slow Package Power Tracking
5463
- ppt_pl3_fppt: Platform Profile Tracking Fast Package Power Tracking

drivers/platform/x86/lenovo/wmi-capdata.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* Lenovo Capability Data provides information on tunable attributes used by
66
* the "Other Mode" WMI interface.
77
*
8+
* Capability Data 00 includes if the attribute is supported by the hardware,
9+
* and the default_value. All attributes are independent of thermal modes.
10+
*
811
* Capability Data 01 includes if the attribute is supported by the hardware,
912
* and the default_value, max_value, min_value, and step increment. Each
1013
* attribute has multiple pages, one for each of the thermal modes managed by
@@ -40,12 +43,14 @@
4043

4144
#include "wmi-capdata.h"
4245

46+
#define LENOVO_CAPABILITY_DATA_00_GUID "362A3AFE-3D96-4665-8530-96DAD5BB300E"
4347
#define LENOVO_CAPABILITY_DATA_01_GUID "7A8F5407-CB67-4D6E-B547-39B3BE018154"
4448

4549
#define ACPI_AC_CLASS "ac_adapter"
4650
#define ACPI_AC_NOTIFY_STATUS 0x80
4751

4852
enum lwmi_cd_type {
53+
LENOVO_CAPABILITY_DATA_00,
4954
LENOVO_CAPABILITY_DATA_01,
5055
};
5156

@@ -59,6 +64,7 @@ static const struct lwmi_cd_info {
5964
const char *name;
6065
enum lwmi_cd_type type;
6166
} lwmi_cd_table[] = {
67+
LWMI_CD_TABLE_ITEM(LENOVO_CAPABILITY_DATA_00),
6268
LWMI_CD_TABLE_ITEM(LENOVO_CAPABILITY_DATA_01),
6369
};
6470

@@ -74,6 +80,7 @@ struct cd_list {
7480
u8 count;
7581

7682
union {
83+
DECLARE_FLEX_ARRAY(struct capdata00, cd00);
7784
DECLARE_FLEX_ARRAY(struct capdata01, cd01);
7885
};
7986
};
@@ -141,6 +148,9 @@ static int lwmi_cd_component_bind(struct device *cd_dev,
141148
struct lwmi_cd_binder *binder = data;
142149

143150
switch (priv->list->type) {
151+
case LENOVO_CAPABILITY_DATA_00:
152+
binder->cd00_list = priv->list;
153+
break;
144154
case LENOVO_CAPABILITY_DATA_01:
145155
binder->cd01_list = priv->list;
146156
break;
@@ -184,6 +194,9 @@ static const struct component_ops lwmi_cd_component_ops = {
184194
return -EINVAL; \
185195
}
186196

197+
DEF_LWMI_CDXX_GET_DATA(cd00, LENOVO_CAPABILITY_DATA_00, struct capdata00);
198+
EXPORT_SYMBOL_NS_GPL(lwmi_cd00_get_data, "LENOVO_WMI_CAPDATA");
199+
187200
DEF_LWMI_CDXX_GET_DATA(cd01, LENOVO_CAPABILITY_DATA_01, struct capdata01);
188201
EXPORT_SYMBOL_NS_GPL(lwmi_cd01_get_data, "LENOVO_WMI_CAPDATA");
189202

@@ -202,6 +215,10 @@ static int lwmi_cd_cache(struct lwmi_cd_priv *priv)
202215
void *p;
203216

204217
switch (priv->list->type) {
218+
case LENOVO_CAPABILITY_DATA_00:
219+
p = &priv->list->cd00[0];
220+
size = sizeof(priv->list->cd00[0]);
221+
break;
205222
case LENOVO_CAPABILITY_DATA_01:
206223
p = &priv->list->cd01[0];
207224
size = sizeof(priv->list->cd01[0]);
@@ -247,6 +264,9 @@ static int lwmi_cd_alloc(struct lwmi_cd_priv *priv, enum lwmi_cd_type type)
247264
count = wmidev_instance_count(priv->wdev);
248265

249266
switch (type) {
267+
case LENOVO_CAPABILITY_DATA_00:
268+
list_size = struct_size(list, cd00, count);
269+
break;
250270
case LENOVO_CAPABILITY_DATA_01:
251271
list_size = struct_size(list, cd01, count);
252272
break;
@@ -359,6 +379,9 @@ static int lwmi_cd_probe(struct wmi_device *wdev, const void *context)
359379
goto out;
360380

361381
switch (info->type) {
382+
case LENOVO_CAPABILITY_DATA_00:
383+
ret = component_add(&wdev->dev, &lwmi_cd_component_ops);
384+
goto out;
362385
case LENOVO_CAPABILITY_DATA_01:
363386
priv->acpi_nb.notifier_call = lwmi_cd01_notifier_call;
364387

@@ -392,6 +415,7 @@ static void lwmi_cd_remove(struct wmi_device *wdev)
392415
struct lwmi_cd_priv *priv = dev_get_drvdata(&wdev->dev);
393416

394417
switch (priv->list->type) {
418+
case LENOVO_CAPABILITY_DATA_00:
395419
case LENOVO_CAPABILITY_DATA_01:
396420
component_del(&wdev->dev, &lwmi_cd_component_ops);
397421
break;
@@ -405,6 +429,7 @@ static void lwmi_cd_remove(struct wmi_device *wdev)
405429
.context = &lwmi_cd_table[_type],
406430

407431
static const struct wmi_device_id lwmi_cd_id_table[] = {
432+
{ LWMI_CD_WDEV_ID(LENOVO_CAPABILITY_DATA_00) },
408433
{ LWMI_CD_WDEV_ID(LENOVO_CAPABILITY_DATA_01) },
409434
{}
410435
};

drivers/platform/x86/lenovo/wmi-capdata.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ struct component_match;
1111
struct device;
1212
struct cd_list;
1313

14+
struct capdata00 {
15+
u32 id;
16+
u32 supported;
17+
u32 default_value;
18+
};
19+
1420
struct capdata01 {
1521
u32 id;
1622
u32 supported;
@@ -21,10 +27,12 @@ struct capdata01 {
2127
};
2228

2329
struct lwmi_cd_binder {
30+
struct cd_list *cd00_list;
2431
struct cd_list *cd01_list;
2532
};
2633

2734
void lwmi_cd_match_add_all(struct device *master, struct component_match **matchptr);
35+
int lwmi_cd00_get_data(struct cd_list *list, u32 attribute_id, struct capdata00 *output);
2836
int lwmi_cd01_get_data(struct cd_list *list, u32 attribute_id, struct capdata01 *output);
2937

3038
#endif /* !_LENOVO_WMI_CAPDATA_H_ */

0 commit comments

Comments
 (0)