diff mbox series

[4/5] firmware: scmi: fix sandbox and related tests for clock discovery

Message ID 20220211120725.25358-4-etienne.carriere@linaro.org
State Superseded
Headers show
Series [1/5] doc: binding: scmi: link to latest Linux kernel binding | expand

Commit Message

Etienne Carriere Feb. 11, 2022, 12:07 p.m. UTC
Updates sandbox SCMI clock driver and tests since enabling CCF will
mandate clock discovery that is all exposed SCMI clocks shall be
discovered at initialization. For this reason, sandbox SCMI clock
driver must emulate all clocks exposed by SCMI server, not only those
effectively consumed by some other U-Boot devices.

Therefore the sandbox SCMI test driver exposes 3 clocks (IDs 0, 1 and 2)
and sandbox SCMI clock consumer driver gets 2 of them.

Series-links: 246809
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
---
 arch/sandbox/dts/test.dts                  |  2 +-
 arch/sandbox/include/asm/scmi_test.h       |  1 -
 drivers/firmware/scmi/sandbox-scmi_agent.c | 12 +++++-------
 test/dm/scmi.c                             | 15 ++++++++++-----
 4 files changed, 16 insertions(+), 14 deletions(-)

Comments

Patrick DELAUNAY Feb. 11, 2022, 1:55 p.m. UTC | #1
Hi,

On 2/11/22 13:07, Etienne Carriere wrote:
> Updates sandbox SCMI clock driver and tests since enabling CCF will
> mandate clock discovery that is all exposed SCMI clocks shall be
> discovered at initialization. For this reason, sandbox SCMI clock
> driver must emulate all clocks exposed by SCMI server, not only those
> effectively consumed by some other U-Boot devices.
>
> Therefore the sandbox SCMI test driver exposes 3 clocks (IDs 0, 1 and 2)
> and sandbox SCMI clock consumer driver gets 2 of them.
>
> Series-links: 246809


=> "Series-links" to remove : it is a patman token

https://patchwork.ozlabs.org/project/uboot/list/?series=246809&state=*


> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> ---
>   arch/sandbox/dts/test.dts                  |  2 +-
>   arch/sandbox/include/asm/scmi_test.h       |  1 -
>   drivers/firmware/scmi/sandbox-scmi_agent.c | 12 +++++-------
>   test/dm/scmi.c                             | 15 ++++++++++-----
>   4 files changed, 16 insertions(+), 14 deletions(-)
>

With this update:


Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>

Thanks
Patrick
Simon Glass Feb. 26, 2022, 6:37 p.m. UTC | #2
Hi Etienne,

On Fri, 11 Feb 2022 at 05:07, Etienne Carriere
<etienne.carriere@linaro.org> wrote:
>
> Updates sandbox SCMI clock driver and tests since enabling CCF will
> mandate clock discovery that is all exposed SCMI clocks shall be
> discovered at initialization. For this reason, sandbox SCMI clock
> driver must emulate all clocks exposed by SCMI server, not only those
> effectively consumed by some other U-Boot devices.
>
> Therefore the sandbox SCMI test driver exposes 3 clocks (IDs 0, 1 and 2)
> and sandbox SCMI clock consumer driver gets 2 of them.
>
> Series-links: 246809

Note if you use patman it should drop this automatically.

> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
> ---
>  arch/sandbox/dts/test.dts                  |  2 +-
>  arch/sandbox/include/asm/scmi_test.h       |  1 -
>  drivers/firmware/scmi/sandbox-scmi_agent.c | 12 +++++-------
>  test/dm/scmi.c                             | 15 ++++++++++-----
>  4 files changed, 16 insertions(+), 14 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 30874b038b..3d206fdb3c 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -1392,7 +1392,7 @@ 
 
 	sandbox_scmi {
 		compatible = "sandbox,scmi-devices";
-		clocks = <&clk_scmi 7>, <&clk_scmi 3>;
+		clocks = <&clk_scmi 2>, <&clk_scmi 0>;
 		resets = <&reset_scmi 3>;
 		regul0-supply = <&regul0_scmi>;
 		regul1-supply = <&regul1_scmi>;
diff --git a/arch/sandbox/include/asm/scmi_test.h b/arch/sandbox/include/asm/scmi_test.h
index 054be5f14e..c72ec1e1cb 100644
--- a/arch/sandbox/include/asm/scmi_test.h
+++ b/arch/sandbox/include/asm/scmi_test.h
@@ -17,7 +17,6 @@  struct sandbox_scmi_service;
  * @rate:	Clock rate in Hertz
  */
 struct sandbox_scmi_clk {
-	uint id;
 	bool enabled;
 	ulong rate;
 };
diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c
index 4fbff3e7ed..562fe53168 100644
--- a/drivers/firmware/scmi/sandbox-scmi_agent.c
+++ b/drivers/firmware/scmi/sandbox-scmi_agent.c
@@ -34,8 +34,9 @@ 
  */
 
 static struct sandbox_scmi_clk scmi_clk[] = {
-	{ .id = 7, .rate = 1000 },
-	{ .id = 3, .rate = 333 },
+	{ .rate = 333 },
+	{ .rate = 200 },
+	{ .rate = 1000 },
 };
 
 static struct sandbox_scmi_reset scmi_reset[] = {
@@ -81,11 +82,8 @@  static void debug_print_agent_state(struct udevice *dev, char *str)
 
 static struct sandbox_scmi_clk *get_scmi_clk_state(uint clock_id)
 {
-	size_t n;
-
-	for (n = 0; n < ARRAY_SIZE(scmi_clk); n++)
-		if (scmi_clk[n].id == clock_id)
-			return scmi_clk + n;
+	if (clock_id < ARRAY_SIZE(scmi_clk))
+		return scmi_clk + clock_id;
 
 	return NULL;
 }
diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index 2f19b99d7c..cc829f83ad 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -54,7 +54,7 @@  static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts,
 	agent = scmi_ctx->agent;
 	ut_assertnonnull(agent);
 
-	ut_asserteq(2, agent->clk_count);
+	ut_asserteq(3, agent->clk_count);
 	ut_assertnonnull(agent->clk);
 	ut_asserteq(1, agent->reset_count);
 	ut_assertnonnull(agent->reset);
@@ -128,14 +128,19 @@  static int dm_test_scmi_clocks(struct unit_test_state *uts)
 	ut_assertnonnull(agent);
 
 	/* Test SCMI clocks rate manipulation */
+	ut_asserteq(333, agent->clk[0].rate);
+	ut_asserteq(200, agent->clk[1].rate);
+	ut_asserteq(1000, agent->clk[2].rate);
+
 	ut_asserteq(1000, clk_get_rate(&scmi_devices->clk[0]));
 	ut_asserteq(333, clk_get_rate(&scmi_devices->clk[1]));
 
 	ret_dev = clk_set_rate(&scmi_devices->clk[1], 1088);
 	ut_assert(!ret_dev || ret_dev == 1088);
 
-	ut_asserteq(1000, agent->clk[0].rate);
-	ut_asserteq(1088, agent->clk[1].rate);
+	ut_asserteq(1088, agent->clk[0].rate);
+	ut_asserteq(200, agent->clk[1].rate);
+	ut_asserteq(1000, agent->clk[2].rate);
 
 	ut_asserteq(1000, clk_get_rate(&scmi_devices->clk[0]));
 	ut_asserteq(1088, clk_get_rate(&scmi_devices->clk[1]));
@@ -151,8 +156,8 @@  static int dm_test_scmi_clocks(struct unit_test_state *uts)
 
 	ut_asserteq(0, clk_enable(&scmi_devices->clk[1]));
 
-	ut_assert(!agent->clk[0].enabled);
-	ut_assert(agent->clk[1].enabled);
+	ut_assert(agent->clk[0].enabled);
+	ut_assert(!agent->clk[1].enabled);
 	ut_assert(!agent->clk[2].enabled);
 
 	ut_assertok(clk_disable(&scmi_devices->clk[1]));