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