3 * Copyright (c) 2012, Intel Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <linux/device.h>
20 #include <linux/hid.h>
21 #include <linux/module.h>
22 #include <linux/slab.h>
23 #include <linux/mfd/core.h>
24 #include <linux/list.h>
25 #include <linux/hid-sensor-ids.h>
26 #include <linux/hid-sensor-hub.h>
29 #define HID_SENSOR_HUB_ENUM_QUIRK 0x01
32 * struct sensor_hub_data - Hold a instance data for a HID hub device
33 * @hsdev: Stored hid instance for current hub device.
34 * @mutex: Mutex to serialize synchronous request.
35 * @lock: Spin lock to protect pending request structure.
36 * @dyn_callback_list: Holds callback function
37 * @dyn_callback_lock: spin lock to protect callback list
38 * @hid_sensor_hub_client_devs: Stores all MFD cells for a hub instance.
39 * @hid_sensor_client_cnt: Number of MFD cells, (no of sensors attached).
40 * @ref_cnt: Number of MFD clients have opened this device
42 struct sensor_hub_data {
45 struct list_head dyn_callback_list;
46 spinlock_t dyn_callback_lock;
47 struct mfd_cell *hid_sensor_hub_client_devs;
48 int hid_sensor_client_cnt;
54 * struct hid_sensor_hub_callbacks_list - Stores callback list
56 * @usage_id: usage id for a physical device.
57 * @usage_callback: Stores registered callback functions.
58 * @priv: Private data for a physical device.
60 struct hid_sensor_hub_callbacks_list {
61 struct list_head list;
63 struct hid_sensor_hub_device *hsdev;
64 struct hid_sensor_hub_callbacks *usage_callback;
68 static struct hid_report *sensor_hub_report(int id, struct hid_device *hdev,
71 struct hid_report *report;
73 list_for_each_entry(report, &hdev->report_enum[dir].report_list, list) {
77 hid_warn(hdev, "No report with id 0x%x found\n", id);
82 static int sensor_hub_get_physical_device_count(struct hid_device *hdev)
87 for (i = 0; i < hdev->maxcollection; ++i) {
88 struct hid_collection *collection = &hdev->collection[i];
89 if (collection->type == HID_COLLECTION_PHYSICAL ||
90 collection->type == HID_COLLECTION_APPLICATION)
97 static void sensor_hub_fill_attr_info(
98 struct hid_sensor_hub_attribute_info *info,
99 s32 index, s32 report_id, struct hid_field *field)
102 info->report_id = report_id;
103 info->units = field->unit;
104 info->unit_expo = field->unit_exponent;
105 info->size = (field->report_size * field->report_count)/8;
106 info->logical_minimum = field->logical_minimum;
107 info->logical_maximum = field->logical_maximum;
110 static struct hid_sensor_hub_callbacks *sensor_hub_get_callback(
111 struct hid_device *hdev,
113 int collection_index,
114 struct hid_sensor_hub_device **hsdev,
117 struct hid_sensor_hub_callbacks_list *callback;
118 struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
121 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
122 list_for_each_entry(callback, &pdata->dyn_callback_list, list)
123 if ((callback->usage_id == usage_id ||
124 callback->usage_id == HID_USAGE_SENSOR_COLLECTION) &&
126 callback->hsdev->start_collection_index) &&
128 callback->hsdev->end_collection_index)) {
129 *priv = callback->priv;
130 *hsdev = callback->hsdev;
131 spin_unlock_irqrestore(&pdata->dyn_callback_lock,
133 return callback->usage_callback;
135 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
140 int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev,
142 struct hid_sensor_hub_callbacks *usage_callback)
144 struct hid_sensor_hub_callbacks_list *callback;
145 struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
148 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
149 list_for_each_entry(callback, &pdata->dyn_callback_list, list)
150 if (callback->usage_id == usage_id &&
151 callback->hsdev == hsdev) {
152 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
155 callback = kzalloc(sizeof(*callback), GFP_ATOMIC);
157 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
160 callback->hsdev = hsdev;
161 callback->usage_callback = usage_callback;
162 callback->usage_id = usage_id;
163 callback->priv = NULL;
165 * If there is a handler registered for the collection type, then
166 * it will handle all reports for sensors in this collection. If
167 * there is also an individual sensor handler registration, then
168 * we want to make sure that the reports are directed to collection
169 * handler, as this may be a fusion sensor. So add collection handlers
170 * to the beginning of the list, so that they are matched first.
172 if (usage_id == HID_USAGE_SENSOR_COLLECTION)
173 list_add(&callback->list, &pdata->dyn_callback_list);
175 list_add_tail(&callback->list, &pdata->dyn_callback_list);
176 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
180 EXPORT_SYMBOL_GPL(sensor_hub_register_callback);
182 int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev,
185 struct hid_sensor_hub_callbacks_list *callback;
186 struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev);
189 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
190 list_for_each_entry(callback, &pdata->dyn_callback_list, list)
191 if (callback->usage_id == usage_id &&
192 callback->hsdev == hsdev) {
193 list_del(&callback->list);
197 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
201 EXPORT_SYMBOL_GPL(sensor_hub_remove_callback);
203 int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
204 u32 field_index, int buffer_size, void *buffer)
206 struct hid_report *report;
207 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
208 __s32 *buf32 = buffer;
214 mutex_lock(&data->mutex);
215 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
216 if (!report || (field_index >= report->maxfield)) {
221 remaining_bytes = buffer_size % sizeof(__s32);
222 buffer_size = buffer_size / sizeof(__s32);
224 for (i = 0; i < buffer_size; ++i) {
225 ret = hid_set_field(report->field[field_index], i,
226 (__force __s32)cpu_to_le32(*buf32));
233 if (remaining_bytes) {
235 memcpy(&value, (u8 *)buf32, remaining_bytes);
236 ret = hid_set_field(report->field[field_index], i,
237 (__force __s32)cpu_to_le32(value));
241 hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT);
242 hid_hw_wait(hsdev->hdev);
245 mutex_unlock(&data->mutex);
249 EXPORT_SYMBOL_GPL(sensor_hub_set_feature);
251 int sensor_hub_get_feature(struct hid_sensor_hub_device *hsdev, u32 report_id,
252 u32 field_index, int buffer_size, void *buffer)
254 struct hid_report *report;
255 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
259 mutex_lock(&data->mutex);
260 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
261 if (!report || (field_index >= report->maxfield) ||
262 report->field[field_index]->report_count < 1) {
266 hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
267 hid_hw_wait(hsdev->hdev);
269 /* calculate number of bytes required to read this field */
270 report_size = DIV_ROUND_UP(report->field[field_index]->report_size,
272 report->field[field_index]->report_count;
277 ret = min(report_size, buffer_size);
278 memcpy(buffer, report->field[field_index]->value, ret);
281 mutex_unlock(&data->mutex);
285 EXPORT_SYMBOL_GPL(sensor_hub_get_feature);
288 int sensor_hub_input_attr_get_raw_value(struct hid_sensor_hub_device *hsdev,
290 u32 attr_usage_id, u32 report_id,
291 enum sensor_hub_read_flags flag)
293 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
295 struct hid_report *report;
298 report = sensor_hub_report(report_id, hsdev->hdev,
303 mutex_lock(hsdev->mutex_ptr);
304 if (flag == SENSOR_HUB_SYNC) {
305 memset(&hsdev->pending, 0, sizeof(hsdev->pending));
306 init_completion(&hsdev->pending.ready);
307 hsdev->pending.usage_id = usage_id;
308 hsdev->pending.attr_usage_id = attr_usage_id;
309 hsdev->pending.raw_size = 0;
311 spin_lock_irqsave(&data->lock, flags);
312 hsdev->pending.status = true;
313 spin_unlock_irqrestore(&data->lock, flags);
315 mutex_lock(&data->mutex);
316 hid_hw_request(hsdev->hdev, report, HID_REQ_GET_REPORT);
317 mutex_unlock(&data->mutex);
318 if (flag == SENSOR_HUB_SYNC) {
319 wait_for_completion_interruptible_timeout(
320 &hsdev->pending.ready, HZ*5);
321 switch (hsdev->pending.raw_size) {
323 ret_val = *(u8 *)hsdev->pending.raw_data;
326 ret_val = *(u16 *)hsdev->pending.raw_data;
329 ret_val = *(u32 *)hsdev->pending.raw_data;
334 kfree(hsdev->pending.raw_data);
335 hsdev->pending.status = false;
337 mutex_unlock(hsdev->mutex_ptr);
341 EXPORT_SYMBOL_GPL(sensor_hub_input_attr_get_raw_value);
343 int hid_sensor_get_usage_index(struct hid_sensor_hub_device *hsdev,
344 u32 report_id, int field_index, u32 usage_id)
346 struct hid_report *report;
347 struct hid_field *field;
350 report = sensor_hub_report(report_id, hsdev->hdev, HID_FEATURE_REPORT);
351 if (!report || (field_index >= report->maxfield))
354 field = report->field[field_index];
355 for (i = 0; i < field->maxusage; ++i) {
356 if (field->usage[i].hid == usage_id)
357 return field->usage[i].usage_index;
363 EXPORT_SYMBOL_GPL(hid_sensor_get_usage_index);
365 int sensor_hub_input_get_attribute_info(struct hid_sensor_hub_device *hsdev,
369 struct hid_sensor_hub_attribute_info *info)
373 struct hid_report *report;
374 struct hid_field *field;
375 struct hid_report_enum *report_enum;
376 struct hid_device *hdev = hsdev->hdev;
378 /* Initialize with defaults */
379 info->usage_id = usage_id;
380 info->attrib_id = attr_usage_id;
381 info->report_id = -1;
384 info->unit_expo = -1;
386 report_enum = &hdev->report_enum[type];
387 list_for_each_entry(report, &report_enum->report_list, list) {
388 for (i = 0; i < report->maxfield; ++i) {
389 field = report->field[i];
390 if (field->maxusage) {
391 if (field->physical == usage_id &&
392 (field->logical == attr_usage_id ||
393 field->usage[0].hid ==
395 (field->usage[0].collection_index >=
396 hsdev->start_collection_index) &&
397 (field->usage[0].collection_index <
398 hsdev->end_collection_index)) {
400 sensor_hub_fill_attr_info(info, i,
413 EXPORT_SYMBOL_GPL(sensor_hub_input_get_attribute_info);
416 static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message)
418 struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
419 struct hid_sensor_hub_callbacks_list *callback;
422 hid_dbg(hdev, " sensor_hub_suspend\n");
423 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
424 list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
425 if (callback->usage_callback->suspend)
426 callback->usage_callback->suspend(
427 callback->hsdev, callback->priv);
429 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
434 static int sensor_hub_resume(struct hid_device *hdev)
436 struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
437 struct hid_sensor_hub_callbacks_list *callback;
440 hid_dbg(hdev, " sensor_hub_resume\n");
441 spin_lock_irqsave(&pdata->dyn_callback_lock, flags);
442 list_for_each_entry(callback, &pdata->dyn_callback_list, list) {
443 if (callback->usage_callback->resume)
444 callback->usage_callback->resume(
445 callback->hsdev, callback->priv);
447 spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags);
452 static int sensor_hub_reset_resume(struct hid_device *hdev)
459 * Handle raw report as sent by device
461 static int sensor_hub_raw_event(struct hid_device *hdev,
462 struct hid_report *report, u8 *raw_data, int size)
467 struct sensor_hub_data *pdata = hid_get_drvdata(hdev);
469 struct hid_sensor_hub_callbacks *callback = NULL;
470 struct hid_collection *collection = NULL;
472 struct hid_sensor_hub_device *hsdev = NULL;
474 hid_dbg(hdev, "sensor_hub_raw_event report id:0x%x size:%d type:%d\n",
475 report->id, size, report->type);
476 hid_dbg(hdev, "maxfield:%d\n", report->maxfield);
477 if (report->type != HID_INPUT_REPORT)
482 ptr++; /* Skip report id */
484 spin_lock_irqsave(&pdata->lock, flags);
486 for (i = 0; i < report->maxfield; ++i) {
487 hid_dbg(hdev, "%d collection_index:%x hid:%x sz:%x\n",
488 i, report->field[i]->usage->collection_index,
489 report->field[i]->usage->hid,
490 (report->field[i]->report_size *
491 report->field[i]->report_count)/8);
492 sz = (report->field[i]->report_size *
493 report->field[i]->report_count)/8;
494 collection = &hdev->collection[
495 report->field[i]->usage->collection_index];
496 hid_dbg(hdev, "collection->usage %x\n",
499 callback = sensor_hub_get_callback(hdev,
500 report->field[i]->physical,
501 report->field[i]->usage[0].collection_index,
507 if (hsdev->pending.status && (hsdev->pending.attr_usage_id ==
508 report->field[i]->usage->hid ||
509 hsdev->pending.attr_usage_id ==
510 report->field[i]->logical)) {
511 hid_dbg(hdev, "data was pending ...\n");
512 hsdev->pending.raw_data = kmemdup(ptr, sz, GFP_ATOMIC);
513 if (hsdev->pending.raw_data)
514 hsdev->pending.raw_size = sz;
516 hsdev->pending.raw_size = 0;
517 complete(&hsdev->pending.ready);
519 if (callback->capture_sample) {
520 if (report->field[i]->logical)
521 callback->capture_sample(hsdev,
522 report->field[i]->logical, sz, ptr,
525 callback->capture_sample(hsdev,
526 report->field[i]->usage->hid, sz, ptr,
531 if (callback && collection && callback->send_event)
532 callback->send_event(hsdev, collection->usage,
534 spin_unlock_irqrestore(&pdata->lock, flags);
539 int sensor_hub_device_open(struct hid_sensor_hub_device *hsdev)
542 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
544 mutex_lock(&data->mutex);
545 if (!data->ref_cnt) {
546 ret = hid_hw_open(hsdev->hdev);
548 hid_err(hsdev->hdev, "failed to open hid device\n");
549 mutex_unlock(&data->mutex);
554 mutex_unlock(&data->mutex);
558 EXPORT_SYMBOL_GPL(sensor_hub_device_open);
560 void sensor_hub_device_close(struct hid_sensor_hub_device *hsdev)
562 struct sensor_hub_data *data = hid_get_drvdata(hsdev->hdev);
564 mutex_lock(&data->mutex);
567 hid_hw_close(hsdev->hdev);
568 mutex_unlock(&data->mutex);
570 EXPORT_SYMBOL_GPL(sensor_hub_device_close);
572 static __u8 *sensor_hub_report_fixup(struct hid_device *hdev, __u8 *rdesc,
576 struct sensor_hub_data *sd = hid_get_drvdata(hdev);
577 unsigned char report_block[] = {
578 0x0a, 0x16, 0x03, 0x15, 0x00, 0x25, 0x05};
579 unsigned char power_block[] = {
580 0x0a, 0x19, 0x03, 0x15, 0x00, 0x25, 0x05};
582 if (!(sd->quirks & HID_SENSOR_HUB_ENUM_QUIRK)) {
583 hid_dbg(hdev, "No Enum quirks\n");
587 /* Looks for power and report state usage id and force to 1 */
588 for (index = 0; index < *rsize; ++index) {
589 if (((*rsize - index) > sizeof(report_block)) &&
590 !memcmp(&rdesc[index], report_block,
591 sizeof(report_block))) {
592 rdesc[index + 4] = 0x01;
593 index += sizeof(report_block);
595 if (((*rsize - index) > sizeof(power_block)) &&
596 !memcmp(&rdesc[index], power_block,
597 sizeof(power_block))) {
598 rdesc[index + 4] = 0x01;
599 index += sizeof(power_block);
603 /* Checks if the report descriptor of Thinkpad Helix 2 has a logical
604 * minimum for magnetic flux axis greater than the maximum */
605 if (hdev->product == USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA &&
606 *rsize == 2558 && rdesc[913] == 0x17 && rdesc[914] == 0x40 &&
607 rdesc[915] == 0x81 && rdesc[916] == 0x08 &&
608 rdesc[917] == 0x00 && rdesc[918] == 0x27 &&
609 rdesc[921] == 0x07 && rdesc[922] == 0x00) {
610 /* Sets negative logical minimum for mag x, y and z */
611 rdesc[914] = rdesc[935] = rdesc[956] = 0xc0;
612 rdesc[915] = rdesc[936] = rdesc[957] = 0x7e;
613 rdesc[916] = rdesc[937] = rdesc[958] = 0xf7;
614 rdesc[917] = rdesc[938] = rdesc[959] = 0xff;
620 static int sensor_hub_probe(struct hid_device *hdev,
621 const struct hid_device_id *id)
624 struct sensor_hub_data *sd;
628 struct hid_sensor_hub_device *hsdev;
629 struct hid_sensor_hub_device *last_hsdev = NULL;
630 struct hid_sensor_hub_device *collection_hsdev = NULL;
632 sd = devm_kzalloc(&hdev->dev, sizeof(*sd), GFP_KERNEL);
634 hid_err(hdev, "cannot allocate Sensor data\n");
638 hid_set_drvdata(hdev, sd);
639 sd->quirks = id->driver_data;
641 spin_lock_init(&sd->lock);
642 spin_lock_init(&sd->dyn_callback_lock);
643 mutex_init(&sd->mutex);
644 ret = hid_parse(hdev);
646 hid_err(hdev, "parse failed\n");
649 INIT_LIST_HEAD(&hdev->inputs);
651 ret = hid_hw_start(hdev, 0);
653 hid_err(hdev, "hw start failed\n");
656 INIT_LIST_HEAD(&sd->dyn_callback_list);
657 sd->hid_sensor_client_cnt = 0;
659 dev_cnt = sensor_hub_get_physical_device_count(hdev);
660 if (dev_cnt > HID_MAX_PHY_DEVICES) {
661 hid_err(hdev, "Invalid Physical device count\n");
665 sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
666 sizeof(struct mfd_cell),
668 if (sd->hid_sensor_hub_client_devs == NULL) {
669 hid_err(hdev, "Failed to allocate memory for mfd cells\n");
674 for (i = 0; i < hdev->maxcollection; ++i) {
675 struct hid_collection *collection = &hdev->collection[i];
677 if (collection->type == HID_COLLECTION_PHYSICAL ||
678 collection->type == HID_COLLECTION_APPLICATION) {
680 hsdev = devm_kzalloc(&hdev->dev, sizeof(*hsdev),
683 hid_err(hdev, "cannot allocate hid_sensor_hub_device\n");
688 hsdev->vendor_id = hdev->vendor;
689 hsdev->product_id = hdev->product;
690 hsdev->usage = collection->usage;
691 hsdev->mutex_ptr = devm_kzalloc(&hdev->dev,
692 sizeof(struct mutex),
694 if (!hsdev->mutex_ptr) {
698 mutex_init(hsdev->mutex_ptr);
699 hsdev->start_collection_index = i;
701 last_hsdev->end_collection_index = i;
703 name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
707 hid_err(hdev, "Failed MFD device name\n");
711 sd->hid_sensor_hub_client_devs[
712 sd->hid_sensor_client_cnt].name = name;
713 sd->hid_sensor_hub_client_devs[
714 sd->hid_sensor_client_cnt].platform_data =
716 sd->hid_sensor_hub_client_devs[
717 sd->hid_sensor_client_cnt].pdata_size =
719 hid_dbg(hdev, "Adding %s:%d\n", name,
720 hsdev->start_collection_index);
721 sd->hid_sensor_client_cnt++;
722 if (collection_hsdev)
723 collection_hsdev->end_collection_index = i;
724 if (collection->type == HID_COLLECTION_APPLICATION &&
725 collection->usage == HID_USAGE_SENSOR_COLLECTION)
726 collection_hsdev = hsdev;
730 last_hsdev->end_collection_index = i;
731 if (collection_hsdev)
732 collection_hsdev->end_collection_index = i;
734 ret = mfd_add_hotplug_devices(&hdev->dev,
735 sd->hid_sensor_hub_client_devs,
736 sd->hid_sensor_client_cnt);
748 static void sensor_hub_remove(struct hid_device *hdev)
750 struct sensor_hub_data *data = hid_get_drvdata(hdev);
754 hid_dbg(hdev, " hardware removed\n");
757 spin_lock_irqsave(&data->lock, flags);
758 for (i = 0; i < data->hid_sensor_client_cnt; ++i) {
759 struct hid_sensor_hub_device *hsdev =
760 data->hid_sensor_hub_client_devs[i].platform_data;
761 if (hsdev->pending.status)
762 complete(&hsdev->pending.ready);
764 spin_unlock_irqrestore(&data->lock, flags);
765 mfd_remove_devices(&hdev->dev);
766 hid_set_drvdata(hdev, NULL);
767 mutex_destroy(&data->mutex);
770 static const struct hid_device_id sensor_hub_devices[] = {
771 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_0,
772 USB_DEVICE_ID_INTEL_HID_SENSOR_0),
773 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
774 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
775 USB_DEVICE_ID_INTEL_HID_SENSOR_0),
776 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
777 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
778 USB_DEVICE_ID_INTEL_HID_SENSOR_1),
779 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
780 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
781 USB_DEVICE_ID_MS_SURFACE_PRO_2),
782 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
783 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
784 USB_DEVICE_ID_MS_TOUCH_COVER_2),
785 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
786 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_MICROSOFT,
787 USB_DEVICE_ID_MS_TYPE_COVER_2),
788 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
789 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_STM_0,
790 USB_DEVICE_ID_STM_HID_SENSOR),
791 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
792 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_STM_0,
793 USB_DEVICE_ID_STM_HID_SENSOR_1),
794 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
795 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_TEXAS_INSTRUMENTS,
796 USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA),
797 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
798 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
799 USB_DEVICE_ID_ITE_LENOVO_YOGA),
800 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
801 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_ITE,
802 USB_DEVICE_ID_ITE_LENOVO_YOGA2),
803 .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
804 { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
808 MODULE_DEVICE_TABLE(hid, sensor_hub_devices);
810 static struct hid_driver sensor_hub_driver = {
811 .name = "hid-sensor-hub",
812 .id_table = sensor_hub_devices,
813 .probe = sensor_hub_probe,
814 .remove = sensor_hub_remove,
815 .raw_event = sensor_hub_raw_event,
816 .report_fixup = sensor_hub_report_fixup,
818 .suspend = sensor_hub_suspend,
819 .resume = sensor_hub_resume,
820 .reset_resume = sensor_hub_reset_resume,
823 module_hid_driver(sensor_hub_driver);
825 MODULE_DESCRIPTION("HID Sensor Hub driver");
826 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@intel.com>");
827 MODULE_LICENSE("GPL");