92 lines
2.4 KiB
C
92 lines
2.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/* Copyright (C) 2025 Derek J. Clark <derekjohn.clark@gmail.com> */
|
|
|
|
#ifndef _LENOVO_WMI_CAPDATA_H_
|
|
#define _LENOVO_WMI_CAPDATA_H_
|
|
|
|
#include <linux/bits.h>
|
|
#include <linux/bitfield.h>
|
|
#include <linux/types.h>
|
|
|
|
#define LWMI_SUPP_VALID BIT(0)
|
|
#define LWMI_SUPP_GET BIT(1)
|
|
#define LWMI_SUPP_SET BIT(2)
|
|
|
|
#define LWMI_ATTR_DEV_ID_MASK GENMASK(31, 24)
|
|
#define LWMI_ATTR_FEAT_ID_MASK GENMASK(23, 16)
|
|
#define LWMI_ATTR_MODE_ID_MASK GENMASK(15, 8)
|
|
#define LWMI_ATTR_TYPE_ID_MASK GENMASK(7, 0)
|
|
|
|
enum lwmi_device_id {
|
|
LWMI_DEVICE_ID_CPU = 0x01,
|
|
LWMI_DEVICE_ID_GPU = 0x02,
|
|
LWMI_DEVICE_ID_PSU = 0x03,
|
|
LWMI_DEVICE_ID_FAN = 0x04,
|
|
};
|
|
|
|
#define LWMI_TYPE_ID_NONE 0x00
|
|
|
|
struct component_match;
|
|
struct device;
|
|
struct cd_list;
|
|
|
|
struct capdata00 {
|
|
u32 id;
|
|
u32 supported;
|
|
u32 default_value;
|
|
};
|
|
|
|
struct capdata01 {
|
|
union {
|
|
struct capdata00;
|
|
struct capdata00 cd00;
|
|
};
|
|
u32 step;
|
|
u32 min_value;
|
|
u32 max_value;
|
|
};
|
|
|
|
struct capdata_fan {
|
|
u32 id;
|
|
u32 min_rpm;
|
|
u32 max_rpm;
|
|
};
|
|
|
|
typedef void (*cd_list_cb_t)(struct device *master_dev, struct cd_list *cd_list);
|
|
|
|
struct lwmi_cd_binder {
|
|
struct cd_list *cd00_list;
|
|
struct cd_list *cd01_list;
|
|
/*
|
|
* May be called during or after the bind callback.
|
|
* Will be called with NULL if capdata_fan does not exist.
|
|
* The pointer is only valid in the callback; never keep it for later use!
|
|
*/
|
|
cd_list_cb_t cd_fan_list_cb;
|
|
};
|
|
|
|
/**
|
|
* lwmi_attr_id() - Formats a capability data attribute ID
|
|
* @dev_id: The u8 corresponding to the device ID.
|
|
* @feat_id: The u8 corresponding to the feature ID on the device.
|
|
* @mode_id: The u8 corresponding to the wmi-gamezone mode for set/get.
|
|
* @type_id: The u8 corresponding to the sub-device.
|
|
*
|
|
* Return: encoded capability data attribute ID.
|
|
*/
|
|
static inline u32 lwmi_attr_id(u8 dev_id, u8 feat_id, u8 mode_id, u8 type_id)
|
|
{
|
|
return (FIELD_PREP(LWMI_ATTR_DEV_ID_MASK, dev_id) |
|
|
FIELD_PREP(LWMI_ATTR_FEAT_ID_MASK, feat_id) |
|
|
FIELD_PREP(LWMI_ATTR_MODE_ID_MASK, mode_id) |
|
|
FIELD_PREP(LWMI_ATTR_TYPE_ID_MASK, type_id));
|
|
}
|
|
|
|
void lwmi_cd_match_add_all(struct device *master, struct component_match **matchptr);
|
|
int lwmi_cd00_get_data(struct cd_list *list, u32 attribute_id, struct capdata00 *output);
|
|
int lwmi_cd01_get_data(struct cd_list *list, u32 attribute_id, struct capdata01 *output);
|
|
int lwmi_cd_fan_get_data(struct cd_list *list, u32 attribute_id, struct capdata_fan *output);
|
|
|
|
#endif /* !_LENOVO_WMI_CAPDATA_H_ */
|