blob: c11448404403b4144c202298bd9ff11b417a58c5 [file] [log] [blame]
Alexey Romanovc52cd072023-09-21 11:13:34 +03001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Copyright (c) 2023 SberDevices, Inc.
4 *
5 * Author: Alexey Romanov <avromanov@salutedevices.com>
6 */
7
8#ifndef __SM_UCLASS_H__
9#define __SM_UCLASS_H__
10
11#include <asm/types.h>
12#include <asm/ptrace.h>
13
14struct udevice;
15
16/**
17 * struct sm_ops - The functions that a SM driver must implement.
18 *
19 * @sm_call: Request a secure monitor call with specified command.
20 *
21 * @sm_call_read: Request a secure monitor call and retrieve data
22 * from secure-monitor (depends on specified command).
23 *
24 * @sm_call_write: Request a secure monitor call and send data
25 * to secure-monitor (depends on specified command).
26 *
27 * The individual methods are described more fully below.
28 */
29struct sm_ops {
30 /**
31 * sm_call - generic SMC call to the secure-monitor
32 *
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
37 *
38 * @return: 0 on success, a negative value on error
39 */
40 int (*sm_call)(struct udevice *dev, u32 cmd, s32 *smc_ret,
41 struct pt_regs *args);
42
43 /**
44 * sm_call_write - send data to secure-monitor
45 *
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
51 *
52 * @return: size of sent data on success, a negative value on error
53 */
54 int (*sm_call_write)(struct udevice *dev, void *buffer,
55 size_t size, u32 cmd, struct pt_regs *args);
56
57 /**
58 * sm_call_read - retrieve data from secure-monitor
59 *
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
65 *
66 * @return: size of read data on success, a negative value on error
67 */
68 int (*sm_call_read)(struct udevice *dev, void *buffer,
69 size_t size, u32 cmd, struct pt_regs *args);
70};
71
72#endif /* __SM_UCLASS_H__ */