14f567b9fSSandeep Singh /* SPDX-License-Identifier: GPL-2.0-or-later */ 24f567b9fSSandeep Singh /* 34f567b9fSSandeep Singh * AMD MP2 PCIe communication driver 4f75203cdSBasavaraj Natikar * Copyright 2020-2021 Advanced Micro Devices, Inc. 54f567b9fSSandeep Singh * Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> 64f567b9fSSandeep Singh * Sandeep Singh <Sandeep.singh@amd.com> 7f75203cdSBasavaraj Natikar * Basavaraj Natikar <Basavaraj.Natikar@amd.com> 84f567b9fSSandeep Singh */ 94f567b9fSSandeep Singh 104f567b9fSSandeep Singh #ifndef PCIE_MP2_AMD_H 114f567b9fSSandeep Singh #define PCIE_MP2_AMD_H 124f567b9fSSandeep Singh 136947f312SBasavaraj Natikar #include "amd_sfh_common.h" 144f567b9fSSandeep Singh 154f567b9fSSandeep Singh /* MP2 C2P Message Registers */ 164f567b9fSSandeep Singh #define AMD_C2P_MSG0 0x10500 174f567b9fSSandeep Singh #define AMD_C2P_MSG1 0x10504 184f567b9fSSandeep Singh #define AMD_C2P_MSG2 0x10508 194f567b9fSSandeep Singh 204f567b9fSSandeep Singh /* MP2 P2C Message Registers */ 214f567b9fSSandeep Singh #define AMD_P2C_MSG3 0x1068C /* Supported Sensors info */ 224f567b9fSSandeep Singh 23f264481aSBasavaraj Natikar #define V2_STATUS 0x2 24f264481aSBasavaraj Natikar 2524a31ea9SBasavaraj Natikar #define HPD_IDX 16 264bd76356SBasavaraj Natikar #define ACS_IDX 22 2724a31ea9SBasavaraj Natikar 28b5d7f43eSBasavaraj Natikar #define SENSOR_DISCOVERY_STATUS_MASK GENMASK(5, 3) 29b5d7f43eSBasavaraj Natikar #define SENSOR_DISCOVERY_STATUS_SHIFT 3 30b5d7f43eSBasavaraj Natikar 314f567b9fSSandeep Singh /* SFH Command register */ 324f567b9fSSandeep Singh union sfh_cmd_base { 334f567b9fSSandeep Singh u32 ul; 344f567b9fSSandeep Singh struct { 354f567b9fSSandeep Singh u32 cmd_id : 8; 364f567b9fSSandeep Singh u32 sensor_id : 8; 374f567b9fSSandeep Singh u32 period : 16; 384f567b9fSSandeep Singh } s; 39f264481aSBasavaraj Natikar struct { 40f264481aSBasavaraj Natikar u32 cmd_id : 4; 41aa0b724aSBasavaraj Natikar u32 intr_disable : 1; 42f264481aSBasavaraj Natikar u32 rsvd1 : 3; 43f264481aSBasavaraj Natikar u32 length : 7; 44f264481aSBasavaraj Natikar u32 mem_type : 1; 45f264481aSBasavaraj Natikar u32 sensor_id : 8; 46f264481aSBasavaraj Natikar u32 period : 8; 47f264481aSBasavaraj Natikar } cmd_v2; 484f567b9fSSandeep Singh }; 494f567b9fSSandeep Singh 50173709f5SBasavaraj Natikar union cmd_response { 51173709f5SBasavaraj Natikar u32 resp; 52173709f5SBasavaraj Natikar struct { 53173709f5SBasavaraj Natikar u32 status : 2; 54173709f5SBasavaraj Natikar u32 out_in_c2p : 1; 55173709f5SBasavaraj Natikar u32 rsvd1 : 1; 56173709f5SBasavaraj Natikar u32 response : 4; 57173709f5SBasavaraj Natikar u32 sub_cmd : 8; 58173709f5SBasavaraj Natikar u32 sensor_id : 6; 59173709f5SBasavaraj Natikar u32 rsvd2 : 10; 60173709f5SBasavaraj Natikar } response_v2; 61173709f5SBasavaraj Natikar }; 62173709f5SBasavaraj Natikar 634f567b9fSSandeep Singh union sfh_cmd_param { 644f567b9fSSandeep Singh u32 ul; 654f567b9fSSandeep Singh struct { 664f567b9fSSandeep Singh u32 buf_layout : 2; 674f567b9fSSandeep Singh u32 buf_length : 6; 684f567b9fSSandeep Singh u32 rsvd : 24; 694f567b9fSSandeep Singh } s; 704f567b9fSSandeep Singh }; 714f567b9fSSandeep Singh 724f567b9fSSandeep Singh struct sfh_cmd_reg { 734f567b9fSSandeep Singh union sfh_cmd_base cmd_base; 744f567b9fSSandeep Singh union sfh_cmd_param cmd_param; 754f567b9fSSandeep Singh phys_addr_t phys_addr; 764f567b9fSSandeep Singh }; 774f567b9fSSandeep Singh 784f567b9fSSandeep Singh enum sensor_idx { 794f567b9fSSandeep Singh accel_idx = 0, 804f567b9fSSandeep Singh gyro_idx = 1, 814f567b9fSSandeep Singh mag_idx = 2, 824f567b9fSSandeep Singh als_idx = 19 834f567b9fSSandeep Singh }; 844f567b9fSSandeep Singh 85f264481aSBasavaraj Natikar enum mem_use_type { 86f264481aSBasavaraj Natikar USE_DRAM, 87f264481aSBasavaraj Natikar USE_C2P_REG, 88f264481aSBasavaraj Natikar }; 89f264481aSBasavaraj Natikar 9024a31ea9SBasavaraj Natikar struct hpd_status { 9124a31ea9SBasavaraj Natikar union { 9224a31ea9SBasavaraj Natikar struct { 9324a31ea9SBasavaraj Natikar u32 object_distance : 16; 94*c691d69fSBasavaraj Natikar u32 probablity : 8; 95*c691d69fSBasavaraj Natikar u32 human_presence_actual : 4; 96*c691d69fSBasavaraj Natikar u32 human_presence_report : 4; 9724a31ea9SBasavaraj Natikar } shpd; 9824a31ea9SBasavaraj Natikar u32 val; 9924a31ea9SBasavaraj Natikar }; 10024a31ea9SBasavaraj Natikar }; 10124a31ea9SBasavaraj Natikar 1024f567b9fSSandeep Singh int amd_mp2_get_sensor_num(struct amd_mp2_dev *privdata, u8 *sensor_id); 1034f567b9fSSandeep Singh int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata); 1044f567b9fSSandeep Singh int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata); 105786aa1b9SBasavaraj Natikar void amd_sfh_set_desc_ops(struct amd_mp2_ops *mp2_ops); 106f264481aSBasavaraj Natikar 1074f567b9fSSandeep Singh #endif 108