0008-surface-button.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. From 215beb9df04b7ad9737a26091415dca9a1be37d1 Mon Sep 17 00:00:00 2001
  2. From: Sachi King <nakato@nakato.io>
  3. Date: Tue, 5 Oct 2021 00:05:09 +1100
  4. Subject: [PATCH] Input: soc_button_array - support AMD variant Surface devices
  5. The power button on the AMD variant of the Surface Laptop uses the
  6. same MSHW0040 device ID as the 5th and later generation of Surface
  7. devices, however they report 0 for their OEM platform revision. As the
  8. _DSM does not exist on the devices requiring special casing, check for
  9. the existance of the _DSM to determine if soc_button_array should be
  10. loaded.
  11. Fixes: c394159310d0 ("Input: soc_button_array - add support for newer surface devices")
  12. Co-developed-by: Maximilian Luz <luzmaximilian@gmail.com>
  13. Signed-off-by: Sachi King <nakato@nakato.io>
  14. Patchset: surface-button
  15. ---
  16. drivers/input/misc/soc_button_array.c | 33 +++++++--------------------
  17. 1 file changed, 8 insertions(+), 25 deletions(-)
  18. diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
  19. index e79f5497948b..2bddbe6e9ea4 100644
  20. --- a/drivers/input/misc/soc_button_array.c
  21. +++ b/drivers/input/misc/soc_button_array.c
  22. @@ -537,8 +537,8 @@ static const struct soc_device_data soc_device_MSHW0028 = {
  23. * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned
  24. * devices use MSHW0040 for power and volume buttons, however the way they
  25. * have to be addressed differs. Make sure that we only load this drivers
  26. - * for the correct devices by checking the OEM Platform Revision provided by
  27. - * the _DSM method.
  28. + * for the correct devices by checking if the OEM Platform Revision DSM call
  29. + * exists.
  30. */
  31. #define MSHW0040_DSM_REVISION 0x01
  32. #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision
  33. @@ -549,31 +549,14 @@ static const guid_t MSHW0040_DSM_UUID =
  34. static int soc_device_check_MSHW0040(struct device *dev)
  35. {
  36. acpi_handle handle = ACPI_HANDLE(dev);
  37. - union acpi_object *result;
  38. - u64 oem_platform_rev = 0; // valid revisions are nonzero
  39. -
  40. - // get OEM platform revision
  41. - result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
  42. - MSHW0040_DSM_REVISION,
  43. - MSHW0040_DSM_GET_OMPR, NULL,
  44. - ACPI_TYPE_INTEGER);
  45. -
  46. - if (result) {
  47. - oem_platform_rev = result->integer.value;
  48. - ACPI_FREE(result);
  49. - }
  50. -
  51. - /*
  52. - * If the revision is zero here, the _DSM evaluation has failed. This
  53. - * indicates that we have a Pro 4 or Book 1 and this driver should not
  54. - * be used.
  55. - */
  56. - if (oem_platform_rev == 0)
  57. - return -ENODEV;
  58. + bool exists;
  59. - dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
  60. + // check if OEM platform revision DSM call exists
  61. + exists = acpi_check_dsm(handle, &MSHW0040_DSM_UUID,
  62. + MSHW0040_DSM_REVISION,
  63. + BIT(MSHW0040_DSM_GET_OMPR));
  64. - return 0;
  65. + return exists ? 0 : -ENODEV;
  66. }
  67. /*
  68. --
  69. 2.41.0
  70. From 254fab464752ac4aac23cb7d27e2fb8c55ba24bd Mon Sep 17 00:00:00 2001
  71. From: Sachi King <nakato@nakato.io>
  72. Date: Tue, 5 Oct 2021 00:22:57 +1100
  73. Subject: [PATCH] platform/surface: surfacepro3_button: don't load on amd
  74. variant
  75. The AMD variant of the Surface Laptop report 0 for their OEM platform
  76. revision. The Surface devices that require the surfacepro3_button
  77. driver do not have the _DSM that gets the OEM platform revision. If the
  78. method does not exist, load surfacepro3_button.
  79. Fixes: 64dd243d7356 ("platform/x86: surfacepro3_button: Fix device check")
  80. Co-developed-by: Maximilian Luz <luzmaximilian@gmail.com>
  81. Signed-off-by: Sachi King <nakato@nakato.io>
  82. Patchset: surface-button
  83. ---
  84. drivers/platform/surface/surfacepro3_button.c | 30 ++++---------------
  85. 1 file changed, 6 insertions(+), 24 deletions(-)
  86. diff --git a/drivers/platform/surface/surfacepro3_button.c b/drivers/platform/surface/surfacepro3_button.c
  87. index 2755601f979c..4240c98ca226 100644
  88. --- a/drivers/platform/surface/surfacepro3_button.c
  89. +++ b/drivers/platform/surface/surfacepro3_button.c
  90. @@ -149,7 +149,8 @@ static int surface_button_resume(struct device *dev)
  91. /*
  92. * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
  93. * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
  94. - * device by checking for the _DSM method and OEM Platform Revision.
  95. + * device by checking for the _DSM method and OEM Platform Revision DSM
  96. + * function.
  97. *
  98. * Returns true if the driver should bind to this device, i.e. the device is
  99. * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
  100. @@ -157,30 +158,11 @@ static int surface_button_resume(struct device *dev)
  101. static bool surface_button_check_MSHW0040(struct acpi_device *dev)
  102. {
  103. acpi_handle handle = dev->handle;
  104. - union acpi_object *result;
  105. - u64 oem_platform_rev = 0; // valid revisions are nonzero
  106. -
  107. - // get OEM platform revision
  108. - result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
  109. - MSHW0040_DSM_REVISION,
  110. - MSHW0040_DSM_GET_OMPR,
  111. - NULL, ACPI_TYPE_INTEGER);
  112. -
  113. - /*
  114. - * If evaluating the _DSM fails, the method is not present. This means
  115. - * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we
  116. - * should use this driver. We use revision 0 indicating it is
  117. - * unavailable.
  118. - */
  119. -
  120. - if (result) {
  121. - oem_platform_rev = result->integer.value;
  122. - ACPI_FREE(result);
  123. - }
  124. -
  125. - dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev);
  126. - return oem_platform_rev == 0;
  127. + // make sure that OEM platform revision DSM call does not exist
  128. + return !acpi_check_dsm(handle, &MSHW0040_DSM_UUID,
  129. + MSHW0040_DSM_REVISION,
  130. + BIT(MSHW0040_DSM_GET_OMPR));
  131. }
  132. --
  133. 2.41.0