1 /* 2 * Copyright 2019 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 */ 23 24 #ifndef _TA_SECUREDISPLAY_IF_H 25 #define _TA_SECUREDISPLAY_IF_H 26 27 /** Secure Display related enumerations */ 28 /**********************************************************/ 29 30 /** @enum ta_securedisplay_command 31 * Secure Display Command ID 32 */ 33 enum ta_securedisplay_command { 34 /* Query whether TA is responding. It is used only for validation purpose */ 35 TA_SECUREDISPLAY_COMMAND__QUERY_TA = 1, 36 /* Send region of Interest and CRC value to I2C */ 37 TA_SECUREDISPLAY_COMMAND__SEND_ROI_CRC = 2, 38 /* V2 to send multiple regions of Interest and CRC value to I2C */ 39 TA_SECUREDISPLAY_COMMAND__SEND_ROI_CRC_V2 = 3, 40 /* Maximum Command ID */ 41 TA_SECUREDISPLAY_COMMAND__MAX_ID = 0x7FFFFFFF, 42 }; 43 44 /** @enum ta_securedisplay_status 45 * Secure Display status returns in shared buffer status 46 */ 47 enum ta_securedisplay_status { 48 TA_SECUREDISPLAY_STATUS__SUCCESS = 0x00, /* Success */ 49 TA_SECUREDISPLAY_STATUS__GENERIC_FAILURE = 0x01, /* Generic Failure */ 50 TA_SECUREDISPLAY_STATUS__INVALID_PARAMETER = 0x02, /* Invalid Parameter */ 51 TA_SECUREDISPLAY_STATUS__NULL_POINTER = 0x03, /* Null Pointer*/ 52 TA_SECUREDISPLAY_STATUS__I2C_WRITE_ERROR = 0x04, /* Fail to Write to I2C */ 53 TA_SECUREDISPLAY_STATUS__READ_DIO_SCRATCH_ERROR = 0x05, /*Fail Read DIO Scratch Register*/ 54 TA_SECUREDISPLAY_STATUS__READ_CRC_ERROR = 0x06, /* Fail to Read CRC*/ 55 TA_SECUREDISPLAY_STATUS__I2C_INIT_ERROR = 0x07, /* Failed to initialize I2C */ 56 57 TA_SECUREDISPLAY_STATUS__MAX = 0x7FFFFFFF,/* Maximum Value for status*/ 58 }; 59 60 /** @enum ta_securedisplay_phy_ID 61 * Physical ID number to use for reading corresponding DIO Scratch register for ROI 62 */ 63 enum ta_securedisplay_phy_ID { 64 TA_SECUREDISPLAY_PHY0 = 0, 65 TA_SECUREDISPLAY_PHY1 = 1, 66 TA_SECUREDISPLAY_PHY2 = 2, 67 TA_SECUREDISPLAY_PHY3 = 3, 68 TA_SECUREDISPLAY_MAX_PHY = 4, 69 }; 70 71 /** @enum ta_securedisplay_ta_query_cmd_ret 72 * A predefined specific reteurn value which is 0xAB only used to validate 73 * communication to Secure Display TA is functional. 74 * This value is used to validate whether TA is responding successfully 75 */ 76 enum ta_securedisplay_ta_query_cmd_ret { 77 /* This is a value to validate if TA is loaded successfully */ 78 TA_SECUREDISPLAY_QUERY_CMD_RET = 0xAB, 79 }; 80 81 /** @enum ta_securedisplay_buffer_size 82 * I2C Buffer size which contains 8 bytes of ROI (X start, X end, Y start, Y end) 83 * and 6 bytes of CRC( R,G,B) and 1 byte for physical ID 84 */ 85 enum ta_securedisplay_buffer_size { 86 /* 15 bytes = 8 byte (ROI) + 6 byte(CRC) + 1 byte(phy_id) */ 87 TA_SECUREDISPLAY_I2C_BUFFER_SIZE = 15, 88 /* 16 bytes = 8 byte (ROI) + 6 byte(CRC) + 1 byte(phy_id) + 1 byte(roi_idx) */ 89 TA_SECUREDISPLAY_V2_I2C_BUFFER_SIZE = 16, 90 }; 91 92 /** Input/output structures for Secure Display commands */ 93 /**********************************************************/ 94 /** 95 * Input structures 96 */ 97 98 /** @struct ta_securedisplay_send_roi_crc_input 99 * Physical ID to determine which DIO scratch register should be used to get ROI 100 */ 101 struct ta_securedisplay_send_roi_crc_input { 102 /* Physical ID */ 103 uint32_t phy_id; 104 }; 105 106 struct ta_securedisplay_send_roi_crc_v2_input { 107 /* Physical ID */ 108 uint32_t phy_id; 109 /* Region of interest index */ 110 uint8_t roi_idx; 111 }; 112 113 /** @union ta_securedisplay_cmd_input 114 * Input buffer 115 */ 116 union ta_securedisplay_cmd_input { 117 /* send ROI and CRC input buffer format */ 118 struct ta_securedisplay_send_roi_crc_input send_roi_crc; 119 /* send ROI and CRC input buffer format, v2 adds a ROI index */ 120 struct ta_securedisplay_send_roi_crc_v2_input send_roi_crc_v2; 121 uint32_t reserved[4]; 122 }; 123 124 /** 125 * Output structures 126 */ 127 128 /** @struct ta_securedisplay_query_ta_output 129 * Output buffer format for query TA whether TA is responding used only for validation purpose 130 */ 131 struct ta_securedisplay_query_ta_output { 132 /* return value from TA when it is queried for validation purpose only */ 133 uint32_t query_cmd_ret; 134 }; 135 136 /** @struct ta_securedisplay_send_roi_crc_output 137 * Output buffer format for send ROI CRC command which will pass I2c buffer created inside TA 138 * and used to write to I2C used only for validation purpose 139 */ 140 struct ta_securedisplay_send_roi_crc_output { 141 uint8_t i2c_buf[TA_SECUREDISPLAY_I2C_BUFFER_SIZE]; /* I2C buffer */ 142 uint8_t reserved; 143 }; 144 145 struct ta_securedisplay_send_roi_crc_v2_output { 146 uint8_t i2c_buf[TA_SECUREDISPLAY_V2_I2C_BUFFER_SIZE]; /* I2C buffer */ 147 }; 148 149 /** @union ta_securedisplay_cmd_output 150 * Output buffer 151 */ 152 union ta_securedisplay_cmd_output { 153 /* Query TA output buffer format used only for validation purpose*/ 154 struct ta_securedisplay_query_ta_output query_ta; 155 /* Send ROI CRC output buffer format used only for validation purpose */ 156 struct ta_securedisplay_send_roi_crc_output send_roi_crc; 157 /* Send ROI CRC output buffer format used only for validation purpose */ 158 struct ta_securedisplay_send_roi_crc_v2_output send_roi_crc_v2; 159 uint32_t reserved[4]; 160 }; 161 162 /** @struct ta_securedisplay_cmd 163 * Secure display command which is shared buffer memory 164 */ 165 struct ta_securedisplay_cmd { 166 uint32_t cmd_id; /**< +0 Bytes Command ID */ 167 enum ta_securedisplay_status status; /**< +4 Bytes Status code returned by the secure display TA */ 168 uint32_t reserved[2]; /**< +8 Bytes Reserved */ 169 union ta_securedisplay_cmd_input securedisplay_in_message; /**< +16 Bytes Command input buffer */ 170 union ta_securedisplay_cmd_output securedisplay_out_message; /**< +32 Bytes Command output buffer */ 171 /**@note Total 48 Bytes */ 172 }; 173 174 #endif //_TA_SECUREDISPLAY_IF_H 175 176