From patchwork Fri Feb 11 12:07:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 541782 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp3020293imo; Fri, 11 Feb 2022 04:07:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfn4IJeXSnvoBJi/aD8PGbyWJBEYCBcR/rSX5zc8B2fQ4vv+JrKAXbiNLGSqF9wdySjOsR X-Received: by 2002:a05:6402:2802:: with SMTP id h2mr1534215ede.255.1644581278560; Fri, 11 Feb 2022 04:07:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644581278; cv=none; d=google.com; s=arc-20160816; b=LNqGgxCGtCk+PIeQr6w6PfRlZXg0Mwkngtswc8hzj0CVwBBgEQVVKtAetDvKa5GyF2 VHOvWjzkXZF89+pIcecWa9o5eIst18FIU2/e8xYHffoZ9VsnpzlDZNn/V35T2esg6W6t x5rXS7DJtnKfPfQoYFmQBW/fWbHFmew7HLsNM2/toVzTDWFcSYmgU3PZukVUuxYE/r9y fu9hEUsKY0jsR/xlwsj7URpPXfZQ5Fmfv58vRZXImBnMIDphq+hFJVhrxG6lCJYREtjO 6+rd8Fe4ooXg+PFYa0wJFdG51WFOqGApvvZ4TVqRPYefunVmtmCT7OM342/D9TAwj3jx 92WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=6sDffo58DmHgndj31zsQWOi7C5sISqQQsFlDQCqpIyI=; b=c0ItkMQG+bkh7NP/lW/IuZiANB+PlcJHFdRh4h6DkL2c7BCaxnWk4t+VHThQkOVVxg bfztQnfUp/hkxRhrGtUN/QPfiWJwFraOLVtCMSrUekfN6vx2BxWtGYxq7kr3AYUbvjHC EhBFWDRs3uekgI6cSCg3EMkDdZwHpp3GvnCQQqgZvXXRnfs7MuCoksin0cIhvFepPjzf vpjofEMFj8F77pouvv9x2vvl6HQFqbpM1MmCJXnMyzgs0/NLgCFusr+muGpTVOLT8kLz Uo00ZTMalUWNGetMBgGIenuEEnogNF4lwnjuYhWIlOCJ9sHor/ZExoU7Ffdm5CDVHwUm wODg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dS5kReeG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 1si15933960ejb.217.2022.02.11.04.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 04:07:58 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dS5kReeG; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F89883A70; Fri, 11 Feb 2022 13:07:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dS5kReeG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2433183A8D; Fri, 11 Feb 2022 13:07:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0C8B683A69 for ; Fri, 11 Feb 2022 13:07:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wm1-x331.google.com with SMTP id c192so5308432wma.4 for ; Fri, 11 Feb 2022 04:07:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6sDffo58DmHgndj31zsQWOi7C5sISqQQsFlDQCqpIyI=; b=dS5kReeG5E0b0Goqo9jpHnc05zUt8icizpsCIdukRnTbAq3usWzfHWSA4lVtC8t4FG uoeVHPj4VOdCNZTTk7QdOj1s/xMljMHekJNLUeA0fuwt4iZVPwX5w5xuzXbCkx0dOZpg HEGKsk4GisEewOjb9N9fdxVzVIYVtGHrejNiqWDN4N+OuejySgbiGEt8J2DoC8jHuDbe EA4g+s0lIEqL2/iI+nbcm7xh7fVugIWaasKoP6r8bV5ftBxNMU4Qpl3cgWIpVic6phhe 8mSWQe2hr/pHnjCml0JcRl0VcloBUNprre7NprealFHO5h834y2jGQoT9Ocp7g/jPeWi 9KVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6sDffo58DmHgndj31zsQWOi7C5sISqQQsFlDQCqpIyI=; b=kGjz1AS8Qpg43TCq3dyAAanP4aoqJxNY37tF1GtKRsPn9f3wvZEOn0gbaQtHerXq2Y t7/Z3ym4V2qXmEhstdpCthHU+7GqqqdoQuf6yo6jJL5AyjNlU7JZnUU3iyL4PM2FaZTn KAodIGpcvSMD0i7RQE9YDmy6OSPCcynSjiHAjwrCLjD6Mj44p6xp8Plrd6+NXz2pp2Wc 9FzWm8hH+RR7USn9B6HmAi463twTFuIulOWq48/mQvir/tFTLoG34e1kVYZjijwdYo5D sBWyA33q+VXCIQv+aWhBeX9v2LIdZU2wtPNf/ppoEcYltFcW7Od95WJqx1v5njKPfKD7 GUEQ== X-Gm-Message-State: AOAM5302VNTfKLSZYxl9w5TkcyD3dqlW8uT2V7Yd9xWWhpaO7GfMIHN9 iVZwgv9THR/rgywlqCjkp+oKTfS5p0trYg== X-Received: by 2002:a05:600c:a0c:: with SMTP id z12mr63026wmp.20.1644581260489; Fri, 11 Feb 2022 04:07:40 -0800 (PST) Received: from lmecxl0524.lme.st.com ([2a04:cec0:1057:737f:9927:5b5d:6280:5a68]) by smtp.gmail.com with ESMTPSA id u14sm4964439wmq.41.2022.02.11.04.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 04:07:40 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Etienne Carriere , Simon Glass Subject: [PATCH 4/5] firmware: scmi: fix sandbox and related tests for clock discovery Date: Fri, 11 Feb 2022 13:07:24 +0100 Message-Id: <20220211120725.25358-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220211120725.25358-1-etienne.carriere@linaro.org> References: <20220211120725.25358-1-etienne.carriere@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 Signed-off-by: Etienne Carriere Reviewed-by: Patrick Delaunay Reviewed-by: Simon Glass --- 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(-) 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 = <®ul0_scmi>; regul1-supply = <®ul1_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]));