1 /* SPDX-License-Identifier: MIT */
3 * Copyright 2019 Advanced Micro Devices, Inc.
5 * Author: Rijo Thomas <Rijo-john.Thomas@amd.com>
6 * Author: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com>
10 /* This file describes the TEE communication interface between host and AMD
17 #include <linux/device.h>
18 #include <linux/mutex.h>
20 #define TEE_DEFAULT_TIMEOUT 10
21 #define MAX_BUFFER_SIZE 992
24 * enum tee_ring_cmd_id - TEE interface commands for ring buffer configuration
25 * @TEE_RING_INIT_CMD: Initialize ring buffer
26 * @TEE_RING_DESTROY_CMD: Destroy ring buffer
27 * @TEE_RING_MAX_CMD: Maximum command id
29 enum tee_ring_cmd_id
{
30 TEE_RING_INIT_CMD
= 0x00010000,
31 TEE_RING_DESTROY_CMD
= 0x00020000,
32 TEE_RING_MAX_CMD
= 0x000F0000,
36 * struct tee_init_ring_cmd - Command to init TEE ring buffer
37 * @low_addr: bits [31:0] of the physical address of ring buffer
38 * @hi_addr: bits [63:32] of the physical address of ring buffer
39 * @size: size of ring buffer in bytes
41 struct tee_init_ring_cmd
{
47 #define MAX_RING_BUFFER_ENTRIES 32
50 * struct ring_buf_manager - Helper structure to manage ring buffer.
51 * @ring_start: starting address of ring buffer
52 * @ring_size: size of ring buffer in bytes
53 * @ring_pa: physical address of ring buffer
54 * @wptr: index to the last written entry in ring buffer
56 struct ring_buf_manager
{
57 struct mutex mutex
; /* synchronizes access to ring buffer */
64 struct psp_tee_device
{
66 struct psp_device
*psp
;
67 void __iomem
*io_regs
;
68 struct tee_vdata
*vdata
;
69 struct ring_buf_manager rb_mgr
;
73 * enum tee_cmd_state - TEE command states for the ring buffer interface
74 * @TEE_CMD_STATE_INIT: initial state of command when sent from host
75 * @TEE_CMD_STATE_PROCESS: command being processed by TEE environment
76 * @TEE_CMD_STATE_COMPLETED: command processing completed
80 TEE_CMD_STATE_PROCESS
,
81 TEE_CMD_STATE_COMPLETED
,
85 * struct tee_ring_cmd - Structure of the command buffer in TEE ring
86 * @cmd_id: refers to &enum tee_cmd_id. Command id for the ring buffer
88 * @cmd_state: refers to &enum tee_cmd_state
89 * @status: status of TEE command execution
90 * @res0: reserved region
91 * @pdata: private data (currently unused)
92 * @res1: reserved region
93 * @buf: TEE command specific buffer
102 u8 buf
[MAX_BUFFER_SIZE
];
104 /* Total size: 1024 bytes */
107 int tee_dev_init(struct psp_device
*psp
);
108 void tee_dev_destroy(struct psp_device
*psp
);
110 #endif /* __TEE_DEV_H__ */