aboutsummaryrefslogtreecommitdiff
path: root/include/sm-uclass.h
blob: c11448404403b4144c202298bd9ff11b417a58c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright (c) 2023 SberDevices, Inc.
 *
 * Author: Alexey Romanov <avromanov@salutedevices.com>
 */

#ifndef __SM_UCLASS_H__
#define __SM_UCLASS_H__

#include <asm/types.h>
#include <asm/ptrace.h>

struct udevice;

/**
 * struct sm_ops - The functions that a SM driver must implement.
 *
 * @sm_call: Request a secure monitor call with specified command.
 *
 * @sm_call_read: Request a secure monitor call and retrieve data
 * from secure-monitor (depends on specified command).
 *
 * @sm_call_write: Request a secure monitor call and send data
 * to secure-monitor (depends on specified command).
 *
 * The individual methods are described more fully below.
 */
struct sm_ops {
	/**
	 * sm_call - generic SMC call to the secure-monitor
	 *
	 * @dev:	Pointer to UCLASS_SM device
	 * @cmd_index:	Index of the SMC function ID
	 * @smc_ret:	Returned value from secure world
	 * @args:	SMC arguments
	 *
	 * @return:	0 on success, a negative value on error
	 */
	int (*sm_call)(struct udevice *dev, u32 cmd, s32 *smc_ret,
		       struct pt_regs *args);

	/**
	 * sm_call_write - send data to secure-monitor
	 *
	 * @dev:	Pointer to UCLASS_SM device
	 * @buffer:	Buffer containing data to send
	 * @size:	Size of the buffer
	 * @cmd:	Index of the SMC function ID
	 * @args:	SMC arguments
	 *
	 * @return:	size of sent data on success, a negative value on error
	 */
	int (*sm_call_write)(struct udevice *dev, void *buffer,
			     size_t size, u32 cmd, struct pt_regs *args);

	/**
	 * sm_call_read - retrieve data from secure-monitor
	 *
	 * @dev:	Pointer to UCLASS_SM device
	 * @buffer:	Buffer to store the retrieved data
	 * @size:	Size of the buffer
	 * @cmd:	Index of the SMC function ID
	 * @args:	SMC arguments
	 *
	 * @return:	size of read data on success, a negative value on error
	 */
	int (*sm_call_read)(struct udevice *dev, void *buffer,
			    size_t size, u32 cmd, struct pt_regs *args);
};

#endif /* __SM_UCLASS_H__ */