Sandeep Singh | 4f567b9 | 2020-10-10 01:31:36 +0530 | [diff] [blame] | 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 | */ |
| 8 | |
| 9 | #ifndef PCIE_MP2_AMD_H |
| 10 | #define PCIE_MP2_AMD_H |
| 11 | |
| 12 | #include <linux/pci.h> |
| 13 | |
| 14 | #define PCI_DEVICE_ID_AMD_MP2 0x15E4 |
| 15 | |
| 16 | #define ENABLE_SENSOR 1 |
| 17 | #define DISABLE_SENSOR 2 |
| 18 | #define STOP_ALL_SENSORS 8 |
| 19 | |
| 20 | /* MP2 C2P Message Registers */ |
| 21 | #define AMD_C2P_MSG0 0x10500 |
| 22 | #define AMD_C2P_MSG1 0x10504 |
| 23 | #define AMD_C2P_MSG2 0x10508 |
| 24 | |
| 25 | /* MP2 P2C Message Registers */ |
| 26 | #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */ |
| 27 | |
| 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; |
| 36 | }; |
| 37 | |
| 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; |
| 45 | }; |
| 46 | |
| 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; |
| 51 | }; |
| 52 | |
| 53 | enum sensor_idx { |
| 54 | accel_idx = 0, |
| 55 | gyro_idx = 1, |
| 56 | mag_idx = 2, |
| 57 | als_idx = 19 |
| 58 | }; |
| 59 | |
| 60 | struct amd_mp2_dev { |
| 61 | struct pci_dev *pdev; |
| 62 | struct amdtp_cl_data *cl_data; |
| 63 | void __iomem *mmio; |
| 64 | u32 activecontrolstatus; |
| 65 | }; |
| 66 | |
| 67 | struct amd_mp2_sensor_info { |
| 68 | u8 sensor_idx; |
| 69 | u32 period; |
Arnd Bergmann | de30491 | 2021-01-03 14:53:55 +0100 | [diff] [blame^] | 70 | dma_addr_t dma_address; |
Sandeep Singh | 4f567b9 | 2020-10-10 01:31:36 +0530 | [diff] [blame] | 71 | }; |
| 72 | |
| 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 |