From patchwork Mon Feb 21 08:22:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 544401 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp3063592imn; Mon, 21 Feb 2022 00:23:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2ednnhYK8Gke6PVkSNORky5u2TTT272CTy3GomBh6fYFW4A1CKwjiw5uxEo4P2Lc/66lK X-Received: by 2002:a17:906:3bc9:b0:6d0:8d78:e7e6 with SMTP id v9-20020a1709063bc900b006d08d78e7e6mr12756896ejf.222.1645431804530; Mon, 21 Feb 2022 00:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645431804; cv=none; d=google.com; s=arc-20160816; b=qbaQMcxO3MQxp92yDcaWmd7LV/UumYFrJXgwiUuI+cBXPae239P6jyBkC03G7pSEk7 7Nw5P5BWDKJ6uuv0d4wmaOA5No1R4ZDnuBAXDKzAl7FA3E8iP3Ky1qturx7/arSVCn6B E+FQ9bGCt6l0LJ+wTFahnPx4LFzQyPlMchjvlERZMgT4bV4xv3rFiHjXmKgfxQEPmJPA asbrOqkNbTeLvrc0vhRF39a7AQJplMYoXSgPa7SbOkIRgbPhh/40WFm8VjtMJUC2DJPN fP38yCzRFigVJ99tgYd42cHRMQ02QPt2vAdbPKTrNy242AiYDto9Ep6R1AlsDLFLsLmw CCqA== 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=Hc/HMcFUZycXpHLj63CryPiSwF2dG9GK1lgZGJUJtY4=; b=ctOZp9JxGGTABa62ATbFQyibYNbuW1zmT235lvJtOl6bxWx40w2eEqbzVWunHe0ra5 J4Fza6/nGR65DORtbmCPFd/8PlHuvpsV/EUL57usRBz1S+3Qbm0qCZz0/QQcmU36xpCX J6BPqbwxeyjJr2+5op0LIUSvIf02x23LZIQMt/QUaJJl3lABWPe5VzH4FZmaE+qlmih+ WHh7OChFV5JoOnSo1D8LrCjGY352pb1FbyxBsMt5F0npb0QhQtsgRjNOqqjcOyZRjDfk VOd+GP0RlegdapUPqvz1gb9/oxmw/krOx7OkSXvtGLmMzYjiU2Gm4S8WVbIC7WOD+buk dD8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lPruJcUz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id jz20si3217847ejb.144.2022.02.21.00.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 00:23:24 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lPruJcUz; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 0421D838A3; Mon, 21 Feb 2022 09:23:03 +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="lPruJcUz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 29F9383BCA; Mon, 21 Feb 2022 09:22:57 +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 22FC183BDC for ; Mon, 21 Feb 2022 09:22:48 +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 l2-20020a7bc342000000b0037fa585de26so87503wmj.1 for ; Mon, 21 Feb 2022 00:22:48 -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=Hc/HMcFUZycXpHLj63CryPiSwF2dG9GK1lgZGJUJtY4=; b=lPruJcUz/vjzWCplAq+Tki6A6b3bnGo/FCxSpBDnRhKjKEaAXY71ua7OrIoVAIQQNf 7AAj5Bu5tn3GHBkfwYLjO8vxUE07Qq7StHuIZfkpcJEgU4znqsAo9qh2GIpMuKcd3qxL gBfcnFu7pMjDs6pM6xhdudsUkSocJycNokV0p3ckg37zcv6bErpZ9ddQr8+W1Gq/0+s/ fNJfOy0LwT2vh3e09UsRU/wpxPRbE+FMD5UoPoFbPf42TSfA9EE+SiD++TeFP9HbrVIQ NZ3qMBaY8LhrfaWAZ4RlNkE7mlym9RgAQP2RMsa5Vo7F1nwGRtfP4bS93Yf38Kpq374C AgfA== 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=Hc/HMcFUZycXpHLj63CryPiSwF2dG9GK1lgZGJUJtY4=; b=HOs185plxy2e4Ig+AnTpCJ3ST2AOCaEj7shyqEIJI8rewCr1cY/CedViHUCCQYR9Ul e/vLlpQ9TbpKZFe210mD5sciAVLHpcZrpKNDLgBaluhtIL9qYHS9UCK9/6j5o+DFYzFE LPC9laOFZ7E/KPp2YAMGB2jxgjhzOc4x3vknhaeY5h5a1mA33yjbKqefZ0zC9oqMl/Ww GQLcbi9wcY6mkeBF9f+20QkeX85bxoVOUAt/Ky7wCC1xnmgokN8huKvd2ApdN4TXBa7t gsGoFX60OXi/o7GQ0x07cPdoW7vK5QKXlkXDZjv90NjwiiWCpmoxTWqpNA8i25Nf+7Gx DvVg== X-Gm-Message-State: AOAM531EGcSqTvsTMecCuKs6Ekhk8CXTGKNxIdTFYFWsQQ6A1UGSu/Be VGmikZ0QGfLAtcgNE5mJXIZlQvT3eolwDdW1 X-Received: by 2002:a1c:4405:0:b0:37b:bf55:4984 with SMTP id r5-20020a1c4405000000b0037bbf554984mr16858985wma.114.1645431767492; Mon, 21 Feb 2022 00:22:47 -0800 (PST) Received: from lmecxl0524.home (2a01cb058b8508003664a9fffe03a3fa.ipv6.abo.wanadoo.fr. [2a01:cb05:8b85:800:3664:a9ff:fe03:a3fa]) by smtp.gmail.com with ESMTPSA id m13-20020a05600c3b0d00b0037c00e01771sm6912286wms.34.2022.02.21.00.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 00:22:47 -0800 (PST) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Etienne Carriere , Simon Glass Subject: [PATCH v2 4/5] firmware: scmi: fix sandbox and related tests for clock discovery Date: Mon, 21 Feb 2022 09:22:41 +0100 Message-Id: <20220221082242.6349-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220221082242.6349-1-etienne.carriere@linaro.org> References: <20220221082242.6349-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. Cc: Simon Glass Reviewed-by: Patrick Delaunay Signed-off-by: Etienne Carriere --- Changes since v1: - Remove Series-links tag and apply R-b tag. --- 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 51474b5760..fc717a8aea 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 d576b5fd89..795f207304 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -52,7 +52,7 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, ut_assertnonnull(scmi_ctx); 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); @@ -125,14 +125,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])); @@ -148,8 +153,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]));