1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2023 SberDevices, Inc.
8 #ifndef __SM_UCLASS_H__
9 #define __SM_UCLASS_H__
11 #include <asm/types.h>
12 #include <asm/ptrace.h>
17 * struct sm_ops - The functions that a SM driver must implement.
19 * @sm_call: Request a secure monitor call with specified command.
21 * @sm_call_read: Request a secure monitor call and retrieve data
22 * from secure-monitor (depends on specified command).
24 * @sm_call_write: Request a secure monitor call and send data
25 * to secure-monitor (depends on specified command).
27 * The individual methods are described more fully below.
31 * sm_call - generic SMC call to the secure-monitor
33 * @dev: Pointer to UCLASS_SM device
34 * @cmd_index: Index of the SMC function ID
35 * @smc_ret: Returned value from secure world
36 * @args: SMC arguments
38 * @return: 0 on success, a negative value on error
40 int (*sm_call)(struct udevice *dev, u32 cmd, s32 *smc_ret,
41 struct pt_regs *args);
44 * sm_call_write - send data to secure-monitor
46 * @dev: Pointer to UCLASS_SM device
47 * @buffer: Buffer containing data to send
48 * @size: Size of the buffer
49 * @cmd: Index of the SMC function ID
50 * @args: SMC arguments
52 * @return: size of sent data on success, a negative value on error
54 int (*sm_call_write)(struct udevice *dev, void *buffer,
55 size_t size, u32 cmd, struct pt_regs *args);
58 * sm_call_read - retrieve data from secure-monitor
60 * @dev: Pointer to UCLASS_SM device
61 * @buffer: Buffer to store the retrieved data
62 * @size: Size of the buffer
63 * @cmd: Index of the SMC function ID
64 * @args: SMC arguments
66 * @return: size of read data on success, a negative value on error
68 int (*sm_call_read)(struct udevice *dev, void *buffer,
69 size_t size, u32 cmd, struct pt_regs *args);
72 #endif /* __SM_UCLASS_H__ */