1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * ISHTP-HID glue driver's definitions.
5 * Copyright (c) 2014-2016, Intel Corporation.
10 /* The fixed ISH product and vendor id */
11 #define ISH_HID_VENDOR 0x8086
12 #define ISH_HID_PRODUCT 0x22D8
13 #define ISH_HID_VERSION 0x0200
16 #define IS_RESPONSE 0x80
18 /* Used to dump to Linux trace buffer, if enabled */
19 extern ishtp_print_log ishtp_hid_print_trace;
20 #define hid_ishtp_trace(client, ...) \
21 (ishtp_hid_print_trace)(NULL, __VA_ARGS__)
23 /* ISH HID message structure */
24 struct hostif_msg_hdr {
25 uint8_t command; /* Bit 7: is_response */
33 struct hostif_msg_hdr hdr;
36 struct hostif_msg_to_sensor {
37 struct hostif_msg_hdr hdr;
48 struct ishtp_version {
55 /* struct for ISHTP aggregated input data */
58 uint8_t num_of_reports;
61 uint16_t size_of_report;
63 } __packed reports[1];
67 #define HOSTIF_HID_COMMAND_BASE 0
68 #define HOSTIF_GET_HID_DESCRIPTOR 0
69 #define HOSTIF_GET_REPORT_DESCRIPTOR 1
70 #define HOSTIF_GET_FEATURE_REPORT 2
71 #define HOSTIF_SET_FEATURE_REPORT 3
72 #define HOSTIF_GET_INPUT_REPORT 4
73 #define HOSTIF_PUBLISH_INPUT_REPORT 5
74 #define HOSTIF_PUBLISH_INPUT_REPORT_LIST 6
75 #define HOSTIF_DM_COMMAND_BASE 32
76 #define HOSTIF_DM_ENUM_DEVICES 33
77 #define HOSTIF_DM_ADD_DEVICE 34
79 #define MAX_HID_DEVICES 32
82 * struct ishtp_cl_data - Encapsulate per ISH TP HID Client
83 * @enum_device_done: Enum devices response complete flag
84 * @hid_descr_done: HID descriptor complete flag
85 * @report_descr_done: Get report descriptor complete flag
86 * @init_done: Init process completed successfully
87 * @suspended: System is under suspend state or in progress
88 * @num_hid_devices: Number of HID devices enumerated in this client
89 * @cur_hid_dev: This keeps track of the device index for which
90 * initialization and registration with HID core
92 * @hid_devices: Store vid/pid/devid for each enumerated HID device
93 * @report_descr: Stores the raw report descriptors for each HID device
94 * @report_descr_size: Report description of size of above repo_descr[]
95 * @hid_sensor_hubs: Pointer to hid_device for all HID device, so that
96 * when clients are removed, they can be freed
97 * @hid_descr: Pointer to hid descriptor for each enumerated hid
99 * @hid_descr_size: Size of each above report descriptor
100 * @init_wait: Wait queue to wait during initialization, where the
101 * client send message to ISH FW and wait for response
102 * @ishtp_hid_wait: The wait for get report during wait callback from hid
104 * @bad_recv_cnt: Running count of packets received with error
105 * @multi_packet_cnt: Count of fragmented packet count
107 * This structure is used to store completion flags and per client data like
108 * like report description, number of HID devices etc.
110 struct ishtp_cl_data {
111 /* completion flags */
112 bool enum_devices_done;
114 bool report_descr_done;
118 unsigned int num_hid_devices;
119 unsigned int cur_hid_dev;
120 unsigned int hid_dev_count;
122 struct device_info *hid_devices;
123 unsigned char *report_descr[MAX_HID_DEVICES];
124 int report_descr_size[MAX_HID_DEVICES];
125 struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES];
126 unsigned char *hid_descr[MAX_HID_DEVICES];
127 int hid_descr_size[MAX_HID_DEVICES];
129 wait_queue_head_t init_wait;
130 wait_queue_head_t ishtp_resume_wait;
131 struct ishtp_cl *hid_ishtp_cl;
134 unsigned int bad_recv_cnt;
135 int multi_packet_cnt;
137 struct work_struct work;
138 struct work_struct resume_work;
139 struct ishtp_cl_device *cl_device;
143 * struct ishtp_hid_data - Per instance HID data
144 * @index: Device index in the order of enumeration
145 * @request_done: Get Feature/Input report complete flag
146 * used during get/set request from hid core
147 * @client_data: Link to the client instance
148 * @hid_wait: Completion waitq
150 * @raw_get_req: Flag indicating raw get request ongoing
151 * @raw_buf: raw request buffer filled on receiving get report
152 * @raw_buf_size: raw request buffer size
153 * Used to tie hid hid->driver data to driver client instance
155 struct ishtp_hid_data {
158 struct ishtp_cl_data *client_data;
159 wait_queue_head_t hid_wait;
167 /* Interface functions between HID LL driver and ISH TP client */
168 void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len,
170 void hid_ishtp_get_report(struct hid_device *hid, int report_id,
172 int ishtp_hid_probe(unsigned int cur_hid_dev,
173 struct ishtp_cl_data *client_data);
174 void ishtp_hid_remove(struct ishtp_cl_data *client_data);
175 int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data);
176 void ishtp_hid_wakeup(struct hid_device *hid);
178 #endif /* ISHTP_HID__H */