xref: /linux/drivers/gpu/drm/amd/amdgpu/ta_secureDisplay_if.h (revision 172cdcaefea5c297fdb3d20b7d5aff60ae4fbce6)
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 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 	/* Maximum Command ID */
39 	TA_SECUREDISPLAY_COMMAND__MAX_ID                = 0x7FFFFFFF,
40 };
41 
42 /** @enum ta_securedisplay_status
43  *    Secure Display status returns in shared buffer status
44  */
45 enum ta_securedisplay_status {
46 	TA_SECUREDISPLAY_STATUS__SUCCESS                 = 0x00,         /* Success */
47 	TA_SECUREDISPLAY_STATUS__GENERIC_FAILURE         = 0x01,         /* Generic Failure */
48 	TA_SECUREDISPLAY_STATUS__INVALID_PARAMETER       = 0x02,         /* Invalid Parameter */
49 	TA_SECUREDISPLAY_STATUS__NULL_POINTER            = 0x03,         /* Null Pointer*/
50 	TA_SECUREDISPLAY_STATUS__I2C_WRITE_ERROR         = 0x04,         /* Fail to Write to I2C */
51 	TA_SECUREDISPLAY_STATUS__READ_DIO_SCRATCH_ERROR  = 0x05, /*Fail Read DIO Scratch Register*/
52 	TA_SECUREDISPLAY_STATUS__READ_CRC_ERROR          = 0x06,         /* Fail to Read CRC*/
53 	TA_SECUREDISPLAY_STATUS__I2C_INIT_ERROR          = 0x07,     /* Failed to initialize I2C */
54 
55 	TA_SECUREDISPLAY_STATUS__MAX                     = 0x7FFFFFFF,/* Maximum Value for status*/
56 };
57 
58 /** @enum ta_securedisplay_max_phy
59  *    Physical ID number to use for reading corresponding DIO Scratch register for ROI
60  */
61 enum  ta_securedisplay_max_phy {
62 	TA_SECUREDISPLAY_PHY0                           = 0,
63 	TA_SECUREDISPLAY_PHY1                           = 1,
64 	TA_SECUREDISPLAY_PHY2                           = 2,
65 	TA_SECUREDISPLAY_PHY3                           = 3,
66 	TA_SECUREDISPLAY_MAX_PHY                        = 4,
67 };
68 
69 /** @enum ta_securedisplay_ta_query_cmd_ret
70  *    A predefined specific reteurn value which is 0xAB only used to validate
71  *    communication to Secure Display TA is functional.
72  *    This value is used to validate whether TA is responding successfully
73  */
74 enum ta_securedisplay_ta_query_cmd_ret {
75 	/* This is a value to validate if TA is loaded successfully */
76 	TA_SECUREDISPLAY_QUERY_CMD_RET                 = 0xAB,
77 };
78 
79 /** @enum ta_securedisplay_buffer_size
80  *    I2C Buffer size which contains 8 bytes of ROI  (X start, X end, Y start, Y end)
81  *    and 6 bytes of CRC( R,G,B) and 1  byte for physical ID
82  */
83 enum ta_securedisplay_buffer_size {
84 	/* 15 bytes = 8 byte (ROI) + 6 byte(CRC) + 1 byte(phy_id) */
85 	TA_SECUREDISPLAY_I2C_BUFFER_SIZE                = 15,
86 };
87 
88 /** Input/output structures for Secure Display commands */
89 /**********************************************************/
90 /**
91  * Input structures
92  */
93 
94 /** @struct ta_securedisplay_send_roi_crc_input
95  *    Physical ID to determine which DIO scratch register should be used to get ROI
96  */
97 struct ta_securedisplay_send_roi_crc_input {
98 	uint32_t  phy_id;  /* Physical ID */
99 };
100 
101 /** @union ta_securedisplay_cmd_input
102  *    Input buffer
103  */
104 union ta_securedisplay_cmd_input {
105 	/* send ROI and CRC input buffer format */
106 	struct ta_securedisplay_send_roi_crc_input        send_roi_crc;
107 	uint32_t                                          reserved[4];
108 };
109 
110 /**
111  * Output structures
112  */
113 
114 /** @struct ta_securedisplay_query_ta_output
115  *  Output buffer format for query TA whether TA is responding used only for validation purpose
116  */
117 struct ta_securedisplay_query_ta_output {
118 	/* return value from TA when it is queried for validation purpose only */
119 	uint32_t  query_cmd_ret;
120 };
121 
122 /** @struct ta_securedisplay_send_roi_crc_output
123  *  Output buffer format for send ROI CRC command which will pass I2c buffer created inside TA
124  *  and used to write to I2C used only for validation purpose
125  */
126 struct ta_securedisplay_send_roi_crc_output {
127 	uint8_t  i2c_buf[TA_SECUREDISPLAY_I2C_BUFFER_SIZE];  /* I2C buffer */
128 	uint8_t  reserved;
129 };
130 
131 /** @union ta_securedisplay_cmd_output
132  *    Output buffer
133  */
134 union ta_securedisplay_cmd_output {
135 	/* Query TA output buffer format used only for validation purpose*/
136 	struct ta_securedisplay_query_ta_output            query_ta;
137 	/* Send ROI CRC output buffer format used only for validation purpose */
138 	struct ta_securedisplay_send_roi_crc_output        send_roi_crc;
139 	uint32_t                                           reserved[4];
140 };
141 
142 /** @struct securedisplay_cmd
143  *    Secure Display Command which is shared buffer memory
144  */
145 struct securedisplay_cmd {
146 	uint32_t                             cmd_id;                    /* +0  Bytes Command ID */
147 	enum ta_securedisplay_status         status;     /* +4  Bytes Status of Secure Display TA */
148 	uint32_t                             reserved[2];               /* +8  Bytes Reserved */
149 	union ta_securedisplay_cmd_input     securedisplay_in_message;  /* +16 Bytes Input Buffer */
150 	union ta_securedisplay_cmd_output    securedisplay_out_message;/* +32 Bytes Output Buffer */
151 	/**@note Total 48 Bytes */
152 };
153 
154 #endif   //_TA_SECUREDISPLAY_IF_H
155 
156