aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Vizzarro <Luca.Vizzarro@arm.com>2020-09-22 14:55:34 +0100
committernicola-mazzucato-arm <42373140+nicola-mazzucato-arm@users.noreply.github.com>2020-11-11 14:24:21 +0000
commit88e35e4f3f74c4f806207fd653ef5729815438d1 (patch)
treeabef298fa762f5f77e1ac6d2ba1583bbbc61e10b
parentfd1a72483414ff74bb3f45dcec8efbfeed85139f (diff)
juno: Integrate mock clock
One of Juno's clocks is the I2S clock, which is a peripheral unsupported by the Juno FVP model. This commit brings an integration of Juno with the mock clock, so that this can be mocked and tested while running under an FVP. Change-Id: I726817562788842e190deb2bedfca99ae8503ef8 Signed-off-by: Luca Vizzarro <Luca.Vizzarro@arm.com>
-rw-r--r--product/juno/scp_ramfw/config_clock.c37
-rw-r--r--product/juno/scp_ramfw/config_juno_cdcel937.c15
-rw-r--r--product/juno/scp_ramfw/config_mock_clock.c40
-rw-r--r--product/juno/scp_ramfw/config_mock_clock.h18
-rw-r--r--product/juno/scp_ramfw/firmware.mk2
5 files changed, 108 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;
}
diff --git a/product/juno/scp_ramfw/config_juno_cdcel937.c b/product/juno/scp_ramfw/config_juno_cdcel937.c
index fc9a8004..ed4d205a 100644
--- a/product/juno/scp_ramfw/config_juno_cdcel937.c
+++ b/product/juno/scp_ramfw/config_juno_cdcel937.c
@@ -5,6 +5,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "config_mock_clock.h"
#include "juno_clock.h"
#include "juno_id.h"
#include "juno_mmap.h"
@@ -13,6 +14,7 @@
#include <mod_clock.h>
#include <mod_juno_cdcel937.h>
#include <mod_juno_hdlcd.h>
+#include <mod_mock_clock.h>
#include <fwk_assert.h>
#include <fwk_element.h>
@@ -186,6 +188,19 @@ static const struct fwk_element *juno_cdcel937_get_element_table(
if (status != FWK_SUCCESS)
return NULL;
+ /* If running under a FVP, direct interactions to the mocked elements */
+ if (platform_id == JUNO_IDX_PLATFORM_FVP) {
+ config =
+ (struct mod_juno_cdcel937_dev_config
+ *)(juno_cdcel937_element_table[JUNO_CLOCK_CDCEL937_IDX_I2SCLK]
+ .data);
+
+ config->clock_hal_id = (fwk_id_t)FWK_ID_ELEMENT_INIT(
+ FWK_MODULE_IDX_MOCK_CLOCK, MOD_MOCK_CLOCK_ELEMENT_IDX_I2S);
+ config->clock_api_id = (fwk_id_t)FWK_ID_API_INIT(
+ FWK_MODULE_IDX_MOCK_CLOCK, MOD_MOCK_CLOCK_API_TYPE_RESPONSE_DRIVER);
+ }
+
/* Add the lookup table to the HDLCD elements */
for (int i = 0; i < JUNO_CLOCK_CDCEL937_IDX_COUNT; i++) {
diff --git a/product/juno/scp_ramfw/config_mock_clock.c b/product/juno/scp_ramfw/config_mock_clock.c
new file mode 100644
index 00000000..91d968e3
--- /dev/null
+++ b/product/juno/scp_ramfw/config_mock_clock.c
@@ -0,0 +1,40 @@
+/*
+ * Arm SCP/MCP Software
+ * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "config_mock_clock.h"
+
+#include <mod_mock_clock.h>
+
+#include <fwk_macros.h>
+#include <fwk_module.h>
+
+static const struct mod_mock_clock_rate i2s_rate_table[] = {
+ { .rate = 1536000 }, { .rate = 2116800 }, { .rate = 2304000 },
+ { .rate = 4233600 }, { .rate = 4608000 }, { .rate = 8467200 },
+ { .rate = 9216000 },
+};
+
+static const struct fwk_element element_table[] = {
+ [MOD_MOCK_CLOCK_ELEMENT_IDX_I2S] =
+ {
+ .name = "MOCK_I2SCLK",
+ .data = &(const struct mod_mock_clock_element_cfg){
+ .rate_table = i2s_rate_table,
+ .rate_count = FWK_ARRAY_SIZE(i2s_rate_table),
+ },
+ },
+ [MOD_MOCK_CLOCK_ELEMENT_IDX_COUNT] = { 0 }, /* Termination description. */
+};
+
+static const struct fwk_element *get_element_table(fwk_id_t module_id)
+{
+ return element_table;
+}
+
+struct fwk_module_config config_mock_clock = {
+ .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table),
+};
diff --git a/product/juno/scp_ramfw/config_mock_clock.h b/product/juno/scp_ramfw/config_mock_clock.h
new file mode 100644
index 00000000..057233ba
--- /dev/null
+++ b/product/juno/scp_ramfw/config_mock_clock.h
@@ -0,0 +1,18 @@
+/*
+ * Arm SCP/MCP Software
+ * Copyright (c) 2020, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CONFIG_MOCK_CLOCK_H
+#define CONFIG_MOCK_CLOCK_H
+
+/* Mock clock element indices for Juno */
+enum mod_mock_clock_element_idx {
+ MOD_MOCK_CLOCK_ELEMENT_IDX_I2S,
+
+ MOD_MOCK_CLOCK_ELEMENT_IDX_COUNT,
+};
+
+#endif /* CONFIG_MOCK_CLOCK_H */
diff --git a/product/juno/scp_ramfw/firmware.mk b/product/juno/scp_ramfw/firmware.mk
index 45ef556d..e21998e0 100644
--- a/product/juno/scp_ramfw/firmware.mk
+++ b/product/juno/scp_ramfw/firmware.mk
@@ -52,6 +52,7 @@ BS_FIRMWARE_MODULES := \
juno_xrp7724 \
reg_sensor \
psu \
+ mock_clock \
mock_psu \
juno_pvt \
juno_thermal
@@ -97,6 +98,7 @@ BS_FIRMWARE_SOURCES := \
config_sensor.c \
config_reg_sensor.c \
config_psu.c \
+ config_mock_clock.c \
config_mock_psu.c \
config_juno_pvt.c \
config_juno_thermal.c \