xref: /linux/drivers/hid/amd-sfh-hid/amd_sfh_common.h (revision 786aa1b961d1b25f9480ae147e84e146f46fdca2)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * AMD MP2 common macros and structures
4  *
5  * Copyright (c) 2022, Advanced Micro Devices, Inc.
6  * All Rights Reserved.
7  *
8  * Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
9  */
10 #ifndef AMD_SFH_COMMON_H
11 #define AMD_SFH_COMMON_H
12 
13 #include <linux/pci.h>
14 #include "amd_sfh_hid.h"
15 
16 #define PCI_DEVICE_ID_AMD_MP2		0x15E4
17 
18 #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
19 #define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
20 
21 #define SENSOR_ENABLED			4
22 #define SENSOR_DISABLED			5
23 
24 #define AMD_SFH_IDLE_LOOP		200
25 
26 enum cmd_id {
27 	NO_OP,
28 	ENABLE_SENSOR,
29 	DISABLE_SENSOR,
30 	STOP_ALL_SENSORS = 8,
31 };
32 
33 struct amd_mp2_sensor_info {
34 	u8 sensor_idx;
35 	u32 period;
36 	dma_addr_t dma_address;
37 };
38 
39 struct amd_mp2_dev {
40 	struct pci_dev *pdev;
41 	struct amdtp_cl_data *cl_data;
42 	void __iomem *mmio;
43 	struct amd_mp2_ops *mp2_ops;
44 	struct amd_input_data in_data;
45 	/* mp2 active control status */
46 	u32 mp2_acs;
47 };
48 
49 struct amd_mp2_ops {
50 	void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
51 	void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
52 	void (*stop_all)(struct amd_mp2_dev *privdata);
53 	int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
54 	void (*clear_intr)(struct amd_mp2_dev *privdata);
55 	int (*init_intr)(struct amd_mp2_dev *privdata);
56 	int (*discovery_status)(struct amd_mp2_dev *privdata);
57 	int (*get_rep_desc)(int sensor_idx, u8 rep_desc[]);
58 	u32 (*get_desc_sz)(int sensor_idx, int descriptor_name);
59 	u8 (*get_feat_rep)(int sensor_idx, int report_id, u8 *feature_report);
60 	u8 (*get_in_rep)(u8 current_index, int sensor_idx, int report_id,
61 			 struct amd_input_data *in_data);
62 };
63 
64 #endif
65