From 1bdef881a2bb85951ce1020ae5b916582fbed1b2 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Wed, 10 Apr 2024 11:31:20 +0300 Subject: [PATCH] audio: base_fw: add platform layer to fw_config data Some of the FW_CONFIG fields are platform specific and cannot be filled with generic means in generic code. Handle this data via a simple platform abstraction to hook platform specific code to FW_CONFIG handling. Move out existing code for Intel cAVS and ACE platforms. Signed-off-by: Kai Vehmanen --- src/audio/base_fw.c | 16 ++++++---------- src/include/sof/platform.h | 9 +++++++++ src/platform/intel/ace/platform.c | 19 +++++++++++++++++++ src/platform/intel/cavs/platform.c | 20 ++++++++++++++++++++ 4 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index e0d8800f7bb1..b0b6a448de6f 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -43,6 +43,7 @@ static int basefw_config(uint32_t *data_offset, char *data) uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD}; struct sof_tlv *tuple = (struct sof_tlv *)data; struct ipc4_scheduler_config sche_cfg; + uint32_t plat_data_offset = 0; uint32_t log_bytes_size = 0; tlv_value_set(tuple, IPC4_FW_VERSION_FW_CFG, sizeof(version), version); @@ -58,15 +59,6 @@ static int basefw_config(uint32_t *data_offset, char *data) IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, clock_get_freq(CPU_LOWEST_FREQ_IDX)); - tuple = tlv_next(tuple); - tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8); - - tuple = tlv_next(tuple); - tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0); - - tuple = tlv_next(tuple); - tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8); - tuple = tlv_next(tuple); tlv_value_uint32_set(tuple, IPC4_DL_MAILBOX_BYTES_FW_CFG, MAILBOX_HOSTBOX_SIZE); @@ -121,7 +113,11 @@ static int basefw_config(uint32_t *data_offset, char *data) IS_ENABLED(CONFIG_ADSP_IMR_CONTEXT_SAVE)); tuple = tlv_next(tuple); - *data_offset = (int)((char *)tuple - data); + + /* add platform specific tuples */ + platform_basefw_fw_config(&plat_data_offset, (char *)tuple); + + *data_offset = (int)((char *)tuple - data) + plat_data_offset; return 0; } diff --git a/src/include/sof/platform.h b/src/include/sof/platform.h index 644275e171c2..fb6803f110e2 100644 --- a/src/include/sof/platform.h +++ b/src/include/sof/platform.h @@ -61,6 +61,15 @@ int platform_context_save(struct sof *sof); */ int platform_basefw_hw_config(uint32_t *data_offset, char *data); +/** + * \brief Platform specific routine to add data tuples to FW_CONFIG + * structure sent to host via IPC. + * \param[out] data_offset data offset after tuples added + * \parma[in] data pointer where to add new entries + * \return 0 if successful, error code otherwise. + */ +int platform_basefw_fw_config(uint32_t *data_offset, char *data); + /** @}*/ #endif diff --git a/src/platform/intel/ace/platform.c b/src/platform/intel/ace/platform.c index e3ecd8669bd6..be4595efeb73 100644 --- a/src/platform/intel/ace/platform.c +++ b/src/platform/intel/ace/platform.c @@ -165,3 +165,22 @@ int platform_basefw_hw_config(uint32_t *data_offset, char *data) return 0; } + +int platform_basefw_fw_config(uint32_t *data_offset, char *data) +{ + struct sof_tlv *tuple = (struct sof_tlv *)data; + uint32_t value; + + tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8); + + tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0); + + tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8); + + tuple = tlv_next(tuple); + *data_offset = (int)((char *)tuple - data); + + return 0; +} diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index c57708c4650f..60ee30d22e5d 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -265,3 +265,23 @@ int platform_basefw_hw_config(uint32_t *data_offset, char *data) return 0; } + +int platform_basefw_fw_config(uint32_t *data_offset, char *data) +{ + struct sof_tlv *tuple = (struct sof_tlv *)data; + uint32_t value; + + tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_SLOW_CLOCK_FREQ_HZ_FW_CFG, IPC4_ALH_CAVS_1_8); + + tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_UAOL_SUPPORT, 0); + + tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_ALH_SUPPORT_LEVEL_FW_CFG, IPC4_ALH_CAVS_1_8); + + tuple = tlv_next(tuple); + *data_offset = (int)((char *)tuple - data); + + return 0; +}