xref: /linux/include/uapi/misc/amd-apml.h (revision bb13a84ed6b78200952b264b4d7a024b730e8246)
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 /*
47  * AMD sideband interface base IOCTL
48  */
49 #define SB_BASE_IOCTL_NR	0xF9
50 
51 /**
52  * DOC: SBRMI_IOCTL_MBOX_CMD
53  *
54  * @Parameters
55  *
56  * @struct apml_mbox_msg
57  *	Pointer to the &struct apml_mbox_msg that will contain the protocol
58  *	information
59  *
60  * @Description
61  * IOCTL command for APML messages using generic _IOWR
62  * The IOCTL provides userspace access to AMD sideband mailbox protocol
63  * - Mailbox message read/write(0x0~0xFF)
64  * - returning "-EFAULT" if none of the above
65  * "-EPROTOTYPE" error is returned to provide additional error details
66  */
67 #define SBRMI_IOCTL_MBOX_CMD		_IOWR(SB_BASE_IOCTL_NR, 0, struct apml_mbox_msg)
68 
69 /**
70  * DOC: SBRMI_IOCTL_CPUID_CMD
71  *
72  * @Parameters
73  *
74  * @struct apml_cpuid_msg
75  *	Pointer to the &struct apml_cpuid_msg that will contain the protocol
76  *	information
77  *
78  * @Description
79  * IOCTL command for APML messages using generic _IOWR
80  * The IOCTL provides userspace access to AMD sideband cpuid protocol
81  * - CPUID protocol to get CPU details for Function/Ext Function
82  * at thread level
83  * - returning "-EFAULT" if none of the above
84  * "-EPROTOTYPE" error is returned to provide additional error details
85  */
86 #define SBRMI_IOCTL_CPUID_CMD		_IOWR(SB_BASE_IOCTL_NR, 1, struct apml_cpuid_msg)
87 
88 #endif /*_AMD_APML_H_*/
89