2020-03-04 15:10:45 +01:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2016-10-22 01:40:17 +02:00
|
|
|
|
2020-05-02 19:24:23 +02:00
|
|
|
#include <acpi/acpigen.h>
|
|
|
|
#include <acpi/acpigen_dsm.h>
|
2016-10-22 01:40:17 +02:00
|
|
|
|
|
|
|
/* ------------------- I2C HID DSM ---------------------------- */
|
|
|
|
|
|
|
|
#define ACPI_DSM_I2C_HID_UUID "3CDFF6F7-4267-4555-AD05-B30A3D8938DE"
|
|
|
|
|
2020-10-14 21:38:29 +02:00
|
|
|
/* I2C HID currently supports revision 1 only, for which, only 1 additional
|
|
|
|
* function is supported. Thus, the query function should return 0x3:
|
|
|
|
* bit 0 = additional function supported
|
|
|
|
* bit 1 = function with index 1 supported
|
|
|
|
* All other revisions do not support additional functions and hence return 0
|
|
|
|
*/
|
|
|
|
|
2016-10-22 01:40:17 +02:00
|
|
|
static void i2c_hid_func0_cb(void *arg)
|
|
|
|
{
|
|
|
|
/* ToInteger (Arg1, Local2) */
|
|
|
|
acpigen_write_to_integer(ARG1_OP, LOCAL2_OP);
|
2020-10-14 21:38:29 +02:00
|
|
|
/* If (LEqual (Local2, 0x1)) */
|
2016-11-14 23:16:26 +01:00
|
|
|
acpigen_write_if_lequal_op_int(LOCAL2_OP, 0x1);
|
2020-10-14 21:38:29 +02:00
|
|
|
/* Return (Buffer (One) { 0x3 }) */
|
|
|
|
acpigen_write_return_singleton_buffer(0x3);
|
2016-10-22 01:40:17 +02:00
|
|
|
acpigen_pop_len(); /* Pop : If */
|
2020-10-14 21:38:29 +02:00
|
|
|
/* Else */
|
2016-10-22 01:40:17 +02:00
|
|
|
acpigen_write_else();
|
|
|
|
/* Return (Buffer (One) { 0x0 }) */
|
|
|
|
acpigen_write_return_singleton_buffer(0x0);
|
|
|
|
acpigen_pop_len(); /* Pop : Else */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void i2c_hid_func1_cb(void *arg)
|
|
|
|
{
|
|
|
|
struct dsm_i2c_hid_config *config = arg;
|
|
|
|
acpigen_write_return_byte(config->hid_desc_reg_offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void (*i2c_hid_callbacks[2])(void *) = {
|
|
|
|
i2c_hid_func0_cb,
|
|
|
|
i2c_hid_func1_cb,
|
|
|
|
};
|
|
|
|
|
|
|
|
void acpigen_write_dsm_i2c_hid(struct dsm_i2c_hid_config *config)
|
|
|
|
{
|
|
|
|
acpigen_write_dsm(ACPI_DSM_I2C_HID_UUID, i2c_hid_callbacks,
|
|
|
|
ARRAY_SIZE(i2c_hid_callbacks), config);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------- End: I2C HID DSM ------------------------- */
|