162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
462306a36Sopenharmony_ci * redistributing this file, you may do so under either license.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright(c) 2022 Intel Corporation. All rights reserved.
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef __IPC4_FW_REG_H__
1062306a36Sopenharmony_ci#define __IPC4_FW_REG_H__
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#define SOF_IPC4_INVALID_STREAM_POSITION	ULLONG_MAX
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/**
1562306a36Sopenharmony_ci * struct sof_ipc4_pipeline_registers - Pipeline start and end information in fw
1662306a36Sopenharmony_ci * @stream_start_offset: Stream start offset (LPIB) reported by mixin
1762306a36Sopenharmony_ci * module allocated on pipeline attached to Host Output Gateway when
1862306a36Sopenharmony_ci * first data is being mixed to mixout module. When data is not mixed
1962306a36Sopenharmony_ci * (right after creation/after reset) value "(u64)-1" is reported
2062306a36Sopenharmony_ci * @stream_end_offset: Stream end offset (LPIB) reported by mixin
2162306a36Sopenharmony_ci * module allocated on pipeline attached to Host Output Gateway
2262306a36Sopenharmony_ci * during transition from RUNNING to PAUSED. When data is not mixed
2362306a36Sopenharmony_ci * (right after creation or after reset) value "(u64)-1" is reported.
2462306a36Sopenharmony_ci * When first data is mixed then value "0"is reported.
2562306a36Sopenharmony_ci */
2662306a36Sopenharmony_cistruct sof_ipc4_pipeline_registers {
2762306a36Sopenharmony_ci	u64 stream_start_offset;
2862306a36Sopenharmony_ci	u64 stream_end_offset;
2962306a36Sopenharmony_ci} __packed __aligned(4);
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define SOF_IPC4_PV_MAX_SUPPORTED_CHANNELS 8
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/**
3462306a36Sopenharmony_ci * struct sof_ipc4_peak_volume_regs - Volume information in fw
3562306a36Sopenharmony_ci * @peak_meter: Peak volume value in fw
3662306a36Sopenharmony_ci * @current_volume: Current volume value in fw
3762306a36Sopenharmony_ci * @target_volume: Target volume value in fw
3862306a36Sopenharmony_ci */
3962306a36Sopenharmony_cistruct sof_ipc4_peak_volume_regs {
4062306a36Sopenharmony_ci	u32 peak_meter[SOF_IPC4_PV_MAX_SUPPORTED_CHANNELS];
4162306a36Sopenharmony_ci	u32 current_volume[SOF_IPC4_PV_MAX_SUPPORTED_CHANNELS];
4262306a36Sopenharmony_ci	u32 target_volume[SOF_IPC4_PV_MAX_SUPPORTED_CHANNELS];
4362306a36Sopenharmony_ci} __packed __aligned(4);
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/**
4662306a36Sopenharmony_ci * struct sof_ipc4_llp_reading - Llp information in fw
4762306a36Sopenharmony_ci * @llp_l: Lower part of 64-bit LLP
4862306a36Sopenharmony_ci * @llp_u: Upper part of 64-bit LLP
4962306a36Sopenharmony_ci * @wclk_l: Lower part of 64-bit Wallclock
5062306a36Sopenharmony_ci * @wclk_u: Upper part of 64-bit Wallclock
5162306a36Sopenharmony_ci */
5262306a36Sopenharmony_cistruct sof_ipc4_llp_reading {
5362306a36Sopenharmony_ci	u32 llp_l;
5462306a36Sopenharmony_ci	u32 llp_u;
5562306a36Sopenharmony_ci	u32 wclk_l;
5662306a36Sopenharmony_ci	u32 wclk_u;
5762306a36Sopenharmony_ci} __packed __aligned(4);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci/**
6062306a36Sopenharmony_ci * struct of sof_ipc4_llp_reading_extended - Extended llp info
6162306a36Sopenharmony_ci * @llp_reading: Llp information in memory window
6262306a36Sopenharmony_ci * @tpd_low: Total processed data (low part)
6362306a36Sopenharmony_ci * @tpd_high: Total processed data (high part)
6462306a36Sopenharmony_ci */
6562306a36Sopenharmony_cistruct sof_ipc4_llp_reading_extended {
6662306a36Sopenharmony_ci	struct sof_ipc4_llp_reading llp_reading;
6762306a36Sopenharmony_ci	u32 tpd_low;
6862306a36Sopenharmony_ci	u32 tpd_high;
6962306a36Sopenharmony_ci} __packed __aligned(4);
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci/**
7262306a36Sopenharmony_ci * struct sof_ipc4_llp_reading_slot - Llp slot information in memory window
7362306a36Sopenharmony_ci * @node_id: Dai gateway node id
7462306a36Sopenharmony_ci * @reading: Llp information in memory window
7562306a36Sopenharmony_ci */
7662306a36Sopenharmony_cistruct sof_ipc4_llp_reading_slot {
7762306a36Sopenharmony_ci	u32 node_id;
7862306a36Sopenharmony_ci	struct sof_ipc4_llp_reading reading;
7962306a36Sopenharmony_ci} __packed __aligned(4);
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci/* ROM information */
8262306a36Sopenharmony_ci#define SOF_IPC4_FW_FUSE_VALUE_MASK		GENMASK(7, 0)
8362306a36Sopenharmony_ci#define SOF_IPC4_FW_LOAD_METHOD_MASK		BIT(8)
8462306a36Sopenharmony_ci#define SOF_IPC4_FW_DOWNLINK_IPC_USE_DMA_MASK	BIT(9)
8562306a36Sopenharmony_ci#define SOF_IPC4_FW_LOAD_METHOD_REV_MASK	GENMASK(11, 10)
8662306a36Sopenharmony_ci#define SOF_IPC4_FW_REVISION_MIN_MASK		GENMASK(15, 12)
8762306a36Sopenharmony_ci#define SOF_IPC4_FW_REVISION_MAJ_MASK		GENMASK(19, 16)
8862306a36Sopenharmony_ci#define SOF_IPC4_FW_VERSION_MIN_MASK		GENMASK(23, 20)
8962306a36Sopenharmony_ci#define SOF_IPC4_FW_VERSION_MAJ_MASK		GENMASK(27, 24)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/* Number of dsp core supported in FW Regs. */
9262306a36Sopenharmony_ci#define SOF_IPC4_MAX_SUPPORTED_ADSP_CORES	8
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci/* Number of host pipeline registers slots in FW Regs. */
9562306a36Sopenharmony_ci#define SOF_IPC4_MAX_PIPELINE_REG_SLOTS		16
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ci/* Number of PeakVol registers slots in FW Regs. */
9862306a36Sopenharmony_ci#define SOF_IPC4_MAX_PEAK_VOL_REG_SLOTS		16
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci/* Number of GPDMA LLP Reading slots in FW Regs. */
10162306a36Sopenharmony_ci#define SOF_IPC4_MAX_LLP_GPDMA_READING_SLOTS	24
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci/* Number of Aggregated SNDW Reading slots in FW Regs. */
10462306a36Sopenharmony_ci#define SOF_IPC4_MAX_LLP_SNDW_READING_SLOTS	15
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* Current ABI version of the Fw registers layout. */
10762306a36Sopenharmony_ci#define SOF_IPC4_FW_REGS_ABI_VER		1
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/**
11062306a36Sopenharmony_ci * struct sof_ipc4_fw_registers - FW Registers exposes additional
11162306a36Sopenharmony_ci * DSP / FW state information to the driver
11262306a36Sopenharmony_ci * @fw_status: Current ROM / FW status
11362306a36Sopenharmony_ci * @lec: Last ROM / FW error code
11462306a36Sopenharmony_ci * @fps: Current DSP clock status
11562306a36Sopenharmony_ci * @lnec: Last Native Error Code(from external library)
11662306a36Sopenharmony_ci * @ltr: Copy of LTRC HW register value(FW only)
11762306a36Sopenharmony_ci * @rsvd0: Reserved0
11862306a36Sopenharmony_ci * @rom_info: ROM info
11962306a36Sopenharmony_ci * @abi_ver: Version of the layout, set to the current FW_REGS_ABI_VER
12062306a36Sopenharmony_ci * @slave_core_sts: Slave core states
12162306a36Sopenharmony_ci * @rsvd2: Reserved2
12262306a36Sopenharmony_ci * @pipeline_regs: State of pipelines attached to host output  gateways
12362306a36Sopenharmony_ci * @peak_vol_regs: State of PeakVol instances indexed by the PeakVol's instance_id
12462306a36Sopenharmony_ci * @llp_gpdma_reading_slots: LLP Readings for single link gateways
12562306a36Sopenharmony_ci * @llp_sndw_reading_slots: SNDW aggregated link gateways
12662306a36Sopenharmony_ci * @llp_evad_reading_slot: LLP Readings for EVAD gateway
12762306a36Sopenharmony_ci */
12862306a36Sopenharmony_cistruct sof_ipc4_fw_registers {
12962306a36Sopenharmony_ci	u32 fw_status;
13062306a36Sopenharmony_ci	u32 lec;
13162306a36Sopenharmony_ci	u32 fps;
13262306a36Sopenharmony_ci	u32 lnec;
13362306a36Sopenharmony_ci	u32 ltr;
13462306a36Sopenharmony_ci	u32 rsvd0;
13562306a36Sopenharmony_ci	u32 rom_info;
13662306a36Sopenharmony_ci	u32 abi_ver;
13762306a36Sopenharmony_ci	u8 slave_core_sts[SOF_IPC4_MAX_SUPPORTED_ADSP_CORES];
13862306a36Sopenharmony_ci	u32 rsvd2[6];
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci	struct sof_ipc4_pipeline_registers
14162306a36Sopenharmony_ci		pipeline_regs[SOF_IPC4_MAX_PIPELINE_REG_SLOTS];
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci	struct sof_ipc4_peak_volume_regs
14462306a36Sopenharmony_ci		peak_vol_regs[SOF_IPC4_MAX_PEAK_VOL_REG_SLOTS];
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	struct sof_ipc4_llp_reading_slot
14762306a36Sopenharmony_ci		llp_gpdma_reading_slots[SOF_IPC4_MAX_LLP_GPDMA_READING_SLOTS];
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci	struct sof_ipc4_llp_reading_slot
15062306a36Sopenharmony_ci		llp_sndw_reading_slots[SOF_IPC4_MAX_LLP_SNDW_READING_SLOTS];
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci	struct sof_ipc4_llp_reading_slot llp_evad_reading_slot;
15362306a36Sopenharmony_ci} __packed __aligned(4);
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci#endif
156