1
2
3
4
5
6#ifndef __STM32MP1_SMC_H__
7#define __STM32MP1_SMC_H__
8
9#include <linux/arm-smccc.h>
10
11
12
13
14
15
16
17
18#define STM32_SMC_VERSION 0x82000000
19
20
21#define STM32_SMC_BSEC 0x82001003
22
23
24#define STM32_SMC_READ_SHADOW 0x01
25#define STM32_SMC_PROG_OTP 0x02
26#define STM32_SMC_WRITE_SHADOW 0x03
27#define STM32_SMC_READ_OTP 0x04
28#define STM32_SMC_READ_ALL 0x05
29#define STM32_SMC_WRITE_ALL 0x06
30#define STM32_SMC_WRLOCK_OTP 0x07
31
32
33#define STM32_SMC_OK 0x0
34#define STM32_SMC_NOT_SUPPORTED -1
35#define STM32_SMC_FAILED -2
36#define STM32_SMC_INVALID_PARAMS -3
37
38#define stm32_smc_exec(svc, op, data1, data2) \
39 stm32_smc(svc, op, data1, data2, NULL)
40
41#ifdef CONFIG_ARM_SMCCC
42static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
43{
44 struct arm_smccc_res res;
45
46 arm_smccc_smc(svc, op, data1, data2, 0, 0, 0, 0, &res);
47
48 if (res.a0) {
49 pr_err("%s: Failed to exec svc=%x op=%x in secure mode (err = %ld)\n",
50 __func__, svc, op, res.a0);
51 return -EINVAL;
52 }
53 if (result)
54 *result = (u32)res.a1;
55
56 return 0;
57}
58#else
59static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
60{
61 return 0;
62}
63#endif
64
65#endif
66