1 /*
2  * Copyright (c) 2014-2016, NVIDIA CORPORATION.
3  *
4  * SPDX-License-Identifier: GPL-2.0
5  */
6 
7 #ifndef _ABI_BPMP_ABI_H_
8 #define _ABI_BPMP_ABI_H_
9 
10 #ifdef LK
11 #include <stdint.h>
12 #endif
13 
14 #ifndef __ABI_PACKED
15 #define __ABI_PACKED __attribute__((packed))
16 #endif
17 
18 #ifdef NO_GCC_EXTENSIONS
19 #define EMPTY char empty;
20 #define EMPTY_ARRAY 1
21 #else
22 #define EMPTY
23 #define EMPTY_ARRAY 0
24 #endif
25 
26 #ifndef __UNION_ANON
27 #define __UNION_ANON
28 #endif
29 /**
30  * @file
31  */
32 
33 
34 /**
35  * @defgroup MRQ MRQ Messages
36  * @brief Messages sent to/from BPMP via IPC
37  * @{
38  *   @defgroup MRQ_Format Message Format
39  *   @defgroup MRQ_Codes Message Request (MRQ) Codes
40  *   @defgroup MRQ_Payloads Message Payloads
41  *   @defgroup Error_Codes Error Codes
42  * @}
43  */
44 
45 /**
46  * @addtogroup MRQ_Format Message Format
47  * @{
48  * The CPU requests the BPMP to perform a particular service by
49  * sending it an IVC frame containing a single MRQ message. An MRQ
50  * message consists of a @ref mrq_request followed by a payload whose
51  * format depends on mrq_request::mrq.
52  *
53  * The BPMP processes the data and replies with an IVC frame (on the
54  * same IVC channel) containing and MRQ response. An MRQ response
55  * consists of a @ref mrq_response followed by a payload whose format
56  * depends on the associated mrq_request::mrq.
57  *
58  * A well-defined subset of the MRQ messages that the CPU sends to the
59  * BPMP can lead to BPMP eventually sending an MRQ message to the
60  * CPU. For example, when the CPU uses an #MRQ_THERMAL message to set
61  * a thermal trip point, the BPMP may eventually send a single
62  * #MRQ_THERMAL message of its own to the CPU indicating that the trip
63  * point has been crossed.
64  * @}
65  */
66 
67 /**
68  * @ingroup MRQ_Format
69  * @brief header for an MRQ message
70  *
71  * Provides the MRQ number for the MRQ message: #mrq. The remainder of
72  * the MRQ message is a payload (immediately following the
73  * mrq_request) whose format depends on mrq.
74  *
75  * @todo document the flags
76  */
77 struct mrq_request {
78 	/** @brief MRQ number of the request */
79 	uint32_t mrq;
80 	/** @brief flags for the request */
81 	uint32_t flags;
82 } __ABI_PACKED;
83 
84 /**
85  * @ingroup MRQ_Format
86  * @brief header for an MRQ response
87  *
88  *  Provides an error code for the associated MRQ message. The
89  *  remainder of the MRQ response is a payload (immediately following
90  *  the mrq_response) whose format depends on the associated
91  *  mrq_request::mrq
92  *
93  * @todo document the flags
94  */
95 struct mrq_response {
96 	/** @brief error code for the MRQ request itself */
97 	int32_t err;
98 	/** @brief flags for the response */
99 	uint32_t flags;
100 } __ABI_PACKED;
101 
102 /**
103  * @ingroup MRQ_Format
104  * Minimum needed size for an IPC message buffer
105  */
106 #define MSG_MIN_SZ	128
107 /**
108  * @ingroup MRQ_Format
109  *  Minimum size guaranteed for data in an IPC message buffer
110  */
111 #define MSG_DATA_MIN_SZ	120
112 
113 /**
114  * @ingroup MRQ_Codes
115  * @name Legal MRQ codes
116  * These are the legal values for mrq_request::mrq
117  * @{
118  */
119 
120 #define MRQ_PING		0
121 #define MRQ_QUERY_TAG		1
122 #define MRQ_MODULE_LOAD		4
123 #define MRQ_MODULE_UNLOAD	5
124 #define MRQ_TRACE_MODIFY	7
125 #define MRQ_WRITE_TRACE		8
126 #define MRQ_THREADED_PING	9
127 #define MRQ_MODULE_MAIL		11
128 #define MRQ_DEBUGFS		19
129 #define MRQ_RESET		20
130 #define MRQ_I2C			21
131 #define MRQ_CLK			22
132 #define MRQ_QUERY_ABI		23
133 #define MRQ_PG_READ_STATE	25
134 #define MRQ_PG_UPDATE_STATE	26
135 #define MRQ_THERMAL		27
136 #define MRQ_CPU_VHINT		28
137 #define MRQ_ABI_RATCHET		29
138 #define MRQ_EMC_DVFS_LATENCY	31
139 #define MRQ_TRACE_ITER		64
140 
141 /** @} */
142 
143 /**
144  * @ingroup MRQ_Codes
145  * @brief Maximum MRQ code to be sent by CPU software to
146  * BPMP. Subject to change in future
147  */
148 #define MAX_CPU_MRQ_ID		64
149 
150 /**
151  * @addtogroup MRQ_Payloads Message Payloads
152  * @{
153  *   @defgroup Ping
154  *   @defgroup Query_Tag Query Tag
155  *   @defgroup Module Loadable Modules
156  *   @defgroup Trace
157  *   @defgroup Debugfs
158  *   @defgroup Reset
159  *   @defgroup I2C
160  *   @defgroup Clocks
161  *   @defgroup ABI_info ABI Info
162  *   @defgroup MC_Flush MC Flush
163  *   @defgroup Powergating
164  *   @defgroup Thermal
165  *   @defgroup Vhint CPU Voltage hint
166  *   @defgroup MRQ_Deprecated Deprecated MRQ messages
167  *   @defgroup EMC
168  * @}
169  */
170 
171 
172 /**
173  * @ingroup MRQ_Codes
174  * @def MRQ_PING
175  * @brief A simple ping
176  *
177  * * Platforms: All
178  * * Initiators: Any
179  * * Targets: Any
180  * * Request Payload: @ref mrq_ping_request
181  * * Response Payload: @ref mrq_ping_response
182  *
183  * @ingroup MRQ_Codes
184  * @def MRQ_THREADED_PING
185  * @brief A deeper ping
186  *
187  * * Platforms: All
188  * * Initiators: Any
189  * * Targets: BPMP
190  * * Request Payload: @ref mrq_ping_request
191  * * Response Payload: @ref mrq_ping_response
192  *
193  * Behavior is equivalent to a simple #MRQ_PING except that BPMP
194  * responds from a thread context (providing a slightly more robust
195  * sign of life).
196  *
197  */
198 
199 /**
200  * @ingroup Ping
201  * @brief request with #MRQ_PING
202  *
203  * Used by the sender of an #MRQ_PING message to request a pong from
204  * recipient. The response from the recipient is computed based on
205  * #challenge.
206  */
207 struct mrq_ping_request {
208 /** @brief arbitrarily chosen value */
209 	uint32_t challenge;
210 } __ABI_PACKED;
211 
212 /**
213  * @ingroup Ping
214  * @brief response to #MRQ_PING
215  *
216  * Sent in response to an #MRQ_PING message. #reply should be the
217  * mrq_ping_request challenge left shifted by 1 with the carry-bit
218  * dropped.
219  *
220  */
221 struct mrq_ping_response {
222 	/** @brief response to the MRQ_PING challege */
223 	uint32_t reply;
224 } __ABI_PACKED;
225 
226 /**
227  * @ingroup MRQ_Codes
228  * @def MRQ_QUERY_TAG
229  * @brief Query BPMP firmware's tag (i.e. version information)
230  *
231  * * Platforms: All
232  * * Initiators: CCPLEX
233  * * Targets: BPMP
234  * * Request Payload: @ref mrq_query_tag_request
235  * * Response Payload: N/A
236  *
237  */
238 
239 /**
240  * @ingroup Query_Tag
241  * @brief request with #MRQ_QUERY_TAG
242  *
243  * Used by #MRQ_QUERY_TAG call to ask BPMP to fill in the memory
244  * pointed by #addr with BPMP firmware header.
245  *
246  * The sender is reponsible for ensuring that #addr is mapped in to
247  * the recipient's address map.
248  */
249 struct mrq_query_tag_request {
250   /** @brief base address to store the firmware header */
251 	uint32_t addr;
252 } __ABI_PACKED;
253 
254 /**
255  * @ingroup MRQ_Codes
256  * @def MRQ_MODULE_LOAD
257  * @brief dynamically load a BPMP code module
258  *
259  * * Platforms: All
260  * * Initiators: CCPLEX
261  * * Targets: BPMP
262  * * Request Payload: @ref mrq_module_load_request
263  * * Response Payload: @ref mrq_module_load_response
264  *
265  * @note This MRQ is disabled on production systems
266  *
267  */
268 
269 /**
270  * @ingroup Module
271  * @brief request with #MRQ_MODULE_LOAD
272  *
273  * Used by #MRQ_MODULE_LOAD calls to ask the recipient to dynamically
274  * load the code located at #phys_addr and having size #size
275  * bytes. #phys_addr is treated as a void pointer.
276  *
277  * The recipient copies the code from #phys_addr to locally allocated
278  * memory prior to responding to this message.
279  *
280  * @todo document the module header format
281  *
282  * The sender is responsible for ensuring that the code is mapped in
283  * the recipient's address map.
284  *
285  */
286 struct mrq_module_load_request {
287 	/** @brief base address of the code to load. Treated as (void *) */
288 	uint32_t phys_addr; /* (void *) */
289 	/** @brief size in bytes of code to load */
290 	uint32_t size;
291 } __ABI_PACKED;
292 
293 /**
294  * @ingroup Module
295  * @brief response to #MRQ_MODULE_LOAD
296  *
297  * @todo document mrq_response::err
298  */
299 struct mrq_module_load_response {
300 	/** @brief handle to the loaded module */
301 	uint32_t base;
302 } __ABI_PACKED;
303 
304 /**
305  * @ingroup MRQ_Codes
306  * @def MRQ_MODULE_UNLOAD
307  * @brief unload a previously loaded code module
308  *
309  * * Platforms: All
310  * * Initiators: CCPLEX
311  * * Targets: BPMP
312  * * Request Payload: @ref mrq_module_unload_request
313  * * Response Payload: N/A
314  *
315  * @note This MRQ is disabled on production systems
316  */
317 
318 /**
319  * @ingroup Module
320  * @brief request with #MRQ_MODULE_UNLOAD
321  *
322  * Used by #MRQ_MODULE_UNLOAD calls to request that a previously loaded
323  * module be unloaded.
324  */
325 struct mrq_module_unload_request {
326 	/** @brief handle of the module to unload */
327 	uint32_t base;
328 } __ABI_PACKED;
329 
330 /**
331  * @ingroup MRQ_Codes
332  * @def MRQ_TRACE_MODIFY
333  * @brief modify the set of enabled trace events
334  *
335  * * Platforms: All
336  * * Initiators: CCPLEX
337  * * Targets: BPMP
338  * * Request Payload: @ref mrq_trace_modify_request
339  * * Response Payload: @ref mrq_trace_modify_response
340  *
341  * @note This MRQ is disabled on production systems
342  */
343 
344 /**
345  * @ingroup Trace
346  * @brief request with #MRQ_TRACE_MODIFY
347  *
348  * Used by %MRQ_TRACE_MODIFY calls to enable or disable specify trace
349  * events.  #set takes precedence for any bit set in both #set and
350  * #clr.
351  */
352 struct mrq_trace_modify_request {
353 	/** @brief bit mask of trace events to disable */
354 	uint32_t clr;
355 	/** @brief bit mask of trace events to enable */
356 	uint32_t set;
357 } __ABI_PACKED;
358 
359 /**
360  * @ingroup Trace
361  * @brief response to #MRQ_TRACE_MODIFY
362  *
363  * Sent in repsonse to an #MRQ_TRACE_MODIFY message. #mask reflects the
364  * state of which events are enabled after the recipient acted on the
365  * message.
366  *
367  */
368 struct mrq_trace_modify_response {
369 	/** @brief bit mask of trace event enable states */
370 	uint32_t mask;
371 } __ABI_PACKED;
372 
373 /**
374  * @ingroup MRQ_Codes
375  * @def MRQ_WRITE_TRACE
376  * @brief Write trace data to a buffer
377  *
378  * * Platforms: All
379  * * Initiators: CCPLEX
380  * * Targets: BPMP
381  * * Request Payload: @ref mrq_write_trace_request
382  * * Response Payload: @ref mrq_write_trace_response
383  *
384  * mrq_response::err depends on the @ref mrq_write_trace_request field
385  * values. err is -#BPMP_EINVAL if size is zero or area is NULL or
386  * area is in an illegal range. A positive value for err indicates the
387  * number of bytes written to area.
388  *
389  * @note This MRQ is disabled on production systems
390  */
391 
392 /**
393  * @ingroup Trace
394  * @brief request with #MRQ_WRITE_TRACE
395  *
396  * Used by MRQ_WRITE_TRACE calls to ask the recipient to copy trace
397  * data from the recipient's local buffer to the output buffer. #area
398  * is treated as a byte-aligned pointer in the recipient's address
399  * space.
400  *
401  * The sender is responsible for ensuring that the output
402  * buffer is mapped in the recipient's address map. The recipient is
403  * responsible for protecting its own code and data from accidental
404  * overwrites.
405  */
406 struct mrq_write_trace_request {
407 	/** @brief base address of output buffer */
408 	uint32_t area;
409 	/** @brief size in bytes of the output buffer */
410 	uint32_t size;
411 } __ABI_PACKED;
412 
413 /**
414  * @ingroup Trace
415  * @brief response to #MRQ_WRITE_TRACE
416  *
417  * Once this response is sent, the respondent will not access the
418  * output buffer further.
419  */
420 struct mrq_write_trace_response {
421 	/**
422 	 * @brief flag whether more data remains in local buffer
423 	 *
424 	 * Value is 1 if the entire local trace buffer has been
425 	 * drained to the outputbuffer. Value is 0 otherwise.
426 	 */
427 	uint32_t eof;
428 } __ABI_PACKED;
429 
430 /** @private */
431 struct mrq_threaded_ping_request {
432 	uint32_t challenge;
433 } __ABI_PACKED;
434 
435 /** @private */
436 struct mrq_threaded_ping_response {
437 	uint32_t reply;
438 } __ABI_PACKED;
439 
440 /**
441  * @ingroup MRQ_Codes
442  * @def MRQ_MODULE_MAIL
443  * @brief send a message to a loadable module
444  *
445  * * Platforms: All
446  * * Initiators: Any
447  * * Targets: BPMP
448  * * Request Payload: @ref mrq_module_mail_request
449  * * Response Payload: @ref mrq_module_mail_response
450  *
451  * @note This MRQ is disabled on production systems
452  */
453 
454 /**
455  * @ingroup Module
456  * @brief request with #MRQ_MODULE_MAIL
457  */
458 struct mrq_module_mail_request {
459 	/** @brief handle to the previously loaded module */
460 	uint32_t base;
461 	/** @brief module-specific mail payload
462 	 *
463 	 * The length of data[ ] is unknown to the BPMP core firmware
464 	 * but it is limited to the size of an IPC message.
465 	 */
466 	uint8_t data[EMPTY_ARRAY];
467 } __ABI_PACKED;
468 
469 /**
470  * @ingroup Module
471  * @brief response to #MRQ_MODULE_MAIL
472  */
473 struct mrq_module_mail_response {
474 	/** @brief module-specific mail payload
475 	 *
476 	 * The length of data[ ] is unknown to the BPMP core firmware
477 	 * but it is limited to the size of an IPC message.
478 	 */
479 	uint8_t data[EMPTY_ARRAY];
480 } __ABI_PACKED;
481 
482 /**
483  * @ingroup MRQ_Codes
484  * @def MRQ_DEBUGFS
485  * @brief Interact with BPMP's debugfs file nodes
486  *
487  * * Platforms: T186
488  * * Initiators: Any
489  * * Targets: BPMP
490  * * Request Payload: @ref mrq_debugfs_request
491  * * Response Payload: @ref mrq_debugfs_response
492  */
493 
494 /**
495  * @addtogroup Debugfs
496  * @{
497  *
498  * The BPMP firmware implements a pseudo-filesystem called
499  * debugfs. Any driver within the firmware may register with debugfs
500  * to expose an arbitrary set of "files" in the filesystem. When
501  * software on the CPU writes to a debugfs file, debugfs passes the
502  * written data to a callback provided by the driver. When software on
503  * the CPU reads a debugfs file, debugfs queries the driver for the
504  * data to return to the CPU. The intention of the debugfs filesystem
505  * is to provide information useful for debugging the system at
506  * runtime.
507  *
508  * @note The files exposed via debugfs are not part of the
509  * BPMP firmware's ABI. debugfs files may be added or removed in any
510  * given version of the firmware. Typically the semantics of a debugfs
511  * file are consistent from version to version but even that is not
512  * guaranteed.
513  *
514  * @}
515  */
516 /** @ingroup Debugfs */
517 enum mrq_debugfs_commands {
518 	CMD_DEBUGFS_READ = 1,
519 	CMD_DEBUGFS_WRITE = 2,
520 	CMD_DEBUGFS_DUMPDIR = 3,
521 	CMD_DEBUGFS_MAX
522 };
523 
524 /**
525  * @ingroup Debugfs
526  * @brief parameters for CMD_DEBUGFS_READ/WRITE command
527  */
528 struct cmd_debugfs_fileop_request {
529 	/** @brief physical address pointing at filename */
530 	uint32_t fnameaddr;
531 	/** @brief length in bytes of filename buffer */
532 	uint32_t fnamelen;
533 	/** @brief physical address pointing to data buffer */
534 	uint32_t dataaddr;
535 	/** @brief length in bytes of data buffer */
536 	uint32_t datalen;
537 } __ABI_PACKED;
538 
539 /**
540  * @ingroup Debugfs
541  * @brief parameters for CMD_DEBUGFS_READ/WRITE command
542  */
543 struct cmd_debugfs_dumpdir_request {
544 	/** @brief physical address pointing to data buffer */
545 	uint32_t dataaddr;
546 	/** @brief length in bytes of data buffer */
547 	uint32_t datalen;
548 } __ABI_PACKED;
549 
550 /**
551  * @ingroup Debugfs
552  * @brief response data for CMD_DEBUGFS_READ/WRITE command
553  */
554 struct cmd_debugfs_fileop_response {
555 	/** @brief always 0 */
556 	uint32_t reserved;
557 	/** @brief number of bytes read from or written to data buffer */
558 	uint32_t nbytes;
559 } __ABI_PACKED;
560 
561 /**
562  * @ingroup Debugfs
563  * @brief response data for CMD_DEBUGFS_DUMPDIR command
564  */
565 struct cmd_debugfs_dumpdir_response {
566 	/** @brief always 0 */
567 	uint32_t reserved;
568 	/** @brief number of bytes read from or written to data buffer */
569 	uint32_t nbytes;
570 } __ABI_PACKED;
571 
572 /**
573  * @ingroup Debugfs
574  * @brief request with #MRQ_DEBUGFS.
575  *
576  * The sender of an MRQ_DEBUGFS message uses #cmd to specify a debugfs
577  * command to execute. Legal commands are the values of @ref
578  * mrq_debugfs_commands. Each command requires a specific additional
579  * payload of data.
580  *
581  * |command            |payload|
582  * |-------------------|-------|
583  * |CMD_DEBUGFS_READ   |fop    |
584  * |CMD_DEBUGFS_WRITE  |fop    |
585  * |CMD_DEBUGFS_DUMPDIR|dumpdir|
586  */
587 struct mrq_debugfs_request {
588 	uint32_t cmd;
589 	union {
590 		struct cmd_debugfs_fileop_request fop;
591 		struct cmd_debugfs_dumpdir_request dumpdir;
592 	} __UNION_ANON;
593 } __ABI_PACKED;
594 
595 /**
596  * @ingroup Debugfs
597  */
598 struct mrq_debugfs_response {
599 	/** @brief always 0 */
600 	int32_t reserved;
601 	union {
602 		/** @brief response data for CMD_DEBUGFS_READ OR
603 		 * CMD_DEBUGFS_WRITE command
604 		 */
605 		struct cmd_debugfs_fileop_response fop;
606 		/** @brief response data for CMD_DEBUGFS_DUMPDIR command */
607 		struct cmd_debugfs_dumpdir_response dumpdir;
608 	} __UNION_ANON;
609 } __ABI_PACKED;
610 
611 /**
612  * @addtogroup Debugfs
613  * @{
614  */
615 #define DEBUGFS_S_ISDIR	(1 << 9)
616 #define DEBUGFS_S_IRUSR	(1 << 8)
617 #define DEBUGFS_S_IWUSR	(1 << 7)
618 /** @} */
619 
620 
621 /**
622  * @ingroup MRQ_Codes
623  * @def MRQ_RESET
624  * @brief reset an IP block
625  *
626  * * Platforms: T186
627  * * Initiators: Any
628  * * Targets: BPMP
629  * * Request Payload: @ref mrq_reset_request
630  * * Response Payload: N/A
631  */
632 
633 /**
634  * @ingroup Reset
635  */
636 enum mrq_reset_commands {
637 	CMD_RESET_ASSERT = 1,
638 	CMD_RESET_DEASSERT = 2,
639 	CMD_RESET_MODULE = 3,
640 	CMD_RESET_MAX, /* not part of ABI and subject to change */
641 };
642 
643 /**
644  * @ingroup Reset
645  * @brief request with MRQ_RESET
646  *
647  * Used by the sender of an #MRQ_RESET message to request BPMP to
648  * assert or or deassert a given reset line.
649  */
650 struct mrq_reset_request {
651 	/** @brief reset action to perform (@enum mrq_reset_commands) */
652 	uint32_t cmd;
653 	/** @brief id of the reset to affected */
654 	uint32_t reset_id;
655 } __ABI_PACKED;
656 
657 /**
658  * @ingroup MRQ_Codes
659  * @def MRQ_I2C
660  * @brief issue an i2c transaction
661  *
662  * * Platforms: T186
663  * * Initiators: Any
664  * * Targets: BPMP
665  * * Request Payload: @ref mrq_i2c_request
666  * * Response Payload: @ref mrq_i2c_response
667  */
668 
669 /**
670  * @addtogroup I2C
671  * @{
672  */
673 #define TEGRA_I2C_IPC_MAX_IN_BUF_SIZE	(MSG_DATA_MIN_SZ - 12)
674 #define TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE	(MSG_DATA_MIN_SZ - 4)
675 /** @} */
676 
677 /**
678  * @ingroup I2C
679  * @name Serial I2C flags
680  * Use these flags with serial_i2c_request::flags
681  * @{
682  */
683 #define SERIALI2C_TEN           0x0010
684 #define SERIALI2C_RD            0x0001
685 #define SERIALI2C_STOP          0x8000
686 #define SERIALI2C_NOSTART       0x4000
687 #define SERIALI2C_REV_DIR_ADDR  0x2000
688 #define SERIALI2C_IGNORE_NAK    0x1000
689 #define SERIALI2C_NO_RD_ACK     0x0800
690 #define SERIALI2C_RECV_LEN      0x0400
691 /** @} */
692 /** @ingroup I2C */
693 enum {
694 	CMD_I2C_XFER = 1
695 };
696 
697 /**
698  * @ingroup I2C
699  * @brief serializable i2c request
700  *
701  * Instances of this structure are packed (little-endian) into
702  * cmd_i2c_xfer_request::data_buf. Each instance represents a single
703  * transaction (or a portion of a transaction with repeated starts) on
704  * an i2c bus.
705  *
706  * Because these structures are packed, some instances are likely to
707  * be misaligned. Additionally because #data is variable length, it is
708  * not possible to iterate through a serialized list of these
709  * structures without inspecting #len in each instance.  It may be
710  * easier to serialize or deserialize cmd_i2c_xfer_request::data_buf
711  * manually rather than using this structure definition.
712 */
713 struct serial_i2c_request {
714 	/** @brief I2C slave address */
715 	uint16_t addr;
716 	/** @brief bitmask of SERIALI2C_ flags */
717 	uint16_t flags;
718 	/** @brief length of I2C transaction in bytes */
719 	uint16_t len;
720 	/** @brief for write transactions only, #len bytes of data */
721 	uint8_t data[];
722 } __ABI_PACKED;
723 
724 /**
725  * @ingroup I2C
726  * @brief trigger one or more i2c transactions
727  */
728 struct cmd_i2c_xfer_request {
729 	/** @brief valid bus number from mach-t186/i2c-t186.h*/
730 	uint32_t bus_id;
731 
732 	/** @brief count of valid bytes in #data_buf*/
733 	uint32_t data_size;
734 
735 	/** @brief serialized packed instances of @ref serial_i2c_request*/
736 	uint8_t data_buf[TEGRA_I2C_IPC_MAX_IN_BUF_SIZE];
737 } __ABI_PACKED;
738 
739 /**
740  * @ingroup I2C
741  * @brief container for data read from the i2c bus
742  *
743  * Processing an cmd_i2c_xfer_request::data_buf causes BPMP to execute
744  * zero or more I2C reads. The data read from the bus is serialized
745  * into #data_buf.
746  */
747 struct cmd_i2c_xfer_response {
748 	/** @brief count of valid bytes in #data_buf*/
749 	uint32_t data_size;
750 	/** @brief i2c read data */
751 	uint8_t data_buf[TEGRA_I2C_IPC_MAX_OUT_BUF_SIZE];
752 } __ABI_PACKED;
753 
754 /**
755  * @ingroup I2C
756  * @brief request with #MRQ_I2C
757  */
758 struct mrq_i2c_request {
759 	/** @brief always CMD_I2C_XFER (i.e. 1) */
760 	uint32_t cmd;
761 	/** @brief parameters of the transfer request */
762 	struct cmd_i2c_xfer_request xfer;
763 } __ABI_PACKED;
764 
765 /**
766  * @ingroup I2C
767  * @brief response to #MRQ_I2C
768  */
769 struct mrq_i2c_response {
770 	struct cmd_i2c_xfer_response xfer;
771 } __ABI_PACKED;
772 
773 /**
774  * @ingroup MRQ_Codes
775  * @def MRQ_CLK
776  *
777  * * Platforms: T186
778  * * Initiators: Any
779  * * Targets: BPMP
780  * * Request Payload: @ref mrq_clk_request
781  * * Response Payload: @ref mrq_clk_response
782  * @addtogroup Clocks
783  * @{
784  */
785 
786 /**
787  * @name MRQ_CLK sub-commands
788  * @{
789  */
790 enum {
791 	CMD_CLK_GET_RATE = 1,
792 	CMD_CLK_SET_RATE = 2,
793 	CMD_CLK_ROUND_RATE = 3,
794 	CMD_CLK_GET_PARENT = 4,
795 	CMD_CLK_SET_PARENT = 5,
796 	CMD_CLK_IS_ENABLED = 6,
797 	CMD_CLK_ENABLE = 7,
798 	CMD_CLK_DISABLE = 8,
799 	CMD_CLK_GET_ALL_INFO = 14,
800 	CMD_CLK_GET_MAX_CLK_ID = 15,
801 	CMD_CLK_MAX,
802 };
803 /** @} */
804 
805 #define MRQ_CLK_NAME_MAXLEN	40
806 #define MRQ_CLK_MAX_PARENTS	16
807 
808 /** @private */
809 struct cmd_clk_get_rate_request {
810 	EMPTY
811 } __ABI_PACKED;
812 
813 struct cmd_clk_get_rate_response {
814 	int64_t rate;
815 } __ABI_PACKED;
816 
817 struct cmd_clk_set_rate_request {
818 	int32_t unused;
819 	int64_t rate;
820 } __ABI_PACKED;
821 
822 struct cmd_clk_set_rate_response {
823 	int64_t rate;
824 } __ABI_PACKED;
825 
826 struct cmd_clk_round_rate_request {
827 	int32_t unused;
828 	int64_t rate;
829 } __ABI_PACKED;
830 
831 struct cmd_clk_round_rate_response {
832 	int64_t rate;
833 } __ABI_PACKED;
834 
835 /** @private */
836 struct cmd_clk_get_parent_request {
837 	EMPTY
838 } __ABI_PACKED;
839 
840 struct cmd_clk_get_parent_response {
841 	uint32_t parent_id;
842 } __ABI_PACKED;
843 
844 struct cmd_clk_set_parent_request {
845 	uint32_t parent_id;
846 } __ABI_PACKED;
847 
848 struct cmd_clk_set_parent_response {
849 	uint32_t parent_id;
850 } __ABI_PACKED;
851 
852 /** @private */
853 struct cmd_clk_is_enabled_request {
854 	EMPTY
855 } __ABI_PACKED;
856 
857 struct cmd_clk_is_enabled_response {
858 	int32_t state;
859 } __ABI_PACKED;
860 
861 /** @private */
862 struct cmd_clk_enable_request {
863 	EMPTY
864 } __ABI_PACKED;
865 
866 /** @private */
867 struct cmd_clk_enable_response {
868 	EMPTY
869 } __ABI_PACKED;
870 
871 /** @private */
872 struct cmd_clk_disable_request {
873 	EMPTY
874 } __ABI_PACKED;
875 
876 /** @private */
877 struct cmd_clk_disable_response {
878 	EMPTY
879 } __ABI_PACKED;
880 
881 /** @private */
882 struct cmd_clk_get_all_info_request {
883 	EMPTY
884 } __ABI_PACKED;
885 
886 struct cmd_clk_get_all_info_response {
887 	uint32_t flags;
888 	uint32_t parent;
889 	uint32_t parents[MRQ_CLK_MAX_PARENTS];
890 	uint8_t num_parents;
891 	uint8_t name[MRQ_CLK_NAME_MAXLEN];
892 } __ABI_PACKED;
893 
894 /** @private */
895 struct cmd_clk_get_max_clk_id_request {
896 	EMPTY
897 } __ABI_PACKED;
898 
899 struct cmd_clk_get_max_clk_id_response {
900 	uint32_t max_id;
901 } __ABI_PACKED;
902 /** @} */
903 
904 /**
905  * @ingroup Clocks
906  * @brief request with #MRQ_CLK
907  *
908  * Used by the sender of an #MRQ_CLK message to control clocks. The
909  * clk_request is split into several sub-commands. Some sub-commands
910  * require no additional data. Others have a sub-command specific
911  * payload
912  *
913  * |sub-command                 |payload                |
914  * |----------------------------|-----------------------|
915  * |CMD_CLK_GET_RATE            |-                      |
916  * |CMD_CLK_SET_RATE            |clk_set_rate           |
917  * |CMD_CLK_ROUND_RATE          |clk_round_rate         |
918  * |CMD_CLK_GET_PARENT          |-                      |
919  * |CMD_CLK_SET_PARENT          |clk_set_parent         |
920  * |CMD_CLK_IS_ENABLED          |-                      |
921  * |CMD_CLK_ENABLE              |-                      |
922  * |CMD_CLK_DISABLE             |-                      |
923  * |CMD_CLK_GET_ALL_INFO        |-                      |
924  * |CMD_CLK_GET_MAX_CLK_ID      |-                      |
925  *
926  */
927 
928 struct mrq_clk_request {
929 	/** @brief sub-command and clock id concatenated to 32-bit word.
930 	 * - bits[31..24] is the sub-cmd.
931 	 * - bits[23..0] is the clock id
932 	 */
933 	uint32_t cmd_and_id;
934 
935 	union {
936 		/** @private */
937 		struct cmd_clk_get_rate_request clk_get_rate;
938 		struct cmd_clk_set_rate_request clk_set_rate;
939 		struct cmd_clk_round_rate_request clk_round_rate;
940 		/** @private */
941 		struct cmd_clk_get_parent_request clk_get_parent;
942 		struct cmd_clk_set_parent_request clk_set_parent;
943 		/** @private */
944 		struct cmd_clk_enable_request clk_enable;
945 		/** @private */
946 		struct cmd_clk_disable_request clk_disable;
947 		/** @private */
948 		struct cmd_clk_is_enabled_request clk_is_enabled;
949 		/** @private */
950 		struct cmd_clk_get_all_info_request clk_get_all_info;
951 		/** @private */
952 		struct cmd_clk_get_max_clk_id_request clk_get_max_clk_id;
953 	} __UNION_ANON;
954 } __ABI_PACKED;
955 
956 /**
957  * @ingroup Clocks
958  * @brief response to MRQ_CLK
959  *
960  * Each sub-command supported by @ref mrq_clk_request may return
961  * sub-command-specific data. Some do and some do not as indicated in
962  * the following table
963  *
964  * |sub-command                 |payload                 |
965  * |----------------------------|------------------------|
966  * |CMD_CLK_GET_RATE            |clk_get_rate            |
967  * |CMD_CLK_SET_RATE            |clk_set_rate            |
968  * |CMD_CLK_ROUND_RATE          |clk_round_rate          |
969  * |CMD_CLK_GET_PARENT          |clk_get_parent          |
970  * |CMD_CLK_SET_PARENT          |clk_set_parent          |
971  * |CMD_CLK_IS_ENABLED          |clk_is_enabled          |
972  * |CMD_CLK_ENABLE              |-                       |
973  * |CMD_CLK_DISABLE             |-                       |
974  * |CMD_CLK_GET_ALL_INFO        |clk_get_all_info        |
975  * |CMD_CLK_GET_MAX_CLK_ID      |clk_get_max_id          |
976  *
977  */
978 
979 struct mrq_clk_response {
980 	union {
981 		struct cmd_clk_get_rate_response clk_get_rate;
982 		struct cmd_clk_set_rate_response clk_set_rate;
983 		struct cmd_clk_round_rate_response clk_round_rate;
984 		struct cmd_clk_get_parent_response clk_get_parent;
985 		struct cmd_clk_set_parent_response clk_set_parent;
986 		/** @private */
987 		struct cmd_clk_enable_response clk_enable;
988 		/** @private */
989 		struct cmd_clk_disable_response clk_disable;
990 		struct cmd_clk_is_enabled_response clk_is_enabled;
991 		struct cmd_clk_get_all_info_response clk_get_all_info;
992 		struct cmd_clk_get_max_clk_id_response clk_get_max_clk_id;
993 	} __UNION_ANON;
994 } __ABI_PACKED;
995 
996 /**
997  * @ingroup MRQ_Codes
998  * @def MRQ_QUERY_ABI
999  * @brief check if an MRQ is implemented
1000  *
1001  * * Platforms: All
1002  * * Initiators: Any
1003  * * Targets: Any
1004  * * Request Payload: @ref mrq_query_abi_request
1005  * * Response Payload: @ref mrq_query_abi_response
1006  */
1007 
1008 /**
1009  * @ingroup ABI_info
1010  * @brief request with MRQ_QUERY_ABI
1011  *
1012  * Used by #MRQ_QUERY_ABI call to check if MRQ code #mrq is supported
1013  * by the recipient.
1014  */
1015 struct mrq_query_abi_request {
1016 	/** @brief MRQ code to query */
1017 	uint32_t mrq;
1018 } __ABI_PACKED;
1019 
1020 /**
1021  * @ingroup ABI_info
1022  * @brief response to MRQ_QUERY_ABI
1023  */
1024 struct mrq_query_abi_response {
1025 	/** @brief 0 if queried MRQ is supported. Else, -#BPMP_ENODEV */
1026 	int32_t status;
1027 } __ABI_PACKED;
1028 
1029 /**
1030  * @ingroup MRQ_Codes
1031  * @def MRQ_PG_READ_STATE
1032  * @brief read the power-gating state of a partition
1033  *
1034  * * Platforms: T186
1035  * * Initiators: Any
1036  * * Targets: BPMP
1037  * * Request Payload: @ref mrq_pg_read_state_request
1038  * * Response Payload: @ref mrq_pg_read_state_response
1039  * @addtogroup Powergating
1040  * @{
1041  */
1042 
1043 /**
1044  * @brief request with #MRQ_PG_READ_STATE
1045  *
1046  * Used by MRQ_PG_READ_STATE call to read the current state of a
1047  * partition.
1048  */
1049 struct mrq_pg_read_state_request {
1050 	/** @brief ID of partition */
1051 	uint32_t partition_id;
1052 } __ABI_PACKED;
1053 
1054 /**
1055  * @brief response to MRQ_PG_READ_STATE
1056  * @todo define possible errors.
1057  */
1058 struct mrq_pg_read_state_response {
1059 	/** @brief read as don't care */
1060 	uint32_t sram_state;
1061 	/** @brief state of power partition
1062 	 * * 0 : off
1063 	 * * 1 : on
1064 	 */
1065 	uint32_t logic_state;
1066 } __ABI_PACKED;
1067 
1068 /** @} */
1069 
1070 /**
1071  * @ingroup MRQ_Codes
1072  * @def MRQ_PG_UPDATE_STATE
1073  * @brief modify the power-gating state of a partition
1074  *
1075  * * Platforms: T186
1076  * * Initiators: Any
1077  * * Targets: BPMP
1078  * * Request Payload: @ref mrq_pg_update_state_request
1079  * * Response Payload: N/A
1080  * @addtogroup Powergating
1081  * @{
1082  */
1083 
1084 /**
1085  * @brief request with mrq_pg_update_state_request
1086  *
1087  * Used by #MRQ_PG_UPDATE_STATE call to request BPMP to change the
1088  * state of a power partition #partition_id.
1089  */
1090 struct mrq_pg_update_state_request {
1091 	/** @brief ID of partition */
1092 	uint32_t partition_id;
1093 	/** @brief secondary control of power partition
1094 	 *  @details Ignored by many versions of the BPMP
1095 	 *  firmware. For maximum compatibility, set the value
1096 	 *  according to @logic_state
1097 	 * *  0x1: power ON partition (@ref logic_state == 0x3)
1098 	 * *  0x3: power OFF partition (@ref logic_state == 0x1)
1099 	 */
1100 	uint32_t sram_state;
1101 	/** @brief controls state of power partition, legal values are
1102 	 * *  0x1 : power OFF partition
1103 	 * *  0x3 : power ON partition
1104 	 */
1105 	uint32_t logic_state;
1106 	/** @brief change state of clocks of the power partition, legal values
1107 	 * *  0x0 : do not change clock state
1108 	 * *  0x1 : disable partition clocks (only applicable when
1109 	 *          @ref logic_state == 0x1)
1110 	 * *  0x3 : enable partition clocks (only applicable when
1111 	 *          @ref logic_state == 0x3)
1112 	 */
1113 	uint32_t clock_state;
1114 } __ABI_PACKED;
1115 /** @} */
1116 
1117 /**
1118  * @ingroup MRQ_Codes
1119  * @def MRQ_THERMAL
1120  * @brief interact with BPMP thermal framework
1121  *
1122  * * Platforms: T186
1123  * * Initiators: Any
1124  * * Targets: Any
1125  * * Request Payload: TODO
1126  * * Response Payload: TODO
1127  *
1128  * @addtogroup Thermal
1129  *
1130  * The BPMP firmware includes a thermal framework. Drivers within the
1131  * bpmp firmware register with the framework to provide thermal
1132  * zones. Each thermal zone corresponds to an entity whose temperature
1133  * can be measured. The framework also has a notion of trip points. A
1134  * trip point consists of a thermal zone id, a temperature, and a
1135  * callback routine. The framework invokes the callback when the zone
1136  * hits the indicated temperature. The BPMP firmware uses this thermal
1137  * framework interally to implement various temperature-dependent
1138  * functions.
1139  *
1140  * Software on the CPU can use #MRQ_THERMAL (with payload @ref
1141  * mrq_thermal_host_to_bpmp_request) to interact with the BPMP thermal
1142  * framework. The CPU must It can query the number of supported zones,
1143  * query zone temperatures, and set trip points.
1144  *
1145  * When a trip point set by the CPU gets crossed, BPMP firmware issues
1146  * an IPC to the CPU having mrq_request::mrq = #MRQ_THERMAL and a
1147  * payload of @ref mrq_thermal_bpmp_to_host_request.
1148  * @{
1149  */
1150 enum mrq_thermal_host_to_bpmp_cmd {
1151 	/**
1152 	 * @brief Check whether the BPMP driver supports the specified
1153 	 * request type.
1154 	 *
1155 	 * Host needs to supply request parameters.
1156 	 *
1157 	 * mrq_response::err is 0 if the specified request is
1158 	 * supported and -#BPMP_ENODEV otherwise.
1159 	 */
1160 	CMD_THERMAL_QUERY_ABI = 0,
1161 
1162 	/**
1163 	 * @brief Get the current temperature of the specified zone.
1164 	 *
1165 	 * Host needs to supply request parameters.
1166 	 *
1167 	 * mrq_response::err is
1168 	 * *  0: Temperature query succeeded.
1169 	 * *  -#BPMP_EINVAL: Invalid request parameters.
1170 	 * *  -#BPMP_ENOENT: No driver registered for thermal zone..
1171 	 * *  -#BPMP_EFAULT: Problem reading temperature measurement.
1172 	 */
1173 	CMD_THERMAL_GET_TEMP = 1,
1174 
1175 	/**
1176 	 * @brief Enable or disable and set the lower and upper
1177 	 *   thermal limits for a thermal trip point. Each zone has
1178 	 *   one trip point.
1179 	 *
1180 	 * Host needs to supply request parameters. Once the
1181 	 * temperature hits a trip point, the BPMP will send a message
1182 	 * to the CPU having MRQ=MRQ_THERMAL and
1183 	 * type=CMD_THERMAL_HOST_TRIP_REACHED
1184 	 *
1185 	 * mrq_response::err is
1186 	 * *  0: Trip successfully set.
1187 	 * *  -#BPMP_EINVAL: Invalid request parameters.
1188 	 * *  -#BPMP_ENOENT: No driver registered for thermal zone.
1189 	 * *  -#BPMP_EFAULT: Problem setting trip point.
1190 	 */
1191 	CMD_THERMAL_SET_TRIP = 2,
1192 
1193 	/**
1194 	 * @brief Get the number of supported thermal zones.
1195 	 *
1196 	 * No request parameters required.
1197 	 *
1198 	 * mrq_response::err is always 0, indicating success.
1199 	 */
1200 	CMD_THERMAL_GET_NUM_ZONES = 3,
1201 
1202 	/** @brief: number of supported host-to-bpmp commands. May
1203 	 * increase in future
1204 	 */
1205 	CMD_THERMAL_HOST_TO_BPMP_NUM
1206 };
1207 
1208 enum mrq_thermal_bpmp_to_host_cmd {
1209 	/**
1210 	 * @brief Indication that the temperature for a zone has
1211 	 *   exceeded the range indicated in the thermal trip point
1212 	 *   for the zone.
1213 	 *
1214 	 * BPMP needs to supply request parameters. Host only needs to
1215 	 * acknowledge.
1216 	 */
1217 	CMD_THERMAL_HOST_TRIP_REACHED = 100,
1218 
1219 	/** @brief: number of supported bpmp-to-host commands. May
1220 	 * increase in future
1221 	 */
1222 	CMD_THERMAL_BPMP_TO_HOST_NUM
1223 };
1224 
1225 /*
1226  * Host->BPMP request data for request type CMD_THERMAL_QUERY_ABI
1227  *
1228  * zone: Request type for which to check existence.
1229  */
1230 struct cmd_thermal_query_abi_request {
1231 	uint32_t type;
1232 } __ABI_PACKED;
1233 
1234 /*
1235  * Host->BPMP request data for request type CMD_THERMAL_GET_TEMP
1236  *
1237  * zone: Number of thermal zone.
1238  */
1239 struct cmd_thermal_get_temp_request {
1240 	uint32_t zone;
1241 } __ABI_PACKED;
1242 
1243 /*
1244  * BPMP->Host reply data for request CMD_THERMAL_GET_TEMP
1245  *
1246  * error: 0 if request succeeded.
1247  *	-BPMP_EINVAL if request parameters were invalid.
1248  *      -BPMP_ENOENT if no driver was registered for the specified thermal zone.
1249  *      -BPMP_EFAULT for other thermal zone driver errors.
1250  * temp: Current temperature in millicelsius.
1251  */
1252 struct cmd_thermal_get_temp_response {
1253 	int32_t temp;
1254 } __ABI_PACKED;
1255 
1256 /*
1257  * Host->BPMP request data for request type CMD_THERMAL_SET_TRIP
1258  *
1259  * zone: Number of thermal zone.
1260  * low: Temperature of lower trip point in millicelsius
1261  * high: Temperature of upper trip point in millicelsius
1262  * enabled: 1 to enable trip point, 0 to disable trip point
1263  */
1264 struct cmd_thermal_set_trip_request {
1265 	uint32_t zone;
1266 	int32_t low;
1267 	int32_t high;
1268 	uint32_t enabled;
1269 } __ABI_PACKED;
1270 
1271 /*
1272  * BPMP->Host request data for request type CMD_THERMAL_HOST_TRIP_REACHED
1273  *
1274  * zone: Number of thermal zone where trip point was reached.
1275  */
1276 struct cmd_thermal_host_trip_reached_request {
1277 	uint32_t zone;
1278 } __ABI_PACKED;
1279 
1280 /*
1281  * BPMP->Host reply data for request type CMD_THERMAL_GET_NUM_ZONES
1282  *
1283  * num: Number of supported thermal zones. The thermal zones are indexed
1284  *      starting from zero.
1285  */
1286 struct cmd_thermal_get_num_zones_response {
1287 	uint32_t num;
1288 } __ABI_PACKED;
1289 
1290 /*
1291  * Host->BPMP request data.
1292  *
1293  * Reply type is union mrq_thermal_bpmp_to_host_response.
1294  *
1295  * type: Type of request. Values listed in enum mrq_thermal_type.
1296  * data: Request type specific parameters.
1297  */
1298 struct mrq_thermal_host_to_bpmp_request {
1299 	uint32_t type;
1300 	union {
1301 		struct cmd_thermal_query_abi_request query_abi;
1302 		struct cmd_thermal_get_temp_request get_temp;
1303 		struct cmd_thermal_set_trip_request set_trip;
1304 	} __UNION_ANON;
1305 } __ABI_PACKED;
1306 
1307 /*
1308  * BPMP->Host request data.
1309  *
1310  * type: Type of request. Values listed in enum mrq_thermal_type.
1311  * data: Request type specific parameters.
1312  */
1313 struct mrq_thermal_bpmp_to_host_request {
1314 	uint32_t type;
1315 	union {
1316 		struct cmd_thermal_host_trip_reached_request host_trip_reached;
1317 	} __UNION_ANON;
1318 } __ABI_PACKED;
1319 
1320 /*
1321  * Data in reply to a Host->BPMP request.
1322  */
1323 union mrq_thermal_bpmp_to_host_response {
1324 	struct cmd_thermal_get_temp_response get_temp;
1325 	struct cmd_thermal_get_num_zones_response get_num_zones;
1326 } __ABI_PACKED;
1327 /** @} */
1328 
1329 /**
1330  * @ingroup MRQ_Codes
1331  * @def MRQ_CPU_VHINT
1332  * @brief Query CPU voltage hint data
1333  *
1334  * * Platforms: T186
1335  * * Initiators: CCPLEX
1336  * * Targets: BPMP
1337  * * Request Payload: @ref mrq_cpu_vhint_request
1338  * * Response Payload: N/A
1339  *
1340  * @addtogroup Vhint CPU Voltage hint
1341  * @{
1342  */
1343 
1344 /**
1345  * @brief request with #MRQ_CPU_VHINT
1346  *
1347  * Used by #MRQ_CPU_VHINT call by CCPLEX to retrieve voltage hint data
1348  * from BPMP to memory space pointed by #addr. CCPLEX is responsible
1349  * to allocate sizeof(cpu_vhint_data) sized block of memory and
1350  * appropriately map it for BPMP before sending the request.
1351  */
1352 struct mrq_cpu_vhint_request {
1353 	/** @brief IOVA address for the #cpu_vhint_data */
1354 	uint32_t addr; /* struct cpu_vhint_data * */
1355 	/** @brief ID of the cluster whose data is requested */
1356 	uint32_t cluster_id; /* enum cluster_id */
1357 } __ABI_PACKED;
1358 
1359 /**
1360  * @brief description of the CPU v/f relation
1361  *
1362  * Used by #MRQ_CPU_VHINT call to carry data pointed by #addr of
1363  * struct mrq_cpu_vhint_request
1364  */
1365 struct cpu_vhint_data {
1366 	uint32_t ref_clk_hz; /**< reference frequency in Hz */
1367 	uint16_t pdiv; /**< post divider value */
1368 	uint16_t mdiv; /**< input divider value */
1369 	uint16_t ndiv_max; /**< fMAX expressed with max NDIV value */
1370 	/** table of ndiv values as a function of vINDEX (voltage index) */
1371 	uint16_t ndiv[80];
1372 	/** minimum allowed NDIV value */
1373 	uint16_t ndiv_min;
1374 	/** minimum allowed voltage hint value (as in vINDEX) */
1375 	uint16_t vfloor;
1376 	/** maximum allowed voltage hint value (as in vINDEX) */
1377 	uint16_t vceil;
1378 	/** post-multiplier for vindex value */
1379 	uint16_t vindex_mult;
1380 	/** post-divider for vindex value */
1381 	uint16_t vindex_div;
1382 	/** reserved for future use */
1383 	uint16_t reserved[328];
1384 } __ABI_PACKED;
1385 
1386 /** @} */
1387 
1388 /**
1389  * @ingroup MRQ_Codes
1390  * @def MRQ_ABI_RATCHET
1391  * @brief ABI ratchet value query
1392  *
1393  * * Platforms: T186
1394  * * Initiators: Any
1395  * * Targets: BPMP
1396  * * Request Payload: @ref mrq_abi_ratchet_request
1397  * * Response Payload: @ref mrq_abi_ratchet_response
1398  * @addtogroup ABI_info
1399  * @{
1400  */
1401 
1402 /**
1403  * @brief an ABI compatibility mechanism
1404  *
1405  * BPMP_ABI_RATCHET_VALUE may increase for various reasons in a future
1406  * revision of this header file.
1407  * 1. That future revision deprecates some MRQ
1408  * 2. That future revision introduces a breaking change to an existing
1409  *    MRQ or
1410  * 3. A bug is discovered in an existing implementation of the BPMP-FW
1411  *    (or possibly one of its clients) which warrants deprecating that
1412  *    implementation.
1413  */
1414 #define BPMP_ABI_RATCHET_VALUE 3
1415 
1416 /**
1417  * @brief request with #MRQ_ABI_RATCHET.
1418  *
1419  * #ratchet should be #BPMP_ABI_RATCHET_VALUE from the ABI header
1420  * against which the requester was compiled.
1421  *
1422  * If ratchet is less than BPMP's #BPMP_ABI_RATCHET_VALUE, BPMP may
1423  * reply with mrq_response::err = -#BPMP_ERANGE to indicate that
1424  * BPMP-FW cannot interoperate correctly with the requester. Requester
1425  * should cease further communication with BPMP.
1426  *
1427  * Otherwise, err shall be 0.
1428  */
1429 struct mrq_abi_ratchet_request {
1430 	/** @brief requester's ratchet value */
1431 	uint16_t ratchet;
1432 };
1433 
1434 /**
1435  * @brief response to #MRQ_ABI_RATCHET
1436  *
1437  * #ratchet shall be #BPMP_ABI_RATCHET_VALUE from the ABI header
1438  * against which BPMP firwmare was compiled.
1439  *
1440  * If #ratchet is less than the requester's #BPMP_ABI_RATCHET_VALUE,
1441  * the requster must either interoperate with BPMP according to an ABI
1442  * header version with BPMP_ABI_RATCHET_VALUE = ratchet or cease
1443  * communication with BPMP.
1444  *
1445  * If mrq_response::err is 0 and ratchet is greater than or equal to the
1446  * requester's BPMP_ABI_RATCHET_VALUE, the requester should continue
1447  * normal operation.
1448  */
1449 struct mrq_abi_ratchet_response {
1450 	/** @brief BPMP's ratchet value */
1451 	uint16_t ratchet;
1452 };
1453 /** @} */
1454 
1455 /**
1456  * @ingroup MRQ_Codes
1457  * @def MRQ_EMC_DVFS_LATENCY
1458  * @brief query frequency dependent EMC DVFS latency
1459  *
1460  * * Platforms: T186
1461  * * Initiators: CCPLEX
1462  * * Targets: BPMP
1463  * * Request Payload: N/A
1464  * * Response Payload: @ref mrq_emc_dvfs_latency_response
1465  * @addtogroup EMC
1466  * @{
1467  */
1468 
1469 /**
1470  * @brief used by @ref mrq_emc_dvfs_latency_response
1471  */
1472 struct emc_dvfs_latency {
1473 	/** @brief EMC frequency in kHz */
1474 	uint32_t freq;
1475 	/** @brief EMC DVFS latency in nanoseconds */
1476 	uint32_t latency;
1477 } __ABI_PACKED;
1478 
1479 #define EMC_DVFS_LATENCY_MAX_SIZE	14
1480 /**
1481  * @brief response to #MRQ_EMC_DVFS_LATENCY
1482  */
1483 struct mrq_emc_dvfs_latency_response {
1484 	/** @brief the number valid entries in #pairs */
1485 	uint32_t num_pairs;
1486 	/** @brief EMC <frequency, latency> information */
1487 	struct emc_dvfs_latency pairs[EMC_DVFS_LATENCY_MAX_SIZE];
1488 } __ABI_PACKED;
1489 
1490 /** @} */
1491 
1492 /**
1493  * @ingroup MRQ_Codes
1494  * @def MRQ_TRACE_ITER
1495  * @brief manage the trace iterator
1496  *
1497  * * Platforms: All
1498  * * Initiators: CCPLEX
1499  * * Targets: BPMP
1500  * * Request Payload: N/A
1501  * * Response Payload: @ref mrq_trace_iter_request
1502  * @addtogroup Trace
1503  * @{
1504  */
1505 enum {
1506 	/** @brief (re)start the tracing now. Ignore older events */
1507 	TRACE_ITER_INIT = 0,
1508 	/** @brief clobber all events in the trace buffer */
1509 	TRACE_ITER_CLEAN = 1
1510 };
1511 
1512 /**
1513  * @brief request with #MRQ_TRACE_ITER
1514  */
1515 struct mrq_trace_iter_request {
1516 	/** @brief TRACE_ITER_INIT or TRACE_ITER_CLEAN */
1517 	uint32_t cmd;
1518 } __ABI_PACKED;
1519 
1520 /** @} */
1521 
1522 /*
1523  *  4. Enumerations
1524  */
1525 
1526 /*
1527  *   4.1 CPU enumerations
1528  *
1529  * See <mach-t186/system-t186.h>
1530  *
1531  *   4.2 CPU Cluster enumerations
1532  *
1533  * See <mach-t186/system-t186.h>
1534  *
1535  *   4.3 System low power state enumerations
1536  *
1537  * See <mach-t186/system-t186.h>
1538  */
1539 
1540 /*
1541  *   4.4 Clock enumerations
1542  *
1543  * For clock enumerations, see <mach-t186/clk-t186.h>
1544  */
1545 
1546 /*
1547  *   4.5 Reset enumerations
1548  *
1549  * For reset enumerations, see <mach-t186/reset-t186.h>
1550  */
1551 
1552 /*
1553  *   4.6 Thermal sensor enumerations
1554  *
1555  * For thermal sensor enumerations, see <mach-t186/thermal-t186.h>
1556  */
1557 
1558 /**
1559  * @defgroup Error_Codes
1560  * Negative values for mrq_response::err generally indicate some
1561  * error. The ABI defines the following error codes. Negating these
1562  * defines is an exercise left to the user.
1563  * @{
1564  */
1565 /** @brief No such file or directory */
1566 #define BPMP_ENOENT	2
1567 /** @brief No MRQ handler */
1568 #define BPMP_ENOHANDLER	3
1569 /** @brief I/O error */
1570 #define BPMP_EIO	5
1571 /** @brief Bad sub-MRQ command */
1572 #define BPMP_EBADCMD	6
1573 /** @brief Not enough memory */
1574 #define BPMP_ENOMEM	12
1575 /** @brief Permission denied */
1576 #define BPMP_EACCES	13
1577 /** @brief Bad address */
1578 #define BPMP_EFAULT	14
1579 /** @brief No such device */
1580 #define BPMP_ENODEV	19
1581 /** @brief Argument is a directory */
1582 #define BPMP_EISDIR	21
1583 /** @brief Invalid argument */
1584 #define BPMP_EINVAL	22
1585 /** @brief Timeout during operation */
1586 #define BPMP_ETIMEDOUT  23
1587 /** @brief Out of range */
1588 #define BPMP_ERANGE	34
1589 /** @} */
1590 /** @} */
1591 #endif
1592