WIP FPC-III support
[linux/fpc-iii.git] / drivers / hid / amd-sfh-hid / amd_sfh_pcie.h
blobe8be94f935b78f862bd7cb0da3e07613b7e6ae49
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
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>
7 */
9 #ifndef PCIE_MP2_AMD_H
10 #define PCIE_MP2_AMD_H
12 #include <linux/pci.h>
14 #define PCI_DEVICE_ID_AMD_MP2 0x15E4
16 #define ENABLE_SENSOR 1
17 #define DISABLE_SENSOR 2
18 #define STOP_ALL_SENSORS 8
20 /* MP2 C2P Message Registers */
21 #define AMD_C2P_MSG0 0x10500
22 #define AMD_C2P_MSG1 0x10504
23 #define AMD_C2P_MSG2 0x10508
25 /* MP2 P2C Message Registers */
26 #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */
28 /* SFH Command register */
29 union sfh_cmd_base {
30 u32 ul;
31 struct {
32 u32 cmd_id : 8;
33 u32 sensor_id : 8;
34 u32 period : 16;
35 } s;
38 union sfh_cmd_param {
39 u32 ul;
40 struct {
41 u32 buf_layout : 2;
42 u32 buf_length : 6;
43 u32 rsvd : 24;
44 } s;
47 struct sfh_cmd_reg {
48 union sfh_cmd_base cmd_base;
49 union sfh_cmd_param cmd_param;
50 phys_addr_t phys_addr;
53 enum sensor_idx {
54 accel_idx = 0,
55 gyro_idx = 1,
56 mag_idx = 2,
57 als_idx = 19
60 struct amd_mp2_dev {
61 struct pci_dev *pdev;
62 struct amdtp_cl_data *cl_data;
63 void __iomem *mmio;
64 u32 activecontrolstatus;
67 struct amd_mp2_sensor_info {
68 u8 sensor_idx;
69 u32 period;
70 phys_addr_t phys_address;
73 void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
74 void amd_stop_sensor(struct amd_mp2_dev *privdata, u16 sensor_idx);
75 void amd_stop_all_sensors(struct amd_mp2_dev *privdata);
76 int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id);
77 int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata);
78 int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata);
79 #endif