Linux Audio

Check our new training course

Loading...
v4.6
 
  1/*
  2 * Supports for the button array on SoC tablets originally running
  3 * Windows 8.
  4 *
  5 * (C) Copyright 2014 Intel Corporation
  6 *
  7 * This program is free software; you can redistribute it and/or
  8 * modify it under the terms of the GNU General Public License
  9 * as published by the Free Software Foundation; version 2
 10 * of the License.
 11 */
 12
 13#include <linux/module.h>
 14#include <linux/input.h>
 15#include <linux/init.h>
 16#include <linux/kernel.h>
 17#include <linux/acpi.h>
 18#include <linux/gpio/consumer.h>
 19#include <linux/gpio_keys.h>
 
 20#include <linux/platform_device.h>
 21
 22/*
 23 * Definition of buttons on the tablet. The ACPI index of each button
 24 * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
 25 * Platforms"
 26 */
 27#define MAX_NBUTTONS	5
 28
 29struct soc_button_info {
 30	const char *name;
 31	int acpi_index;
 32	unsigned int event_type;
 33	unsigned int event_code;
 34	bool autorepeat;
 35	bool wakeup;
 36};
 37
 
 
 
 
 
 38/*
 39 * Some of the buttons like volume up/down are auto repeat, while others
 40 * are not. To support both, we register two platform devices, and put
 41 * buttons into them based on whether the key should be auto repeat.
 42 */
 43#define BUTTON_TYPES	2
 44
 45struct soc_button_data {
 46	struct platform_device *children[BUTTON_TYPES];
 47};
 48
 49/*
 50 * Get the Nth GPIO number from the ACPI object.
 51 */
 52static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
 53{
 54	struct gpio_desc *desc;
 55	int gpio;
 56
 57	desc = gpiod_get_index(dev, KBUILD_MODNAME, acpi_index, GPIOD_ASIS);
 58	if (IS_ERR(desc))
 59		return PTR_ERR(desc);
 60
 61	gpio = desc_to_gpio(desc);
 62
 63	gpiod_put(desc);
 64
 65	return gpio;
 66}
 67
 68static struct platform_device *
 69soc_button_device_create(struct platform_device *pdev,
 70			 const struct soc_button_info *button_info,
 71			 bool autorepeat)
 72{
 73	const struct soc_button_info *info;
 74	struct platform_device *pd;
 75	struct gpio_keys_button *gpio_keys;
 76	struct gpio_keys_platform_data *gpio_keys_pdata;
 77	int n_buttons = 0;
 78	int gpio;
 79	int error;
 80
 
 
 
 
 81	gpio_keys_pdata = devm_kzalloc(&pdev->dev,
 82				       sizeof(*gpio_keys_pdata) +
 83					sizeof(*gpio_keys) * MAX_NBUTTONS,
 84				       GFP_KERNEL);
 85	if (!gpio_keys_pdata)
 86		return ERR_PTR(-ENOMEM);
 87
 88	gpio_keys = (void *)(gpio_keys_pdata + 1);
 
 89
 90	for (info = button_info; info->name; info++) {
 91		if (info->autorepeat != autorepeat)
 92			continue;
 93
 94		gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
 95		if (gpio < 0)
 
 
 
 
 
 
 
 
 
 
 
 96			continue;
 
 97
 98		gpio_keys[n_buttons].type = info->event_type;
 99		gpio_keys[n_buttons].code = info->event_code;
100		gpio_keys[n_buttons].gpio = gpio;
101		gpio_keys[n_buttons].active_low = 1;
102		gpio_keys[n_buttons].desc = info->name;
103		gpio_keys[n_buttons].wakeup = info->wakeup;
 
 
104		n_buttons++;
105	}
106
107	if (n_buttons == 0) {
108		error = -ENODEV;
109		goto err_free_mem;
110	}
111
112	gpio_keys_pdata->buttons = gpio_keys;
113	gpio_keys_pdata->nbuttons = n_buttons;
114	gpio_keys_pdata->rep = autorepeat;
115
116	pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
117	if (!pd) {
118		error = -ENOMEM;
 
 
 
 
 
119		goto err_free_mem;
120	}
121
122	error = platform_device_add_data(pd, gpio_keys_pdata,
123					 sizeof(*gpio_keys_pdata));
124	if (error)
125		goto err_free_pdev;
126
127	error = platform_device_add(pd);
128	if (error)
129		goto err_free_pdev;
130
131	return pd;
132
133err_free_pdev:
134	platform_device_put(pd);
135err_free_mem:
136	devm_kfree(&pdev->dev, gpio_keys_pdata);
137	return ERR_PTR(error);
138}
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140static int soc_button_remove(struct platform_device *pdev)
141{
142	struct soc_button_data *priv = platform_get_drvdata(pdev);
143
144	int i;
145
146	for (i = 0; i < BUTTON_TYPES; i++)
147		if (priv->children[i])
148			platform_device_unregister(priv->children[i]);
149
150	return 0;
151}
152
153static int soc_button_probe(struct platform_device *pdev)
154{
155	struct device *dev = &pdev->dev;
156	const struct acpi_device_id *id;
157	struct soc_button_info *button_info;
158	struct soc_button_data *priv;
159	struct platform_device *pd;
160	int i;
161	int error;
162
163	id = acpi_match_device(dev->driver->acpi_match_table, dev);
164	if (!id)
165		return -ENODEV;
 
 
 
 
 
 
 
 
 
 
 
166
167	button_info = (struct soc_button_info *)id->driver_data;
 
 
 
 
168
169	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
170	if (!priv)
171		return -ENOMEM;
172
173	platform_set_drvdata(pdev, priv);
174
175	for (i = 0; i < BUTTON_TYPES; i++) {
176		pd = soc_button_device_create(pdev, button_info, i == 0);
177		if (IS_ERR(pd)) {
178			error = PTR_ERR(pd);
179			if (error != -ENODEV) {
180				soc_button_remove(pdev);
181				return error;
182			}
183			continue;
184		}
185
186		priv->children[i] = pd;
187	}
188
189	if (!priv->children[0] && !priv->children[1])
190		return -ENODEV;
191
 
 
 
192	return 0;
193}
194
195static struct soc_button_info soc_button_PNP0C40[] = {
 
 
 
 
 
196	{ "power", 0, EV_KEY, KEY_POWER, false, true },
197	{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
198	{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
199	{ "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false },
200	{ "rotation_lock", 4, EV_SW, SW_ROTATE_LOCK, false, false },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201	{ }
202};
203
 
 
 
 
 
204static const struct acpi_device_id soc_button_acpi_match[] = {
205	{ "PNP0C40", (unsigned long)soc_button_PNP0C40 },
 
 
 
 
 
206	{ }
207};
208
209MODULE_DEVICE_TABLE(acpi, soc_button_acpi_match);
210
211static struct platform_driver soc_button_driver = {
212	.probe          = soc_button_probe,
213	.remove		= soc_button_remove,
214	.driver		= {
215		.name = KBUILD_MODNAME,
216		.acpi_match_table = ACPI_PTR(soc_button_acpi_match),
217	},
218};
219module_platform_driver(soc_button_driver);
220
221MODULE_LICENSE("GPL");
v5.4
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * Supports for the button array on SoC tablets originally running
  4 * Windows 8.
  5 *
  6 * (C) Copyright 2014 Intel Corporation
 
 
 
 
 
  7 */
  8
  9#include <linux/module.h>
 10#include <linux/input.h>
 11#include <linux/init.h>
 12#include <linux/kernel.h>
 13#include <linux/acpi.h>
 14#include <linux/gpio/consumer.h>
 15#include <linux/gpio_keys.h>
 16#include <linux/gpio.h>
 17#include <linux/platform_device.h>
 18
 
 
 
 
 
 
 
 19struct soc_button_info {
 20	const char *name;
 21	int acpi_index;
 22	unsigned int event_type;
 23	unsigned int event_code;
 24	bool autorepeat;
 25	bool wakeup;
 26};
 27
 28struct soc_device_data {
 29	const struct soc_button_info *button_info;
 30	int (*check)(struct device *dev);
 31};
 32
 33/*
 34 * Some of the buttons like volume up/down are auto repeat, while others
 35 * are not. To support both, we register two platform devices, and put
 36 * buttons into them based on whether the key should be auto repeat.
 37 */
 38#define BUTTON_TYPES	2
 39
 40struct soc_button_data {
 41	struct platform_device *children[BUTTON_TYPES];
 42};
 43
 44/*
 45 * Get the Nth GPIO number from the ACPI object.
 46 */
 47static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
 48{
 49	struct gpio_desc *desc;
 50	int gpio;
 51
 52	desc = gpiod_get_index(dev, NULL, acpi_index, GPIOD_ASIS);
 53	if (IS_ERR(desc))
 54		return PTR_ERR(desc);
 55
 56	gpio = desc_to_gpio(desc);
 57
 58	gpiod_put(desc);
 59
 60	return gpio;
 61}
 62
 63static struct platform_device *
 64soc_button_device_create(struct platform_device *pdev,
 65			 const struct soc_button_info *button_info,
 66			 bool autorepeat)
 67{
 68	const struct soc_button_info *info;
 69	struct platform_device *pd;
 70	struct gpio_keys_button *gpio_keys;
 71	struct gpio_keys_platform_data *gpio_keys_pdata;
 72	int n_buttons = 0;
 73	int gpio;
 74	int error;
 75
 76	for (info = button_info; info->name; info++)
 77		if (info->autorepeat == autorepeat)
 78			n_buttons++;
 79
 80	gpio_keys_pdata = devm_kzalloc(&pdev->dev,
 81				       sizeof(*gpio_keys_pdata) +
 82					sizeof(*gpio_keys) * n_buttons,
 83				       GFP_KERNEL);
 84	if (!gpio_keys_pdata)
 85		return ERR_PTR(-ENOMEM);
 86
 87	gpio_keys = (void *)(gpio_keys_pdata + 1);
 88	n_buttons = 0;
 89
 90	for (info = button_info; info->name; info++) {
 91		if (info->autorepeat != autorepeat)
 92			continue;
 93
 94		gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
 95		if (!gpio_is_valid(gpio)) {
 96			/*
 97			 * Skip GPIO if not present. Note we deliberately
 98			 * ignore -EPROBE_DEFER errors here. On some devices
 99			 * Intel is using so called virtual GPIOs which are not
100			 * GPIOs at all but some way for AML code to check some
101			 * random status bits without need a custom opregion.
102			 * In some cases the resources table we parse points to
103			 * such a virtual GPIO, since these are not real GPIOs
104			 * we do not have a driver for these so they will never
105			 * show up, therefore we ignore -EPROBE_DEFER.
106			 */
107			continue;
108		}
109
110		gpio_keys[n_buttons].type = info->event_type;
111		gpio_keys[n_buttons].code = info->event_code;
112		gpio_keys[n_buttons].gpio = gpio;
113		gpio_keys[n_buttons].active_low = 1;
114		gpio_keys[n_buttons].desc = info->name;
115		gpio_keys[n_buttons].wakeup = info->wakeup;
116		/* These devices often use cheap buttons, use 50 ms debounce */
117		gpio_keys[n_buttons].debounce_interval = 50;
118		n_buttons++;
119	}
120
121	if (n_buttons == 0) {
122		error = -ENODEV;
123		goto err_free_mem;
124	}
125
126	gpio_keys_pdata->buttons = gpio_keys;
127	gpio_keys_pdata->nbuttons = n_buttons;
128	gpio_keys_pdata->rep = autorepeat;
129
130	pd = platform_device_register_resndata(&pdev->dev, "gpio-keys",
131					       PLATFORM_DEVID_AUTO, NULL, 0,
132					       gpio_keys_pdata,
133					       sizeof(*gpio_keys_pdata));
134	error = PTR_ERR_OR_ZERO(pd);
135	if (error) {
136		dev_err(&pdev->dev,
137			"failed registering gpio-keys: %d\n", error);
138		goto err_free_mem;
139	}
140
 
 
 
 
 
 
 
 
 
141	return pd;
142
 
 
143err_free_mem:
144	devm_kfree(&pdev->dev, gpio_keys_pdata);
145	return ERR_PTR(error);
146}
147
148static int soc_button_get_acpi_object_int(const union acpi_object *obj)
149{
150	if (obj->type != ACPI_TYPE_INTEGER)
151		return -1;
152
153	return obj->integer.value;
154}
155
156/* Parse a single ACPI0011 _DSD button descriptor */
157static int soc_button_parse_btn_desc(struct device *dev,
158				     const union acpi_object *desc,
159				     int collection_uid,
160				     struct soc_button_info *info)
161{
162	int upage, usage;
163
164	if (desc->type != ACPI_TYPE_PACKAGE ||
165	    desc->package.count != 5 ||
166	    /* First byte should be 1 (control) */
167	    soc_button_get_acpi_object_int(&desc->package.elements[0]) != 1 ||
168	    /* Third byte should be collection uid */
169	    soc_button_get_acpi_object_int(&desc->package.elements[2]) !=
170							    collection_uid) {
171		dev_err(dev, "Invalid ACPI Button Descriptor\n");
172		return -ENODEV;
173	}
174
175	info->event_type = EV_KEY;
176	info->acpi_index =
177		soc_button_get_acpi_object_int(&desc->package.elements[1]);
178	upage = soc_button_get_acpi_object_int(&desc->package.elements[3]);
179	usage = soc_button_get_acpi_object_int(&desc->package.elements[4]);
180
181	/*
182	 * The UUID: fa6bd625-9ce8-470d-a2c7-b3ca36c4282e descriptors use HID
183	 * usage page and usage codes, but otherwise the device is not HID
184	 * compliant: it uses one irq per button instead of generating HID
185	 * input reports and some buttons should generate wakeups where as
186	 * others should not, so we cannot use the HID subsystem.
187	 *
188	 * Luckily all devices only use a few usage page + usage combinations,
189	 * so we can simply check for the known combinations here.
190	 */
191	if (upage == 0x01 && usage == 0x81) {
192		info->name = "power";
193		info->event_code = KEY_POWER;
194		info->wakeup = true;
195	} else if (upage == 0x01 && usage == 0xca) {
196		info->name = "rotation lock switch";
197		info->event_type = EV_SW;
198		info->event_code = SW_ROTATE_LOCK;
199	} else if (upage == 0x07 && usage == 0xe3) {
200		info->name = "home";
201		info->event_code = KEY_LEFTMETA;
202		info->wakeup = true;
203	} else if (upage == 0x0c && usage == 0xe9) {
204		info->name = "volume_up";
205		info->event_code = KEY_VOLUMEUP;
206		info->autorepeat = true;
207	} else if (upage == 0x0c && usage == 0xea) {
208		info->name = "volume_down";
209		info->event_code = KEY_VOLUMEDOWN;
210		info->autorepeat = true;
211	} else {
212		dev_warn(dev, "Unknown button index %d upage %02x usage %02x, ignoring\n",
213			 info->acpi_index, upage, usage);
214		info->name = "unknown";
215		info->event_code = KEY_RESERVED;
216	}
217
218	return 0;
219}
220
221/* ACPI0011 _DSD btns descriptors UUID: fa6bd625-9ce8-470d-a2c7-b3ca36c4282e */
222static const u8 btns_desc_uuid[16] = {
223	0x25, 0xd6, 0x6b, 0xfa, 0xe8, 0x9c, 0x0d, 0x47,
224	0xa2, 0xc7, 0xb3, 0xca, 0x36, 0xc4, 0x28, 0x2e
225};
226
227/* Parse ACPI0011 _DSD button descriptors */
228static struct soc_button_info *soc_button_get_button_info(struct device *dev)
229{
230	struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER };
231	const union acpi_object *desc, *el0, *uuid, *btns_desc = NULL;
232	struct soc_button_info *button_info;
233	acpi_status status;
234	int i, btn, collection_uid = -1;
235
236	status = acpi_evaluate_object_typed(ACPI_HANDLE(dev), "_DSD", NULL,
237					    &buf, ACPI_TYPE_PACKAGE);
238	if (ACPI_FAILURE(status)) {
239		dev_err(dev, "ACPI _DSD object not found\n");
240		return ERR_PTR(-ENODEV);
241	}
242
243	/* Look for the Button Descriptors UUID */
244	desc = buf.pointer;
245	for (i = 0; (i + 1) < desc->package.count; i += 2) {
246		uuid = &desc->package.elements[i];
247
248		if (uuid->type != ACPI_TYPE_BUFFER ||
249		    uuid->buffer.length != 16 ||
250		    desc->package.elements[i + 1].type != ACPI_TYPE_PACKAGE) {
251			break;
252		}
253
254		if (memcmp(uuid->buffer.pointer, btns_desc_uuid, 16) == 0) {
255			btns_desc = &desc->package.elements[i + 1];
256			break;
257		}
258	}
259
260	if (!btns_desc) {
261		dev_err(dev, "ACPI Button Descriptors not found\n");
262		button_info = ERR_PTR(-ENODEV);
263		goto out;
264	}
265
266	/* The first package describes the collection */
267	el0 = &btns_desc->package.elements[0];
268	if (el0->type == ACPI_TYPE_PACKAGE &&
269	    el0->package.count == 5 &&
270	    /* First byte should be 0 (collection) */
271	    soc_button_get_acpi_object_int(&el0->package.elements[0]) == 0 &&
272	    /* Third byte should be 0 (top level collection) */
273	    soc_button_get_acpi_object_int(&el0->package.elements[2]) == 0) {
274		collection_uid = soc_button_get_acpi_object_int(
275						&el0->package.elements[1]);
276	}
277	if (collection_uid == -1) {
278		dev_err(dev, "Invalid Button Collection Descriptor\n");
279		button_info = ERR_PTR(-ENODEV);
280		goto out;
281	}
282
283	/* There are package.count - 1 buttons + 1 terminating empty entry */
284	button_info = devm_kcalloc(dev, btns_desc->package.count,
285				   sizeof(*button_info), GFP_KERNEL);
286	if (!button_info) {
287		button_info = ERR_PTR(-ENOMEM);
288		goto out;
289	}
290
291	/* Parse the button descriptors */
292	for (i = 1, btn = 0; i < btns_desc->package.count; i++, btn++) {
293		if (soc_button_parse_btn_desc(dev,
294					      &btns_desc->package.elements[i],
295					      collection_uid,
296					      &button_info[btn])) {
297			button_info = ERR_PTR(-ENODEV);
298			goto out;
299		}
300	}
301
302out:
303	kfree(buf.pointer);
304	return button_info;
305}
306
307static int soc_button_remove(struct platform_device *pdev)
308{
309	struct soc_button_data *priv = platform_get_drvdata(pdev);
310
311	int i;
312
313	for (i = 0; i < BUTTON_TYPES; i++)
314		if (priv->children[i])
315			platform_device_unregister(priv->children[i]);
316
317	return 0;
318}
319
320static int soc_button_probe(struct platform_device *pdev)
321{
322	struct device *dev = &pdev->dev;
323	const struct soc_device_data *device_data;
324	const struct soc_button_info *button_info;
325	struct soc_button_data *priv;
326	struct platform_device *pd;
327	int i;
328	int error;
329
330	device_data = acpi_device_get_match_data(dev);
331	if (device_data && device_data->check) {
332		error = device_data->check(dev);
333		if (error)
334			return error;
335	}
336
337	if (device_data && device_data->button_info) {
338		button_info = device_data->button_info;
339	} else {
340		button_info = soc_button_get_button_info(dev);
341		if (IS_ERR(button_info))
342			return PTR_ERR(button_info);
343	}
344
345	error = gpiod_count(dev, NULL);
346	if (error < 0) {
347		dev_dbg(dev, "no GPIO attached, ignoring...\n");
348		return -ENODEV;
349	}
350
351	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
352	if (!priv)
353		return -ENOMEM;
354
355	platform_set_drvdata(pdev, priv);
356
357	for (i = 0; i < BUTTON_TYPES; i++) {
358		pd = soc_button_device_create(pdev, button_info, i == 0);
359		if (IS_ERR(pd)) {
360			error = PTR_ERR(pd);
361			if (error != -ENODEV) {
362				soc_button_remove(pdev);
363				return error;
364			}
365			continue;
366		}
367
368		priv->children[i] = pd;
369	}
370
371	if (!priv->children[0] && !priv->children[1])
372		return -ENODEV;
373
374	if (!device_data || !device_data->button_info)
375		devm_kfree(dev, button_info);
376
377	return 0;
378}
379
380/*
381 * Definition of buttons on the tablet. The ACPI index of each button
382 * is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
383 * Platforms"
384 */
385static const struct soc_button_info soc_button_PNP0C40[] = {
386	{ "power", 0, EV_KEY, KEY_POWER, false, true },
387	{ "home", 1, EV_KEY, KEY_LEFTMETA, false, true },
388	{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
389	{ "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false },
390	{ "rotation_lock", 4, EV_KEY, KEY_ROTATE_LOCK_TOGGLE, false, false },
391	{ }
392};
393
394static const struct soc_device_data soc_device_PNP0C40 = {
395	.button_info = soc_button_PNP0C40,
396};
397
398/*
399 * Special device check for Surface Book 2 and Surface Pro (2017).
400 * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned
401 * devices use MSHW0040 for power and volume buttons, however the way they
402 * have to be addressed differs. Make sure that we only load this drivers
403 * for the correct devices by checking the OEM Platform Revision provided by
404 * the _DSM method.
405 */
406#define MSHW0040_DSM_REVISION		0x01
407#define MSHW0040_DSM_GET_OMPR		0x02	// get OEM Platform Revision
408static const guid_t MSHW0040_DSM_UUID =
409	GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
410		  0x49, 0x80, 0x35);
411
412static int soc_device_check_MSHW0040(struct device *dev)
413{
414	acpi_handle handle = ACPI_HANDLE(dev);
415	union acpi_object *result;
416	u64 oem_platform_rev = 0;	// valid revisions are nonzero
417
418	// get OEM platform revision
419	result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
420					 MSHW0040_DSM_REVISION,
421					 MSHW0040_DSM_GET_OMPR, NULL,
422					 ACPI_TYPE_INTEGER);
423
424	if (result) {
425		oem_platform_rev = result->integer.value;
426		ACPI_FREE(result);
427	}
428
429	/*
430	 * If the revision is zero here, the _DSM evaluation has failed. This
431	 * indicates that we have a Pro 4 or Book 1 and this driver should not
432	 * be used.
433	 */
434	if (oem_platform_rev == 0)
435		return -ENODEV;
436
437	dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
438
439	return 0;
440}
441
442/*
443 * Button infos for Microsoft Surface Book 2 and Surface Pro (2017).
444 * Obtained from DSDT/testing.
445 */
446static const struct soc_button_info soc_button_MSHW0040[] = {
447	{ "power", 0, EV_KEY, KEY_POWER, false, true },
448	{ "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false },
449	{ "volume_down", 4, EV_KEY, KEY_VOLUMEDOWN, true, false },
450	{ }
451};
452
453static const struct soc_device_data soc_device_MSHW0040 = {
454	.button_info = soc_button_MSHW0040,
455	.check = soc_device_check_MSHW0040,
456};
457
458static const struct acpi_device_id soc_button_acpi_match[] = {
459	{ "PNP0C40", (unsigned long)&soc_device_PNP0C40 },
460	{ "ACPI0011", 0 },
461
462	/* Microsoft Surface Devices (5th and 6th generation) */
463	{ "MSHW0040", (unsigned long)&soc_device_MSHW0040 },
464
465	{ }
466};
467
468MODULE_DEVICE_TABLE(acpi, soc_button_acpi_match);
469
470static struct platform_driver soc_button_driver = {
471	.probe          = soc_button_probe,
472	.remove		= soc_button_remove,
473	.driver		= {
474		.name = KBUILD_MODNAME,
475		.acpi_match_table = ACPI_PTR(soc_button_acpi_match),
476	},
477};
478module_platform_driver(soc_button_driver);
479
480MODULE_LICENSE("GPL");