Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Input: soc_button_array - support AMD variant Surface devices
The power button on the AMD variant of the Surface Laptop uses the
same MSHW0040 device ID as the 5th and later generation of Surface
devices, however they report 0 for their OEM platform revision.  As the
_DSM does not exist on the devices requiring special casing, check for
the existance of the _DSM to determine if soc_button_array should be
loaded.

Fixes: c394159 ("Input: soc_button_array - add support for newer surface devices")
Co-developed-by: Maximilian Luz <luzmaximilian@gmail.com>

Signed-off-by: Sachi King <nakato@nakato.io>
  • Loading branch information
nakato committed Oct 5, 2021
1 parent 6d5f7fb commit 1927c0b
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions drivers/input/misc/soc_button_array.c
Expand Up @@ -474,8 +474,8 @@ static const struct soc_device_data soc_device_INT33D3 = {
* Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned
* devices use MSHW0040 for power and volume buttons, however the way they
* have to be addressed differs. Make sure that we only load this drivers
* for the correct devices by checking the OEM Platform Revision provided by
* the _DSM method.
* for the correct devices by checking if the OEM Platform Revision DSM call
* exists.
*/
#define MSHW0040_DSM_REVISION 0x01
#define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision
Expand All @@ -486,31 +486,14 @@ static const guid_t MSHW0040_DSM_UUID =
static int soc_device_check_MSHW0040(struct device *dev)
{
acpi_handle handle = ACPI_HANDLE(dev);
union acpi_object *result;
u64 oem_platform_rev = 0; // valid revisions are nonzero

// get OEM platform revision
result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
MSHW0040_DSM_REVISION,
MSHW0040_DSM_GET_OMPR, NULL,
ACPI_TYPE_INTEGER);

if (result) {
oem_platform_rev = result->integer.value;
ACPI_FREE(result);
}

/*
* If the revision is zero here, the _DSM evaluation has failed. This
* indicates that we have a Pro 4 or Book 1 and this driver should not
* be used.
*/
if (oem_platform_rev == 0)
return -ENODEV;
bool exists;

dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
// check if OEM platform revision DSM call exists
exists = acpi_check_dsm(handle, &MSHW0040_DSM_UUID,
MSHW0040_DSM_REVISION,
BIT(MSHW0040_DSM_GET_OMPR));

return 0;
return exists ? 0 : -ENODEV;
}

/*
Expand Down

0 comments on commit 1927c0b

Please sign in to comment.