17c008829SNicholas Kazlauskas /*
27c008829SNicholas Kazlauskas  * Copyright 2019 Advanced Micro Devices, Inc.
37c008829SNicholas Kazlauskas  *
47c008829SNicholas Kazlauskas  * Permission is hereby granted, free of charge, to any person obtaining a
57c008829SNicholas Kazlauskas  * copy of this software and associated documentation files (the "Software"),
67c008829SNicholas Kazlauskas  * to deal in the Software without restriction, including without limitation
77c008829SNicholas Kazlauskas  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
87c008829SNicholas Kazlauskas  * and/or sell copies of the Software, and to permit persons to whom the
97c008829SNicholas Kazlauskas  * Software is furnished to do so, subject to the following conditions:
107c008829SNicholas Kazlauskas  *
117c008829SNicholas Kazlauskas  * The above copyright notice and this permission notice shall be included in
127c008829SNicholas Kazlauskas  * all copies or substantial portions of the Software.
137c008829SNicholas Kazlauskas  *
147c008829SNicholas Kazlauskas  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
157c008829SNicholas Kazlauskas  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
167c008829SNicholas Kazlauskas  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
177c008829SNicholas Kazlauskas  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
187c008829SNicholas Kazlauskas  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
197c008829SNicholas Kazlauskas  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
207c008829SNicholas Kazlauskas  * OTHER DEALINGS IN THE SOFTWARE.
217c008829SNicholas Kazlauskas  *
227c008829SNicholas Kazlauskas  * Authors: AMD
237c008829SNicholas Kazlauskas  *
247c008829SNicholas Kazlauskas  */
257c008829SNicholas Kazlauskas 
265624c345SAnthony Koo #ifndef DMUB_CMD_H
275624c345SAnthony Koo #define DMUB_CMD_H
287c008829SNicholas Kazlauskas 
298b19a4e3SAnthony Koo #if defined(_TEST_HARNESS) || defined(FPGA_USB4)
308b19a4e3SAnthony Koo #include "dmub_fw_types.h"
318b19a4e3SAnthony Koo #include "include_legacy/atomfirmware.h"
328b19a4e3SAnthony Koo 
338b19a4e3SAnthony Koo #if defined(_TEST_HARNESS)
348b19a4e3SAnthony Koo #include <string.h>
358b19a4e3SAnthony Koo #endif
368b19a4e3SAnthony Koo #else
378b19a4e3SAnthony Koo 
3884034ad4SAnthony Koo #include <asm/byteorder.h>
3984034ad4SAnthony Koo #include <linux/types.h>
4084034ad4SAnthony Koo #include <linux/string.h>
4184034ad4SAnthony Koo #include <linux/delay.h>
4284034ad4SAnthony Koo 
437c008829SNicholas Kazlauskas #include "atomfirmware.h"
4422aa5614SYongqiang Sun 
458b19a4e3SAnthony Koo #endif // defined(_TEST_HARNESS) || defined(FPGA_USB4)
468b19a4e3SAnthony Koo 
478598a722SAnthony Koo /* Firmware versioning. */
488598a722SAnthony Koo #ifdef DMUB_EXPOSE_VERSION
495b5e0776SAnthony Koo #define DMUB_FW_VERSION_GIT_HASH 0x9525efb5
50b2265774SAnthony Koo #define DMUB_FW_VERSION_MAJOR 0
518598a722SAnthony Koo #define DMUB_FW_VERSION_MINOR 0
525b5e0776SAnthony Koo #define DMUB_FW_VERSION_REVISION 90
53ded750e6SAnthony Koo #define DMUB_FW_VERSION_TEST 0
54ded750e6SAnthony Koo #define DMUB_FW_VERSION_VBIOS 0
55ded750e6SAnthony Koo #define DMUB_FW_VERSION_HOTFIX 0
56ded750e6SAnthony Koo #define DMUB_FW_VERSION_UCODE (((DMUB_FW_VERSION_MAJOR & 0xFF) << 24) | \
57ded750e6SAnthony Koo 		((DMUB_FW_VERSION_MINOR & 0xFF) << 16) | \
58ded750e6SAnthony Koo 		((DMUB_FW_VERSION_REVISION & 0xFF) << 8) | \
59ded750e6SAnthony Koo 		((DMUB_FW_VERSION_TEST & 0x1) << 7) | \
60ded750e6SAnthony Koo 		((DMUB_FW_VERSION_VBIOS & 0x1) << 6) | \
61ded750e6SAnthony Koo 		(DMUB_FW_VERSION_HOTFIX & 0x3F))
62ded750e6SAnthony Koo 
638598a722SAnthony Koo #endif
6484034ad4SAnthony Koo 
6584034ad4SAnthony Koo //<DMUB_TYPES>==================================================================
6684034ad4SAnthony Koo /* Basic type definitions. */
6784034ad4SAnthony Koo 
688b19a4e3SAnthony Koo #define __forceinline inline
698b19a4e3SAnthony Koo 
701a595f28SAnthony Koo /**
711a595f28SAnthony Koo  * Flag from driver to indicate that ABM should be disabled gradually
721a595f28SAnthony Koo  * by slowly reversing all backlight programming and pixel compensation.
731a595f28SAnthony Koo  */
7484034ad4SAnthony Koo #define SET_ABM_PIPE_GRADUALLY_DISABLE           0
751a595f28SAnthony Koo 
761a595f28SAnthony Koo /**
771a595f28SAnthony Koo  * Flag from driver to indicate that ABM should be disabled immediately
781a595f28SAnthony Koo  * and undo all backlight programming and pixel compensation.
791a595f28SAnthony Koo  */
8084034ad4SAnthony Koo #define SET_ABM_PIPE_IMMEDIATELY_DISABLE         255
811a595f28SAnthony Koo 
821a595f28SAnthony Koo /**
831a595f28SAnthony Koo  * Flag from driver to indicate that ABM should be disabled immediately
841a595f28SAnthony Koo  * and keep the current backlight programming and pixel compensation.
851a595f28SAnthony Koo  */
86d9beecfcSAnthony Koo #define SET_ABM_PIPE_IMMEDIATE_KEEP_GAIN_DISABLE 254
871a595f28SAnthony Koo 
881a595f28SAnthony Koo /**
891a595f28SAnthony Koo  * Flag from driver to set the current ABM pipe index or ABM operating level.
901a595f28SAnthony Koo  */
9184034ad4SAnthony Koo #define SET_ABM_PIPE_NORMAL                      1
9284034ad4SAnthony Koo 
931a595f28SAnthony Koo /**
941a595f28SAnthony Koo  * Number of ambient light levels in ABM algorithm.
951a595f28SAnthony Koo  */
961a595f28SAnthony Koo #define NUM_AMBI_LEVEL                  5
971a595f28SAnthony Koo 
981a595f28SAnthony Koo /**
991a595f28SAnthony Koo  * Number of operating/aggression levels in ABM algorithm.
1001a595f28SAnthony Koo  */
1011a595f28SAnthony Koo #define NUM_AGGR_LEVEL                  4
1021a595f28SAnthony Koo 
1031a595f28SAnthony Koo /**
1041a595f28SAnthony Koo  * Number of segments in the gamma curve.
1051a595f28SAnthony Koo  */
1061a595f28SAnthony Koo #define NUM_POWER_FN_SEGS               8
1071a595f28SAnthony Koo 
1081a595f28SAnthony Koo /**
1091a595f28SAnthony Koo  * Number of segments in the backlight curve.
1101a595f28SAnthony Koo  */
1111a595f28SAnthony Koo #define NUM_BL_CURVE_SEGS               16
1121a595f28SAnthony Koo 
11384034ad4SAnthony Koo /* Maximum number of streams on any ASIC. */
11484034ad4SAnthony Koo #define DMUB_MAX_STREAMS 6
11584034ad4SAnthony Koo 
11684034ad4SAnthony Koo /* Maximum number of planes on any ASIC. */
11784034ad4SAnthony Koo #define DMUB_MAX_PLANES 6
11884034ad4SAnthony Koo 
11970732504SYongqiang Sun /* Trace buffer offset for entry */
12070732504SYongqiang Sun #define TRACE_BUFFER_ENTRY_OFFSET  16
12170732504SYongqiang Sun 
122592a6318SAnthony Koo /**
123f56c837aSMikita Lipski  *
124f56c837aSMikita Lipski  * PSR control version legacy
125f56c837aSMikita Lipski  */
126f56c837aSMikita Lipski #define DMUB_CMD_PSR_CONTROL_VERSION_UNKNOWN 0x0
127f56c837aSMikita Lipski /**
128f56c837aSMikita Lipski  * PSR control version with multi edp support
129f56c837aSMikita Lipski  */
130f56c837aSMikita Lipski #define DMUB_CMD_PSR_CONTROL_VERSION_1 0x1
131f56c837aSMikita Lipski 
132f56c837aSMikita Lipski 
133f56c837aSMikita Lipski /**
13463de4f04SJake Wang  * ABM control version legacy
135e922057bSJake Wang  */
13663de4f04SJake Wang #define DMUB_CMD_ABM_CONTROL_VERSION_UNKNOWN 0x0
137e922057bSJake Wang 
138e922057bSJake Wang /**
13963de4f04SJake Wang  * ABM control version with multi edp support
140e922057bSJake Wang  */
14163de4f04SJake Wang #define DMUB_CMD_ABM_CONTROL_VERSION_1 0x1
142e922057bSJake Wang 
143e922057bSJake Wang /**
144592a6318SAnthony Koo  * Physical framebuffer address location, 64-bit.
145592a6318SAnthony Koo  */
14684034ad4SAnthony Koo #ifndef PHYSICAL_ADDRESS_LOC
14784034ad4SAnthony Koo #define PHYSICAL_ADDRESS_LOC union large_integer
14884034ad4SAnthony Koo #endif
14984034ad4SAnthony Koo 
150592a6318SAnthony Koo /**
151592a6318SAnthony Koo  * OS/FW agnostic memcpy
152592a6318SAnthony Koo  */
15384034ad4SAnthony Koo #ifndef dmub_memcpy
15484034ad4SAnthony Koo #define dmub_memcpy(dest, source, bytes) memcpy((dest), (source), (bytes))
15584034ad4SAnthony Koo #endif
15684034ad4SAnthony Koo 
157592a6318SAnthony Koo /**
158592a6318SAnthony Koo  * OS/FW agnostic memset
159592a6318SAnthony Koo  */
16084034ad4SAnthony Koo #ifndef dmub_memset
16184034ad4SAnthony Koo #define dmub_memset(dest, val, bytes) memset((dest), (val), (bytes))
16284034ad4SAnthony Koo #endif
16384034ad4SAnthony Koo 
164d9beecfcSAnthony Koo #if defined(__cplusplus)
165d9beecfcSAnthony Koo extern "C" {
166d9beecfcSAnthony Koo #endif
167d9beecfcSAnthony Koo 
168592a6318SAnthony Koo /**
169592a6318SAnthony Koo  * OS/FW agnostic udelay
170592a6318SAnthony Koo  */
17184034ad4SAnthony Koo #ifndef dmub_udelay
17284034ad4SAnthony Koo #define dmub_udelay(microseconds) udelay(microseconds)
17384034ad4SAnthony Koo #endif
17484034ad4SAnthony Koo 
175592a6318SAnthony Koo /**
1760b51e7e8SAnthony Koo  * Number of nanoseconds per DMUB tick.
1770b51e7e8SAnthony Koo  * DMCUB_TIMER_CURRENT increments in DMUB ticks, which are 10ns by default.
1780b51e7e8SAnthony Koo  * If DMCUB_TIMER_WINDOW is non-zero this will no longer be true.
1790b51e7e8SAnthony Koo  */
1800b51e7e8SAnthony Koo #define NS_PER_DMUB_TICK 10
1810b51e7e8SAnthony Koo 
1820b51e7e8SAnthony Koo /**
183592a6318SAnthony Koo  * union dmub_addr - DMUB physical/virtual 64-bit address.
184592a6318SAnthony Koo  */
18584034ad4SAnthony Koo union dmub_addr {
18684034ad4SAnthony Koo 	struct {
187592a6318SAnthony Koo 		uint32_t low_part; /**< Lower 32 bits */
188592a6318SAnthony Koo 		uint32_t high_part; /**< Upper 32 bits */
189592a6318SAnthony Koo 	} u; /*<< Low/high bit access */
190592a6318SAnthony Koo 	uint64_t quad_part; /*<< 64 bit address */
19184034ad4SAnthony Koo };
19284034ad4SAnthony Koo 
1931a595f28SAnthony Koo /**
1941a595f28SAnthony Koo  * Flags that can be set by driver to change some PSR behaviour.
1951a595f28SAnthony Koo  */
19684034ad4SAnthony Koo union dmub_psr_debug_flags {
1971a595f28SAnthony Koo 	/**
1981a595f28SAnthony Koo 	 * Debug flags.
1991a595f28SAnthony Koo 	 */
20084034ad4SAnthony Koo 	struct {
2011a595f28SAnthony Koo 		/**
2021a595f28SAnthony Koo 		 * Enable visual confirm in FW.
2031a595f28SAnthony Koo 		 */
204447f3d0fSAnthony Koo 		uint32_t visual_confirm : 1;
2051a595f28SAnthony Koo 		/**
2061a595f28SAnthony Koo 		 * Use HW Lock Mgr object to do HW locking in FW.
2071a595f28SAnthony Koo 		 */
208447f3d0fSAnthony Koo 		uint32_t use_hw_lock_mgr : 1;
2091a595f28SAnthony Koo 
2101a595f28SAnthony Koo 		/**
2111a595f28SAnthony Koo 		 * Unused.
2121a595f28SAnthony Koo 		 * TODO: Remove.
2131a595f28SAnthony Koo 		 */
2148b3f6b98SAnthony Koo 		uint32_t log_line_nums : 1;
21584034ad4SAnthony Koo 	} bitfields;
21684034ad4SAnthony Koo 
2171a595f28SAnthony Koo 	/**
2181a595f28SAnthony Koo 	 * Union for debug flags.
2191a595f28SAnthony Koo 	 */
220447f3d0fSAnthony Koo 	uint32_t u32All;
22184034ad4SAnthony Koo };
22284034ad4SAnthony Koo 
2231a595f28SAnthony Koo /**
2241a595f28SAnthony Koo  * DMUB feature capabilities.
2251a595f28SAnthony Koo  * After DMUB init, driver will query FW capabilities prior to enabling certain features.
2261a595f28SAnthony Koo  */
22734ba432cSAnthony Koo struct dmub_feature_caps {
2281a595f28SAnthony Koo 	/**
2291a595f28SAnthony Koo 	 * Max PSR version supported by FW.
2301a595f28SAnthony Koo 	 */
23134ba432cSAnthony Koo 	uint8_t psr;
23234ba432cSAnthony Koo 	uint8_t reserved[7];
23334ba432cSAnthony Koo };
23434ba432cSAnthony Koo 
23584034ad4SAnthony Koo #if defined(__cplusplus)
23684034ad4SAnthony Koo }
23784034ad4SAnthony Koo #endif
23884034ad4SAnthony Koo 
23984034ad4SAnthony Koo //==============================================================================
24084034ad4SAnthony Koo //</DMUB_TYPES>=================================================================
24184034ad4SAnthony Koo //==============================================================================
24284034ad4SAnthony Koo //< DMUB_META>==================================================================
24384034ad4SAnthony Koo //==============================================================================
24484034ad4SAnthony Koo #pragma pack(push, 1)
24584034ad4SAnthony Koo 
24684034ad4SAnthony Koo /* Magic value for identifying dmub_fw_meta_info */
24784034ad4SAnthony Koo #define DMUB_FW_META_MAGIC 0x444D5542
24884034ad4SAnthony Koo 
24984034ad4SAnthony Koo /* Offset from the end of the file to the dmub_fw_meta_info */
25084034ad4SAnthony Koo #define DMUB_FW_META_OFFSET 0x24
25184034ad4SAnthony Koo 
25284034ad4SAnthony Koo /**
25384034ad4SAnthony Koo  * struct dmub_fw_meta_info - metadata associated with fw binary
25484034ad4SAnthony Koo  *
25584034ad4SAnthony Koo  * NOTE: This should be considered a stable API. Fields should
25684034ad4SAnthony Koo  *       not be repurposed or reordered. New fields should be
25784034ad4SAnthony Koo  *       added instead to extend the structure.
25884034ad4SAnthony Koo  *
25984034ad4SAnthony Koo  * @magic_value: magic value identifying DMUB firmware meta info
26084034ad4SAnthony Koo  * @fw_region_size: size of the firmware state region
26184034ad4SAnthony Koo  * @trace_buffer_size: size of the tracebuffer region
26284034ad4SAnthony Koo  * @fw_version: the firmware version information
263b2265774SAnthony Koo  * @dal_fw: 1 if the firmware is DAL
26484034ad4SAnthony Koo  */
26584034ad4SAnthony Koo struct dmub_fw_meta_info {
266592a6318SAnthony Koo 	uint32_t magic_value; /**< magic value identifying DMUB firmware meta info */
267592a6318SAnthony Koo 	uint32_t fw_region_size; /**< size of the firmware state region */
268592a6318SAnthony Koo 	uint32_t trace_buffer_size; /**< size of the tracebuffer region */
269592a6318SAnthony Koo 	uint32_t fw_version; /**< the firmware version information */
270592a6318SAnthony Koo 	uint8_t dal_fw; /**< 1 if the firmware is DAL */
271592a6318SAnthony Koo 	uint8_t reserved[3]; /**< padding bits */
27284034ad4SAnthony Koo };
27384034ad4SAnthony Koo 
274592a6318SAnthony Koo /**
275592a6318SAnthony Koo  * union dmub_fw_meta - ensures that dmub_fw_meta_info remains 64 bytes
276592a6318SAnthony Koo  */
27784034ad4SAnthony Koo union dmub_fw_meta {
278592a6318SAnthony Koo 	struct dmub_fw_meta_info info; /**< metadata info */
279592a6318SAnthony Koo 	uint8_t reserved[64]; /**< padding bits */
28084034ad4SAnthony Koo };
28184034ad4SAnthony Koo 
28284034ad4SAnthony Koo #pragma pack(pop)
283788408b7SAnthony Koo 
28484034ad4SAnthony Koo //==============================================================================
2856b66208fSYongqiang Sun //< DMUB Trace Buffer>================================================================
2866b66208fSYongqiang Sun //==============================================================================
287592a6318SAnthony Koo /**
288592a6318SAnthony Koo  * dmub_trace_code_t - firmware trace code, 32-bits
289592a6318SAnthony Koo  */
2906b66208fSYongqiang Sun typedef uint32_t dmub_trace_code_t;
2916b66208fSYongqiang Sun 
292592a6318SAnthony Koo /**
293592a6318SAnthony Koo  * struct dmcub_trace_buf_entry - Firmware trace entry
294592a6318SAnthony Koo  */
2956b66208fSYongqiang Sun struct dmcub_trace_buf_entry {
296592a6318SAnthony Koo 	dmub_trace_code_t trace_code; /**< trace code for the event */
297592a6318SAnthony Koo 	uint32_t tick_count; /**< the tick count at time of trace */
298592a6318SAnthony Koo 	uint32_t param0; /**< trace defined parameter 0 */
299592a6318SAnthony Koo 	uint32_t param1; /**< trace defined parameter 1 */
3006b66208fSYongqiang Sun };
3016b66208fSYongqiang Sun 
3026b66208fSYongqiang Sun //==============================================================================
303788408b7SAnthony Koo //< DMUB_STATUS>================================================================
304788408b7SAnthony Koo //==============================================================================
305788408b7SAnthony Koo 
306788408b7SAnthony Koo /**
307788408b7SAnthony Koo  * DMCUB scratch registers can be used to determine firmware status.
308788408b7SAnthony Koo  * Current scratch register usage is as follows:
309788408b7SAnthony Koo  *
310492dd8a8SAnthony Koo  * SCRATCH0: FW Boot Status register
311021eaef8SAnthony Koo  * SCRATCH5: LVTMA Status Register
312492dd8a8SAnthony Koo  * SCRATCH15: FW Boot Options register
313788408b7SAnthony Koo  */
314788408b7SAnthony Koo 
315592a6318SAnthony Koo /**
316592a6318SAnthony Koo  * union dmub_fw_boot_status - Status bit definitions for SCRATCH0.
317592a6318SAnthony Koo  */
318492dd8a8SAnthony Koo union dmub_fw_boot_status {
319492dd8a8SAnthony Koo 	struct {
320592a6318SAnthony Koo 		uint32_t dal_fw : 1; /**< 1 if DAL FW */
321592a6318SAnthony Koo 		uint32_t mailbox_rdy : 1; /**< 1 if mailbox ready */
322592a6318SAnthony Koo 		uint32_t optimized_init_done : 1; /**< 1 if optimized init done */
323592a6318SAnthony Koo 		uint32_t restore_required : 1; /**< 1 if driver should call restore */
32401934c30SAnthony Koo 		uint32_t defer_load : 1; /**< 1 if VBIOS data is deferred programmed */
32501934c30SAnthony Koo 		uint32_t reserved : 1;
32601934c30SAnthony Koo 		uint32_t detection_required: 1; /**<  if detection need to be triggered by driver */
32701934c30SAnthony Koo 
328592a6318SAnthony Koo 	} bits; /**< status bits */
329592a6318SAnthony Koo 	uint32_t all; /**< 32-bit access to status bits */
330492dd8a8SAnthony Koo };
331492dd8a8SAnthony Koo 
332592a6318SAnthony Koo /**
333592a6318SAnthony Koo  * enum dmub_fw_boot_status_bit - Enum bit definitions for SCRATCH0.
334592a6318SAnthony Koo  */
335492dd8a8SAnthony Koo enum dmub_fw_boot_status_bit {
336592a6318SAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_DAL_FIRMWARE = (1 << 0), /**< 1 if DAL FW */
337592a6318SAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_MAILBOX_READY = (1 << 1), /**< 1 if mailbox ready */
338592a6318SAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if init done */
339592a6318SAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_RESTORE_REQUIRED = (1 << 3), /**< 1 if driver should call restore */
3401e0958bbSAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_DEFERRED_LOADED = (1 << 4), /**< 1 if VBIOS data is deferred programmed */
34101934c30SAnthony Koo 	DMUB_FW_BOOT_STATUS_BIT_DETECTION_REQUIRED = (1 << 6), /**< 1 if detection need to be triggered by driver*/
342492dd8a8SAnthony Koo };
343492dd8a8SAnthony Koo 
344021eaef8SAnthony Koo /* Register bit definition for SCRATCH5 */
345021eaef8SAnthony Koo union dmub_lvtma_status {
346021eaef8SAnthony Koo 	struct {
347021eaef8SAnthony Koo 		uint32_t psp_ok : 1;
348021eaef8SAnthony Koo 		uint32_t edp_on : 1;
349021eaef8SAnthony Koo 		uint32_t reserved : 30;
350021eaef8SAnthony Koo 	} bits;
351021eaef8SAnthony Koo 	uint32_t all;
352021eaef8SAnthony Koo };
353021eaef8SAnthony Koo 
354021eaef8SAnthony Koo enum dmub_lvtma_status_bit {
355021eaef8SAnthony Koo 	DMUB_LVTMA_STATUS_BIT_PSP_OK = (1 << 0),
356021eaef8SAnthony Koo 	DMUB_LVTMA_STATUS_BIT_EDP_ON = (1 << 1),
357021eaef8SAnthony Koo };
358021eaef8SAnthony Koo 
359592a6318SAnthony Koo /**
3601e0958bbSAnthony Koo  * union dmub_fw_boot_options - Boot option definitions for SCRATCH14
361592a6318SAnthony Koo  */
362492dd8a8SAnthony Koo union dmub_fw_boot_options {
363492dd8a8SAnthony Koo 	struct {
364592a6318SAnthony Koo 		uint32_t pemu_env : 1; /**< 1 if PEMU */
365592a6318SAnthony Koo 		uint32_t fpga_env : 1; /**< 1 if FPGA */
366592a6318SAnthony Koo 		uint32_t optimized_init : 1; /**< 1 if optimized init */
367592a6318SAnthony Koo 		uint32_t skip_phy_access : 1; /**< 1 if PHY access should be skipped */
368592a6318SAnthony Koo 		uint32_t disable_clk_gate: 1; /**< 1 if clock gating should be disabled */
369592a6318SAnthony Koo 		uint32_t skip_phy_init_panel_sequence: 1; /**< 1 to skip panel init seq */
370b04cb192SNicholas Kazlauskas 		uint32_t z10_disable: 1; /**< 1 to disable z10 */
371b0ce6272SMeenakshikumar Somasundaram 		uint32_t enable_dpia: 1; /**< 1 if DPIA should be enabled */
3721e0958bbSAnthony Koo 		uint32_t invalid_vbios_data: 1; /**< 1 if VBIOS data table is invalid */
373*3137f792SHansen 		uint32_t dpia_supported: 1; /**< 1 if DPIA is supported on this platform */
374*3137f792SHansen 		uint32_t sel_mux_phy_c_d_phy_f_g: 1; /**< 1 if PHYF/PHYG should be enabled */
375*3137f792SHansen 		/**< 1 if all root clock gating is enabled and low power memory is enabled*/
376*3137f792SHansen 		uint32_t power_optimization: 1;
377b129c94eSAnthony Koo 		uint32_t diag_env: 1; /* 1 if diagnostic environment */
378b129c94eSAnthony Koo 
379b129c94eSAnthony Koo 		uint32_t reserved : 19; /**< reserved */
380592a6318SAnthony Koo 	} bits; /**< boot bits */
381592a6318SAnthony Koo 	uint32_t all; /**< 32-bit access to bits */
382492dd8a8SAnthony Koo };
383492dd8a8SAnthony Koo 
384492dd8a8SAnthony Koo enum dmub_fw_boot_options_bit {
385592a6318SAnthony Koo 	DMUB_FW_BOOT_OPTION_BIT_PEMU_ENV = (1 << 0), /**< 1 if PEMU */
386592a6318SAnthony Koo 	DMUB_FW_BOOT_OPTION_BIT_FPGA_ENV = (1 << 1), /**< 1 if FPGA */
387592a6318SAnthony Koo 	DMUB_FW_BOOT_OPTION_BIT_OPTIMIZED_INIT_DONE = (1 << 2), /**< 1 if optimized init done */
388492dd8a8SAnthony Koo };
389492dd8a8SAnthony Koo 
390788408b7SAnthony Koo //==============================================================================
391788408b7SAnthony Koo //</DMUB_STATUS>================================================================
39284034ad4SAnthony Koo //==============================================================================
39384034ad4SAnthony Koo //< DMUB_VBIOS>=================================================================
39484034ad4SAnthony Koo //==============================================================================
39584034ad4SAnthony Koo 
39684034ad4SAnthony Koo /*
397592a6318SAnthony Koo  * enum dmub_cmd_vbios_type - VBIOS commands.
398592a6318SAnthony Koo  *
39984034ad4SAnthony Koo  * Command IDs should be treated as stable ABI.
40084034ad4SAnthony Koo  * Do not reuse or modify IDs.
40184034ad4SAnthony Koo  */
40284034ad4SAnthony Koo enum dmub_cmd_vbios_type {
403592a6318SAnthony Koo 	/**
404592a6318SAnthony Koo 	 * Configures the DIG encoder.
405592a6318SAnthony Koo 	 */
40684034ad4SAnthony Koo 	DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL = 0,
407592a6318SAnthony Koo 	/**
408592a6318SAnthony Koo 	 * Controls the PHY.
409592a6318SAnthony Koo 	 */
41084034ad4SAnthony Koo 	DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL = 1,
411592a6318SAnthony Koo 	/**
412592a6318SAnthony Koo 	 * Sets the pixel clock/symbol clock.
413592a6318SAnthony Koo 	 */
41484034ad4SAnthony Koo 	DMUB_CMD__VBIOS_SET_PIXEL_CLOCK = 2,
415592a6318SAnthony Koo 	/**
416592a6318SAnthony Koo 	 * Enables or disables power gating.
417592a6318SAnthony Koo 	 */
41884034ad4SAnthony Koo 	DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING = 3,
4192ac685bfSAnthony Koo 	DMUB_CMD__VBIOS_LVTMA_CONTROL = 15,
42084034ad4SAnthony Koo };
42184034ad4SAnthony Koo 
42284034ad4SAnthony Koo //==============================================================================
42384034ad4SAnthony Koo //</DMUB_VBIOS>=================================================================
42484034ad4SAnthony Koo //==============================================================================
42584034ad4SAnthony Koo //< DMUB_GPINT>=================================================================
42684034ad4SAnthony Koo //==============================================================================
42784034ad4SAnthony Koo 
42884034ad4SAnthony Koo /**
42984034ad4SAnthony Koo  * The shifts and masks below may alternatively be used to format and read
43084034ad4SAnthony Koo  * the command register bits.
43184034ad4SAnthony Koo  */
43284034ad4SAnthony Koo 
43384034ad4SAnthony Koo #define DMUB_GPINT_DATA_PARAM_MASK 0xFFFF
43484034ad4SAnthony Koo #define DMUB_GPINT_DATA_PARAM_SHIFT 0
43584034ad4SAnthony Koo 
43684034ad4SAnthony Koo #define DMUB_GPINT_DATA_COMMAND_CODE_MASK 0xFFF
43784034ad4SAnthony Koo #define DMUB_GPINT_DATA_COMMAND_CODE_SHIFT 16
43884034ad4SAnthony Koo 
43984034ad4SAnthony Koo #define DMUB_GPINT_DATA_STATUS_MASK 0xF
44084034ad4SAnthony Koo #define DMUB_GPINT_DATA_STATUS_SHIFT 28
44184034ad4SAnthony Koo 
44284034ad4SAnthony Koo /**
44384034ad4SAnthony Koo  * Command responses.
44484034ad4SAnthony Koo  */
44584034ad4SAnthony Koo 
446592a6318SAnthony Koo /**
447592a6318SAnthony Koo  * Return response for DMUB_GPINT__STOP_FW command.
448592a6318SAnthony Koo  */
44984034ad4SAnthony Koo #define DMUB_GPINT__STOP_FW_RESPONSE 0xDEADDEAD
45084034ad4SAnthony Koo 
45184034ad4SAnthony Koo /**
452592a6318SAnthony Koo  * union dmub_gpint_data_register - Format for sending a command via the GPINT.
45384034ad4SAnthony Koo  */
45484034ad4SAnthony Koo union dmub_gpint_data_register {
45584034ad4SAnthony Koo 	struct {
456592a6318SAnthony Koo 		uint32_t param : 16; /**< 16-bit parameter */
457592a6318SAnthony Koo 		uint32_t command_code : 12; /**< GPINT command */
458592a6318SAnthony Koo 		uint32_t status : 4; /**< Command status bit */
459592a6318SAnthony Koo 	} bits; /**< GPINT bit access */
460592a6318SAnthony Koo 	uint32_t all; /**< GPINT  32-bit access */
46184034ad4SAnthony Koo };
46284034ad4SAnthony Koo 
46384034ad4SAnthony Koo /*
464592a6318SAnthony Koo  * enum dmub_gpint_command - GPINT command to DMCUB FW
465592a6318SAnthony Koo  *
46684034ad4SAnthony Koo  * Command IDs should be treated as stable ABI.
46784034ad4SAnthony Koo  * Do not reuse or modify IDs.
46884034ad4SAnthony Koo  */
46984034ad4SAnthony Koo enum dmub_gpint_command {
470592a6318SAnthony Koo 	/**
471592a6318SAnthony Koo 	 * Invalid command, ignored.
472592a6318SAnthony Koo 	 */
47384034ad4SAnthony Koo 	DMUB_GPINT__INVALID_COMMAND = 0,
474592a6318SAnthony Koo 	/**
475592a6318SAnthony Koo 	 * DESC: Queries the firmware version.
476592a6318SAnthony Koo 	 * RETURN: Firmware version.
477592a6318SAnthony Koo 	 */
47884034ad4SAnthony Koo 	DMUB_GPINT__GET_FW_VERSION = 1,
479592a6318SAnthony Koo 	/**
480592a6318SAnthony Koo 	 * DESC: Halts the firmware.
481592a6318SAnthony Koo 	 * RETURN: DMUB_GPINT__STOP_FW_RESPONSE (0xDEADDEAD) when halted
482592a6318SAnthony Koo 	 */
48384034ad4SAnthony Koo 	DMUB_GPINT__STOP_FW = 2,
4841a595f28SAnthony Koo 	/**
4851a595f28SAnthony Koo 	 * DESC: Get PSR state from FW.
4861a595f28SAnthony Koo 	 * RETURN: PSR state enum. This enum may need to be converted to the legacy PSR state value.
4871a595f28SAnthony Koo 	 */
48884034ad4SAnthony Koo 	DMUB_GPINT__GET_PSR_STATE = 7,
48980eba958SAnthony Koo 	/**
49080eba958SAnthony Koo 	 * DESC: Notifies DMCUB of the currently active streams.
49180eba958SAnthony Koo 	 * ARGS: Stream mask, 1 bit per active stream index.
49280eba958SAnthony Koo 	 */
49380eba958SAnthony Koo 	DMUB_GPINT__IDLE_OPT_NOTIFY_STREAM_MASK = 8,
4941a595f28SAnthony Koo 	/**
4951a595f28SAnthony Koo 	 * DESC: Start PSR residency counter. Stop PSR resdiency counter and get value.
4961a595f28SAnthony Koo 	 * ARGS: We can measure residency from various points. The argument will specify the residency mode.
4971a595f28SAnthony Koo 	 *       By default, it is measured from after we powerdown the PHY, to just before we powerup the PHY.
4981a595f28SAnthony Koo 	 * RETURN: PSR residency in milli-percent.
4991a595f28SAnthony Koo 	 */
500672251b2SAnthony Koo 	DMUB_GPINT__PSR_RESIDENCY = 9,
50101934c30SAnthony Koo 
50201934c30SAnthony Koo 	/**
50301934c30SAnthony Koo 	 * DESC: Notifies DMCUB detection is done so detection required can be cleared.
50401934c30SAnthony Koo 	 */
50501934c30SAnthony Koo 	DMUB_GPINT__NOTIFY_DETECTION_DONE = 12,
50684034ad4SAnthony Koo };
50784034ad4SAnthony Koo 
5080b51e7e8SAnthony Koo /**
5090b51e7e8SAnthony Koo  * INBOX0 generic command definition
5100b51e7e8SAnthony Koo  */
5110b51e7e8SAnthony Koo union dmub_inbox0_cmd_common {
5120b51e7e8SAnthony Koo 	struct {
5130b51e7e8SAnthony Koo 		uint32_t command_code: 8; /**< INBOX0 command code */
5140b51e7e8SAnthony Koo 		uint32_t param: 24; /**< 24-bit parameter */
5150b51e7e8SAnthony Koo 	} bits;
5160b51e7e8SAnthony Koo 	uint32_t all;
5170b51e7e8SAnthony Koo };
5180b51e7e8SAnthony Koo 
5190b51e7e8SAnthony Koo /**
5200b51e7e8SAnthony Koo  * INBOX0 hw_lock command definition
5210b51e7e8SAnthony Koo  */
5220b51e7e8SAnthony Koo union dmub_inbox0_cmd_lock_hw {
5230b51e7e8SAnthony Koo 	struct {
5240b51e7e8SAnthony Koo 		uint32_t command_code: 8;
5250b51e7e8SAnthony Koo 
5260b51e7e8SAnthony Koo 		/* NOTE: Must be have enough bits to match: enum hw_lock_client */
5270b51e7e8SAnthony Koo 		uint32_t hw_lock_client: 1;
5280b51e7e8SAnthony Koo 
5290b51e7e8SAnthony Koo 		/* NOTE: Below fields must match with: struct dmub_hw_lock_inst_flags */
5300b51e7e8SAnthony Koo 		uint32_t otg_inst: 3;
5310b51e7e8SAnthony Koo 		uint32_t opp_inst: 3;
5320b51e7e8SAnthony Koo 		uint32_t dig_inst: 3;
5330b51e7e8SAnthony Koo 
5340b51e7e8SAnthony Koo 		/* NOTE: Below fields must match with: union dmub_hw_lock_flags */
5350b51e7e8SAnthony Koo 		uint32_t lock_pipe: 1;
5360b51e7e8SAnthony Koo 		uint32_t lock_cursor: 1;
5370b51e7e8SAnthony Koo 		uint32_t lock_dig: 1;
5380b51e7e8SAnthony Koo 		uint32_t triple_buffer_lock: 1;
5390b51e7e8SAnthony Koo 
5400b51e7e8SAnthony Koo 		uint32_t lock: 1;				/**< Lock */
5410b51e7e8SAnthony Koo 		uint32_t should_release: 1;		/**< Release */
5420b51e7e8SAnthony Koo 		uint32_t reserved: 8; 			/**< Reserved for extending more clients, HW, etc. */
5430b51e7e8SAnthony Koo 	} bits;
5440b51e7e8SAnthony Koo 	uint32_t all;
5450b51e7e8SAnthony Koo };
5460b51e7e8SAnthony Koo 
5470b51e7e8SAnthony Koo union dmub_inbox0_data_register {
5480b51e7e8SAnthony Koo 	union dmub_inbox0_cmd_common inbox0_cmd_common;
5490b51e7e8SAnthony Koo 	union dmub_inbox0_cmd_lock_hw inbox0_cmd_lock_hw;
5500b51e7e8SAnthony Koo };
5510b51e7e8SAnthony Koo 
5520b51e7e8SAnthony Koo enum dmub_inbox0_command {
5530b51e7e8SAnthony Koo 	/**
5540b51e7e8SAnthony Koo 	 * DESC: Invalid command, ignored.
5550b51e7e8SAnthony Koo 	 */
5560b51e7e8SAnthony Koo 	DMUB_INBOX0_CMD__INVALID_COMMAND = 0,
5570b51e7e8SAnthony Koo 	/**
5580b51e7e8SAnthony Koo 	 * DESC: Notification to acquire/release HW lock
5590b51e7e8SAnthony Koo 	 * ARGS:
5600b51e7e8SAnthony Koo 	 */
5610b51e7e8SAnthony Koo 	DMUB_INBOX0_CMD__HW_LOCK = 1,
5620b51e7e8SAnthony Koo };
56384034ad4SAnthony Koo //==============================================================================
56484034ad4SAnthony Koo //</DMUB_GPINT>=================================================================
56584034ad4SAnthony Koo //==============================================================================
56684034ad4SAnthony Koo //< DMUB_CMD>===================================================================
56784034ad4SAnthony Koo //==============================================================================
56884034ad4SAnthony Koo 
569592a6318SAnthony Koo /**
570592a6318SAnthony Koo  * Size in bytes of each DMUB command.
571592a6318SAnthony Koo  */
5727c008829SNicholas Kazlauskas #define DMUB_RB_CMD_SIZE 64
573592a6318SAnthony Koo 
574592a6318SAnthony Koo /**
575592a6318SAnthony Koo  * Maximum number of items in the DMUB ringbuffer.
576592a6318SAnthony Koo  */
5777c008829SNicholas Kazlauskas #define DMUB_RB_MAX_ENTRY 128
578592a6318SAnthony Koo 
579592a6318SAnthony Koo /**
580592a6318SAnthony Koo  * Ringbuffer size in bytes.
581592a6318SAnthony Koo  */
5827c008829SNicholas Kazlauskas #define DMUB_RB_SIZE (DMUB_RB_CMD_SIZE * DMUB_RB_MAX_ENTRY)
583592a6318SAnthony Koo 
584592a6318SAnthony Koo /**
585592a6318SAnthony Koo  * REG_SET mask for reg offload.
586592a6318SAnthony Koo  */
5877c008829SNicholas Kazlauskas #define REG_SET_MASK 0xFFFF
5887c008829SNicholas Kazlauskas 
589d4bbcecbSNicholas Kazlauskas /*
590592a6318SAnthony Koo  * enum dmub_cmd_type - DMUB inbox command.
591592a6318SAnthony Koo  *
592d4bbcecbSNicholas Kazlauskas  * Command IDs should be treated as stable ABI.
593d4bbcecbSNicholas Kazlauskas  * Do not reuse or modify IDs.
594d4bbcecbSNicholas Kazlauskas  */
595d4bbcecbSNicholas Kazlauskas enum dmub_cmd_type {
596592a6318SAnthony Koo 	/**
597592a6318SAnthony Koo 	 * Invalid command.
598592a6318SAnthony Koo 	 */
599d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__NULL = 0,
600592a6318SAnthony Koo 	/**
601592a6318SAnthony Koo 	 * Read modify write register sequence offload.
602592a6318SAnthony Koo 	 */
603d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE = 1,
604592a6318SAnthony Koo 	/**
605592a6318SAnthony Koo 	 * Field update register sequence offload.
606592a6318SAnthony Koo 	 */
607d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ = 2,
608592a6318SAnthony Koo 	/**
609592a6318SAnthony Koo 	 * Burst write sequence offload.
610592a6318SAnthony Koo 	 */
611d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__REG_SEQ_BURST_WRITE = 3,
612592a6318SAnthony Koo 	/**
613592a6318SAnthony Koo 	 * Reg wait sequence offload.
614592a6318SAnthony Koo 	 */
615d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__REG_REG_WAIT = 4,
616592a6318SAnthony Koo 	/**
617592a6318SAnthony Koo 	 * Workaround to avoid HUBP underflow during NV12 playback.
618592a6318SAnthony Koo 	 */
619bae9c49bSYongqiang Sun 	DMUB_CMD__PLAT_54186_WA = 5,
6201a595f28SAnthony Koo 	/**
6211a595f28SAnthony Koo 	 * Command type used to query FW feature caps.
6221a595f28SAnthony Koo 	 */
62334ba432cSAnthony Koo 	DMUB_CMD__QUERY_FEATURE_CAPS = 6,
6241a595f28SAnthony Koo 	/**
6251a595f28SAnthony Koo 	 * Command type used for all PSR commands.
6261a595f28SAnthony Koo 	 */
627d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__PSR = 64,
628592a6318SAnthony Koo 	/**
629592a6318SAnthony Koo 	 * Command type used for all MALL commands.
630592a6318SAnthony Koo 	 */
63152f2e83eSBhawanpreet Lakha 	DMUB_CMD__MALL = 65,
6321a595f28SAnthony Koo 	/**
6331a595f28SAnthony Koo 	 * Command type used for all ABM commands.
6341a595f28SAnthony Koo 	 */
635e6ea8c34SWyatt Wood 	DMUB_CMD__ABM = 66,
6361a595f28SAnthony Koo 	/**
6371a595f28SAnthony Koo 	 * Command type used for HW locking in FW.
6381a595f28SAnthony Koo 	 */
639788408b7SAnthony Koo 	DMUB_CMD__HW_LOCK = 69,
6401a595f28SAnthony Koo 	/**
6411a595f28SAnthony Koo 	 * Command type used to access DP AUX.
6421a595f28SAnthony Koo 	 */
643d9beecfcSAnthony Koo 	DMUB_CMD__DP_AUX_ACCESS = 70,
6441a595f28SAnthony Koo 	/**
6451a595f28SAnthony Koo 	 * Command type used for OUTBOX1 notification enable
6461a595f28SAnthony Koo 	 */
647d9beecfcSAnthony Koo 	DMUB_CMD__OUTBOX1_ENABLE = 71,
648b04cb192SNicholas Kazlauskas 	/**
649b04cb192SNicholas Kazlauskas 	 * Command type used for all idle optimization commands.
650b04cb192SNicholas Kazlauskas 	 */
651b04cb192SNicholas Kazlauskas 	DMUB_CMD__IDLE_OPT = 72,
652b04cb192SNicholas Kazlauskas 	/**
653b04cb192SNicholas Kazlauskas 	 * Command type used for all clock manager commands.
654b04cb192SNicholas Kazlauskas 	 */
655b04cb192SNicholas Kazlauskas 	DMUB_CMD__CLK_MGR = 73,
656b04cb192SNicholas Kazlauskas 	/**
657b04cb192SNicholas Kazlauskas 	 * Command type used for all panel control commands.
658b04cb192SNicholas Kazlauskas 	 */
659b04cb192SNicholas Kazlauskas 	DMUB_CMD__PANEL_CNTL = 74,
660592a6318SAnthony Koo 	/**
66176724b76SJimmy Kizito 	 * Command type used for interfacing with DPIA.
66276724b76SJimmy Kizito 	 */
66376724b76SJimmy Kizito 	DMUB_CMD__DPIA = 77,
66476724b76SJimmy Kizito 	/**
665021eaef8SAnthony Koo 	 * Command type used for EDID CEA parsing
666021eaef8SAnthony Koo 	 */
667021eaef8SAnthony Koo 	DMUB_CMD__EDID_CEA = 79,
668021eaef8SAnthony Koo 	/**
669592a6318SAnthony Koo 	 * Command type used for all VBIOS interface commands.
670592a6318SAnthony Koo 	 */
671d4bbcecbSNicholas Kazlauskas 	DMUB_CMD__VBIOS = 128,
6727c008829SNicholas Kazlauskas };
6737c008829SNicholas Kazlauskas 
674592a6318SAnthony Koo /**
675592a6318SAnthony Koo  * enum dmub_out_cmd_type - DMUB outbox commands.
676592a6318SAnthony Koo  */
6773b37260bSAnthony Koo enum dmub_out_cmd_type {
678592a6318SAnthony Koo 	/**
679592a6318SAnthony Koo 	 * Invalid outbox command, ignored.
680592a6318SAnthony Koo 	 */
6813b37260bSAnthony Koo 	DMUB_OUT_CMD__NULL = 0,
6821a595f28SAnthony Koo 	/**
6831a595f28SAnthony Koo 	 * Command type used for DP AUX Reply data notification
6841a595f28SAnthony Koo 	 */
685d9beecfcSAnthony Koo 	DMUB_OUT_CMD__DP_AUX_REPLY = 1,
686892b74a6SMeenakshikumar Somasundaram 	/**
687892b74a6SMeenakshikumar Somasundaram 	 * Command type used for DP HPD event notification
688892b74a6SMeenakshikumar Somasundaram 	 */
689892b74a6SMeenakshikumar Somasundaram 	DMUB_OUT_CMD__DP_HPD_NOTIFY = 2,
69071af9d46SMeenakshikumar Somasundaram 	/**
69171af9d46SMeenakshikumar Somasundaram 	 * Command type used for SET_CONFIG Reply notification
69271af9d46SMeenakshikumar Somasundaram 	 */
69371af9d46SMeenakshikumar Somasundaram 	DMUB_OUT_CMD__SET_CONFIG_REPLY = 3,
6943b37260bSAnthony Koo };
6953b37260bSAnthony Koo 
69676724b76SJimmy Kizito /* DMUB_CMD__DPIA command sub-types. */
69776724b76SJimmy Kizito enum dmub_cmd_dpia_type {
69876724b76SJimmy Kizito 	DMUB_CMD__DPIA_DIG1_DPIA_CONTROL = 0,
69971af9d46SMeenakshikumar Somasundaram 	DMUB_CMD__DPIA_SET_CONFIG_ACCESS = 1,
70076724b76SJimmy Kizito };
70176724b76SJimmy Kizito 
7027c008829SNicholas Kazlauskas #pragma pack(push, 1)
7037c008829SNicholas Kazlauskas 
704592a6318SAnthony Koo /**
705592a6318SAnthony Koo  * struct dmub_cmd_header - Common command header fields.
706592a6318SAnthony Koo  */
7077c008829SNicholas Kazlauskas struct dmub_cmd_header {
708592a6318SAnthony Koo 	unsigned int type : 8; /**< command type */
709592a6318SAnthony Koo 	unsigned int sub_type : 8; /**< command sub type */
710592a6318SAnthony Koo 	unsigned int ret_status : 1; /**< 1 if returned data, 0 otherwise */
7110b51e7e8SAnthony Koo 	unsigned int multi_cmd_pending : 1; /**< 1 if multiple commands chained together */
7120b51e7e8SAnthony Koo 	unsigned int reserved0 : 6; /**< reserved bits */
713592a6318SAnthony Koo 	unsigned int payload_bytes : 6;  /* payload excluding header - up to 60 bytes */
714592a6318SAnthony Koo 	unsigned int reserved1 : 2; /**< reserved bits */
7157c008829SNicholas Kazlauskas };
7167c008829SNicholas Kazlauskas 
7177c008829SNicholas Kazlauskas /*
718592a6318SAnthony Koo  * struct dmub_cmd_read_modify_write_sequence - Read modify write
7197c008829SNicholas Kazlauskas  *
7207c008829SNicholas Kazlauskas  * 60 payload bytes can hold up to 5 sets of read modify writes,
7217c008829SNicholas Kazlauskas  * each take 3 dwords.
7227c008829SNicholas Kazlauskas  *
7237c008829SNicholas Kazlauskas  * number of sequences = header.payload_bytes / sizeof(struct dmub_cmd_read_modify_write_sequence)
7247c008829SNicholas Kazlauskas  *
7257c008829SNicholas Kazlauskas  * modify_mask = 0xffff'ffff means all fields are going to be updated.  in this case
7267c008829SNicholas Kazlauskas  * command parser will skip the read and we can use modify_mask = 0xffff'ffff as reg write
7277c008829SNicholas Kazlauskas  */
7287c008829SNicholas Kazlauskas struct dmub_cmd_read_modify_write_sequence {
729592a6318SAnthony Koo 	uint32_t addr; /**< register address */
730592a6318SAnthony Koo 	uint32_t modify_mask; /**< modify mask */
731592a6318SAnthony Koo 	uint32_t modify_value; /**< modify value */
7327c008829SNicholas Kazlauskas };
7337c008829SNicholas Kazlauskas 
734592a6318SAnthony Koo /**
735592a6318SAnthony Koo  * Maximum number of ops in read modify write sequence.
736592a6318SAnthony Koo  */
7377c008829SNicholas Kazlauskas #define DMUB_READ_MODIFY_WRITE_SEQ__MAX 5
738592a6318SAnthony Koo 
739592a6318SAnthony Koo /**
740592a6318SAnthony Koo  * struct dmub_cmd_read_modify_write_sequence - Read modify write command.
741592a6318SAnthony Koo  */
7427c008829SNicholas Kazlauskas struct dmub_rb_cmd_read_modify_write {
743592a6318SAnthony Koo 	struct dmub_cmd_header header;  /**< command header */
744592a6318SAnthony Koo 	/**
745592a6318SAnthony Koo 	 * Read modify write sequence.
746592a6318SAnthony Koo 	 */
7477c008829SNicholas Kazlauskas 	struct dmub_cmd_read_modify_write_sequence seq[DMUB_READ_MODIFY_WRITE_SEQ__MAX];
7487c008829SNicholas Kazlauskas };
7497c008829SNicholas Kazlauskas 
7507c008829SNicholas Kazlauskas /*
7517c008829SNicholas Kazlauskas  * Update a register with specified masks and values sequeunce
7527c008829SNicholas Kazlauskas  *
7537c008829SNicholas Kazlauskas  * 60 payload bytes can hold address + up to 7 sets of mask/value combo, each take 2 dword
7547c008829SNicholas Kazlauskas  *
7557c008829SNicholas Kazlauskas  * number of field update sequence = (header.payload_bytes - sizeof(addr)) / sizeof(struct read_modify_write_sequence)
7567c008829SNicholas Kazlauskas  *
7577c008829SNicholas Kazlauskas  *
7587c008829SNicholas Kazlauskas  * USE CASE:
7597c008829SNicholas Kazlauskas  *   1. auto-increment register where additional read would update pointer and produce wrong result
7607c008829SNicholas Kazlauskas  *   2. toggle a bit without read in the middle
7617c008829SNicholas Kazlauskas  */
7627c008829SNicholas Kazlauskas 
7637c008829SNicholas Kazlauskas struct dmub_cmd_reg_field_update_sequence {
764592a6318SAnthony Koo 	uint32_t modify_mask; /**< 0xffff'ffff to skip initial read */
765592a6318SAnthony Koo 	uint32_t modify_value; /**< value to update with */
7667c008829SNicholas Kazlauskas };
7677c008829SNicholas Kazlauskas 
768592a6318SAnthony Koo /**
769592a6318SAnthony Koo  * Maximum number of ops in field update sequence.
770592a6318SAnthony Koo  */
7717c008829SNicholas Kazlauskas #define DMUB_REG_FIELD_UPDATE_SEQ__MAX 7
772592a6318SAnthony Koo 
773592a6318SAnthony Koo /**
774592a6318SAnthony Koo  * struct dmub_rb_cmd_reg_field_update_sequence - Field update command.
775592a6318SAnthony Koo  */
7767c008829SNicholas Kazlauskas struct dmub_rb_cmd_reg_field_update_sequence {
777592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< command header */
778592a6318SAnthony Koo 	uint32_t addr; /**< register address */
779592a6318SAnthony Koo 	/**
780592a6318SAnthony Koo 	 * Field update sequence.
781592a6318SAnthony Koo 	 */
7827c008829SNicholas Kazlauskas 	struct dmub_cmd_reg_field_update_sequence seq[DMUB_REG_FIELD_UPDATE_SEQ__MAX];
7837c008829SNicholas Kazlauskas };
7847c008829SNicholas Kazlauskas 
785592a6318SAnthony Koo 
786592a6318SAnthony Koo /**
787592a6318SAnthony Koo  * Maximum number of burst write values.
788592a6318SAnthony Koo  */
789592a6318SAnthony Koo #define DMUB_BURST_WRITE_VALUES__MAX  14
790592a6318SAnthony Koo 
7917c008829SNicholas Kazlauskas /*
792592a6318SAnthony Koo  * struct dmub_rb_cmd_burst_write - Burst write
7937c008829SNicholas Kazlauskas  *
7947c008829SNicholas Kazlauskas  * support use case such as writing out LUTs.
7957c008829SNicholas Kazlauskas  *
7967c008829SNicholas Kazlauskas  * 60 payload bytes can hold up to 14 values to write to given address
7977c008829SNicholas Kazlauskas  *
7987c008829SNicholas Kazlauskas  * number of payload = header.payload_bytes / sizeof(struct read_modify_write_sequence)
7997c008829SNicholas Kazlauskas  */
8007c008829SNicholas Kazlauskas struct dmub_rb_cmd_burst_write {
801592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< command header */
802592a6318SAnthony Koo 	uint32_t addr; /**< register start address */
803592a6318SAnthony Koo 	/**
804592a6318SAnthony Koo 	 * Burst write register values.
805592a6318SAnthony Koo 	 */
8067c008829SNicholas Kazlauskas 	uint32_t write_values[DMUB_BURST_WRITE_VALUES__MAX];
8077c008829SNicholas Kazlauskas };
8087c008829SNicholas Kazlauskas 
809592a6318SAnthony Koo /**
810592a6318SAnthony Koo  * struct dmub_rb_cmd_common - Common command header
811592a6318SAnthony Koo  */
8127c008829SNicholas Kazlauskas struct dmub_rb_cmd_common {
813592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< command header */
814592a6318SAnthony Koo 	/**
815592a6318SAnthony Koo 	 * Padding to RB_CMD_SIZE
816592a6318SAnthony Koo 	 */
8177c008829SNicholas Kazlauskas 	uint8_t cmd_buffer[DMUB_RB_CMD_SIZE - sizeof(struct dmub_cmd_header)];
8187c008829SNicholas Kazlauskas };
8197c008829SNicholas Kazlauskas 
820592a6318SAnthony Koo /**
821592a6318SAnthony Koo  * struct dmub_cmd_reg_wait_data - Register wait data
822592a6318SAnthony Koo  */
8237c008829SNicholas Kazlauskas struct dmub_cmd_reg_wait_data {
824592a6318SAnthony Koo 	uint32_t addr; /**< Register address */
825592a6318SAnthony Koo 	uint32_t mask; /**< Mask for register bits */
826592a6318SAnthony Koo 	uint32_t condition_field_value; /**< Value to wait for */
827592a6318SAnthony Koo 	uint32_t time_out_us; /**< Time out for reg wait in microseconds */
8287c008829SNicholas Kazlauskas };
8297c008829SNicholas Kazlauskas 
830592a6318SAnthony Koo /**
831592a6318SAnthony Koo  * struct dmub_rb_cmd_reg_wait - Register wait command
832592a6318SAnthony Koo  */
8337c008829SNicholas Kazlauskas struct dmub_rb_cmd_reg_wait {
834592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< Command header */
835592a6318SAnthony Koo 	struct dmub_cmd_reg_wait_data reg_wait; /**< Register wait data */
8367c008829SNicholas Kazlauskas };
8377c008829SNicholas Kazlauskas 
838592a6318SAnthony Koo /**
839592a6318SAnthony Koo  * struct dmub_cmd_PLAT_54186_wa - Underflow workaround
840592a6318SAnthony Koo  *
841592a6318SAnthony Koo  * Reprograms surface parameters to avoid underflow.
842592a6318SAnthony Koo  */
843bae9c49bSYongqiang Sun struct dmub_cmd_PLAT_54186_wa {
844592a6318SAnthony Koo 	uint32_t DCSURF_SURFACE_CONTROL; /**< reg value */
845592a6318SAnthony Koo 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH; /**< reg value */
846592a6318SAnthony Koo 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS; /**< reg value */
847592a6318SAnthony Koo 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C; /**< reg value */
848592a6318SAnthony Koo 	uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C; /**< reg value */
84922aa5614SYongqiang Sun 	struct {
850592a6318SAnthony Koo 		uint8_t hubp_inst : 4; /**< HUBP instance */
851592a6318SAnthony Koo 		uint8_t tmz_surface : 1; /**< TMZ enable or disable */
852592a6318SAnthony Koo 		uint8_t immediate :1; /**< Immediate flip */
853592a6318SAnthony Koo 		uint8_t vmid : 4; /**< VMID */
854592a6318SAnthony Koo 		uint8_t grph_stereo : 1; /**< 1 if stereo */
855592a6318SAnthony Koo 		uint32_t reserved : 21; /**< Reserved */
856592a6318SAnthony Koo 	} flip_params; /**< Pageflip parameters */
857592a6318SAnthony Koo 	uint32_t reserved[9]; /**< Reserved bits */
8588c019253SYongqiang Sun };
8598c019253SYongqiang Sun 
860592a6318SAnthony Koo /**
861592a6318SAnthony Koo  * struct dmub_rb_cmd_PLAT_54186_wa - Underflow workaround command
862592a6318SAnthony Koo  */
863bae9c49bSYongqiang Sun struct dmub_rb_cmd_PLAT_54186_wa {
864592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< Command header */
865592a6318SAnthony Koo 	struct dmub_cmd_PLAT_54186_wa flip; /**< Flip data */
8668c019253SYongqiang Sun };
8678c019253SYongqiang Sun 
868592a6318SAnthony Koo /**
869592a6318SAnthony Koo  * struct dmub_rb_cmd_mall - MALL command data.
870592a6318SAnthony Koo  */
87152f2e83eSBhawanpreet Lakha struct dmub_rb_cmd_mall {
872592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< Common command header */
873592a6318SAnthony Koo 	union dmub_addr cursor_copy_src; /**< Cursor copy address */
874592a6318SAnthony Koo 	union dmub_addr cursor_copy_dst; /**< Cursor copy destination */
875592a6318SAnthony Koo 	uint32_t tmr_delay; /**< Timer delay */
876592a6318SAnthony Koo 	uint32_t tmr_scale; /**< Timer scale */
877592a6318SAnthony Koo 	uint16_t cursor_width; /**< Cursor width in pixels */
878592a6318SAnthony Koo 	uint16_t cursor_pitch; /**< Cursor pitch in pixels */
879592a6318SAnthony Koo 	uint16_t cursor_height; /**< Cursor height in pixels */
880592a6318SAnthony Koo 	uint8_t cursor_bpp; /**< Cursor bits per pixel */
881592a6318SAnthony Koo 	uint8_t debug_bits; /**< Debug bits */
882ea7154d8SBhawanpreet Lakha 
883592a6318SAnthony Koo 	uint8_t reserved1; /**< Reserved bits */
884592a6318SAnthony Koo 	uint8_t reserved2; /**< Reserved bits */
88552f2e83eSBhawanpreet Lakha };
88652f2e83eSBhawanpreet Lakha 
887b04cb192SNicholas Kazlauskas /**
888b04cb192SNicholas Kazlauskas  * enum dmub_cmd_idle_opt_type - Idle optimization command type.
889b04cb192SNicholas Kazlauskas  */
890b04cb192SNicholas Kazlauskas enum dmub_cmd_idle_opt_type {
891b04cb192SNicholas Kazlauskas 	/**
892b04cb192SNicholas Kazlauskas 	 * DCN hardware restore.
893b04cb192SNicholas Kazlauskas 	 */
894b04cb192SNicholas Kazlauskas 	DMUB_CMD__IDLE_OPT_DCN_RESTORE = 0,
895f586fea8SJake Wang 
896f586fea8SJake Wang 	/**
897f586fea8SJake Wang 	 * DCN hardware save.
898f586fea8SJake Wang 	 */
899f586fea8SJake Wang 	DMUB_CMD__IDLE_OPT_DCN_SAVE_INIT = 1
900b04cb192SNicholas Kazlauskas };
901b04cb192SNicholas Kazlauskas 
902b04cb192SNicholas Kazlauskas /**
903b04cb192SNicholas Kazlauskas  * struct dmub_rb_cmd_idle_opt_dcn_restore - DCN restore command data.
904b04cb192SNicholas Kazlauskas  */
905b04cb192SNicholas Kazlauskas struct dmub_rb_cmd_idle_opt_dcn_restore {
906b04cb192SNicholas Kazlauskas 	struct dmub_cmd_header header; /**< header */
907b04cb192SNicholas Kazlauskas };
908b04cb192SNicholas Kazlauskas 
909b04cb192SNicholas Kazlauskas /**
910b04cb192SNicholas Kazlauskas  * struct dmub_clocks - Clock update notification.
911b04cb192SNicholas Kazlauskas  */
912b04cb192SNicholas Kazlauskas struct dmub_clocks {
913b04cb192SNicholas Kazlauskas 	uint32_t dispclk_khz; /**< dispclk kHz */
914b04cb192SNicholas Kazlauskas 	uint32_t dppclk_khz; /**< dppclk kHz */
915b04cb192SNicholas Kazlauskas 	uint32_t dcfclk_khz; /**< dcfclk kHz */
916b04cb192SNicholas Kazlauskas 	uint32_t dcfclk_deep_sleep_khz; /**< dcfclk deep sleep kHz */
917b04cb192SNicholas Kazlauskas };
918b04cb192SNicholas Kazlauskas 
919b04cb192SNicholas Kazlauskas /**
920b04cb192SNicholas Kazlauskas  * enum dmub_cmd_clk_mgr_type - Clock manager commands.
921b04cb192SNicholas Kazlauskas  */
922b04cb192SNicholas Kazlauskas enum dmub_cmd_clk_mgr_type {
923b04cb192SNicholas Kazlauskas 	/**
924b04cb192SNicholas Kazlauskas 	 * Notify DMCUB of clock update.
925b04cb192SNicholas Kazlauskas 	 */
926b04cb192SNicholas Kazlauskas 	DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS = 0,
927b04cb192SNicholas Kazlauskas };
928b04cb192SNicholas Kazlauskas 
929b04cb192SNicholas Kazlauskas /**
930b04cb192SNicholas Kazlauskas  * struct dmub_rb_cmd_clk_mgr_notify_clocks - Clock update notification.
931b04cb192SNicholas Kazlauskas  */
932b04cb192SNicholas Kazlauskas struct dmub_rb_cmd_clk_mgr_notify_clocks {
933b04cb192SNicholas Kazlauskas 	struct dmub_cmd_header header; /**< header */
934b04cb192SNicholas Kazlauskas 	struct dmub_clocks clocks; /**< clock data */
935b04cb192SNicholas Kazlauskas };
9368fe44c08SAlex Deucher 
937592a6318SAnthony Koo /**
938592a6318SAnthony Koo  * struct dmub_cmd_digx_encoder_control_data - Encoder control data.
939592a6318SAnthony Koo  */
9407c008829SNicholas Kazlauskas struct dmub_cmd_digx_encoder_control_data {
941592a6318SAnthony Koo 	union dig_encoder_control_parameters_v1_5 dig; /**< payload */
9427c008829SNicholas Kazlauskas };
9437c008829SNicholas Kazlauskas 
944592a6318SAnthony Koo /**
945592a6318SAnthony Koo  * struct dmub_rb_cmd_digx_encoder_control - Encoder control command.
946592a6318SAnthony Koo  */
9477c008829SNicholas Kazlauskas struct dmub_rb_cmd_digx_encoder_control {
948592a6318SAnthony Koo 	struct dmub_cmd_header header;  /**< header */
949592a6318SAnthony Koo 	struct dmub_cmd_digx_encoder_control_data encoder_control; /**< payload */
9507c008829SNicholas Kazlauskas };
9517c008829SNicholas Kazlauskas 
952592a6318SAnthony Koo /**
953592a6318SAnthony Koo  * struct dmub_cmd_set_pixel_clock_data - Set pixel clock data.
954592a6318SAnthony Koo  */
9557c008829SNicholas Kazlauskas struct dmub_cmd_set_pixel_clock_data {
956592a6318SAnthony Koo 	struct set_pixel_clock_parameter_v1_7 clk; /**< payload */
9577c008829SNicholas Kazlauskas };
9587c008829SNicholas Kazlauskas 
959592a6318SAnthony Koo /**
960592a6318SAnthony Koo  * struct dmub_cmd_set_pixel_clock_data - Set pixel clock command.
961592a6318SAnthony Koo  */
9627c008829SNicholas Kazlauskas struct dmub_rb_cmd_set_pixel_clock {
963592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< header */
964592a6318SAnthony Koo 	struct dmub_cmd_set_pixel_clock_data pixel_clock; /**< payload */
9657c008829SNicholas Kazlauskas };
9667c008829SNicholas Kazlauskas 
967592a6318SAnthony Koo /**
968592a6318SAnthony Koo  * struct dmub_cmd_enable_disp_power_gating_data - Display power gating.
969592a6318SAnthony Koo  */
9707c008829SNicholas Kazlauskas struct dmub_cmd_enable_disp_power_gating_data {
971592a6318SAnthony Koo 	struct enable_disp_power_gating_parameters_v2_1 pwr; /**< payload */
9727c008829SNicholas Kazlauskas };
9737c008829SNicholas Kazlauskas 
974592a6318SAnthony Koo /**
975592a6318SAnthony Koo  * struct dmub_rb_cmd_enable_disp_power_gating - Display power command.
976592a6318SAnthony Koo  */
9777c008829SNicholas Kazlauskas struct dmub_rb_cmd_enable_disp_power_gating {
978592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< header */
979592a6318SAnthony Koo 	struct dmub_cmd_enable_disp_power_gating_data power_gating;  /**< payload */
9807c008829SNicholas Kazlauskas };
9817c008829SNicholas Kazlauskas 
982592a6318SAnthony Koo /**
983592a6318SAnthony Koo  * struct dmub_dig_transmitter_control_data_v1_7 - Transmitter control.
984592a6318SAnthony Koo  */
985d448521eSAnthony Koo struct dmub_dig_transmitter_control_data_v1_7 {
986d448521eSAnthony Koo 	uint8_t phyid; /**< 0=UNIPHYA, 1=UNIPHYB, 2=UNIPHYC, 3=UNIPHYD, 4=UNIPHYE, 5=UNIPHYF */
987d448521eSAnthony Koo 	uint8_t action; /**< Defined as ATOM_TRANSMITER_ACTION_xxx */
988d448521eSAnthony Koo 	union {
989d448521eSAnthony Koo 		uint8_t digmode; /**< enum atom_encode_mode_def */
990d448521eSAnthony Koo 		uint8_t dplaneset; /**< DP voltage swing and pre-emphasis value, "DP_LANE_SET__xDB_y_zV" */
991d448521eSAnthony Koo 	} mode_laneset;
992d448521eSAnthony Koo 	uint8_t lanenum; /**< Number of lanes */
993d448521eSAnthony Koo 	union {
994d448521eSAnthony Koo 		uint32_t symclk_10khz; /**< Symbol Clock in 10Khz */
995d448521eSAnthony Koo 	} symclk_units;
996d448521eSAnthony Koo 	uint8_t hpdsel; /**< =1: HPD1, =2: HPD2, ..., =6: HPD6, =0: HPD is not assigned */
997d448521eSAnthony Koo 	uint8_t digfe_sel; /**< DIG front-end selection, bit0 means DIG0 FE is enabled */
998d448521eSAnthony Koo 	uint8_t connobj_id; /**< Connector Object Id defined in ObjectId.h */
9995a2730fcSFangzhi Zuo 	uint8_t HPO_instance; /**< HPO instance (0: inst0, 1: inst1) */
1000d448521eSAnthony Koo 	uint8_t reserved1; /**< For future use */
1001d448521eSAnthony Koo 	uint8_t reserved2[3]; /**< For future use */
1002d448521eSAnthony Koo 	uint32_t reserved3[11]; /**< For future use */
1003d448521eSAnthony Koo };
1004d448521eSAnthony Koo 
1005592a6318SAnthony Koo /**
1006592a6318SAnthony Koo  * union dmub_cmd_dig1_transmitter_control_data - Transmitter control data.
1007592a6318SAnthony Koo  */
1008d448521eSAnthony Koo union dmub_cmd_dig1_transmitter_control_data {
1009592a6318SAnthony Koo 	struct dig_transmitter_control_parameters_v1_6 dig; /**< payload */
1010592a6318SAnthony Koo 	struct dmub_dig_transmitter_control_data_v1_7 dig_v1_7;  /**< payload 1.7 */
10117c008829SNicholas Kazlauskas };
10127c008829SNicholas Kazlauskas 
1013592a6318SAnthony Koo /**
1014592a6318SAnthony Koo  * struct dmub_rb_cmd_dig1_transmitter_control - Transmitter control command.
1015592a6318SAnthony Koo  */
10167c008829SNicholas Kazlauskas struct dmub_rb_cmd_dig1_transmitter_control {
1017592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< header */
1018592a6318SAnthony Koo 	union dmub_cmd_dig1_transmitter_control_data transmitter_control; /**< payload */
10197c008829SNicholas Kazlauskas };
10207c008829SNicholas Kazlauskas 
1021592a6318SAnthony Koo /**
102276724b76SJimmy Kizito  * DPIA tunnel command parameters.
102376724b76SJimmy Kizito  */
102476724b76SJimmy Kizito struct dmub_cmd_dig_dpia_control_data {
102576724b76SJimmy Kizito 	uint8_t enc_id;         /** 0 = ENGINE_ID_DIGA, ... */
102676724b76SJimmy Kizito 	uint8_t action;         /** ATOM_TRANSMITER_ACTION_DISABLE/ENABLE/SETUP_VSEMPH */
102776724b76SJimmy Kizito 	union {
102876724b76SJimmy Kizito 		uint8_t digmode;    /** enum atom_encode_mode_def */
102976724b76SJimmy Kizito 		uint8_t dplaneset;  /** DP voltage swing and pre-emphasis value */
103076724b76SJimmy Kizito 	} mode_laneset;
103176724b76SJimmy Kizito 	uint8_t lanenum;        /** Lane number 1, 2, 4, 8 */
103276724b76SJimmy Kizito 	uint32_t symclk_10khz;  /** Symbol Clock in 10Khz */
103376724b76SJimmy Kizito 	uint8_t hpdsel;         /** =0: HPD is not assigned */
103476724b76SJimmy Kizito 	uint8_t digfe_sel;      /** DIG stream( front-end ) selection, bit0 - DIG0 FE */
103576724b76SJimmy Kizito 	uint8_t dpia_id;        /** Index of DPIA */
103676724b76SJimmy Kizito 	uint8_t fec_rdy : 1;
103776724b76SJimmy Kizito 	uint8_t reserved : 7;
103876724b76SJimmy Kizito 	uint32_t reserved1;
103976724b76SJimmy Kizito };
104076724b76SJimmy Kizito 
104176724b76SJimmy Kizito /**
104276724b76SJimmy Kizito  * DMUB command for DPIA tunnel control.
104376724b76SJimmy Kizito  */
104476724b76SJimmy Kizito struct dmub_rb_cmd_dig1_dpia_control {
104576724b76SJimmy Kizito 	struct dmub_cmd_header header;
104676724b76SJimmy Kizito 	struct dmub_cmd_dig_dpia_control_data dpia_control;
104776724b76SJimmy Kizito };
104876724b76SJimmy Kizito 
104976724b76SJimmy Kizito /**
105071af9d46SMeenakshikumar Somasundaram  * SET_CONFIG Command Payload
105171af9d46SMeenakshikumar Somasundaram  */
105271af9d46SMeenakshikumar Somasundaram struct set_config_cmd_payload {
105371af9d46SMeenakshikumar Somasundaram 	uint8_t msg_type; /* set config message type */
105471af9d46SMeenakshikumar Somasundaram 	uint8_t msg_data; /* set config message data */
105571af9d46SMeenakshikumar Somasundaram };
105671af9d46SMeenakshikumar Somasundaram 
105771af9d46SMeenakshikumar Somasundaram /**
105871af9d46SMeenakshikumar Somasundaram  * Data passed from driver to FW in a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command.
105971af9d46SMeenakshikumar Somasundaram  */
106071af9d46SMeenakshikumar Somasundaram struct dmub_cmd_set_config_control_data {
106171af9d46SMeenakshikumar Somasundaram 	struct set_config_cmd_payload cmd_pkt;
106271af9d46SMeenakshikumar Somasundaram 	uint8_t instance; /* DPIA instance */
106371af9d46SMeenakshikumar Somasundaram 	uint8_t immed_status; /* Immediate status returned in case of error */
106471af9d46SMeenakshikumar Somasundaram };
106571af9d46SMeenakshikumar Somasundaram 
106671af9d46SMeenakshikumar Somasundaram /**
106771af9d46SMeenakshikumar Somasundaram  * DMUB command structure for SET_CONFIG command.
106871af9d46SMeenakshikumar Somasundaram  */
106971af9d46SMeenakshikumar Somasundaram struct dmub_rb_cmd_set_config_access {
107071af9d46SMeenakshikumar Somasundaram 	struct dmub_cmd_header header; /* header */
107171af9d46SMeenakshikumar Somasundaram 	struct dmub_cmd_set_config_control_data set_config_control; /* set config data */
107271af9d46SMeenakshikumar Somasundaram };
107371af9d46SMeenakshikumar Somasundaram 
107471af9d46SMeenakshikumar Somasundaram /**
1075592a6318SAnthony Koo  * struct dmub_rb_cmd_dpphy_init - DPPHY init.
1076592a6318SAnthony Koo  */
10777c008829SNicholas Kazlauskas struct dmub_rb_cmd_dpphy_init {
1078592a6318SAnthony Koo 	struct dmub_cmd_header header; /**< header */
1079592a6318SAnthony Koo 	uint8_t reserved[60]; /**< reserved bits */
10807c008829SNicholas Kazlauskas };
10817c008829SNicholas Kazlauskas 
10821a595f28SAnthony Koo /**
10831a595f28SAnthony Koo  * enum dp_aux_request_action - DP AUX request command listing.
10841a595f28SAnthony Koo  *
10851a595f28SAnthony Koo  * 4 AUX request command bits are shifted to high nibble.
10861a595f28SAnthony Koo  */
1087d9beecfcSAnthony Koo enum dp_aux_request_action {
10881a595f28SAnthony Koo 	/** I2C-over-AUX write request */
1089d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_WRITE		= 0x00,
10901a595f28SAnthony Koo 	/** I2C-over-AUX read request */
1091d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_READ		= 0x10,
10921a595f28SAnthony Koo 	/** I2C-over-AUX write status request */
1093d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_STATUS_REQ	= 0x20,
10941a595f28SAnthony Koo 	/** I2C-over-AUX write request with MOT=1 */
1095d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_WRITE_MOT		= 0x40,
10961a595f28SAnthony Koo 	/** I2C-over-AUX read request with MOT=1 */
1097d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_READ_MOT		= 0x50,
10981a595f28SAnthony Koo 	/** I2C-over-AUX write status request with MOT=1 */
1099d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_I2C_STATUS_REQ_MOT	= 0x60,
11001a595f28SAnthony Koo 	/** Native AUX write request */
1101d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_DPCD_WRITE		= 0x80,
11021a595f28SAnthony Koo 	/** Native AUX read request */
1103d9beecfcSAnthony Koo 	DP_AUX_REQ_ACTION_DPCD_READ		= 0x90
1104d9beecfcSAnthony Koo };
1105d9beecfcSAnthony Koo 
11061a595f28SAnthony Koo /**
11071a595f28SAnthony Koo  * enum aux_return_code_type - DP AUX process return code listing.
11081a595f28SAnthony Koo  */
1109fd0f1d21SAnthony Koo enum aux_return_code_type {
11101a595f28SAnthony Koo 	/** AUX process succeeded */
1111fd0f1d21SAnthony Koo 	AUX_RET_SUCCESS = 0,
11121a595f28SAnthony Koo 	/** AUX process failed with unknown reason */
1113b6402afeSAnthony Koo 	AUX_RET_ERROR_UNKNOWN,
11141a595f28SAnthony Koo 	/** AUX process completed with invalid reply */
1115b6402afeSAnthony Koo 	AUX_RET_ERROR_INVALID_REPLY,
11161a595f28SAnthony Koo 	/** AUX process timed out */
1117fd0f1d21SAnthony Koo 	AUX_RET_ERROR_TIMEOUT,
11181a595f28SAnthony Koo 	/** HPD was low during AUX process */
1119b6402afeSAnthony Koo 	AUX_RET_ERROR_HPD_DISCON,
11201a595f28SAnthony Koo 	/** Failed to acquire AUX engine */
1121b6402afeSAnthony Koo 	AUX_RET_ERROR_ENGINE_ACQUIRE,
11221a595f28SAnthony Koo 	/** AUX request not supported */
1123fd0f1d21SAnthony Koo 	AUX_RET_ERROR_INVALID_OPERATION,
11241a595f28SAnthony Koo 	/** AUX process not available */
1125fd0f1d21SAnthony Koo 	AUX_RET_ERROR_PROTOCOL_ERROR,
1126fd0f1d21SAnthony Koo };
1127fd0f1d21SAnthony Koo 
11281a595f28SAnthony Koo /**
11291a595f28SAnthony Koo  * enum aux_channel_type - DP AUX channel type listing.
11301a595f28SAnthony Koo  */
1131b6402afeSAnthony Koo enum aux_channel_type {
11321a595f28SAnthony Koo 	/** AUX thru Legacy DP AUX */
1133b6402afeSAnthony Koo 	AUX_CHANNEL_LEGACY_DDC,
11341a595f28SAnthony Koo 	/** AUX thru DPIA DP tunneling */
1135b6402afeSAnthony Koo 	AUX_CHANNEL_DPIA
1136b6402afeSAnthony Koo };
1137b6402afeSAnthony Koo 
11381a595f28SAnthony Koo /**
11391a595f28SAnthony Koo  * struct aux_transaction_parameters - DP AUX request transaction data
11401a595f28SAnthony Koo  */
1141d9beecfcSAnthony Koo struct aux_transaction_parameters {
11421a595f28SAnthony Koo 	uint8_t is_i2c_over_aux; /**< 0=native AUX, 1=I2C-over-AUX */
11431a595f28SAnthony Koo 	uint8_t action; /**< enum dp_aux_request_action */
11441a595f28SAnthony Koo 	uint8_t length; /**< DP AUX request data length */
11451a595f28SAnthony Koo 	uint8_t reserved; /**< For future use */
11461a595f28SAnthony Koo 	uint32_t address; /**< DP AUX address */
11471a595f28SAnthony Koo 	uint8_t data[16]; /**< DP AUX write data */
1148d9beecfcSAnthony Koo };
1149d9beecfcSAnthony Koo 
11501a595f28SAnthony Koo /**
11511a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
11521a595f28SAnthony Koo  */
1153d9beecfcSAnthony Koo struct dmub_cmd_dp_aux_control_data {
11541a595f28SAnthony Koo 	uint8_t instance; /**< AUX instance or DPIA instance */
11551a595f28SAnthony Koo 	uint8_t manual_acq_rel_enable; /**< manual control for acquiring or releasing AUX channel */
11561a595f28SAnthony Koo 	uint8_t sw_crc_enabled; /**< Use software CRC for tunneling packet instead of hardware CRC */
11571a595f28SAnthony Koo 	uint8_t reserved0; /**< For future use */
11581a595f28SAnthony Koo 	uint16_t timeout; /**< timeout time in us */
11591a595f28SAnthony Koo 	uint16_t reserved1; /**< For future use */
11601a595f28SAnthony Koo 	enum aux_channel_type type; /**< enum aux_channel_type */
11611a595f28SAnthony Koo 	struct aux_transaction_parameters dpaux; /**< struct aux_transaction_parameters */
1162d9beecfcSAnthony Koo };
1163d9beecfcSAnthony Koo 
11641a595f28SAnthony Koo /**
11651a595f28SAnthony Koo  * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
11661a595f28SAnthony Koo  */
1167d9beecfcSAnthony Koo struct dmub_rb_cmd_dp_aux_access {
11681a595f28SAnthony Koo 	/**
11691a595f28SAnthony Koo 	 * Command header.
11701a595f28SAnthony Koo 	 */
1171d9beecfcSAnthony Koo 	struct dmub_cmd_header header;
11721a595f28SAnthony Koo 	/**
11731a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__DP_AUX_ACCESS command.
11741a595f28SAnthony Koo 	 */
1175d9beecfcSAnthony Koo 	struct dmub_cmd_dp_aux_control_data aux_control;
1176d9beecfcSAnthony Koo };
1177d9beecfcSAnthony Koo 
11781a595f28SAnthony Koo /**
11791a595f28SAnthony Koo  * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
11801a595f28SAnthony Koo  */
1181d9beecfcSAnthony Koo struct dmub_rb_cmd_outbox1_enable {
11821a595f28SAnthony Koo 	/**
11831a595f28SAnthony Koo 	 * Command header.
11841a595f28SAnthony Koo 	 */
1185d9beecfcSAnthony Koo 	struct dmub_cmd_header header;
11861a595f28SAnthony Koo 	/**
11871a595f28SAnthony Koo 	 *  enable: 0x0 -> disable outbox1 notification (default value)
11881a595f28SAnthony Koo 	 *			0x1 -> enable outbox1 notification
11891a595f28SAnthony Koo 	 */
1190d9beecfcSAnthony Koo 	uint32_t enable;
1191d9beecfcSAnthony Koo };
1192d9beecfcSAnthony Koo 
1193d9beecfcSAnthony Koo /* DP AUX Reply command - OutBox Cmd */
11941a595f28SAnthony Koo /**
11951a595f28SAnthony Koo  * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
11961a595f28SAnthony Koo  */
1197d9beecfcSAnthony Koo struct aux_reply_data {
11981a595f28SAnthony Koo 	/**
11991a595f28SAnthony Koo 	 * Aux cmd
12001a595f28SAnthony Koo 	 */
1201d9beecfcSAnthony Koo 	uint8_t command;
12021a595f28SAnthony Koo 	/**
12031a595f28SAnthony Koo 	 * Aux reply data length (max: 16 bytes)
12041a595f28SAnthony Koo 	 */
1205d9beecfcSAnthony Koo 	uint8_t length;
12061a595f28SAnthony Koo 	/**
12071a595f28SAnthony Koo 	 * Alignment only
12081a595f28SAnthony Koo 	 */
1209d9beecfcSAnthony Koo 	uint8_t pad[2];
12101a595f28SAnthony Koo 	/**
12111a595f28SAnthony Koo 	 * Aux reply data
12121a595f28SAnthony Koo 	 */
1213d9beecfcSAnthony Koo 	uint8_t data[16];
1214d9beecfcSAnthony Koo };
1215d9beecfcSAnthony Koo 
12161a595f28SAnthony Koo /**
12171a595f28SAnthony Koo  * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
12181a595f28SAnthony Koo  */
1219d9beecfcSAnthony Koo struct aux_reply_control_data {
12201a595f28SAnthony Koo 	/**
12211a595f28SAnthony Koo 	 * Reserved for future use
12221a595f28SAnthony Koo 	 */
1223d9beecfcSAnthony Koo 	uint32_t handle;
12241a595f28SAnthony Koo 	/**
12251a595f28SAnthony Koo 	 * Aux Instance
12261a595f28SAnthony Koo 	 */
1227b6402afeSAnthony Koo 	uint8_t instance;
12281a595f28SAnthony Koo 	/**
12291a595f28SAnthony Koo 	 * Aux transaction result: definition in enum aux_return_code_type
12301a595f28SAnthony Koo 	 */
1231d9beecfcSAnthony Koo 	uint8_t result;
12321a595f28SAnthony Koo 	/**
12331a595f28SAnthony Koo 	 * Alignment only
12341a595f28SAnthony Koo 	 */
1235d9beecfcSAnthony Koo 	uint16_t pad;
1236d9beecfcSAnthony Koo };
1237d9beecfcSAnthony Koo 
12381a595f28SAnthony Koo /**
12391a595f28SAnthony Koo  * Definition of a DMUB_OUT_CMD__DP_AUX_REPLY command.
12401a595f28SAnthony Koo  */
1241d9beecfcSAnthony Koo struct dmub_rb_cmd_dp_aux_reply {
12421a595f28SAnthony Koo 	/**
12431a595f28SAnthony Koo 	 * Command header.
12441a595f28SAnthony Koo 	 */
1245d9beecfcSAnthony Koo 	struct dmub_cmd_header header;
12461a595f28SAnthony Koo 	/**
12471a595f28SAnthony Koo 	 * Control Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
12481a595f28SAnthony Koo 	 */
1249d9beecfcSAnthony Koo 	struct aux_reply_control_data control;
12501a595f28SAnthony Koo 	/**
12511a595f28SAnthony Koo 	 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_AUX_REPLY command.
12521a595f28SAnthony Koo 	 */
1253d9beecfcSAnthony Koo 	struct aux_reply_data reply_data;
1254d9beecfcSAnthony Koo };
1255d9beecfcSAnthony Koo 
1256fd0f1d21SAnthony Koo /* DP HPD Notify command - OutBox Cmd */
12571a595f28SAnthony Koo /**
12581a595f28SAnthony Koo  * DP HPD Type
12591a595f28SAnthony Koo  */
1260fd0f1d21SAnthony Koo enum dp_hpd_type {
12611a595f28SAnthony Koo 	/**
12621a595f28SAnthony Koo 	 * Normal DP HPD
12631a595f28SAnthony Koo 	 */
1264fd0f1d21SAnthony Koo 	DP_HPD = 0,
12651a595f28SAnthony Koo 	/**
12661a595f28SAnthony Koo 	 * DP HPD short pulse
12671a595f28SAnthony Koo 	 */
1268fd0f1d21SAnthony Koo 	DP_IRQ
1269fd0f1d21SAnthony Koo };
1270fd0f1d21SAnthony Koo 
12711a595f28SAnthony Koo /**
12721a595f28SAnthony Koo  * DP HPD Status
12731a595f28SAnthony Koo  */
1274fd0f1d21SAnthony Koo enum dp_hpd_status {
12751a595f28SAnthony Koo 	/**
12761a595f28SAnthony Koo 	 * DP_HPD status low
12771a595f28SAnthony Koo 	 */
1278fd0f1d21SAnthony Koo 	DP_HPD_UNPLUG = 0,
12791a595f28SAnthony Koo 	/**
12801a595f28SAnthony Koo 	 * DP_HPD status high
12811a595f28SAnthony Koo 	 */
1282fd0f1d21SAnthony Koo 	DP_HPD_PLUG
1283fd0f1d21SAnthony Koo };
1284fd0f1d21SAnthony Koo 
12851a595f28SAnthony Koo /**
12861a595f28SAnthony Koo  * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
12871a595f28SAnthony Koo  */
1288d9beecfcSAnthony Koo struct dp_hpd_data {
12891a595f28SAnthony Koo 	/**
12901a595f28SAnthony Koo 	 * DP HPD instance
12911a595f28SAnthony Koo 	 */
1292b6402afeSAnthony Koo 	uint8_t instance;
12931a595f28SAnthony Koo 	/**
12941a595f28SAnthony Koo 	 * HPD type
12951a595f28SAnthony Koo 	 */
1296d9beecfcSAnthony Koo 	uint8_t hpd_type;
12971a595f28SAnthony Koo 	/**
12981a595f28SAnthony Koo 	 * HPD status: only for type: DP_HPD to indicate status
12991a595f28SAnthony Koo 	 */
1300d9beecfcSAnthony Koo 	uint8_t hpd_status;
13011a595f28SAnthony Koo 	/**
13021a595f28SAnthony Koo 	 * Alignment only
13031a595f28SAnthony Koo 	 */
1304d9beecfcSAnthony Koo 	uint8_t pad;
1305d9beecfcSAnthony Koo };
1306d9beecfcSAnthony Koo 
13071a595f28SAnthony Koo /**
13081a595f28SAnthony Koo  * Definition of a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
13091a595f28SAnthony Koo  */
1310d9beecfcSAnthony Koo struct dmub_rb_cmd_dp_hpd_notify {
13111a595f28SAnthony Koo 	/**
13121a595f28SAnthony Koo 	 * Command header.
13131a595f28SAnthony Koo 	 */
1314d9beecfcSAnthony Koo 	struct dmub_cmd_header header;
13151a595f28SAnthony Koo 	/**
13161a595f28SAnthony Koo 	 * Data passed to driver from FW in a DMUB_OUT_CMD__DP_HPD_NOTIFY command.
13171a595f28SAnthony Koo 	 */
1318d9beecfcSAnthony Koo 	struct dp_hpd_data hpd_data;
1319d9beecfcSAnthony Koo };
1320d9beecfcSAnthony Koo 
132171af9d46SMeenakshikumar Somasundaram /**
132271af9d46SMeenakshikumar Somasundaram  * Definition of a SET_CONFIG reply from DPOA.
132371af9d46SMeenakshikumar Somasundaram  */
132471af9d46SMeenakshikumar Somasundaram enum set_config_status {
132571af9d46SMeenakshikumar Somasundaram 	SET_CONFIG_PENDING = 0,
132671af9d46SMeenakshikumar Somasundaram 	SET_CONFIG_ACK_RECEIVED,
132771af9d46SMeenakshikumar Somasundaram 	SET_CONFIG_RX_TIMEOUT,
132871af9d46SMeenakshikumar Somasundaram 	SET_CONFIG_UNKNOWN_ERROR,
132971af9d46SMeenakshikumar Somasundaram };
133071af9d46SMeenakshikumar Somasundaram 
133171af9d46SMeenakshikumar Somasundaram /**
133271af9d46SMeenakshikumar Somasundaram  * Definition of a set_config reply
133371af9d46SMeenakshikumar Somasundaram  */
133471af9d46SMeenakshikumar Somasundaram struct set_config_reply_control_data {
133571af9d46SMeenakshikumar Somasundaram 	uint8_t instance; /* DPIA Instance */
133671af9d46SMeenakshikumar Somasundaram 	uint8_t status; /* Set Config reply */
133771af9d46SMeenakshikumar Somasundaram 	uint16_t pad; /* Alignment */
133871af9d46SMeenakshikumar Somasundaram };
133971af9d46SMeenakshikumar Somasundaram 
134071af9d46SMeenakshikumar Somasundaram /**
134171af9d46SMeenakshikumar Somasundaram  * Definition of a DMUB_OUT_CMD__SET_CONFIG_REPLY command.
134271af9d46SMeenakshikumar Somasundaram  */
134371af9d46SMeenakshikumar Somasundaram struct dmub_rb_cmd_dp_set_config_reply {
134471af9d46SMeenakshikumar Somasundaram 	struct dmub_cmd_header header;
134571af9d46SMeenakshikumar Somasundaram 	struct set_config_reply_control_data set_config_reply_control;
134671af9d46SMeenakshikumar Somasundaram };
134771af9d46SMeenakshikumar Somasundaram 
134884034ad4SAnthony Koo /*
134984034ad4SAnthony Koo  * Command IDs should be treated as stable ABI.
135084034ad4SAnthony Koo  * Do not reuse or modify IDs.
135184034ad4SAnthony Koo  */
135284034ad4SAnthony Koo 
13531a595f28SAnthony Koo /**
13541a595f28SAnthony Koo  * PSR command sub-types.
13551a595f28SAnthony Koo  */
135684034ad4SAnthony Koo enum dmub_cmd_psr_type {
13571a595f28SAnthony Koo 	/**
13581a595f28SAnthony Koo 	 * Set PSR version support.
13591a595f28SAnthony Koo 	 */
136084034ad4SAnthony Koo 	DMUB_CMD__PSR_SET_VERSION		= 0,
13611a595f28SAnthony Koo 	/**
13621a595f28SAnthony Koo 	 * Copy driver-calculated parameters to PSR state.
13631a595f28SAnthony Koo 	 */
136484034ad4SAnthony Koo 	DMUB_CMD__PSR_COPY_SETTINGS		= 1,
13651a595f28SAnthony Koo 	/**
13661a595f28SAnthony Koo 	 * Enable PSR.
13671a595f28SAnthony Koo 	 */
136884034ad4SAnthony Koo 	DMUB_CMD__PSR_ENABLE			= 2,
13691a595f28SAnthony Koo 
13701a595f28SAnthony Koo 	/**
13711a595f28SAnthony Koo 	 * Disable PSR.
13721a595f28SAnthony Koo 	 */
137384034ad4SAnthony Koo 	DMUB_CMD__PSR_DISABLE			= 3,
13741a595f28SAnthony Koo 
13751a595f28SAnthony Koo 	/**
13761a595f28SAnthony Koo 	 * Set PSR level.
13771a595f28SAnthony Koo 	 * PSR level is a 16-bit value dicated by driver that
13781a595f28SAnthony Koo 	 * will enable/disable different functionality.
13791a595f28SAnthony Koo 	 */
138084034ad4SAnthony Koo 	DMUB_CMD__PSR_SET_LEVEL			= 4,
13811a595f28SAnthony Koo 
13821a595f28SAnthony Koo 	/**
13831a595f28SAnthony Koo 	 * Forces PSR enabled until an explicit PSR disable call.
13841a595f28SAnthony Koo 	 */
1385672251b2SAnthony Koo 	DMUB_CMD__PSR_FORCE_STATIC		= 5,
1386e5dfcd27SRobin Chen 	/**
1387e5dfcd27SRobin Chen 	 * Set PSR power option
1388e5dfcd27SRobin Chen 	 */
1389e5dfcd27SRobin Chen 	DMUB_CMD__SET_PSR_POWER_OPT = 7,
139084034ad4SAnthony Koo };
139184034ad4SAnthony Koo 
13921a595f28SAnthony Koo /**
13931a595f28SAnthony Koo  * PSR versions.
13941a595f28SAnthony Koo  */
139584034ad4SAnthony Koo enum psr_version {
13961a595f28SAnthony Koo 	/**
13971a595f28SAnthony Koo 	 * PSR version 1.
13981a595f28SAnthony Koo 	 */
139984034ad4SAnthony Koo 	PSR_VERSION_1				= 0,
14001a595f28SAnthony Koo 	/**
14011a595f28SAnthony Koo 	 * PSR not supported.
14021a595f28SAnthony Koo 	 */
140384034ad4SAnthony Koo 	PSR_VERSION_UNSUPPORTED			= 0xFFFFFFFF,
140484034ad4SAnthony Koo };
140584034ad4SAnthony Koo 
1406592a6318SAnthony Koo /**
1407592a6318SAnthony Koo  * enum dmub_cmd_mall_type - MALL commands
1408592a6318SAnthony Koo  */
140952f2e83eSBhawanpreet Lakha enum dmub_cmd_mall_type {
1410592a6318SAnthony Koo 	/**
1411592a6318SAnthony Koo 	 * Allows display refresh from MALL.
1412592a6318SAnthony Koo 	 */
141352f2e83eSBhawanpreet Lakha 	DMUB_CMD__MALL_ACTION_ALLOW = 0,
1414592a6318SAnthony Koo 	/**
1415592a6318SAnthony Koo 	 * Disallows display refresh from MALL.
1416592a6318SAnthony Koo 	 */
141752f2e83eSBhawanpreet Lakha 	DMUB_CMD__MALL_ACTION_DISALLOW = 1,
1418592a6318SAnthony Koo 	/**
1419592a6318SAnthony Koo 	 * Cursor copy for MALL.
1420592a6318SAnthony Koo 	 */
142152f2e83eSBhawanpreet Lakha 	DMUB_CMD__MALL_ACTION_COPY_CURSOR = 2,
1422592a6318SAnthony Koo 	/**
1423592a6318SAnthony Koo 	 * Controls DF requests.
1424592a6318SAnthony Koo 	 */
1425ea7154d8SBhawanpreet Lakha 	DMUB_CMD__MALL_ACTION_NO_DF_REQ = 3,
142652f2e83eSBhawanpreet Lakha };
142752f2e83eSBhawanpreet Lakha 
1428592a6318SAnthony Koo 
14291a595f28SAnthony Koo /**
14301a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
14311a595f28SAnthony Koo  */
14327c008829SNicholas Kazlauskas struct dmub_cmd_psr_copy_settings_data {
14331a595f28SAnthony Koo 	/**
14341a595f28SAnthony Koo 	 * Flags that can be set by driver to change some PSR behaviour.
14351a595f28SAnthony Koo 	 */
14367b8a6362SAnthony Koo 	union dmub_psr_debug_flags debug;
14371a595f28SAnthony Koo 	/**
14381a595f28SAnthony Koo 	 * 16-bit value dicated by driver that will enable/disable different functionality.
14391a595f28SAnthony Koo 	 */
14404c1a1335SWyatt Wood 	uint16_t psr_level;
14411a595f28SAnthony Koo 	/**
14421a595f28SAnthony Koo 	 * DPP HW instance.
14431a595f28SAnthony Koo 	 */
14444c1a1335SWyatt Wood 	uint8_t dpp_inst;
14451a595f28SAnthony Koo 	/**
14461a595f28SAnthony Koo 	 * MPCC HW instance.
14471a595f28SAnthony Koo 	 * Not used in dmub fw,
144834ba432cSAnthony Koo 	 * dmub fw will get active opp by reading odm registers.
144934ba432cSAnthony Koo 	 */
14504c1a1335SWyatt Wood 	uint8_t mpcc_inst;
14511a595f28SAnthony Koo 	/**
14521a595f28SAnthony Koo 	 * OPP HW instance.
14531a595f28SAnthony Koo 	 * Not used in dmub fw,
14541a595f28SAnthony Koo 	 * dmub fw will get active opp by reading odm registers.
14551a595f28SAnthony Koo 	 */
14564c1a1335SWyatt Wood 	uint8_t opp_inst;
14571a595f28SAnthony Koo 	/**
14581a595f28SAnthony Koo 	 * OTG HW instance.
14591a595f28SAnthony Koo 	 */
14604c1a1335SWyatt Wood 	uint8_t otg_inst;
14611a595f28SAnthony Koo 	/**
14621a595f28SAnthony Koo 	 * DIG FE HW instance.
14631a595f28SAnthony Koo 	 */
14644c1a1335SWyatt Wood 	uint8_t digfe_inst;
14651a595f28SAnthony Koo 	/**
14661a595f28SAnthony Koo 	 * DIG BE HW instance.
14671a595f28SAnthony Koo 	 */
14684c1a1335SWyatt Wood 	uint8_t digbe_inst;
14691a595f28SAnthony Koo 	/**
14701a595f28SAnthony Koo 	 * DP PHY HW instance.
14711a595f28SAnthony Koo 	 */
14724c1a1335SWyatt Wood 	uint8_t dpphy_inst;
14731a595f28SAnthony Koo 	/**
14741a595f28SAnthony Koo 	 * AUX HW instance.
14751a595f28SAnthony Koo 	 */
14764c1a1335SWyatt Wood 	uint8_t aux_inst;
14771a595f28SAnthony Koo 	/**
14781a595f28SAnthony Koo 	 * Determines if SMU optimzations are enabled/disabled.
14791a595f28SAnthony Koo 	 */
14804c1a1335SWyatt Wood 	uint8_t smu_optimizations_en;
14811a595f28SAnthony Koo 	/**
14821a595f28SAnthony Koo 	 * Unused.
14831a595f28SAnthony Koo 	 * TODO: Remove.
14841a595f28SAnthony Koo 	 */
14854c1a1335SWyatt Wood 	uint8_t frame_delay;
14861a595f28SAnthony Koo 	/**
14871a595f28SAnthony Koo 	 * If RFB setup time is greater than the total VBLANK time,
14881a595f28SAnthony Koo 	 * it is not possible for the sink to capture the video frame
14891a595f28SAnthony Koo 	 * in the same frame the SDP is sent. In this case,
14901a595f28SAnthony Koo 	 * the frame capture indication bit should be set and an extra
14911a595f28SAnthony Koo 	 * static frame should be transmitted to the sink.
14921a595f28SAnthony Koo 	 */
14934c1a1335SWyatt Wood 	uint8_t frame_cap_ind;
14941a595f28SAnthony Koo 	/**
14951a595f28SAnthony Koo 	 * Explicit padding to 4 byte boundary.
14961a595f28SAnthony Koo 	 */
1497175f0971SYongqiang Sun 	uint8_t pad[2];
14981a595f28SAnthony Koo 	/**
14991a595f28SAnthony Koo 	 * Multi-display optimizations are implemented on certain ASICs.
15001a595f28SAnthony Koo 	 */
1501175f0971SYongqiang Sun 	uint8_t multi_disp_optimizations_en;
15021a595f28SAnthony Koo 	/**
15031a595f28SAnthony Koo 	 * The last possible line SDP may be transmitted without violating
15041a595f28SAnthony Koo 	 * the RFB setup time or entering the active video frame.
15051a595f28SAnthony Koo 	 */
150678ead771SAnthony Koo 	uint16_t init_sdp_deadline;
15071a595f28SAnthony Koo 	/**
15081a595f28SAnthony Koo 	 * Explicit padding to 4 byte boundary.
15091a595f28SAnthony Koo 	 */
151078ead771SAnthony Koo 	uint16_t pad2;
15111a595f28SAnthony Koo 	/**
15121a595f28SAnthony Koo 	 * Length of each horizontal line in us.
15131a595f28SAnthony Koo 	 */
15149b56f6bcSAnthony Koo 	uint32_t line_time_in_us;
1515ecc11601SAnthony Koo 	/**
1516ecc11601SAnthony Koo 	 * FEC enable status in driver
1517ecc11601SAnthony Koo 	 */
1518ecc11601SAnthony Koo 	uint8_t fec_enable_status;
1519ecc11601SAnthony Koo 	/**
1520ecc11601SAnthony Koo 	 * FEC re-enable delay when PSR exit.
1521ecc11601SAnthony Koo 	 * unit is 100us, range form 0~255(0xFF).
1522ecc11601SAnthony Koo 	 */
1523ecc11601SAnthony Koo 	uint8_t fec_enable_delay_in100us;
1524ecc11601SAnthony Koo 	/**
1525f56c837aSMikita Lipski 	 * PSR control version.
1526ecc11601SAnthony Koo 	 */
1527f56c837aSMikita Lipski 	uint8_t cmd_version;
1528f56c837aSMikita Lipski 	/**
1529f56c837aSMikita Lipski 	 * Panel Instance.
1530f56c837aSMikita Lipski 	 * Panel isntance to identify which psr_state to use
1531f56c837aSMikita Lipski 	 * Currently the support is only for 0 or 1
1532f56c837aSMikita Lipski 	 */
1533f56c837aSMikita Lipski 	uint8_t panel_inst;
1534360d1b65SIan Chen 	/**
1535360d1b65SIan Chen 	 * Explicit padding to 4 byte boundary.
1536360d1b65SIan Chen 	 */
1537360d1b65SIan Chen 	uint8_t pad3[4];
15387c008829SNicholas Kazlauskas };
15397c008829SNicholas Kazlauskas 
15401a595f28SAnthony Koo /**
15411a595f28SAnthony Koo  * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
15421a595f28SAnthony Koo  */
15437c008829SNicholas Kazlauskas struct dmub_rb_cmd_psr_copy_settings {
15441a595f28SAnthony Koo 	/**
15451a595f28SAnthony Koo 	 * Command header.
15461a595f28SAnthony Koo 	 */
15477c008829SNicholas Kazlauskas 	struct dmub_cmd_header header;
15481a595f28SAnthony Koo 	/**
15491a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__PSR_COPY_SETTINGS command.
15501a595f28SAnthony Koo 	 */
15517c008829SNicholas Kazlauskas 	struct dmub_cmd_psr_copy_settings_data psr_copy_settings_data;
15527c008829SNicholas Kazlauskas };
15537c008829SNicholas Kazlauskas 
15541a595f28SAnthony Koo /**
15551a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__PSR_SET_LEVEL command.
15561a595f28SAnthony Koo  */
15577c008829SNicholas Kazlauskas struct dmub_cmd_psr_set_level_data {
15581a595f28SAnthony Koo 	/**
15591a595f28SAnthony Koo 	 * 16-bit value dicated by driver that will enable/disable different functionality.
15601a595f28SAnthony Koo 	 */
15617c008829SNicholas Kazlauskas 	uint16_t psr_level;
15621a595f28SAnthony Koo 	/**
1563f56c837aSMikita Lipski 	 * PSR control version.
15641a595f28SAnthony Koo 	 */
1565f56c837aSMikita Lipski 	uint8_t cmd_version;
1566f56c837aSMikita Lipski 	/**
1567f56c837aSMikita Lipski 	 * Panel Instance.
1568f56c837aSMikita Lipski 	 * Panel isntance to identify which psr_state to use
1569f56c837aSMikita Lipski 	 * Currently the support is only for 0 or 1
1570f56c837aSMikita Lipski 	 */
1571f56c837aSMikita Lipski 	uint8_t panel_inst;
15727c008829SNicholas Kazlauskas };
15737c008829SNicholas Kazlauskas 
15741a595f28SAnthony Koo /**
15751a595f28SAnthony Koo  * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
15761a595f28SAnthony Koo  */
15777c008829SNicholas Kazlauskas struct dmub_rb_cmd_psr_set_level {
15781a595f28SAnthony Koo 	/**
15791a595f28SAnthony Koo 	 * Command header.
15801a595f28SAnthony Koo 	 */
15817c008829SNicholas Kazlauskas 	struct dmub_cmd_header header;
15821a595f28SAnthony Koo 	/**
15831a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
15841a595f28SAnthony Koo 	 */
15857c008829SNicholas Kazlauskas 	struct dmub_cmd_psr_set_level_data psr_set_level_data;
15867c008829SNicholas Kazlauskas };
15877c008829SNicholas Kazlauskas 
1588f56c837aSMikita Lipski struct dmub_rb_cmd_psr_enable_data {
1589f56c837aSMikita Lipski 	/**
1590f56c837aSMikita Lipski 	 * PSR control version.
1591f56c837aSMikita Lipski 	 */
1592f56c837aSMikita Lipski 	uint8_t cmd_version;
1593f56c837aSMikita Lipski 	/**
1594f56c837aSMikita Lipski 	 * Panel Instance.
1595f56c837aSMikita Lipski 	 * Panel isntance to identify which psr_state to use
1596f56c837aSMikita Lipski 	 * Currently the support is only for 0 or 1
1597f56c837aSMikita Lipski 	 */
1598f56c837aSMikita Lipski 	uint8_t panel_inst;
1599f56c837aSMikita Lipski 	/**
1600f56c837aSMikita Lipski 	 * Explicit padding to 4 byte boundary.
1601f56c837aSMikita Lipski 	 */
1602f56c837aSMikita Lipski 	uint8_t pad[2];
1603f56c837aSMikita Lipski };
1604f56c837aSMikita Lipski 
16051a595f28SAnthony Koo /**
16061a595f28SAnthony Koo  * Definition of a DMUB_CMD__PSR_ENABLE command.
16071a595f28SAnthony Koo  * PSR enable/disable is controlled using the sub_type.
16081a595f28SAnthony Koo  */
16097c008829SNicholas Kazlauskas struct dmub_rb_cmd_psr_enable {
16101a595f28SAnthony Koo 	/**
16111a595f28SAnthony Koo 	 * Command header.
16121a595f28SAnthony Koo 	 */
16137c008829SNicholas Kazlauskas 	struct dmub_cmd_header header;
1614f56c837aSMikita Lipski 
1615f56c837aSMikita Lipski 	struct dmub_rb_cmd_psr_enable_data data;
16167c008829SNicholas Kazlauskas };
16177c008829SNicholas Kazlauskas 
16181a595f28SAnthony Koo /**
16191a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
16201a595f28SAnthony Koo  */
1621d4b8573eSWyatt Wood struct dmub_cmd_psr_set_version_data {
16221a595f28SAnthony Koo 	/**
16231a595f28SAnthony Koo 	 * PSR version that FW should implement.
16241a595f28SAnthony Koo 	 */
16251a595f28SAnthony Koo 	enum psr_version version;
1626f56c837aSMikita Lipski 	/**
1627f56c837aSMikita Lipski 	 * PSR control version.
1628f56c837aSMikita Lipski 	 */
1629f56c837aSMikita Lipski 	uint8_t cmd_version;
1630f56c837aSMikita Lipski 	/**
1631f56c837aSMikita Lipski 	 * Panel Instance.
1632f56c837aSMikita Lipski 	 * Panel isntance to identify which psr_state to use
1633f56c837aSMikita Lipski 	 * Currently the support is only for 0 or 1
1634f56c837aSMikita Lipski 	 */
1635f56c837aSMikita Lipski 	uint8_t panel_inst;
1636f56c837aSMikita Lipski 	/**
1637f56c837aSMikita Lipski 	 * Explicit padding to 4 byte boundary.
1638f56c837aSMikita Lipski 	 */
1639f56c837aSMikita Lipski 	uint8_t pad[2];
16407c008829SNicholas Kazlauskas };
16417c008829SNicholas Kazlauskas 
16421a595f28SAnthony Koo /**
16431a595f28SAnthony Koo  * Definition of a DMUB_CMD__PSR_SET_VERSION command.
16441a595f28SAnthony Koo  */
1645d4b8573eSWyatt Wood struct dmub_rb_cmd_psr_set_version {
16461a595f28SAnthony Koo 	/**
16471a595f28SAnthony Koo 	 * Command header.
16481a595f28SAnthony Koo 	 */
16497c008829SNicholas Kazlauskas 	struct dmub_cmd_header header;
16501a595f28SAnthony Koo 	/**
16511a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__PSR_SET_VERSION command.
16521a595f28SAnthony Koo 	 */
1653d4b8573eSWyatt Wood 	struct dmub_cmd_psr_set_version_data psr_set_version_data;
16547c008829SNicholas Kazlauskas };
16557c008829SNicholas Kazlauskas 
1656f56c837aSMikita Lipski struct dmub_cmd_psr_force_static_data {
1657f56c837aSMikita Lipski 	/**
1658f56c837aSMikita Lipski 	 * PSR control version.
1659f56c837aSMikita Lipski 	 */
1660f56c837aSMikita Lipski 	uint8_t cmd_version;
1661f56c837aSMikita Lipski 	/**
1662f56c837aSMikita Lipski 	 * Panel Instance.
1663f56c837aSMikita Lipski 	 * Panel isntance to identify which psr_state to use
1664f56c837aSMikita Lipski 	 * Currently the support is only for 0 or 1
1665f56c837aSMikita Lipski 	 */
1666f56c837aSMikita Lipski 	uint8_t panel_inst;
1667f56c837aSMikita Lipski 	/**
1668f56c837aSMikita Lipski 	 * Explicit padding to 4 byte boundary.
1669f56c837aSMikita Lipski 	 */
1670f56c837aSMikita Lipski 	uint8_t pad[2];
1671f56c837aSMikita Lipski };
1672f56c837aSMikita Lipski 
16731a595f28SAnthony Koo /**
16741a595f28SAnthony Koo  * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
16751a595f28SAnthony Koo  */
1676672251b2SAnthony Koo struct dmub_rb_cmd_psr_force_static {
16771a595f28SAnthony Koo 	/**
16781a595f28SAnthony Koo 	 * Command header.
16791a595f28SAnthony Koo 	 */
1680672251b2SAnthony Koo 	struct dmub_cmd_header header;
1681f56c837aSMikita Lipski 	/**
1682f56c837aSMikita Lipski 	 * Data passed from driver to FW in a DMUB_CMD__PSR_FORCE_STATIC command.
1683f56c837aSMikita Lipski 	 */
1684f56c837aSMikita Lipski 	struct dmub_cmd_psr_force_static_data psr_force_static_data;
1685672251b2SAnthony Koo };
1686672251b2SAnthony Koo 
16871a595f28SAnthony Koo /**
1688e5dfcd27SRobin Chen  * Data passed from driver to FW in a DMUB_CMD__SET_PSR_POWER_OPT command.
1689e5dfcd27SRobin Chen  */
1690e5dfcd27SRobin Chen struct dmub_cmd_psr_set_power_opt_data {
1691e5dfcd27SRobin Chen 	/**
1692e5dfcd27SRobin Chen 	 * PSR control version.
1693e5dfcd27SRobin Chen 	 */
1694e5dfcd27SRobin Chen 	uint8_t cmd_version;
1695e5dfcd27SRobin Chen 	/**
1696e5dfcd27SRobin Chen 	 * Panel Instance.
1697e5dfcd27SRobin Chen 	 * Panel isntance to identify which psr_state to use
1698e5dfcd27SRobin Chen 	 * Currently the support is only for 0 or 1
1699e5dfcd27SRobin Chen 	 */
1700e5dfcd27SRobin Chen 	uint8_t panel_inst;
1701e5dfcd27SRobin Chen 	/**
1702e5dfcd27SRobin Chen 	 * Explicit padding to 4 byte boundary.
1703e5dfcd27SRobin Chen 	 */
1704e5dfcd27SRobin Chen 	uint8_t pad[2];
1705e5dfcd27SRobin Chen 	/**
1706e5dfcd27SRobin Chen 	 * PSR power option
1707e5dfcd27SRobin Chen 	 */
1708e5dfcd27SRobin Chen 	uint32_t power_opt;
1709e5dfcd27SRobin Chen };
1710e5dfcd27SRobin Chen 
1711e5dfcd27SRobin Chen /**
1712e5dfcd27SRobin Chen  * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
1713e5dfcd27SRobin Chen  */
1714e5dfcd27SRobin Chen struct dmub_rb_cmd_psr_set_power_opt {
1715e5dfcd27SRobin Chen 	/**
1716e5dfcd27SRobin Chen 	 * Command header.
1717e5dfcd27SRobin Chen 	 */
1718e5dfcd27SRobin Chen 	struct dmub_cmd_header header;
1719e5dfcd27SRobin Chen 	/**
1720e5dfcd27SRobin Chen 	 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
1721e5dfcd27SRobin Chen 	 */
1722e5dfcd27SRobin Chen 	struct dmub_cmd_psr_set_power_opt_data psr_set_power_opt_data;
1723e5dfcd27SRobin Chen };
1724e5dfcd27SRobin Chen 
1725e5dfcd27SRobin Chen /**
17261a595f28SAnthony Koo  * Set of HW components that can be locked.
17270b51e7e8SAnthony Koo  *
17280b51e7e8SAnthony Koo  * Note: If updating with more HW components, fields
17290b51e7e8SAnthony Koo  * in dmub_inbox0_cmd_lock_hw must be updated to match.
17301a595f28SAnthony Koo  */
1731788408b7SAnthony Koo union dmub_hw_lock_flags {
17321a595f28SAnthony Koo 	/**
17331a595f28SAnthony Koo 	 * Set of HW components that can be locked.
17341a595f28SAnthony Koo 	 */
1735788408b7SAnthony Koo 	struct {
17361a595f28SAnthony Koo 		/**
17371a595f28SAnthony Koo 		 * Lock/unlock OTG master update lock.
17381a595f28SAnthony Koo 		 */
1739788408b7SAnthony Koo 		uint8_t lock_pipe   : 1;
17401a595f28SAnthony Koo 		/**
17411a595f28SAnthony Koo 		 * Lock/unlock cursor.
17421a595f28SAnthony Koo 		 */
1743788408b7SAnthony Koo 		uint8_t lock_cursor : 1;
17441a595f28SAnthony Koo 		/**
17451a595f28SAnthony Koo 		 * Lock/unlock global update lock.
17461a595f28SAnthony Koo 		 */
1747788408b7SAnthony Koo 		uint8_t lock_dig    : 1;
17481a595f28SAnthony Koo 		/**
17491a595f28SAnthony Koo 		 * Triple buffer lock requires additional hw programming to usual OTG master lock.
17501a595f28SAnthony Koo 		 */
1751788408b7SAnthony Koo 		uint8_t triple_buffer_lock : 1;
1752788408b7SAnthony Koo 	} bits;
1753788408b7SAnthony Koo 
17541a595f28SAnthony Koo 	/**
17551a595f28SAnthony Koo 	 * Union for HW Lock flags.
17561a595f28SAnthony Koo 	 */
1757788408b7SAnthony Koo 	uint8_t u8All;
1758788408b7SAnthony Koo };
1759788408b7SAnthony Koo 
17601a595f28SAnthony Koo /**
17611a595f28SAnthony Koo  * Instances of HW to be locked.
17620b51e7e8SAnthony Koo  *
17630b51e7e8SAnthony Koo  * Note: If updating with more HW components, fields
17640b51e7e8SAnthony Koo  * in dmub_inbox0_cmd_lock_hw must be updated to match.
17651a595f28SAnthony Koo  */
1766788408b7SAnthony Koo struct dmub_hw_lock_inst_flags {
17671a595f28SAnthony Koo 	/**
17681a595f28SAnthony Koo 	 * OTG HW instance for OTG master update lock.
17691a595f28SAnthony Koo 	 */
1770788408b7SAnthony Koo 	uint8_t otg_inst;
17711a595f28SAnthony Koo 	/**
17721a595f28SAnthony Koo 	 * OPP instance for cursor lock.
17731a595f28SAnthony Koo 	 */
1774788408b7SAnthony Koo 	uint8_t opp_inst;
17751a595f28SAnthony Koo 	/**
17761a595f28SAnthony Koo 	 * OTG HW instance for global update lock.
17771a595f28SAnthony Koo 	 * TODO: Remove, and re-use otg_inst.
17781a595f28SAnthony Koo 	 */
1779788408b7SAnthony Koo 	uint8_t dig_inst;
17801a595f28SAnthony Koo 	/**
17811a595f28SAnthony Koo 	 * Explicit pad to 4 byte boundary.
17821a595f28SAnthony Koo 	 */
1783788408b7SAnthony Koo 	uint8_t pad;
1784788408b7SAnthony Koo };
1785788408b7SAnthony Koo 
17861a595f28SAnthony Koo /**
17871a595f28SAnthony Koo  * Clients that can acquire the HW Lock Manager.
17880b51e7e8SAnthony Koo  *
17890b51e7e8SAnthony Koo  * Note: If updating with more clients, fields in
17900b51e7e8SAnthony Koo  * dmub_inbox0_cmd_lock_hw must be updated to match.
17911a595f28SAnthony Koo  */
1792788408b7SAnthony Koo enum hw_lock_client {
17931a595f28SAnthony Koo 	/**
17941a595f28SAnthony Koo 	 * Driver is the client of HW Lock Manager.
17951a595f28SAnthony Koo 	 */
1796788408b7SAnthony Koo 	HW_LOCK_CLIENT_DRIVER = 0,
17971a595f28SAnthony Koo 	/**
17981a595f28SAnthony Koo 	 * Invalid client.
17991a595f28SAnthony Koo 	 */
1800788408b7SAnthony Koo 	HW_LOCK_CLIENT_INVALID = 0xFFFFFFFF,
1801788408b7SAnthony Koo };
1802788408b7SAnthony Koo 
18031a595f28SAnthony Koo /**
18041a595f28SAnthony Koo  * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
18051a595f28SAnthony Koo  */
1806788408b7SAnthony Koo struct dmub_cmd_lock_hw_data {
18071a595f28SAnthony Koo 	/**
18081a595f28SAnthony Koo 	 * Specifies the client accessing HW Lock Manager.
18091a595f28SAnthony Koo 	 */
1810788408b7SAnthony Koo 	enum hw_lock_client client;
18111a595f28SAnthony Koo 	/**
18121a595f28SAnthony Koo 	 * HW instances to be locked.
18131a595f28SAnthony Koo 	 */
1814788408b7SAnthony Koo 	struct dmub_hw_lock_inst_flags inst_flags;
18151a595f28SAnthony Koo 	/**
18161a595f28SAnthony Koo 	 * Which components to be locked.
18171a595f28SAnthony Koo 	 */
1818788408b7SAnthony Koo 	union dmub_hw_lock_flags hw_locks;
18191a595f28SAnthony Koo 	/**
18201a595f28SAnthony Koo 	 * Specifies lock/unlock.
18211a595f28SAnthony Koo 	 */
1822788408b7SAnthony Koo 	uint8_t lock;
18231a595f28SAnthony Koo 	/**
18241a595f28SAnthony Koo 	 * HW can be unlocked separately from releasing the HW Lock Mgr.
18251a595f28SAnthony Koo 	 * This flag is set if the client wishes to release the object.
18261a595f28SAnthony Koo 	 */
1827788408b7SAnthony Koo 	uint8_t should_release;
18281a595f28SAnthony Koo 	/**
18291a595f28SAnthony Koo 	 * Explicit padding to 4 byte boundary.
18301a595f28SAnthony Koo 	 */
1831788408b7SAnthony Koo 	uint8_t pad;
1832788408b7SAnthony Koo };
1833788408b7SAnthony Koo 
18341a595f28SAnthony Koo /**
18351a595f28SAnthony Koo  * Definition of a DMUB_CMD__HW_LOCK command.
18361a595f28SAnthony Koo  * Command is used by driver and FW.
18371a595f28SAnthony Koo  */
1838788408b7SAnthony Koo struct dmub_rb_cmd_lock_hw {
18391a595f28SAnthony Koo 	/**
18401a595f28SAnthony Koo 	 * Command header.
18411a595f28SAnthony Koo 	 */
1842788408b7SAnthony Koo 	struct dmub_cmd_header header;
18431a595f28SAnthony Koo 	/**
18441a595f28SAnthony Koo 	 * Data passed to HW Lock Mgr in a DMUB_CMD__HW_LOCK command.
18451a595f28SAnthony Koo 	 */
1846788408b7SAnthony Koo 	struct dmub_cmd_lock_hw_data lock_hw_data;
1847788408b7SAnthony Koo };
1848788408b7SAnthony Koo 
18491a595f28SAnthony Koo /**
18501a595f28SAnthony Koo  * ABM command sub-types.
18511a595f28SAnthony Koo  */
185284034ad4SAnthony Koo enum dmub_cmd_abm_type {
18531a595f28SAnthony Koo 	/**
18541a595f28SAnthony Koo 	 * Initialize parameters for ABM algorithm.
18551a595f28SAnthony Koo 	 * Data is passed through an indirect buffer.
18561a595f28SAnthony Koo 	 */
185784034ad4SAnthony Koo 	DMUB_CMD__ABM_INIT_CONFIG	= 0,
18581a595f28SAnthony Koo 	/**
18591a595f28SAnthony Koo 	 * Set OTG and panel HW instance.
18601a595f28SAnthony Koo 	 */
186184034ad4SAnthony Koo 	DMUB_CMD__ABM_SET_PIPE		= 1,
18621a595f28SAnthony Koo 	/**
18631a595f28SAnthony Koo 	 * Set user requested backklight level.
18641a595f28SAnthony Koo 	 */
186584034ad4SAnthony Koo 	DMUB_CMD__ABM_SET_BACKLIGHT	= 2,
18661a595f28SAnthony Koo 	/**
18671a595f28SAnthony Koo 	 * Set ABM operating/aggression level.
18681a595f28SAnthony Koo 	 */
186984034ad4SAnthony Koo 	DMUB_CMD__ABM_SET_LEVEL		= 3,
18701a595f28SAnthony Koo 	/**
18711a595f28SAnthony Koo 	 * Set ambient light level.
18721a595f28SAnthony Koo 	 */
187384034ad4SAnthony Koo 	DMUB_CMD__ABM_SET_AMBIENT_LEVEL	= 4,
18741a595f28SAnthony Koo 	/**
18751a595f28SAnthony Koo 	 * Enable/disable fractional duty cycle for backlight PWM.
18761a595f28SAnthony Koo 	 */
187784034ad4SAnthony Koo 	DMUB_CMD__ABM_SET_PWM_FRAC	= 5,
1878b629a824SEric Yang 
1879b629a824SEric Yang 	/**
1880b629a824SEric Yang 	 * unregister vertical interrupt after steady state is reached
1881b629a824SEric Yang 	 */
1882b629a824SEric Yang 	DMUB_CMD__ABM_PAUSE	= 6,
188384034ad4SAnthony Koo };
188484034ad4SAnthony Koo 
18851a595f28SAnthony Koo /**
18861a595f28SAnthony Koo  * Parameters for ABM2.4 algorithm. Passed from driver to FW via an indirect buffer.
18871a595f28SAnthony Koo  * Requirements:
18881a595f28SAnthony Koo  *  - Padded explicitly to 32-bit boundary.
18891a595f28SAnthony Koo  *  - Must ensure this structure matches the one on driver-side,
18901a595f28SAnthony Koo  *    otherwise it won't be aligned.
189184034ad4SAnthony Koo  */
189284034ad4SAnthony Koo struct abm_config_table {
18931a595f28SAnthony Koo 	/**
18941a595f28SAnthony Koo 	 * Gamma curve thresholds, used for crgb conversion.
18951a595f28SAnthony Koo 	 */
189684034ad4SAnthony Koo 	uint16_t crgb_thresh[NUM_POWER_FN_SEGS];                 // 0B
18971a595f28SAnthony Koo 	/**
18981a595f28SAnthony Koo 	 * Gamma curve offsets, used for crgb conversion.
18991a595f28SAnthony Koo 	 */
1900b6402afeSAnthony Koo 	uint16_t crgb_offset[NUM_POWER_FN_SEGS];                 // 16B
19011a595f28SAnthony Koo 	/**
19021a595f28SAnthony Koo 	 * Gamma curve slopes, used for crgb conversion.
19031a595f28SAnthony Koo 	 */
1904b6402afeSAnthony Koo 	uint16_t crgb_slope[NUM_POWER_FN_SEGS];                  // 32B
19051a595f28SAnthony Koo 	/**
19061a595f28SAnthony Koo 	 * Custom backlight curve thresholds.
19071a595f28SAnthony Koo 	 */
1908b6402afeSAnthony Koo 	uint16_t backlight_thresholds[NUM_BL_CURVE_SEGS];        // 48B
19091a595f28SAnthony Koo 	/**
19101a595f28SAnthony Koo 	 * Custom backlight curve offsets.
19111a595f28SAnthony Koo 	 */
1912b6402afeSAnthony Koo 	uint16_t backlight_offsets[NUM_BL_CURVE_SEGS];           // 78B
19131a595f28SAnthony Koo 	/**
19141a595f28SAnthony Koo 	 * Ambient light thresholds.
19151a595f28SAnthony Koo 	 */
1916b6402afeSAnthony Koo 	uint16_t ambient_thresholds_lux[NUM_AMBI_LEVEL];         // 112B
19171a595f28SAnthony Koo 	/**
19181a595f28SAnthony Koo 	 * Minimum programmable backlight.
19191a595f28SAnthony Koo 	 */
1920b6402afeSAnthony Koo 	uint16_t min_abm_backlight;                              // 122B
19211a595f28SAnthony Koo 	/**
19221a595f28SAnthony Koo 	 * Minimum reduction values.
19231a595f28SAnthony Koo 	 */
1924b6402afeSAnthony Koo 	uint8_t min_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 124B
19251a595f28SAnthony Koo 	/**
19261a595f28SAnthony Koo 	 * Maximum reduction values.
19271a595f28SAnthony Koo 	 */
1928b6402afeSAnthony Koo 	uint8_t max_reduction[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 144B
19291a595f28SAnthony Koo 	/**
19301a595f28SAnthony Koo 	 * Bright positive gain.
19311a595f28SAnthony Koo 	 */
1932b6402afeSAnthony Koo 	uint8_t bright_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL]; // 164B
19331a595f28SAnthony Koo 	/**
19341a595f28SAnthony Koo 	 * Dark negative gain.
19351a595f28SAnthony Koo 	 */
1936b6402afeSAnthony Koo 	uint8_t dark_pos_gain[NUM_AMBI_LEVEL][NUM_AGGR_LEVEL];   // 184B
19371a595f28SAnthony Koo 	/**
19381a595f28SAnthony Koo 	 * Hybrid factor.
19391a595f28SAnthony Koo 	 */
1940b6402afeSAnthony Koo 	uint8_t hybrid_factor[NUM_AGGR_LEVEL];                   // 204B
19411a595f28SAnthony Koo 	/**
19421a595f28SAnthony Koo 	 * Contrast factor.
19431a595f28SAnthony Koo 	 */
1944b6402afeSAnthony Koo 	uint8_t contrast_factor[NUM_AGGR_LEVEL];                 // 208B
19451a595f28SAnthony Koo 	/**
19461a595f28SAnthony Koo 	 * Deviation gain.
19471a595f28SAnthony Koo 	 */
1948b6402afeSAnthony Koo 	uint8_t deviation_gain[NUM_AGGR_LEVEL];                  // 212B
19491a595f28SAnthony Koo 	/**
19501a595f28SAnthony Koo 	 * Minimum knee.
19511a595f28SAnthony Koo 	 */
1952b6402afeSAnthony Koo 	uint8_t min_knee[NUM_AGGR_LEVEL];                        // 216B
19531a595f28SAnthony Koo 	/**
19541a595f28SAnthony Koo 	 * Maximum knee.
19551a595f28SAnthony Koo 	 */
1956b6402afeSAnthony Koo 	uint8_t max_knee[NUM_AGGR_LEVEL];                        // 220B
19571a595f28SAnthony Koo 	/**
19581a595f28SAnthony Koo 	 * Unused.
19591a595f28SAnthony Koo 	 */
1960b6402afeSAnthony Koo 	uint8_t iir_curve[NUM_AMBI_LEVEL];                       // 224B
19611a595f28SAnthony Koo 	/**
19621a595f28SAnthony Koo 	 * Explicit padding to 4 byte boundary.
19631a595f28SAnthony Koo 	 */
1964b6402afeSAnthony Koo 	uint8_t pad3[3];                                         // 229B
19651a595f28SAnthony Koo 	/**
19661a595f28SAnthony Koo 	 * Backlight ramp reduction.
19671a595f28SAnthony Koo 	 */
1968b6402afeSAnthony Koo 	uint16_t blRampReduction[NUM_AGGR_LEVEL];                // 232B
19691a595f28SAnthony Koo 	/**
19701a595f28SAnthony Koo 	 * Backlight ramp start.
19711a595f28SAnthony Koo 	 */
1972b6402afeSAnthony Koo 	uint16_t blRampStart[NUM_AGGR_LEVEL];                    // 240B
197384034ad4SAnthony Koo };
197484034ad4SAnthony Koo 
19751a595f28SAnthony Koo /**
19761a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
19771a595f28SAnthony Koo  */
1978e6ea8c34SWyatt Wood struct dmub_cmd_abm_set_pipe_data {
19791a595f28SAnthony Koo 	/**
19801a595f28SAnthony Koo 	 * OTG HW instance.
19811a595f28SAnthony Koo 	 */
19827b8a6362SAnthony Koo 	uint8_t otg_inst;
19831a595f28SAnthony Koo 
19841a595f28SAnthony Koo 	/**
19851a595f28SAnthony Koo 	 * Panel Control HW instance.
19861a595f28SAnthony Koo 	 */
19877b8a6362SAnthony Koo 	uint8_t panel_inst;
19881a595f28SAnthony Koo 
19891a595f28SAnthony Koo 	/**
19901a595f28SAnthony Koo 	 * Controls how ABM will interpret a set pipe or set level command.
19911a595f28SAnthony Koo 	 */
19927b8a6362SAnthony Koo 	uint8_t set_pipe_option;
19931a595f28SAnthony Koo 
19941a595f28SAnthony Koo 	/**
19951a595f28SAnthony Koo 	 * Unused.
19961a595f28SAnthony Koo 	 * TODO: Remove.
19971a595f28SAnthony Koo 	 */
19981a595f28SAnthony Koo 	uint8_t ramping_boundary;
1999e6ea8c34SWyatt Wood };
2000e6ea8c34SWyatt Wood 
20011a595f28SAnthony Koo /**
20021a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_SET_PIPE command.
20031a595f28SAnthony Koo  */
2004e6ea8c34SWyatt Wood struct dmub_rb_cmd_abm_set_pipe {
20051a595f28SAnthony Koo 	/**
20061a595f28SAnthony Koo 	 * Command header.
20071a595f28SAnthony Koo 	 */
2008e6ea8c34SWyatt Wood 	struct dmub_cmd_header header;
20091a595f28SAnthony Koo 
20101a595f28SAnthony Koo 	/**
20111a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PIPE command.
20121a595f28SAnthony Koo 	 */
2013e6ea8c34SWyatt Wood 	struct dmub_cmd_abm_set_pipe_data abm_set_pipe_data;
2014e6ea8c34SWyatt Wood };
2015e6ea8c34SWyatt Wood 
20161a595f28SAnthony Koo /**
20171a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
20181a595f28SAnthony Koo  */
2019e6ea8c34SWyatt Wood struct dmub_cmd_abm_set_backlight_data {
20201a595f28SAnthony Koo 	/**
20211a595f28SAnthony Koo 	 * Number of frames to ramp to backlight user level.
20221a595f28SAnthony Koo 	 */
2023e6ea8c34SWyatt Wood 	uint32_t frame_ramp;
20241a595f28SAnthony Koo 
20251a595f28SAnthony Koo 	/**
20261a595f28SAnthony Koo 	 * Requested backlight level from user.
20271a595f28SAnthony Koo 	 */
2028474ac4a8SYongqiang Sun 	uint32_t backlight_user_level;
2029e922057bSJake Wang 
2030e922057bSJake Wang 	/**
203163de4f04SJake Wang 	 * ABM control version.
2032e922057bSJake Wang 	 */
2033e922057bSJake Wang 	uint8_t version;
2034e922057bSJake Wang 
2035e922057bSJake Wang 	/**
2036e922057bSJake Wang 	 * Panel Control HW instance mask.
2037e922057bSJake Wang 	 * Bit 0 is Panel Control HW instance 0.
2038e922057bSJake Wang 	 * Bit 1 is Panel Control HW instance 1.
2039e922057bSJake Wang 	 */
2040e922057bSJake Wang 	uint8_t panel_mask;
2041e922057bSJake Wang 
2042e922057bSJake Wang 	/**
2043e922057bSJake Wang 	 * Explicit padding to 4 byte boundary.
2044e922057bSJake Wang 	 */
2045e922057bSJake Wang 	uint8_t pad[2];
2046e6ea8c34SWyatt Wood };
2047e6ea8c34SWyatt Wood 
20481a595f28SAnthony Koo /**
20491a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
20501a595f28SAnthony Koo  */
2051e6ea8c34SWyatt Wood struct dmub_rb_cmd_abm_set_backlight {
20521a595f28SAnthony Koo 	/**
20531a595f28SAnthony Koo 	 * Command header.
20541a595f28SAnthony Koo 	 */
2055e6ea8c34SWyatt Wood 	struct dmub_cmd_header header;
20561a595f28SAnthony Koo 
20571a595f28SAnthony Koo 	/**
20581a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_BACKLIGHT command.
20591a595f28SAnthony Koo 	 */
2060e6ea8c34SWyatt Wood 	struct dmub_cmd_abm_set_backlight_data abm_set_backlight_data;
2061e6ea8c34SWyatt Wood };
2062e6ea8c34SWyatt Wood 
20631a595f28SAnthony Koo /**
20641a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
20651a595f28SAnthony Koo  */
2066e6ea8c34SWyatt Wood struct dmub_cmd_abm_set_level_data {
20671a595f28SAnthony Koo 	/**
20681a595f28SAnthony Koo 	 * Set current ABM operating/aggression level.
20691a595f28SAnthony Koo 	 */
2070e6ea8c34SWyatt Wood 	uint32_t level;
207163de4f04SJake Wang 
207263de4f04SJake Wang 	/**
207363de4f04SJake Wang 	 * ABM control version.
207463de4f04SJake Wang 	 */
207563de4f04SJake Wang 	uint8_t version;
207663de4f04SJake Wang 
207763de4f04SJake Wang 	/**
207863de4f04SJake Wang 	 * Panel Control HW instance mask.
207963de4f04SJake Wang 	 * Bit 0 is Panel Control HW instance 0.
208063de4f04SJake Wang 	 * Bit 1 is Panel Control HW instance 1.
208163de4f04SJake Wang 	 */
208263de4f04SJake Wang 	uint8_t panel_mask;
208363de4f04SJake Wang 
208463de4f04SJake Wang 	/**
208563de4f04SJake Wang 	 * Explicit padding to 4 byte boundary.
208663de4f04SJake Wang 	 */
208763de4f04SJake Wang 	uint8_t pad[2];
2088e6ea8c34SWyatt Wood };
2089e6ea8c34SWyatt Wood 
20901a595f28SAnthony Koo /**
20911a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
20921a595f28SAnthony Koo  */
2093e6ea8c34SWyatt Wood struct dmub_rb_cmd_abm_set_level {
20941a595f28SAnthony Koo 	/**
20951a595f28SAnthony Koo 	 * Command header.
20961a595f28SAnthony Koo 	 */
2097e6ea8c34SWyatt Wood 	struct dmub_cmd_header header;
20981a595f28SAnthony Koo 
20991a595f28SAnthony Koo 	/**
21001a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_LEVEL command.
21011a595f28SAnthony Koo 	 */
2102e6ea8c34SWyatt Wood 	struct dmub_cmd_abm_set_level_data abm_set_level_data;
2103e6ea8c34SWyatt Wood };
2104e6ea8c34SWyatt Wood 
21051a595f28SAnthony Koo /**
21061a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
21071a595f28SAnthony Koo  */
2108e6ea8c34SWyatt Wood struct dmub_cmd_abm_set_ambient_level_data {
21091a595f28SAnthony Koo 	/**
21101a595f28SAnthony Koo 	 * Ambient light sensor reading from OS.
21111a595f28SAnthony Koo 	 */
2112e6ea8c34SWyatt Wood 	uint32_t ambient_lux;
211363de4f04SJake Wang 
211463de4f04SJake Wang 	/**
211563de4f04SJake Wang 	 * ABM control version.
211663de4f04SJake Wang 	 */
211763de4f04SJake Wang 	uint8_t version;
211863de4f04SJake Wang 
211963de4f04SJake Wang 	/**
212063de4f04SJake Wang 	 * Panel Control HW instance mask.
212163de4f04SJake Wang 	 * Bit 0 is Panel Control HW instance 0.
212263de4f04SJake Wang 	 * Bit 1 is Panel Control HW instance 1.
212363de4f04SJake Wang 	 */
212463de4f04SJake Wang 	uint8_t panel_mask;
212563de4f04SJake Wang 
212663de4f04SJake Wang 	/**
212763de4f04SJake Wang 	 * Explicit padding to 4 byte boundary.
212863de4f04SJake Wang 	 */
212963de4f04SJake Wang 	uint8_t pad[2];
2130e6ea8c34SWyatt Wood };
2131e6ea8c34SWyatt Wood 
21321a595f28SAnthony Koo /**
21331a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
21341a595f28SAnthony Koo  */
2135e6ea8c34SWyatt Wood struct dmub_rb_cmd_abm_set_ambient_level {
21361a595f28SAnthony Koo 	/**
21371a595f28SAnthony Koo 	 * Command header.
21381a595f28SAnthony Koo 	 */
2139e6ea8c34SWyatt Wood 	struct dmub_cmd_header header;
21401a595f28SAnthony Koo 
21411a595f28SAnthony Koo 	/**
21421a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
21431a595f28SAnthony Koo 	 */
2144e6ea8c34SWyatt Wood 	struct dmub_cmd_abm_set_ambient_level_data abm_set_ambient_level_data;
2145e6ea8c34SWyatt Wood };
2146e6ea8c34SWyatt Wood 
21471a595f28SAnthony Koo /**
21481a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
21491a595f28SAnthony Koo  */
2150e6ea8c34SWyatt Wood struct dmub_cmd_abm_set_pwm_frac_data {
21511a595f28SAnthony Koo 	/**
21521a595f28SAnthony Koo 	 * Enable/disable fractional duty cycle for backlight PWM.
21531a595f28SAnthony Koo 	 * TODO: Convert to uint8_t.
21541a595f28SAnthony Koo 	 */
2155e6ea8c34SWyatt Wood 	uint32_t fractional_pwm;
215663de4f04SJake Wang 
215763de4f04SJake Wang 	/**
215863de4f04SJake Wang 	 * ABM control version.
215963de4f04SJake Wang 	 */
216063de4f04SJake Wang 	uint8_t version;
216163de4f04SJake Wang 
216263de4f04SJake Wang 	/**
216363de4f04SJake Wang 	 * Panel Control HW instance mask.
216463de4f04SJake Wang 	 * Bit 0 is Panel Control HW instance 0.
216563de4f04SJake Wang 	 * Bit 1 is Panel Control HW instance 1.
216663de4f04SJake Wang 	 */
216763de4f04SJake Wang 	uint8_t panel_mask;
216863de4f04SJake Wang 
216963de4f04SJake Wang 	/**
217063de4f04SJake Wang 	 * Explicit padding to 4 byte boundary.
217163de4f04SJake Wang 	 */
217263de4f04SJake Wang 	uint8_t pad[2];
2173e6ea8c34SWyatt Wood };
2174e6ea8c34SWyatt Wood 
21751a595f28SAnthony Koo /**
21761a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
21771a595f28SAnthony Koo  */
2178e6ea8c34SWyatt Wood struct dmub_rb_cmd_abm_set_pwm_frac {
21791a595f28SAnthony Koo 	/**
21801a595f28SAnthony Koo 	 * Command header.
21811a595f28SAnthony Koo 	 */
2182e6ea8c34SWyatt Wood 	struct dmub_cmd_header header;
21831a595f28SAnthony Koo 
21841a595f28SAnthony Koo 	/**
21851a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_SET_PWM_FRAC command.
21861a595f28SAnthony Koo 	 */
2187e6ea8c34SWyatt Wood 	struct dmub_cmd_abm_set_pwm_frac_data abm_set_pwm_frac_data;
2188e6ea8c34SWyatt Wood };
2189e6ea8c34SWyatt Wood 
21901a595f28SAnthony Koo /**
21911a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
21921a595f28SAnthony Koo  */
219316012806SWyatt Wood struct dmub_cmd_abm_init_config_data {
21941a595f28SAnthony Koo 	/**
21951a595f28SAnthony Koo 	 * Location of indirect buffer used to pass init data to ABM.
21961a595f28SAnthony Koo 	 */
219716012806SWyatt Wood 	union dmub_addr src;
21981a595f28SAnthony Koo 
21991a595f28SAnthony Koo 	/**
22001a595f28SAnthony Koo 	 * Indirect buffer length.
22011a595f28SAnthony Koo 	 */
220216012806SWyatt Wood 	uint16_t bytes;
220363de4f04SJake Wang 
220463de4f04SJake Wang 
220563de4f04SJake Wang 	/**
220663de4f04SJake Wang 	 * ABM control version.
220763de4f04SJake Wang 	 */
220863de4f04SJake Wang 	uint8_t version;
220963de4f04SJake Wang 
221063de4f04SJake Wang 	/**
221163de4f04SJake Wang 	 * Panel Control HW instance mask.
221263de4f04SJake Wang 	 * Bit 0 is Panel Control HW instance 0.
221363de4f04SJake Wang 	 * Bit 1 is Panel Control HW instance 1.
221463de4f04SJake Wang 	 */
221563de4f04SJake Wang 	uint8_t panel_mask;
221663de4f04SJake Wang 
221763de4f04SJake Wang 	/**
221863de4f04SJake Wang 	 * Explicit padding to 4 byte boundary.
221963de4f04SJake Wang 	 */
222063de4f04SJake Wang 	uint8_t pad[2];
222116012806SWyatt Wood };
222216012806SWyatt Wood 
22231a595f28SAnthony Koo /**
22241a595f28SAnthony Koo  * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
22251a595f28SAnthony Koo  */
222616012806SWyatt Wood struct dmub_rb_cmd_abm_init_config {
22271a595f28SAnthony Koo 	/**
22281a595f28SAnthony Koo 	 * Command header.
22291a595f28SAnthony Koo 	 */
223016012806SWyatt Wood 	struct dmub_cmd_header header;
22311a595f28SAnthony Koo 
22321a595f28SAnthony Koo 	/**
22331a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__ABM_INIT_CONFIG command.
22341a595f28SAnthony Koo 	 */
223516012806SWyatt Wood 	struct dmub_cmd_abm_init_config_data abm_init_config_data;
223616012806SWyatt Wood };
223716012806SWyatt Wood 
22381a595f28SAnthony Koo /**
2239b629a824SEric Yang  * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command.
2240b629a824SEric Yang  */
2241b629a824SEric Yang 
2242b629a824SEric Yang struct dmub_cmd_abm_pause_data {
2243b629a824SEric Yang 
2244b629a824SEric Yang 	/**
2245b629a824SEric Yang 	 * Panel Control HW instance mask.
2246b629a824SEric Yang 	 * Bit 0 is Panel Control HW instance 0.
2247b629a824SEric Yang 	 * Bit 1 is Panel Control HW instance 1.
2248b629a824SEric Yang 	 */
2249b629a824SEric Yang 	uint8_t panel_mask;
2250b629a824SEric Yang 
2251b629a824SEric Yang 	/**
2252b629a824SEric Yang 	 * OTG hw instance
2253b629a824SEric Yang 	 */
2254b629a824SEric Yang 	uint8_t otg_inst;
2255b629a824SEric Yang 
2256b629a824SEric Yang 	/**
2257b629a824SEric Yang 	 * Enable or disable ABM pause
2258b629a824SEric Yang 	 */
2259b629a824SEric Yang 	uint8_t enable;
2260b629a824SEric Yang 
2261b629a824SEric Yang 	/**
2262b629a824SEric Yang 	 * Explicit padding to 4 byte boundary.
2263b629a824SEric Yang 	 */
2264b629a824SEric Yang 	uint8_t pad[1];
2265b629a824SEric Yang };
2266b629a824SEric Yang 
2267b629a824SEric Yang /**
2268b629a824SEric Yang  * Definition of a DMUB_CMD__ABM_PAUSE command.
2269b629a824SEric Yang  */
2270b629a824SEric Yang struct dmub_rb_cmd_abm_pause {
2271b629a824SEric Yang 	/**
2272b629a824SEric Yang 	 * Command header.
2273b629a824SEric Yang 	 */
2274b629a824SEric Yang 	struct dmub_cmd_header header;
2275b629a824SEric Yang 
2276b629a824SEric Yang 	/**
2277b629a824SEric Yang 	 * Data passed from driver to FW in a DMUB_CMD__ABM_PAUSE command.
2278b629a824SEric Yang 	 */
2279b629a824SEric Yang 	struct dmub_cmd_abm_pause_data abm_pause_data;
2280b629a824SEric Yang };
2281b629a824SEric Yang 
2282b629a824SEric Yang /**
22831a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
22841a595f28SAnthony Koo  */
228534ba432cSAnthony Koo struct dmub_cmd_query_feature_caps_data {
22861a595f28SAnthony Koo 	/**
22871a595f28SAnthony Koo 	 * DMUB feature capabilities.
22881a595f28SAnthony Koo 	 * After DMUB init, driver will query FW capabilities prior to enabling certain features.
22891a595f28SAnthony Koo 	 */
229034ba432cSAnthony Koo 	struct dmub_feature_caps feature_caps;
229134ba432cSAnthony Koo };
229234ba432cSAnthony Koo 
22931a595f28SAnthony Koo /**
22941a595f28SAnthony Koo  * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
22951a595f28SAnthony Koo  */
229634ba432cSAnthony Koo struct dmub_rb_cmd_query_feature_caps {
22971a595f28SAnthony Koo 	/**
22981a595f28SAnthony Koo 	 * Command header.
22991a595f28SAnthony Koo 	 */
230034ba432cSAnthony Koo 	struct dmub_cmd_header header;
23011a595f28SAnthony Koo 	/**
23021a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__QUERY_FEATURE_CAPS command.
23031a595f28SAnthony Koo 	 */
230434ba432cSAnthony Koo 	struct dmub_cmd_query_feature_caps_data query_feature_caps_data;
230534ba432cSAnthony Koo };
230634ba432cSAnthony Koo 
2307592a6318SAnthony Koo struct dmub_optc_state {
2308592a6318SAnthony Koo 	uint32_t v_total_max;
2309592a6318SAnthony Koo 	uint32_t v_total_min;
2310592a6318SAnthony Koo 	uint32_t v_total_mid;
2311592a6318SAnthony Koo 	uint32_t v_total_mid_frame_num;
2312592a6318SAnthony Koo 	uint32_t tg_inst;
2313592a6318SAnthony Koo 	uint32_t enable_manual_trigger;
2314592a6318SAnthony Koo 	uint32_t clear_force_vsync;
2315592a6318SAnthony Koo };
2316592a6318SAnthony Koo 
2317592a6318SAnthony Koo struct dmub_rb_cmd_drr_update {
2318592a6318SAnthony Koo 		struct dmub_cmd_header header;
2319592a6318SAnthony Koo 		struct dmub_optc_state dmub_optc_state_req;
2320592a6318SAnthony Koo };
2321592a6318SAnthony Koo 
2322b04cb192SNicholas Kazlauskas /**
2323b04cb192SNicholas Kazlauskas  * enum dmub_cmd_panel_cntl_type - Panel control command.
2324b04cb192SNicholas Kazlauskas  */
2325b04cb192SNicholas Kazlauskas enum dmub_cmd_panel_cntl_type {
2326b04cb192SNicholas Kazlauskas 	/**
2327b04cb192SNicholas Kazlauskas 	 * Initializes embedded panel hardware blocks.
2328b04cb192SNicholas Kazlauskas 	 */
2329b04cb192SNicholas Kazlauskas 	DMUB_CMD__PANEL_CNTL_HW_INIT = 0,
2330b04cb192SNicholas Kazlauskas 	/**
2331b04cb192SNicholas Kazlauskas 	 * Queries backlight info for the embedded panel.
2332b04cb192SNicholas Kazlauskas 	 */
2333b04cb192SNicholas Kazlauskas 	DMUB_CMD__PANEL_CNTL_QUERY_BACKLIGHT_INFO = 1,
2334b04cb192SNicholas Kazlauskas };
2335b04cb192SNicholas Kazlauskas 
2336b04cb192SNicholas Kazlauskas /**
2337b04cb192SNicholas Kazlauskas  * struct dmub_cmd_panel_cntl_data - Panel control data.
2338b04cb192SNicholas Kazlauskas  */
2339b04cb192SNicholas Kazlauskas struct dmub_cmd_panel_cntl_data {
2340b04cb192SNicholas Kazlauskas 	uint32_t inst; /**< panel instance */
2341b04cb192SNicholas Kazlauskas 	uint32_t current_backlight; /* in/out */
2342b04cb192SNicholas Kazlauskas 	uint32_t bl_pwm_cntl; /* in/out */
2343b04cb192SNicholas Kazlauskas 	uint32_t bl_pwm_period_cntl; /* in/out */
2344b04cb192SNicholas Kazlauskas 	uint32_t bl_pwm_ref_div1; /* in/out */
2345b04cb192SNicholas Kazlauskas 	uint8_t is_backlight_on : 1; /* in/out */
2346b04cb192SNicholas Kazlauskas 	uint8_t is_powered_on : 1; /* in/out */
2347b04cb192SNicholas Kazlauskas };
2348b04cb192SNicholas Kazlauskas 
2349b04cb192SNicholas Kazlauskas /**
2350b04cb192SNicholas Kazlauskas  * struct dmub_rb_cmd_panel_cntl - Panel control command.
2351b04cb192SNicholas Kazlauskas  */
2352b04cb192SNicholas Kazlauskas struct dmub_rb_cmd_panel_cntl {
2353b04cb192SNicholas Kazlauskas 	struct dmub_cmd_header header; /**< header */
2354b04cb192SNicholas Kazlauskas 	struct dmub_cmd_panel_cntl_data data; /**< payload */
2355b04cb192SNicholas Kazlauskas };
2356b04cb192SNicholas Kazlauskas 
23571a595f28SAnthony Koo /**
23581a595f28SAnthony Koo  * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
23591a595f28SAnthony Koo  */
23601a595f28SAnthony Koo struct dmub_cmd_lvtma_control_data {
23611a595f28SAnthony Koo 	uint8_t uc_pwr_action; /**< LVTMA_ACTION */
23621a595f28SAnthony Koo 	uint8_t reserved_0[3]; /**< For future use */
23631a595f28SAnthony Koo 	uint8_t panel_inst; /**< LVTMA control instance */
23641a595f28SAnthony Koo 	uint8_t reserved_1[3]; /**< For future use */
23651a595f28SAnthony Koo };
23661a595f28SAnthony Koo 
23671a595f28SAnthony Koo /**
23681a595f28SAnthony Koo  * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
23691a595f28SAnthony Koo  */
23701a595f28SAnthony Koo struct dmub_rb_cmd_lvtma_control {
23711a595f28SAnthony Koo 	/**
23721a595f28SAnthony Koo 	 * Command header.
23731a595f28SAnthony Koo 	 */
23741a595f28SAnthony Koo 	struct dmub_cmd_header header;
23751a595f28SAnthony Koo 	/**
23761a595f28SAnthony Koo 	 * Data passed from driver to FW in a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
23771a595f28SAnthony Koo 	 */
23781a595f28SAnthony Koo 	struct dmub_cmd_lvtma_control_data data;
23791a595f28SAnthony Koo };
23801a595f28SAnthony Koo 
2381592a6318SAnthony Koo /**
2382021eaef8SAnthony Koo  * Maximum number of bytes a chunk sent to DMUB for parsing
2383021eaef8SAnthony Koo  */
2384021eaef8SAnthony Koo #define DMUB_EDID_CEA_DATA_CHUNK_BYTES 8
2385021eaef8SAnthony Koo 
2386021eaef8SAnthony Koo /**
2387021eaef8SAnthony Koo  *  Represent a chunk of CEA blocks sent to DMUB for parsing
2388021eaef8SAnthony Koo  */
2389021eaef8SAnthony Koo struct dmub_cmd_send_edid_cea {
2390021eaef8SAnthony Koo 	uint16_t offset;	/**< offset into the CEA block */
2391021eaef8SAnthony Koo 	uint8_t length;	/**< number of bytes in payload to copy as part of CEA block */
2392021eaef8SAnthony Koo 	uint16_t total_length;  /**< total length of the CEA block */
2393021eaef8SAnthony Koo 	uint8_t payload[DMUB_EDID_CEA_DATA_CHUNK_BYTES]; /**< data chunk of the CEA block */
2394021eaef8SAnthony Koo 	uint8_t pad[3]; /**< padding and for future expansion */
2395021eaef8SAnthony Koo };
2396021eaef8SAnthony Koo 
2397021eaef8SAnthony Koo /**
2398021eaef8SAnthony Koo  * Result of VSDB parsing from CEA block
2399021eaef8SAnthony Koo  */
2400021eaef8SAnthony Koo struct dmub_cmd_edid_cea_amd_vsdb {
2401021eaef8SAnthony Koo 	uint8_t vsdb_found;		/**< 1 if parsing has found valid AMD VSDB */
2402021eaef8SAnthony Koo 	uint8_t freesync_supported;	/**< 1 if Freesync is supported */
2403021eaef8SAnthony Koo 	uint16_t amd_vsdb_version;	/**< AMD VSDB version */
2404021eaef8SAnthony Koo 	uint16_t min_frame_rate;	/**< Maximum frame rate */
2405021eaef8SAnthony Koo 	uint16_t max_frame_rate;	/**< Minimum frame rate */
2406021eaef8SAnthony Koo };
2407021eaef8SAnthony Koo 
2408021eaef8SAnthony Koo /**
2409021eaef8SAnthony Koo  * Result of sending a CEA chunk
2410021eaef8SAnthony Koo  */
2411021eaef8SAnthony Koo struct dmub_cmd_edid_cea_ack {
2412021eaef8SAnthony Koo 	uint16_t offset;	/**< offset of the chunk into the CEA block */
2413021eaef8SAnthony Koo 	uint8_t success;	/**< 1 if this sending of chunk succeeded */
2414021eaef8SAnthony Koo 	uint8_t pad;		/**< padding and for future expansion */
2415021eaef8SAnthony Koo };
2416021eaef8SAnthony Koo 
2417021eaef8SAnthony Koo /**
2418021eaef8SAnthony Koo  * Specify whether the result is an ACK/NACK or the parsing has finished
2419021eaef8SAnthony Koo  */
2420021eaef8SAnthony Koo enum dmub_cmd_edid_cea_reply_type {
2421021eaef8SAnthony Koo 	DMUB_CMD__EDID_CEA_AMD_VSDB	= 1, /**< VSDB parsing has finished */
2422021eaef8SAnthony Koo 	DMUB_CMD__EDID_CEA_ACK		= 2, /**< acknowledges the CEA sending is OK or failing */
2423021eaef8SAnthony Koo };
2424021eaef8SAnthony Koo 
2425021eaef8SAnthony Koo /**
2426021eaef8SAnthony Koo  * Definition of a DMUB_CMD__EDID_CEA command.
2427021eaef8SAnthony Koo  */
2428021eaef8SAnthony Koo struct dmub_rb_cmd_edid_cea {
2429021eaef8SAnthony Koo 	struct dmub_cmd_header header;	/**< Command header */
2430021eaef8SAnthony Koo 	union dmub_cmd_edid_cea_data {
2431021eaef8SAnthony Koo 		struct dmub_cmd_send_edid_cea input; /**< input to send CEA chunks */
2432021eaef8SAnthony Koo 		struct dmub_cmd_edid_cea_output { /**< output with results */
2433021eaef8SAnthony Koo 			uint8_t type;	/**< dmub_cmd_edid_cea_reply_type */
2434021eaef8SAnthony Koo 			union {
2435021eaef8SAnthony Koo 				struct dmub_cmd_edid_cea_amd_vsdb amd_vsdb;
2436021eaef8SAnthony Koo 				struct dmub_cmd_edid_cea_ack ack;
2437021eaef8SAnthony Koo 			};
2438021eaef8SAnthony Koo 		} output;	/**< output to retrieve ACK/NACK or VSDB parsing results */
2439021eaef8SAnthony Koo 	} data;	/**< Command data */
2440021eaef8SAnthony Koo 
2441021eaef8SAnthony Koo };
2442021eaef8SAnthony Koo 
2443021eaef8SAnthony Koo /**
2444592a6318SAnthony Koo  * union dmub_rb_cmd - DMUB inbox command.
2445592a6318SAnthony Koo  */
24467c008829SNicholas Kazlauskas union dmub_rb_cmd {
2447dc6e2448SWyatt Wood 	struct dmub_rb_cmd_lock_hw lock_hw;
2448592a6318SAnthony Koo 	/**
2449592a6318SAnthony Koo 	 * Elements shared with all commands.
2450592a6318SAnthony Koo 	 */
24517c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_common cmd_common;
2452592a6318SAnthony Koo 	/**
2453592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__REG_SEQ_READ_MODIFY_WRITE command.
2454592a6318SAnthony Koo 	 */
2455592a6318SAnthony Koo 	struct dmub_rb_cmd_read_modify_write read_modify_write;
2456592a6318SAnthony Koo 	/**
2457592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__REG_SEQ_FIELD_UPDATE_SEQ command.
2458592a6318SAnthony Koo 	 */
2459592a6318SAnthony Koo 	struct dmub_rb_cmd_reg_field_update_sequence reg_field_update_seq;
2460592a6318SAnthony Koo 	/**
2461592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__REG_SEQ_BURST_WRITE command.
2462592a6318SAnthony Koo 	 */
2463592a6318SAnthony Koo 	struct dmub_rb_cmd_burst_write burst_write;
2464592a6318SAnthony Koo 	/**
2465592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__REG_REG_WAIT command.
2466592a6318SAnthony Koo 	 */
2467592a6318SAnthony Koo 	struct dmub_rb_cmd_reg_wait reg_wait;
2468592a6318SAnthony Koo 	/**
2469592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_DIGX_ENCODER_CONTROL command.
2470592a6318SAnthony Koo 	 */
24717c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_digx_encoder_control digx_encoder_control;
2472592a6318SAnthony Koo 	/**
2473592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_SET_PIXEL_CLOCK command.
2474592a6318SAnthony Koo 	 */
24757c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_set_pixel_clock set_pixel_clock;
2476592a6318SAnthony Koo 	/**
2477592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_ENABLE_DISP_POWER_GATING command.
2478592a6318SAnthony Koo 	 */
24797c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_enable_disp_power_gating enable_disp_power_gating;
2480592a6318SAnthony Koo 	/**
2481592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_DPPHY_INIT command.
2482592a6318SAnthony Koo 	 */
24837c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_dpphy_init dpphy_init;
2484592a6318SAnthony Koo 	/**
2485592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_DIG1_TRANSMITTER_CONTROL command.
2486592a6318SAnthony Koo 	 */
24877c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_dig1_transmitter_control dig1_transmitter_control;
24881a595f28SAnthony Koo 	/**
24891a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_SET_VERSION command.
24901a595f28SAnthony Koo 	 */
2491d4b8573eSWyatt Wood 	struct dmub_rb_cmd_psr_set_version psr_set_version;
24921a595f28SAnthony Koo 	/**
24931a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_COPY_SETTINGS command.
24941a595f28SAnthony Koo 	 */
24957c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_psr_copy_settings psr_copy_settings;
24961a595f28SAnthony Koo 	/**
24971a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_ENABLE command.
24981a595f28SAnthony Koo 	 */
2499d4b8573eSWyatt Wood 	struct dmub_rb_cmd_psr_enable psr_enable;
25001a595f28SAnthony Koo 	/**
25011a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_SET_LEVEL command.
25021a595f28SAnthony Koo 	 */
25037c008829SNicholas Kazlauskas 	struct dmub_rb_cmd_psr_set_level psr_set_level;
25041a595f28SAnthony Koo 	/**
25051a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__PSR_FORCE_STATIC command.
25061a595f28SAnthony Koo 	 */
2507672251b2SAnthony Koo 	struct dmub_rb_cmd_psr_force_static psr_force_static;
2508592a6318SAnthony Koo 	/**
2509e5dfcd27SRobin Chen 	 * Definition of a DMUB_CMD__SET_PSR_POWER_OPT command.
2510e5dfcd27SRobin Chen 	 */
2511e5dfcd27SRobin Chen 	struct dmub_rb_cmd_psr_set_power_opt psr_set_power_opt;
2512e5dfcd27SRobin Chen 	/**
2513592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__PLAT_54186_WA command.
2514592a6318SAnthony Koo 	 */
2515bae9c49bSYongqiang Sun 	struct dmub_rb_cmd_PLAT_54186_wa PLAT_54186_wa;
2516592a6318SAnthony Koo 	/**
2517592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__MALL command.
2518592a6318SAnthony Koo 	 */
251952f2e83eSBhawanpreet Lakha 	struct dmub_rb_cmd_mall mall;
2520b04cb192SNicholas Kazlauskas 	/**
2521b04cb192SNicholas Kazlauskas 	 * Definition of a DMUB_CMD__IDLE_OPT_DCN_RESTORE command.
2522b04cb192SNicholas Kazlauskas 	 */
2523b04cb192SNicholas Kazlauskas 	struct dmub_rb_cmd_idle_opt_dcn_restore dcn_restore;
2524b04cb192SNicholas Kazlauskas 
2525b04cb192SNicholas Kazlauskas 	/**
2526b04cb192SNicholas Kazlauskas 	 * Definition of a DMUB_CMD__CLK_MGR_NOTIFY_CLOCKS command.
2527b04cb192SNicholas Kazlauskas 	 */
2528b04cb192SNicholas Kazlauskas 	struct dmub_rb_cmd_clk_mgr_notify_clocks notify_clocks;
2529b04cb192SNicholas Kazlauskas 
2530b04cb192SNicholas Kazlauskas 	/**
2531b04cb192SNicholas Kazlauskas 	 * Definition of DMUB_CMD__PANEL_CNTL commands.
2532b04cb192SNicholas Kazlauskas 	 */
2533b04cb192SNicholas Kazlauskas 	struct dmub_rb_cmd_panel_cntl panel_cntl;
25341a595f28SAnthony Koo 	/**
25351a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_SET_PIPE command.
25361a595f28SAnthony Koo 	 */
2537e6ea8c34SWyatt Wood 	struct dmub_rb_cmd_abm_set_pipe abm_set_pipe;
25381a595f28SAnthony Koo 
25391a595f28SAnthony Koo 	/**
25401a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_SET_BACKLIGHT command.
25411a595f28SAnthony Koo 	 */
2542e6ea8c34SWyatt Wood 	struct dmub_rb_cmd_abm_set_backlight abm_set_backlight;
25431a595f28SAnthony Koo 
25441a595f28SAnthony Koo 	/**
25451a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_SET_LEVEL command.
25461a595f28SAnthony Koo 	 */
2547e6ea8c34SWyatt Wood 	struct dmub_rb_cmd_abm_set_level abm_set_level;
25481a595f28SAnthony Koo 
25491a595f28SAnthony Koo 	/**
25501a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_SET_AMBIENT_LEVEL command.
25511a595f28SAnthony Koo 	 */
2552e6ea8c34SWyatt Wood 	struct dmub_rb_cmd_abm_set_ambient_level abm_set_ambient_level;
25531a595f28SAnthony Koo 
25541a595f28SAnthony Koo 	/**
25551a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_SET_PWM_FRAC command.
25561a595f28SAnthony Koo 	 */
2557e6ea8c34SWyatt Wood 	struct dmub_rb_cmd_abm_set_pwm_frac abm_set_pwm_frac;
25581a595f28SAnthony Koo 
25591a595f28SAnthony Koo 	/**
25601a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__ABM_INIT_CONFIG command.
25611a595f28SAnthony Koo 	 */
256216012806SWyatt Wood 	struct dmub_rb_cmd_abm_init_config abm_init_config;
25631a595f28SAnthony Koo 
25641a595f28SAnthony Koo 	/**
2565b629a824SEric Yang 	 * Definition of a DMUB_CMD__ABM_PAUSE command.
2566b629a824SEric Yang 	 */
2567b629a824SEric Yang 	struct dmub_rb_cmd_abm_pause abm_pause;
2568b629a824SEric Yang 
2569b629a824SEric Yang 	/**
25701a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__DP_AUX_ACCESS command.
25711a595f28SAnthony Koo 	 */
2572d9beecfcSAnthony Koo 	struct dmub_rb_cmd_dp_aux_access dp_aux_access;
25731a595f28SAnthony Koo 
25741a595f28SAnthony Koo 	/**
2575592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__OUTBOX1_ENABLE command.
2576592a6318SAnthony Koo 	 */
2577592a6318SAnthony Koo 	struct dmub_rb_cmd_outbox1_enable outbox1_enable;
2578592a6318SAnthony Koo 
2579592a6318SAnthony Koo 	/**
2580592a6318SAnthony Koo 	 * Definition of a DMUB_CMD__QUERY_FEATURE_CAPS command.
25811a595f28SAnthony Koo 	 */
258234ba432cSAnthony Koo 	struct dmub_rb_cmd_query_feature_caps query_feature_caps;
2583592a6318SAnthony Koo 	struct dmub_rb_cmd_drr_update drr_update;
25841a595f28SAnthony Koo 	/**
25851a595f28SAnthony Koo 	 * Definition of a DMUB_CMD__VBIOS_LVTMA_CONTROL command.
25861a595f28SAnthony Koo 	 */
25871a595f28SAnthony Koo 	struct dmub_rb_cmd_lvtma_control lvtma_control;
2588021eaef8SAnthony Koo 	/**
258976724b76SJimmy Kizito 	 * Definition of a DMUB_CMD__DPIA_DIG1_CONTROL command.
259076724b76SJimmy Kizito 	 */
259176724b76SJimmy Kizito 	struct dmub_rb_cmd_dig1_dpia_control dig1_dpia_control;
259276724b76SJimmy Kizito 	/**
259371af9d46SMeenakshikumar Somasundaram 	 * Definition of a DMUB_CMD__DPIA_SET_CONFIG_ACCESS command.
259471af9d46SMeenakshikumar Somasundaram 	 */
259571af9d46SMeenakshikumar Somasundaram 	struct dmub_rb_cmd_set_config_access set_config_access;
259671af9d46SMeenakshikumar Somasundaram 	/**
2597021eaef8SAnthony Koo 	 * Definition of a DMUB_CMD__EDID_CEA command.
2598021eaef8SAnthony Koo 	 */
2599021eaef8SAnthony Koo 	struct dmub_rb_cmd_edid_cea edid_cea;
26007c008829SNicholas Kazlauskas };
26017c008829SNicholas Kazlauskas 
2602592a6318SAnthony Koo /**
2603592a6318SAnthony Koo  * union dmub_rb_out_cmd - Outbox command
2604592a6318SAnthony Koo  */
2605d9beecfcSAnthony Koo union dmub_rb_out_cmd {
2606592a6318SAnthony Koo 	/**
2607592a6318SAnthony Koo 	 * Parameters common to every command.
2608592a6318SAnthony Koo 	 */
2609d9beecfcSAnthony Koo 	struct dmub_rb_cmd_common cmd_common;
2610592a6318SAnthony Koo 	/**
2611592a6318SAnthony Koo 	 * AUX reply command.
2612592a6318SAnthony Koo 	 */
2613d9beecfcSAnthony Koo 	struct dmub_rb_cmd_dp_aux_reply dp_aux_reply;
2614592a6318SAnthony Koo 	/**
2615592a6318SAnthony Koo 	 * HPD notify command.
2616592a6318SAnthony Koo 	 */
2617d9beecfcSAnthony Koo 	struct dmub_rb_cmd_dp_hpd_notify dp_hpd_notify;
261871af9d46SMeenakshikumar Somasundaram 	/**
261971af9d46SMeenakshikumar Somasundaram 	 * SET_CONFIG reply command.
262071af9d46SMeenakshikumar Somasundaram 	 */
262171af9d46SMeenakshikumar Somasundaram 	struct dmub_rb_cmd_dp_set_config_reply set_config_reply;
2622d9beecfcSAnthony Koo };
26237c008829SNicholas Kazlauskas #pragma pack(pop)
26247c008829SNicholas Kazlauskas 
262584034ad4SAnthony Koo 
262684034ad4SAnthony Koo //==============================================================================
262784034ad4SAnthony Koo //</DMUB_CMD>===================================================================
262884034ad4SAnthony Koo //==============================================================================
262984034ad4SAnthony Koo //< DMUB_RB>====================================================================
263084034ad4SAnthony Koo //==============================================================================
263184034ad4SAnthony Koo 
263284034ad4SAnthony Koo #if defined(__cplusplus)
263384034ad4SAnthony Koo extern "C" {
263484034ad4SAnthony Koo #endif
263584034ad4SAnthony Koo 
2636592a6318SAnthony Koo /**
2637592a6318SAnthony Koo  * struct dmub_rb_init_params - Initialization params for DMUB ringbuffer
2638592a6318SAnthony Koo  */
263984034ad4SAnthony Koo struct dmub_rb_init_params {
2640592a6318SAnthony Koo 	void *ctx; /**< Caller provided context pointer */
2641592a6318SAnthony Koo 	void *base_address; /**< CPU base address for ring's data */
2642592a6318SAnthony Koo 	uint32_t capacity; /**< Ringbuffer capacity in bytes */
2643592a6318SAnthony Koo 	uint32_t read_ptr; /**< Initial read pointer for consumer in bytes */
2644592a6318SAnthony Koo 	uint32_t write_ptr; /**< Initial write pointer for producer in bytes */
264584034ad4SAnthony Koo };
264684034ad4SAnthony Koo 
2647592a6318SAnthony Koo /**
2648592a6318SAnthony Koo  * struct dmub_rb - Inbox or outbox DMUB ringbuffer
2649592a6318SAnthony Koo  */
265084034ad4SAnthony Koo struct dmub_rb {
2651592a6318SAnthony Koo 	void *base_address; /**< CPU address for the ring's data */
2652592a6318SAnthony Koo 	uint32_t rptr; /**< Read pointer for consumer in bytes */
2653592a6318SAnthony Koo 	uint32_t wrpt; /**< Write pointer for producer in bytes */
2654592a6318SAnthony Koo 	uint32_t capacity; /**< Ringbuffer capacity in bytes */
265584034ad4SAnthony Koo 
2656592a6318SAnthony Koo 	void *ctx; /**< Caller provided context pointer */
2657592a6318SAnthony Koo 	void *dmub; /**< Pointer to the DMUB interface */
265884034ad4SAnthony Koo };
265984034ad4SAnthony Koo 
2660592a6318SAnthony Koo /**
2661592a6318SAnthony Koo  * @brief Checks if the ringbuffer is empty.
2662592a6318SAnthony Koo  *
2663592a6318SAnthony Koo  * @param rb DMUB Ringbuffer
2664592a6318SAnthony Koo  * @return true if empty
2665592a6318SAnthony Koo  * @return false otherwise
2666592a6318SAnthony Koo  */
266784034ad4SAnthony Koo static inline bool dmub_rb_empty(struct dmub_rb *rb)
266884034ad4SAnthony Koo {
266984034ad4SAnthony Koo 	return (rb->wrpt == rb->rptr);
267084034ad4SAnthony Koo }
267184034ad4SAnthony Koo 
2672592a6318SAnthony Koo /**
2673592a6318SAnthony Koo  * @brief Checks if the ringbuffer is full
2674592a6318SAnthony Koo  *
2675592a6318SAnthony Koo  * @param rb DMUB Ringbuffer
2676592a6318SAnthony Koo  * @return true if full
2677592a6318SAnthony Koo  * @return false otherwise
2678592a6318SAnthony Koo  */
267984034ad4SAnthony Koo static inline bool dmub_rb_full(struct dmub_rb *rb)
268084034ad4SAnthony Koo {
268184034ad4SAnthony Koo 	uint32_t data_count;
268284034ad4SAnthony Koo 
268384034ad4SAnthony Koo 	if (rb->wrpt >= rb->rptr)
268484034ad4SAnthony Koo 		data_count = rb->wrpt - rb->rptr;
268584034ad4SAnthony Koo 	else
268684034ad4SAnthony Koo 		data_count = rb->capacity - (rb->rptr - rb->wrpt);
268784034ad4SAnthony Koo 
268884034ad4SAnthony Koo 	return (data_count == (rb->capacity - DMUB_RB_CMD_SIZE));
268984034ad4SAnthony Koo }
269084034ad4SAnthony Koo 
2691592a6318SAnthony Koo /**
2692592a6318SAnthony Koo  * @brief Pushes a command into the ringbuffer
2693592a6318SAnthony Koo  *
2694592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2695592a6318SAnthony Koo  * @param cmd The command to push
2696592a6318SAnthony Koo  * @return true if the ringbuffer was not full
2697592a6318SAnthony Koo  * @return false otherwise
2698592a6318SAnthony Koo  */
269984034ad4SAnthony Koo static inline bool dmub_rb_push_front(struct dmub_rb *rb,
270084034ad4SAnthony Koo 				      const union dmub_rb_cmd *cmd)
270184034ad4SAnthony Koo {
27023a9d5b0bSAnthony Koo 	uint64_t volatile *dst = (uint64_t volatile *)(rb->base_address) + rb->wrpt / sizeof(uint64_t);
27033a9d5b0bSAnthony Koo 	const uint64_t *src = (const uint64_t *)cmd;
27043a9d5b0bSAnthony Koo 	uint8_t i;
270584034ad4SAnthony Koo 
270684034ad4SAnthony Koo 	if (dmub_rb_full(rb))
270784034ad4SAnthony Koo 		return false;
270884034ad4SAnthony Koo 
270984034ad4SAnthony Koo 	// copying data
27103a9d5b0bSAnthony Koo 	for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
27113a9d5b0bSAnthony Koo 		*dst++ = *src++;
271284034ad4SAnthony Koo 
271384034ad4SAnthony Koo 	rb->wrpt += DMUB_RB_CMD_SIZE;
271484034ad4SAnthony Koo 
271584034ad4SAnthony Koo 	if (rb->wrpt >= rb->capacity)
271684034ad4SAnthony Koo 		rb->wrpt %= rb->capacity;
271784034ad4SAnthony Koo 
271884034ad4SAnthony Koo 	return true;
271984034ad4SAnthony Koo }
272084034ad4SAnthony Koo 
2721592a6318SAnthony Koo /**
2722592a6318SAnthony Koo  * @brief Pushes a command into the DMUB outbox ringbuffer
2723592a6318SAnthony Koo  *
2724592a6318SAnthony Koo  * @param rb DMUB outbox ringbuffer
2725592a6318SAnthony Koo  * @param cmd Outbox command
2726592a6318SAnthony Koo  * @return true if not full
2727592a6318SAnthony Koo  * @return false otherwise
2728592a6318SAnthony Koo  */
2729d9beecfcSAnthony Koo static inline bool dmub_rb_out_push_front(struct dmub_rb *rb,
2730d9beecfcSAnthony Koo 				      const union dmub_rb_out_cmd *cmd)
2731d9beecfcSAnthony Koo {
2732d9beecfcSAnthony Koo 	uint8_t *dst = (uint8_t *)(rb->base_address) + rb->wrpt;
2733d459b79bSAnthony Koo 	const uint8_t *src = (const uint8_t *)cmd;
2734d9beecfcSAnthony Koo 
2735d9beecfcSAnthony Koo 	if (dmub_rb_full(rb))
2736d9beecfcSAnthony Koo 		return false;
2737d9beecfcSAnthony Koo 
2738d9beecfcSAnthony Koo 	dmub_memcpy(dst, src, DMUB_RB_CMD_SIZE);
2739d9beecfcSAnthony Koo 
2740d9beecfcSAnthony Koo 	rb->wrpt += DMUB_RB_CMD_SIZE;
2741d9beecfcSAnthony Koo 
2742d9beecfcSAnthony Koo 	if (rb->wrpt >= rb->capacity)
2743d9beecfcSAnthony Koo 		rb->wrpt %= rb->capacity;
2744d9beecfcSAnthony Koo 
2745d9beecfcSAnthony Koo 	return true;
2746d9beecfcSAnthony Koo }
2747d9beecfcSAnthony Koo 
2748592a6318SAnthony Koo /**
2749592a6318SAnthony Koo  * @brief Returns the next unprocessed command in the ringbuffer.
2750592a6318SAnthony Koo  *
2751592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2752592a6318SAnthony Koo  * @param cmd The command to return
2753592a6318SAnthony Koo  * @return true if not empty
2754592a6318SAnthony Koo  * @return false otherwise
2755592a6318SAnthony Koo  */
275684034ad4SAnthony Koo static inline bool dmub_rb_front(struct dmub_rb *rb,
275734ba432cSAnthony Koo 				 union dmub_rb_cmd  **cmd)
275884034ad4SAnthony Koo {
275934ba432cSAnthony Koo 	uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rb->rptr;
276084034ad4SAnthony Koo 
276184034ad4SAnthony Koo 	if (dmub_rb_empty(rb))
276284034ad4SAnthony Koo 		return false;
276384034ad4SAnthony Koo 
276434ba432cSAnthony Koo 	*cmd = (union dmub_rb_cmd *)rb_cmd;
276584034ad4SAnthony Koo 
276684034ad4SAnthony Koo 	return true;
276784034ad4SAnthony Koo }
276884034ad4SAnthony Koo 
2769592a6318SAnthony Koo /**
27700b51e7e8SAnthony Koo  * @brief Determines the next ringbuffer offset.
27710b51e7e8SAnthony Koo  *
27720b51e7e8SAnthony Koo  * @param rb DMUB inbox ringbuffer
27730b51e7e8SAnthony Koo  * @param num_cmds Number of commands
27740b51e7e8SAnthony Koo  * @param next_rptr The next offset in the ringbuffer
27750b51e7e8SAnthony Koo  */
27760b51e7e8SAnthony Koo static inline void dmub_rb_get_rptr_with_offset(struct dmub_rb *rb,
27770b51e7e8SAnthony Koo 				  uint32_t num_cmds,
27780b51e7e8SAnthony Koo 				  uint32_t *next_rptr)
27790b51e7e8SAnthony Koo {
27800b51e7e8SAnthony Koo 	*next_rptr = rb->rptr + DMUB_RB_CMD_SIZE * num_cmds;
27810b51e7e8SAnthony Koo 
27820b51e7e8SAnthony Koo 	if (*next_rptr >= rb->capacity)
27830b51e7e8SAnthony Koo 		*next_rptr %= rb->capacity;
27840b51e7e8SAnthony Koo }
27850b51e7e8SAnthony Koo 
27860b51e7e8SAnthony Koo /**
27870b51e7e8SAnthony Koo  * @brief Returns a pointer to a command in the inbox.
27880b51e7e8SAnthony Koo  *
27890b51e7e8SAnthony Koo  * @param rb DMUB inbox ringbuffer
27900b51e7e8SAnthony Koo  * @param cmd The inbox command to return
27910b51e7e8SAnthony Koo  * @param rptr The ringbuffer offset
27920b51e7e8SAnthony Koo  * @return true if not empty
27930b51e7e8SAnthony Koo  * @return false otherwise
27940b51e7e8SAnthony Koo  */
27950b51e7e8SAnthony Koo static inline bool dmub_rb_peek_offset(struct dmub_rb *rb,
27960b51e7e8SAnthony Koo 				 union dmub_rb_cmd  **cmd,
27970b51e7e8SAnthony Koo 				 uint32_t rptr)
27980b51e7e8SAnthony Koo {
27990b51e7e8SAnthony Koo 	uint8_t *rb_cmd = (uint8_t *)(rb->base_address) + rptr;
28000b51e7e8SAnthony Koo 
28010b51e7e8SAnthony Koo 	if (dmub_rb_empty(rb))
28020b51e7e8SAnthony Koo 		return false;
28030b51e7e8SAnthony Koo 
28040b51e7e8SAnthony Koo 	*cmd = (union dmub_rb_cmd *)rb_cmd;
28050b51e7e8SAnthony Koo 
28060b51e7e8SAnthony Koo 	return true;
28070b51e7e8SAnthony Koo }
28080b51e7e8SAnthony Koo 
28090b51e7e8SAnthony Koo /**
2810592a6318SAnthony Koo  * @brief Returns the next unprocessed command in the outbox.
2811592a6318SAnthony Koo  *
2812592a6318SAnthony Koo  * @param rb DMUB outbox ringbuffer
2813592a6318SAnthony Koo  * @param cmd The outbox command to return
2814592a6318SAnthony Koo  * @return true if not empty
2815592a6318SAnthony Koo  * @return false otherwise
2816592a6318SAnthony Koo  */
2817d9beecfcSAnthony Koo static inline bool dmub_rb_out_front(struct dmub_rb *rb,
2818d9beecfcSAnthony Koo 				 union dmub_rb_out_cmd *cmd)
2819d9beecfcSAnthony Koo {
28203a9d5b0bSAnthony Koo 	const uint64_t volatile *src = (const uint64_t volatile *)(rb->base_address) + rb->rptr / sizeof(uint64_t);
28213a9d5b0bSAnthony Koo 	uint64_t *dst = (uint64_t *)cmd;
28223a9d5b0bSAnthony Koo 	uint8_t i;
2823d9beecfcSAnthony Koo 
2824d9beecfcSAnthony Koo 	if (dmub_rb_empty(rb))
2825d9beecfcSAnthony Koo 		return false;
2826d9beecfcSAnthony Koo 
2827d9beecfcSAnthony Koo 	// copying data
28283a9d5b0bSAnthony Koo 	for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
28293a9d5b0bSAnthony Koo 		*dst++ = *src++;
2830d9beecfcSAnthony Koo 
2831d9beecfcSAnthony Koo 	return true;
2832d9beecfcSAnthony Koo }
2833d9beecfcSAnthony Koo 
2834592a6318SAnthony Koo /**
2835592a6318SAnthony Koo  * @brief Removes the front entry in the ringbuffer.
2836592a6318SAnthony Koo  *
2837592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2838592a6318SAnthony Koo  * @return true if the command was removed
2839592a6318SAnthony Koo  * @return false if there were no commands
2840592a6318SAnthony Koo  */
284184034ad4SAnthony Koo static inline bool dmub_rb_pop_front(struct dmub_rb *rb)
284284034ad4SAnthony Koo {
284384034ad4SAnthony Koo 	if (dmub_rb_empty(rb))
284484034ad4SAnthony Koo 		return false;
284584034ad4SAnthony Koo 
284684034ad4SAnthony Koo 	rb->rptr += DMUB_RB_CMD_SIZE;
284784034ad4SAnthony Koo 
284884034ad4SAnthony Koo 	if (rb->rptr >= rb->capacity)
284984034ad4SAnthony Koo 		rb->rptr %= rb->capacity;
285084034ad4SAnthony Koo 
285184034ad4SAnthony Koo 	return true;
285284034ad4SAnthony Koo }
285384034ad4SAnthony Koo 
2854592a6318SAnthony Koo /**
2855592a6318SAnthony Koo  * @brief Flushes commands in the ringbuffer to framebuffer memory.
2856592a6318SAnthony Koo  *
2857592a6318SAnthony Koo  * Avoids a race condition where DMCUB accesses memory while
2858592a6318SAnthony Koo  * there are still writes in flight to framebuffer.
2859592a6318SAnthony Koo  *
2860592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2861592a6318SAnthony Koo  */
286284034ad4SAnthony Koo static inline void dmub_rb_flush_pending(const struct dmub_rb *rb)
286384034ad4SAnthony Koo {
286484034ad4SAnthony Koo 	uint32_t rptr = rb->rptr;
286584034ad4SAnthony Koo 	uint32_t wptr = rb->wrpt;
286684034ad4SAnthony Koo 
286784034ad4SAnthony Koo 	while (rptr != wptr) {
28683a9d5b0bSAnthony Koo 		uint64_t volatile *data = (uint64_t volatile *)rb->base_address + rptr / sizeof(uint64_t);
28693a9d5b0bSAnthony Koo 		//uint64_t volatile *p = (uint64_t volatile *)data;
28703a9d5b0bSAnthony Koo 		uint64_t temp;
28713a9d5b0bSAnthony Koo 		uint8_t i;
287284034ad4SAnthony Koo 
28733a9d5b0bSAnthony Koo 		for (i = 0; i < DMUB_RB_CMD_SIZE / sizeof(uint64_t); i++)
28743a9d5b0bSAnthony Koo 			temp = *data++;
287584034ad4SAnthony Koo 
287684034ad4SAnthony Koo 		rptr += DMUB_RB_CMD_SIZE;
287784034ad4SAnthony Koo 		if (rptr >= rb->capacity)
287884034ad4SAnthony Koo 			rptr %= rb->capacity;
287984034ad4SAnthony Koo 	}
288084034ad4SAnthony Koo }
288184034ad4SAnthony Koo 
2882592a6318SAnthony Koo /**
2883592a6318SAnthony Koo  * @brief Initializes a DMCUB ringbuffer
2884592a6318SAnthony Koo  *
2885592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2886592a6318SAnthony Koo  * @param init_params initial configuration for the ringbuffer
2887592a6318SAnthony Koo  */
288884034ad4SAnthony Koo static inline void dmub_rb_init(struct dmub_rb *rb,
288984034ad4SAnthony Koo 				struct dmub_rb_init_params *init_params)
289084034ad4SAnthony Koo {
289184034ad4SAnthony Koo 	rb->base_address = init_params->base_address;
289284034ad4SAnthony Koo 	rb->capacity = init_params->capacity;
289384034ad4SAnthony Koo 	rb->rptr = init_params->read_ptr;
289484034ad4SAnthony Koo 	rb->wrpt = init_params->write_ptr;
289584034ad4SAnthony Koo }
289684034ad4SAnthony Koo 
2897592a6318SAnthony Koo /**
2898592a6318SAnthony Koo  * @brief Copies output data from in/out commands into the given command.
2899592a6318SAnthony Koo  *
2900592a6318SAnthony Koo  * @param rb DMUB ringbuffer
2901592a6318SAnthony Koo  * @param cmd Command to copy data into
2902592a6318SAnthony Koo  */
290334ba432cSAnthony Koo static inline void dmub_rb_get_return_data(struct dmub_rb *rb,
290434ba432cSAnthony Koo 					   union dmub_rb_cmd *cmd)
290534ba432cSAnthony Koo {
290634ba432cSAnthony Koo 	// Copy rb entry back into command
290734ba432cSAnthony Koo 	uint8_t *rd_ptr = (rb->rptr == 0) ?
290834ba432cSAnthony Koo 		(uint8_t *)rb->base_address + rb->capacity - DMUB_RB_CMD_SIZE :
290934ba432cSAnthony Koo 		(uint8_t *)rb->base_address + rb->rptr - DMUB_RB_CMD_SIZE;
291034ba432cSAnthony Koo 
291134ba432cSAnthony Koo 	dmub_memcpy(cmd, rd_ptr, DMUB_RB_CMD_SIZE);
291234ba432cSAnthony Koo }
291334ba432cSAnthony Koo 
291484034ad4SAnthony Koo #if defined(__cplusplus)
291584034ad4SAnthony Koo }
291684034ad4SAnthony Koo #endif
291784034ad4SAnthony Koo 
291884034ad4SAnthony Koo //==============================================================================
291984034ad4SAnthony Koo //</DMUB_RB>====================================================================
292084034ad4SAnthony Koo //==============================================================================
292184034ad4SAnthony Koo 
29227c008829SNicholas Kazlauskas #endif /* _DMUB_CMD_H_ */
2923