Skip to content

Commit 9d8d517

Browse files
EvenxfJiri Kosina
authored andcommitted
HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation
Intel QuickSPI driver uses THC hardware to accelerate HID over SPI (HIDSPI) protocol flow. This patch implements all data flows described in HID over SPI protocol SPEC by using THC hardware layer APIs. HID over SPI SPEC: https://www.microsoft.com/download/details.aspx?id=103325 Co-developed-by: Xinpeng Sun <xinpeng.sun@intel.com> Signed-off-by: Xinpeng Sun <xinpeng.sun@intel.com> Signed-off-by: Even Xu <even.xu@intel.com> Tested-by: Rui Zhang <rui1.zhang@intel.com> Tested-by: Mark Pearson <mpearson-lenovo@squebb.ca> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca> Tested-by: Aaron Ma <aaron.ma@canonical.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
1 parent 7cb06f0 commit 9d8d517

File tree

6 files changed

+609
-1
lines changed

6 files changed

+609
-1
lines changed

drivers/hid/intel-thc-hid/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ intel-thc-objs += intel-thc/intel-thc-dma.o
1212
obj-$(CONFIG_INTEL_QUICKSPI) += intel-quickspi.o
1313
intel-quickspi-objs += intel-quickspi/pci-quickspi.o
1414
intel-quickspi-objs += intel-quickspi/quickspi-hid.o
15+
intel-quickspi-objs += intel-quickspi/quickspi-protocol.o
1516

1617
ccflags-y += -I $(src)/intel-thc

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-dev.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
#ifndef _QUICKSPI_DEV_H_
55
#define _QUICKSPI_DEV_H_
66

7+
#include <linux/bits.h>
78
#include <linux/hid-over-spi.h>
9+
#include <linux/sizes.h>
10+
#include <linux/wait.h>
11+
12+
#include "quickspi-protocol.h"
813

914
#define PCI_DEVICE_ID_INTEL_THC_MTL_DEVICE_ID_SPI_PORT1 0x7E49
1015
#define PCI_DEVICE_ID_INTEL_THC_MTL_DEVICE_ID_SPI_PORT2 0x7E4B
@@ -92,6 +97,21 @@ struct acpi_device;
9297
* @active_ltr_val: THC active LTR value
9398
* @low_power_ltr_val: THC low power LTR value
9499
* @report_descriptor: store a copy of device report descriptor
100+
* @input_buf: store a copy of latest input report data
101+
* @report_buf: store a copy of latest input/output report packet from set/get feature
102+
* @report_len: the length of input/output report packet
103+
* @reset_ack_wq: workqueue for waiting reset response from device
104+
* @reset_ack: indicate reset response received or not
105+
* @nondma_int_received_wq: workqueue for waiting THC non-DMA interrupt
106+
* @nondma_int_received: indicate THC non-DMA interrupt received or not
107+
* @report_desc_got_wq: workqueue for waiting device report descriptor
108+
* @report_desc_got: indicate device report descritor received or not
109+
* @set_power_on_wq: workqueue for waiting set power on response from device
110+
* @set_power_on: indicate set power on response received or not
111+
* @get_feature_cmpl_wq: workqueue for waiting get feature response from device
112+
* @get_feature_cmpl: indicate get feature received or not
113+
* @set_feature_cmpl_wq: workqueue for waiting set feature to device
114+
* @set_feature_cmpl: indicate set feature send complete or not
95115
*/
96116
struct quickspi_device {
97117
struct device *dev;
@@ -121,6 +141,24 @@ struct quickspi_device {
121141
u32 low_power_ltr_val;
122142

123143
u8 *report_descriptor;
144+
u8 *input_buf;
145+
u8 *report_buf;
146+
u32 report_len;
147+
148+
wait_queue_head_t reset_ack_wq;
149+
bool reset_ack;
150+
151+
wait_queue_head_t nondma_int_received_wq;
152+
bool nondma_int_received;
153+
154+
wait_queue_head_t report_desc_got_wq;
155+
bool report_desc_got;
156+
157+
wait_queue_head_t get_report_cmpl_wq;
158+
bool get_report_cmpl;
159+
160+
wait_queue_head_t set_report_cmpl_wq;
161+
bool set_report_cmpl;
124162
};
125163

126164
#endif /* _QUICKSPI_DEV_H_ */

drivers/hid/intel-thc-hid/intel-quickspi/quickspi-hid.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,22 @@ static int quickspi_hid_raw_request(struct hid_device *hid,
5151
__u8 *buf, size_t len,
5252
unsigned char rtype, int reqtype)
5353
{
54-
return 0;
54+
struct quickspi_device *qsdev = hid->driver_data;
55+
int ret = 0;
56+
57+
switch (reqtype) {
58+
case HID_REQ_GET_REPORT:
59+
ret = quickspi_get_report(qsdev, rtype, reportnum, buf);
60+
break;
61+
case HID_REQ_SET_REPORT:
62+
ret = quickspi_set_report(qsdev, rtype, reportnum, buf, len);
63+
break;
64+
default:
65+
dev_err_once(qsdev->dev, "Not supported request type %d\n", reqtype);
66+
break;
67+
}
68+
69+
return ret;
5570
}
5671

5772
static int quickspi_hid_power(struct hid_device *hid, int lvl)

0 commit comments

Comments
 (0)