Alexey Romanov | c52cd07 | 2023-09-21 11:13:34 +0300 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
| 2 | /* |
| 3 | * Copyright (c) 2023 SberDevices, Inc. |
| 4 | * |
| 5 | * Author: Alexey Romanov <avromanov@salutedevices.ru> |
| 6 | */ |
| 7 | |
| 8 | #ifndef __SM_H__ |
| 9 | #define __SM_H__ |
| 10 | |
| 11 | /* |
| 12 | * NOTE: UCLASS_SM is designed with the idea that |
| 13 | * each driver should convert @cmd to some raw |
| 14 | * value, which is known only for driver, and set this |
| 15 | * value to the first element of the @args->regs array. |
| 16 | * Therefore, it is necessary to pass the remaining |
| 17 | * arguments starting at index = 1. Anyway, driver |
| 18 | * implementation may vary, so, please, check the specific |
| 19 | * implementation of the driver you are using. |
| 20 | */ |
| 21 | |
Tom Rini | d678a59 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 22 | #include <asm/types.h> |
Alexey Romanov | c52cd07 | 2023-09-21 11:13:34 +0300 | [diff] [blame] | 23 | #include <asm/ptrace.h> |
| 24 | |
| 25 | struct udevice; |
| 26 | |
| 27 | /** |
| 28 | * sm_call - generic SMC call to the secure-monitor |
| 29 | * |
| 30 | * @dev: Pointer to UCLASS_SM device |
| 31 | * @cmd_index: Index of the SMC function ID |
| 32 | * @smc_ret: Returned value from secure world |
| 33 | * @args: SMC arguments |
| 34 | * |
| 35 | * @return: 0 on success, a negative value on error |
| 36 | */ |
| 37 | int sm_call(struct udevice *dev, u32 cmd, s32 *ret, struct pt_regs *args); |
| 38 | |
| 39 | /** |
| 40 | * sm_call_read - retrieve data from secure-monitor |
| 41 | * |
| 42 | * @dev: Pointer to UCLASS_MESON_SM device |
| 43 | * @buffer: Buffer to store the retrieved data |
| 44 | * @size: Size of the buffer |
| 45 | * @cmd: Index of the SMC function ID |
| 46 | * @args: SMC arguments |
| 47 | * |
| 48 | * @return: size of read data on success, a negative value on error |
| 49 | */ |
| 50 | int sm_call_read(struct udevice *dev, void *buffer, size_t size, |
| 51 | u32 cmd, struct pt_regs *args); |
| 52 | |
| 53 | /** |
| 54 | * sm_call_write - send data to secure-monitor |
| 55 | * |
| 56 | * @dev: Pointer to UCLASS_SM device |
| 57 | * @buffer: Buffer containing data to send |
| 58 | * @size: Size of the buffer |
| 59 | * @cmd: Index of the SMC function ID |
| 60 | * @args: SMC arguments |
| 61 | * |
| 62 | * @return: size of sent data on success, a negative value on error |
| 63 | */ |
| 64 | int sm_call_write(struct udevice *dev, void *buffer, size_t size, |
| 65 | u32 cmd, struct pt_regs *args); |
| 66 | |
| 67 | #endif /* __SM_H__ */ |