![]() |
|
|||
0001 /* SPDX-License-Identifier: MIT */ 0002 /* 0003 * Copyright (C) 2019,2021 Advanced Micro Devices, Inc. 0004 * 0005 * Author: Rijo Thomas <Rijo-john.Thomas@amd.com> 0006 * Author: Devaraj Rangasamy <Devaraj.Rangasamy@amd.com> 0007 * 0008 */ 0009 0010 /* This file describes the TEE communication interface between host and AMD 0011 * Secure Processor 0012 */ 0013 0014 #ifndef __TEE_DEV_H__ 0015 #define __TEE_DEV_H__ 0016 0017 #include <linux/device.h> 0018 #include <linux/mutex.h> 0019 0020 #define TEE_DEFAULT_TIMEOUT 10 0021 #define MAX_BUFFER_SIZE 988 0022 0023 /** 0024 * enum tee_ring_cmd_id - TEE interface commands for ring buffer configuration 0025 * @TEE_RING_INIT_CMD: Initialize ring buffer 0026 * @TEE_RING_DESTROY_CMD: Destroy ring buffer 0027 * @TEE_RING_MAX_CMD: Maximum command id 0028 */ 0029 enum tee_ring_cmd_id { 0030 TEE_RING_INIT_CMD = 0x00010000, 0031 TEE_RING_DESTROY_CMD = 0x00020000, 0032 TEE_RING_MAX_CMD = 0x000F0000, 0033 }; 0034 0035 /** 0036 * struct tee_init_ring_cmd - Command to init TEE ring buffer 0037 * @low_addr: bits [31:0] of the physical address of ring buffer 0038 * @hi_addr: bits [63:32] of the physical address of ring buffer 0039 * @size: size of ring buffer in bytes 0040 */ 0041 struct tee_init_ring_cmd { 0042 u32 low_addr; 0043 u32 hi_addr; 0044 u32 size; 0045 }; 0046 0047 #define MAX_RING_BUFFER_ENTRIES 32 0048 0049 /** 0050 * struct ring_buf_manager - Helper structure to manage ring buffer. 0051 * @ring_start: starting address of ring buffer 0052 * @ring_size: size of ring buffer in bytes 0053 * @ring_pa: physical address of ring buffer 0054 * @wptr: index to the last written entry in ring buffer 0055 */ 0056 struct ring_buf_manager { 0057 struct mutex mutex; /* synchronizes access to ring buffer */ 0058 void *ring_start; 0059 u32 ring_size; 0060 phys_addr_t ring_pa; 0061 u32 wptr; 0062 }; 0063 0064 struct psp_tee_device { 0065 struct device *dev; 0066 struct psp_device *psp; 0067 void __iomem *io_regs; 0068 struct tee_vdata *vdata; 0069 struct ring_buf_manager rb_mgr; 0070 }; 0071 0072 /** 0073 * enum tee_cmd_state - TEE command states for the ring buffer interface 0074 * @TEE_CMD_STATE_INIT: initial state of command when sent from host 0075 * @TEE_CMD_STATE_PROCESS: command being processed by TEE environment 0076 * @TEE_CMD_STATE_COMPLETED: command processing completed 0077 */ 0078 enum tee_cmd_state { 0079 TEE_CMD_STATE_INIT, 0080 TEE_CMD_STATE_PROCESS, 0081 TEE_CMD_STATE_COMPLETED, 0082 }; 0083 0084 /** 0085 * enum cmd_resp_state - TEE command's response status maintained by driver 0086 * @CMD_RESPONSE_INVALID: initial state when no command is written to ring 0087 * @CMD_WAITING_FOR_RESPONSE: driver waiting for response from TEE 0088 * @CMD_RESPONSE_TIMEDOUT: failed to get response from TEE 0089 * @CMD_RESPONSE_COPIED: driver has copied response from TEE 0090 */ 0091 enum cmd_resp_state { 0092 CMD_RESPONSE_INVALID, 0093 CMD_WAITING_FOR_RESPONSE, 0094 CMD_RESPONSE_TIMEDOUT, 0095 CMD_RESPONSE_COPIED, 0096 }; 0097 0098 /** 0099 * struct tee_ring_cmd - Structure of the command buffer in TEE ring 0100 * @cmd_id: refers to &enum tee_cmd_id. Command id for the ring buffer 0101 * interface 0102 * @cmd_state: refers to &enum tee_cmd_state 0103 * @status: status of TEE command execution 0104 * @res0: reserved region 0105 * @pdata: private data (currently unused) 0106 * @res1: reserved region 0107 * @buf: TEE command specific buffer 0108 * @flag: refers to &enum cmd_resp_state 0109 */ 0110 struct tee_ring_cmd { 0111 u32 cmd_id; 0112 u32 cmd_state; 0113 u32 status; 0114 u32 res0[1]; 0115 u64 pdata; 0116 u32 res1[2]; 0117 u8 buf[MAX_BUFFER_SIZE]; 0118 u32 flag; 0119 0120 /* Total size: 1024 bytes */ 0121 } __packed; 0122 0123 int tee_dev_init(struct psp_device *psp); 0124 void tee_dev_destroy(struct psp_device *psp); 0125 0126 #endif /* __TEE_DEV_H__ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |