From patchwork Tue Sep 26 06:57:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 726381 Delivered-To: patch@linaro.org Received: by 2002:adf:ea87:0:b0:31d:da82:a3b4 with SMTP id s7csp2779946wrm; Mon, 25 Sep 2023 23:58:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0Fc4v31P17qTrzr/63MR62L0mMvogW9q23ufLXkit9Vp6Y5yBKNfI0fPK9/3cdaOCI8g+ X-Received: by 2002:a5d:67c7:0:b0:314:1230:29b0 with SMTP id n7-20020a5d67c7000000b00314123029b0mr7108524wrw.52.1695711519826; Mon, 25 Sep 2023 23:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695711519; cv=none; d=google.com; s=arc-20160816; b=vcEBoAcA1Vh88P1LR8ZSg5Xz0Mw4d7/Gw5IXWLHl7TVGleKED/rlv5KVa6S8/kWLUv du2iRnGoZiHBC77NDglzIble71p3SHs9mk2No5tiZMMtNXPK1N5dKhLLth+owyU/r1Zg Jj6MN8EUOO7yD3wBbibqzeoL6vaFRSqqUOCG0aEBIxjQgxECll6O8tkwk/9y0jeQ/igp 7fK0vEjebizonrgfKvrVLyFNDkNubt4C09LV+urnj0QmKeXgggikpHJk/tYYeZNaKx3/ OWnezQ1cGs+pnsmmTLy/r92bHJJDQ0yF1ZkiGYH4yz8GUZ+vFHeJOuPyyNv2P0/kxKVL v1vg== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9w6NtVmxhTP8bJl1pLz+4m/B3yXvXCTMKNDuB9SU9KQ=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=ntJ25dwvh07UDNmimrUV2gDI1N0rvUmHg1d/tBxyNYvpuNz/9LPn/j9QqWH7f6prhg PiuYxtHc/j6eG8VLpegbSGGzG4zWjAeXPrdUJj1XtdS9Nw0hxQjs6ruKjMxcbkb8Or1M 4FXaQU9Ztv1yy4f7B6wLaBwxi5X528TuOMFgnRT5vb9yK0hsisL/+Egnt56YerHb7Ww3 6a9B++1Wg/ocmR8aKyOdsmFZiYlT6qzAJpqaSWnB+ij8UZaj9QUBniY+ZXDqTacLJzj7 WE4Q9lN8krhxH9N8nTVJhASdnO9roIjFATygp6JfNngQS+el18oF+p6FAn9iipXdDqH1 iZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=t8iWSi3V; 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 m5-20020a5d56c5000000b0031ad4d5132asi5597965wrw.155.2023.09.25.23.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:58:39 -0700 (PDT) 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=t8iWSi3V; 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 4C4E286C2D; Tue, 26 Sep 2023 08:58:21 +0200 (CEST) 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="t8iWSi3V"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5636086C67; Tue, 26 Sep 2023 08:58:20 +0200 (CEST) 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 autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (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 1A70986C2D for ; Tue, 26 Sep 2023 08:58:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-690fe1d9ba1so1882009b3a.0 for ; Mon, 25 Sep 2023 23:58:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695711496; x=1696316296; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9w6NtVmxhTP8bJl1pLz+4m/B3yXvXCTMKNDuB9SU9KQ=; b=t8iWSi3Vb0N1G/im1ig3tBt8jqQewfm0cvyqbphoIjoXEPcXH7zcBLIsrYZt0Ku2UV +wovZuRVM7s+lvbxJ0lKm6B/KR5hgsxafF41kiWu+ZuBn/QyjB0gjux/XIKDwDxi4qvg aLIJPaiJQtL114lvqj+7hIPKMi67GE/7s0XcZ29kMdxZ+hSn6hURtroZk9Ubsz6WkfEh u4MItp3ClrwWjSfQM0HXCV6DLZjtwjLz3ByrUHjjXnCoDdTJV4+1LYvq0Ymp2/HsaMbe 6ZEVC64g5n14VQLih2NVxYvTroU2dSVtmjF1nwdF0Boe5oIEO32P/IrhBwPMWlWiBz5t la2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695711496; x=1696316296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9w6NtVmxhTP8bJl1pLz+4m/B3yXvXCTMKNDuB9SU9KQ=; b=WBrci5gQ316Um+o4O9Y+aZZzLd4o4YM1n+b2OWrjWWoyvyH0Eqwv6FvEkG91bE77sT Nq8cNpVomrCI5GDlpx6iPP0oPUE5tfm90DdjvYknGhNpCF82TO5qqBRKcindTxj+pyXH i3Wma1ndXXgIzmnESlW8KGo+ixt/kGjEEgutyiiWoJUVZ1q1COg6ytI7nRtIcVS02S+e b4mXa2ufpUGBSAQoZOE6+ljg//j44pMx5i+sgEy5He8HEsQmAqFEVU5hTSO+/yfM7sPv d32RudJNgiyDgyKoEkWG+mcKfGMheYGfiuUAW/NTR9lvPG1EU363AGLsdJzRcoN06Ui6 7Z9w== X-Gm-Message-State: AOJu0YxsqkltnmxTcgFJPsnT7TPxYnYpMkZ6jE4y1l9PYS9RKA5Q44lZ Tswg3swL3EDeR9QWUHz2anbCFA== X-Received: by 2002:a05:6a00:d66:b0:68e:3eff:e93a with SMTP id n38-20020a056a000d6600b0068e3effe93amr9155829pfv.2.1695711496344; Mon, 25 Sep 2023 23:58:16 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:6585:aea6:5002:a825]) by smtp.gmail.com with ESMTPSA id s2-20020a639242000000b0057825bd3448sm8758874pgn.51.2023.09.25.23.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 23:58:15 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH v5 03/16] firmware: scmi: support dummy channels for sandbox agent Date: Tue, 26 Sep 2023 15:57:37 +0900 Message-Id: <20230926065750.734440-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230926065750.734440-1-takahiro.akashi@linaro.org> References: <20230926065750.734440-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 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.8 at phobos.denx.de X-Virus-Status: Clean In sandbox scmi agent, channels are not used at all. But in this patch, dummy channels are supported in order to test protocol-specific channels. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v5 * new commit --- arch/sandbox/include/asm/scmi_test.h | 13 ++++ drivers/firmware/scmi/sandbox-scmi_agent.c | 90 ++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/arch/sandbox/include/asm/scmi_test.h b/arch/sandbox/include/asm/scmi_test.h index c72ec1e1cb25..75cb462a5584 100644 --- a/arch/sandbox/include/asm/scmi_test.h +++ b/arch/sandbox/include/asm/scmi_test.h @@ -88,6 +88,14 @@ struct sandbox_scmi_devices { }; #ifdef CONFIG_SCMI_FIRMWARE +/** + * sandbox_scmi_channel_id - Get the channel id + * @dev: Reference to the SCMI protocol device + * + * Return: Channel id + */ +unsigned int sandbox_scmi_channel_id(struct udevice *dev); + /** * sandbox_scmi_service_ctx - Get the simulated SCMI services context * @return: Reference to backend simulated resources state @@ -101,6 +109,11 @@ struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); */ struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); #else +inline unsigned int sandbox_scmi_channel_id(struct udevice *dev); +{ + return 0; +} + static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) { return NULL; diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 031882998dfa..394df043918f 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -33,6 +33,26 @@ * various uclass devices, as clocks and reset controllers. */ +/** + * struct sandbox_channel - Description of sandbox transport + * @channel_id: Channel identifier + * + * Dummy channel. This will be used to test if a protocol-specific + * channel is properly used. + * Id 0 means a channel for the sandbox agent. + */ +struct sandbox_channel { + unsigned int channel_id; +}; + +/** + * struct scmi_channel - Channel instance referenced in SCMI drivers + * @ref: Reference to local channel instance + **/ +struct scmi_channel { + struct sandbox_channel ref; +}; + static struct sandbox_scmi_clk scmi_clk[] = { { .rate = 333 }, { .rate = 200 }, @@ -470,6 +490,73 @@ static int sandbox_scmi_voltd_level_get(struct udevice *dev, return 0; } +/** + * sandbox_scmi_of_get_channel - assigne a channel + * @dev: SCMI agent device + * @protocol: SCMI protocol device + * @channel: Pointer to channel info + * + * Assign a channel for the protocol, @protocol, in @channel, + * based on a device tree's property. + * + * Return: 0 on success, error code on failure + */ +static int sandbox_scmi_of_get_channel(struct udevice *dev, + struct udevice *protocol, + struct scmi_channel **channel) +{ + struct sandbox_channel *agent_chan = dev_get_plat(dev); + struct sandbox_channel *chan; + u32 channel_id; + + if (dev_read_u32(protocol, "linaro,sandbox-channel-id", &channel_id)) { + /* Uses agent channel */ + *channel = container_of(agent_chan, struct scmi_channel, ref); + + return 0; + } + + /* Setup a dedicated channel */ + chan = calloc(1, sizeof(*chan)); + if (!chan) + return -ENOMEM; + + chan->channel_id = channel_id; + + *channel = container_of(chan, struct scmi_channel, ref); + + return 0; +} + +/** + * sandbox_scmi_of_to_plat - assigne a channel to agent + * @dev: SCMI agent device + * + * Assign a channel for the agent, @protocol. + * + * Return: always 0 + */ +static int sandbox_scmi_of_to_plat(struct udevice *dev) +{ + struct sandbox_channel *chan = dev_get_plat(dev); + + /* The channel for agent is always 0 */ + chan->channel_id = 0; + + return 0; +} + +unsigned int sandbox_scmi_channel_id(struct udevice *dev) +{ + struct scmi_agent_proto_priv *priv; + struct sandbox_channel *chan; + + priv = dev_get_parent_priv(dev); + chan = (struct sandbox_channel *)&priv->channel->ref; + + return chan->channel_id; +} + static int sandbox_scmi_test_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) @@ -584,6 +671,7 @@ static const struct udevice_id sandbox_scmi_test_ids[] = { }; struct scmi_agent_ops sandbox_scmi_test_ops = { + .of_get_channel = sandbox_scmi_of_get_channel, .process_msg = sandbox_scmi_test_process_msg, }; @@ -592,6 +680,8 @@ U_BOOT_DRIVER(sandbox_scmi_agent) = { .id = UCLASS_SCMI_AGENT, .of_match = sandbox_scmi_test_ids, .priv_auto = sizeof(struct sandbox_scmi_agent), + .plat_auto = sizeof(struct sandbox_channel), + .of_to_plat = sandbox_scmi_of_to_plat, .probe = sandbox_scmi_test_probe, .remove = sandbox_scmi_test_remove, .ops = &sandbox_scmi_test_ops,