1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * AMD Platform Management Framework Interface 4 * 5 * Copyright (c) 2023, Advanced Micro Devices, Inc. 6 * All Rights Reserved. 7 * 8 * Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> 9 * Basavaraj Natikar <Basavaraj.Natikar@amd.com> 10 */ 11 12 #ifndef AMD_PMF_IO_H 13 #define AMD_PMF_IO_H 14 15 #include <linux/types.h> 16 17 /** 18 * enum sfh_message_type - Query the SFH message type 19 * @MT_HPD: Message ID to know the Human presence info from MP2 FW 20 * @MT_ALS: Message ID to know the Ambient light info from MP2 FW 21 * @MT_SRA: Message ID to know the SRA data from MP2 FW 22 * @MT_OP_MODE: Message ID to know the operating-mode (tablet/laptop) info 23 */ 24 enum sfh_message_type { 25 MT_HPD, 26 MT_ALS, 27 MT_SRA, 28 MT_OP_MODE, 29 }; 30 31 /** 32 * enum sfh_hpd_info - Query the Human presence information 33 * @SFH_NOT_DETECTED: Check the HPD connection information from MP2 FW 34 * @SFH_USER_PRESENT: Check if the user is present from HPD sensor 35 * @SFH_USER_AWAY: Check if the user is away from HPD sensor 36 */ 37 enum sfh_hpd_info { 38 SFH_NOT_DETECTED, 39 SFH_USER_PRESENT, 40 SFH_USER_AWAY, 41 }; 42 43 /** 44 * struct amd_sfh_info - get HPD sensor info from MP2 FW 45 * @ambient_light: Populates the ambient light information 46 * @user_present: Populates the user presence information 47 * @platform_type: Operating modes (clamshell, flat, tent, etc.) 48 * @laptop_placement: Device states (ontable, onlap, outbag) 49 * @op_mode: Operating-mode field (see enum sfh_dev_mode); used for tablet detection 50 */ 51 struct amd_sfh_info { 52 u32 ambient_light; 53 u8 user_present; 54 u32 platform_type; 55 u32 laptop_placement; 56 u32 op_mode; 57 }; 58 59 /** 60 * enum sfh_dev_mode - SFH operating-mode field (sfh_op_mode.mode, bits 0-2) 61 * @SFH_MODE_LAPTOP: Device is in laptop/clamshell posture 62 * @SFH_MODE_TABLET: Device is in tablet posture 63 */ 64 enum sfh_dev_mode { 65 SFH_MODE_LAPTOP = 1, 66 SFH_MODE_TABLET = 3, 67 }; 68 69 /** 70 * struct amd_pmf_npu_metrics: Get NPU metrics data from PMF driver 71 * @npuclk_freq: NPU clock frequency [MHz] 72 * @npu_busy: NPU busy % [0-100] 73 * @npu_power: NPU power [mW] 74 * @mpnpuclk_freq: MPNPU [MHz] 75 * @npu_reads: NPU read bandwidth [MB/sec] 76 * @npu_writes: NPU write bandwidth [MB/sec] 77 * @npu_temp: NPU temperature [C] 78 */ 79 struct amd_pmf_npu_metrics { 80 u16 npuclk_freq; 81 u16 npu_busy[8]; 82 u16 npu_power; 83 u16 mpnpuclk_freq; 84 u16 npu_reads; 85 u16 npu_writes; 86 u16 npu_temp; 87 }; 88 89 int amd_get_sfh_info(struct amd_sfh_info *sfh_info, enum sfh_message_type op); 90 91 /* AMD PMF and NPU interface */ 92 int amd_pmf_get_npu_data(struct amd_pmf_npu_metrics *info); 93 #endif 94