diff options
author | Maximilian Luz <luzmaximilian@gmail.com> | 2019-07-28 05:55:48 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2019-07-28 05:58:40 -0400 |
commit | 64dd243d735655d1ff6bc7450dd5203cf57c9dfb (patch) | |
tree | 00b1ef7c7d3ae5cb52f913857dc850a497f4102b | |
parent | 3b51c44bd6936e86a7180abd9aebc4387a479253 (diff) |
platform/x86: surfacepro3_button: Fix device check
Do not use the surfacepro3_button driver on newer Microsoft Surface
models, only use it on the Surface Pro 3 and 4. Newer models (5th, 6th
and possibly future generations) use the same device as the Surface Pro
4 to represent their volume and power buttons (MSHW0040), but their
actual implementation is significantly different. This patch ensures
that the surfacepro3_button driver is only used on the Pro 3 and 4
models, allowing a different driver to bind on other models.
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Chen Yu <yu.c.chen@intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r-- | drivers/platform/x86/surfacepro3_button.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c index 47c6d000465a..ec515223f654 100644 --- a/drivers/platform/x86/surfacepro3_button.c +++ b/drivers/platform/x86/surfacepro3_button.c | |||
@@ -20,6 +20,12 @@ | |||
20 | #define SURFACE_BUTTON_OBJ_NAME "VGBI" | 20 | #define SURFACE_BUTTON_OBJ_NAME "VGBI" |
21 | #define SURFACE_BUTTON_DEVICE_NAME "Surface Pro 3/4 Buttons" | 21 | #define SURFACE_BUTTON_DEVICE_NAME "Surface Pro 3/4 Buttons" |
22 | 22 | ||
23 | #define MSHW0040_DSM_REVISION 0x01 | ||
24 | #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision | ||
25 | static const guid_t MSHW0040_DSM_UUID = | ||
26 | GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65, | ||
27 | 0x49, 0x80, 0x35); | ||
28 | |||
23 | #define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8 | 29 | #define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8 |
24 | 30 | ||
25 | #define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6 | 31 | #define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6 |
@@ -142,6 +148,44 @@ static int surface_button_resume(struct device *dev) | |||
142 | } | 148 | } |
143 | #endif | 149 | #endif |
144 | 150 | ||
151 | /* | ||
152 | * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device | ||
153 | * ID (MSHW0040) for the power/volume buttons. Make sure this is the right | ||
154 | * device by checking for the _DSM method and OEM Platform Revision. | ||
155 | * | ||
156 | * Returns true if the driver should bind to this device, i.e. the device is | ||
157 | * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1. | ||
158 | */ | ||
159 | static bool surface_button_check_MSHW0040(struct acpi_device *dev) | ||
160 | { | ||
161 | acpi_handle handle = dev->handle; | ||
162 | union acpi_object *result; | ||
163 | u64 oem_platform_rev = 0; // valid revisions are nonzero | ||
164 | |||
165 | // get OEM platform revision | ||
166 | result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID, | ||
167 | MSHW0040_DSM_REVISION, | ||
168 | MSHW0040_DSM_GET_OMPR, | ||
169 | NULL, ACPI_TYPE_INTEGER); | ||
170 | |||
171 | /* | ||
172 | * If evaluating the _DSM fails, the method is not present. This means | ||
173 | * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we | ||
174 | * should use this driver. We use revision 0 indicating it is | ||
175 | * unavailable. | ||
176 | */ | ||
177 | |||
178 | if (result) { | ||
179 | oem_platform_rev = result->integer.value; | ||
180 | ACPI_FREE(result); | ||
181 | } | ||
182 | |||
183 | dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev); | ||
184 | |||
185 | return oem_platform_rev == 0; | ||
186 | } | ||
187 | |||
188 | |||
145 | static int surface_button_add(struct acpi_device *device) | 189 | static int surface_button_add(struct acpi_device *device) |
146 | { | 190 | { |
147 | struct surface_button *button; | 191 | struct surface_button *button; |
@@ -154,6 +198,9 @@ static int surface_button_add(struct acpi_device *device) | |||
154 | strlen(SURFACE_BUTTON_OBJ_NAME))) | 198 | strlen(SURFACE_BUTTON_OBJ_NAME))) |
155 | return -ENODEV; | 199 | return -ENODEV; |
156 | 200 | ||
201 | if (!surface_button_check_MSHW0040(device)) | ||
202 | return -ENODEV; | ||
203 | |||
157 | button = kzalloc(sizeof(struct surface_button), GFP_KERNEL); | 204 | button = kzalloc(sizeof(struct surface_button), GFP_KERNEL); |
158 | if (!button) | 205 | if (!button) |
159 | return -ENOMEM; | 206 | return -ENOMEM; |