1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * AMD MP2 Sensors transport driver 4 * 5 * Copyright 2020-2021 Advanced Micro Devices, Inc. 6 * Authors: Nehal Bakulchandra Shah <Nehal-bakulchandra.shah@amd.com> 7 * Sandeep Singh <sandeep.singh@amd.com> 8 * Basavaraj Natikar <Basavaraj.Natikar@amd.com> 9 */ 10 11 #ifndef AMDSFH_HID_H 12 #define AMDSFH_HID_H 13 14 #define MAX_HID_DEVICES 5 15 #define AMD_SFH_HID_VENDOR 0x1022 16 #define AMD_SFH_HID_PRODUCT 0x0001 17 18 struct request_list { 19 struct hid_device *hid; 20 struct list_head list; 21 u8 report_id; 22 u8 sensor_idx; 23 u8 report_type; 24 u8 current_index; 25 }; 26 27 struct amd_input_data { 28 u32 *sensor_virt_addr[MAX_HID_DEVICES]; 29 u8 *input_report[MAX_HID_DEVICES]; 30 }; 31 32 struct amdtp_cl_data { 33 u8 init_done; 34 u32 cur_hid_dev; 35 bool is_any_sensor_enabled; 36 u32 hid_dev_count; 37 u32 num_hid_devices; 38 struct device_info *hid_devices; 39 u8 *report_descr[MAX_HID_DEVICES]; 40 int report_descr_sz[MAX_HID_DEVICES]; 41 struct hid_device *hid_sensor_hubs[MAX_HID_DEVICES]; 42 u8 *hid_descr[MAX_HID_DEVICES]; 43 int hid_descr_size[MAX_HID_DEVICES]; 44 phys_addr_t phys_addr_base; 45 dma_addr_t sensor_dma_addr[MAX_HID_DEVICES]; 46 u32 sensor_sts[MAX_HID_DEVICES]; 47 u32 sensor_requested_cnt[MAX_HID_DEVICES]; 48 u8 report_type[MAX_HID_DEVICES]; 49 u8 report_id[MAX_HID_DEVICES]; 50 u8 sensor_idx[MAX_HID_DEVICES]; 51 u8 *feature_report[MAX_HID_DEVICES]; 52 u8 request_done[MAX_HID_DEVICES]; 53 struct amd_input_data *in_data; 54 struct delayed_work work; 55 struct delayed_work work_buffer; 56 struct request_list req_list; 57 }; 58 59 /** 60 * struct amdtp_hid_data - Per instance HID data 61 * @index: Device index in the order of enumeration 62 * @request_done: Get Feature/Input report complete flag 63 * used during get/set request from hid core 64 * @cli_data: Link to the client instance 65 * @hid_wait: Completion waitq 66 * 67 * Used to tie hid->driver data to driver client instance 68 */ 69 struct amdtp_hid_data { 70 int index; 71 struct amdtp_cl_data *cli_data; 72 wait_queue_head_t hid_wait; 73 }; 74 75 /* Interface functions between HID LL driver and AMD SFH client */ 76 void hid_amdtp_set_feature(struct hid_device *hid, char *buf, u32 len, int report_id); 77 void hid_amdtp_get_report(struct hid_device *hid, int report_id, int report_type); 78 int amdtp_hid_probe(u32 cur_hid_dev, struct amdtp_cl_data *cli_data); 79 void amdtp_hid_remove(struct amdtp_cl_data *cli_data); 80 int amd_sfh_get_report(struct hid_device *hid, int report_id, int report_type); 81 void amd_sfh_set_report(struct hid_device *hid, int report_id, int report_type); 82 void amdtp_hid_wakeup(struct hid_device *hid); 83 #endif 84