MAJOR=4
MINOR=38
DEVNAME=tty38
     ˆÅÊ…]iñÄ¿È ?÷     /* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) 2014-2022, NVIDIA CORPORATION.  All rights reserved.
 */

#ifndef ABI_BPMP_ABI_H
#define ABI_BPMP_ABI_H

#if defined(LK) || defined(BPMP_ABI_HAVE_STDC)
#include <stddef.h>
#include <stdint.h>
#endif

#ifndef BPMP_ABI_PACKED
#ifdef __ABI_PACKED
#define BPMP_ABI_PACKED __ABI_PACKED
#else
#define BPMP_ABI_PACKED __attribute__((packed))
#endif
#endif

#ifdef NO_GCC_EXTENSIONS
#define BPMP_ABI_EMPTY char empty;
#define BPMP_ABI_EMPTY_ARRAY 1
#else
#define BPMP_ABI_EMPTY
#define BPMP_ABI_EMPTY_ARRAY 0
#endif

#ifndef BPMP_UNION_ANON
#ifdef __UNION_ANON
#define BPMP_UNION_ANON __UNION_ANON
#else
#define BPMP_UNION_ANON
#endif
#endif

/**
 * @file
 */

/**
 * @defgroup MRQ MRQ Messages
 * @brief Messages sent to/from BPMP via IPC
 * @{
 *   @defgroup MRQ_Format Message Format
 *   @defgroup MRQ_Codes Message Request (MRQ) Codes
 *   @defgroup MRQ_Payloads Message Payloads
 *   @defgroup Error_Codes Error Codes
 * @}
 */

/**
 * @addtogroup MRQ_Format
 * @{
 * The CPU requests the BPMP to perform a particular service by
 * sending it an IVC frame containing a single MRQ message. An MRQ
 * message consists of a @ref mrq_request followed by a payload whose
 * format depends on mrq_request::mrq.
 *
 * The BPMP processes the data and replies with an IVC frame (on the
 * same IVC channel) containing and MRQ response. An MRQ response
 * consists of a @ref mrq_response followed by a payload whose format
 * depends on the associated mrq_request::mrq.
 *
 * A well-defined subset of the MRQ messages that the CPU sends to the
 * BPMP can lead to BPMP eventually sending an MRQ message to the
 * CPU. For example, when the CPU uses an #MRQ_THERMAL message to set
 * a thermal trip point, the BPMP may eventually send a single
 * #MRQ_THERMAL message of its own to the CPU indicating that the trip
 * point has been crossed.
 * @}
 */

/**
 * @ingroup MRQ_Format
 * Request an answer from the peer.
 * This should be set in mrq_request::flags for all requests targetted
 * at BPMP. For requests originating in BPMP, this flag is optional except
 * for messages targeting MCE, for which the field must be set.
 * When this flag is not set, the remote peer must not send a response
 * back.
 */
#define BPMP_MAIL_DO_ACK	(1U << 0U)

/**
 * @ingroup MRQ_Format
 * Ring the sender's doorbell when responding. This should be set unless
 * the sender wants to poll the underlying communications layer directly.
 *
 * An optional direction that can be specified in mrq_request::flags.
 */
#define BPMP_MAIL_RING_DB	(1U << 1U)

/**
 * @ingroup MRQ_Format
 * CRC present
 */
#define BPMP_MAIL_CRC_PRESENT	(1U << 2U)

/**
 * @ingroup MRQ_Format
 * @brief Header for an MRQ message
 *
 * Provides the MRQ number for the MRQ message: #mrq. The remainder of
 * the MRQ message is a payload (immediately following the
 * mrq_request) whose format depends on mrq.
 */
struct mrq_request {
	/** @brief MRQ number of the request */
	uint32_t mrq;

	/**
	 * @brief 32bit word containing a number of fields as follows:
	 *
	 * 	struct {
	 * 		uint8_t options:4;
	 * 		uint8_t xid:4;
	 * 		uint8_t payload_length;
	 * 		uint16_t crc16;
	 * 	};
	 *
	 * **options** directions to the receiver and indicates CRC presence.
	 *
	 * #BPMP_MAIL_DO_ACK and  #BPMP_MAIL_RING_DB see documentation of respective options.
	 * #BPMP_MAIL_CRC_PRESENT is supported on T234 and later platforms. It indicates the
	 * crc16, xid and length fields are present when set.
	 * Some platform configurations, especially when targeted to applications requiring
	 * functional safety, mandate this option being set or otherwise will respond with
	 * -BPMP_EBADMSG and ignore the request.
	 *
	 * **xid** is a transaction ID.
	 *
	 * Only used when #BPMP_MAIL_CRC_PRESENT is set.
	 *
	 * **payload_length** of the message expressed in bytes without the size of this header.
	 * See table below for minimum accepted payload lengths for each MRQ.
	 * Note: For DMCE communication, this field expresses the length as