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