diff options
Diffstat (limited to 'product/juno/scp_ramfw/config_clock.c')
-rw-r--r-- | product/juno/scp_ramfw/config_clock.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/product/juno/scp_ramfw/config_clock.c b/product/juno/scp_ramfw/config_clock.c index ac017cfa..cd7fdfcb 100644 --- a/product/juno/scp_ramfw/config_clock.c +++ b/product/juno/scp_ramfw/config_clock.c @@ -5,13 +5,16 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include "config_mock_clock.h" #include "config_power_domain.h" #include "juno_clock.h" +#include "juno_id.h" #include <mod_clock.h> #include <mod_juno_cdcel937.h> #include <mod_juno_hdlcd.h> #include <mod_juno_soc_clock_ram.h> +#include <mod_mock_clock.h> #include <mod_power_domain.h> #include <fwk_element.h> @@ -23,10 +26,6 @@ static struct fwk_element clock_dev_desc_table[] = { [JUNO_CLOCK_IDX_I2SCLK] = { .name = "I2SCLK", .data = &((struct mod_clock_dev_config) { - .driver_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_JUNO_CDCEL937, - JUNO_CLOCK_CDCEL937_IDX_I2SCLK), - .api_id = FWK_ID_API_INIT(FWK_MODULE_IDX_JUNO_CDCEL937, - MOD_JUNO_CDCEL937_API_IDX_CLOCK_DRIVER), .pd_source_id = FWK_ID_NONE_INIT, }), }, @@ -108,6 +107,36 @@ static struct fwk_element clock_dev_desc_table[] = { static const struct fwk_element *clock_get_dev_desc_table(fwk_id_t module_id) { + int status; + enum juno_idx_platform platform_id = JUNO_IDX_PLATFORM_COUNT; + struct mod_clock_dev_config *dev_cfg; + + status = juno_id_get_platform(&platform_id); + if (!fwk_expect(status == FWK_SUCCESS)) + return NULL; + + /* + * When running under an FVP the I2S clock does not fully function, + * as it requires the I2C hardware interrupt to properly work. This + * is replaced with the mock clock. + * + * Referencing and dereferencing is required to bypass the const qualifier. + */ + dev_cfg = (struct mod_clock_dev_config + *)(clock_dev_desc_table[JUNO_CLOCK_IDX_I2SCLK].data); + if (platform_id == JUNO_IDX_PLATFORM_FVP) { + *((fwk_id_t *)(&dev_cfg->api_id)) = (fwk_id_t)FWK_ID_API_INIT( + FWK_MODULE_IDX_MOCK_CLOCK, MOD_MOCK_CLOCK_API_TYPE_DRIVER); + *((fwk_id_t *)(&dev_cfg->driver_id)) = (fwk_id_t)FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_MOCK_CLOCK, MOD_MOCK_CLOCK_ELEMENT_IDX_I2S); + } else { + *((fwk_id_t *)(&dev_cfg->api_id)) = (fwk_id_t)FWK_ID_API_INIT( + FWK_MODULE_IDX_JUNO_CDCEL937, + MOD_JUNO_CDCEL937_API_IDX_CLOCK_DRIVER); + *((fwk_id_t *)(&dev_cfg->driver_id)) = (fwk_id_t)FWK_ID_ELEMENT_INIT( + FWK_MODULE_IDX_JUNO_CDCEL937, JUNO_CLOCK_CDCEL937_IDX_I2SCLK); + } + return clock_dev_desc_table; } |