1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * AMD MP2 PCIe communication driver
4 * Copyright 2020 Advanced Micro Devices, Inc.
5 * Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
6 * Sandeep Singh <Sandeep.singh@amd.com>
10 #define PCIE_MP2_AMD_H
12 #include <linux/pci.h>
13 #include "amd_sfh_hid.h"
15 #define PCI_DEVICE_ID_AMD_MP2 0x15E4
17 #define ENABLE_SENSOR 1
18 #define DISABLE_SENSOR 2
19 #define STOP_ALL_SENSORS 8
21 /* MP2 C2P Message Registers */
22 #define AMD_C2P_MSG0 0x10500
23 #define AMD_C2P_MSG1 0x10504
24 #define AMD_C2P_MSG2 0x10508
26 #define AMD_C2P_MSG(regno) (0x10500 + ((regno) * 4))
27 #define AMD_P2C_MSG(regno) (0x10680 + ((regno) * 4))
29 /* MP2 P2C Message Registers */
30 #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */
34 #define SENSOR_ENABLED 4
35 #define SENSOR_DISABLED 5
39 #define AMD_SFH_IDLE_LOOP 200
41 /* SFH Command register */
83 union sfh_cmd_base cmd_base;
84 union sfh_cmd_param cmd_param;
85 phys_addr_t phys_addr;
97 struct amdtp_cl_data *cl_data;
99 const struct amd_mp2_ops *mp2_ops;
100 struct amd_input_data in_data;
101 /* mp2 active control status */
105 struct amd_mp2_sensor_info {
108 dma_addr_t dma_address;
119 u32 human_presence_report : 4;
120 u32 human_presence_actual : 4;
122 u32 object_distance : 16;
128 void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
129 void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx);
130 void amd_stop_all_sensors(struct amd_mp2_dev *privdata);
131 int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id);
132 int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata);
133 int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
134 u32 amd_sfh_wait_for_response(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
135 void amd_mp2_suspend(struct amd_mp2_dev *mp2);
136 void amd_mp2_resume(struct amd_mp2_dev *mp2);
139 void (*start)(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
140 void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
141 void (*stop_all)(struct amd_mp2_dev *privdata);
142 int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);