2020-10-10 01:31:37 +05:30
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* AMD MP2 Sensors transport driver
*
2021-09-23 17:59:30 +05:30
* Copyright 2020 - 2021 Advanced Micro Devices , Inc .
2020-10-10 01:31:37 +05:30
* Authors : Nehal Bakulchandra Shah < Nehal - bakulchandra . shah @ amd . com >
* Sandeep Singh < sandeep . singh @ amd . com >
2021-09-23 17:59:30 +05:30
* Basavaraj Natikar < Basavaraj . Natikar @ amd . com >
2020-10-10 01:31:37 +05:30
*/
# ifndef AMDSFH_HID_H
# define AMDSFH_HID_H
2021-06-18 13:48:38 +05:30
# define MAX_HID_DEVICES 5
2020-10-10 01:31:37 +05:30
# define AMD_SFH_HID_VENDOR 0x1022
# define AMD_SFH_HID_PRODUCT 0x0001
2022-07-12 23:48:28 +05:30
struct request_list {
struct hid_device * hid ;
struct list_head list ;
u8 report_id ;
u8 sensor_idx ;
u8 report_type ;
u8 current_index ;
} ;
2021-06-18 13:48:37 +05:30
struct amd_input_data {
u32 * sensor_virt_addr [ MAX_HID_DEVICES ] ;
u8 * input_report [ MAX_HID_DEVICES ] ;
} ;
2020-10-10 01:31:37 +05:30
struct amdtp_cl_data {
u8 init_done ;
u32 cur_hid_dev ;
u32 hid_dev_count ;
u32 num_hid_devices ;
struct device_info * hid_devices ;
u8 * report_descr [ MAX_HID_DEVICES ] ;
int report_descr_sz [ MAX_HID_DEVICES ] ;
struct hid_device * hid_sensor_hubs [ MAX_HID_DEVICES ] ;
u8 * hid_descr [ MAX_HID_DEVICES ] ;
int hid_descr_size [ MAX_HID_DEVICES ] ;
phys_addr_t phys_addr_base ;
2021-01-03 14:53:55 +01:00
dma_addr_t sensor_dma_addr [ MAX_HID_DEVICES ] ;
2020-10-10 01:31:37 +05:30
u32 sensor_sts [ MAX_HID_DEVICES ] ;
u32 sensor_requested_cnt [ MAX_HID_DEVICES ] ;
u8 report_type [ MAX_HID_DEVICES ] ;
u8 report_id [ MAX_HID_DEVICES ] ;
u8 sensor_idx [ MAX_HID_DEVICES ] ;
u8 * feature_report [ MAX_HID_DEVICES ] ;
u8 request_done [ MAX_HID_DEVICES ] ;
2021-06-18 13:48:37 +05:30
struct amd_input_data * in_data ;
2020-10-10 01:31:37 +05:30
struct delayed_work work ;
struct delayed_work work_buffer ;
2022-07-12 23:48:29 +05:30
struct request_list req_list ;
2020-10-10 01:31:37 +05:30
} ;
/**
* struct amdtp_hid_data - Per instance HID data
* @ index : Device index in the order of enumeration
* @ request_done : Get Feature / Input report complete flag
* used during get / set request from hid core
* @ cli_data : Link to the client instance
* @ hid_wait : Completion waitq
*
* Used to tie hid - > driver data to driver client instance
*/
struct amdtp_hid_data {
int index ;
struct amdtp_cl_data * cli_data ;
wait_queue_head_t hid_wait ;
} ;
/* Interface functions between HID LL driver and AMD SFH client */
void hid_amdtp_set_feature ( struct hid_device * hid , char * buf , u32 len , int report_id ) ;
void hid_amdtp_get_report ( struct hid_device * hid , int report_id , int report_type ) ;
int amdtp_hid_probe ( u32 cur_hid_dev , struct amdtp_cl_data * cli_data ) ;
void amdtp_hid_remove ( struct amdtp_cl_data * cli_data ) ;
int amd_sfh_get_report ( struct hid_device * hid , int report_id , int report_type ) ;
void amd_sfh_set_report ( struct hid_device * hid , int report_id , int report_type ) ;
void amdtp_hid_wakeup ( struct hid_device * hid ) ;
# endif