aboutsummaryrefslogtreecommitdiff
path: root/drivers/firmware/scmi/sandbox-scmi_devices.c
diff options
context:
space:
mode:
authorEtienne Carriere <etienne.carriere@linaro.org>2020-09-09 18:44:07 +0200
committerTom Rini <trini@konsulko.com>2020-09-30 11:55:24 -0400
commitc0dd177a9986b97dab42f07b3db0ed1d2fe6e540 (patch)
treeae4db71e77556f34f9fa7023205e4284c1d72c38 /drivers/firmware/scmi/sandbox-scmi_devices.c
parent34d76fefb2667d0ca138ff4fcf8bc8443032449f (diff)
firmware: smci: sandbox test for SCMI reset controllers
Add tests for SCMI reset controllers. A test device driver sandbox-scmi_devices.c is used to get reset resources, allowing further resets manipulation. Change sandbox-smci_agent to emulate 1 reset controller exposed through an agent. Add DM test scmi_resets to test this reset controller. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Cc: Simon Glass <sjg@chromium.org> Cc: Peng Fan <peng.fan@nxp.com> Cc: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/firmware/scmi/sandbox-scmi_devices.c')
-rw-r--r--drivers/firmware/scmi/sandbox-scmi_devices.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/drivers/firmware/scmi/sandbox-scmi_devices.c b/drivers/firmware/scmi/sandbox-scmi_devices.c
index b3e411c5ac..c69967bf69 100644
--- a/drivers/firmware/scmi/sandbox-scmi_devices.c
+++ b/drivers/firmware/scmi/sandbox-scmi_devices.c
@@ -7,6 +7,7 @@
#include <clk.h>
#include <dm.h>
#include <malloc.h>
+#include <reset.h>
#include <asm/io.h>
#include <asm/scmi_test.h>
#include <dm/device_compat.h>
@@ -14,18 +15,22 @@
/*
* Simulate to some extent a SCMI exchange.
* This drivers gets SCMI resources and offers API function to the
- * SCMI test sequence manipulate the resources, currently clocks.
+ * SCMI test sequence manipulate the resources, currently clock
+ * and reset controllers.
*/
#define SCMI_TEST_DEVICES_CLK_COUNT 3
+#define SCMI_TEST_DEVICES_RD_COUNT 1
/*
* struct sandbox_scmi_device_priv - Storage for device handles used by test
* @clk: Array of clock instances used by tests
+ * @reset_clt: Array of the reset controller instances used by tests
* @devices: Resources exposed by sandbox_scmi_devices_ctx()
*/
struct sandbox_scmi_device_priv {
struct clk clk[SCMI_TEST_DEVICES_CLK_COUNT];
+ struct reset_ctl reset_ctl[SCMI_TEST_DEVICES_RD_COUNT];
struct sandbox_scmi_devices devices;
};
@@ -39,6 +44,22 @@ struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
return NULL;
}
+static int sandbox_scmi_devices_remove(struct udevice *dev)
+{
+ struct sandbox_scmi_devices *devices = sandbox_scmi_devices_ctx(dev);
+ int ret = 0;
+ size_t n;
+
+ for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) {
+ int ret2 = reset_free(devices->reset + n);
+
+ if (ret2 && !ret)
+ ret = ret2;
+ }
+
+ return ret;
+}
+
static int sandbox_scmi_devices_probe(struct udevice *dev)
{
struct sandbox_scmi_device_priv *priv = dev_get_priv(dev);
@@ -48,6 +69,8 @@ static int sandbox_scmi_devices_probe(struct udevice *dev)
priv->devices = (struct sandbox_scmi_devices){
.clk = priv->clk,
.clk_count = SCMI_TEST_DEVICES_CLK_COUNT,
+ .reset = priv->reset_ctl,
+ .reset_count = SCMI_TEST_DEVICES_RD_COUNT,
};
for (n = 0; n < SCMI_TEST_DEVICES_CLK_COUNT; n++) {
@@ -58,7 +81,21 @@ static int sandbox_scmi_devices_probe(struct udevice *dev)
}
}
+ for (n = 0; n < SCMI_TEST_DEVICES_RD_COUNT; n++) {
+ ret = reset_get_by_index(dev, n, priv->devices.reset + n);
+ if (ret) {
+ dev_err(dev, "%s: Failed on reset %zu\n", __func__, n);
+ goto err_reset;
+ }
+ }
+
return 0;
+
+err_reset:
+ for (; n > 0; n--)
+ reset_free(priv->devices.reset + n - 1);
+
+ return ret;
}
static const struct udevice_id sandbox_scmi_devices_ids[] = {
@@ -71,5 +108,6 @@ U_BOOT_DRIVER(sandbox_scmi_devices) = {
.id = UCLASS_MISC,
.of_match = sandbox_scmi_devices_ids,
.priv_auto_alloc_size = sizeof(struct sandbox_scmi_device_priv),
+ .remove = sandbox_scmi_devices_remove,
.probe = sandbox_scmi_devices_probe,
};