xref: /linux/include/soc/tegra/bpmp-abi.h (revision b204b92be30621a6ca99097155a8997e323c66e7)
19952f691SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2983de5f9SThierry Reding /*
3*b204b92bSPeter De Schrijver  * Copyright (c) 2014-2022, NVIDIA CORPORATION.  All rights reserved.
4983de5f9SThierry Reding  */
5983de5f9SThierry Reding 
64e871899SJon Hunter #ifndef ABI_BPMP_ABI_H
74e871899SJon Hunter #define ABI_BPMP_ABI_H
8983de5f9SThierry Reding 
94e871899SJon Hunter #if defined(LK) || defined(BPMP_ABI_HAVE_STDC)
104e871899SJon Hunter #include <stddef.h>
11983de5f9SThierry Reding #include <stdint.h>
12983de5f9SThierry Reding #endif
13983de5f9SThierry Reding 
144e871899SJon Hunter #ifndef BPMP_ABI_PACKED
154e871899SJon Hunter #ifdef __ABI_PACKED
164e871899SJon Hunter #define BPMP_ABI_PACKED __ABI_PACKED
174e871899SJon Hunter #else
184e871899SJon Hunter #define BPMP_ABI_PACKED __attribute__((packed))
194e871899SJon Hunter #endif
20983de5f9SThierry Reding #endif
21983de5f9SThierry Reding 
22983de5f9SThierry Reding #ifdef NO_GCC_EXTENSIONS
234e871899SJon Hunter #define BPMP_ABI_EMPTY char empty;
244e871899SJon Hunter #define BPMP_ABI_EMPTY_ARRAY 1
25983de5f9SThierry Reding #else
264e871899SJon Hunter #define BPMP_ABI_EMPTY
274e871899SJon Hunter #define BPMP_ABI_EMPTY_ARRAY 0
28983de5f9SThierry Reding #endif
29983de5f9SThierry Reding 
304e871899SJon Hunter #ifndef BPMP_UNION_ANON
314e871899SJon Hunter #ifdef __UNION_ANON
324e871899SJon Hunter #define BPMP_UNION_ANON __UNION_ANON
334e871899SJon Hunter #else
344e871899SJon Hunter #define BPMP_UNION_ANON
35983de5f9SThierry Reding #endif
364e871899SJon Hunter #endif
374e871899SJon Hunter 
38983de5f9SThierry Reding /**
39983de5f9SThierry Reding  * @file
40983de5f9SThierry Reding  */
41983de5f9SThierry Reding 
42983de5f9SThierry Reding /**
43983de5f9SThierry Reding  * @defgroup MRQ MRQ Messages
44983de5f9SThierry Reding  * @brief Messages sent to/from BPMP via IPC
45983de5f9SThierry Reding  * @{
46983de5f9SThierry Reding  *   @defgroup MRQ_Format Message Format
47983de5f9SThierry Reding  *   @defgroup MRQ_Codes Message Request (MRQ) Codes
48983de5f9SThierry Reding  *   @defgroup MRQ_Payloads Message Payloads
49983de5f9SThierry Reding  *   @defgroup Error_Codes Error Codes
50983de5f9SThierry Reding  * @}
51983de5f9SThierry Reding  */
52983de5f9SThierry Reding 
53983de5f9SThierry Reding /**
544bef358cSTimo Alho  * @addtogroup MRQ_Format
55983de5f9SThierry Reding  * @{
56983de5f9SThierry Reding  * The CPU requests the BPMP to perform a particular service by
57983de5f9SThierry Reding  * sending it an IVC frame containing a single MRQ message. An MRQ
58983de5f9SThierry Reding  * message consists of a @ref mrq_request followed by a payload whose
59983de5f9SThierry Reding  * format depends on mrq_request::mrq.
60983de5f9SThierry Reding  *
61983de5f9SThierry Reding  * The BPMP processes the data and replies with an IVC frame (on the
62983de5f9SThierry Reding  * same IVC channel) containing and MRQ response. An MRQ response
63983de5f9SThierry Reding  * consists of a @ref mrq_response followed by a payload whose format
64983de5f9SThierry Reding  * depends on the associated mrq_request::mrq.
65983de5f9SThierry Reding  *
66983de5f9SThierry Reding  * A well-defined subset of the MRQ messages that the CPU sends to the
67983de5f9SThierry Reding  * BPMP can lead to BPMP eventually sending an MRQ message to the
68983de5f9SThierry Reding  * CPU. For example, when the CPU uses an #MRQ_THERMAL message to set
69983de5f9SThierry Reding  * a thermal trip point, the BPMP may eventually send a single
70983de5f9SThierry Reding  * #MRQ_THERMAL message of its own to the CPU indicating that the trip
71983de5f9SThierry Reding  * point has been crossed.
72983de5f9SThierry Reding  * @}
73983de5f9SThierry Reding  */
74983de5f9SThierry Reding 
75983de5f9SThierry Reding /**
76983de5f9SThierry Reding  * @ingroup MRQ_Format
77*b204b92bSPeter De Schrijver  * Request an answer from the peer.
78*b204b92bSPeter De Schrijver  * This should be set in mrq_request::flags for all requests targetted
79*b204b92bSPeter De Schrijver  * at BPMP. For requests originating in BPMP, this flag is optional except
80*b204b92bSPeter De Schrijver  * for messages targeting MCE, for which the field must be set.
81*b204b92bSPeter De Schrijver  * When this flag is not set, the remote peer must not send a response
82*b204b92bSPeter De Schrijver  * back.
83*b204b92bSPeter De Schrijver  */
84*b204b92bSPeter De Schrijver #define BPMP_MAIL_DO_ACK	(1U << 0U)
85*b204b92bSPeter De Schrijver 
86*b204b92bSPeter De Schrijver /**
87*b204b92bSPeter De Schrijver  * @ingroup MRQ_Format
88*b204b92bSPeter De Schrijver  * Ring the sender's doorbell when responding. This should be set unless
89*b204b92bSPeter De Schrijver  * the sender wants to poll the underlying communications layer directly.
90*b204b92bSPeter De Schrijver  *
91*b204b92bSPeter De Schrijver  * An optional direction that can be specified in mrq_request::flags.
92*b204b92bSPeter De Schrijver  */
93*b204b92bSPeter De Schrijver #define BPMP_MAIL_RING_DB	(1U << 1U)
94*b204b92bSPeter De Schrijver 
95*b204b92bSPeter De Schrijver /**
96*b204b92bSPeter De Schrijver  * @ingroup MRQ_Format
97*b204b92bSPeter De Schrijver  * CRC present
98*b204b92bSPeter De Schrijver  */
99*b204b92bSPeter De Schrijver #define BPMP_MAIL_CRC_PRESENT	(1U << 2U)
100*b204b92bSPeter De Schrijver 
101*b204b92bSPeter De Schrijver /**
102*b204b92bSPeter De Schrijver  * @ingroup MRQ_Format
1034bef358cSTimo Alho  * @brief Header for an MRQ message
104983de5f9SThierry Reding  *
105983de5f9SThierry Reding  * Provides the MRQ number for the MRQ message: #mrq. The remainder of
106983de5f9SThierry Reding  * the MRQ message is a payload (immediately following the
107983de5f9SThierry Reding  * mrq_request) whose format depends on mrq.
108983de5f9SThierry Reding  */
109983de5f9SThierry Reding struct mrq_request {
110983de5f9SThierry Reding 	/** @brief MRQ number of the request */
111983de5f9SThierry Reding 	uint32_t mrq;
1124e871899SJon Hunter 
11352b8b803SThierry Reding 	/**
114*b204b92bSPeter De Schrijver 	 * @brief 32bit word containing a number of fields as follows:
11552b8b803SThierry Reding 	 *
116*b204b92bSPeter De Schrijver 	 * 	struct {
117*b204b92bSPeter De Schrijver 	 * 		uint8_t options:4;
118*b204b92bSPeter De Schrijver 	 * 		uint8_t xid:4;
119*b204b92bSPeter De Schrijver 	 * 		uint8_t payload_length;
120*b204b92bSPeter De Schrijver 	 * 		uint16_t crc16;
121*b204b92bSPeter De Schrijver 	 * 	};
122*b204b92bSPeter De Schrijver 	 *
123*b204b92bSPeter De Schrijver 	 * **options** directions to the receiver and indicates CRC presence.
124*b204b92bSPeter De Schrijver 	 *
125*b204b92bSPeter De Schrijver 	 * #BPMP_MAIL_DO_ACK and  #BPMP_MAIL_RING_DB see documentation of respective options.
126*b204b92bSPeter De Schrijver 	 * #BPMP_MAIL_CRC_PRESENT is supported on T234 and later platforms. It indicates the
127*b204b92bSPeter De Schrijver 	 * crc16, xid and length fields are present when set.
128*b204b92bSPeter De Schrijver 	 * Some platform configurations, especially when targeted to applications requiring
129*b204b92bSPeter De Schrijver 	 * functional safety, mandate this option being set or otherwise will respond with
130*b204b92bSPeter De Schrijver 	 * -BPMP_EBADMSG and ignore the request.
131*b204b92bSPeter De Schrijver 	 *
132*b204b92bSPeter De Schrijver 	 * **xid** is a transaction ID.
133*b204b92bSPeter De Schrijver 	 *
134*b204b92bSPeter De Schrijver 	 * Only used when #BPMP_MAIL_CRC_PRESENT is set.
135*b204b92bSPeter De Schrijver 	 *
136*b204b92bSPeter De Schrijver 	 * **payload_length** of the message expressed in bytes without the size of this header.
137*b204b92bSPeter De Schrijver 	 * See table below for minimum accepted payload lengths for each MRQ.
138*b204b92bSPeter De Schrijver 	 * Note: For DMCE communication, this field expresses the length as a multiple of 4 bytes
139*b204b92bSPeter De Schrijver 	 * rather than bytes.
140*b204b92bSPeter De Schrijver 	 *
141*b204b92bSPeter De Schrijver 	 * Only used when #BPMP_MAIL_CRC_PRESENT is set.
142*b204b92bSPeter De Schrijver 	 *
143*b204b92bSPeter De Schrijver 	 * | MRQ                  | CMD                                  | minimum payload length
144*b204b92bSPeter De Schrijver 	 * | -------------------- | ------------------------------------ | ------------------------------------------ |
145*b204b92bSPeter De Schrijver 	 * | MRQ_PING             |                                      | 4                                          |
146*b204b92bSPeter De Schrijver 	 * | MRQ_THREADED_PING    |                                      | 4                                          |
147*b204b92bSPeter De Schrijver 	 * | MRQ_RESET            | any                                  | 8                                          |
148*b204b92bSPeter De Schrijver 	 * | MRQ_I2C              |                                      | 12 + cmd_i2c_xfer_request.data_size        |
149*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_GET_RATE                     | 4                                          |
150*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_SET_RATE                     | 16                                         |
151*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_ROUND_RATE                   | 16                                         |
152*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_GET_PARENT                   | 4                                          |
153*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_SET_PARENT                   | 8                                          |
154*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_ENABLE                       | 4                                          |
155*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_DISABLE                      | 4                                          |
156*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_IS_ENABLED                   | 4                                          |
157*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_GET_ALL_INFO                 | 4                                          |
158*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_GET_MAX_CLK_ID               | 4                                          |
159*b204b92bSPeter De Schrijver 	 * | MRQ_CLK              | CMD_CLK_GET_FMAX_AT_VMIN             | 4                                          |
160*b204b92bSPeter De Schrijver 	 * | MRQ_QUERY_ABI        |                                      | 4                                          |
161*b204b92bSPeter De Schrijver 	 * | MRQ_PG               | CMD_PG_QUERY_ABI                     | 12                                         |
162*b204b92bSPeter De Schrijver 	 * | MRQ_PG               | CMD_PG_SET_STATE                     | 12                                         |
163*b204b92bSPeter De Schrijver 	 * | MRQ_PG               | CMD_PG_GET_STATE                     | 8                                          |
164*b204b92bSPeter De Schrijver 	 * | MRQ_PG               | CMD_PG_GET_NAME                      | 8                                          |
165*b204b92bSPeter De Schrijver 	 * | MRQ_PG               | CMD_PG_GET_MAX_ID                    | 8                                          |
166*b204b92bSPeter De Schrijver 	 * | MRQ_THERMAL          | CMD_THERMAL_QUERY_ABI                | 8                                          |
167*b204b92bSPeter De Schrijver 	 * | MRQ_THERMAL          | CMD_THERMAL_GET_TEMP                 | 8                                          |
168*b204b92bSPeter De Schrijver 	 * | MRQ_THERMAL          | CMD_THERMAL_SET_TRIP                 | 20                                         |
169*b204b92bSPeter De Schrijver 	 * | MRQ_THERMAL          | CMD_THERMAL_GET_NUM_ZONES            | 4                                          |
170*b204b92bSPeter De Schrijver 	 * | MRQ_THERMAL          | CMD_THERMAL_GET_THERMTRIP            | 8                                          |
171*b204b92bSPeter De Schrijver 	 * | MRQ_CPU_VHINT        |                                      | 8                                          |
172*b204b92bSPeter De Schrijver 	 * | MRQ_ABI_RATCHET      |                                      | 2                                          |
173*b204b92bSPeter De Schrijver 	 * | MRQ_EMC_DVFS_LATENCY |                                      | 8                                          |
174*b204b92bSPeter De Schrijver 	 * | MRQ_EMC_DVFS_EMCHUB  |                                      | 8                                          |
175*b204b92bSPeter De Schrijver 	 * | MRQ_EMC_DISP_RFL     |                                      | 4                                          |
176*b204b92bSPeter De Schrijver 	 * | MRQ_BWMGR            | CMD_BWMGR_QUERY_ABI                  | 8                                          |
177*b204b92bSPeter De Schrijver 	 * | MRQ_BWMGR            | CMD_BWMGR_CALC_RATE                  | 8 + 8 * bwmgr_rate_req.num_iso_clients     |
178*b204b92bSPeter De Schrijver 	 * | MRQ_ISO_CLIENT       | CMD_ISO_CLIENT_QUERY_ABI             | 8                                          |
179*b204b92bSPeter De Schrijver 	 * | MRQ_ISO_CLIENT       | CMD_ISO_CLIENT_CALCULATE_LA          | 16                                         |
180*b204b92bSPeter De Schrijver 	 * | MRQ_ISO_CLIENT       | CMD_ISO_CLIENT_SET_LA                | 16                                         |
181*b204b92bSPeter De Schrijver 	 * | MRQ_ISO_CLIENT       | CMD_ISO_CLIENT_GET_MAX_BW            | 8                                          |
182*b204b92bSPeter De Schrijver 	 * | MRQ_CPU_NDIV_LIMITS  |                                      | 4                                          |
183*b204b92bSPeter De Schrijver 	 * | MRQ_CPU_AUTO_CC3     |                                      | 4                                          |
184*b204b92bSPeter De Schrijver 	 * | MRQ_RINGBUF_CONSOLE  | CMD_RINGBUF_CONSOLE_QUERY_ABI        | 8                                          |
185*b204b92bSPeter De Schrijver 	 * | MRQ_RINGBUF_CONSOLE  | CMD_RINGBUF_CONSOLE_READ             | 5                                          |
186*b204b92bSPeter De Schrijver 	 * | MRQ_RINGBUF_CONSOLE  | CMD_RINGBUF_CONSOLE_WRITE            | 5 + cmd_ringbuf_console_write_req.len      |
187*b204b92bSPeter De Schrijver 	 * | MRQ_RINGBUF_CONSOLE  | CMD_RINGBUF_CONSOLE_GET_FIFO         | 4                                          |
188*b204b92bSPeter De Schrijver 	 * | MRQ_STRAP            | STRAP_SET                            | 12                                         |
189*b204b92bSPeter De Schrijver 	 * | MRQ_UPHY             | CMD_UPHY_PCIE_LANE_MARGIN_CONTROL    | 24                                         |
190*b204b92bSPeter De Schrijver 	 * | MRQ_UPHY             | CMD_UPHY_PCIE_LANE_MARGIN_STATUS     | 4                                          |
191*b204b92bSPeter De Schrijver 	 * | MRQ_UPHY             | CMD_UPHY_PCIE_EP_CONTROLLER_PLL_INIT | 5                                          |
192*b204b92bSPeter De Schrijver 	 * | MRQ_UPHY             | CMD_UPHY_PCIE_CONTROLLER_STATE       | 6                                          |
193*b204b92bSPeter De Schrijver 	 * | MRQ_UPHY             | CMD_UPHY_PCIE_EP_CONTROLLER_PLL_OFF  | 5                                          |
194*b204b92bSPeter De Schrijver 	 * | MRQ_FMON             | CMD_FMON_GEAR_CLAMP                  | 16                                         |
195*b204b92bSPeter De Schrijver 	 * | MRQ_FMON             | CMD_FMON_GEAR_FREE                   | 4                                          |
196*b204b92bSPeter De Schrijver 	 * | MRQ_FMON             | CMD_FMON_GEAR_GET                    | 4                                          |
197*b204b92bSPeter De Schrijver 	 * | MRQ_FMON             | CMD_FMON_FAULT_STS_GET               | 8                                          |
198*b204b92bSPeter De Schrijver 	 * | MRQ_EC               | CMD_EC_STATUS_EX_GET                 | 12                                         |
199*b204b92bSPeter De Schrijver 	 * | MRQ_QUERY_FW_TAG     |                                      | 0                                          |
200*b204b92bSPeter De Schrijver 	 * | MRQ_DEBUG            | CMD_DEBUG_OPEN_RO                    | 4 + length of cmd_debug_fopen_request.name |
201*b204b92bSPeter De Schrijver 	 * | MRQ_DEBUG            | CMD_DEBUG_OPEN_WO                    | 4 + length of cmd_debug_fopen_request.name |
202*b204b92bSPeter De Schrijver 	 * | MRQ_DEBUG            | CMD_DEBUG_READ                       | 8                                          |
203*b204b92bSPeter De Schrijver 	 * | MRQ_DEBUG            | CMD_DEBUG_WRITE                      | 12 + cmd_debug_fwrite_request.datalen      |
204*b204b92bSPeter De Schrijver 	 * | MRQ_DEBUG            | CMD_DEBUG_CLOSE                      | 8                                          |
205*b204b92bSPeter De Schrijver 	 * | MRQ_TELEMETRY        |                                      | 8                                          |
206*b204b92bSPeter De Schrijver 	 * | MRQ_PWR_LIMIT        | CMD_PWR_LIMIT_QUERY_ABI              | 8                                          |
207*b204b92bSPeter De Schrijver 	 * | MRQ_PWR_LIMIT        | CMD_PWR_LIMIT_SET                    | 20                                         |
208*b204b92bSPeter De Schrijver 	 * | MRQ_PWR_LIMIT        | CMD_PWR_LIMIT_GET                    | 16                                         |
209*b204b92bSPeter De Schrijver 	 * | MRQ_PWR_LIMIT        | CMD_PWR_LIMIT_CURR_CAP               | 8                                          |
210*b204b92bSPeter De Schrijver 	 * | MRQ_GEARS            |                                      | 0                                          |
211*b204b92bSPeter De Schrijver 	 * | MRQ_BWMGR_INT        | CMD_BWMGR_INT_QUERY_ABI              | 8                                          |
212*b204b92bSPeter De Schrijver 	 * | MRQ_BWMGR_INT        | CMD_BWMGR_INT_CALC_AND_SET           | 16                                         |
213*b204b92bSPeter De Schrijver 	 * | MRQ_BWMGR_INT        | CMD_BWMGR_INT_CAP_SET                | 8                                          |
214*b204b92bSPeter De Schrijver 	 * | MRQ_OC_STATUS        |                                      | 0                                          |
215*b204b92bSPeter De Schrijver 	 *
216*b204b92bSPeter De Schrijver 	 * **crc16**
217*b204b92bSPeter De Schrijver 	 *
218*b204b92bSPeter De Schrijver 	 * CRC16 using polynomial x^16 + x^14 + x^12 + x^11 + x^8 + x^5 + x^4 + x^2 + 1
219*b204b92bSPeter De Schrijver 	 * and initialization value 0x4657. The CRC is calculated over all bytes of the message
220*b204b92bSPeter De Schrijver 	 * including this header. However the crc16 field is considered to be set to 0 when
221*b204b92bSPeter De Schrijver 	 * calculating the CRC. Only used when #BPMP_MAIL_CRC_PRESENT is set. If
222*b204b92bSPeter De Schrijver 	 * #BPMP_MAIL_CRC_PRESENT is set and this field does not match the CRC as
223*b204b92bSPeter De Schrijver 	 * calculated by BPMP, -BPMP_EBADMSG will be returned and the request will
224*b204b92bSPeter De Schrijver 	 * be ignored. See code snippet below on how to calculate the CRC.
225*b204b92bSPeter De Schrijver 	 *
226*b204b92bSPeter De Schrijver 	 * @code
227*b204b92bSPeter De Schrijver 	 *	uint16_t calc_crc_digest(uint16_t crc, uint8_t *data, size_t size)
228*b204b92bSPeter De Schrijver 	 *	{
229*b204b92bSPeter De Schrijver 	 *		for (size_t i = 0; i < size; i++) {
230*b204b92bSPeter De Schrijver 	 *			crc ^= data[i] << 8;
231*b204b92bSPeter De Schrijver 	 *			for (size_t j = 0; j < 8; j++) {
232*b204b92bSPeter De Schrijver 	 *				if ((crc & 0x8000) == 0x8000) {
233*b204b92bSPeter De Schrijver 	 *					crc = (crc << 1) ^ 0xAC9A;
234*b204b92bSPeter De Schrijver 	 *				} else {
235*b204b92bSPeter De Schrijver 	 *					crc = (crc << 1);
236*b204b92bSPeter De Schrijver 	 *				}
237*b204b92bSPeter De Schrijver 	 *			}
238*b204b92bSPeter De Schrijver 	 *		}
239*b204b92bSPeter De Schrijver 	 *		return crc;
240*b204b92bSPeter De Schrijver 	 *	}
241*b204b92bSPeter De Schrijver 	 *
242*b204b92bSPeter De Schrijver 	 *	uint16_t calc_crc(uint8_t *data, size_t size)
243*b204b92bSPeter De Schrijver 	 *	{
244*b204b92bSPeter De Schrijver 	 *		return calc_crc_digest(0x4657, data, size);
245*b204b92bSPeter De Schrijver 	 *	}
246*b204b92bSPeter De Schrijver 	 * @endcode
24752b8b803SThierry Reding 	 */
248983de5f9SThierry Reding 	uint32_t flags;
2494e871899SJon Hunter } BPMP_ABI_PACKED;
250983de5f9SThierry Reding 
251983de5f9SThierry Reding /**
252983de5f9SThierry Reding  * @ingroup MRQ_Format
2534bef358cSTimo Alho  * @brief Header for an MRQ response
254983de5f9SThierry Reding  *
255983de5f9SThierry Reding  *  Provides an error code for the associated MRQ message. The
256983de5f9SThierry Reding  *  remainder of the MRQ response is a payload (immediately following
257983de5f9SThierry Reding  *  the mrq_response) whose format depends on the associated
258983de5f9SThierry Reding  *  mrq_request::mrq
259983de5f9SThierry Reding  */
260983de5f9SThierry Reding struct mrq_response {
2614bef358cSTimo Alho 	/** @brief Error code for the MRQ request itself */
262983de5f9SThierry Reding 	int32_t err;
263*b204b92bSPeter De Schrijver 
264*b204b92bSPeter De Schrijver 	/**
265*b204b92bSPeter De Schrijver 	 * @brief 32bit word containing a number of fields as follows:
266*b204b92bSPeter De Schrijver 	 *
267*b204b92bSPeter De Schrijver 	 * 	struct {
268*b204b92bSPeter De Schrijver 	 * 		uint8_t options:4;
269*b204b92bSPeter De Schrijver 	 * 		uint8_t xid:4;
270*b204b92bSPeter De Schrijver 	 * 		uint8_t payload_length;
271*b204b92bSPeter De Schrijver 	 * 		uint16_t crc16;
272*b204b92bSPeter De Schrijver 	 * 	};
273*b204b92bSPeter De Schrijver 	 *
274*b204b92bSPeter De Schrijver 	 * **options** indicates CRC presence.
275*b204b92bSPeter De Schrijver 	 *
276*b204b92bSPeter De Schrijver 	 * #BPMP_MAIL_CRC_PRESENT is supported on T234 and later platforms and
277*b204b92bSPeter De Schrijver 	 * indicates the crc16 related fields are present when set.
278*b204b92bSPeter De Schrijver 	 *
279*b204b92bSPeter De Schrijver 	 * **xid** is the transaction ID as sent by the requestor.
280*b204b92bSPeter De Schrijver 	 *
281*b204b92bSPeter De Schrijver 	 * **length** of the message expressed in bytes without the size of this header.
282*b204b92bSPeter De Schrijver 	 * Note: For DMCE communication, this field expresses the length as a multiple of 4 bytes
283*b204b92bSPeter De Schrijver 	 * rather than bytes.
284*b204b92bSPeter De Schrijver 	 *
285*b204b92bSPeter De Schrijver 	 * **crc16**
286*b204b92bSPeter De Schrijver 	 *
287*b204b92bSPeter De Schrijver 	 * CRC16 using polynomial x^16 + x^14 + x^12 + x^11 + x^8 + x^5 + x^4 + x^2 + 1
288*b204b92bSPeter De Schrijver 	 * and initialization value 0x4657. The CRC is calculated over all bytes of the message
289*b204b92bSPeter De Schrijver 	 * including this header. However the crc16 field is considered to be set to 0 when
290*b204b92bSPeter De Schrijver 	 * calculating the CRC. Only used when #BPMP_MAIL_CRC_PRESENT is set.
291*b204b92bSPeter De Schrijver 	 */
292983de5f9SThierry Reding 	uint32_t flags;
2934e871899SJon Hunter } BPMP_ABI_PACKED;
294983de5f9SThierry Reding 
295983de5f9SThierry Reding /**
296983de5f9SThierry Reding  * @ingroup MRQ_Format
297983de5f9SThierry Reding  * Minimum needed size for an IPC message buffer
298983de5f9SThierry Reding  */
2994e871899SJon Hunter #define MSG_MIN_SZ	128U
300983de5f9SThierry Reding /**
301983de5f9SThierry Reding  * @ingroup MRQ_Format
302983de5f9SThierry Reding  *  Minimum size guaranteed for data in an IPC message buffer
303983de5f9SThierry Reding  */
3044e871899SJon Hunter #define MSG_DATA_MIN_SZ	120U
305983de5f9SThierry Reding 
306983de5f9SThierry Reding /**
307983de5f9SThierry Reding  * @ingroup MRQ_Codes
308983de5f9SThierry Reding  * @name Legal MRQ codes
309983de5f9SThierry Reding  * These are the legal values for mrq_request::mrq
310983de5f9SThierry Reding  * @{
311983de5f9SThierry Reding  */
312983de5f9SThierry Reding 
3134e871899SJon Hunter #define MRQ_PING		0U
3144e871899SJon Hunter #define MRQ_QUERY_TAG		1U
3154e871899SJon Hunter #define MRQ_THREADED_PING	9U
3164e871899SJon Hunter #define MRQ_DEBUGFS		19U
3174e871899SJon Hunter #define MRQ_RESET		20U
3184e871899SJon Hunter #define MRQ_I2C			21U
3194e871899SJon Hunter #define MRQ_CLK			22U
3204e871899SJon Hunter #define MRQ_QUERY_ABI		23U
3214e871899SJon Hunter #define MRQ_THERMAL		27U
3224e871899SJon Hunter #define MRQ_CPU_VHINT		28U
3234e871899SJon Hunter #define MRQ_ABI_RATCHET		29U
3244e871899SJon Hunter #define MRQ_EMC_DVFS_LATENCY	31U
3254e871899SJon Hunter #define MRQ_RINGBUF_CONSOLE	65U
3264e871899SJon Hunter #define MRQ_PG			66U
3274e871899SJon Hunter #define MRQ_CPU_NDIV_LIMITS	67U
3284e871899SJon Hunter #define MRQ_STRAP               68U
3294e871899SJon Hunter #define MRQ_UPHY		69U
3304e871899SJon Hunter #define MRQ_CPU_AUTO_CC3	70U
3314e871899SJon Hunter #define MRQ_QUERY_FW_TAG	71U
3324e871899SJon Hunter #define MRQ_FMON		72U
3334e871899SJon Hunter #define MRQ_EC			73U
3344e871899SJon Hunter #define MRQ_DEBUG		75U
335*b204b92bSPeter De Schrijver #define MRQ_EMC_DVFS_EMCHUB	76U
336*b204b92bSPeter De Schrijver #define MRQ_BWMGR		77U
337*b204b92bSPeter De Schrijver #define MRQ_ISO_CLIENT		78U
338*b204b92bSPeter De Schrijver #define MRQ_EMC_DISP_RFL	79U
339*b204b92bSPeter De Schrijver #define MRQ_TELEMETRY		80U
340*b204b92bSPeter De Schrijver #define MRQ_PWR_LIMIT		81U
341*b204b92bSPeter De Schrijver #define MRQ_GEARS		82U
342*b204b92bSPeter De Schrijver #define MRQ_BWMGR_INT		83U
343*b204b92bSPeter De Schrijver #define MRQ_OC_STATUS		84U
344*b204b92bSPeter De Schrijver 
345*b204b92bSPeter De Schrijver /** @cond DEPRECATED */
346*b204b92bSPeter De Schrijver #define MRQ_RESERVED_2		2U
347*b204b92bSPeter De Schrijver #define MRQ_RESERVED_3		3U
348*b204b92bSPeter De Schrijver #define MRQ_RESERVED_4		4U
349*b204b92bSPeter De Schrijver #define MRQ_RESERVED_5   	5U
350*b204b92bSPeter De Schrijver #define MRQ_RESERVED_6		6U
351*b204b92bSPeter De Schrijver #define MRQ_RESERVED_7		7U
352*b204b92bSPeter De Schrijver #define MRQ_RESERVED_8		8U
353*b204b92bSPeter De Schrijver #define MRQ_RESERVED_10		10U
354*b204b92bSPeter De Schrijver #define MRQ_RESERVED_11		11U
355*b204b92bSPeter De Schrijver #define MRQ_RESERVED_12		12U
356*b204b92bSPeter De Schrijver #define MRQ_RESERVED_13		13U
357*b204b92bSPeter De Schrijver #define MRQ_RESERVED_14		14U
358*b204b92bSPeter De Schrijver #define MRQ_RESERVED_15		15U
359*b204b92bSPeter De Schrijver #define MRQ_RESERVED_16		16U
360*b204b92bSPeter De Schrijver #define MRQ_RESERVED_17		17U
361*b204b92bSPeter De Schrijver #define MRQ_RESERVED_18		18U
362*b204b92bSPeter De Schrijver #define MRQ_RESERVED_24		24U
363*b204b92bSPeter De Schrijver #define MRQ_RESERVED_25		25U
364*b204b92bSPeter De Schrijver #define MRQ_RESERVED_26		26U
365*b204b92bSPeter De Schrijver #define MRQ_RESERVED_30		30U
366*b204b92bSPeter De Schrijver #define MRQ_RESERVED_64		64U
367*b204b92bSPeter De Schrijver #define MRQ_RESERVED_74		74U
368*b204b92bSPeter De Schrijver /** @endcond DEPRECATED */
369983de5f9SThierry Reding 
370983de5f9SThierry Reding /** @} */
371983de5f9SThierry Reding 
372983de5f9SThierry Reding /**
373983de5f9SThierry Reding  * @ingroup MRQ_Codes
374983de5f9SThierry Reding  * @brief Maximum MRQ code to be sent by CPU software to
375983de5f9SThierry Reding  * BPMP. Subject to change in future
376983de5f9SThierry Reding  */
377*b204b92bSPeter De Schrijver #define MAX_CPU_MRQ_ID		84U
378983de5f9SThierry Reding 
379983de5f9SThierry Reding /**
3804bef358cSTimo Alho  * @addtogroup MRQ_Payloads
381983de5f9SThierry Reding  * @{
3824bef358cSTimo Alho  *   @defgroup Ping Ping
383983de5f9SThierry Reding  *   @defgroup Query_Tag Query Tag
384983de5f9SThierry Reding  *   @defgroup Module Loadable Modules
3854bef358cSTimo Alho  *   @defgroup Trace Trace
3864bef358cSTimo Alho  *   @defgroup Debugfs Debug File System
3874bef358cSTimo Alho  *   @defgroup Reset Reset
3884bef358cSTimo Alho  *   @defgroup I2C I2C
3894bef358cSTimo Alho  *   @defgroup Clocks Clocks
390983de5f9SThierry Reding  *   @defgroup ABI_info ABI Info
3914bef358cSTimo Alho  *   @defgroup Powergating Power Gating
3924bef358cSTimo Alho  *   @defgroup Thermal Thermal
393*b204b92bSPeter De Schrijver  *   @defgroup OC_status OC status
394983de5f9SThierry Reding  *   @defgroup Vhint CPU Voltage hint
3954bef358cSTimo Alho  *   @defgroup EMC EMC
396*b204b92bSPeter De Schrijver  *   @defgroup BWMGR BWMGR
397*b204b92bSPeter De Schrijver  *   @defgroup ISO_CLIENT ISO_CLIENT
3984bef358cSTimo Alho  *   @defgroup CPU NDIV Limits
3994bef358cSTimo Alho  *   @defgroup RingbufConsole Ring Buffer Console
4004bef358cSTimo Alho  *   @defgroup Strap Straps
4014bef358cSTimo Alho  *   @defgroup UPHY UPHY
4024bef358cSTimo Alho  *   @defgroup CC3 Auto-CC3
4034bef358cSTimo Alho  *   @defgroup FMON FMON
4044bef358cSTimo Alho  *   @defgroup EC EC
405*b204b92bSPeter De Schrijver  *   @defgroup Telemetry Telemetry
406*b204b92bSPeter De Schrijver  *   @defgroup Pwrlimit PWR_LIMIT
407*b204b92bSPeter De Schrijver  *   @defgroup Gears Gears
408*b204b92bSPeter De Schrijver  *   @defgroup BWMGR_INT Bandwidth Manager Integrated
409*b204b92bSPeter De Schrijver  * @} MRQ_Payloads
410983de5f9SThierry Reding  */
411983de5f9SThierry Reding 
412983de5f9SThierry Reding /**
413983de5f9SThierry Reding  * @ingroup MRQ_Codes
414983de5f9SThierry Reding  * @def MRQ_PING
415983de5f9SThierry Reding  * @brief A simple ping
416983de5f9SThierry Reding  *
417983de5f9SThierry Reding  * * Platforms: All
418983de5f9SThierry Reding  * * Initiators: Any
419983de5f9SThierry Reding  * * Targets: Any
420983de5f9SThierry Reding  * * Request Payload: @ref mrq_ping_request
421983de5f9SThierry Reding  * * Response Payload: @ref mrq_ping_response
422983de5f9SThierry Reding  *
423983de5f9SThierry Reding  * @ingroup MRQ_Codes
424983de5f9SThierry Reding  * @def MRQ_THREADED_PING
425983de5f9SThierry Reding  * @brief A deeper ping
426983de5f9SThierry Reding  *
427983de5f9SThierry Reding  * * Platforms: All
428983de5f9SThierry Reding  * * Initiators: Any
429983de5f9SThierry Reding  * * Targets: BPMP
430983de5f9SThierry Reding  * * Request Payload: @ref mrq_ping_request
431983de5f9SThierry Reding  * * Response Payload: @ref mrq_ping_response
432983de5f9SThierry Reding  *
433983de5f9SThierry Reding  * Behavior is equivalent to a simple #MRQ_PING except that BPMP
434983de5f9SThierry Reding  * responds from a thread context (providing a slightly more robust
435983de5f9SThierry Reding  * sign of life).
436983de5f9SThierry Reding  *
437983de5f9SThierry Reding  */
438983de5f9SThierry Reding 
439983de5f9SThierry Reding /**
440983de5f9SThierry Reding  * @ingroup Ping
4414bef358cSTimo Alho  * @brief Request with #MRQ_PING
442983de5f9SThierry Reding  *
443983de5f9SThierry Reding  * Used by the sender of an #MRQ_PING message to request a pong from
444983de5f9SThierry Reding  * recipient. The response from the recipient is computed based on
445983de5f9SThierry Reding  * #challenge.
446983de5f9SThierry Reding  */
447983de5f9SThierry Reding struct mrq_ping_request {
4484bef358cSTimo Alho /** @brief Arbitrarily chosen value */
449983de5f9SThierry Reding 	uint32_t challenge;
4504e871899SJon Hunter } BPMP_ABI_PACKED;
451983de5f9SThierry Reding 
452983de5f9SThierry Reding /**
453983de5f9SThierry Reding  * @ingroup Ping
4544bef358cSTimo Alho  * @brief Response to #MRQ_PING
455983de5f9SThierry Reding  *
456983de5f9SThierry Reding  * Sent in response to an #MRQ_PING message. #reply should be the
457983de5f9SThierry Reding  * mrq_ping_request challenge left shifted by 1 with the carry-bit
458983de5f9SThierry Reding  * dropped.
459983de5f9SThierry Reding  *
460983de5f9SThierry Reding  */
461983de5f9SThierry Reding struct mrq_ping_response {
4624bef358cSTimo Alho 	/** @brief Response to the MRQ_PING challege */
463983de5f9SThierry Reding 	uint32_t reply;
4644e871899SJon Hunter } BPMP_ABI_PACKED;
465983de5f9SThierry Reding 
466983de5f9SThierry Reding /**
467983de5f9SThierry Reding  * @ingroup MRQ_Codes
468983de5f9SThierry Reding  * @def MRQ_QUERY_TAG
4694bef358cSTimo Alho  * @brief Query BPMP firmware's tag (i.e. unique identifer)
4704bef358cSTimo Alho  *
4714bef358cSTimo Alho  * @deprecated Use #MRQ_QUERY_FW_TAG instead.
472983de5f9SThierry Reding  *
473983de5f9SThierry Reding  * * Platforms: All
474983de5f9SThierry Reding  * * Initiators: CCPLEX
475983de5f9SThierry Reding  * * Targets: BPMP
476983de5f9SThierry Reding  * * Request Payload: @ref mrq_query_tag_request
477983de5f9SThierry Reding  * * Response Payload: N/A
478983de5f9SThierry Reding  *
479983de5f9SThierry Reding  */
480983de5f9SThierry Reding 
481983de5f9SThierry Reding /**
482983de5f9SThierry Reding  * @ingroup Query_Tag
4834bef358cSTimo Alho  * @brief Request with #MRQ_QUERY_TAG
484983de5f9SThierry Reding  *
4854bef358cSTimo Alho  * @deprecated This structure will be removed in future version.
4864bef358cSTimo Alho  * Use MRQ_QUERY_FW_TAG instead.
487983de5f9SThierry Reding  */
488983de5f9SThierry Reding struct mrq_query_tag_request {
4894bef358cSTimo Alho   /** @brief Base address to store the firmware tag */
490983de5f9SThierry Reding 	uint32_t addr;
4914e871899SJon Hunter } BPMP_ABI_PACKED;
492983de5f9SThierry Reding 
4934bef358cSTimo Alho 
4944bef358cSTimo Alho /**
4954bef358cSTimo Alho  * @ingroup MRQ_Codes
4964bef358cSTimo Alho  * @def MRQ_QUERY_FW_TAG
4974bef358cSTimo Alho  * @brief Query BPMP firmware's tag (i.e. unique identifier)
4984bef358cSTimo Alho  *
4994bef358cSTimo Alho  * * Platforms: All
5004bef358cSTimo Alho  * * Initiators: Any
5014bef358cSTimo Alho  * * Targets: BPMP
5024bef358cSTimo Alho  * * Request Payload: N/A
5034bef358cSTimo Alho  * * Response Payload: @ref mrq_query_fw_tag_response
5044bef358cSTimo Alho  *
5054bef358cSTimo Alho  */
5064bef358cSTimo Alho 
5074bef358cSTimo Alho /**
5084bef358cSTimo Alho  * @ingroup Query_Tag
5094bef358cSTimo Alho  * @brief Response to #MRQ_QUERY_FW_TAG
5104bef358cSTimo Alho  *
5114bef358cSTimo Alho  * Sent in response to #MRQ_QUERY_FW_TAG message. #tag contains the unique
5124bef358cSTimo Alho  * identifier for the version of firmware issuing the reply.
5134bef358cSTimo Alho  *
5144bef358cSTimo Alho  */
5154bef358cSTimo Alho struct mrq_query_fw_tag_response {
5164bef358cSTimo Alho   /** @brief Array to store tag information */
5174bef358cSTimo Alho 	uint8_t tag[32];
5184e871899SJon Hunter } BPMP_ABI_PACKED;
5194bef358cSTimo Alho 
520983de5f9SThierry Reding /** @private */
521983de5f9SThierry Reding struct mrq_threaded_ping_request {
522983de5f9SThierry Reding 	uint32_t challenge;
5234e871899SJon Hunter } BPMP_ABI_PACKED;
524983de5f9SThierry Reding 
525983de5f9SThierry Reding /** @private */
526983de5f9SThierry Reding struct mrq_threaded_ping_response {
527983de5f9SThierry Reding 	uint32_t reply;
5284e871899SJon Hunter } BPMP_ABI_PACKED;
529983de5f9SThierry Reding 
530983de5f9SThierry Reding /**
531983de5f9SThierry Reding  * @ingroup MRQ_Codes
532983de5f9SThierry Reding  * @def MRQ_DEBUGFS
533983de5f9SThierry Reding  * @brief Interact with BPMP's debugfs file nodes
534983de5f9SThierry Reding  *
5355e37b9c1SJon Hunter  * @deprecated use MRQ_DEBUG instead.
5365e37b9c1SJon Hunter  *
5374bef358cSTimo Alho  * * Platforms: T186, T194
538983de5f9SThierry Reding  * * Initiators: Any
539983de5f9SThierry Reding  * * Targets: BPMP
540983de5f9SThierry Reding  * * Request Payload: @ref mrq_debugfs_request
541983de5f9SThierry Reding  * * Response Payload: @ref mrq_debugfs_response
542983de5f9SThierry Reding  */
543983de5f9SThierry Reding 
544983de5f9SThierry Reding /**
545983de5f9SThierry Reding  * @addtogroup Debugfs
546983de5f9SThierry Reding  * @{
547983de5f9SThierry Reding  *
548983de5f9SThierry Reding  * The BPMP firmware implements a pseudo-filesystem called
549983de5f9SThierry Reding  * debugfs. Any driver within the firmware may register with debugfs
550983de5f9SThierry Reding  * to expose an arbitrary set of "files" in the filesystem. When
551983de5f9SThierry Reding  * software on the CPU writes to a debugfs file, debugfs passes the
552983de5f9SThierry Reding  * written data to a callback provided by the driver. When software on
553983de5f9SThierry Reding  * the CPU reads a debugfs file, debugfs queries the driver for the
554983de5f9SThierry Reding  * data to return to the CPU. The intention of the debugfs filesystem
555983de5f9SThierry Reding  * is to provide information useful for debugging the system at
556983de5f9SThierry Reding  * runtime.
557983de5f9SThierry Reding  *
558983de5f9SThierry Reding  * @note The files exposed via debugfs are not part of the
559983de5f9SThierry Reding  * BPMP firmware's ABI. debugfs files may be added or removed in any
560983de5f9SThierry Reding  * given version of the firmware. Typically the semantics of a debugfs
561983de5f9SThierry Reding  * file are consistent from version to version but even that is not
562983de5f9SThierry Reding  * guaranteed.
563983de5f9SThierry Reding  *
564983de5f9SThierry Reding  * @}
565983de5f9SThierry Reding  */
5664bef358cSTimo Alho 
567983de5f9SThierry Reding /** @ingroup Debugfs */
568983de5f9SThierry Reding enum mrq_debugfs_commands {
5694bef358cSTimo Alho 	/** @brief Perform read */
570983de5f9SThierry Reding 	CMD_DEBUGFS_READ = 1,
5714bef358cSTimo Alho 	/** @brief Perform write */
572983de5f9SThierry Reding 	CMD_DEBUGFS_WRITE = 2,
5734bef358cSTimo Alho 	/** @brief Perform dumping directory */
574983de5f9SThierry Reding 	CMD_DEBUGFS_DUMPDIR = 3,
5754bef358cSTimo Alho 	/** @brief Not a command */
576983de5f9SThierry Reding 	CMD_DEBUGFS_MAX
577983de5f9SThierry Reding };
578983de5f9SThierry Reding 
579983de5f9SThierry Reding /**
580983de5f9SThierry Reding  * @ingroup Debugfs
5814bef358cSTimo Alho  * @brief Parameters for CMD_DEBUGFS_READ/WRITE command
582983de5f9SThierry Reding  */
583983de5f9SThierry Reding struct cmd_debugfs_fileop_request {
5844bef358cSTimo Alho 	/** @brief Physical address pointing at filename */
585983de5f9SThierry Reding 	uint32_t fnameaddr;
5864bef358cSTimo Alho 	/** @brief Length in bytes of filename buffer */
587983de5f9SThierry Reding 	uint32_t fnamelen;
5884bef358cSTimo Alho 	/** @brief Physical address pointing to data buffer */
589983de5f9SThierry Reding 	uint32_t dataaddr;
5904bef358cSTimo Alho 	/** @brief Length in bytes of data buffer */
591983de5f9SThierry Reding 	uint32_t datalen;
5924e871899SJon Hunter } BPMP_ABI_PACKED;
593983de5f9SThierry Reding 
594983de5f9SThierry Reding /**
595983de5f9SThierry Reding  * @ingroup Debugfs
5964bef358cSTimo Alho  * @brief Parameters for CMD_DEBUGFS_READ/WRITE command
597983de5f9SThierry Reding  */
598983de5f9SThierry Reding struct cmd_debugfs_dumpdir_request {
5994bef358cSTimo Alho 	/** @brief Physical address pointing to data buffer */
600983de5f9SThierry Reding 	uint32_t dataaddr;
6014bef358cSTimo Alho 	/** @brief Length in bytes of data buffer */
602983de5f9SThierry Reding 	uint32_t datalen;
6034e871899SJon Hunter } BPMP_ABI_PACKED;
604983de5f9SThierry Reding 
605983de5f9SThierry Reding /**
606983de5f9SThierry Reding  * @ingroup Debugfs
6074bef358cSTimo Alho  * @brief Response data for CMD_DEBUGFS_READ/WRITE command
608983de5f9SThierry Reding  */
609983de5f9SThierry Reding struct cmd_debugfs_fileop_response {
6104bef358cSTimo Alho 	/** @brief Always 0 */
611983de5f9SThierry Reding 	uint32_t reserved;
6124bef358cSTimo Alho 	/** @brief Number of bytes read from or written to data buffer */
613983de5f9SThierry Reding 	uint32_t nbytes;
6144e871899SJon Hunter } BPMP_ABI_PACKED;
615983de5f9SThierry Reding 
616983de5f9SThierry Reding /**
617983de5f9SThierry Reding  * @ingroup Debugfs
6184bef358cSTimo Alho  * @brief Response data for CMD_DEBUGFS_DUMPDIR command
619983de5f9SThierry Reding  */
620983de5f9SThierry Reding struct cmd_debugfs_dumpdir_response {
6214bef358cSTimo Alho 	/** @brief Always 0 */
622983de5f9SThierry Reding 	uint32_t reserved;
6234bef358cSTimo Alho 	/** @brief Number of bytes read from or written to data buffer */
624983de5f9SThierry Reding 	uint32_t nbytes;
6254e871899SJon Hunter } BPMP_ABI_PACKED;
626983de5f9SThierry Reding 
627983de5f9SThierry Reding /**
628983de5f9SThierry Reding  * @ingroup Debugfs
6294bef358cSTimo Alho  * @brief Request with #MRQ_DEBUGFS.
630983de5f9SThierry Reding  *
631983de5f9SThierry Reding  * The sender of an MRQ_DEBUGFS message uses #cmd to specify a debugfs
632983de5f9SThierry Reding  * command to execute. Legal commands are the values of @ref
633983de5f9SThierry Reding  * mrq_debugfs_commands. Each command requires a specific additional
634983de5f9SThierry Reding  * payload of data.
635983de5f9SThierry Reding  *
636983de5f9SThierry Reding  * |command            |payload|
637983de5f9SThierry Reding  * |-------------------|-------|
638983de5f9SThierry Reding  * |CMD_DEBUGFS_READ   |fop    |
639983de5f9SThierry Reding  * |CMD_DEBUGFS_WRITE  |fop    |
640983de5f9SThierry Reding  * |CMD_DEBUGFS_DUMPDIR|dumpdir|
641983de5f9SThierry Reding  */
642983de5f9SThierry Reding struct mrq_debugfs_request {
6434bef358cSTimo Alho 	/** @brief Sub-command (@ref mrq_debugfs_commands) */
644983de5f9SThierry Reding 	uint32_t cmd;
645983de5f9SThierry Reding 	union {
646983de5f9SThierry Reding 		struct cmd_debugfs_fileop_request fop;
647983de5f9SThierry Reding 		struct cmd_debugfs_dumpdir_request dumpdir;
6484e871899SJon Hunter 	} BPMP_UNION_ANON;
6494e871899SJon Hunter } BPMP_ABI_PACKED;
650983de5f9SThierry Reding 
651983de5f9SThierry Reding /**
652983de5f9SThierry Reding  * @ingroup Debugfs
653983de5f9SThierry Reding  */
654983de5f9SThierry Reding struct mrq_debugfs_response {
6554bef358cSTimo Alho 	/** @brief Always 0 */
656983de5f9SThierry Reding 	int32_t reserved;
657983de5f9SThierry Reding 	union {
6584bef358cSTimo Alho 		/** @brief Response data for CMD_DEBUGFS_READ OR
659983de5f9SThierry Reding 		 * CMD_DEBUGFS_WRITE command
660983de5f9SThierry Reding 		 */
661983de5f9SThierry Reding 		struct cmd_debugfs_fileop_response fop;
6624bef358cSTimo Alho 		/** @brief Response data for CMD_DEBUGFS_DUMPDIR command */
663983de5f9SThierry Reding 		struct cmd_debugfs_dumpdir_response dumpdir;
6644e871899SJon Hunter 	} BPMP_UNION_ANON;
6654e871899SJon Hunter } BPMP_ABI_PACKED;
666983de5f9SThierry Reding 
667983de5f9SThierry Reding /**
668983de5f9SThierry Reding  * @addtogroup Debugfs
669983de5f9SThierry Reding  * @{
670983de5f9SThierry Reding  */
671983de5f9SThierry Reding #define DEBUGFS_S_ISDIR	(1 << 9)
672983de5f9SThierry Reding #define DEBUGFS_S_IRUSR	(1 << 8)
673983de5f9SThierry Reding #define DEBUGFS_S_IWUSR	(1 << 7)
674*b204b92bSPeter De Schrijver /** @} Debugfs */
675983de5f9SThierry Reding 
676983de5f9SThierry Reding /**
677983de5f9SThierry Reding  * @ingroup MRQ_Codes
6785e37b9c1SJon Hunter  * @def MRQ_DEBUG
6795e37b9c1SJon Hunter  * @brief Interact with BPMP's debugfs file nodes. Use message payload
6805e37b9c1SJon Hunter  * for exchanging data. This is functionally equivalent to
6815e37b9c1SJon Hunter  * @ref MRQ_DEBUGFS. But the way in which data is exchanged is different.
6825e37b9c1SJon Hunter  * When software running on CPU tries to read a debugfs file,
6835e37b9c1SJon Hunter  * the file path and read data will be stored in message payload.
6845e37b9c1SJon Hunter  * Since the message payload size is limited, a debugfs file
6855e37b9c1SJon Hunter  * transaction might require multiple frames of data exchanged
6865e37b9c1SJon Hunter  * between BPMP and CPU until the transaction completes.
6875e37b9c1SJon Hunter  *
6885e37b9c1SJon Hunter  * * Platforms: T194
6895e37b9c1SJon Hunter  * * Initiators: Any
6905e37b9c1SJon Hunter  * * Targets: BPMP
6915e37b9c1SJon Hunter  * * Request Payload: @ref mrq_debug_request
6925e37b9c1SJon Hunter  * * Response Payload: @ref mrq_debug_response
6935e37b9c1SJon Hunter  */
6945e37b9c1SJon Hunter 
6955e37b9c1SJon Hunter /** @ingroup Debugfs */
6965e37b9c1SJon Hunter enum mrq_debug_commands {
6975e37b9c1SJon Hunter 	/** @brief Open required file for read operation */
6985e37b9c1SJon Hunter 	CMD_DEBUG_OPEN_RO = 0,
6995e37b9c1SJon Hunter 	/** @brief Open required file for write operation */
7005e37b9c1SJon Hunter 	CMD_DEBUG_OPEN_WO = 1,
7015e37b9c1SJon Hunter 	/** @brief Perform read */
7025e37b9c1SJon Hunter 	CMD_DEBUG_READ = 2,
7035e37b9c1SJon Hunter 	/** @brief Perform write */
7045e37b9c1SJon Hunter 	CMD_DEBUG_WRITE = 3,
7055e37b9c1SJon Hunter 	/** @brief Close file */
7065e37b9c1SJon Hunter 	CMD_DEBUG_CLOSE = 4,
7075e37b9c1SJon Hunter 	/** @brief Not a command */
7085e37b9c1SJon Hunter 	CMD_DEBUG_MAX
7095e37b9c1SJon Hunter };
7105e37b9c1SJon Hunter 
7115e37b9c1SJon Hunter /**
7125e37b9c1SJon Hunter  * @ingroup Debugfs
7135e37b9c1SJon Hunter  * @brief Maximum number of files that can be open at a given time
7145e37b9c1SJon Hunter  */
7155e37b9c1SJon Hunter #define DEBUG_MAX_OPEN_FILES	1
7165e37b9c1SJon Hunter 
7175e37b9c1SJon Hunter /**
7185e37b9c1SJon Hunter  * @ingroup Debugfs
7195e37b9c1SJon Hunter  * @brief Maximum size of null-terminated file name string in bytes.
7205e37b9c1SJon Hunter  * Value is derived from memory available in message payload while
7215e37b9c1SJon Hunter  * using @ref cmd_debug_fopen_request
7225e37b9c1SJon Hunter  * Value 4 corresponds to size of @ref mrq_debug_commands
7235e37b9c1SJon Hunter  * in @ref mrq_debug_request.
7245e37b9c1SJon Hunter  * 120 - 4 dbg_cmd(32bit)  = 116
7255e37b9c1SJon Hunter  */
7265e37b9c1SJon Hunter #define DEBUG_FNAME_MAX_SZ	(MSG_DATA_MIN_SZ - 4)
7275e37b9c1SJon Hunter 
7285e37b9c1SJon Hunter /**
7295e37b9c1SJon Hunter  * @ingroup Debugfs
7305e37b9c1SJon Hunter  * @brief Parameters for CMD_DEBUG_OPEN command
7315e37b9c1SJon Hunter  */
7325e37b9c1SJon Hunter struct cmd_debug_fopen_request {
7335e37b9c1SJon Hunter 	/** @brief File name - Null-terminated string with maximum
7345e37b9c1SJon Hunter 	 * length @ref DEBUG_FNAME_MAX_SZ
7355e37b9c1SJon Hunter 	 */
7365e37b9c1SJon Hunter 	char name[DEBUG_FNAME_MAX_SZ];
7374e871899SJon Hunter } BPMP_ABI_PACKED;
7385e37b9c1SJon Hunter 
7395e37b9c1SJon Hunter /**
7405e37b9c1SJon Hunter  * @ingroup Debugfs
7415e37b9c1SJon Hunter  * @brief Response data for CMD_DEBUG_OPEN_RO/WO command
7425e37b9c1SJon Hunter  */
7435e37b9c1SJon Hunter struct cmd_debug_fopen_response {
7445e37b9c1SJon Hunter 	/** @brief Identifier for file access */
7455e37b9c1SJon Hunter 	uint32_t fd;
7465e37b9c1SJon Hunter 	/** @brief Data length. File data size for READ command.
7475e37b9c1SJon Hunter 	 * Maximum allowed length for WRITE command
7485e37b9c1SJon Hunter 	 */
7495e37b9c1SJon Hunter 	uint32_t datalen;
7504e871899SJon Hunter } BPMP_ABI_PACKED;
7515e37b9c1SJon Hunter 
7525e37b9c1SJon Hunter /**
7535e37b9c1SJon Hunter  * @ingroup Debugfs
7545e37b9c1SJon Hunter  * @brief Parameters for CMD_DEBUG_READ command
7555e37b9c1SJon Hunter  */
7565e37b9c1SJon Hunter struct cmd_debug_fread_request {
7575e37b9c1SJon Hunter 	/** @brief File access identifier received in response
7585e37b9c1SJon Hunter 	 * to CMD_DEBUG_OPEN_RO request
7595e37b9c1SJon Hunter 	 */
7605e37b9c1SJon Hunter 	uint32_t fd;
7614e871899SJon Hunter } BPMP_ABI_PACKED;
7625e37b9c1SJon Hunter 
7635e37b9c1SJon Hunter /**
7645e37b9c1SJon Hunter  * @ingroup Debugfs
7655e37b9c1SJon Hunter  * @brief Maximum size of read data in bytes.
7665e37b9c1SJon Hunter  * Value is derived from memory available in message payload while
7675e37b9c1SJon Hunter  * using @ref cmd_debug_fread_response.
7685e37b9c1SJon Hunter  */
7695e37b9c1SJon Hunter #define DEBUG_READ_MAX_SZ	(MSG_DATA_MIN_SZ - 4)
7705e37b9c1SJon Hunter 
7715e37b9c1SJon Hunter /**
7725e37b9c1SJon Hunter  * @ingroup Debugfs
7735e37b9c1SJon Hunter  * @brief Response data for CMD_DEBUG_READ command
7745e37b9c1SJon Hunter  */
7755e37b9c1SJon Hunter struct cmd_debug_fread_response {
7765e37b9c1SJon Hunter 	/** @brief Size of data provided in this response in bytes */
7775e37b9c1SJon Hunter 	uint32_t readlen;
7785e37b9c1SJon Hunter 	/** @brief File data from seek position */
7795e37b9c1SJon Hunter 	char data[DEBUG_READ_MAX_SZ];
7804e871899SJon Hunter } BPMP_ABI_PACKED;
7815e37b9c1SJon Hunter 
7825e37b9c1SJon Hunter /**
7835e37b9c1SJon Hunter  * @ingroup Debugfs
7845e37b9c1SJon Hunter  * @brief Maximum size of write data in bytes.
7855e37b9c1SJon Hunter  * Value is derived from memory available in message payload while
7865e37b9c1SJon Hunter  * using @ref cmd_debug_fwrite_request.
7875e37b9c1SJon Hunter  */
7885e37b9c1SJon Hunter #define DEBUG_WRITE_MAX_SZ	(MSG_DATA_MIN_SZ - 12)
7895e37b9c1SJon Hunter 
7905e37b9c1SJon Hunter /**
7915e37b9c1SJon Hunter  * @ingroup Debugfs
7925e37b9c1SJon Hunter  * @brief Parameters for CMD_DEBUG_WRITE command
7935e37b9c1SJon Hunter  */
7945e37b9c1SJon Hunter struct cmd_debug_fwrite_request {
7955e37b9c1SJon Hunter 	/** @brief File access identifier received in response
7965e37b9c1SJon Hunter 	 * to CMD_DEBUG_OPEN_RO request
7975e37b9c1SJon Hunter 	 */
7985e37b9c1SJon Hunter 	uint32_t fd;
7995e37b9c1SJon Hunter 	/** @brief Size of write data in bytes */
8005e37b9c1SJon Hunter 	uint32_t datalen;
8015e37b9c1SJon Hunter 	/** @brief Data to be written */
8025e37b9c1SJon Hunter 	char data[DEBUG_WRITE_MAX_SZ];
8034e871899SJon Hunter } BPMP_ABI_PACKED;
8045e37b9c1SJon Hunter 
8055e37b9c1SJon Hunter /**
8065e37b9c1SJon Hunter  * @ingroup Debugfs
8075e37b9c1SJon Hunter  * @brief Parameters for CMD_DEBUG_CLOSE command
8085e37b9c1SJon Hunter  */
8095e37b9c1SJon Hunter struct cmd_debug_fclose_request {
8105e37b9c1SJon Hunter 	/** @brief File access identifier received in response
8115e37b9c1SJon Hunter 	 * to CMD_DEBUG_OPEN_RO request
8125e37b9c1SJon Hunter 	 */
8135e37b9c1SJon Hunter 	uint32_t fd;
8144e871899SJon Hunter } BPMP_ABI_PACKED;
8155e37b9c1SJon Hunter 
8165e37b9c1SJon Hunter /**
8175e37b9c1SJon Hunter  * @ingroup Debugfs
8185e37b9c1SJon Hunter  * @brief Request with #MRQ_DEBUG.
8195e37b9c1SJon Hunter  *
8205e37b9c1SJon Hunter  * The sender of an MRQ_DEBUG message uses #cmd to specify a debugfs
8215e37b9c1SJon Hunter  * command to execute. Legal commands are the values of @ref
8225e37b9c1SJon Hunter  * mrq_debug_commands. Each command requires a specific additional
8235e37b9c1SJon Hunter  * payload of data.
8245e37b9c1SJon Hunter  *
8255e37b9c1SJon Hunter  * |command            |payload|
8265e37b9c1SJon Hunter  * |-------------------|-------|
8275e37b9c1SJon Hunter  * |CMD_DEBUG_OPEN_RO  |fop    |
8285e37b9c1SJon Hunter  * |CMD_DEBUG_OPEN_WO  |fop    |
8295e37b9c1SJon Hunter  * |CMD_DEBUG_READ     |frd    |
8305e37b9c1SJon Hunter  * |CMD_DEBUG_WRITE    |fwr    |
8315e37b9c1SJon Hunter  * |CMD_DEBUG_CLOSE    |fcl    |
8325e37b9c1SJon Hunter  */
8335e37b9c1SJon Hunter struct mrq_debug_request {
8345e37b9c1SJon Hunter 	/** @brief Sub-command (@ref mrq_debug_commands) */
8355e37b9c1SJon Hunter 	uint32_t cmd;
8365e37b9c1SJon Hunter 	union {
8375e37b9c1SJon Hunter 		/** @brief Request payload for CMD_DEBUG_OPEN_RO/WO command */
8385e37b9c1SJon Hunter 		struct cmd_debug_fopen_request fop;
8395e37b9c1SJon Hunter 		/** @brief Request payload for CMD_DEBUG_READ command */
8405e37b9c1SJon Hunter 		struct cmd_debug_fread_request frd;
8415e37b9c1SJon Hunter 		/** @brief Request payload for CMD_DEBUG_WRITE command */
8425e37b9c1SJon Hunter 		struct cmd_debug_fwrite_request fwr;
8435e37b9c1SJon Hunter 		/** @brief Request payload for CMD_DEBUG_CLOSE command */
8445e37b9c1SJon Hunter 		struct cmd_debug_fclose_request fcl;
8454e871899SJon Hunter 	} BPMP_UNION_ANON;
8464e871899SJon Hunter } BPMP_ABI_PACKED;
8475e37b9c1SJon Hunter 
8485e37b9c1SJon Hunter /**
8495e37b9c1SJon Hunter  * @ingroup Debugfs
8505e37b9c1SJon Hunter  */
8515e37b9c1SJon Hunter struct mrq_debug_response {
8525e37b9c1SJon Hunter 	union {
8535e37b9c1SJon Hunter 		/** @brief Response data for CMD_DEBUG_OPEN_RO/WO command */
8545e37b9c1SJon Hunter 		struct cmd_debug_fopen_response fop;
8555e37b9c1SJon Hunter 		/** @brief Response data for CMD_DEBUG_READ command */
8565e37b9c1SJon Hunter 		struct cmd_debug_fread_response frd;
8574e871899SJon Hunter 	} BPMP_UNION_ANON;
8584e871899SJon Hunter } BPMP_ABI_PACKED;
8595e37b9c1SJon Hunter 
8605e37b9c1SJon Hunter /**
8615e37b9c1SJon Hunter  * @ingroup MRQ_Codes
862983de5f9SThierry Reding  * @def MRQ_RESET
8634bef358cSTimo Alho  * @brief Reset an IP block
864983de5f9SThierry Reding  *
8654bef358cSTimo Alho  * * Platforms: T186, T194
866983de5f9SThierry Reding  * * Initiators: Any
867983de5f9SThierry Reding  * * Targets: BPMP
868983de5f9SThierry Reding  * * Request Payload: @ref mrq_reset_request
86952b8b803SThierry Reding  * * Response Payload: @ref mrq_reset_response
8704bef358cSTimo Alho  *
8714bef358cSTimo Alho  * @addtogroup Reset
8724bef358cSTimo Alho  * @{
873983de5f9SThierry Reding  */
874983de5f9SThierry Reding 
875983de5f9SThierry Reding enum mrq_reset_commands {
8764e871899SJon Hunter 	/**
8774e871899SJon Hunter 	 * @brief Assert module reset
8784e871899SJon Hunter 	 *
8794e871899SJon Hunter 	 * mrq_response::err is 0 if the operation was successful, or @n
8804e871899SJon Hunter 	 * -#BPMP_EINVAL if mrq_reset_request::reset_id is invalid @n
8814e871899SJon Hunter 	 * -#BPMP_EACCES if mrq master is not an owner of target domain reset @n
8824e871899SJon Hunter 	 * -#BPMP_ENOTSUP if target domain h/w state does not allow reset
8834e871899SJon Hunter 	 */
884983de5f9SThierry Reding 	CMD_RESET_ASSERT = 1,
8854e871899SJon Hunter 	/**
8864e871899SJon Hunter 	 * @brief Deassert module reset
8874e871899SJon Hunter 	 *
8884e871899SJon Hunter 	 * mrq_response::err is 0 if the operation was successful, or @n
8894e871899SJon Hunter 	 * -#BPMP_EINVAL if mrq_reset_request::reset_id is invalid @n
8904e871899SJon Hunter 	 * -#BPMP_EACCES if mrq master is not an owner of target domain reset @n
8914e871899SJon Hunter 	 * -#BPMP_ENOTSUP if target domain h/w state does not allow reset
8924e871899SJon Hunter 	 */
893983de5f9SThierry Reding 	CMD_RESET_DEASSERT = 2,
8944e871899SJon Hunter 	/**
8954e871899SJon Hunter 	 * @brief Assert and deassert the module reset
8964e871899SJon Hunter 	 *
8974e871899SJon Hunter 	 * mrq_response::err is 0 if the operation was successful, or @n
8984e871899SJon Hunter 	 * -#BPMP_EINVAL if mrq_reset_request::reset_id is invalid @n
8994e871899SJon Hunter 	 * -#BPMP_EACCES if mrq master is not an owner of target domain reset @n
9004e871899SJon Hunter 	 * -#BPMP_ENOTSUP if target domain h/w state does not allow reset
9014e871899SJon Hunter 	 */
902983de5f9SThierry Reding 	CMD_RESET_MODULE = 3,
9034e871899SJon Hunter 	/**
9044e871899SJon Hunter 	 * @brief Get the highest reset ID
9054e871899SJon Hunter 	 *
9064e871899SJon Hunter 	 * mrq_response::err is 0 if the operation was successful, or @n
9074e871899SJon Hunter 	 * -#BPMP_ENODEV if no reset domains are supported (number of IDs is 0)
9084e871899SJon Hunter 	 */
90952b8b803SThierry Reding 	CMD_RESET_GET_MAX_ID = 4,
9104e871899SJon Hunter 
9114bef358cSTimo Alho 	/** @brief Not part of ABI and subject to change */
9124bef358cSTimo Alho 	CMD_RESET_MAX,
913983de5f9SThierry Reding };
914983de5f9SThierry Reding 
915983de5f9SThierry Reding /**
9164bef358cSTimo Alho  * @brief Request with MRQ_RESET
917983de5f9SThierry Reding  *
918983de5f9SThierry Reding  * Used by the sender of an #MRQ_RESET message to request BPMP to
919*b204b92bSPeter De Schrijver  * assert or or deassert a given reset line.
920983de5f9SThierry Reding  */
921983de5f9SThierry Reding struct mrq_reset_request {
9224bef358cSTimo Alho 	/** @brief Reset action to perform (@ref mrq_reset_commands) */
923983de5f9SThierry Reding 	uint32_t cmd;
9244bef358cSTimo Alho 	/** @brief Id of the reset to affected */
925983de5f9SThierry Reding 	uint32_t reset_id;
9264e871899SJon Hunter } BPMP_ABI_PACKED;
927983de5f9SThierry Reding 
928983de5f9SThierry Reding /**
92952b8b803SThierry Reding  * @brief Response for MRQ_RESET sub-command CMD_RESET_GET_MAX_ID. When
93052b8b803SThierry Reding  * this sub-command is not supported, firmware will return -BPMP_EBADCMD
93152b8b803SThierry Reding  * in mrq_response::err.
93252b8b803SThierry Reding  */
93352b8b803SThierry Reding struct cmd_reset_get_max_id_response {
9344bef358cSTimo Alho 	/** @brief Max reset id */
93552b8b803SThierry Reding 	uint32_t max_id;
9364e871899SJon Hunter } BPMP_ABI_PACKED;
93752b8b803SThierry Reding 
93852b8b803SThierry Reding /**
93952b8b803SThierry Reding  * @brief Response with MRQ_RESET
94052b8b803SThierry Reding  *
94152b8b803SThierry Reding  * Each sub-command supported by @ref mrq_reset_request may return
94252b8b803SThierry Reding  * sub-command-specific data. Some do and some do not as indicated
94352b8b803SThierry Reding  * in the following table
94452b8b803SThierry Reding  *
94552b8b803SThierry Reding  * | sub-command          | payload          |
94652b8b803SThierry Reding  * |----------------------|------------------|
94752b8b803SThierry Reding  * | CMD_RESET_ASSERT     | -                |
94852b8b803SThierry Reding  * | CMD_RESET_DEASSERT   | -                |
94952b8b803SThierry Reding  * | CMD_RESET_MODULE     | -                |
95052b8b803SThierry Reding  * | CMD_RESET_GET_MAX_ID | reset_get_max_id |
95152b8b803SThierry Reding  */
95252b8b803SThierry Reding struct mrq_reset_response {
95352b8b803SThierry Reding 	union {
95452b8b803SThierry Reding 		struct cmd_reset_get_max_id_response reset_get_max_id;
9554e871899SJon Hunter 	} BPMP_UNION_ANON;
9564e871899SJon Hunter } BPMP_ABI_PACKED;
95752b8b803SThierry Reding 
958*b204b92bSPeter De Schrijver /** @} Reset */
9594bef358cSTimo Alho 
96052b8b803SThierry Reding /**
961983de5f9SThierry Reding  * @ingroup MRQ_Codes
962983de5f9SThierry Reding  * @def MRQ_I2C
9634bef358cSTimo Alho  * @brief Issue an i2c transaction
964983de5f9SThierry Reding  *
9654bef358cSTimo Alho  * * Platforms: T186, T194
966983de5f9SThierry Reding  * * Initiators: Any
967983de5f9SThierry Reding  * * Targets: BPMP
968983de5f9SThierry Reding  * * Request Payload: @ref mrq_i2c_request
969983de5f9SThierry Reding  * * Response Payload: @ref mrq_i2c_response
9704bef358cSTimo Alho  *
971983de5f9SThierry Reding  * @addtogroup I2C
972983de5f9SThierry Reding  * @{
973983de5f9SThierry Reding  */
9744e871899SJon Hunter #define TEGRA_I2C_IPC_MAX_IN_BUF_SIZE	(MSG_DATA_MIN_SZ - 12U)
9754e871899SJon Hunter #define TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE	(MSG_DATA_MIN_SZ - 4U)
976983de5f9SThierry Reding 
9774e871899SJon Hunter #define SERIALI2C_TEN           0x0010U
9784e871899SJon Hunter #define SERIALI2C_RD            0x0001U
9794e871899SJon Hunter #define SERIALI2C_STOP          0x8000U
9804e871899SJon Hunter #define SERIALI2C_NOSTART       0x4000U
9814e871899SJon Hunter #define SERIALI2C_REV_DIR_ADDR  0x2000U
9824e871899SJon Hunter #define SERIALI2C_IGNORE_NAK    0x1000U
9834e871899SJon Hunter #define SERIALI2C_NO_RD_ACK     0x0800U
9844e871899SJon Hunter #define SERIALI2C_RECV_LEN      0x0400U
9854bef358cSTimo Alho 
986983de5f9SThierry Reding enum {
987983de5f9SThierry Reding 	CMD_I2C_XFER = 1
988983de5f9SThierry Reding };
989983de5f9SThierry Reding 
990983de5f9SThierry Reding /**
9914bef358cSTimo Alho  * @brief Serializable i2c request
992983de5f9SThierry Reding  *
993983de5f9SThierry Reding  * Instances of this structure are packed (little-endian) into
994983de5f9SThierry Reding  * cmd_i2c_xfer_request::data_buf. Each instance represents a single
995983de5f9SThierry Reding  * transaction (or a portion of a transaction with repeated starts) on
996983de5f9SThierry Reding  * an i2c bus.
997983de5f9SThierry Reding  *
998983de5f9SThierry Reding  * Because these structures are packed, some instances are likely to
999983de5f9SThierry Reding  * be misaligned. Additionally because #data is variable length, it is
1000983de5f9SThierry Reding  * not possible to iterate through a serialized list of these
1001983de5f9SThierry Reding  * structures without inspecting #len in each instance.  It may be
1002983de5f9SThierry Reding  * easier to serialize or deserialize cmd_i2c_xfer_request::data_buf
1003983de5f9SThierry Reding  * manually rather than using this structure definition.
1004983de5f9SThierry Reding */
1005983de5f9SThierry Reding struct serial_i2c_request {
1006983de5f9SThierry Reding 	/** @brief I2C slave address */
1007983de5f9SThierry Reding 	uint16_t addr;
10084bef358cSTimo Alho 	/** @brief Bitmask of SERIALI2C_ flags */
1009983de5f9SThierry Reding 	uint16_t flags;
10104bef358cSTimo Alho 	/** @brief Length of I2C transaction in bytes */
1011983de5f9SThierry Reding 	uint16_t len;
10124bef358cSTimo Alho 	/** @brief For write transactions only, #len bytes of data */
1013983de5f9SThierry Reding 	uint8_t data[];
10144e871899SJon Hunter } BPMP_ABI_PACKED;
1015983de5f9SThierry Reding 
1016983de5f9SThierry Reding /**
10174bef358cSTimo Alho  * @brief Trigger one or more i2c transactions
1018983de5f9SThierry Reding  */
1019983de5f9SThierry Reding struct cmd_i2c_xfer_request {
1020*b204b92bSPeter De Schrijver 	/**
1021*b204b92bSPeter De Schrijver 	 * @brief Tegra PWR_I2C bus identifier
1022*b204b92bSPeter De Schrijver 	 *
1023*b204b92bSPeter De Schrijver 	 * @cond (bpmp_t234 || bpmp_t239 || bpmp_t194)
1024*b204b92bSPeter De Schrijver 	 * Must be set to 5.
1025*b204b92bSPeter De Schrijver 	 * @endcond (bpmp_t234 || bpmp_t239 || bpmp_t194)
1026*b204b92bSPeter De Schrijver 	 * @cond bpmp_th500
1027*b204b92bSPeter De Schrijver 	 * Must be set to 1.
1028*b204b92bSPeter De Schrijver 	 * @endcond bpmp_th500
1029*b204b92bSPeter De Schrijver 	 *
1030*b204b92bSPeter De Schrijver 	 */
1031983de5f9SThierry Reding 	uint32_t bus_id;
1032983de5f9SThierry Reding 
10334bef358cSTimo Alho 	/** @brief Count of valid bytes in #data_buf*/
1034983de5f9SThierry Reding 	uint32_t data_size;
1035983de5f9SThierry Reding 
10364bef358cSTimo Alho 	/** @brief Serialized packed instances of @ref serial_i2c_request*/
1037983de5f9SThierry Reding 	uint8_t data_buf[TEGRA_I2C_IPC_MAX_IN_BUF_SIZE];
10384e871899SJon Hunter } BPMP_ABI_PACKED;
1039983de5f9SThierry Reding 
1040983de5f9SThierry Reding /**
10414bef358cSTimo Alho  * @brief Container for data read from the i2c bus
1042983de5f9SThierry Reding  *
1043983de5f9SThierry Reding  * Processing an cmd_i2c_xfer_request::data_buf causes BPMP to execute
1044983de5f9SThierry Reding  * zero or more I2C reads. The data read from the bus is serialized
1045983de5f9SThierry Reding  * into #data_buf.
1046983de5f9SThierry Reding  */
1047983de5f9SThierry Reding struct cmd_i2c_xfer_response {
10484bef358cSTimo Alho 	/** @brief Count of valid bytes in #data_buf*/
1049983de5f9SThierry Reding 	uint32_t data_size;
10504bef358cSTimo Alho 	/** @brief I2c read data */
1051983de5f9SThierry Reding 	uint8_t data_buf[TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE];
10524e871899SJon Hunter } BPMP_ABI_PACKED;
1053983de5f9SThierry Reding 
1054983de5f9SThierry Reding /**
10554bef358cSTimo Alho  * @brief Request with #MRQ_I2C
1056983de5f9SThierry Reding  */
1057983de5f9SThierry Reding struct mrq_i2c_request {
10584bef358cSTimo Alho 	/** @brief Always CMD_I2C_XFER (i.e. 1) */
1059983de5f9SThierry Reding 	uint32_t cmd;
10604bef358cSTimo Alho 	/** @brief Parameters of the transfer request */
1061983de5f9SThierry Reding 	struct cmd_i2c_xfer_request xfer;
10624e871899SJon Hunter } BPMP_ABI_PACKED;
1063983de5f9SThierry Reding 
1064983de5f9SThierry Reding /**
10654bef358cSTimo Alho  * @brief Response to #MRQ_I2C
10664e871899SJon Hunter  *
10674e871899SJon Hunter  * mrq_response:err is
10684e871899SJon Hunter  *  0: Success
10694e871899SJon Hunter  *  -#BPMP_EBADCMD: if mrq_i2c_request::cmd is other than 1
10704e871899SJon Hunter  *  -#BPMP_EINVAL: if cmd_i2c_xfer_request does not contain correctly formatted request
10714e871899SJon Hunter  *  -#BPMP_ENODEV: if cmd_i2c_xfer_request::bus_id is not supported by BPMP
10724e871899SJon Hunter  *  -#BPMP_EACCES: if i2c transaction is not allowed due to firewall rules
10734e871899SJon Hunter  *  -#BPMP_ETIMEDOUT: if i2c transaction times out
10744e871899SJon Hunter  *  -#BPMP_ENXIO: if i2c slave device does not reply with ACK to the transaction
10754e871899SJon Hunter  *  -#BPMP_EAGAIN: if ARB_LOST condition is detected by the i2c controller
10764e871899SJon Hunter  *  -#BPMP_EIO: any other i2c controller error code than NO_ACK or ARB_LOST
1077983de5f9SThierry Reding  */
1078983de5f9SThierry Reding struct mrq_i2c_response {
1079983de5f9SThierry Reding 	struct cmd_i2c_xfer_response xfer;
10804e871899SJon Hunter } BPMP_ABI_PACKED;
1081983de5f9SThierry Reding 
1082*b204b92bSPeter De Schrijver /** @} I2C */
10834bef358cSTimo Alho 
1084983de5f9SThierry Reding /**
1085983de5f9SThierry Reding  * @ingroup MRQ_Codes
1086983de5f9SThierry Reding  * @def MRQ_CLK
10874bef358cSTimo Alho  * @brief Perform a clock operation
1088983de5f9SThierry Reding  *
10894bef358cSTimo Alho  * * Platforms: T186, T194
1090983de5f9SThierry Reding  * * Initiators: Any
1091983de5f9SThierry Reding  * * Targets: BPMP
1092983de5f9SThierry Reding  * * Request Payload: @ref mrq_clk_request
1093983de5f9SThierry Reding  * * Response Payload: @ref mrq_clk_response
10944bef358cSTimo Alho  *
1095983de5f9SThierry Reding  * @addtogroup Clocks
1096983de5f9SThierry Reding  * @{
1097983de5f9SThierry Reding  */
1098983de5f9SThierry Reding enum {
1099983de5f9SThierry Reding 	CMD_CLK_GET_RATE = 1,
1100983de5f9SThierry Reding 	CMD_CLK_SET_RATE = 2,
1101983de5f9SThierry Reding 	CMD_CLK_ROUND_RATE = 3,
1102983de5f9SThierry Reding 	CMD_CLK_GET_PARENT = 4,
1103983de5f9SThierry Reding 	CMD_CLK_SET_PARENT = 5,
1104983de5f9SThierry Reding 	CMD_CLK_IS_ENABLED = 6,
1105983de5f9SThierry Reding 	CMD_CLK_ENABLE = 7,
1106983de5f9SThierry Reding 	CMD_CLK_DISABLE = 8,
1107*b204b92bSPeter De Schrijver /** @cond DEPRECATED */
1108*b204b92bSPeter De Schrijver 	CMD_CLK_PROPERTIES = 9,
1109*b204b92bSPeter De Schrijver 	CMD_CLK_POSSIBLE_PARENTS = 10,
1110*b204b92bSPeter De Schrijver 	CMD_CLK_NUM_POSSIBLE_PARENTS = 11,
1111*b204b92bSPeter De Schrijver 	CMD_CLK_GET_POSSIBLE_PARENT = 12,
1112*b204b92bSPeter De Schrijver 	CMD_CLK_RESET_REFCOUNTS = 13,
1113*b204b92bSPeter De Schrijver /** @endcond DEPRECATED */
1114983de5f9SThierry Reding 	CMD_CLK_GET_ALL_INFO = 14,
1115983de5f9SThierry Reding 	CMD_CLK_GET_MAX_CLK_ID = 15,
11164bef358cSTimo Alho 	CMD_CLK_GET_FMAX_AT_VMIN = 16,
1117983de5f9SThierry Reding 	CMD_CLK_MAX,
1118983de5f9SThierry Reding };
1119983de5f9SThierry Reding 
11204e871899SJon Hunter #define BPMP_CLK_HAS_MUX	(1U << 0U)
11214e871899SJon Hunter #define BPMP_CLK_HAS_SET_RATE	(1U << 1U)
11224e871899SJon Hunter #define BPMP_CLK_IS_ROOT	(1U << 2U)
11234e871899SJon Hunter #define BPMP_CLK_IS_VAR_ROOT	(1U << 3U)
1124*b204b92bSPeter De Schrijver /**
1125*b204b92bSPeter De Schrijver  * @brief Protection against rate and parent changes
1126*b204b92bSPeter De Schrijver  *
1127*b204b92bSPeter De Schrijver  * #MRQ_CLK command #CMD_CLK_SET_RATE or #MRQ_CLK command #CMD_CLK_SET_PARENT will return
1128*b204b92bSPeter De Schrijver  * -#BPMP_EACCES.
1129*b204b92bSPeter De Schrijver  */
1130*b204b92bSPeter De Schrijver #define BPMP_CLK_RATE_PARENT_CHANGE_DENIED (1U << 30)
1131*b204b92bSPeter De Schrijver 
1132*b204b92bSPeter De Schrijver /**
1133*b204b92bSPeter De Schrijver  * @brief Protection against state changes
1134*b204b92bSPeter De Schrijver  *
1135*b204b92bSPeter De Schrijver  * #MRQ_CLK command #CMD_CLK_ENABLE or #MRQ_CLK command #CMD_CLK_DISABLE will return
1136*b204b92bSPeter De Schrijver  * -#BPMP_EACCES.
1137*b204b92bSPeter De Schrijver  */
1138*b204b92bSPeter De Schrijver #define BPMP_CLK_STATE_CHANGE_DENIED (1U << 31)
113952b8b803SThierry Reding 
11404e871899SJon Hunter #define MRQ_CLK_NAME_MAXLEN	40U
11414e871899SJon Hunter #define MRQ_CLK_MAX_PARENTS	16U
1142983de5f9SThierry Reding 
1143983de5f9SThierry Reding /** @private */
1144983de5f9SThierry Reding struct cmd_clk_get_rate_request {
11454e871899SJon Hunter 	BPMP_ABI_EMPTY
11464e871899SJon Hunter } BPMP_ABI_PACKED;
1147983de5f9SThierry Reding 
1148983de5f9SThierry Reding struct cmd_clk_get_rate_response {
1149983de5f9SThierry Reding 	int64_t rate;
11504e871899SJon Hunter } BPMP_ABI_PACKED;
1151983de5f9SThierry Reding 
1152983de5f9SThierry Reding struct cmd_clk_set_rate_request {
1153983de5f9SThierry Reding 	int32_t unused;
1154983de5f9SThierry Reding 	int64_t rate;
11554e871899SJon Hunter } BPMP_ABI_PACKED;
1156983de5f9SThierry Reding 
1157983de5f9SThierry Reding struct cmd_clk_set_rate_response {
1158983de5f9SThierry Reding 	int64_t rate;
11594e871899SJon Hunter } BPMP_ABI_PACKED;
1160983de5f9SThierry Reding 
1161983de5f9SThierry Reding struct cmd_clk_round_rate_request {
1162983de5f9SThierry Reding 	int32_t unused;
1163983de5f9SThierry Reding 	int64_t rate;
11644e871899SJon Hunter } BPMP_ABI_PACKED;
1165983de5f9SThierry Reding 
1166983de5f9SThierry Reding struct cmd_clk_round_rate_response {
1167983de5f9SThierry Reding 	int64_t rate;
11684e871899SJon Hunter } BPMP_ABI_PACKED;
1169983de5f9SThierry Reding 
1170983de5f9SThierry Reding /** @private */
1171983de5f9SThierry Reding struct cmd_clk_get_parent_request {
11724e871899SJon Hunter 	BPMP_ABI_EMPTY
11734e871899SJon Hunter } BPMP_ABI_PACKED;
1174983de5f9SThierry Reding 
1175983de5f9SThierry Reding struct cmd_clk_get_parent_response {
1176983de5f9SThierry Reding 	uint32_t parent_id;
11774e871899SJon Hunter } BPMP_ABI_PACKED;
1178983de5f9SThierry Reding 
1179983de5f9SThierry Reding struct cmd_clk_set_parent_request {
1180983de5f9SThierry Reding 	uint32_t parent_id;
11814e871899SJon Hunter } BPMP_ABI_PACKED;
1182983de5f9SThierry Reding 
1183983de5f9SThierry Reding struct cmd_clk_set_parent_response {
1184983de5f9SThierry Reding 	uint32_t parent_id;
11854e871899SJon Hunter } BPMP_ABI_PACKED;
1186983de5f9SThierry Reding 
1187983de5f9SThierry Reding /** @private */
1188983de5f9SThierry Reding struct cmd_clk_is_enabled_request {
11894e871899SJon Hunter 	BPMP_ABI_EMPTY
11904e871899SJon Hunter } BPMP_ABI_PACKED;
1191983de5f9SThierry Reding 
11924e871899SJon Hunter /**
11934e871899SJon Hunter  * @brief Response data to #MRQ_CLK sub-command CMD_CLK_IS_ENABLED
11944e871899SJon Hunter  */
1195983de5f9SThierry Reding struct cmd_clk_is_enabled_response {
11964e871899SJon Hunter 	/**
11974e871899SJon Hunter 	 * @brief The state of the clock that has been succesfully
11984e871899SJon Hunter 	 * requested with CMD_CLK_ENABLE or CMD_CLK_DISABLE by the
11994e871899SJon Hunter 	 * master invoking the command earlier.
12004e871899SJon Hunter 	 *
12014e871899SJon Hunter 	 * The state may not reflect the physical state of the clock
12024e871899SJon Hunter 	 * if there are some other masters requesting it to be
12034e871899SJon Hunter 	 * enabled.
12044e871899SJon Hunter 	 *
12054e871899SJon Hunter 	 * Value 0 is disabled, all other values indicate enabled.
12064e871899SJon Hunter 	 */
1207983de5f9SThierry Reding 	int32_t state;
12084e871899SJon Hunter } BPMP_ABI_PACKED;
1209983de5f9SThierry Reding 
1210983de5f9SThierry Reding /** @private */
1211983de5f9SThierry Reding struct cmd_clk_enable_request {
12124e871899SJon Hunter 	BPMP_ABI_EMPTY
12134e871899SJon Hunter } BPMP_ABI_PACKED;
1214983de5f9SThierry Reding 
1215983de5f9SThierry Reding /** @private */
1216983de5f9SThierry Reding struct cmd_clk_enable_response {
12174e871899SJon Hunter 	BPMP_ABI_EMPTY
12184e871899SJon Hunter } BPMP_ABI_PACKED;
1219983de5f9SThierry Reding 
1220983de5f9SThierry Reding /** @private */
1221983de5f9SThierry Reding struct cmd_clk_disable_request {
12224e871899SJon Hunter 	BPMP_ABI_EMPTY
12234e871899SJon Hunter } BPMP_ABI_PACKED;
1224983de5f9SThierry Reding 
1225983de5f9SThierry Reding /** @private */
1226983de5f9SThierry Reding struct cmd_clk_disable_response {
12274e871899SJon Hunter 	BPMP_ABI_EMPTY
12284e871899SJon Hunter } BPMP_ABI_PACKED;
1229983de5f9SThierry Reding 
1230*b204b92bSPeter De Schrijver /** @cond DEPRECATED */
1231*b204b92bSPeter De Schrijver /** @private */
1232*b204b92bSPeter De Schrijver struct cmd_clk_properties_request {
1233*b204b92bSPeter De Schrijver 	BPMP_ABI_EMPTY
1234*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1235*b204b92bSPeter De Schrijver 
1236*b204b92bSPeter De Schrijver /** @todo flags need to be spelled out here */
1237*b204b92bSPeter De Schrijver struct cmd_clk_properties_response {
1238*b204b92bSPeter De Schrijver 	uint32_t flags;
1239*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1240*b204b92bSPeter De Schrijver 
1241*b204b92bSPeter De Schrijver /** @private */
1242*b204b92bSPeter De Schrijver struct cmd_clk_possible_parents_request {
1243*b204b92bSPeter De Schrijver 	BPMP_ABI_EMPTY
1244*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1245*b204b92bSPeter De Schrijver 
1246*b204b92bSPeter De Schrijver struct cmd_clk_possible_parents_response {
1247*b204b92bSPeter De Schrijver 	uint8_t num_parents;
1248*b204b92bSPeter De Schrijver 	uint8_t reserved[3];
1249*b204b92bSPeter De Schrijver 	uint32_t parent_id[MRQ_CLK_MAX_PARENTS];
1250*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1251*b204b92bSPeter De Schrijver 
1252*b204b92bSPeter De Schrijver /** @private */
1253*b204b92bSPeter De Schrijver struct cmd_clk_num_possible_parents_request {
1254*b204b92bSPeter De Schrijver 	BPMP_ABI_EMPTY
1255*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1256*b204b92bSPeter De Schrijver 
1257*b204b92bSPeter De Schrijver struct cmd_clk_num_possible_parents_response {
1258*b204b92bSPeter De Schrijver 	uint8_t num_parents;
1259*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1260*b204b92bSPeter De Schrijver 
1261*b204b92bSPeter De Schrijver struct cmd_clk_get_possible_parent_request {
1262*b204b92bSPeter De Schrijver 	uint8_t parent_idx;
1263*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1264*b204b92bSPeter De Schrijver 
1265*b204b92bSPeter De Schrijver struct cmd_clk_get_possible_parent_response {
1266*b204b92bSPeter De Schrijver 	uint32_t parent_id;
1267*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1268*b204b92bSPeter De Schrijver /** @endcond DEPRECATED */
1269*b204b92bSPeter De Schrijver 
1270983de5f9SThierry Reding /** @private */
1271983de5f9SThierry Reding struct cmd_clk_get_all_info_request {
12724e871899SJon Hunter 	BPMP_ABI_EMPTY
12734e871899SJon Hunter } BPMP_ABI_PACKED;
1274983de5f9SThierry Reding 
1275983de5f9SThierry Reding struct cmd_clk_get_all_info_response {
1276983de5f9SThierry Reding 	uint32_t flags;
1277983de5f9SThierry Reding 	uint32_t parent;
1278983de5f9SThierry Reding 	uint32_t parents[MRQ_CLK_MAX_PARENTS];
1279983de5f9SThierry Reding 	uint8_t num_parents;
1280983de5f9SThierry Reding 	uint8_t name[MRQ_CLK_NAME_MAXLEN];
12814e871899SJon Hunter } BPMP_ABI_PACKED;
1282983de5f9SThierry Reding 
1283983de5f9SThierry Reding /** @private */
1284983de5f9SThierry Reding struct cmd_clk_get_max_clk_id_request {
12854e871899SJon Hunter 	BPMP_ABI_EMPTY
12864e871899SJon Hunter } BPMP_ABI_PACKED;
1287983de5f9SThierry Reding 
1288983de5f9SThierry Reding struct cmd_clk_get_max_clk_id_response {
1289983de5f9SThierry Reding 	uint32_t max_id;
12904e871899SJon Hunter } BPMP_ABI_PACKED;
12914bef358cSTimo Alho 
12924bef358cSTimo Alho /** @private */
12934bef358cSTimo Alho struct cmd_clk_get_fmax_at_vmin_request {
12944e871899SJon Hunter 	BPMP_ABI_EMPTY
12954e871899SJon Hunter } BPMP_ABI_PACKED;
12964bef358cSTimo Alho 
12974bef358cSTimo Alho struct cmd_clk_get_fmax_at_vmin_response {
12984bef358cSTimo Alho 	int64_t rate;
12994e871899SJon Hunter } BPMP_ABI_PACKED;
1300983de5f9SThierry Reding 
1301*b204b92bSPeter De Schrijver 
1302983de5f9SThierry Reding /**
1303983de5f9SThierry Reding  * @ingroup Clocks
13044bef358cSTimo Alho  * @brief Request with #MRQ_CLK
1305983de5f9SThierry Reding  *
1306983de5f9SThierry Reding  * Used by the sender of an #MRQ_CLK message to control clocks. The
1307983de5f9SThierry Reding  * clk_request is split into several sub-commands. Some sub-commands
1308983de5f9SThierry Reding  * require no additional data. Others have a sub-command specific
1309983de5f9SThierry Reding  * payload
1310983de5f9SThierry Reding  *
1311983de5f9SThierry Reding  * |sub-command                 |payload                |
1312983de5f9SThierry Reding  * |----------------------------|-----------------------|
1313983de5f9SThierry Reding  * |CMD_CLK_GET_RATE            |-                      |
1314983de5f9SThierry Reding  * |CMD_CLK_SET_RATE            |clk_set_rate           |
1315983de5f9SThierry Reding  * |CMD_CLK_ROUND_RATE          |clk_round_rate         |
1316983de5f9SThierry Reding  * |CMD_CLK_GET_PARENT          |-                      |
1317983de5f9SThierry Reding  * |CMD_CLK_SET_PARENT          |clk_set_parent         |
1318983de5f9SThierry Reding  * |CMD_CLK_IS_ENABLED          |-                      |
1319983de5f9SThierry Reding  * |CMD_CLK_ENABLE              |-                      |
1320983de5f9SThierry Reding  * |CMD_CLK_DISABLE             |-                      |
1321983de5f9SThierry Reding  * |CMD_CLK_GET_ALL_INFO        |-                      |
1322983de5f9SThierry Reding  * |CMD_CLK_GET_MAX_CLK_ID      |-                      |
13234bef358cSTimo Alho  * |CMD_CLK_GET_FMAX_AT_VMIN    |-
13244bef358cSTimo Alho  * |
1325983de5f9SThierry Reding  *
1326983de5f9SThierry Reding  */
1327983de5f9SThierry Reding 
1328*b204b92bSPeter De Schrijver /** @cond DEPRECATED
1329*b204b92bSPeter De Schrijver  *
1330*b204b92bSPeter De Schrijver  * Older versions of firmware also supported following sub-commands:
1331*b204b92bSPeter De Schrijver  * |CMD_CLK_PROPERTIES          |-                      |
1332*b204b92bSPeter De Schrijver  * |CMD_CLK_POSSIBLE_PARENTS    |-                      |
1333*b204b92bSPeter De Schrijver  * |CMD_CLK_NUM_POSSIBLE_PARENTS|-                      |
1334*b204b92bSPeter De Schrijver  * |CMD_CLK_GET_POSSIBLE_PARENT |clk_get_possible_parent|
1335*b204b92bSPeter De Schrijver  * |CMD_CLK_RESET_REFCOUNTS     |-                      |
1336*b204b92bSPeter De Schrijver  *
1337*b204b92bSPeter De Schrijver  * @endcond DEPRECATED */
1338*b204b92bSPeter De Schrijver 
1339983de5f9SThierry Reding struct mrq_clk_request {
13404bef358cSTimo Alho 	/** @brief Sub-command and clock id concatenated to 32-bit word.
1341983de5f9SThierry Reding 	 * - bits[31..24] is the sub-cmd.
1342983de5f9SThierry Reding 	 * - bits[23..0] is the clock id
1343983de5f9SThierry Reding 	 */
1344983de5f9SThierry Reding 	uint32_t cmd_and_id;
1345983de5f9SThierry Reding 
1346983de5f9SThierry Reding 	union {
1347983de5f9SThierry Reding 		/** @private */
1348983de5f9SThierry Reding 		struct cmd_clk_get_rate_request clk_get_rate;
1349983de5f9SThierry Reding 		struct cmd_clk_set_rate_request clk_set_rate;
1350983de5f9SThierry Reding 		struct cmd_clk_round_rate_request clk_round_rate;
1351983de5f9SThierry Reding 		/** @private */
1352983de5f9SThierry Reding 		struct cmd_clk_get_parent_request clk_get_parent;
1353983de5f9SThierry Reding 		struct cmd_clk_set_parent_request clk_set_parent;
1354983de5f9SThierry Reding 		/** @private */
1355983de5f9SThierry Reding 		struct cmd_clk_enable_request clk_enable;
1356983de5f9SThierry Reding 		/** @private */
1357983de5f9SThierry Reding 		struct cmd_clk_disable_request clk_disable;
1358983de5f9SThierry Reding 		/** @private */
1359983de5f9SThierry Reding 		struct cmd_clk_is_enabled_request clk_is_enabled;
1360*b204b92bSPeter De Schrijver 		/** @cond DEPRECATED */
1361*b204b92bSPeter De Schrijver 		/** @private */
1362*b204b92bSPeter De Schrijver 		struct cmd_clk_properties_request clk_properties;
1363*b204b92bSPeter De Schrijver 		/** @private */
1364*b204b92bSPeter De Schrijver 		struct cmd_clk_possible_parents_request clk_possible_parents;
1365*b204b92bSPeter De Schrijver 		/** @private */
1366*b204b92bSPeter De Schrijver 		struct cmd_clk_num_possible_parents_request clk_num_possible_parents;
1367*b204b92bSPeter De Schrijver 		struct cmd_clk_get_possible_parent_request clk_get_possible_parent;
1368*b204b92bSPeter De Schrijver 		/** @endcond DEPRECATED */
1369983de5f9SThierry Reding 		/** @private */
1370983de5f9SThierry Reding 		struct cmd_clk_get_all_info_request clk_get_all_info;
1371983de5f9SThierry Reding 		/** @private */
1372983de5f9SThierry Reding 		struct cmd_clk_get_max_clk_id_request clk_get_max_clk_id;
13734bef358cSTimo Alho 		/** @private */
13744bef358cSTimo Alho 		struct cmd_clk_get_fmax_at_vmin_request clk_get_fmax_at_vmin;
13754e871899SJon Hunter 	} BPMP_UNION_ANON;
13764e871899SJon Hunter } BPMP_ABI_PACKED;
1377983de5f9SThierry Reding 
1378983de5f9SThierry Reding /**
1379983de5f9SThierry Reding  * @ingroup Clocks
13804bef358cSTimo Alho  * @brief Response to MRQ_CLK
1381983de5f9SThierry Reding  *
1382983de5f9SThierry Reding  * Each sub-command supported by @ref mrq_clk_request may return
1383983de5f9SThierry Reding  * sub-command-specific data. Some do and some do not as indicated in
1384983de5f9SThierry Reding  * the following table
1385983de5f9SThierry Reding  *
1386983de5f9SThierry Reding  * |sub-command                 |payload                 |
1387983de5f9SThierry Reding  * |----------------------------|------------------------|
1388983de5f9SThierry Reding  * |CMD_CLK_GET_RATE            |clk_get_rate            |
1389983de5f9SThierry Reding  * |CMD_CLK_SET_RATE            |clk_set_rate            |
1390983de5f9SThierry Reding  * |CMD_CLK_ROUND_RATE          |clk_round_rate          |
1391983de5f9SThierry Reding  * |CMD_CLK_GET_PARENT          |clk_get_parent          |
1392983de5f9SThierry Reding  * |CMD_CLK_SET_PARENT          |clk_set_parent          |
1393983de5f9SThierry Reding  * |CMD_CLK_IS_ENABLED          |clk_is_enabled          |
1394983de5f9SThierry Reding  * |CMD_CLK_ENABLE              |-                       |
1395983de5f9SThierry Reding  * |CMD_CLK_DISABLE             |-                       |
1396983de5f9SThierry Reding  * |CMD_CLK_GET_ALL_INFO        |clk_get_all_info        |
1397983de5f9SThierry Reding  * |CMD_CLK_GET_MAX_CLK_ID      |clk_get_max_id          |
13984bef358cSTimo Alho  * |CMD_CLK_GET_FMAX_AT_VMIN    |clk_get_fmax_at_vmin    |
1399983de5f9SThierry Reding  *
1400983de5f9SThierry Reding  */
1401983de5f9SThierry Reding 
1402*b204b92bSPeter De Schrijver /** @cond DEPRECATED
1403*b204b92bSPeter De Schrijver  *
1404*b204b92bSPeter De Schrijver  * Older versions of firmware also supported following sub-commands:
1405*b204b92bSPeter De Schrijver  * |CMD_CLK_PROPERTIES          |clk_properties          |
1406*b204b92bSPeter De Schrijver  * |CMD_CLK_POSSIBLE_PARENTS    |clk_possible_parents    |
1407*b204b92bSPeter De Schrijver  * |CMD_CLK_NUM_POSSIBLE_PARENTS|clk_num_possible_parents|
1408*b204b92bSPeter De Schrijver  * |CMD_CLK_GET_POSSIBLE_PARENT |clk_get_possible_parents|
1409*b204b92bSPeter De Schrijver  * |CMD_CLK_RESET_REFCOUNTS     |-                       |
1410*b204b92bSPeter De Schrijver  *
1411*b204b92bSPeter De Schrijver  * @endcond DEPRECATED */
1412*b204b92bSPeter De Schrijver 
1413983de5f9SThierry Reding struct mrq_clk_response {
1414983de5f9SThierry Reding 	union {
1415983de5f9SThierry Reding 		struct cmd_clk_get_rate_response clk_get_rate;
1416983de5f9SThierry Reding 		struct cmd_clk_set_rate_response clk_set_rate;
1417983de5f9SThierry Reding 		struct cmd_clk_round_rate_response clk_round_rate;
1418983de5f9SThierry Reding 		struct cmd_clk_get_parent_response clk_get_parent;
1419983de5f9SThierry Reding 		struct cmd_clk_set_parent_response clk_set_parent;
1420983de5f9SThierry Reding 		/** @private */
1421983de5f9SThierry Reding 		struct cmd_clk_enable_response clk_enable;
1422983de5f9SThierry Reding 		/** @private */
1423983de5f9SThierry Reding 		struct cmd_clk_disable_response clk_disable;
1424983de5f9SThierry Reding 		struct cmd_clk_is_enabled_response clk_is_enabled;
1425*b204b92bSPeter De Schrijver 		/** @cond DEPRECATED */
1426*b204b92bSPeter De Schrijver 		struct cmd_clk_properties_response clk_properties;
1427*b204b92bSPeter De Schrijver 		struct cmd_clk_possible_parents_response clk_possible_parents;
1428*b204b92bSPeter De Schrijver 		struct cmd_clk_num_possible_parents_response clk_num_possible_parents;
1429*b204b92bSPeter De Schrijver 		struct cmd_clk_get_possible_parent_response clk_get_possible_parent;
1430*b204b92bSPeter De Schrijver 		/** @endcond DEPRECATED */
1431983de5f9SThierry Reding 		struct cmd_clk_get_all_info_response clk_get_all_info;
1432983de5f9SThierry Reding 		struct cmd_clk_get_max_clk_id_response clk_get_max_clk_id;
14334bef358cSTimo Alho 		struct cmd_clk_get_fmax_at_vmin_response clk_get_fmax_at_vmin;
14344e871899SJon Hunter 	} BPMP_UNION_ANON;
14354e871899SJon Hunter } BPMP_ABI_PACKED;
1436983de5f9SThierry Reding 
1437*b204b92bSPeter De Schrijver /** @} Clocks */
14384bef358cSTimo Alho 
1439983de5f9SThierry Reding /**
1440983de5f9SThierry Reding  * @ingroup MRQ_Codes
1441983de5f9SThierry Reding  * @def MRQ_QUERY_ABI
14424bef358cSTimo Alho  * @brief Check if an MRQ is implemented
1443983de5f9SThierry Reding  *
1444983de5f9SThierry Reding  * * Platforms: All
1445983de5f9SThierry Reding  * * Initiators: Any
144652b8b803SThierry Reding  * * Targets: Any except DMCE
1447983de5f9SThierry Reding  * * Request Payload: @ref mrq_query_abi_request
1448983de5f9SThierry Reding  * * Response Payload: @ref mrq_query_abi_response
1449983de5f9SThierry Reding  */
1450983de5f9SThierry Reding 
1451983de5f9SThierry Reding /**
1452983de5f9SThierry Reding  * @ingroup ABI_info
14534bef358cSTimo Alho  * @brief Request with MRQ_QUERY_ABI
1454983de5f9SThierry Reding  *
1455983de5f9SThierry Reding  * Used by #MRQ_QUERY_ABI call to check if MRQ code #mrq is supported
1456983de5f9SThierry Reding  * by the recipient.
1457983de5f9SThierry Reding  */
1458983de5f9SThierry Reding struct mrq_query_abi_request {
1459983de5f9SThierry Reding 	/** @brief MRQ code to query */
1460983de5f9SThierry Reding 	uint32_t mrq;
14614e871899SJon Hunter } BPMP_ABI_PACKED;
1462983de5f9SThierry Reding 
1463983de5f9SThierry Reding /**
1464983de5f9SThierry Reding  * @ingroup ABI_info
14654bef358cSTimo Alho  * @brief Response to MRQ_QUERY_ABI
146652b8b803SThierry Reding  *
146752b8b803SThierry Reding  * @note mrq_response::err of 0 indicates that the query was
146852b8b803SThierry Reding  * successful, not that the MRQ itself is supported!
1469983de5f9SThierry Reding  */
1470983de5f9SThierry Reding struct mrq_query_abi_response {
1471983de5f9SThierry Reding 	/** @brief 0 if queried MRQ is supported. Else, -#BPMP_ENODEV */
1472983de5f9SThierry Reding 	int32_t status;
14734e871899SJon Hunter } BPMP_ABI_PACKED;
1474983de5f9SThierry Reding 
1475983de5f9SThierry Reding /**
1476983de5f9SThierry Reding  *
1477983de5f9SThierry Reding  * @ingroup MRQ_Codes
147852b8b803SThierry Reding  * @def MRQ_PG
147952b8b803SThierry Reding  * @brief Control power-gating state of a partition. In contrast to
148052b8b803SThierry Reding  * MRQ_PG_UPDATE_STATE, operations that change the power partition
148152b8b803SThierry Reding  * state are NOT reference counted
148252b8b803SThierry Reding  *
1483*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t186)
1484*b204b92bSPeter De Schrijver  * @note On T194 and earlier BPMP-FW forcefully turns off some partitions as
1485*b204b92bSPeter De Schrijver  * part of SC7 entry because their state cannot be adequately restored on exit.
1486*b204b92bSPeter De Schrijver  * Therefore, it is recommended to power off all domains via MRQ_PG prior to SC7
1487*b204b92bSPeter De Schrijver  * entry.
14884bef358cSTimo Alho  * See @ref bpmp_pdomain_ids for further detail.
1489*b204b92bSPeter De Schrijver  * @endcond (bpmp_t194 || bpmp_t186)
14904bef358cSTimo Alho  *
14914bef358cSTimo Alho  * * Platforms: T186, T194
149252b8b803SThierry Reding  * * Initiators: Any
149352b8b803SThierry Reding  * * Targets: BPMP
149452b8b803SThierry Reding  * * Request Payload: @ref mrq_pg_request
149552b8b803SThierry Reding  * * Response Payload: @ref mrq_pg_response
14964bef358cSTimo Alho  *
149752b8b803SThierry Reding  * @addtogroup Powergating
149852b8b803SThierry Reding  * @{
149952b8b803SThierry Reding  */
150052b8b803SThierry Reding enum mrq_pg_cmd {
150152b8b803SThierry Reding 	/**
150252b8b803SThierry Reding 	 * @brief Check whether the BPMP driver supports the specified
150352b8b803SThierry Reding 	 * request type
150452b8b803SThierry Reding 	 *
150552b8b803SThierry Reding 	 * mrq_response::err is 0 if the specified request is
150652b8b803SThierry Reding 	 * supported and -#BPMP_ENODEV otherwise.
150752b8b803SThierry Reding 	 */
150852b8b803SThierry Reding 	CMD_PG_QUERY_ABI = 0,
150952b8b803SThierry Reding 
151052b8b803SThierry Reding 	/**
151152b8b803SThierry Reding 	 * @brief Set the current state of specified power domain. The
151252b8b803SThierry Reding 	 * possible values for power domains are defined in enum
151352b8b803SThierry Reding 	 * pg_states
151452b8b803SThierry Reding 	 *
151552b8b803SThierry Reding 	 * mrq_response:err is
151652b8b803SThierry Reding 	 * 0: Success
151752b8b803SThierry Reding 	 * -#BPMP_EINVAL: Invalid request parameters
151852b8b803SThierry Reding 	 */
151952b8b803SThierry Reding 	CMD_PG_SET_STATE = 1,
152052b8b803SThierry Reding 
152152b8b803SThierry Reding 	/**
152252b8b803SThierry Reding 	 * @brief Get the current state of specified power domain. The
152352b8b803SThierry Reding 	 * possible values for power domains are defined in enum
152452b8b803SThierry Reding 	 * pg_states
152552b8b803SThierry Reding 	 *
152652b8b803SThierry Reding 	 * mrq_response:err is
152752b8b803SThierry Reding 	 * 0: Success
152852b8b803SThierry Reding 	 * -#BPMP_EINVAL: Invalid request parameters
152952b8b803SThierry Reding 	 */
153052b8b803SThierry Reding 	CMD_PG_GET_STATE = 2,
153152b8b803SThierry Reding 
153252b8b803SThierry Reding 	/**
15334bef358cSTimo Alho 	 * @brief Get the name string of specified power domain id.
153452b8b803SThierry Reding 	 *
153552b8b803SThierry Reding 	 * mrq_response:err is
153652b8b803SThierry Reding 	 * 0: Success
153752b8b803SThierry Reding 	 * -#BPMP_EINVAL: Invalid request parameters
153852b8b803SThierry Reding 	 */
153952b8b803SThierry Reding 	CMD_PG_GET_NAME = 3,
154052b8b803SThierry Reding 
154152b8b803SThierry Reding 
154252b8b803SThierry Reding 	/**
15434bef358cSTimo Alho 	 * @brief Get the highest power domain id in the system. Not
154452b8b803SThierry Reding 	 * all IDs between 0 and max_id are valid IDs.
154552b8b803SThierry Reding 	 *
154652b8b803SThierry Reding 	 * mrq_response:err is
154752b8b803SThierry Reding 	 * 0: Success
154852b8b803SThierry Reding 	 * -#BPMP_EINVAL: Invalid request parameters
154952b8b803SThierry Reding 	 */
155052b8b803SThierry Reding 	CMD_PG_GET_MAX_ID = 4,
155152b8b803SThierry Reding };
155252b8b803SThierry Reding 
155352b8b803SThierry Reding #define MRQ_PG_NAME_MAXLEN	40
155452b8b803SThierry Reding 
155552b8b803SThierry Reding enum pg_states {
15564bef358cSTimo Alho 	/** @brief Power domain is OFF */
155752b8b803SThierry Reding 	PG_STATE_OFF = 0,
15584bef358cSTimo Alho 	/** @brief Power domain is ON */
155952b8b803SThierry Reding 	PG_STATE_ON = 1,
15604bef358cSTimo Alho 	/**
15614bef358cSTimo Alho 	 * @brief a legacy state where power domain and the clock
15624bef358cSTimo Alho 	 * associated to the domain are ON.
15634bef358cSTimo Alho 	 * This state is only supported in T186, and the use of it is
15644bef358cSTimo Alho 	 * deprecated.
15654bef358cSTimo Alho 	 */
156652b8b803SThierry Reding 	PG_STATE_RUNNING = 2,
156752b8b803SThierry Reding };
156852b8b803SThierry Reding 
156952b8b803SThierry Reding struct cmd_pg_query_abi_request {
15704bef358cSTimo Alho 	/** @ref mrq_pg_cmd */
15714bef358cSTimo Alho 	uint32_t type;
15724e871899SJon Hunter } BPMP_ABI_PACKED;
157352b8b803SThierry Reding 
157452b8b803SThierry Reding struct cmd_pg_set_state_request {
15754bef358cSTimo Alho 	/** @ref pg_states */
15764bef358cSTimo Alho 	uint32_t state;
15774e871899SJon Hunter } BPMP_ABI_PACKED;
157852b8b803SThierry Reding 
15794e871899SJon Hunter /**
15804e871899SJon Hunter  * @brief Response data to #MRQ_PG sub command #CMD_PG_GET_STATE
15814e871899SJon Hunter  */
158252b8b803SThierry Reding struct cmd_pg_get_state_response {
15834e871899SJon Hunter 	/**
15844e871899SJon Hunter 	 * @brief The state of the power partition that has been
15854e871899SJon Hunter 	 * succesfuly requested by the master earlier using #MRQ_PG
15864e871899SJon Hunter 	 * command #CMD_PG_SET_STATE.
15874e871899SJon Hunter 	 *
15884e871899SJon Hunter 	 * The state may not reflect the physical state of the power
15894e871899SJon Hunter 	 * partition if there are some other masters requesting it to
15904e871899SJon Hunter 	 * be enabled.
15914e871899SJon Hunter 	 *
15924e871899SJon Hunter 	 * See @ref pg_states for possible values
15934e871899SJon Hunter 	 */
15944bef358cSTimo Alho 	uint32_t state;
15954e871899SJon Hunter } BPMP_ABI_PACKED;
159652b8b803SThierry Reding 
159752b8b803SThierry Reding struct cmd_pg_get_name_response {
159852b8b803SThierry Reding 	uint8_t name[MRQ_PG_NAME_MAXLEN];
15994e871899SJon Hunter } BPMP_ABI_PACKED;
160052b8b803SThierry Reding 
160152b8b803SThierry Reding struct cmd_pg_get_max_id_response {
160252b8b803SThierry Reding 	uint32_t max_id;
16034e871899SJon Hunter } BPMP_ABI_PACKED;
160452b8b803SThierry Reding 
160552b8b803SThierry Reding /**
16064bef358cSTimo Alho  * @brief Request with #MRQ_PG
160752b8b803SThierry Reding  *
160852b8b803SThierry Reding  * Used by the sender of an #MRQ_PG message to control power
160952b8b803SThierry Reding  * partitions. The pg_request is split into several sub-commands. Some
161052b8b803SThierry Reding  * sub-commands require no additional data. Others have a sub-command
161152b8b803SThierry Reding  * specific payload
161252b8b803SThierry Reding  *
161352b8b803SThierry Reding  * |sub-command                 |payload                |
161452b8b803SThierry Reding  * |----------------------------|-----------------------|
161552b8b803SThierry Reding  * |CMD_PG_QUERY_ABI            | query_abi             |
161652b8b803SThierry Reding  * |CMD_PG_SET_STATE            | set_state             |
161752b8b803SThierry Reding  * |CMD_PG_GET_STATE            | -                     |
161852b8b803SThierry Reding  * |CMD_PG_GET_NAME             | -                     |
161952b8b803SThierry Reding  * |CMD_PG_GET_MAX_ID           | -                     |
162052b8b803SThierry Reding  *
162152b8b803SThierry Reding  */
162252b8b803SThierry Reding struct mrq_pg_request {
162352b8b803SThierry Reding 	uint32_t cmd;
162452b8b803SThierry Reding 	uint32_t id;
162552b8b803SThierry Reding 	union {
162652b8b803SThierry Reding 		struct cmd_pg_query_abi_request query_abi;
162752b8b803SThierry Reding 		struct cmd_pg_set_state_request set_state;
16284e871899SJon Hunter 	} BPMP_UNION_ANON;
16294e871899SJon Hunter } BPMP_ABI_PACKED;
163052b8b803SThierry Reding 
163152b8b803SThierry Reding /**
16324bef358cSTimo Alho  * @brief Response to MRQ_PG
163352b8b803SThierry Reding  *
163452b8b803SThierry Reding  * Each sub-command supported by @ref mrq_pg_request may return
163552b8b803SThierry Reding  * sub-command-specific data. Some do and some do not as indicated in
163652b8b803SThierry Reding  * the following table
163752b8b803SThierry Reding  *
163852b8b803SThierry Reding  * |sub-command                 |payload                |
163952b8b803SThierry Reding  * |----------------------------|-----------------------|
164052b8b803SThierry Reding  * |CMD_PG_QUERY_ABI            | -                     |
164152b8b803SThierry Reding  * |CMD_PG_SET_STATE            | -                     |
164252b8b803SThierry Reding  * |CMD_PG_GET_STATE            | get_state             |
164352b8b803SThierry Reding  * |CMD_PG_GET_NAME             | get_name              |
164452b8b803SThierry Reding  * |CMD_PG_GET_MAX_ID           | get_max_id            |
164552b8b803SThierry Reding  */
164652b8b803SThierry Reding struct mrq_pg_response {
164752b8b803SThierry Reding 	union {
164852b8b803SThierry Reding 		struct cmd_pg_get_state_response get_state;
164952b8b803SThierry Reding 		struct cmd_pg_get_name_response get_name;
165052b8b803SThierry Reding 		struct cmd_pg_get_max_id_response get_max_id;
16514e871899SJon Hunter 	} BPMP_UNION_ANON;
16524e871899SJon Hunter } BPMP_ABI_PACKED;
165352b8b803SThierry Reding 
1654*b204b92bSPeter De Schrijver /** @} Powergating */
16554bef358cSTimo Alho 
165652b8b803SThierry Reding /**
165752b8b803SThierry Reding  * @ingroup MRQ_Codes
1658983de5f9SThierry Reding  * @def MRQ_THERMAL
16594bef358cSTimo Alho  * @brief Interact with BPMP thermal framework
1660983de5f9SThierry Reding  *
16614bef358cSTimo Alho  * * Platforms: T186, T194
1662983de5f9SThierry Reding  * * Initiators: Any
1663983de5f9SThierry Reding  * * Targets: Any
1664983de5f9SThierry Reding  * * Request Payload: TODO
1665983de5f9SThierry Reding  * * Response Payload: TODO
1666983de5f9SThierry Reding  *
1667983de5f9SThierry Reding  * @addtogroup Thermal
1668983de5f9SThierry Reding  *
1669983de5f9SThierry Reding  * The BPMP firmware includes a thermal framework. Drivers within the
1670983de5f9SThierry Reding  * bpmp firmware register with the framework to provide thermal
1671983de5f9SThierry Reding  * zones. Each thermal zone corresponds to an entity whose temperature
1672983de5f9SThierry Reding  * can be measured. The framework also has a notion of trip points. A
1673983de5f9SThierry Reding  * trip point consists of a thermal zone id, a temperature, and a
1674983de5f9SThierry Reding  * callback routine. The framework invokes the callback when the zone
1675983de5f9SThierry Reding  * hits the indicated temperature. The BPMP firmware uses this thermal
1676983de5f9SThierry Reding  * framework interally to implement various temperature-dependent
1677983de5f9SThierry Reding  * functions.
1678983de5f9SThierry Reding  *
1679983de5f9SThierry Reding  * Software on the CPU can use #MRQ_THERMAL (with payload @ref
1680983de5f9SThierry Reding  * mrq_thermal_host_to_bpmp_request) to interact with the BPMP thermal
1681983de5f9SThierry Reding  * framework. The CPU must It can query the number of supported zones,
1682983de5f9SThierry Reding  * query zone temperatures, and set trip points.
1683983de5f9SThierry Reding  *
1684983de5f9SThierry Reding  * When a trip point set by the CPU gets crossed, BPMP firmware issues
1685983de5f9SThierry Reding  * an IPC to the CPU having mrq_request::mrq = #MRQ_THERMAL and a
1686983de5f9SThierry Reding  * payload of @ref mrq_thermal_bpmp_to_host_request.
1687983de5f9SThierry Reding  * @{
1688983de5f9SThierry Reding  */
1689983de5f9SThierry Reding enum mrq_thermal_host_to_bpmp_cmd {
1690983de5f9SThierry Reding 	/**
1691983de5f9SThierry Reding 	 * @brief Check whether the BPMP driver supports the specified
1692983de5f9SThierry Reding 	 * request type.
1693983de5f9SThierry Reding 	 *
1694983de5f9SThierry Reding 	 * Host needs to supply request parameters.
1695983de5f9SThierry Reding 	 *
1696983de5f9SThierry Reding 	 * mrq_response::err is 0 if the specified request is
1697983de5f9SThierry Reding 	 * supported and -#BPMP_ENODEV otherwise.
1698983de5f9SThierry Reding 	 */
1699983de5f9SThierry Reding 	CMD_THERMAL_QUERY_ABI = 0,
1700983de5f9SThierry Reding 
1701983de5f9SThierry Reding 	/**
1702983de5f9SThierry Reding 	 * @brief Get the current temperature of the specified zone.
1703983de5f9SThierry Reding 	 *
1704983de5f9SThierry Reding 	 * Host needs to supply request parameters.
1705983de5f9SThierry Reding 	 *
1706983de5f9SThierry Reding 	 * mrq_response::err is
1707983de5f9SThierry Reding 	 * *  0: Temperature query succeeded.
1708983de5f9SThierry Reding 	 * *  -#BPMP_EINVAL: Invalid request parameters.
1709983de5f9SThierry Reding 	 * *  -#BPMP_ENOENT: No driver registered for thermal zone..
1710983de5f9SThierry Reding 	 * *  -#BPMP_EFAULT: Problem reading temperature measurement.
1711983de5f9SThierry Reding 	 */
1712983de5f9SThierry Reding 	CMD_THERMAL_GET_TEMP = 1,
1713983de5f9SThierry Reding 
1714983de5f9SThierry Reding 	/**
1715983de5f9SThierry Reding 	 * @brief Enable or disable and set the lower and upper
1716983de5f9SThierry Reding 	 *   thermal limits for a thermal trip point. Each zone has
1717983de5f9SThierry Reding 	 *   one trip point.
1718983de5f9SThierry Reding 	 *
1719983de5f9SThierry Reding 	 * Host needs to supply request parameters. Once the
1720983de5f9SThierry Reding 	 * temperature hits a trip point, the BPMP will send a message
1721983de5f9SThierry Reding 	 * to the CPU having MRQ=MRQ_THERMAL and
1722983de5f9SThierry Reding 	 * type=CMD_THERMAL_HOST_TRIP_REACHED
1723983de5f9SThierry Reding 	 *
1724983de5f9SThierry Reding 	 * mrq_response::err is
1725983de5f9SThierry Reding 	 * *  0: Trip successfully set.
1726983de5f9SThierry Reding 	 * *  -#BPMP_EINVAL: Invalid request parameters.
1727983de5f9SThierry Reding 	 * *  -#BPMP_ENOENT: No driver registered for thermal zone.
1728983de5f9SThierry Reding 	 * *  -#BPMP_EFAULT: Problem setting trip point.
1729983de5f9SThierry Reding 	 */
1730983de5f9SThierry Reding 	CMD_THERMAL_SET_TRIP = 2,
1731983de5f9SThierry Reding 
1732983de5f9SThierry Reding 	/**
1733983de5f9SThierry Reding 	 * @brief Get the number of supported thermal zones.
1734983de5f9SThierry Reding 	 *
1735983de5f9SThierry Reding 	 * No request parameters required.
1736983de5f9SThierry Reding 	 *
1737983de5f9SThierry Reding 	 * mrq_response::err is always 0, indicating success.
1738983de5f9SThierry Reding 	 */
1739983de5f9SThierry Reding 	CMD_THERMAL_GET_NUM_ZONES = 3,
1740983de5f9SThierry Reding 
17414e871899SJon Hunter 	/**
17424e871899SJon Hunter 	 * @brief Get the thermtrip of the specified zone.
17434e871899SJon Hunter 	 *
17444e871899SJon Hunter 	 * Host needs to supply request parameters.
17454e871899SJon Hunter 	 *
17464e871899SJon Hunter 	 * mrq_response::err is
17474e871899SJon Hunter 	 * *  0: Valid zone information returned.
17484e871899SJon Hunter 	 * *  -#BPMP_EINVAL: Invalid request parameters.
17494e871899SJon Hunter 	 * *  -#BPMP_ENOENT: No driver registered for thermal zone.
17504e871899SJon Hunter 	 * *  -#BPMP_ERANGE if thermtrip is invalid or disabled.
17514e871899SJon Hunter 	 * *  -#BPMP_EFAULT: Problem reading zone information.
17524e871899SJon Hunter 	 */
17534e871899SJon Hunter 	CMD_THERMAL_GET_THERMTRIP = 4,
17544e871899SJon Hunter 
1755983de5f9SThierry Reding 	/** @brief: number of supported host-to-bpmp commands. May
1756983de5f9SThierry Reding 	 * increase in future
1757983de5f9SThierry Reding 	 */
1758983de5f9SThierry Reding 	CMD_THERMAL_HOST_TO_BPMP_NUM
1759983de5f9SThierry Reding };
1760983de5f9SThierry Reding 
1761983de5f9SThierry Reding enum mrq_thermal_bpmp_to_host_cmd {
1762983de5f9SThierry Reding 	/**
1763983de5f9SThierry Reding 	 * @brief Indication that the temperature for a zone has
1764983de5f9SThierry Reding 	 *   exceeded the range indicated in the thermal trip point
1765983de5f9SThierry Reding 	 *   for the zone.
1766983de5f9SThierry Reding 	 *
1767983de5f9SThierry Reding 	 * BPMP needs to supply request parameters. Host only needs to
1768983de5f9SThierry Reding 	 * acknowledge.
1769983de5f9SThierry Reding 	 */
1770983de5f9SThierry Reding 	CMD_THERMAL_HOST_TRIP_REACHED = 100,
1771983de5f9SThierry Reding 
1772983de5f9SThierry Reding 	/** @brief: number of supported bpmp-to-host commands. May
1773983de5f9SThierry Reding 	 * increase in future
1774983de5f9SThierry Reding 	 */
1775983de5f9SThierry Reding 	CMD_THERMAL_BPMP_TO_HOST_NUM
1776983de5f9SThierry Reding };
1777983de5f9SThierry Reding 
1778983de5f9SThierry Reding /*
1779983de5f9SThierry Reding  * Host->BPMP request data for request type CMD_THERMAL_QUERY_ABI
1780983de5f9SThierry Reding  *
1781983de5f9SThierry Reding  * zone: Request type for which to check existence.
1782983de5f9SThierry Reding  */
1783983de5f9SThierry Reding struct cmd_thermal_query_abi_request {
1784983de5f9SThierry Reding 	uint32_t type;
17854e871899SJon Hunter } BPMP_ABI_PACKED;
1786983de5f9SThierry Reding 
1787983de5f9SThierry Reding /*
1788983de5f9SThierry Reding  * Host->BPMP request data for request type CMD_THERMAL_GET_TEMP
1789983de5f9SThierry Reding  *
1790983de5f9SThierry Reding  * zone: Number of thermal zone.
1791983de5f9SThierry Reding  */
1792983de5f9SThierry Reding struct cmd_thermal_get_temp_request {
1793983de5f9SThierry Reding 	uint32_t zone;
17944e871899SJon Hunter } BPMP_ABI_PACKED;
1795983de5f9SThierry Reding 
1796983de5f9SThierry Reding /*
1797983de5f9SThierry Reding  * BPMP->Host reply data for request CMD_THERMAL_GET_TEMP
1798983de5f9SThierry Reding  *
1799983de5f9SThierry Reding  * error: 0 if request succeeded.
1800983de5f9SThierry Reding  *	-BPMP_EINVAL if request parameters were invalid.
1801983de5f9SThierry Reding  *      -BPMP_ENOENT if no driver was registered for the specified thermal zone.
1802983de5f9SThierry Reding  *      -BPMP_EFAULT for other thermal zone driver errors.
1803983de5f9SThierry Reding  * temp: Current temperature in millicelsius.
1804983de5f9SThierry Reding  */
1805983de5f9SThierry Reding struct cmd_thermal_get_temp_response {
1806983de5f9SThierry Reding 	int32_t temp;
18074e871899SJon Hunter } BPMP_ABI_PACKED;
1808983de5f9SThierry Reding 
1809983de5f9SThierry Reding /*
1810983de5f9SThierry Reding  * Host->BPMP request data for request type CMD_THERMAL_SET_TRIP
1811983de5f9SThierry Reding  *
1812983de5f9SThierry Reding  * zone: Number of thermal zone.
1813983de5f9SThierry Reding  * low: Temperature of lower trip point in millicelsius
1814983de5f9SThierry Reding  * high: Temperature of upper trip point in millicelsius
1815983de5f9SThierry Reding  * enabled: 1 to enable trip point, 0 to disable trip point
1816983de5f9SThierry Reding  */
1817983de5f9SThierry Reding struct cmd_thermal_set_trip_request {
1818983de5f9SThierry Reding 	uint32_t zone;
1819983de5f9SThierry Reding 	int32_t low;
1820983de5f9SThierry Reding 	int32_t high;
1821983de5f9SThierry Reding 	uint32_t enabled;
18224e871899SJon Hunter } BPMP_ABI_PACKED;
1823983de5f9SThierry Reding 
1824983de5f9SThierry Reding /*
1825983de5f9SThierry Reding  * BPMP->Host request data for request type CMD_THERMAL_HOST_TRIP_REACHED
1826983de5f9SThierry Reding  *
1827983de5f9SThierry Reding  * zone: Number of thermal zone where trip point was reached.
1828983de5f9SThierry Reding  */
1829983de5f9SThierry Reding struct cmd_thermal_host_trip_reached_request {
1830983de5f9SThierry Reding 	uint32_t zone;
18314e871899SJon Hunter } BPMP_ABI_PACKED;
1832983de5f9SThierry Reding 
1833983de5f9SThierry Reding /*
1834983de5f9SThierry Reding  * BPMP->Host reply data for request type CMD_THERMAL_GET_NUM_ZONES
1835983de5f9SThierry Reding  *
1836983de5f9SThierry Reding  * num: Number of supported thermal zones. The thermal zones are indexed
1837983de5f9SThierry Reding  *      starting from zero.
1838983de5f9SThierry Reding  */
1839983de5f9SThierry Reding struct cmd_thermal_get_num_zones_response {
1840983de5f9SThierry Reding 	uint32_t num;
18414e871899SJon Hunter } BPMP_ABI_PACKED;
18424e871899SJon Hunter 
18434e871899SJon Hunter /*
18444e871899SJon Hunter  * Host->BPMP request data for request type CMD_THERMAL_GET_THERMTRIP
18454e871899SJon Hunter  *
18464e871899SJon Hunter  * zone: Number of thermal zone.
18474e871899SJon Hunter  */
18484e871899SJon Hunter struct cmd_thermal_get_thermtrip_request {
18494e871899SJon Hunter 	uint32_t zone;
18504e871899SJon Hunter } BPMP_ABI_PACKED;
18514e871899SJon Hunter 
18524e871899SJon Hunter /*
18534e871899SJon Hunter  * BPMP->Host reply data for request CMD_THERMAL_GET_THERMTRIP
18544e871899SJon Hunter  *
18554e871899SJon Hunter  * thermtrip: HW shutdown temperature in millicelsius.
18564e871899SJon Hunter  */
18574e871899SJon Hunter struct cmd_thermal_get_thermtrip_response {
18584e871899SJon Hunter 	int32_t thermtrip;
18594e871899SJon Hunter } BPMP_ABI_PACKED;
1860983de5f9SThierry Reding 
1861983de5f9SThierry Reding /*
1862983de5f9SThierry Reding  * Host->BPMP request data.
1863983de5f9SThierry Reding  *
1864983de5f9SThierry Reding  * Reply type is union mrq_thermal_bpmp_to_host_response.
1865983de5f9SThierry Reding  *
1866983de5f9SThierry Reding  * type: Type of request. Values listed in enum mrq_thermal_type.
1867983de5f9SThierry Reding  * data: Request type specific parameters.
1868983de5f9SThierry Reding  */
1869983de5f9SThierry Reding struct mrq_thermal_host_to_bpmp_request {
1870983de5f9SThierry Reding 	uint32_t type;
1871983de5f9SThierry Reding 	union {
1872983de5f9SThierry Reding 		struct cmd_thermal_query_abi_request query_abi;
1873983de5f9SThierry Reding 		struct cmd_thermal_get_temp_request get_temp;
1874983de5f9SThierry Reding 		struct cmd_thermal_set_trip_request set_trip;
18754e871899SJon Hunter 		struct cmd_thermal_get_thermtrip_request get_thermtrip;
18764e871899SJon Hunter 	} BPMP_UNION_ANON;
18774e871899SJon Hunter } BPMP_ABI_PACKED;
1878983de5f9SThierry Reding 
1879983de5f9SThierry Reding /*
1880983de5f9SThierry Reding  * BPMP->Host request data.
1881983de5f9SThierry Reding  *
1882983de5f9SThierry Reding  * type: Type of request. Values listed in enum mrq_thermal_type.
1883983de5f9SThierry Reding  * data: Request type specific parameters.
1884983de5f9SThierry Reding  */
1885983de5f9SThierry Reding struct mrq_thermal_bpmp_to_host_request {
1886983de5f9SThierry Reding 	uint32_t type;
1887983de5f9SThierry Reding 	union {
1888983de5f9SThierry Reding 		struct cmd_thermal_host_trip_reached_request host_trip_reached;
18894e871899SJon Hunter 	} BPMP_UNION_ANON;
18904e871899SJon Hunter } BPMP_ABI_PACKED;
1891983de5f9SThierry Reding 
1892983de5f9SThierry Reding /*
1893983de5f9SThierry Reding  * Data in reply to a Host->BPMP request.
1894983de5f9SThierry Reding  */
1895983de5f9SThierry Reding union mrq_thermal_bpmp_to_host_response {
1896983de5f9SThierry Reding 	struct cmd_thermal_get_temp_response get_temp;
18974e871899SJon Hunter 	struct cmd_thermal_get_thermtrip_response get_thermtrip;
1898983de5f9SThierry Reding 	struct cmd_thermal_get_num_zones_response get_num_zones;
18994e871899SJon Hunter } BPMP_ABI_PACKED;
1900*b204b92bSPeter De Schrijver 
1901*b204b92bSPeter De Schrijver /** @} Thermal */
1902*b204b92bSPeter De Schrijver 
1903*b204b92bSPeter De Schrijver /**
1904*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
1905*b204b92bSPeter De Schrijver  * @def MRQ_OC_STATUS
1906*b204b92bSPeter De Schrijver  * @brief Query over current status
1907*b204b92bSPeter De Schrijver  *
1908*b204b92bSPeter De Schrijver  * * Platforms: T234
1909*b204b92bSPeter De Schrijver  * @cond bpmp_t234
1910*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
1911*b204b92bSPeter De Schrijver  * * Targets: BPMP
1912*b204b92bSPeter De Schrijver  * * Request Payload: N/A
1913*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_oc_status_response
1914*b204b92bSPeter De Schrijver  *
1915*b204b92bSPeter De Schrijver  * @addtogroup OC_status
1916*b204b92bSPeter De Schrijver  * @{
1917*b204b92bSPeter De Schrijver  */
1918*b204b92bSPeter De Schrijver 
1919*b204b92bSPeter De Schrijver #define OC_STATUS_MAX_SIZE	24U
1920*b204b92bSPeter De Schrijver 
1921*b204b92bSPeter De Schrijver /*
1922*b204b92bSPeter De Schrijver  * @brief Response to #MRQ_OC_STATUS
1923*b204b92bSPeter De Schrijver  *
1924*b204b92bSPeter De Schrijver  * throt_en: Value for each OC alarm where zero signifies throttle is
1925*b204b92bSPeter De Schrijver  *           disabled, and non-zero throttle is enabled.
1926*b204b92bSPeter De Schrijver  * event_cnt: Total number of OC events for each OC alarm.
1927*b204b92bSPeter De Schrijver  *
1928*b204b92bSPeter De Schrijver  * mrq_response::err is 0 if the operation was successful and
1929*b204b92bSPeter De Schrijver  * -#BPMP_ENODEV otherwise.
1930*b204b92bSPeter De Schrijver  */
1931*b204b92bSPeter De Schrijver struct mrq_oc_status_response {
1932*b204b92bSPeter De Schrijver 	uint8_t throt_en[OC_STATUS_MAX_SIZE];
1933*b204b92bSPeter De Schrijver 	uint32_t event_cnt[OC_STATUS_MAX_SIZE];
1934*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
1935*b204b92bSPeter De Schrijver 
1936*b204b92bSPeter De Schrijver /** @} OC_status */
1937*b204b92bSPeter De Schrijver /** @endcond bpmp_t234 */
1938983de5f9SThierry Reding 
1939983de5f9SThierry Reding /**
1940983de5f9SThierry Reding  * @ingroup MRQ_Codes
1941983de5f9SThierry Reding  * @def MRQ_CPU_VHINT
1942983de5f9SThierry Reding  * @brief Query CPU voltage hint data
1943983de5f9SThierry Reding  *
1944983de5f9SThierry Reding  * * Platforms: T186
19454bef358cSTimo Alho  * @cond bpmp_t186
1946983de5f9SThierry Reding  * * Initiators: CCPLEX
1947983de5f9SThierry Reding  * * Targets: BPMP
1948983de5f9SThierry Reding  * * Request Payload: @ref mrq_cpu_vhint_request
1949983de5f9SThierry Reding  * * Response Payload: N/A
1950983de5f9SThierry Reding  *
19514bef358cSTimo Alho  * @addtogroup Vhint
1952983de5f9SThierry Reding  * @{
1953983de5f9SThierry Reding  */
1954983de5f9SThierry Reding 
1955983de5f9SThierry Reding /**
19564bef358cSTimo Alho  * @brief Request with #MRQ_CPU_VHINT
1957983de5f9SThierry Reding  *
1958983de5f9SThierry Reding  * Used by #MRQ_CPU_VHINT call by CCPLEX to retrieve voltage hint data
1959983de5f9SThierry Reding  * from BPMP to memory space pointed by #addr. CCPLEX is responsible
1960983de5f9SThierry Reding  * to allocate sizeof(cpu_vhint_data) sized block of memory and
1961983de5f9SThierry Reding  * appropriately map it for BPMP before sending the request.
1962983de5f9SThierry Reding  */
1963983de5f9SThierry Reding struct mrq_cpu_vhint_request {
1964983de5f9SThierry Reding 	/** @brief IOVA address for the #cpu_vhint_data */
19654bef358cSTimo Alho 	uint32_t addr;
1966983de5f9SThierry Reding 	/** @brief ID of the cluster whose data is requested */
19674bef358cSTimo Alho 	uint32_t cluster_id;
19684e871899SJon Hunter } BPMP_ABI_PACKED;
1969983de5f9SThierry Reding 
1970983de5f9SThierry Reding /**
19714bef358cSTimo Alho  * @brief Description of the CPU v/f relation
1972983de5f9SThierry Reding  *
19734bef358cSTimo Alho  * Used by #MRQ_CPU_VHINT call to carry data pointed by
19744bef358cSTimo Alho  * #mrq_cpu_vhint_request::addr
1975983de5f9SThierry Reding  */
1976983de5f9SThierry Reding struct cpu_vhint_data {
1977983de5f9SThierry Reding 	uint32_t ref_clk_hz; /**< reference frequency in Hz */
1978983de5f9SThierry Reding 	uint16_t pdiv; /**< post divider value */
1979983de5f9SThierry Reding 	uint16_t mdiv; /**< input divider value */
1980983de5f9SThierry Reding 	uint16_t ndiv_max; /**< fMAX expressed with max NDIV value */
1981983de5f9SThierry Reding 	/** table of ndiv values as a function of vINDEX (voltage index) */
1982983de5f9SThierry Reding 	uint16_t ndiv[80];
1983983de5f9SThierry Reding 	/** minimum allowed NDIV value */
1984983de5f9SThierry Reding 	uint16_t ndiv_min;
1985983de5f9SThierry Reding 	/** minimum allowed voltage hint value (as in vINDEX) */
1986983de5f9SThierry Reding 	uint16_t vfloor;
1987983de5f9SThierry Reding 	/** maximum allowed voltage hint value (as in vINDEX) */
1988983de5f9SThierry Reding 	uint16_t vceil;
1989983de5f9SThierry Reding 	/** post-multiplier for vindex value */
1990983de5f9SThierry Reding 	uint16_t vindex_mult;
1991983de5f9SThierry Reding 	/** post-divider for vindex value */
1992983de5f9SThierry Reding 	uint16_t vindex_div;
1993983de5f9SThierry Reding 	/** reserved for future use */
1994983de5f9SThierry Reding 	uint16_t reserved[328];
19954e871899SJon Hunter } BPMP_ABI_PACKED;
1996*b204b92bSPeter De Schrijver 
1997*b204b92bSPeter De Schrijver /** @} Vhint */
1998*b204b92bSPeter De Schrijver /** @endcond bpmp_t186 */
1999983de5f9SThierry Reding 
2000983de5f9SThierry Reding /**
2001983de5f9SThierry Reding  * @ingroup MRQ_Codes
2002983de5f9SThierry Reding  * @def MRQ_ABI_RATCHET
2003983de5f9SThierry Reding  * @brief ABI ratchet value query
2004983de5f9SThierry Reding  *
20054bef358cSTimo Alho  * * Platforms: T186, T194
2006983de5f9SThierry Reding  * * Initiators: Any
2007983de5f9SThierry Reding  * * Targets: BPMP
2008983de5f9SThierry Reding  * * Request Payload: @ref mrq_abi_ratchet_request
2009983de5f9SThierry Reding  * * Response Payload: @ref mrq_abi_ratchet_response
2010983de5f9SThierry Reding  * @addtogroup ABI_info
2011983de5f9SThierry Reding  * @{
2012983de5f9SThierry Reding  */
2013983de5f9SThierry Reding 
2014983de5f9SThierry Reding /**
20154bef358cSTimo Alho  * @brief An ABI compatibility mechanism
2016983de5f9SThierry Reding  *
2017983de5f9SThierry Reding  * BPMP_ABI_RATCHET_VALUE may increase for various reasons in a future
2018983de5f9SThierry Reding  * revision of this header file.
2019983de5f9SThierry Reding  * 1. That future revision deprecates some MRQ
2020983de5f9SThierry Reding  * 2. That future revision introduces a breaking change to an existing
2021983de5f9SThierry Reding  *    MRQ or
2022983de5f9SThierry Reding  * 3. A bug is discovered in an existing implementation of the BPMP-FW
2023983de5f9SThierry Reding  *    (or possibly one of its clients) which warrants deprecating that
2024983de5f9SThierry Reding  *    implementation.
2025983de5f9SThierry Reding  */
2026983de5f9SThierry Reding #define BPMP_ABI_RATCHET_VALUE 3
2027983de5f9SThierry Reding 
2028983de5f9SThierry Reding /**
20294bef358cSTimo Alho  * @brief Request with #MRQ_ABI_RATCHET.
2030983de5f9SThierry Reding  *
2031983de5f9SThierry Reding  * #ratchet should be #BPMP_ABI_RATCHET_VALUE from the ABI header
2032983de5f9SThierry Reding  * against which the requester was compiled.
2033983de5f9SThierry Reding  *
2034983de5f9SThierry Reding  * If ratchet is less than BPMP's #BPMP_ABI_RATCHET_VALUE, BPMP may
2035983de5f9SThierry Reding  * reply with mrq_response::err = -#BPMP_ERANGE to indicate that
2036983de5f9SThierry Reding  * BPMP-FW cannot interoperate correctly with the requester. Requester
2037983de5f9SThierry Reding  * should cease further communication with BPMP.
2038983de5f9SThierry Reding  *
2039983de5f9SThierry Reding  * Otherwise, err shall be 0.
2040983de5f9SThierry Reding  */
2041983de5f9SThierry Reding struct mrq_abi_ratchet_request {
20424bef358cSTimo Alho 	/** @brief Requester's ratchet value */
2043983de5f9SThierry Reding 	uint16_t ratchet;
2044983de5f9SThierry Reding };
2045983de5f9SThierry Reding 
2046983de5f9SThierry Reding /**
20474bef358cSTimo Alho  * @brief Response to #MRQ_ABI_RATCHET
2048983de5f9SThierry Reding  *
2049983de5f9SThierry Reding  * #ratchet shall be #BPMP_ABI_RATCHET_VALUE from the ABI header
2050983de5f9SThierry Reding  * against which BPMP firwmare was compiled.
2051983de5f9SThierry Reding  *
2052983de5f9SThierry Reding  * If #ratchet is less than the requester's #BPMP_ABI_RATCHET_VALUE,
2053983de5f9SThierry Reding  * the requster must either interoperate with BPMP according to an ABI
2054983de5f9SThierry Reding  * header version with BPMP_ABI_RATCHET_VALUE = ratchet or cease
2055983de5f9SThierry Reding  * communication with BPMP.
2056983de5f9SThierry Reding  *
2057983de5f9SThierry Reding  * If mrq_response::err is 0 and ratchet is greater than or equal to the
2058983de5f9SThierry Reding  * requester's BPMP_ABI_RATCHET_VALUE, the requester should continue
2059983de5f9SThierry Reding  * normal operation.
2060983de5f9SThierry Reding  */
2061983de5f9SThierry Reding struct mrq_abi_ratchet_response {
2062983de5f9SThierry Reding 	/** @brief BPMP's ratchet value */
2063983de5f9SThierry Reding 	uint16_t ratchet;
2064983de5f9SThierry Reding };
2065*b204b92bSPeter De Schrijver 
2066*b204b92bSPeter De Schrijver /** @} ABI_info */
2067983de5f9SThierry Reding 
2068983de5f9SThierry Reding /**
2069983de5f9SThierry Reding  * @ingroup MRQ_Codes
2070983de5f9SThierry Reding  * @def MRQ_EMC_DVFS_LATENCY
20714bef358cSTimo Alho  * @brief Query frequency dependent EMC DVFS latency
2072983de5f9SThierry Reding  *
2073*b204b92bSPeter De Schrijver  * * Platforms: T186, T194, T234
2074983de5f9SThierry Reding  * * Initiators: CCPLEX
2075983de5f9SThierry Reding  * * Targets: BPMP
2076983de5f9SThierry Reding  * * Request Payload: N/A
2077983de5f9SThierry Reding  * * Response Payload: @ref mrq_emc_dvfs_latency_response
2078983de5f9SThierry Reding  * @addtogroup EMC
2079983de5f9SThierry Reding  * @{
2080983de5f9SThierry Reding  */
2081983de5f9SThierry Reding 
2082983de5f9SThierry Reding /**
20834bef358cSTimo Alho  * @brief Used by @ref mrq_emc_dvfs_latency_response
2084983de5f9SThierry Reding  */
2085983de5f9SThierry Reding struct emc_dvfs_latency {
20864e871899SJon Hunter 	/** @brief EMC DVFS node frequency in kHz */
2087983de5f9SThierry Reding 	uint32_t freq;
2088983de5f9SThierry Reding 	/** @brief EMC DVFS latency in nanoseconds */
2089983de5f9SThierry Reding 	uint32_t latency;
20904e871899SJon Hunter } BPMP_ABI_PACKED;
2091983de5f9SThierry Reding 
2092983de5f9SThierry Reding #define EMC_DVFS_LATENCY_MAX_SIZE	14
2093983de5f9SThierry Reding /**
20944bef358cSTimo Alho  * @brief Response to #MRQ_EMC_DVFS_LATENCY
2095983de5f9SThierry Reding  */
2096983de5f9SThierry Reding struct mrq_emc_dvfs_latency_response {
20974bef358cSTimo Alho 	/** @brief The number valid entries in #pairs */
2098983de5f9SThierry Reding 	uint32_t num_pairs;
20994e871899SJon Hunter 	/** @brief EMC DVFS node <frequency, latency> information */
2100983de5f9SThierry Reding 	struct emc_dvfs_latency pairs[EMC_DVFS_LATENCY_MAX_SIZE];
21014e871899SJon Hunter } BPMP_ABI_PACKED;
2102983de5f9SThierry Reding 
2103*b204b92bSPeter De Schrijver /** @} EMC */
2104*b204b92bSPeter De Schrijver 
2105*b204b92bSPeter De Schrijver /**
2106*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
2107*b204b92bSPeter De Schrijver  * @def MRQ_EMC_DVFS_EMCHUB
2108*b204b92bSPeter De Schrijver  * @brief Query EMC HUB frequencies
2109*b204b92bSPeter De Schrijver  *
2110*b204b92bSPeter De Schrijver  * * Platforms: T234 onwards
2111*b204b92bSPeter De Schrijver  * @cond (bpmp_t234 || bpmp_t239 || bpmp_th500)
2112*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
2113*b204b92bSPeter De Schrijver  * * Targets: BPMP
2114*b204b92bSPeter De Schrijver  * * Request Payload: N/A
2115*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_emc_dvfs_emchub_response
2116*b204b92bSPeter De Schrijver  * @addtogroup EMC
2117*b204b92bSPeter De Schrijver  * @{
2118*b204b92bSPeter De Schrijver  */
2119*b204b92bSPeter De Schrijver 
2120*b204b92bSPeter De Schrijver /**
2121*b204b92bSPeter De Schrijver  * @brief Used by @ref mrq_emc_dvfs_emchub_response
2122*b204b92bSPeter De Schrijver  */
2123*b204b92bSPeter De Schrijver struct emc_dvfs_emchub {
2124*b204b92bSPeter De Schrijver 	/** @brief EMC DVFS node frequency in kHz */
2125*b204b92bSPeter De Schrijver 	uint32_t freq;
2126*b204b92bSPeter De Schrijver 	/** @brief EMC HUB frequency in kHz */
2127*b204b92bSPeter De Schrijver 	uint32_t hub_freq;
2128*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2129*b204b92bSPeter De Schrijver 
2130*b204b92bSPeter De Schrijver #define EMC_DVFS_EMCHUB_MAX_SIZE	EMC_DVFS_LATENCY_MAX_SIZE
2131*b204b92bSPeter De Schrijver /**
2132*b204b92bSPeter De Schrijver  * @brief Response to #MRQ_EMC_DVFS_EMCHUB
2133*b204b92bSPeter De Schrijver  */
2134*b204b92bSPeter De Schrijver struct mrq_emc_dvfs_emchub_response {
2135*b204b92bSPeter De Schrijver 	/** @brief The number valid entries in #pairs */
2136*b204b92bSPeter De Schrijver 	uint32_t num_pairs;
2137*b204b92bSPeter De Schrijver 	/** @brief EMC DVFS node <frequency, hub frequency> information */
2138*b204b92bSPeter De Schrijver 	struct emc_dvfs_emchub pairs[EMC_DVFS_EMCHUB_MAX_SIZE];
2139*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2140*b204b92bSPeter De Schrijver 
2141*b204b92bSPeter De Schrijver /** @} EMC */
2142*b204b92bSPeter De Schrijver /** @endcond (bpmp_t234 || bpmp_t239 || bpmp_th500) */
2143*b204b92bSPeter De Schrijver 
2144*b204b92bSPeter De Schrijver /**
2145*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
2146*b204b92bSPeter De Schrijver  * @def MRQ_EMC_DISP_RFL
2147*b204b92bSPeter De Schrijver  * @brief Set EMC display RFL handshake mode of operations
2148*b204b92bSPeter De Schrijver  *
2149*b204b92bSPeter De Schrijver  * * Platforms: T234 onwards
2150*b204b92bSPeter De Schrijver  * @cond (bpmp_t234 || bpmp_t239 || bpmp_th500)
2151*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
2152*b204b92bSPeter De Schrijver  * * Targets: BPMP
2153*b204b92bSPeter De Schrijver  * * Request Payload: @ref mrq_emc_disp_rfl_request
2154*b204b92bSPeter De Schrijver  * * Response Payload: N/A
2155*b204b92bSPeter De Schrijver  *
2156*b204b92bSPeter De Schrijver  * @addtogroup EMC
2157*b204b92bSPeter De Schrijver  * @{
2158*b204b92bSPeter De Schrijver  */
2159*b204b92bSPeter De Schrijver 
2160*b204b92bSPeter De Schrijver enum mrq_emc_disp_rfl_mode {
2161*b204b92bSPeter De Schrijver 	/** @brief EMC display RFL handshake disabled  */
2162*b204b92bSPeter De Schrijver 	EMC_DISP_RFL_MODE_DISABLED = 0,
2163*b204b92bSPeter De Schrijver 	/** @brief EMC display RFL handshake enabled  */
2164*b204b92bSPeter De Schrijver 	EMC_DISP_RFL_MODE_ENABLED = 1,
2165*b204b92bSPeter De Schrijver };
2166*b204b92bSPeter De Schrijver 
2167*b204b92bSPeter De Schrijver /**
2168*b204b92bSPeter De Schrijver  * @ingroup EMC
2169*b204b92bSPeter De Schrijver  * @brief Request with #MRQ_EMC_DISP_RFL
2170*b204b92bSPeter De Schrijver  *
2171*b204b92bSPeter De Schrijver  * Used by the sender of an #MRQ_EMC_DISP_RFL message to
2172*b204b92bSPeter De Schrijver  * request the mode of EMC display RFL handshake.
2173*b204b92bSPeter De Schrijver  *
2174*b204b92bSPeter De Schrijver  * mrq_response::err is
2175*b204b92bSPeter De Schrijver  * * 0: RFL mode is set successfully
2176*b204b92bSPeter De Schrijver  * * -#BPMP_EINVAL: invalid mode requested
2177*b204b92bSPeter De Schrijver  * * -#BPMP_ENOSYS: RFL handshake is not supported
2178*b204b92bSPeter De Schrijver  * * -#BPMP_EACCES: Permission denied
2179*b204b92bSPeter De Schrijver  * * -#BPMP_ENODEV: if disp rfl mrq is not supported by BPMP-FW
2180*b204b92bSPeter De Schrijver  */
2181*b204b92bSPeter De Schrijver struct mrq_emc_disp_rfl_request {
2182*b204b92bSPeter De Schrijver 	/** @brief EMC display RFL mode (@ref mrq_emc_disp_rfl_mode) */
2183*b204b92bSPeter De Schrijver 	uint32_t mode;
2184*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2185*b204b92bSPeter De Schrijver 
2186*b204b92bSPeter De Schrijver /** @} EMC */
2187*b204b92bSPeter De Schrijver /** @endcond (bpmp_t234 || bpmp_t239 || bpmp_th500) */
2188*b204b92bSPeter De Schrijver 
2189*b204b92bSPeter De Schrijver /**
2190*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
2191*b204b92bSPeter De Schrijver  * @def MRQ_BWMGR
2192*b204b92bSPeter De Schrijver  * @brief bwmgr requests
2193*b204b92bSPeter De Schrijver  *
2194*b204b92bSPeter De Schrijver  * * Platforms: T234 onwards
2195*b204b92bSPeter De Schrijver  * @cond (bpmp_t234 || bpmp_t239 || bpmp_th500)
2196*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
2197*b204b92bSPeter De Schrijver  * * Targets: BPMP
2198*b204b92bSPeter De Schrijver  * * Request Payload: @ref mrq_bwmgr_request
2199*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_bwmgr_response
2200*b204b92bSPeter De Schrijver  *
2201*b204b92bSPeter De Schrijver  * @addtogroup BWMGR
2202*b204b92bSPeter De Schrijver  *
2203*b204b92bSPeter De Schrijver  * @{
2204*b204b92bSPeter De Schrijver  */
2205*b204b92bSPeter De Schrijver 
2206*b204b92bSPeter De Schrijver enum mrq_bwmgr_cmd {
2207*b204b92bSPeter De Schrijver 	/**
2208*b204b92bSPeter De Schrijver 	 * @brief Check whether the BPMP driver supports the specified
2209*b204b92bSPeter De Schrijver 	 * request type
2210*b204b92bSPeter De Schrijver 	 *
2211*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the specified request is
2212*b204b92bSPeter De Schrijver 	 * supported and -#BPMP_ENODEV otherwise.
2213*b204b92bSPeter De Schrijver 	 */
2214*b204b92bSPeter De Schrijver 	CMD_BWMGR_QUERY_ABI = 0,
2215*b204b92bSPeter De Schrijver 
2216*b204b92bSPeter De Schrijver 	/**
2217*b204b92bSPeter De Schrijver 	 * @brief Determine dram rate to satisfy iso/niso bw requests
2218*b204b92bSPeter De Schrijver 	 *
2219*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2220*b204b92bSPeter De Schrijver 	 * *  0: calc_rate succeeded.
2221*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EINVAL: Invalid request parameters.
2222*b204b92bSPeter De Schrijver 	 * *  -#BPMP_ENOTSUP: Requested bw is not available.
2223*b204b92bSPeter De Schrijver 	 */
2224*b204b92bSPeter De Schrijver 	CMD_BWMGR_CALC_RATE = 1
2225*b204b92bSPeter De Schrijver };
2226*b204b92bSPeter De Schrijver 
2227*b204b92bSPeter De Schrijver /*
2228*b204b92bSPeter De Schrijver  * request data for request type CMD_BWMGR_QUERY_ABI
2229*b204b92bSPeter De Schrijver  *
2230*b204b92bSPeter De Schrijver  * type: Request type for which to check existence.
2231*b204b92bSPeter De Schrijver  */
2232*b204b92bSPeter De Schrijver struct cmd_bwmgr_query_abi_request {
2233*b204b92bSPeter De Schrijver 	uint32_t type;
2234*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2235*b204b92bSPeter De Schrijver 
2236*b204b92bSPeter De Schrijver /**
2237*b204b92bSPeter De Schrijver  * @brief Used by @ref cmd_bwmgr_calc_rate_request
2238*b204b92bSPeter De Schrijver  */
2239*b204b92bSPeter De Schrijver struct iso_req {
2240*b204b92bSPeter De Schrijver 	/* @brief bwmgr client ID @ref bpmp_bwmgr_ids */
2241*b204b92bSPeter De Schrijver 	uint32_t id;
2242*b204b92bSPeter De Schrijver 	/* @brief bw in kBps requested by client */
2243*b204b92bSPeter De Schrijver 	uint32_t iso_bw;
2244*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2245*b204b92bSPeter De Schrijver 
2246*b204b92bSPeter De Schrijver #define MAX_ISO_CLIENTS		13U
2247*b204b92bSPeter De Schrijver /*
2248*b204b92bSPeter De Schrijver  * request data for request type CMD_BWMGR_CALC_RATE
2249*b204b92bSPeter De Schrijver  */
2250*b204b92bSPeter De Schrijver struct cmd_bwmgr_calc_rate_request {
2251*b204b92bSPeter De Schrijver 	/* @brief total bw in kBps requested by all niso clients */
2252*b204b92bSPeter De Schrijver 	uint32_t sum_niso_bw;
2253*b204b92bSPeter De Schrijver 	/* @brief The number of iso clients */
2254*b204b92bSPeter De Schrijver 	uint32_t num_iso_clients;
2255*b204b92bSPeter De Schrijver 	/* @brief iso_req <id, iso_bw> information */
2256*b204b92bSPeter De Schrijver 	struct iso_req isobw_reqs[MAX_ISO_CLIENTS];
2257*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2258*b204b92bSPeter De Schrijver 
2259*b204b92bSPeter De Schrijver /*
2260*b204b92bSPeter De Schrijver  * response data for request type CMD_BWMGR_CALC_RATE
2261*b204b92bSPeter De Schrijver  *
2262*b204b92bSPeter De Schrijver  * iso_rate_min: min dram data clk rate in kHz to satisfy all iso bw reqs
2263*b204b92bSPeter De Schrijver  * total_rate_min: min dram data clk rate in kHz to satisfy all bw reqs
2264*b204b92bSPeter De Schrijver  */
2265*b204b92bSPeter De Schrijver struct cmd_bwmgr_calc_rate_response {
2266*b204b92bSPeter De Schrijver 	uint32_t iso_rate_min;
2267*b204b92bSPeter De Schrijver 	uint32_t total_rate_min;
2268*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2269*b204b92bSPeter De Schrijver 
2270*b204b92bSPeter De Schrijver /*
2271*b204b92bSPeter De Schrijver  * @brief Request with #MRQ_BWMGR
2272*b204b92bSPeter De Schrijver  *
2273*b204b92bSPeter De Schrijver  *
2274*b204b92bSPeter De Schrijver  * |sub-command                 |payload                       |
2275*b204b92bSPeter De Schrijver  * |----------------------------|------------------------------|
2276*b204b92bSPeter De Schrijver  * |CMD_BWMGR_QUERY_ABI         | cmd_bwmgr_query_abi_request  |
2277*b204b92bSPeter De Schrijver  * |CMD_BWMGR_CALC_RATE         | cmd_bwmgr_calc_rate_request  |
2278*b204b92bSPeter De Schrijver  *
2279*b204b92bSPeter De Schrijver  */
2280*b204b92bSPeter De Schrijver struct mrq_bwmgr_request {
2281*b204b92bSPeter De Schrijver 	uint32_t cmd;
2282*b204b92bSPeter De Schrijver 	union {
2283*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_query_abi_request query_abi;
2284*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_calc_rate_request bwmgr_rate_req;
2285*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2286*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2287*b204b92bSPeter De Schrijver 
2288*b204b92bSPeter De Schrijver /*
2289*b204b92bSPeter De Schrijver  * @brief Response to MRQ_BWMGR
2290*b204b92bSPeter De Schrijver  *
2291*b204b92bSPeter De Schrijver  * |sub-command                 |payload                       |
2292*b204b92bSPeter De Schrijver  * |----------------------------|------------------------------|
2293*b204b92bSPeter De Schrijver  * |CMD_BWMGR_CALC_RATE         | cmd_bwmgr_calc_rate_response |
2294*b204b92bSPeter De Schrijver  */
2295*b204b92bSPeter De Schrijver struct mrq_bwmgr_response {
2296*b204b92bSPeter De Schrijver 	union {
2297*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_calc_rate_response bwmgr_rate_resp;
2298*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2299*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2300*b204b92bSPeter De Schrijver 
2301*b204b92bSPeter De Schrijver /** @} BWMGR */
2302*b204b92bSPeter De Schrijver /** @endcond (bpmp_t234 || bpmp_t239 || bpmp_th500) */
2303*b204b92bSPeter De Schrijver 
2304*b204b92bSPeter De Schrijver /**
2305*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
2306*b204b92bSPeter De Schrijver  * @def MRQ_BWMGR_INT
2307*b204b92bSPeter De Schrijver  * @brief bpmp-integrated bwmgr requests
2308*b204b92bSPeter De Schrijver  *
2309*b204b92bSPeter De Schrijver  * * Platforms: T234 onwards
2310*b204b92bSPeter De Schrijver  * @cond (bpmp_t234 || bpmp_t239 || bpmp_th500)
2311*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
2312*b204b92bSPeter De Schrijver  * * Targets: BPMP
2313*b204b92bSPeter De Schrijver  * * Request Payload: @ref mrq_bwmgr_int_request
2314*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_bwmgr_int_response
2315*b204b92bSPeter De Schrijver  *
2316*b204b92bSPeter De Schrijver  * @addtogroup BWMGR_INT
2317*b204b92bSPeter De Schrijver  * @{
2318*b204b92bSPeter De Schrijver  */
2319*b204b92bSPeter De Schrijver 
2320*b204b92bSPeter De Schrijver enum mrq_bwmgr_int_cmd {
2321*b204b92bSPeter De Schrijver 	/**
2322*b204b92bSPeter De Schrijver 	 * @brief Check whether the BPMP-FW supports the specified
2323*b204b92bSPeter De Schrijver 	 * request type
2324*b204b92bSPeter De Schrijver 	 *
2325*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the specified request is
2326*b204b92bSPeter De Schrijver 	 * supported and -#BPMP_ENODEV otherwise.
2327*b204b92bSPeter De Schrijver 	 */
2328*b204b92bSPeter De Schrijver 	CMD_BWMGR_INT_QUERY_ABI = 1,
2329*b204b92bSPeter De Schrijver 
2330*b204b92bSPeter De Schrijver 	/**
2331*b204b92bSPeter De Schrijver 	 * @brief Determine and set dram rate to satisfy iso/niso bw request
2332*b204b92bSPeter De Schrijver 	 *
2333*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2334*b204b92bSPeter De Schrijver 	 * *  0: request succeeded.
2335*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EINVAL: Invalid request parameters.
2336*b204b92bSPeter De Schrijver 	 *          set_frequency in @ref cmd_bwmgr_int_calc_and_set_response
2337*b204b92bSPeter De Schrijver 	 *          will not be set.
2338*b204b92bSPeter De Schrijver 	 * *  -#BPMP_ENOTSUP: Requested bw is not available.
2339*b204b92bSPeter De Schrijver 	 *          set_frequency in @ref cmd_bwmgr_int_calc_and_set_response
2340*b204b92bSPeter De Schrijver 	 *          will be current dram-clk rate.
2341*b204b92bSPeter De Schrijver 	 */
2342*b204b92bSPeter De Schrijver 	CMD_BWMGR_INT_CALC_AND_SET = 2,
2343*b204b92bSPeter De Schrijver 
2344*b204b92bSPeter De Schrijver 	/**
2345*b204b92bSPeter De Schrijver 	 * @brief Set a max DRAM frequency for the bandwidth-manager
2346*b204b92bSPeter De Schrijver 	 *
2347*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2348*b204b92bSPeter De Schrijver 	 * *  0: request succeeded.
2349*b204b92bSPeter De Schrijver 	 * *  -#BPMP_ENOTSUP: Requested cap frequency is not possible.
2350*b204b92bSPeter De Schrijver 	 */
2351*b204b92bSPeter De Schrijver 	CMD_BWMGR_INT_CAP_SET = 3
2352*b204b92bSPeter De Schrijver };
2353*b204b92bSPeter De Schrijver 
2354*b204b92bSPeter De Schrijver /*
2355*b204b92bSPeter De Schrijver  * request structure for request type CMD_BWMGR_QUERY_ABI
2356*b204b92bSPeter De Schrijver  *
2357*b204b92bSPeter De Schrijver  * type: Request type for which to check existence.
2358*b204b92bSPeter De Schrijver  */
2359*b204b92bSPeter De Schrijver struct cmd_bwmgr_int_query_abi_request {
2360*b204b92bSPeter De Schrijver 	/* @brief request type determined by @ref mrq_bwmgr_int_cmd */
2361*b204b92bSPeter De Schrijver 	uint32_t type;
2362*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2363*b204b92bSPeter De Schrijver 
2364*b204b92bSPeter De Schrijver /**
2365*b204b92bSPeter De Schrijver  * @defgroup bwmgr_int_unit_type BWMGR_INT floor unit-types
2366*b204b92bSPeter De Schrijver  * @addtogroup bwmgr_int_unit_type
2367*b204b92bSPeter De Schrijver  * @{
2368*b204b92bSPeter De Schrijver  */
2369*b204b92bSPeter De Schrijver /** @brief kilobytes per second unit-type */
2370*b204b92bSPeter De Schrijver #define BWMGR_INT_UNIT_KBPS  0U
2371*b204b92bSPeter De Schrijver /** @brief kilohertz unit-type */
2372*b204b92bSPeter De Schrijver #define BWMGR_INT_UNIT_KHZ   1U
2373*b204b92bSPeter De Schrijver 
2374*b204b92bSPeter De Schrijver /** @} bwmgr_int_unit_type */
2375*b204b92bSPeter De Schrijver 
2376*b204b92bSPeter De Schrijver /*
2377*b204b92bSPeter De Schrijver  * request data for request type CMD_BWMGR_INT_CALC_AND_SET
2378*b204b92bSPeter De Schrijver  */
2379*b204b92bSPeter De Schrijver struct cmd_bwmgr_int_calc_and_set_request {
2380*b204b92bSPeter De Schrijver 	/* @brief bwmgr client ID @ref bpmp_bwmgr_ids */
2381*b204b92bSPeter De Schrijver 	uint32_t client_id;
2382*b204b92bSPeter De Schrijver 	/* @brief average niso bw usage in kBps requested by client. */
2383*b204b92bSPeter De Schrijver 	uint32_t niso_bw;
2384*b204b92bSPeter De Schrijver 	/*
2385*b204b92bSPeter De Schrijver 	 * @brief average iso bw usage in kBps requested by client.
2386*b204b92bSPeter De Schrijver 	 *  Value is ignored if client is niso. Determined by client_id.
2387*b204b92bSPeter De Schrijver 	 */
2388*b204b92bSPeter De Schrijver 	uint32_t iso_bw;
2389*b204b92bSPeter De Schrijver 	/*
2390*b204b92bSPeter De Schrijver 	 * @brief memory clock floor requested by client.
2391*b204b92bSPeter De Schrijver 	 *  Unit determined by floor_unit.
2392*b204b92bSPeter De Schrijver 	 */
2393*b204b92bSPeter De Schrijver 	uint32_t mc_floor;
2394*b204b92bSPeter De Schrijver 	/*
2395*b204b92bSPeter De Schrijver 	 * @brief toggle to determine the unit-type of floor value.
2396*b204b92bSPeter De Schrijver 	 *  See @ref bwmgr_int_unit_type definitions for unit-type mappings.
2397*b204b92bSPeter De Schrijver 	 */
2398*b204b92bSPeter De Schrijver 	uint8_t floor_unit;
2399*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2400*b204b92bSPeter De Schrijver 
2401*b204b92bSPeter De Schrijver struct cmd_bwmgr_int_cap_set_request {
2402*b204b92bSPeter De Schrijver 	/* @brief requested cap frequency in Hz. */
2403*b204b92bSPeter De Schrijver 	uint64_t rate;
2404*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2405*b204b92bSPeter De Schrijver 
2406*b204b92bSPeter De Schrijver /*
2407*b204b92bSPeter De Schrijver  * response data for request type CMD_BWMGR_CALC_AND_SET
2408*b204b92bSPeter De Schrijver  */
2409*b204b92bSPeter De Schrijver struct cmd_bwmgr_int_calc_and_set_response {
2410*b204b92bSPeter De Schrijver 	/* @brief current set memory clock frequency in Hz */
2411*b204b92bSPeter De Schrijver 	uint64_t rate;
2412*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2413*b204b92bSPeter De Schrijver 
2414*b204b92bSPeter De Schrijver /*
2415*b204b92bSPeter De Schrijver  * @brief Request with #MRQ_BWMGR_INT
2416*b204b92bSPeter De Schrijver  *
2417*b204b92bSPeter De Schrijver  *
2418*b204b92bSPeter De Schrijver  * |sub-command                 |payload                            |
2419*b204b92bSPeter De Schrijver  * |----------------------------|-----------------------------------|
2420*b204b92bSPeter De Schrijver  * |CMD_BWMGR_INT_QUERY_ABI     | cmd_bwmgr_int_query_abi_request   |
2421*b204b92bSPeter De Schrijver  * |CMD_BWMGR_INT_CALC_AND_SET  | cmd_bwmgr_int_calc_and_set_request|
2422*b204b92bSPeter De Schrijver  * |CMD_BWMGR_INT_CAP_SET       | cmd_bwmgr_int_cap_set_request     |
2423*b204b92bSPeter De Schrijver  *
2424*b204b92bSPeter De Schrijver  */
2425*b204b92bSPeter De Schrijver struct mrq_bwmgr_int_request {
2426*b204b92bSPeter De Schrijver 	uint32_t cmd;
2427*b204b92bSPeter De Schrijver 	union {
2428*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_int_query_abi_request query_abi;
2429*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_int_calc_and_set_request bwmgr_calc_set_req;
2430*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_int_cap_set_request bwmgr_cap_set_req;
2431*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2432*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2433*b204b92bSPeter De Schrijver 
2434*b204b92bSPeter De Schrijver /*
2435*b204b92bSPeter De Schrijver  * @brief Response to MRQ_BWMGR_INT
2436*b204b92bSPeter De Schrijver  *
2437*b204b92bSPeter De Schrijver  * |sub-command                 |payload                                |
2438*b204b92bSPeter De Schrijver  * |----------------------------|---------------------------------------|
2439*b204b92bSPeter De Schrijver  * |CMD_BWMGR_INT_CALC_AND_SET  | cmd_bwmgr_int_calc_and_set_response   |
2440*b204b92bSPeter De Schrijver  */
2441*b204b92bSPeter De Schrijver struct mrq_bwmgr_int_response {
2442*b204b92bSPeter De Schrijver 	union {
2443*b204b92bSPeter De Schrijver 		struct cmd_bwmgr_int_calc_and_set_response bwmgr_calc_set_resp;
2444*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2445*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2446*b204b92bSPeter De Schrijver 
2447*b204b92bSPeter De Schrijver /** @} BWMGR_INT */
2448*b204b92bSPeter De Schrijver /** @endcond (bpmp_t234 || bpmp_t239 || bpmp_th500) */
2449*b204b92bSPeter De Schrijver 
2450*b204b92bSPeter De Schrijver /**
2451*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
2452*b204b92bSPeter De Schrijver  * @def MRQ_ISO_CLIENT
2453*b204b92bSPeter De Schrijver  * @brief ISO client requests
2454*b204b92bSPeter De Schrijver  *
2455*b204b92bSPeter De Schrijver  * * Platforms: T234 onwards
2456*b204b92bSPeter De Schrijver  * @cond (bpmp_t234 || bpmp_t239 || bpmp_th500)
2457*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
2458*b204b92bSPeter De Schrijver  * * Targets: BPMP
2459*b204b92bSPeter De Schrijver  * * Request Payload: @ref mrq_iso_client_request
2460*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_iso_client_response
2461*b204b92bSPeter De Schrijver  *
2462*b204b92bSPeter De Schrijver  * @addtogroup ISO_CLIENT
2463*b204b92bSPeter De Schrijver  * @{
2464*b204b92bSPeter De Schrijver  */
2465*b204b92bSPeter De Schrijver 
2466*b204b92bSPeter De Schrijver enum mrq_iso_client_cmd {
2467*b204b92bSPeter De Schrijver 	/**
2468*b204b92bSPeter De Schrijver 	 * @brief Check whether the BPMP driver supports the specified
2469*b204b92bSPeter De Schrijver 	 * request type
2470*b204b92bSPeter De Schrijver 	 *
2471*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the specified request is
2472*b204b92bSPeter De Schrijver 	 * supported and -#BPMP_ENODEV otherwise.
2473*b204b92bSPeter De Schrijver 	 */
2474*b204b92bSPeter De Schrijver 	CMD_ISO_CLIENT_QUERY_ABI = 0,
2475*b204b92bSPeter De Schrijver 
2476*b204b92bSPeter De Schrijver 	/*
2477*b204b92bSPeter De Schrijver 	 * @brief check for legal LA for the iso client. Without programming
2478*b204b92bSPeter De Schrijver 	 * LA MC registers, calculate and ensure that legal LA is possible for
2479*b204b92bSPeter De Schrijver 	 * iso bw requested by the ISO client.
2480*b204b92bSPeter De Schrijver 	 *
2481*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2482*b204b92bSPeter De Schrijver 	 * *  0: check la succeeded.
2483*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EINVAL: Invalid request parameters.
2484*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EFAULT: Legal LA is not possible for client requested iso_bw
2485*b204b92bSPeter De Schrijver 	 */
2486*b204b92bSPeter De Schrijver 	CMD_ISO_CLIENT_CALCULATE_LA = 1,
2487*b204b92bSPeter De Schrijver 
2488*b204b92bSPeter De Schrijver 	/*
2489*b204b92bSPeter De Schrijver 	 * @brief set LA for the iso client. Calculate and program the LA/PTSA
2490*b204b92bSPeter De Schrijver 	 * MC registers corresponding to the client making bw request
2491*b204b92bSPeter De Schrijver 	 *
2492*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2493*b204b92bSPeter De Schrijver 	 * *  0: set la succeeded.
2494*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EINVAL: Invalid request parameters.
2495*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EFAULT: Failed to calculate or program MC registers.
2496*b204b92bSPeter De Schrijver 	 */
2497*b204b92bSPeter De Schrijver 	CMD_ISO_CLIENT_SET_LA = 2,
2498*b204b92bSPeter De Schrijver 
2499*b204b92bSPeter De Schrijver 	/*
2500*b204b92bSPeter De Schrijver 	 * @brief Get max possible bw for iso client
2501*b204b92bSPeter De Schrijver 	 *
2502*b204b92bSPeter De Schrijver 	 * mrq_response::err is
2503*b204b92bSPeter De Schrijver 	 * *  0: get_max_bw succeeded.
2504*b204b92bSPeter De Schrijver 	 * *  -#BPMP_EINVAL: Invalid request parameters.
2505*b204b92bSPeter De Schrijver 	 */
2506*b204b92bSPeter De Schrijver 	CMD_ISO_CLIENT_GET_MAX_BW = 3
2507*b204b92bSPeter De Schrijver };
2508*b204b92bSPeter De Schrijver 
2509*b204b92bSPeter De Schrijver /*
2510*b204b92bSPeter De Schrijver  * request data for request type CMD_ISO_CLIENT_QUERY_ABI
2511*b204b92bSPeter De Schrijver  *
2512*b204b92bSPeter De Schrijver  * type: Request type for which to check existence.
2513*b204b92bSPeter De Schrijver  */
2514*b204b92bSPeter De Schrijver struct cmd_iso_client_query_abi_request {
2515*b204b92bSPeter De Schrijver 	uint32_t type;
2516*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2517*b204b92bSPeter De Schrijver 
2518*b204b92bSPeter De Schrijver /*
2519*b204b92bSPeter De Schrijver  * request data for request type CMD_ISO_CLIENT_CALCULATE_LA
2520*b204b92bSPeter De Schrijver  *
2521*b204b92bSPeter De Schrijver  * id: client ID in @ref bpmp_bwmgr_ids
2522*b204b92bSPeter De Schrijver  * bw: bw requested in kBps by client ID.
2523*b204b92bSPeter De Schrijver  * init_bw_floor: initial dram_bw_floor in kBps passed by client ID.
2524*b204b92bSPeter De Schrijver  * ISO client will perform mempool allocation and DVFS buffering based
2525*b204b92bSPeter De Schrijver  * on this dram_bw_floor.
2526*b204b92bSPeter De Schrijver  */
2527*b204b92bSPeter De Schrijver struct cmd_iso_client_calculate_la_request {
2528*b204b92bSPeter De Schrijver 	uint32_t id;
2529*b204b92bSPeter De Schrijver 	uint32_t bw;
2530*b204b92bSPeter De Schrijver 	uint32_t init_bw_floor;
2531*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2532*b204b92bSPeter De Schrijver 
2533*b204b92bSPeter De Schrijver /*
2534*b204b92bSPeter De Schrijver  * request data for request type CMD_ISO_CLIENT_SET_LA
2535*b204b92bSPeter De Schrijver  *
2536*b204b92bSPeter De Schrijver  * id: client ID in @ref bpmp_bwmgr_ids
2537*b204b92bSPeter De Schrijver  * bw: bw requested in kBps by client ID.
2538*b204b92bSPeter De Schrijver  * final_bw_floor: final dram_bw_floor in kBps.
2539*b204b92bSPeter De Schrijver  * Sometimes the initial dram_bw_floor passed by ISO client may need to be
2540*b204b92bSPeter De Schrijver  * updated by considering higher dram freq's. This is the final dram_bw_floor
2541*b204b92bSPeter De Schrijver  * used to calculate and program MC registers.
2542*b204b92bSPeter De Schrijver  */
2543*b204b92bSPeter De Schrijver struct cmd_iso_client_set_la_request {
2544*b204b92bSPeter De Schrijver 	uint32_t id;
2545*b204b92bSPeter De Schrijver 	uint32_t bw;
2546*b204b92bSPeter De Schrijver 	uint32_t final_bw_floor;
2547*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2548*b204b92bSPeter De Schrijver 
2549*b204b92bSPeter De Schrijver /*
2550*b204b92bSPeter De Schrijver  * request data for request type CMD_ISO_CLIENT_GET_MAX_BW
2551*b204b92bSPeter De Schrijver  *
2552*b204b92bSPeter De Schrijver  * id: client ID in @ref bpmp_bwmgr_ids
2553*b204b92bSPeter De Schrijver  */
2554*b204b92bSPeter De Schrijver struct cmd_iso_client_get_max_bw_request {
2555*b204b92bSPeter De Schrijver 	uint32_t id;
2556*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2557*b204b92bSPeter De Schrijver 
2558*b204b92bSPeter De Schrijver /*
2559*b204b92bSPeter De Schrijver  * response data for request type CMD_ISO_CLIENT_CALCULATE_LA
2560*b204b92bSPeter De Schrijver  *
2561*b204b92bSPeter De Schrijver  * la_rate_floor: minimum dram_rate_floor in kHz at which a legal la is possible
2562*b204b92bSPeter De Schrijver  * iso_client_only_rate: Minimum dram freq in kHz required to satisfy this clients
2563*b204b92bSPeter De Schrijver  * iso bw request, assuming all other iso clients are inactive
2564*b204b92bSPeter De Schrijver  */
2565*b204b92bSPeter De Schrijver struct cmd_iso_client_calculate_la_response {
2566*b204b92bSPeter De Schrijver 	uint32_t la_rate_floor;
2567*b204b92bSPeter De Schrijver 	uint32_t iso_client_only_rate;
2568*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2569*b204b92bSPeter De Schrijver 
2570*b204b92bSPeter De Schrijver /**
2571*b204b92bSPeter De Schrijver  * @brief Used by @ref cmd_iso_client_get_max_bw_response
2572*b204b92bSPeter De Schrijver  */
2573*b204b92bSPeter De Schrijver struct iso_max_bw {
2574*b204b92bSPeter De Schrijver 	/* @brief dram frequency in kHz */
2575*b204b92bSPeter De Schrijver 	uint32_t freq;
2576*b204b92bSPeter De Schrijver 	/* @brief max possible iso-bw in kBps */
2577*b204b92bSPeter De Schrijver 	uint32_t iso_bw;
2578*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2579*b204b92bSPeter De Schrijver 
2580*b204b92bSPeter De Schrijver #define ISO_MAX_BW_MAX_SIZE	14U
2581*b204b92bSPeter De Schrijver /*
2582*b204b92bSPeter De Schrijver  * response data for request type CMD_ISO_CLIENT_GET_MAX_BW
2583*b204b92bSPeter De Schrijver  */
2584*b204b92bSPeter De Schrijver struct cmd_iso_client_get_max_bw_response {
2585*b204b92bSPeter De Schrijver 	/* @brief The number valid entries in iso_max_bw pairs */
2586*b204b92bSPeter De Schrijver 	uint32_t num_pairs;
2587*b204b92bSPeter De Schrijver 	/* @brief max ISOBW <dram freq, max bw> information */
2588*b204b92bSPeter De Schrijver 	struct iso_max_bw pairs[ISO_MAX_BW_MAX_SIZE];
2589*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2590*b204b92bSPeter De Schrijver 
2591*b204b92bSPeter De Schrijver /**
2592*b204b92bSPeter De Schrijver  * @brief Request with #MRQ_ISO_CLIENT
2593*b204b92bSPeter De Schrijver  *
2594*b204b92bSPeter De Schrijver  * Used by the sender of an #MRQ_ISO_CLIENT message.
2595*b204b92bSPeter De Schrijver  *
2596*b204b92bSPeter De Schrijver  * |sub-command                          |payload                                 |
2597*b204b92bSPeter De Schrijver  * |------------------------------------ |----------------------------------------|
2598*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_QUERY_ABI		 |cmd_iso_client_query_abi_request        |
2599*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_CALCULATE_LA		 |cmd_iso_client_calculate_la_request     |
2600*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_SET_LA		 |cmd_iso_client_set_la_request           |
2601*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_GET_MAX_BW		 |cmd_iso_client_get_max_bw_request       |
2602*b204b92bSPeter De Schrijver  *
2603*b204b92bSPeter De Schrijver  */
2604*b204b92bSPeter De Schrijver 
2605*b204b92bSPeter De Schrijver struct mrq_iso_client_request {
2606*b204b92bSPeter De Schrijver 	/* Type of request. Values listed in enum mrq_iso_client_cmd */
2607*b204b92bSPeter De Schrijver 	uint32_t cmd;
2608*b204b92bSPeter De Schrijver 	union {
2609*b204b92bSPeter De Schrijver 		struct cmd_iso_client_query_abi_request query_abi;
2610*b204b92bSPeter De Schrijver 		struct cmd_iso_client_calculate_la_request calculate_la_req;
2611*b204b92bSPeter De Schrijver 		struct cmd_iso_client_set_la_request set_la_req;
2612*b204b92bSPeter De Schrijver 		struct cmd_iso_client_get_max_bw_request max_isobw_req;
2613*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2614*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2615*b204b92bSPeter De Schrijver 
2616*b204b92bSPeter De Schrijver /**
2617*b204b92bSPeter De Schrijver  * @brief Response to MRQ_ISO_CLIENT
2618*b204b92bSPeter De Schrijver  *
2619*b204b92bSPeter De Schrijver  * Each sub-command supported by @ref mrq_iso_client_request may return
2620*b204b92bSPeter De Schrijver  * sub-command-specific data. Some do and some do not as indicated in
2621*b204b92bSPeter De Schrijver  * the following table
2622*b204b92bSPeter De Schrijver  *
2623*b204b92bSPeter De Schrijver  * |sub-command                  |payload                             |
2624*b204b92bSPeter De Schrijver  * |---------------------------- |------------------------------------|
2625*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_CALCULATE_LA  |cmd_iso_client_calculate_la_response|
2626*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_SET_LA        |N/A                                 |
2627*b204b92bSPeter De Schrijver  * |CMD_ISO_CLIENT_GET_MAX_BW    |cmd_iso_client_get_max_bw_response  |
2628*b204b92bSPeter De Schrijver  *
2629*b204b92bSPeter De Schrijver  */
2630*b204b92bSPeter De Schrijver 
2631*b204b92bSPeter De Schrijver struct mrq_iso_client_response {
2632*b204b92bSPeter De Schrijver 	union {
2633*b204b92bSPeter De Schrijver 		struct cmd_iso_client_calculate_la_response calculate_la_resp;
2634*b204b92bSPeter De Schrijver 		struct cmd_iso_client_get_max_bw_response max_isobw_resp;
2635*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
2636*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
2637*b204b92bSPeter De Schrijver 
2638*b204b92bSPeter De Schrijver /** @} ISO_CLIENT */
2639*b204b92bSPeter De Schrijver /** @endcond (bpmp_t234 || bpmp_t239 || bpmp_th500) */
2640983de5f9SThierry Reding 
2641983de5f9SThierry Reding /**
2642983de5f9SThierry Reding  * @ingroup MRQ_Codes
26434bef358cSTimo Alho  * @def MRQ_CPU_NDIV_LIMITS
26444bef358cSTimo Alho  * @brief CPU freq. limits in ndiv
26454bef358cSTimo Alho  *
26464bef358cSTimo Alho  * * Platforms: T194 onwards
2647*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500)
26484bef358cSTimo Alho  * * Initiators: CCPLEX
26494bef358cSTimo Alho  * * Targets: BPMP
26504bef358cSTimo Alho  * * Request Payload: @ref mrq_cpu_ndiv_limits_request
26514bef358cSTimo Alho  * * Response Payload: @ref mrq_cpu_ndiv_limits_response
26524bef358cSTimo Alho  * @addtogroup CPU
26534bef358cSTimo Alho  * @{
26544bef358cSTimo Alho  */
26554bef358cSTimo Alho 
26564bef358cSTimo Alho /**
26574bef358cSTimo Alho  * @brief Request for ndiv limits of a cluster
26584bef358cSTimo Alho  */
26594bef358cSTimo Alho struct mrq_cpu_ndiv_limits_request {
26604bef358cSTimo Alho 	/** @brief Enum cluster_id */
26614bef358cSTimo Alho 	uint32_t cluster_id;
26624e871899SJon Hunter } BPMP_ABI_PACKED;
26634bef358cSTimo Alho 
26644bef358cSTimo Alho /**
26654bef358cSTimo Alho  * @brief Response to #MRQ_CPU_NDIV_LIMITS
26664bef358cSTimo Alho  */
26674bef358cSTimo Alho struct mrq_cpu_ndiv_limits_response {
26684bef358cSTimo Alho 	/** @brief Reference frequency in Hz */
26694bef358cSTimo Alho 	uint32_t ref_clk_hz;
26704bef358cSTimo Alho 	/** @brief Post divider value */
26714bef358cSTimo Alho 	uint16_t pdiv;
26724bef358cSTimo Alho 	/** @brief Input divider value */
26734bef358cSTimo Alho 	uint16_t mdiv;
26744bef358cSTimo Alho 	/** @brief FMAX expressed with max NDIV value */
26754bef358cSTimo Alho 	uint16_t ndiv_max;
26764bef358cSTimo Alho 	/** @brief Minimum allowed NDIV value */
26774bef358cSTimo Alho 	uint16_t ndiv_min;
26784e871899SJon Hunter } BPMP_ABI_PACKED;
26794bef358cSTimo Alho 
2680*b204b92bSPeter De Schrijver /** @} CPU */
2681*b204b92bSPeter De Schrijver /** @endcond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500) */
26824bef358cSTimo Alho 
26834bef358cSTimo Alho /**
26844bef358cSTimo Alho  * @ingroup MRQ_Codes
26854bef358cSTimo Alho  * @def MRQ_CPU_AUTO_CC3
26864bef358cSTimo Alho  * @brief Query CPU cluster auto-CC3 configuration
26874bef358cSTimo Alho  *
2688*b204b92bSPeter De Schrijver  * * Platforms: T194
26894bef358cSTimo Alho  * @cond bpmp_t194
26904bef358cSTimo Alho  * * Initiators: CCPLEX
26914bef358cSTimo Alho  * * Targets: BPMP
26924bef358cSTimo Alho  * * Request Payload: @ref mrq_cpu_auto_cc3_request
26934bef358cSTimo Alho  * * Response Payload: @ref mrq_cpu_auto_cc3_response
26944bef358cSTimo Alho  * @addtogroup CC3
26954bef358cSTimo Alho  *
26964bef358cSTimo Alho  * Queries from BPMP auto-CC3 configuration (allowed/not allowed) for a
26974bef358cSTimo Alho  * specified cluster. CCPLEX s/w uses this information to override its own
26984bef358cSTimo Alho  * device tree auto-CC3 settings, so that BPMP device tree is a single source of
26994bef358cSTimo Alho  * auto-CC3 platform configuration.
27004bef358cSTimo Alho  *
27014bef358cSTimo Alho  * @{
27024bef358cSTimo Alho  */
27034bef358cSTimo Alho 
27044bef358cSTimo Alho /**
27054bef358cSTimo Alho  * @brief Request for auto-CC3 configuration of a cluster
27064bef358cSTimo Alho  */
27074bef358cSTimo Alho struct mrq_cpu_auto_cc3_request {
27084bef358cSTimo Alho 	/** @brief Enum cluster_id (logical cluster id, known to CCPLEX s/w) */
27094bef358cSTimo Alho 	uint32_t cluster_id;
27104e871899SJon Hunter } BPMP_ABI_PACKED;
27114bef358cSTimo Alho 
27124bef358cSTimo Alho /**
27134bef358cSTimo Alho  * @brief Response to #MRQ_CPU_AUTO_CC3
27144bef358cSTimo Alho  */
27154bef358cSTimo Alho struct mrq_cpu_auto_cc3_response {
27164bef358cSTimo Alho 	/**
27174bef358cSTimo Alho 	 * @brief auto-CC3 configuration
27184bef358cSTimo Alho 	 *
27194bef358cSTimo Alho 	 * - bits[31..10] reserved.
27204bef358cSTimo Alho 	 * - bits[9..1] cc3 ndiv
27214bef358cSTimo Alho 	 * - bit [0] if "1" auto-CC3 is allowed, if "0" auto-CC3 is not allowed
27224bef358cSTimo Alho 	 */
27234bef358cSTimo Alho 	uint32_t auto_cc3_config;
27244e871899SJon Hunter } BPMP_ABI_PACKED;
27254bef358cSTimo Alho 
2726*b204b92bSPeter De Schrijver /** @} CC3 */
2727*b204b92bSPeter De Schrijver /** @endcond bpmp_t194 */
2728983de5f9SThierry Reding 
272952b8b803SThierry Reding /**
273052b8b803SThierry Reding  * @ingroup MRQ_Codes
273152b8b803SThierry Reding  * @def MRQ_RINGBUF_CONSOLE
273252b8b803SThierry Reding  * @brief A ring buffer debug console for BPMP
273352b8b803SThierry Reding  * @addtogroup RingbufConsole
273452b8b803SThierry Reding  *
273552b8b803SThierry Reding  * The ring buffer debug console aims to be a substitute for the UART debug
273652b8b803SThierry Reding  * console. The debug console is implemented with two ring buffers in the
273752b8b803SThierry Reding  * BPMP-FW, the RX (receive) and TX (transmit) buffers. Characters can be read
273852b8b803SThierry Reding  * and written to the buffers by the host via the MRQ interface.
273952b8b803SThierry Reding  *
274052b8b803SThierry Reding  * @{
274152b8b803SThierry Reding  */
274252b8b803SThierry Reding 
274352b8b803SThierry Reding /**
274452b8b803SThierry Reding  * @brief Maximum number of bytes transferred in a single write command to the
274552b8b803SThierry Reding  * BPMP
274652b8b803SThierry Reding  *
274752b8b803SThierry Reding  * This is determined by the number of free bytes in the message struct,
274852b8b803SThierry Reding  * rounded down to a multiple of four.
274952b8b803SThierry Reding  */
275052b8b803SThierry Reding #define MRQ_RINGBUF_CONSOLE_MAX_WRITE_LEN 112
275152b8b803SThierry Reding 
275252b8b803SThierry Reding /**
275352b8b803SThierry Reding  * @brief Maximum number of bytes transferred in a single read command to the
275452b8b803SThierry Reding  * BPMP
275552b8b803SThierry Reding  *
275652b8b803SThierry Reding  * This is determined by the number of free bytes in the message struct,
275752b8b803SThierry Reding  * rounded down to a multiple of four.
275852b8b803SThierry Reding  */
275952b8b803SThierry Reding #define MRQ_RINGBUF_CONSOLE_MAX_READ_LEN 116
276052b8b803SThierry Reding 
276152b8b803SThierry Reding enum mrq_ringbuf_console_host_to_bpmp_cmd {
276252b8b803SThierry Reding 	/**
276352b8b803SThierry Reding 	 * @brief Check whether the BPMP driver supports the specified request
276452b8b803SThierry Reding 	 * type
276552b8b803SThierry Reding 	 *
276652b8b803SThierry Reding 	 * mrq_response::err is 0 if the specified request is supported and
276752b8b803SThierry Reding 	 * -#BPMP_ENODEV otherwise
276852b8b803SThierry Reding 	 */
276952b8b803SThierry Reding 	CMD_RINGBUF_CONSOLE_QUERY_ABI = 0,
277052b8b803SThierry Reding 	/**
277152b8b803SThierry Reding 	 * @brief Perform a read operation on the BPMP TX buffer
277252b8b803SThierry Reding 	 *
277352b8b803SThierry Reding 	 * mrq_response::err is 0
277452b8b803SThierry Reding 	 */
277552b8b803SThierry Reding 	CMD_RINGBUF_CONSOLE_READ = 1,
277652b8b803SThierry Reding 	/**
277752b8b803SThierry Reding 	 * @brief Perform a write operation on the BPMP RX buffer
277852b8b803SThierry Reding 	 *
277952b8b803SThierry Reding 	 * mrq_response::err is 0 if the operation was successful and
278052b8b803SThierry Reding 	 * -#BPMP_ENODEV otherwise
278152b8b803SThierry Reding 	 */
278252b8b803SThierry Reding 	CMD_RINGBUF_CONSOLE_WRITE = 2,
278352b8b803SThierry Reding 	/**
278452b8b803SThierry Reding 	 * @brief Get the length of the buffer and the physical addresses of
278552b8b803SThierry Reding 	 * the buffer data and the head and tail counters
278652b8b803SThierry Reding 	 *
278752b8b803SThierry Reding 	 * mrq_response::err is 0 if the operation was successful and
278852b8b803SThierry Reding 	 * -#BPMP_ENODEV otherwise
278952b8b803SThierry Reding 	 */
279052b8b803SThierry Reding 	CMD_RINGBUF_CONSOLE_GET_FIFO = 3,
279152b8b803SThierry Reding };
279252b8b803SThierry Reding 
279352b8b803SThierry Reding /**
279452b8b803SThierry Reding  * @ingroup RingbufConsole
279552b8b803SThierry Reding  * @brief Host->BPMP request data for request type
279652b8b803SThierry Reding  * #CMD_RINGBUF_CONSOLE_QUERY_ABI
279752b8b803SThierry Reding  */
279852b8b803SThierry Reding struct cmd_ringbuf_console_query_abi_req {
279952b8b803SThierry Reding 	/** @brief Command identifier to be queried */
280052b8b803SThierry Reding 	uint32_t cmd;
28014e871899SJon Hunter } BPMP_ABI_PACKED;
280252b8b803SThierry Reding 
280352b8b803SThierry Reding /** @private */
280452b8b803SThierry Reding struct cmd_ringbuf_console_query_abi_resp {
28054e871899SJon Hunter 	BPMP_ABI_EMPTY
28064e871899SJon Hunter } BPMP_ABI_PACKED;
280752b8b803SThierry Reding 
280852b8b803SThierry Reding /**
280952b8b803SThierry Reding  * @ingroup RingbufConsole
281052b8b803SThierry Reding  * @brief Host->BPMP request data for request type #CMD_RINGBUF_CONSOLE_READ
281152b8b803SThierry Reding  */
281252b8b803SThierry Reding struct cmd_ringbuf_console_read_req {
281352b8b803SThierry Reding 	/**
281452b8b803SThierry Reding 	 * @brief Number of bytes requested to be read from the BPMP TX buffer
281552b8b803SThierry Reding 	 */
281652b8b803SThierry Reding 	uint8_t len;
28174e871899SJon Hunter } BPMP_ABI_PACKED;
281852b8b803SThierry Reding 
281952b8b803SThierry Reding /**
282052b8b803SThierry Reding  * @ingroup RingbufConsole
282152b8b803SThierry Reding  * @brief BPMP->Host response data for request type #CMD_RINGBUF_CONSOLE_READ
282252b8b803SThierry Reding  */
282352b8b803SThierry Reding struct cmd_ringbuf_console_read_resp {
282452b8b803SThierry Reding 	/** @brief The actual data read from the BPMP TX buffer */
282552b8b803SThierry Reding 	uint8_t data[MRQ_RINGBUF_CONSOLE_MAX_READ_LEN];
282652b8b803SThierry Reding 	/** @brief Number of bytes in cmd_ringbuf_console_read_resp::data */
282752b8b803SThierry Reding 	uint8_t len;
28284e871899SJon Hunter } BPMP_ABI_PACKED;
282952b8b803SThierry Reding 
283052b8b803SThierry Reding /**
283152b8b803SThierry Reding  * @ingroup RingbufConsole
283252b8b803SThierry Reding  * @brief Host->BPMP request data for request type #CMD_RINGBUF_CONSOLE_WRITE
283352b8b803SThierry Reding  */
283452b8b803SThierry Reding struct cmd_ringbuf_console_write_req {
283552b8b803SThierry Reding 	/** @brief The actual data to be written to the BPMP RX buffer */
283652b8b803SThierry Reding 	uint8_t data[MRQ_RINGBUF_CONSOLE_MAX_WRITE_LEN];
283752b8b803SThierry Reding 	/** @brief Number of bytes in cmd_ringbuf_console_write_req::data */
283852b8b803SThierry Reding 	uint8_t len;
28394e871899SJon Hunter } BPMP_ABI_PACKED;
284052b8b803SThierry Reding 
284152b8b803SThierry Reding /**
284252b8b803SThierry Reding  * @ingroup RingbufConsole
284352b8b803SThierry Reding  * @brief BPMP->Host response data for request type #CMD_RINGBUF_CONSOLE_WRITE
284452b8b803SThierry Reding  */
284552b8b803SThierry Reding struct cmd_ringbuf_console_write_resp {
284652b8b803SThierry Reding 	/** @brief Number of bytes of available space in the BPMP RX buffer */
284752b8b803SThierry Reding 	uint32_t space_avail;
284852b8b803SThierry Reding 	/** @brief Number of bytes that were written to the BPMP RX buffer */
284952b8b803SThierry Reding 	uint8_t len;
28504e871899SJon Hunter } BPMP_ABI_PACKED;
285152b8b803SThierry Reding 
285252b8b803SThierry Reding /** @private */
285352b8b803SThierry Reding struct cmd_ringbuf_console_get_fifo_req {
28544e871899SJon Hunter 	BPMP_ABI_EMPTY
28554e871899SJon Hunter } BPMP_ABI_PACKED;
285652b8b803SThierry Reding 
285752b8b803SThierry Reding /**
285852b8b803SThierry Reding  * @ingroup RingbufConsole
285952b8b803SThierry Reding  * @brief BPMP->Host reply data for request type #CMD_RINGBUF_CONSOLE_GET_FIFO
286052b8b803SThierry Reding  */
286152b8b803SThierry Reding struct cmd_ringbuf_console_get_fifo_resp {
286252b8b803SThierry Reding 	/** @brief Physical address of the BPMP TX buffer */
286352b8b803SThierry Reding 	uint64_t bpmp_tx_buf_addr;
286452b8b803SThierry Reding 	/** @brief Physical address of the BPMP TX buffer head counter */
286552b8b803SThierry Reding 	uint64_t bpmp_tx_head_addr;
286652b8b803SThierry Reding 	/** @brief Physical address of the BPMP TX buffer tail counter */
286752b8b803SThierry Reding 	uint64_t bpmp_tx_tail_addr;
286852b8b803SThierry Reding 	/** @brief Length of the BPMP TX buffer */
286952b8b803SThierry Reding 	uint32_t bpmp_tx_buf_len;
28704e871899SJon Hunter } BPMP_ABI_PACKED;
287152b8b803SThierry Reding 
287252b8b803SThierry Reding /**
287352b8b803SThierry Reding  * @ingroup RingbufConsole
287452b8b803SThierry Reding  * @brief Host->BPMP request data.
287552b8b803SThierry Reding  *
287652b8b803SThierry Reding  * Reply type is union #mrq_ringbuf_console_bpmp_to_host_response .
287752b8b803SThierry Reding  */
287852b8b803SThierry Reding struct mrq_ringbuf_console_host_to_bpmp_request {
287952b8b803SThierry Reding 	/**
28804bef358cSTimo Alho 	 * @brief Type of request. Values listed in enum
288152b8b803SThierry Reding 	 * #mrq_ringbuf_console_host_to_bpmp_cmd.
288252b8b803SThierry Reding 	 */
288352b8b803SThierry Reding 	uint32_t type;
288452b8b803SThierry Reding 	/** @brief  request type specific parameters. */
288552b8b803SThierry Reding 	union {
288652b8b803SThierry Reding 		struct cmd_ringbuf_console_query_abi_req query_abi;
288752b8b803SThierry Reding 		struct cmd_ringbuf_console_read_req read;
288852b8b803SThierry Reding 		struct cmd_ringbuf_console_write_req write;
288952b8b803SThierry Reding 		struct cmd_ringbuf_console_get_fifo_req get_fifo;
28904e871899SJon Hunter 	} BPMP_UNION_ANON;
28914e871899SJon Hunter } BPMP_ABI_PACKED;
289252b8b803SThierry Reding 
289352b8b803SThierry Reding /**
289452b8b803SThierry Reding  * @ingroup RingbufConsole
289552b8b803SThierry Reding  * @brief Host->BPMP reply data
289652b8b803SThierry Reding  *
289752b8b803SThierry Reding  * In response to struct #mrq_ringbuf_console_host_to_bpmp_request.
289852b8b803SThierry Reding  */
289952b8b803SThierry Reding union mrq_ringbuf_console_bpmp_to_host_response {
290052b8b803SThierry Reding 	struct cmd_ringbuf_console_query_abi_resp query_abi;
290152b8b803SThierry Reding 	struct cmd_ringbuf_console_read_resp read;
290252b8b803SThierry Reding 	struct cmd_ringbuf_console_write_resp write;
290352b8b803SThierry Reding 	struct cmd_ringbuf_console_get_fifo_resp get_fifo;
29044e871899SJon Hunter } BPMP_ABI_PACKED;
2905*b204b92bSPeter De Schrijver 
2906*b204b92bSPeter De Schrijver /** @} RingbufConsole */
290752b8b803SThierry Reding 
29084bef358cSTimo Alho /**
29094bef358cSTimo Alho  * @ingroup MRQ_Codes
29104bef358cSTimo Alho  * @def MRQ_STRAP
29114bef358cSTimo Alho  * @brief Set a strap value controlled by BPMP
29124bef358cSTimo Alho  *
29134bef358cSTimo Alho  * * Platforms: T194 onwards
2914*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500)
29154bef358cSTimo Alho  * * Initiators: CCPLEX
29164bef358cSTimo Alho  * * Targets: BPMP
29174bef358cSTimo Alho  * * Request Payload: @ref mrq_strap_request
29184bef358cSTimo Alho  * * Response Payload: N/A
29194bef358cSTimo Alho  * @addtogroup Strap
29204bef358cSTimo Alho  *
29214bef358cSTimo Alho  * A strap is an input that is sampled by a hardware unit during the
29224bef358cSTimo Alho  * unit's startup process. The sampled value of a strap affects the
29234bef358cSTimo Alho  * behavior of the unit until the unit is restarted. Many hardware
29244bef358cSTimo Alho  * units sample their straps at the instant that their resets are
29254bef358cSTimo Alho  * deasserted.
29264bef358cSTimo Alho  *
29274bef358cSTimo Alho  * BPMP owns registers which act as straps to various units. It
29284bef358cSTimo Alho  * exposes limited control of those straps via #MRQ_STRAP.
29294bef358cSTimo Alho  *
29304bef358cSTimo Alho  * @{
29314bef358cSTimo Alho  */
29324bef358cSTimo Alho enum mrq_strap_cmd {
29334bef358cSTimo Alho 	/** @private */
29344bef358cSTimo Alho 	STRAP_RESERVED = 0,
29354bef358cSTimo Alho 	/** @brief Set a strap value */
29364bef358cSTimo Alho 	STRAP_SET = 1
29374bef358cSTimo Alho };
29384bef358cSTimo Alho 
29394bef358cSTimo Alho /**
29404bef358cSTimo Alho  * @brief Request with #MRQ_STRAP
29414bef358cSTimo Alho  */
29424bef358cSTimo Alho struct mrq_strap_request {
29434bef358cSTimo Alho 	/** @brief @ref mrq_strap_cmd */
29444bef358cSTimo Alho 	uint32_t cmd;
2945*b204b92bSPeter De Schrijver 	/** @brief Strap ID from @ref Strap_Identifiers */
29464bef358cSTimo Alho 	uint32_t id;
29474bef358cSTimo Alho 	/** @brief Desired value for strap (if cmd is #STRAP_SET) */
29484bef358cSTimo Alho 	uint32_t value;
29494e871899SJon Hunter } BPMP_ABI_PACKED;
29504bef358cSTimo Alho 
2951*b204b92bSPeter De Schrijver /** @} Strap */
2952*b204b92bSPeter De Schrijver /** @endcond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500) */
29534bef358cSTimo Alho 
29544bef358cSTimo Alho /**
29554bef358cSTimo Alho  * @ingroup MRQ_Codes
29564bef358cSTimo Alho  * @def MRQ_UPHY
29574bef358cSTimo Alho  * @brief Perform a UPHY operation
29584bef358cSTimo Alho  *
29594bef358cSTimo Alho  * * Platforms: T194 onwards
2960*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500)
29614bef358cSTimo Alho  * * Initiators: CCPLEX
29624bef358cSTimo Alho  * * Targets: BPMP
29634bef358cSTimo Alho  * * Request Payload: @ref mrq_uphy_request
29644bef358cSTimo Alho  * * Response Payload: @ref mrq_uphy_response
29654bef358cSTimo Alho  *
29664bef358cSTimo Alho  * @addtogroup UPHY
29674bef358cSTimo Alho  * @{
29684bef358cSTimo Alho  */
29694bef358cSTimo Alho enum {
29704bef358cSTimo Alho 	CMD_UPHY_PCIE_LANE_MARGIN_CONTROL = 1,
29714bef358cSTimo Alho 	CMD_UPHY_PCIE_LANE_MARGIN_STATUS = 2,
29724bef358cSTimo Alho 	CMD_UPHY_PCIE_EP_CONTROLLER_PLL_INIT = 3,
29734bef358cSTimo Alho 	CMD_UPHY_PCIE_CONTROLLER_STATE = 4,
2974ee22d0c5SVidya Sagar 	CMD_UPHY_PCIE_EP_CONTROLLER_PLL_OFF = 5,
2975*b204b92bSPeter De Schrijver 	CMD_UPHY_DISPLAY_PORT_INIT = 6,
2976*b204b92bSPeter De Schrijver 	CMD_UPHY_DISPLAY_PORT_OFF = 7,
2977*b204b92bSPeter De Schrijver 	CMD_UPHY_XUSB_DYN_LANES_RESTORE = 8,
29784bef358cSTimo Alho 	CMD_UPHY_MAX,
29794bef358cSTimo Alho };
29804bef358cSTimo Alho 
29814bef358cSTimo Alho struct cmd_uphy_margin_control_request {
29824bef358cSTimo Alho 	/** @brief Enable margin */
29834bef358cSTimo Alho 	int32_t en;
29844bef358cSTimo Alho 	/** @brief Clear the number of error and sections */
29854bef358cSTimo Alho 	int32_t clr;
29864bef358cSTimo Alho 	/** @brief Set x offset (1's complement) for left/right margin type (y should be 0) */
29874bef358cSTimo Alho 	uint32_t x;
29884bef358cSTimo Alho 	/** @brief Set y offset (1's complement) for left/right margin type (x should be 0) */
29894bef358cSTimo Alho 	uint32_t y;
29904bef358cSTimo Alho 	/** @brief Set number of bit blocks for each margin section */
29914bef358cSTimo Alho 	uint32_t nblks;
29924e871899SJon Hunter } BPMP_ABI_PACKED;
29934bef358cSTimo Alho 
29944bef358cSTimo Alho struct cmd_uphy_margin_status_response {
29954bef358cSTimo Alho 	/** @brief Number of errors observed */
29964bef358cSTimo Alho 	uint32_t status;
29974e871899SJon Hunter } BPMP_ABI_PACKED;
29984bef358cSTimo Alho 
29994bef358cSTimo Alho struct cmd_uphy_ep_controller_pll_init_request {
3000*b204b92bSPeter De Schrijver 	/** @brief EP controller number, T194 valid: 0, 4, 5; T234 valid: 5, 6, 7, 10; T239 valid: 0 */
30014bef358cSTimo Alho 	uint8_t ep_controller;
30024e871899SJon Hunter } BPMP_ABI_PACKED;
30034bef358cSTimo Alho 
30044bef358cSTimo Alho struct cmd_uphy_pcie_controller_state_request {
3005*b204b92bSPeter De Schrijver 	/** @brief PCIE controller number, T194 valid: 0-4; T234 valid: 0-10; T239 valid: 0-3 */
30064bef358cSTimo Alho 	uint8_t pcie_controller;
30074bef358cSTimo Alho 	uint8_t enable;
30084e871899SJon Hunter } BPMP_ABI_PACKED;
30094bef358cSTimo Alho 
3010ee22d0c5SVidya Sagar struct cmd_uphy_ep_controller_pll_off_request {
3011*b204b92bSPeter De Schrijver 	/** @brief EP controller number, T194 valid: 0, 4, 5; T234 valid: 5, 6, 7, 10; T239 valid: 0 */
3012ee22d0c5SVidya Sagar 	uint8_t ep_controller;
30134e871899SJon Hunter } BPMP_ABI_PACKED;
3014ee22d0c5SVidya Sagar 
3015*b204b92bSPeter De Schrijver struct cmd_uphy_display_port_init_request {
3016*b204b92bSPeter De Schrijver 	/** @brief DisplayPort link rate, T239 valid: 1620, 2700, 5400, 8100, 2160, 2430, 3240, 4320, 6750 */
3017*b204b92bSPeter De Schrijver 	uint16_t link_rate;
3018*b204b92bSPeter De Schrijver 	/** @brief 1: lane 0; 2: lane 1; 3: lane 0 and 1 */
3019*b204b92bSPeter De Schrijver 	uint16_t lanes_bitmap;
3020*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3021*b204b92bSPeter De Schrijver 
3022*b204b92bSPeter De Schrijver struct cmd_uphy_xusb_dyn_lanes_restore_request {
3023*b204b92bSPeter De Schrijver 	/** @brief 1: lane 0; 2: lane 1; 3: lane 0 and 1 */
3024*b204b92bSPeter De Schrijver 	uint16_t lanes_bitmap;
3025*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3026*b204b92bSPeter De Schrijver 
30274bef358cSTimo Alho /**
30284bef358cSTimo Alho  * @ingroup UPHY
30294bef358cSTimo Alho  * @brief Request with #MRQ_UPHY
30304bef358cSTimo Alho  *
3031*b204b92bSPeter De Schrijver  * Used by the sender of an #MRQ_UPHY message to control UPHY.
3032*b204b92bSPeter De Schrijver  * The uphy_request is split into several sub-commands. CMD_UPHY_PCIE_LANE_MARGIN_STATUS
3033*b204b92bSPeter De Schrijver  * requires no additional data. Others have a sub-command specific payload. Below table
3034*b204b92bSPeter De Schrijver  * shows sub-commands with their corresponding payload data.
30354bef358cSTimo Alho  *
30364bef358cSTimo Alho  * |sub-command                          |payload                                 |
30374bef358cSTimo Alho  * |------------------------------------ |----------------------------------------|
30384bef358cSTimo Alho  * |CMD_UPHY_PCIE_LANE_MARGIN_CONTROL    |uphy_set_margin_control                 |
30394bef358cSTimo Alho  * |CMD_UPHY_PCIE_LANE_MARGIN_STATUS     |                                        |
30404bef358cSTimo Alho  * |CMD_UPHY_PCIE_EP_CONTROLLER_PLL_INIT |cmd_uphy_ep_controller_pll_init_request |
30414bef358cSTimo Alho  * |CMD_UPHY_PCIE_CONTROLLER_STATE       |cmd_uphy_pcie_controller_state_request  |
3042ee22d0c5SVidya Sagar  * |CMD_UPHY_PCIE_EP_CONTROLLER_PLL_OFF  |cmd_uphy_ep_controller_pll_off_request  |
3043*b204b92bSPeter De Schrijver  * |CMD_UPHY_PCIE_DISPLAY_PORT_INIT      |cmd_uphy_display_port_init_request      |
3044*b204b92bSPeter De Schrijver  * |CMD_UPHY_PCIE_DISPLAY_PORT_OFF       |                                        |
3045*b204b92bSPeter De Schrijver  * |CMD_UPHY_XUSB_DYN_LANES_RESTORE      |cmd_uphy_xusb_dyn_lanes_restore_request |
30464bef358cSTimo Alho  *
3047983de5f9SThierry Reding  */
3048983de5f9SThierry Reding 
30494bef358cSTimo Alho struct mrq_uphy_request {
30504bef358cSTimo Alho 	/** @brief Lane number. */
30514bef358cSTimo Alho 	uint16_t lane;
30524bef358cSTimo Alho 	/** @brief Sub-command id. */
30534bef358cSTimo Alho 	uint16_t cmd;
30544bef358cSTimo Alho 
30554bef358cSTimo Alho 	union {
30564bef358cSTimo Alho 		struct cmd_uphy_margin_control_request uphy_set_margin_control;
30574bef358cSTimo Alho 		struct cmd_uphy_ep_controller_pll_init_request ep_ctrlr_pll_init;
30584bef358cSTimo Alho 		struct cmd_uphy_pcie_controller_state_request controller_state;
3059ee22d0c5SVidya Sagar 		struct cmd_uphy_ep_controller_pll_off_request ep_ctrlr_pll_off;
3060*b204b92bSPeter De Schrijver 		struct cmd_uphy_display_port_init_request display_port_init;
3061*b204b92bSPeter De Schrijver 		struct cmd_uphy_xusb_dyn_lanes_restore_request xusb_dyn_lanes_restore;
30624e871899SJon Hunter 	} BPMP_UNION_ANON;
30634e871899SJon Hunter } BPMP_ABI_PACKED;
30644bef358cSTimo Alho 
30654bef358cSTimo Alho /**
30664bef358cSTimo Alho  * @ingroup UPHY
30674bef358cSTimo Alho  * @brief Response to MRQ_UPHY
3068983de5f9SThierry Reding  *
30694bef358cSTimo Alho  * Each sub-command supported by @ref mrq_uphy_request may return
30704bef358cSTimo Alho  * sub-command-specific data. Some do and some do not as indicated in
30714bef358cSTimo Alho  * the following table
3072983de5f9SThierry Reding  *
30734bef358cSTimo Alho  * |sub-command                       |payload                 |
30744bef358cSTimo Alho  * |----------------------------      |------------------------|
30754bef358cSTimo Alho  * |CMD_UPHY_PCIE_LANE_MARGIN_CONTROL |                        |
30764bef358cSTimo Alho  * |CMD_UPHY_PCIE_LANE_MARGIN_STATUS  |uphy_get_margin_status  |
3077983de5f9SThierry Reding  *
3078983de5f9SThierry Reding  */
3079983de5f9SThierry Reding 
30804bef358cSTimo Alho struct mrq_uphy_response {
30814bef358cSTimo Alho 	union {
30824bef358cSTimo Alho 		struct cmd_uphy_margin_status_response uphy_get_margin_status;
30834e871899SJon Hunter 	} BPMP_UNION_ANON;
30844e871899SJon Hunter } BPMP_ABI_PACKED;
30854bef358cSTimo Alho 
3086*b204b92bSPeter De Schrijver /** @} UPHY */
3087*b204b92bSPeter De Schrijver /** @endcond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500) */
30884bef358cSTimo Alho 
30894bef358cSTimo Alho /**
30904bef358cSTimo Alho  * @ingroup MRQ_Codes
30914bef358cSTimo Alho  * @def MRQ_FMON
30924bef358cSTimo Alho  * @brief Perform a frequency monitor configuration operations
3093983de5f9SThierry Reding  *
30944bef358cSTimo Alho  * * Platforms: T194 onwards
3095*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500)
30964bef358cSTimo Alho  * * Initiators: CCPLEX
30974bef358cSTimo Alho  * * Targets: BPMP
30984bef358cSTimo Alho  * * Request Payload: @ref mrq_fmon_request
30994bef358cSTimo Alho  * * Response Payload: @ref mrq_fmon_response
3100*b204b92bSPeter De Schrijver  * @endcond (bpmp_t194 || bpmp_t234 || bpmp_t239 || bpmp_th500)
31014bef358cSTimo Alho  *
31024bef358cSTimo Alho  * @addtogroup FMON
31034bef358cSTimo Alho  * @{
3104*b204b92bSPeter De Schrijver  * @cond (bpmp_t194 || bpmp_t234)
31054bef358cSTimo Alho  */
31064bef358cSTimo Alho enum {
31074bef358cSTimo Alho 	/**
31084bef358cSTimo Alho 	 * @brief Clamp FMON configuration to specified rate.
31094bef358cSTimo Alho 	 *
31104bef358cSTimo Alho 	 * The monitored clock must be running for clamp to succeed. If
31114bef358cSTimo Alho 	 * clamped, FMON configuration is preserved when clock rate
31124bef358cSTimo Alho 	 * and/or state is changed.
3113*b204b92bSPeter De Schrijver 	 *
3114*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the operation was successful, or @n
3115*b204b92bSPeter De Schrijver 	 * -#BPMP_EACCES: FMON access error @n
3116*b204b92bSPeter De Schrijver 	 * -#BPMP_EBADCMD if subcommand is not supported @n
3117*b204b92bSPeter De Schrijver 	 * -#BPMP_EBADSLT: clamp FMON on cluster with auto-CC3 enabled @n
3118*b204b92bSPeter De Schrijver 	 * -#BPMP_EBUSY: fmon is already clamped at different rate @n
3119*b204b92bSPeter De Schrijver 	 * -#BPMP_EFAULT: self-diagnostic error @n
3120*b204b92bSPeter De Schrijver 	 * -#BPMP_EINVAL: invalid FMON configuration @n
3121*b204b92bSPeter De Schrijver 	 * -#BPMP_EOPNOTSUPP: not in production mode @n
3122*b204b92bSPeter De Schrijver 	 * -#BPMP_ENODEV: invalid clk_id @n
3123*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOENT: no calibration data, uninitialized @n
3124*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOTSUP: avfs config not set @n
3125*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOSYS: clamp FMON on cluster clock w/ no NAFLL @n
3126*b204b92bSPeter De Schrijver 	 * -#BPMP_ETIMEDOUT: operation timed out @n
31274bef358cSTimo Alho 	 */
31284bef358cSTimo Alho 	CMD_FMON_GEAR_CLAMP = 1,
31294bef358cSTimo Alho 	/**
31304bef358cSTimo Alho 	 * @brief Release clamped FMON configuration.
31314bef358cSTimo Alho 	 *
31324bef358cSTimo Alho 	 * Allow FMON configuration to follow monitored clock rate
31334bef358cSTimo Alho 	 * and/or state changes.
3134*b204b92bSPeter De Schrijver 	 *
3135*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the operation was successful, or @n
3136*b204b92bSPeter De Schrijver 	 * -#BPMP_EBADCMD if subcommand is not supported @n
3137*b204b92bSPeter De Schrijver 	 * -#BPMP_ENODEV: invalid clk_id @n
3138*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOENT: no calibration data, uninitialized @n
3139*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOTSUP: avfs config not set @n
3140*b204b92bSPeter De Schrijver 	 * -#BPMP_EOPNOTSUPP: not in production mode @n
31414bef358cSTimo Alho 	 */
31424bef358cSTimo Alho 	CMD_FMON_GEAR_FREE = 2,
31434bef358cSTimo Alho 	/**
31444bef358cSTimo Alho 	 * @brief Return rate FMON is clamped at, or 0 if FMON is not
31454bef358cSTimo Alho 	 *         clamped.
31464bef358cSTimo Alho 	 *
31474bef358cSTimo Alho 	 * Inherently racy, since clamp state can be changed
31484bef358cSTimo Alho 	 * concurrently. Useful for testing.
3149*b204b92bSPeter De Schrijver 	 *
3150*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the operation was successful, or @n
3151*b204b92bSPeter De Schrijver 	 * -#BPMP_EBADCMD if subcommand is not supported @n
3152*b204b92bSPeter De Schrijver 	 * -#BPMP_ENODEV: invalid clk_id @n
3153*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOENT: no calibration data, uninitialized @n
3154*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOTSUP: avfs config not set @n
3155*b204b92bSPeter De Schrijver 	 * -#BPMP_EOPNOTSUPP: not in production mode @n
31564bef358cSTimo Alho 	 */
31574bef358cSTimo Alho 	CMD_FMON_GEAR_GET = 3,
3158*b204b92bSPeter De Schrijver 	/**
3159*b204b92bSPeter De Schrijver 	 * @brief Return current status of FMON faults detected by FMON
3160*b204b92bSPeter De Schrijver 	 *         h/w or s/w since last invocation of this command.
3161*b204b92bSPeter De Schrijver 	 *         Clears fault status.
3162*b204b92bSPeter De Schrijver 	 *
3163*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the operation was successful, or @n
3164*b204b92bSPeter De Schrijver 	 * -#BPMP_EBADCMD if subcommand is not supported @n
3165*b204b92bSPeter De Schrijver 	 * -#BPMP_EINVAL: invalid fault type @n
3166*b204b92bSPeter De Schrijver 	 * -#BPMP_ENODEV: invalid clk_id @n
3167*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOENT: no calibration data, uninitialized @n
3168*b204b92bSPeter De Schrijver 	 * -#BPMP_ENOTSUP: avfs config not set @n
3169*b204b92bSPeter De Schrijver 	 * -#BPMP_EOPNOTSUPP: not in production mode @n
3170*b204b92bSPeter De Schrijver 	 */
3171*b204b92bSPeter De Schrijver 	CMD_FMON_FAULT_STS_GET = 4,
31724bef358cSTimo Alho };
31734bef358cSTimo Alho 
3174*b204b92bSPeter De Schrijver /**
3175*b204b92bSPeter De Schrijver  * @cond DEPRECATED
3176*b204b92bSPeter De Schrijver  * Kept for backward compatibility
3177*b204b92bSPeter De Schrijver  */
3178*b204b92bSPeter De Schrijver #define CMD_FMON_NUM		4
3179*b204b92bSPeter De Schrijver 
3180*b204b92bSPeter De Schrijver /** @endcond DEPRECATED */
3181*b204b92bSPeter De Schrijver 
3182*b204b92bSPeter De Schrijver /**
3183*b204b92bSPeter De Schrijver  * @defgroup fmon_fault_type FMON fault type
3184*b204b92bSPeter De Schrijver  * @addtogroup fmon_fault_type
3185*b204b92bSPeter De Schrijver  * @{
3186*b204b92bSPeter De Schrijver  */
3187*b204b92bSPeter De Schrijver /** @brief All detected FMON faults (h/w or s/w) */
3188*b204b92bSPeter De Schrijver #define FMON_FAULT_TYPE_ALL		0U
3189*b204b92bSPeter De Schrijver /** @brief FMON faults detected by h/w */
3190*b204b92bSPeter De Schrijver #define FMON_FAULT_TYPE_HW		1U
3191*b204b92bSPeter De Schrijver /** @brief FMON faults detected by s/w */
3192*b204b92bSPeter De Schrijver #define FMON_FAULT_TYPE_SW		2U
3193*b204b92bSPeter De Schrijver 
3194*b204b92bSPeter De Schrijver /** @} fmon_fault_type */
3195*b204b92bSPeter De Schrijver 
3196*b204b92bSPeter De Schrijver 
31974bef358cSTimo Alho struct cmd_fmon_gear_clamp_request {
31984bef358cSTimo Alho 	int32_t unused;
31994bef358cSTimo Alho 	int64_t rate;
32004e871899SJon Hunter } BPMP_ABI_PACKED;
32014bef358cSTimo Alho 
32024bef358cSTimo Alho /** @private */
32034bef358cSTimo Alho struct cmd_fmon_gear_clamp_response {
32044e871899SJon Hunter 	BPMP_ABI_EMPTY
32054e871899SJon Hunter } BPMP_ABI_PACKED;
32064bef358cSTimo Alho 
32074bef358cSTimo Alho /** @private */
32084bef358cSTimo Alho struct cmd_fmon_gear_free_request {
32094e871899SJon Hunter 	BPMP_ABI_EMPTY
32104e871899SJon Hunter } BPMP_ABI_PACKED;
32114bef358cSTimo Alho 
32124bef358cSTimo Alho /** @private */
32134bef358cSTimo Alho struct cmd_fmon_gear_free_response {
32144e871899SJon Hunter 	BPMP_ABI_EMPTY
32154e871899SJon Hunter } BPMP_ABI_PACKED;
32164bef358cSTimo Alho 
32174bef358cSTimo Alho /** @private */
32184bef358cSTimo Alho struct cmd_fmon_gear_get_request {
32194e871899SJon Hunter 	BPMP_ABI_EMPTY
32204e871899SJon Hunter } BPMP_ABI_PACKED;
32214bef358cSTimo Alho 
32224bef358cSTimo Alho struct cmd_fmon_gear_get_response {
32234bef358cSTimo Alho 	int64_t rate;
32244e871899SJon Hunter } BPMP_ABI_PACKED;
32254bef358cSTimo Alho 
3226*b204b92bSPeter De Schrijver struct cmd_fmon_fault_sts_get_request {
3227*b204b92bSPeter De Schrijver 	uint32_t fault_type;	/**< @ref fmon_fault_type */
3228*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3229*b204b92bSPeter De Schrijver 
3230*b204b92bSPeter De Schrijver struct cmd_fmon_fault_sts_get_response {
3231*b204b92bSPeter De Schrijver 	uint32_t fault_sts;
3232*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3233*b204b92bSPeter De Schrijver 
32344bef358cSTimo Alho /**
32354bef358cSTimo Alho  * @ingroup FMON
32364bef358cSTimo Alho  * @brief Request with #MRQ_FMON
32374bef358cSTimo Alho  *
32384bef358cSTimo Alho  * Used by the sender of an #MRQ_FMON message to configure clock
32394bef358cSTimo Alho  * frequency monitors. The FMON request is split into several
32404bef358cSTimo Alho  * sub-commands. Some sub-commands require no additional data.
32414bef358cSTimo Alho  * Others have a sub-command specific payload
32424bef358cSTimo Alho  *
32434bef358cSTimo Alho  * |sub-command                 |payload                |
32444bef358cSTimo Alho  * |----------------------------|-----------------------|
32454bef358cSTimo Alho  * |CMD_FMON_GEAR_CLAMP         |fmon_gear_clamp        |
32464bef358cSTimo Alho  * |CMD_FMON_GEAR_FREE          |-                      |
32474bef358cSTimo Alho  * |CMD_FMON_GEAR_GET           |-                      |
3248*b204b92bSPeter De Schrijver  * |CMD_FMON_FAULT_STS_GET      |fmon_fault_sts_get     |
32494bef358cSTimo Alho  *
3250983de5f9SThierry Reding  */
32514bef358cSTimo Alho struct mrq_fmon_request {
32524bef358cSTimo Alho 	/** @brief Sub-command and clock id concatenated to 32-bit word.
32534bef358cSTimo Alho 	 * - bits[31..24] is the sub-cmd.
32544bef358cSTimo Alho 	 * - bits[23..0] is monitored clock id used to select target
32554bef358cSTimo Alho 	 *   FMON
32564bef358cSTimo Alho 	 */
32574bef358cSTimo Alho 	uint32_t cmd_and_id;
32584bef358cSTimo Alho 
32594bef358cSTimo Alho 	union {
32604bef358cSTimo Alho 		struct cmd_fmon_gear_clamp_request fmon_gear_clamp;
32614bef358cSTimo Alho 		/** @private */
32624bef358cSTimo Alho 		struct cmd_fmon_gear_free_request fmon_gear_free;
32634bef358cSTimo Alho 		/** @private */
32644bef358cSTimo Alho 		struct cmd_fmon_gear_get_request fmon_gear_get;
3265*b204b92bSPeter De Schrijver 		struct cmd_fmon_fault_sts_get_request fmon_fault_sts_get;
32664e871899SJon Hunter 	} BPMP_UNION_ANON;
32674e871899SJon Hunter } BPMP_ABI_PACKED;
32684bef358cSTimo Alho 
32694bef358cSTimo Alho /**
32704bef358cSTimo Alho  * @ingroup FMON
32714bef358cSTimo Alho  * @brief Response to MRQ_FMON
3272983de5f9SThierry Reding  *
32734bef358cSTimo Alho  * Each sub-command supported by @ref mrq_fmon_request may
32744bef358cSTimo Alho  * return sub-command-specific data as indicated below.
32754bef358cSTimo Alho  *
32764bef358cSTimo Alho  * |sub-command                 |payload                 |
32774bef358cSTimo Alho  * |----------------------------|------------------------|
32784bef358cSTimo Alho  * |CMD_FMON_GEAR_CLAMP         |-                       |
32794bef358cSTimo Alho  * |CMD_FMON_GEAR_FREE          |-                       |
32804bef358cSTimo Alho  * |CMD_FMON_GEAR_GET           |fmon_gear_get           |
3281*b204b92bSPeter De Schrijver  * |CMD_FMON_FAULT_STS_GET      |fmon_fault_sts_get      |
32824bef358cSTimo Alho  *
3283983de5f9SThierry Reding  */
3284983de5f9SThierry Reding 
32854bef358cSTimo Alho struct mrq_fmon_response {
32864bef358cSTimo Alho 	union {
32874bef358cSTimo Alho 		/** @private */
32884bef358cSTimo Alho 		struct cmd_fmon_gear_clamp_response fmon_gear_clamp;
32894bef358cSTimo Alho 		/** @private */
32904bef358cSTimo Alho 		struct cmd_fmon_gear_free_response fmon_gear_free;
32914bef358cSTimo Alho 		struct cmd_fmon_gear_get_response fmon_gear_get;
3292*b204b92bSPeter De Schrijver 		struct cmd_fmon_fault_sts_get_response fmon_fault_sts_get;
32934e871899SJon Hunter 	} BPMP_UNION_ANON;
32944e871899SJon Hunter } BPMP_ABI_PACKED;
32954bef358cSTimo Alho 
3296*b204b92bSPeter De Schrijver /** @endcond (bpmp_t194 || bpmp_t234) */
3297*b204b92bSPeter De Schrijver /** @} FMON */
32984bef358cSTimo Alho 
32994bef358cSTimo Alho /**
33004bef358cSTimo Alho  * @ingroup MRQ_Codes
33014bef358cSTimo Alho  * @def MRQ_EC
33024bef358cSTimo Alho  * @brief Provide status information on faults reported by Error
33034bef358cSTimo Alho  *        Collator (EC) to HSM.
3304983de5f9SThierry Reding  *
3305*b204b92bSPeter De Schrijver  * * Platforms: T194
33064bef358cSTimo Alho  * @cond bpmp_t194
33074bef358cSTimo Alho  * * Initiators: CCPLEX
33084bef358cSTimo Alho  * * Targets: BPMP
33094bef358cSTimo Alho  * * Request Payload: @ref mrq_ec_request
33104bef358cSTimo Alho  * * Response Payload: @ref mrq_ec_response
33114bef358cSTimo Alho  *
33124bef358cSTimo Alho  * @note This MRQ ABI is under construction, and subject to change
33134bef358cSTimo Alho  *
3314*b204b92bSPeter De Schrijver  * @endcond bpmp_t194
33154bef358cSTimo Alho  * @addtogroup EC
33164bef358cSTimo Alho  * @{
3317*b204b92bSPeter De Schrijver  * @cond bpmp_t194
33184bef358cSTimo Alho  */
33194bef358cSTimo Alho enum {
33204bef358cSTimo Alho 	/**
33214e871899SJon Hunter 	 * @cond DEPRECATED
33224bef358cSTimo Alho 	 * @brief Retrieve specified EC status.
33234bef358cSTimo Alho 	 *
33244bef358cSTimo Alho 	 * mrq_response::err is 0 if the operation was successful, or @n
33254bef358cSTimo Alho 	 * -#BPMP_ENODEV if target EC is not owned by BPMP @n
33264e871899SJon Hunter 	 * -#BPMP_EACCES if target EC power domain is turned off @n
33274e871899SJon Hunter 	 * -#BPMP_EBADCMD if subcommand is not supported
3328*b204b92bSPeter De Schrijver 	 * @endcond DEPRECATED
33294bef358cSTimo Alho 	 */
33304e871899SJon Hunter 	CMD_EC_STATUS_GET = 1,	/* deprecated */
33314e871899SJon Hunter 
33324e871899SJon Hunter 	/**
33334e871899SJon Hunter 	 * @brief Retrieve specified EC extended status (includes error
33344e871899SJon Hunter 	 *        counter and user values).
33354e871899SJon Hunter 	 *
33364e871899SJon Hunter 	 * mrq_response::err is 0 if the operation was successful, or @n
33374e871899SJon Hunter 	 * -#BPMP_ENODEV if target EC is not owned by BPMP @n
33384e871899SJon Hunter 	 * -#BPMP_EACCES if target EC power domain is turned off @n
33394e871899SJon Hunter 	 * -#BPMP_EBADCMD if subcommand is not supported
33404e871899SJon Hunter 	 */
33414e871899SJon Hunter 	CMD_EC_STATUS_EX_GET = 2,
33424bef358cSTimo Alho 	CMD_EC_NUM,
33434bef358cSTimo Alho };
33444bef358cSTimo Alho 
33454bef358cSTimo Alho /** @brief BPMP ECs error types */
33464bef358cSTimo Alho enum bpmp_ec_err_type {
33474bef358cSTimo Alho 	/** @brief Parity error on internal data path
33484bef358cSTimo Alho 	 *
33494bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
33504bef358cSTimo Alho 	 */
33514bef358cSTimo Alho 	EC_ERR_TYPE_PARITY_INTERNAL		= 1,
33524bef358cSTimo Alho 
33534bef358cSTimo Alho 	/** @brief ECC SEC error on internal data path
33544bef358cSTimo Alho 	 *
33554bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
33564bef358cSTimo Alho 	 */
33574bef358cSTimo Alho 	EC_ERR_TYPE_ECC_SEC_INTERNAL		= 2,
33584bef358cSTimo Alho 
33594bef358cSTimo Alho 	/** @brief ECC DED error on internal data path
33604bef358cSTimo Alho 	 *
33614bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
33624bef358cSTimo Alho 	 */
33634bef358cSTimo Alho 	EC_ERR_TYPE_ECC_DED_INTERNAL		= 3,
33644bef358cSTimo Alho 
33654bef358cSTimo Alho 	/** @brief Comparator error
33664bef358cSTimo Alho 	 *
33674bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
33684bef358cSTimo Alho 	 */
33694bef358cSTimo Alho 	EC_ERR_TYPE_COMPARATOR			= 4,
33704bef358cSTimo Alho 
33714bef358cSTimo Alho 	/** @brief Register parity error
33724bef358cSTimo Alho 	 *
33734bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_reg_parity_desc.
33744bef358cSTimo Alho 	 */
33754bef358cSTimo Alho 	EC_ERR_TYPE_REGISTER_PARITY		= 5,
33764bef358cSTimo Alho 
33774bef358cSTimo Alho 	/** @brief Parity error from on-chip SRAM/FIFO
33784bef358cSTimo Alho 	 *
33794bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
33804bef358cSTimo Alho 	 */
33814bef358cSTimo Alho 	EC_ERR_TYPE_PARITY_SRAM			= 6,
33824bef358cSTimo Alho 
33834bef358cSTimo Alho 	/** @brief Clock Monitor error
33844bef358cSTimo Alho 	 *
33854bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_fmon_desc.
33864bef358cSTimo Alho 	 */
33874bef358cSTimo Alho 	EC_ERR_TYPE_CLOCK_MONITOR		= 9,
33884bef358cSTimo Alho 
33894bef358cSTimo Alho 	/** @brief Voltage Monitor error
33904bef358cSTimo Alho 	 *
33914bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_vmon_desc.
33924bef358cSTimo Alho 	 */
33934bef358cSTimo Alho 	EC_ERR_TYPE_VOLTAGE_MONITOR		= 10,
33944bef358cSTimo Alho 
33954bef358cSTimo Alho 	/** @brief SW Correctable error
33964bef358cSTimo Alho 	 *
33974e871899SJon Hunter 	 *  Error descriptor @ref ec_err_sw_error_desc.
33984bef358cSTimo Alho 	 */
33994bef358cSTimo Alho 	EC_ERR_TYPE_SW_CORRECTABLE		= 16,
34004bef358cSTimo Alho 
34014bef358cSTimo Alho 	/** @brief SW Uncorrectable error
34024bef358cSTimo Alho 	 *
34034e871899SJon Hunter 	 *  Error descriptor @ref ec_err_sw_error_desc.
34044bef358cSTimo Alho 	 */
34054bef358cSTimo Alho 	EC_ERR_TYPE_SW_UNCORRECTABLE		= 17,
34064bef358cSTimo Alho 
34074bef358cSTimo Alho 	/** @brief Other HW Correctable error
34084bef358cSTimo Alho 	 *
34094bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
34104bef358cSTimo Alho 	 */
34114bef358cSTimo Alho 	EC_ERR_TYPE_OTHER_HW_CORRECTABLE	= 32,
34124bef358cSTimo Alho 
34134bef358cSTimo Alho 	/** @brief Other HW Uncorrectable error
34144bef358cSTimo Alho 	 *
34154bef358cSTimo Alho 	 *  Error descriptor @ref ec_err_simple_desc.
34164bef358cSTimo Alho 	 */
34174bef358cSTimo Alho 	EC_ERR_TYPE_OTHER_HW_UNCORRECTABLE	= 33,
34184bef358cSTimo Alho };
34194bef358cSTimo Alho 
34204bef358cSTimo Alho /** @brief Group of registers with parity error. */
34214bef358cSTimo Alho enum ec_registers_group {
34224bef358cSTimo Alho 	/** @brief Functional registers group */
34234e871899SJon Hunter 	EC_ERR_GROUP_FUNC_REG		= 0U,
34244bef358cSTimo Alho 	/** @brief SCR registers group */
34254e871899SJon Hunter 	EC_ERR_GROUP_SCR_REG		= 1U,
34264bef358cSTimo Alho };
34274bef358cSTimo Alho 
34284bef358cSTimo Alho /**
34294bef358cSTimo Alho  * @defgroup bpmp_ec_status_flags EC Status Flags
34304bef358cSTimo Alho  * @addtogroup bpmp_ec_status_flags
34314bef358cSTimo Alho  * @{
34324bef358cSTimo Alho  */
34334bef358cSTimo Alho /** @brief No EC error found flag */
34344e871899SJon Hunter #define EC_STATUS_FLAG_NO_ERROR		0x0001U
34354bef358cSTimo Alho /** @brief Last EC error found flag */
34364e871899SJon Hunter #define EC_STATUS_FLAG_LAST_ERROR	0x0002U
34374bef358cSTimo Alho /** @brief EC latent error flag */
34384e871899SJon Hunter #define EC_STATUS_FLAG_LATENT_ERROR	0x0004U
3439*b204b92bSPeter De Schrijver 
3440*b204b92bSPeter De Schrijver /** @} bpmp_ec_status_flags */
34414bef358cSTimo Alho 
34424bef358cSTimo Alho /**
34434bef358cSTimo Alho  * @defgroup bpmp_ec_desc_flags EC Descriptor Flags
34444bef358cSTimo Alho  * @addtogroup bpmp_ec_desc_flags
34454bef358cSTimo Alho  * @{
34464bef358cSTimo Alho  */
34474bef358cSTimo Alho /** @brief EC descriptor error resolved flag */
34484e871899SJon Hunter #define EC_DESC_FLAG_RESOLVED		0x0001U
34494bef358cSTimo Alho /** @brief EC descriptor failed to retrieve id flag */
34504e871899SJon Hunter #define EC_DESC_FLAG_NO_ID		0x0002U
3451*b204b92bSPeter De Schrijver 
3452*b204b92bSPeter De Schrijver /** @} bpmp_ec_desc_flags */
34534bef358cSTimo Alho 
34544bef358cSTimo Alho /**
34554bef358cSTimo Alho  * |error type                       | fmon_clk_id values        |
34564bef358cSTimo Alho  * |---------------------------------|---------------------------|
34574bef358cSTimo Alho  * |@ref EC_ERR_TYPE_CLOCK_MONITOR   |@ref bpmp_clock_ids        |
34584bef358cSTimo Alho  */
34594bef358cSTimo Alho struct ec_err_fmon_desc {
34604bef358cSTimo Alho 	/** @brief Bitmask of @ref bpmp_ec_desc_flags  */
34614bef358cSTimo Alho 	uint16_t desc_flags;
34624bef358cSTimo Alho 	/** @brief FMON monitored clock id */
34634bef358cSTimo Alho 	uint16_t fmon_clk_id;
3464*b204b92bSPeter De Schrijver 	/**
3465*b204b92bSPeter De Schrijver 	 * @brief Bitmask of fault flags
3466*b204b92bSPeter De Schrijver 	 *
3467*b204b92bSPeter De Schrijver 	 * @ref bpmp_fmon_faults_flags
3468*b204b92bSPeter De Schrijver 	 */
34694bef358cSTimo Alho 	uint32_t fmon_faults;
34704bef358cSTimo Alho 	/** @brief FMON faults access error */
34714bef358cSTimo Alho 	int32_t fmon_access_error;
34724e871899SJon Hunter } BPMP_ABI_PACKED;
34734bef358cSTimo Alho 
34744bef358cSTimo Alho /**
34754bef358cSTimo Alho  * | error type                      | vmon_adc_id values        |
34764bef358cSTimo Alho  * |---------------------------------|---------------------------|
34774bef358cSTimo Alho  * |@ref EC_ERR_TYPE_VOLTAGE_MONITOR |@ref bpmp_adc_ids          |
34784bef358cSTimo Alho  */
34794bef358cSTimo Alho struct ec_err_vmon_desc {
34804bef358cSTimo Alho 	/** @brief Bitmask of @ref bpmp_ec_desc_flags  */
34814bef358cSTimo Alho 	uint16_t desc_flags;
34824bef358cSTimo Alho 	/** @brief VMON rail adc id */
34834bef358cSTimo Alho 	uint16_t vmon_adc_id;
3484*b204b92bSPeter De Schrijver 	/** @brief Bitmask of bpmp_vmon_faults_flags */
34854bef358cSTimo Alho 	uint32_t vmon_faults;
34864bef358cSTimo Alho 	/** @brief VMON faults access error */
34874bef358cSTimo Alho 	int32_t vmon_access_error;
34884e871899SJon Hunter } BPMP_ABI_PACKED;
34894bef358cSTimo Alho 
34904bef358cSTimo Alho /**
34914bef358cSTimo Alho  * |error type                       | reg_id values         |
3492*b204b92bSPeter De Schrijver  * |---------------------------------|-----------------------|
3493*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_REGISTER_PARITY | bpmp_ec_registers_ids |
34944bef358cSTimo Alho  */
34954bef358cSTimo Alho struct ec_err_reg_parity_desc {
34964bef358cSTimo Alho 	/** @brief Bitmask of @ref bpmp_ec_desc_flags  */
34974bef358cSTimo Alho 	uint16_t desc_flags;
34984bef358cSTimo Alho 	/** @brief Register id */
34994bef358cSTimo Alho 	uint16_t reg_id;
35004bef358cSTimo Alho 	/** @brief Register group @ref ec_registers_group */
35014bef358cSTimo Alho 	uint16_t reg_group;
35024e871899SJon Hunter } BPMP_ABI_PACKED;
35034e871899SJon Hunter 
35044e871899SJon Hunter /**
35054e871899SJon Hunter  * |error type                        | err_source_id values |
3506*b204b92bSPeter De Schrijver  * |--------------------------------- |----------------------|
3507*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_SW_CORRECTABLE   | bpmp_ec_ce_swd_ids   |
3508*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_SW_UNCORRECTABLE | bpmp_ec_ue_swd_ids   |
35094e871899SJon Hunter  */
35104e871899SJon Hunter struct ec_err_sw_error_desc {
35114e871899SJon Hunter 	/** @brief Bitmask of @ref bpmp_ec_desc_flags  */
35124e871899SJon Hunter 	uint16_t desc_flags;
35134e871899SJon Hunter 	/** @brief Error source id */
35144e871899SJon Hunter 	uint16_t err_source_id;
35154e871899SJon Hunter 	/** @brief Sw error data */
35164e871899SJon Hunter 	uint32_t sw_error_data;
35174e871899SJon Hunter } BPMP_ABI_PACKED;
35184bef358cSTimo Alho 
35194bef358cSTimo Alho /**
35204bef358cSTimo Alho  * |error type                              | err_source_id values   |
3521*b204b92bSPeter De Schrijver  * |----------------------------------------|------------------------|
3522*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_PARITY_INTERNAL        |  bpmp_ec_ipath_ids     |
3523*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_ECC_SEC_INTERNAL       |  bpmp_ec_ipath_ids     |
3524*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_ECC_DED_INTERNAL       |  bpmp_ec_ipath_ids     |
3525*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_COMPARATOR             |  bpmp_ec_comparator_ids|
3526*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_OTHER_HW_CORRECTABLE   |  bpmp_ec_misc_hwd_ids  |
3527*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_OTHER_HW_UNCORRECTABLE |  bpmp_ec_misc_hwd_ids  |
3528*b204b92bSPeter De Schrijver  * |@ref EC_ERR_TYPE_PARITY_SRAM            |  bpmp_clock_ids        |
35294bef358cSTimo Alho  */
35304bef358cSTimo Alho struct ec_err_simple_desc {
35314bef358cSTimo Alho 	/** @brief Bitmask of @ref bpmp_ec_desc_flags  */
35324bef358cSTimo Alho 	uint16_t desc_flags;
35334bef358cSTimo Alho 	/** @brief Error source id. Id space depends on error type. */
35344bef358cSTimo Alho 	uint16_t err_source_id;
35354e871899SJon Hunter } BPMP_ABI_PACKED;
35364bef358cSTimo Alho 
35374bef358cSTimo Alho /** @brief Union of EC error descriptors */
35384bef358cSTimo Alho union ec_err_desc {
35394bef358cSTimo Alho 	struct ec_err_fmon_desc fmon_desc;
35404bef358cSTimo Alho 	struct ec_err_vmon_desc vmon_desc;
35414bef358cSTimo Alho 	struct ec_err_reg_parity_desc reg_parity_desc;
35424e871899SJon Hunter 	struct ec_err_sw_error_desc sw_error_desc;
35434bef358cSTimo Alho 	struct ec_err_simple_desc simple_desc;
35444e871899SJon Hunter } BPMP_ABI_PACKED;
35454bef358cSTimo Alho 
35464bef358cSTimo Alho struct cmd_ec_status_get_request {
35474bef358cSTimo Alho 	/** @brief HSM error line number that identifies target EC. */
35484bef358cSTimo Alho 	uint32_t ec_hsm_id;
35494e871899SJon Hunter } BPMP_ABI_PACKED;
35504bef358cSTimo Alho 
35514bef358cSTimo Alho /** EC status maximum number of descriptors */
35524e871899SJon Hunter #define EC_ERR_STATUS_DESC_MAX_NUM	4U
35534bef358cSTimo Alho 
35544e871899SJon Hunter /**
35554e871899SJon Hunter  * @cond DEPRECATED
35564e871899SJon Hunter  */
35574bef358cSTimo Alho struct cmd_ec_status_get_response {
35584bef358cSTimo Alho 	/** @brief Target EC id (the same id received with request). */
35594bef358cSTimo Alho 	uint32_t ec_hsm_id;
35604bef358cSTimo Alho 	/**
35614bef358cSTimo Alho 	 * @brief Bitmask of @ref bpmp_ec_status_flags
35624bef358cSTimo Alho 	 *
35634bef358cSTimo Alho 	 * If NO_ERROR flag is set, error_ fields should be ignored
35644bef358cSTimo Alho 	 */
35654bef358cSTimo Alho 	uint32_t ec_status_flags;
35664bef358cSTimo Alho 	/** @brief Found EC error index. */
35674bef358cSTimo Alho 	uint32_t error_idx;
35684bef358cSTimo Alho 	/** @brief  Found EC error type @ref bpmp_ec_err_type. */
35694bef358cSTimo Alho 	uint32_t error_type;
35704bef358cSTimo Alho 	/** @brief  Number of returned EC error descriptors */
35714bef358cSTimo Alho 	uint32_t error_desc_num;
35724bef358cSTimo Alho 	/** @brief  EC error descriptors */
35734bef358cSTimo Alho 	union ec_err_desc error_descs[EC_ERR_STATUS_DESC_MAX_NUM];
35744e871899SJon Hunter } BPMP_ABI_PACKED;
3575*b204b92bSPeter De Schrijver /** @endcond DEPRECATED */
35764e871899SJon Hunter 
35774e871899SJon Hunter struct cmd_ec_status_ex_get_response {
35784e871899SJon Hunter 	/** @brief Target EC id (the same id received with request). */
35794e871899SJon Hunter 	uint32_t ec_hsm_id;
35804e871899SJon Hunter 	/**
35814e871899SJon Hunter 	 * @brief Bitmask of @ref bpmp_ec_status_flags
35824e871899SJon Hunter 	 *
35834e871899SJon Hunter 	 * If NO_ERROR flag is set, error_ fields should be ignored
35844e871899SJon Hunter 	 */
35854e871899SJon Hunter 	uint32_t ec_status_flags;
35864e871899SJon Hunter 	/** @brief Found EC error index. */
35874e871899SJon Hunter 	uint32_t error_idx;
35884e871899SJon Hunter 	/** @brief  Found EC error type @ref bpmp_ec_err_type. */
35894e871899SJon Hunter 	uint32_t error_type;
35904e871899SJon Hunter 	/** @brief  Found EC mission error counter value */
35914e871899SJon Hunter 	uint32_t error_counter;
35924e871899SJon Hunter 	/** @brief  Found EC mission error user value */
35934e871899SJon Hunter 	uint32_t error_uval;
35944e871899SJon Hunter 	/** @brief  Reserved entry    */
35954e871899SJon Hunter 	uint32_t reserved;
35964e871899SJon Hunter 	/** @brief  Number of returned EC error descriptors */
35974e871899SJon Hunter 	uint32_t error_desc_num;
35984e871899SJon Hunter 	/** @brief  EC error descriptors */
35994e871899SJon Hunter 	union ec_err_desc error_descs[EC_ERR_STATUS_DESC_MAX_NUM];
36004e871899SJon Hunter } BPMP_ABI_PACKED;
36014bef358cSTimo Alho 
36024bef358cSTimo Alho /**
36034bef358cSTimo Alho  * @ingroup EC
36044bef358cSTimo Alho  * @brief Request with #MRQ_EC
36054bef358cSTimo Alho  *
36064bef358cSTimo Alho  * Used by the sender of an #MRQ_EC message to access ECs owned
36074bef358cSTimo Alho  * by BPMP.
36084bef358cSTimo Alho  *
36094e871899SJon Hunter  * @cond DEPRECATED
36104bef358cSTimo Alho  * |sub-command                 |payload                |
36114bef358cSTimo Alho  * |----------------------------|-----------------------|
36124bef358cSTimo Alho  * |@ref CMD_EC_STATUS_GET      |ec_status_get          |
3613*b204b92bSPeter De Schrijver  * @endcond DEPRECATED
36144e871899SJon Hunter  *
36154e871899SJon Hunter  * |sub-command                 |payload                |
36164e871899SJon Hunter  * |----------------------------|-----------------------|
36174e871899SJon Hunter  * |@ref CMD_EC_STATUS_EX_GET   |ec_status_get          |
36184bef358cSTimo Alho  *
36194bef358cSTimo Alho  */
36204bef358cSTimo Alho 
36214bef358cSTimo Alho struct mrq_ec_request {
36224bef358cSTimo Alho 	/** @brief Sub-command id. */
36234bef358cSTimo Alho 	uint32_t cmd_id;
36244bef358cSTimo Alho 
36254bef358cSTimo Alho 	union {
36264bef358cSTimo Alho 		struct cmd_ec_status_get_request ec_status_get;
36274e871899SJon Hunter 	} BPMP_UNION_ANON;
36284e871899SJon Hunter } BPMP_ABI_PACKED;
36294bef358cSTimo Alho 
36304bef358cSTimo Alho /**
36314bef358cSTimo Alho  * @ingroup EC
36324bef358cSTimo Alho  * @brief Response to MRQ_EC
36334bef358cSTimo Alho  *
36344bef358cSTimo Alho  * Each sub-command supported by @ref mrq_ec_request may return
36354bef358cSTimo Alho  * sub-command-specific data as indicated below.
36364bef358cSTimo Alho  *
36374e871899SJon Hunter  * @cond DEPRECATED
36384bef358cSTimo Alho  * |sub-command                 |payload                 |
36394bef358cSTimo Alho  * |----------------------------|------------------------|
36404bef358cSTimo Alho  * |@ref CMD_EC_STATUS_GET      |ec_status_get           |
3641*b204b92bSPeter De Schrijver  * @endcond DEPRECATED
36424e871899SJon Hunter  *
36434e871899SJon Hunter  * |sub-command                 |payload                 |
36444e871899SJon Hunter  * |----------------------------|------------------------|
36454e871899SJon Hunter  * |@ref CMD_EC_STATUS_EX_GET   |ec_status_ex_get        |
36464bef358cSTimo Alho  *
36474bef358cSTimo Alho  */
36484bef358cSTimo Alho 
36494bef358cSTimo Alho struct mrq_ec_response {
36504bef358cSTimo Alho 	union {
36514e871899SJon Hunter 		/**
36524e871899SJon Hunter 		 * @cond DEPRECATED
36534e871899SJon Hunter 		 */
36544bef358cSTimo Alho 		struct cmd_ec_status_get_response ec_status_get;
3655*b204b92bSPeter De Schrijver 		/** @endcond DEPRECATED */
36564e871899SJon Hunter 		struct cmd_ec_status_ex_get_response ec_status_ex_get;
36574e871899SJon Hunter 	} BPMP_UNION_ANON;
36584e871899SJon Hunter } BPMP_ABI_PACKED;
36594bef358cSTimo Alho 
3660*b204b92bSPeter De Schrijver /** @endcond bpmp_t194 */
3661*b204b92bSPeter De Schrijver /** @} EC */
3662*b204b92bSPeter De Schrijver 
3663*b204b92bSPeter De Schrijver /**
3664*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
3665*b204b92bSPeter De Schrijver  * @def MRQ_TELEMETRY
3666*b204b92bSPeter De Schrijver  * @brief Get address of memory buffer refreshed with recently sampled
3667*b204b92bSPeter De Schrijver  *        telemetry data
3668*b204b92bSPeter De Schrijver  *
3669*b204b92bSPeter De Schrijver  * * Platforms: TH500 onwards
3670*b204b92bSPeter De Schrijver  * @cond bpmp_th500
3671*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
3672*b204b92bSPeter De Schrijver  * * Targets: BPMP
3673*b204b92bSPeter De Schrijver  * * Request Payload: N/A
3674*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_telemetry_response
3675*b204b92bSPeter De Schrijver  * @addtogroup Telemetry
3676*b204b92bSPeter De Schrijver  * @{
3677*b204b92bSPeter De Schrijver  */
3678*b204b92bSPeter De Schrijver 
3679*b204b92bSPeter De Schrijver /**
3680*b204b92bSPeter De Schrijver  * @brief Response to #MRQ_TELEMETRY
3681*b204b92bSPeter De Schrijver  *
3682*b204b92bSPeter De Schrijver  * mrq_response::err is
3683*b204b92bSPeter De Schrijver  * * 0: Telemetry data is available at returned address
3684*b204b92bSPeter De Schrijver  * * -#BPMP_EACCES: MRQ master is not allowed to request buffer refresh
3685*b204b92bSPeter De Schrijver  * * -#BPMP_ENAVAIL: Telemetry buffer cannot be refreshed via this MRQ channel
3686*b204b92bSPeter De Schrijver  * * -#BPMP_ENOTSUP: Telemetry buffer is not supported by BPMP-FW
3687*b204b92bSPeter De Schrijver  * * -#BPMP_ENODEV: Telemetry mrq is not supported by BPMP-FW
3688*b204b92bSPeter De Schrijver  */
3689*b204b92bSPeter De Schrijver struct mrq_telemetry_response {
3690*b204b92bSPeter De Schrijver 	/** @brief Physical address of telemetry data buffer */
3691*b204b92bSPeter De Schrijver 	uint64_t data_buf_addr;	/**< see @ref bpmp_telemetry_layout */
3692*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3693*b204b92bSPeter De Schrijver 
3694*b204b92bSPeter De Schrijver /** @} Telemetry */
3695*b204b92bSPeter De Schrijver /** @endcond bpmp_th500 */
3696*b204b92bSPeter De Schrijver 
3697*b204b92bSPeter De Schrijver /**
3698*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
3699*b204b92bSPeter De Schrijver  * @def MRQ_PWR_LIMIT
3700*b204b92bSPeter De Schrijver  * @brief Control power limits.
3701*b204b92bSPeter De Schrijver  *
3702*b204b92bSPeter De Schrijver  * * Platforms: TH500 onwards
3703*b204b92bSPeter De Schrijver  * @cond bpmp_th500
3704*b204b92bSPeter De Schrijver  * * Initiators: Any
3705*b204b92bSPeter De Schrijver  * * Targets: BPMP
3706*b204b92bSPeter De Schrijver  * * Request Payload: @ref mrq_pwr_limit_request
3707*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_pwr_limit_response
3708*b204b92bSPeter De Schrijver  *
3709*b204b92bSPeter De Schrijver  * @addtogroup Pwrlimit
3710*b204b92bSPeter De Schrijver  * @{
3711*b204b92bSPeter De Schrijver  */
3712*b204b92bSPeter De Schrijver enum mrq_pwr_limit_cmd {
3713*b204b92bSPeter De Schrijver 	/**
3714*b204b92bSPeter De Schrijver 	 * @brief Check whether the BPMP-FW supports the specified
3715*b204b92bSPeter De Schrijver 	 * command
3716*b204b92bSPeter De Schrijver 	 *
3717*b204b92bSPeter De Schrijver 	 * mrq_response::err is 0 if the specified request is
3718*b204b92bSPeter De Schrijver 	 * supported and -#BPMP_ENODEV otherwise.
3719*b204b92bSPeter De Schrijver 	 */
3720*b204b92bSPeter De Schrijver 	CMD_PWR_LIMIT_QUERY_ABI = 0,
3721*b204b92bSPeter De Schrijver 
3722*b204b92bSPeter De Schrijver 	/**
3723*b204b92bSPeter De Schrijver 	 * @brief Set power limit
3724*b204b92bSPeter De Schrijver 	 *
3725*b204b92bSPeter De Schrijver 	 * mrq_response:err is
3726*b204b92bSPeter De Schrijver 	 * * 0: Success
3727*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENODEV: Pwr limit mrq is not supported by BPMP-FW
3728*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENAVAIL: Invalid request parameters
3729*b204b92bSPeter De Schrijver 	 * * -#BPMP_EACCES: Request is not accepted
3730*b204b92bSPeter De Schrijver 	 */
3731*b204b92bSPeter De Schrijver 	CMD_PWR_LIMIT_SET = 1,
3732*b204b92bSPeter De Schrijver 
3733*b204b92bSPeter De Schrijver 	/**
3734*b204b92bSPeter De Schrijver 	 * @brief Get power limit setting
3735*b204b92bSPeter De Schrijver 	 *
3736*b204b92bSPeter De Schrijver 	 * mrq_response:err is
3737*b204b92bSPeter De Schrijver 	 * * 0: Success
3738*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENODEV: Pwr limit mrq is not supported by BPMP-FW
3739*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENAVAIL: Invalid request parameters
3740*b204b92bSPeter De Schrijver 	 */
3741*b204b92bSPeter De Schrijver 	CMD_PWR_LIMIT_GET = 2,
3742*b204b92bSPeter De Schrijver 
3743*b204b92bSPeter De Schrijver 	/**
3744*b204b92bSPeter De Schrijver 	 * @brief Get current power cap
3745*b204b92bSPeter De Schrijver 	 *
3746*b204b92bSPeter De Schrijver 	 * mrq_response:err is
3747*b204b92bSPeter De Schrijver 	 * * 0: Success
3748*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENODEV: Pwr limit mrq is not supported by BPMP-FW
3749*b204b92bSPeter De Schrijver 	 * * -#BPMP_ENAVAIL: Invalid request parameters
3750*b204b92bSPeter De Schrijver 	 */
3751*b204b92bSPeter De Schrijver 	CMD_PWR_LIMIT_CURR_CAP = 3,
3752*b204b92bSPeter De Schrijver };
3753*b204b92bSPeter De Schrijver 
3754*b204b92bSPeter De Schrijver /**
3755*b204b92bSPeter De Schrijver  * @defgroup bpmp_pwr_limit_type PWR_LIMIT TYPEs
3756*b204b92bSPeter De Schrijver  * @{
3757*b204b92bSPeter De Schrijver  */
3758*b204b92bSPeter De Schrijver /** @brief Limit value specifies traget cap */
3759*b204b92bSPeter De Schrijver #define PWR_LIMIT_TYPE_TARGET_CAP		0U
3760*b204b92bSPeter De Schrijver /** @brief Limit value specifies maximum possible target cap */
3761*b204b92bSPeter De Schrijver #define PWR_LIMIT_TYPE_BOUND_MAX		1U
3762*b204b92bSPeter De Schrijver /** @brief Limit value specifies minimum possible target cap */
3763*b204b92bSPeter De Schrijver #define PWR_LIMIT_TYPE_BOUND_MIN		2U
3764*b204b92bSPeter De Schrijver /** @brief Number of limit types supported by mrq interface */
3765*b204b92bSPeter De Schrijver #define PWR_LIMIT_TYPE_NUM			3U
3766*b204b92bSPeter De Schrijver 
3767*b204b92bSPeter De Schrijver /** @} bpmp_pwr_limit_type */
3768*b204b92bSPeter De Schrijver 
3769*b204b92bSPeter De Schrijver /**
3770*b204b92bSPeter De Schrijver  * @brief Request data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_QUERY_ABI
3771*b204b92bSPeter De Schrijver  */
3772*b204b92bSPeter De Schrijver struct cmd_pwr_limit_query_abi_request {
3773*b204b92bSPeter De Schrijver 	uint32_t cmd_code; /**< @ref mrq_pwr_limit_cmd */
3774*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3775*b204b92bSPeter De Schrijver 
3776*b204b92bSPeter De Schrijver /**
3777*b204b92bSPeter De Schrijver  * @brief Request data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_SET
3778*b204b92bSPeter De Schrijver  *
3779*b204b92bSPeter De Schrijver  * Set specified limit of specified type from specified source. The success of
3780*b204b92bSPeter De Schrijver  * the request means that specified value is accepted as input to arbitration
3781*b204b92bSPeter De Schrijver  * with other sources settings for the same limit of the same type. Zero limit
3782*b204b92bSPeter De Schrijver  * is ignored by the arbitration (i.e., indicates "no limit set").
3783*b204b92bSPeter De Schrijver  */
3784*b204b92bSPeter De Schrijver struct cmd_pwr_limit_set_request {
3785*b204b92bSPeter De Schrijver 	uint32_t limit_id;   /**< @ref bpmp_pwr_limit_id */
3786*b204b92bSPeter De Schrijver 	uint32_t limit_src;  /**< @ref bpmp_pwr_limit_src */
3787*b204b92bSPeter De Schrijver 	uint32_t limit_type; /**< @ref bpmp_pwr_limit_type */
3788*b204b92bSPeter De Schrijver 	uint32_t limit_setting;
3789*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3790*b204b92bSPeter De Schrijver 
3791*b204b92bSPeter De Schrijver /**
3792*b204b92bSPeter De Schrijver  * @brief Request data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_GET
3793*b204b92bSPeter De Schrijver  *
3794*b204b92bSPeter De Schrijver  * Get previously set from specified source specified limit value of specified
3795*b204b92bSPeter De Schrijver  * type.
3796*b204b92bSPeter De Schrijver  */
3797*b204b92bSPeter De Schrijver struct cmd_pwr_limit_get_request {
3798*b204b92bSPeter De Schrijver 	uint32_t limit_id;   /**< @ref bpmp_pwr_limit_id */
3799*b204b92bSPeter De Schrijver 	uint32_t limit_src;  /**< @ref bpmp_pwr_limit_src */
3800*b204b92bSPeter De Schrijver 	uint32_t limit_type; /**< @ref bpmp_pwr_limit_type */
3801*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3802*b204b92bSPeter De Schrijver 
3803*b204b92bSPeter De Schrijver /**
3804*b204b92bSPeter De Schrijver  * @brief Response data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_GET
3805*b204b92bSPeter De Schrijver  */
3806*b204b92bSPeter De Schrijver struct cmd_pwr_limit_get_response {
3807*b204b92bSPeter De Schrijver 	uint32_t limit_setting;
3808*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3809*b204b92bSPeter De Schrijver 
3810*b204b92bSPeter De Schrijver /**
3811*b204b92bSPeter De Schrijver  * @brief Request data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_CURR_CAP
3812*b204b92bSPeter De Schrijver  *
3813*b204b92bSPeter De Schrijver  * For specified limit get current power cap aggregated from all sources.
3814*b204b92bSPeter De Schrijver  */
3815*b204b92bSPeter De Schrijver struct cmd_pwr_limit_curr_cap_request {
3816*b204b92bSPeter De Schrijver 	uint32_t limit_id;   /**< @ref bpmp_pwr_limit_id */
3817*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3818*b204b92bSPeter De Schrijver 
3819*b204b92bSPeter De Schrijver /**
3820*b204b92bSPeter De Schrijver  * @brief Response data for #MRQ_PWR_LIMIT command CMD_PWR_LIMIT_CURR_CAP
3821*b204b92bSPeter De Schrijver  */
3822*b204b92bSPeter De Schrijver struct cmd_pwr_limit_curr_cap_response {
3823*b204b92bSPeter De Schrijver 	uint32_t curr_cap;
3824*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3825*b204b92bSPeter De Schrijver 
3826*b204b92bSPeter De Schrijver /**
3827*b204b92bSPeter De Schrijver  * @brief Request with #MRQ_PWR_LIMIT
3828*b204b92bSPeter De Schrijver  *
3829*b204b92bSPeter De Schrijver  * |sub-command                 |payload                          |
3830*b204b92bSPeter De Schrijver  * |----------------------------|---------------------------------|
3831*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_QUERY_ABI     | cmd_pwr_limit_query_abi_request |
3832*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_SET           | cmd_pwr_limit_set_request       |
3833*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_GET           | cmd_pwr_limit_get_request       |
3834*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_CURR_CAP      | cmd_pwr_limit_curr_cap_request  |
3835*b204b92bSPeter De Schrijver  */
3836*b204b92bSPeter De Schrijver struct mrq_pwr_limit_request {
3837*b204b92bSPeter De Schrijver 	uint32_t cmd;
3838*b204b92bSPeter De Schrijver 	union {
3839*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_query_abi_request pwr_limit_query_abi_req;
3840*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_set_request pwr_limit_set_req;
3841*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_get_request pwr_limit_get_req;
3842*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_curr_cap_request pwr_limit_curr_cap_req;
3843*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
3844*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3845*b204b92bSPeter De Schrijver 
3846*b204b92bSPeter De Schrijver /**
3847*b204b92bSPeter De Schrijver  * @brief Response to MRQ_PWR_LIMIT
3848*b204b92bSPeter De Schrijver  *
3849*b204b92bSPeter De Schrijver  * |sub-command                 |payload                          |
3850*b204b92bSPeter De Schrijver  * |----------------------------|---------------------------------|
3851*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_QUERY_ABI     | -                               |
3852*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_SET           | -                               |
3853*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_GET           | cmd_pwr_limit_get_response      |
3854*b204b92bSPeter De Schrijver  * |CMD_PWR_LIMIT_CURR_CAP      | cmd_pwr_limit_curr_cap_response |
3855*b204b92bSPeter De Schrijver  */
3856*b204b92bSPeter De Schrijver struct mrq_pwr_limit_response {
3857*b204b92bSPeter De Schrijver 	union {
3858*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_get_response pwr_limit_get_rsp;
3859*b204b92bSPeter De Schrijver 		struct cmd_pwr_limit_curr_cap_response pwr_limit_curr_cap_rsp;
3860*b204b92bSPeter De Schrijver 	} BPMP_UNION_ANON;
3861*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3862*b204b92bSPeter De Schrijver 
3863*b204b92bSPeter De Schrijver /** @} PwrLimit */
3864*b204b92bSPeter De Schrijver /** @endcond bpmp_th500 */
3865*b204b92bSPeter De Schrijver 
3866*b204b92bSPeter De Schrijver 
3867*b204b92bSPeter De Schrijver /**
3868*b204b92bSPeter De Schrijver  * @ingroup MRQ_Codes
3869*b204b92bSPeter De Schrijver  * @def MRQ_GEARS
3870*b204b92bSPeter De Schrijver  * @brief Get thresholds for NDIV offset switching
3871*b204b92bSPeter De Schrijver  *
3872*b204b92bSPeter De Schrijver  * * Platforms: TH500 onwards
3873*b204b92bSPeter De Schrijver  * @cond bpmp_th500
3874*b204b92bSPeter De Schrijver  * * Initiators: CCPLEX
3875*b204b92bSPeter De Schrijver  * * Targets: BPMP
3876*b204b92bSPeter De Schrijver  * * Request Payload: N/A
3877*b204b92bSPeter De Schrijver  * * Response Payload: @ref mrq_gears_response
3878*b204b92bSPeter De Schrijver  * @addtogroup Gears
3879*b204b92bSPeter De Schrijver  * @{
3880*b204b92bSPeter De Schrijver  */
3881*b204b92bSPeter De Schrijver 
3882*b204b92bSPeter De Schrijver /**
3883*b204b92bSPeter De Schrijver  * @brief Response to #MRQ_GEARS
3884*b204b92bSPeter De Schrijver  *
3885*b204b92bSPeter De Schrijver  * Used by the sender of an #MRQ_GEARS message to request thresholds
3886*b204b92bSPeter De Schrijver  * for NDIV offset switching.
3887*b204b92bSPeter De Schrijver  *
3888*b204b92bSPeter De Schrijver  * The mrq_gears_response::ncpu array defines four thresholds in units
3889*b204b92bSPeter De Schrijver  * of number of online CPUS to be used for choosing between five different
3890*b204b92bSPeter De Schrijver  * NDIV offset settings for CCPLEX cluster NAFLLs
3891*b204b92bSPeter De Schrijver  *
3892*b204b92bSPeter De Schrijver  * 1. If number of online CPUs < ncpu[0] use offset0
3893*b204b92bSPeter De Schrijver  * 2. If number of online CPUs < ncpu[1] use offset1
3894*b204b92bSPeter De Schrijver  * 3. If number of online CPUs < ncpu[2] use offset2
3895*b204b92bSPeter De Schrijver  * 4. If number of online CPUs < ncpu[3] use offset3
3896*b204b92bSPeter De Schrijver  * 5. If number of online CPUs >= ncpu[3] disable offsetting
3897*b204b92bSPeter De Schrijver  *
3898*b204b92bSPeter De Schrijver  * For TH500 mrq_gears_response::ncpu array has four valid entries.
3899*b204b92bSPeter De Schrijver  *
3900*b204b92bSPeter De Schrijver  * mrq_response::err is
3901*b204b92bSPeter De Schrijver  * * 0: gears defined and response data valid
3902*b204b92bSPeter De Schrijver  * * -#BPMP_ENODEV: MRQ is not supported by BPMP-FW
3903*b204b92bSPeter De Schrijver  * * -#BPMP_EACCES: Operation not permitted for the MRQ master
3904*b204b92bSPeter De Schrijver  * * -#BPMP_ENAVAIL: NDIV offsetting is disabled
3905*b204b92bSPeter De Schrijver  */
3906*b204b92bSPeter De Schrijver struct mrq_gears_response {
3907*b204b92bSPeter De Schrijver 	/** @brief number of online CPUs for each gear */
3908*b204b92bSPeter De Schrijver 	uint32_t ncpu[16];
3909*b204b92bSPeter De Schrijver } BPMP_ABI_PACKED;
3910*b204b92bSPeter De Schrijver 
3911*b204b92bSPeter De Schrijver /** @} Gears */
3912*b204b92bSPeter De Schrijver /** @endcond bpmp_th500 */
39134bef358cSTimo Alho 
39144bef358cSTimo Alho /**
39154bef358cSTimo Alho  * @addtogroup Error_Codes
3916983de5f9SThierry Reding  * Negative values for mrq_response::err generally indicate some
3917983de5f9SThierry Reding  * error. The ABI defines the following error codes. Negating these
3918983de5f9SThierry Reding  * defines is an exercise left to the user.
3919983de5f9SThierry Reding  * @{
3920983de5f9SThierry Reding  */
39214bef358cSTimo Alho 
39224e871899SJon Hunter /** @brief Operation not permitted */
39234e871899SJon Hunter #define BPMP_EPERM	1
3924983de5f9SThierry Reding /** @brief No such file or directory */
3925983de5f9SThierry Reding #define BPMP_ENOENT	2
3926983de5f9SThierry Reding /** @brief No MRQ handler */
3927983de5f9SThierry Reding #define BPMP_ENOHANDLER	3
3928983de5f9SThierry Reding /** @brief I/O error */
3929983de5f9SThierry Reding #define BPMP_EIO	5
3930983de5f9SThierry Reding /** @brief Bad sub-MRQ command */
3931983de5f9SThierry Reding #define BPMP_EBADCMD	6
39324e871899SJon Hunter /** @brief Resource temporarily unavailable */
39334e871899SJon Hunter #define BPMP_EAGAIN	11
3934983de5f9SThierry Reding /** @brief Not enough memory */
3935983de5f9SThierry Reding #define BPMP_ENOMEM	12
3936983de5f9SThierry Reding /** @brief Permission denied */
3937983de5f9SThierry Reding #define BPMP_EACCES	13
3938983de5f9SThierry Reding /** @brief Bad address */
3939983de5f9SThierry Reding #define BPMP_EFAULT	14
39404e871899SJon Hunter /** @brief Resource busy */
39414e871899SJon Hunter #define BPMP_EBUSY	16
3942983de5f9SThierry Reding /** @brief No such device */
3943983de5f9SThierry Reding #define BPMP_ENODEV	19
3944983de5f9SThierry Reding /** @brief Argument is a directory */
3945983de5f9SThierry Reding #define BPMP_EISDIR	21
3946983de5f9SThierry Reding /** @brief Invalid argument */
3947983de5f9SThierry Reding #define BPMP_EINVAL	22
3948983de5f9SThierry Reding /** @brief Timeout during operation */
3949983de5f9SThierry Reding #define BPMP_ETIMEDOUT  23
3950983de5f9SThierry Reding /** @brief Out of range */
3951983de5f9SThierry Reding #define BPMP_ERANGE	34
39524bef358cSTimo Alho /** @brief Function not implemented */
39534bef358cSTimo Alho #define BPMP_ENOSYS	38
39544bef358cSTimo Alho /** @brief Invalid slot */
39554bef358cSTimo Alho #define BPMP_EBADSLT	57
3956*b204b92bSPeter De Schrijver /** @brief Invalid message */
3957*b204b92bSPeter De Schrijver #define BPMP_EBADMSG	77
3958*b204b92bSPeter De Schrijver /** @brief Operation not supported */
3959*b204b92bSPeter De Schrijver #define BPMP_EOPNOTSUPP 95
3960*b204b92bSPeter De Schrijver /** @brief Targeted resource not available */
3961*b204b92bSPeter De Schrijver #define BPMP_ENAVAIL	119
39624e871899SJon Hunter /** @brief Not supported */
39634e871899SJon Hunter #define BPMP_ENOTSUP	134
39644e871899SJon Hunter /** @brief No such device or address */
39654e871899SJon Hunter #define BPMP_ENXIO	140
39664bef358cSTimo Alho 
3967*b204b92bSPeter De Schrijver /** @} Error_Codes */
39684bef358cSTimo Alho 
39694e871899SJon Hunter #if defined(BPMP_ABI_CHECKS)
39704e871899SJon Hunter #include "bpmp_abi_checks.h"
39714e871899SJon Hunter #endif
39724e871899SJon Hunter 
3973983de5f9SThierry Reding #endif
3974