1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 /* 3 * Copyright (C) 2021-2024 Advanced Micro Devices, Inc. 4 */ 5 #ifndef _AMD_APML_H_ 6 #define _AMD_APML_H_ 7 8 #include <linux/types.h> 9 10 /* Mailbox data size for data_in and data_out */ 11 #define AMD_SBI_MB_DATA_SIZE 4 12 13 struct apml_mbox_msg { 14 /* 15 * Mailbox Message ID 16 */ 17 __u32 cmd; 18 /* 19 * [0]...[3] mailbox 32bit input/output data 20 */ 21 __u32 mb_in_out; 22 /* 23 * Error code is returned in case of soft mailbox error 24 */ 25 __u32 fw_ret_code; 26 }; 27 28 struct apml_cpuid_msg { 29 /* 30 * CPUID input 31 * [0]...[3] cpuid func, 32 * [4][5] cpuid: thread 33 * [6] cpuid: ext function & read eax/ebx or ecx/edx 34 * [7:0] -> bits [7:4] -> ext function & 35 * bit [0] read eax/ebx or ecx/edx 36 * CPUID output 37 */ 38 __u64 cpu_in_out; 39 /* 40 * Status code for CPUID read 41 */ 42 __u32 fw_ret_code; 43 __u32 pad; 44 }; 45 46 struct apml_mcamsr_msg { 47 /* 48 * MCAMSR input 49 * [0]...[3] mca msr func, 50 * [4][5] thread 51 * MCAMSR output 52 */ 53 __u64 mcamsr_in_out; 54 /* 55 * Status code for MCA/MSR access 56 */ 57 __u32 fw_ret_code; 58 __u32 pad; 59 }; 60 61 /* 62 * AMD sideband interface base IOCTL 63 */ 64 #define SB_BASE_IOCTL_NR 0xF9 65 66 /** 67 * DOC: SBRMI_IOCTL_MBOX_CMD 68 * 69 * @Parameters 70 * 71 * @struct apml_mbox_msg 72 * Pointer to the &struct apml_mbox_msg that will contain the protocol 73 * information 74 * 75 * @Description 76 * IOCTL command for APML messages using generic _IOWR 77 * The IOCTL provides userspace access to AMD sideband mailbox protocol 78 * - Mailbox message read/write(0x0~0xFF) 79 * - returning "-EFAULT" if none of the above 80 * "-EPROTOTYPE" error is returned to provide additional error details 81 */ 82 #define SBRMI_IOCTL_MBOX_CMD _IOWR(SB_BASE_IOCTL_NR, 0, struct apml_mbox_msg) 83 84 /** 85 * DOC: SBRMI_IOCTL_CPUID_CMD 86 * 87 * @Parameters 88 * 89 * @struct apml_cpuid_msg 90 * Pointer to the &struct apml_cpuid_msg that will contain the protocol 91 * information 92 * 93 * @Description 94 * IOCTL command for APML messages using generic _IOWR 95 * The IOCTL provides userspace access to AMD sideband cpuid protocol 96 * - CPUID protocol to get CPU details for Function/Ext Function 97 * at thread level 98 * - returning "-EFAULT" if none of the above 99 * "-EPROTOTYPE" error is returned to provide additional error details 100 */ 101 #define SBRMI_IOCTL_CPUID_CMD _IOWR(SB_BASE_IOCTL_NR, 1, struct apml_cpuid_msg) 102 103 /** 104 * DOC: SBRMI_IOCTL_MCAMSR_CMD 105 * 106 * @Parameters 107 * 108 * @struct apml_mcamsr_msg 109 * Pointer to the &struct apml_mcamsr_msg that will contain the protocol 110 * information 111 * 112 * @Description 113 * IOCTL command for APML messages using generic _IOWR 114 * The IOCTL provides userspace access to AMD sideband MCAMSR protocol 115 * - MCAMSR protocol to get MCA bank details for Function at thread level 116 * - returning "-EFAULT" if none of the above 117 * "-EPROTOTYPE" error is returned to provide additional error details 118 */ 119 #define SBRMI_IOCTL_MCAMSR_CMD _IOWR(SB_BASE_IOCTL_NR, 2, struct apml_mcamsr_msg) 120 121 #endif /*_AMD_APML_H_*/ 122