// SPDX-License-Identifier: GPL-2.0-only /* * ISHTP client driver for HID (ISH) * * Copyright (c) 2014-2016, Intel Corporation. */ #include <linux/module.h> #include <linux/hid.h> #include <linux/intel-ish-client-if.h> #include <linux/sched.h> #include "ishtp-hid.h" /* ISH Transport protocol (ISHTP in short) GUID */ static const struct ishtp_device_id hid_ishtp_id_table[] = …; MODULE_DEVICE_TABLE(ishtp, hid_ishtp_id_table); /* Rx ring buffer pool size */ #define HID_CL_RX_RING_SIZE … #define HID_CL_TX_RING_SIZE … #define cl_data_to_dev(client_data) … /** * report_bad_packet() - Report bad packets * @hid_ishtp_cl: Client instance to get stats * @recv_buf: Raw received host interface message * @cur_pos: Current position index in payload * @payload_len: Length of payload expected * * Dumps error in case bad packet is received */ static void report_bad_packet(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, size_t cur_pos, size_t payload_len) { … } /** * process_recv() - Received and parse incoming packet * @hid_ishtp_cl: Client instance to get stats * @recv_buf: Raw received host interface message * @data_len: length of the message * * Parse the incoming packet. If it is a response packet then it will update * per instance flags and wake up the caller waiting to for the response. */ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, size_t data_len) { … } /** * ish_cl_event_cb() - bus driver callback for incoming message/packet * @device: Pointer to the ishtp client device for which this message * is targeted * * Remove the packet from the list and process the message by calling * process_recv */ static void ish_cl_event_cb(struct ishtp_cl_device *device) { … } /** * hid_ishtp_set_feature() - send request to ISH FW to set a feature request * @hid: hid device instance for this request * @buf: feature buffer * @len: Length of feature buffer * @report_id: Report id for the feature set request * * This is called from hid core .request() callback. This function doesn't wait * for response. */ void hid_ishtp_set_feature(struct hid_device *hid, char *buf, unsigned int len, int report_id) { … } /** * hid_ishtp_get_report() - request to get feature/input report * @hid: hid device instance for this request * @report_id: Report id for the get request * @report_type: Report type for the this request * * This is called from hid core .request() callback. This function will send * request to FW and return without waiting for response. */ void hid_ishtp_get_report(struct hid_device *hid, int report_id, int report_type) { … } /** * ishtp_hid_link_ready_wait() - Wait for link ready * @client_data: client data instance * * If the transport link started suspend process, then wait, till either * resumed or timeout * * Return: 0 on success, non zero on error */ int ishtp_hid_link_ready_wait(struct ishtp_cl_data *client_data) { … } /** * ishtp_enum_enum_devices() - Enumerate hid devices * @hid_ishtp_cl: client instance * * Helper function to send request to firmware to enumerate HID devices * * Return: 0 on success, non zero on error */ static int ishtp_enum_enum_devices(struct ishtp_cl *hid_ishtp_cl) { … } /** * ishtp_get_hid_descriptor() - Get hid descriptor * @hid_ishtp_cl: client instance * @index: Index into the hid_descr array * * Helper function to send request to firmware get HID descriptor of a device * * Return: 0 on success, non zero on error */ static int ishtp_get_hid_descriptor(struct ishtp_cl *hid_ishtp_cl, int index) { … } /** * ishtp_get_report_descriptor() - Get report descriptor * @hid_ishtp_cl: client instance * @index: Index into the hid_descr array * * Helper function to send request to firmware get HID report descriptor of * a device * * Return: 0 on success, non zero on error */ static int ishtp_get_report_descriptor(struct ishtp_cl *hid_ishtp_cl, int index) { … } /** * hid_ishtp_cl_init() - Init function for ISHTP client * @hid_ishtp_cl: ISHTP client instance * @reset: true if called for init after reset * * This function complete the initializtion of the client. The summary of * processing: * - Send request to enumerate the hid clients * Get the HID descriptor for each enumearated device * Get report description of each device * Register each device wik hid core by calling ishtp_hid_probe * * Return: 0 on success, non zero on error */ static int hid_ishtp_cl_init(struct ishtp_cl *hid_ishtp_cl, bool reset) { … } /** * hid_ishtp_cl_deinit() - Deinit function for ISHTP client * @hid_ishtp_cl: ISHTP client instance * * Unlink and free hid client */ static void hid_ishtp_cl_deinit(struct ishtp_cl *hid_ishtp_cl) { … } static void hid_ishtp_cl_reset_handler(struct work_struct *work) { … } static void hid_ishtp_cl_resume_handler(struct work_struct *work) { … } ishtp_print_log ishtp_hid_print_trace; /** * hid_ishtp_cl_probe() - ISHTP client driver probe * @cl_device: ISHTP client device instance * * This function gets called on device create on ISHTP bus * * Return: 0 on success, non zero on error */ static int hid_ishtp_cl_probe(struct ishtp_cl_device *cl_device) { … } /** * hid_ishtp_cl_remove() - ISHTP client driver remove * @cl_device: ISHTP client device instance * * This function gets called on device remove on ISHTP bus * * Return: 0 */ static void hid_ishtp_cl_remove(struct ishtp_cl_device *cl_device) { … } /** * hid_ishtp_cl_reset() - ISHTP client driver reset * @cl_device: ISHTP client device instance * * This function gets called on device reset on ISHTP bus * * Return: 0 */ static int hid_ishtp_cl_reset(struct ishtp_cl_device *cl_device) { … } /** * hid_ishtp_cl_suspend() - ISHTP client driver suspend * @device: device instance * * This function gets called on system suspend * * Return: 0 */ static int hid_ishtp_cl_suspend(struct device *device) { … } /** * hid_ishtp_cl_resume() - ISHTP client driver resume * @device: device instance * * This function gets called on system resume * * Return: 0 */ static int hid_ishtp_cl_resume(struct device *device) { … } static const struct dev_pm_ops hid_ishtp_pm_ops = …; static struct ishtp_cl_driver hid_ishtp_cl_driver = …; static int __init ish_hid_init(void) { … } static void __exit ish_hid_exit(void) { … } late_initcall(ish_hid_init); module_exit(ish_hid_exit); MODULE_DESCRIPTION(…) …; /* Primary author */ MODULE_AUTHOR(…) …; /* * Several modification for multi instance support * suspend/resume and clean up */ MODULE_AUTHOR(…) …; MODULE_LICENSE(…) …;