/* * Some of the buttons like volume up/down are auto repeat, while others * are not. To support both, we register two platform devices, and put * buttons into them based on whether the key should be auto repeat.
*/ #define BUTTON_TYPES 2
/* * Some 2-in-1s which use the soc_button_array driver have this ugly issue in * their DSDT where the _LID method modifies the irq-type settings of the GPIOs * used for the power and home buttons. The intend of this AML code is to * disable these buttons when the lid is closed. * The AML does this by directly poking the GPIO controllers registers. This is * problematic because when re-enabling the irq, which happens whenever _LID * gets called with the lid open (e.g. on boot and on resume), it sets the * irq-type to IRQ_TYPE_LEVEL_LOW. Where as the gpio-keys driver programs the * type to, and expects it to be, IRQ_TYPE_EDGE_BOTH. * To work around this we don't set gpio_keys_button.gpio on these 2-in-1s, * instead we get the irq for the GPIO ourselves, configure it as * IRQ_TYPE_LEVEL_LOW (to match how the _LID AML code configures it) and pass * the irq in gpio_keys_button.irq. Below is a list of affected devices.
*/ staticconststruct dmi_system_id dmi_use_low_level_irq[] = {
{ /* * Acer Switch 10 SW5-012. _LID method messes with home- and * power-button GPIO IRQ settings. When (re-)enabling the irq * it ors in its own flags without clearing the previous set * ones, leading to an irq-type of IRQ_TYPE_LEVEL_LOW | * IRQ_TYPE_LEVEL_HIGH causing a continuous interrupt storm.
*/
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"),
},
},
{ /* Acer Switch V 10 SW5-017, same issue as Acer Switch 10 SW5-012. */
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
DMI_MATCH(DMI_PRODUCT_NAME, "SW5-017"),
},
},
{ /* * Acer One S1003. _LID method messes with power-button GPIO * IRQ settings, leading to a non working power-button.
*/
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
DMI_MATCH(DMI_PRODUCT_NAME, "One S1003"),
},
},
{ /* * Lenovo Yoga Tab2 1051F/1051L, something messes with the home-button * IRQ settings, leading to a non working home-button.
*/
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
DMI_MATCH(DMI_PRODUCT_NAME, "60073"),
DMI_MATCH(DMI_PRODUCT_VERSION, "1051"),
},
},
{} /* Terminating entry */
};
/* * Some devices have a wrong entry which points to a GPIO which is * required in another driver, so this driver must not claim it.
*/ staticconststruct dmi_system_id dmi_invalid_acpi_index[] = {
{ /* * Lenovo Yoga Book X90F / X90L, the PNP0C40 home button entry * points to a GPIO which is not a home button and which is * required by the lenovo-yogabook driver.
*/
.matches = {
DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "CHERRYVIEW D1 PLATFORM"),
DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "YETI-11"),
},
.driver_data = (void *)1l,
},
{} /* Terminating entry */
};
/* * Get the Nth GPIO number from the ACPI object.
*/ staticint soc_button_lookup_gpio(struct device *dev, int acpi_index, int *gpio_ret, int *irq_ret)
{ struct gpio_desc *desc;
desc = gpiod_get_index(dev, NULL, acpi_index, GPIOD_ASIS); if (IS_ERR(desc)) return PTR_ERR(desc);
dmi_id = dmi_first_match(dmi_invalid_acpi_index); if (dmi_id)
invalid_acpi_index = (long)dmi_id->driver_data;
for (info = button_info; info->name; info++) { if (info->autorepeat != autorepeat) continue;
if (info->acpi_index == invalid_acpi_index) continue;
error = soc_button_lookup_gpio(&pdev->dev, info->acpi_index, &gpio, &irq); if (error || irq < 0) { /* * Skip GPIO if not present. Note we deliberately * ignore -EPROBE_DEFER errors here. On some devices * Intel is using so called virtual GPIOs which are not * GPIOs at all but some way for AML code to check some * random status bits without need a custom opregion. * In some cases the resources table we parse points to * such a virtual GPIO, since these are not real GPIOs * we do not have a driver for these so they will never * show up, therefore we ignore -EPROBE_DEFER.
*/ continue;
}
/* * Button info for Microsoft Surface 3 (non pro), this is identical to * the PNP0C40 info except that the home button is active-high. * * The Surface 3 Pro also has a MSHW0028 ACPI device, but that uses a custom * version of the drivers/platform/x86/intel/hid.c 5 button array ACPI API * instead. A check() callback is not necessary though as the Surface 3 Pro * MSHW0028 ACPI device's resource table does not contain any GPIOs.
*/ staticconststruct soc_button_info soc_button_MSHW0028[] = {
{ "power", 0, EV_KEY, KEY_POWER, false, true, true },
{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true, false },
{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false, true },
{ "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false, true },
{ }
};
/* * Special device check for Surface Book 2 and Surface Pro (2017). * 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.
*/ #define MSHW0040_DSM_REVISION 0x01 #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision staticconst guid_t MSHW0040_DSM_UUID =
GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
0x49, 0x80, 0x35);
// 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;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.