1 /* SPDX-License-Identifier: BSD-3-Clause */
2 /*
3  * Copyright (c) 2016-2020, STMicroelectronics
4  * Copyright (c) 2018, Linaro Limited
5  */
6 #ifndef __STM32MP1_SMC_H__
7 #define __STM32MP1_SMC_H__
8 
9 #include <sm/optee_smc.h>
10 
11 /*
12  * SIP Functions
13  */
14 #define STM32_SIP_SVC_VERSION_MAJOR	0x0
15 #define STM32_SIP_SVC_VERSION_MINOR	0x1
16 
17 #define STM32_SIP_SVC_FUNCTION_COUNT	0x3
18 
19 /* STM32 SIP service generic return codes */
20 #define STM32_SIP_SVC_OK		0x0
21 #define STM32_SIP_SVC_UNKNOWN_FUNCTION	OPTEE_SMC_RETURN_UNKNOWN_FUNCTION
22 #define STM32_SIP_SVC_FAILED		0xfffffffeU
23 #define STM32_SIP_SVC_INVALID_PARAMS	0xfffffffdU
24 
25 /*
26  * SMC function IDs for STM32 Service queries
27  * STM32 SMC services use the space between 0x82000000 and 0x8200FFFF
28  * like this is defined in SMC calling Convention by ARM
29  * for SiP (Silicon Partner)
30  * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
31  */
32 
33 /*
34  * SIP function STM32_SIP_FUNC_CALL_COUNT
35  *
36  * Argument a0: (input) SMCC ID
37  *		(output) Count of defined function IDs
38  */
39 #define STM32_SIP_SVC_FUNC_CALL_COUNT		0xff00
40 
41 /*
42  * Return the following UID if using API specified in this file without
43  * further extensions:
44  * 50aa78a7-9bf4-4a14-8a5e-264d5994c214.
45  *
46  * Represented in 4 32-bit words in STM32_SIP_UID_0, STM32_SIP_UID_1,
47  * STM32_SIP_UID_2, STM32_SIP_UID_3.
48  */
49 #define STM32_SIP_SVC_UID_0			0x50aa78a7
50 #define STM32_SIP_SVC_UID_1			0x9bf44a14
51 #define STM32_SIP_SVC_UID_2			0x8a5e264d
52 #define STM32_SIP_SVC_UID_3			0x5994c214
53 
54 /*
55  * SIP function STM32_SIP_SVC_FUNC_UID
56  *
57  * Argument a0: (input) SMCC ID
58  *		(output) Lowest 32bit of the stm32mp1 SIP service UUID
59  * Argument a1: (output) Next 32bit of the stm32mp1 SIP service UUID
60  * Argument a2: (output) Next 32bit of the stm32mp1 SIP service UUID
61  * Argument a3: (output) Last 32bit of the stm32mp1 SIP service UUID
62  */
63 #define STM32_SIP_SVC_FUNC_UID			0xff01
64 
65 /*
66  * SIP function STM32_SIP_FUNC_VERSION
67  *
68  * Argument a0: (input) SMCC ID
69  *		(output) STM32 SIP service major
70  * Argument a1: (output) STM32 SIP service minor
71  */
72 #define STM32_SIP_SVC_FUNC_VERSION		0xff03
73 
74 /*
75  * SIP functions STM32_SIP_SVC_FUNC_BSEC
76  *
77  * Argument a0: (input) SMCCC function ID
78  *		(output) status return code
79  * Argument a1: (input) Service ID (STM32_SIP_BSEC_xxx)
80  * Argument a2: (input) OTP index
81  *		(output) OTP read value, if applicable
82  * Argument a3: (input) OTP value if applicable
83  */
84 #define STM32_SIP_SVC_FUNC_BSEC			0x1003
85 
86 /* Service ID for function ID STM32_SIP_FUNC_BSEC */
87 #define STM32_SIP_SVC_BSEC_READ_SHADOW		0x1
88 #define STM32_SIP_SVC_BSEC_PROG_OTP		0x2
89 #define STM32_SIP_SVC_BSEC_WRITE_SHADOW		0x3
90 #define STM32_SIP_SVC_BSEC_READ_OTP		0x4
91 /* reserved for STM32_SIP_SVC_SMC_READ_ALL	0x5 */
92 /* reserved for STM32_SIP_SVC_SMC_WRITE_ALL	0x6 */
93 #define STM32_SIP_SVC_BSEC_WRLOCK_OTP		0x7
94 
95 /*
96  * SIP function STM32_SIP_SVC_FUNC_SCMI_AGENT0
97  * SIP function STM32_SIP_SVC_FUNC_SCMI_AGENT1
98  *
99  * Process SCMI message pending in related SCMI shared memory buffer.
100  *
101  * Argument a0: (input) SMCC ID
102  */
103 #define STM32_SIP_SVC_FUNC_SCMI_AGENT0		0x2000
104 #define STM32_SIP_SVC_FUNC_SCMI_AGENT1		0x2001
105 
106 #endif /* __STM32MP1_SMC_H__*/
107