From patchwork Wed Oct 11 10:06:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731918 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315233wrv; Wed, 11 Oct 2023 03:07:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJWPvC3aiipM+X9UfmPQDASfA+ukug0hCIuHzLBfnDo4JHyFb99czxUmCydBtSiN6hwt6G X-Received: by 2002:a5d:67c9:0:b0:321:5211:8e20 with SMTP id n9-20020a5d67c9000000b0032152118e20mr17373212wrw.59.1697018869881; Wed, 11 Oct 2023 03:07:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018869; cv=none; d=google.com; s=arc-20160816; b=kk3RCLHKHKfsq2nC05dcHulVom+vsH13BjFWHdHOXf13toDs+lFg2QJoEWkhrEa7CV t2CDs05IxAT0b3f6zQ7BZs4CoKf7ftFdCIYhMEPT8apULTipP9MNRvLOmaj22AnSXESY YhiCAwWePnUpshMIZ6RSytk79AWEcmB3OFaAcEHbyNQPOqHanBQtnAhEpxLUezrNljiI Fp97czdvhqfQQefwmM92OrTVUllHnVtT8YStKZWuXm8VJI24IRalFnGVT3JUrl1FZKaT alz5xBsWBqgtPamxS3s7h6e8II03CBB9QNBoZXecwNw4DMAE76N2v3MondaodmWewF4G MWxw== 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=Aeq5VDuothqtLHwhLqrA5oAGFjFITjlkK3Z4L9cq6tI=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=qxmqU+al9wcy6wzOO3D8rAP9bfwR1ftijyBUSLz5E9bprzausRg6FBTR8ElAx2w8Ol ZsrpYNMZuuK/uJ7iO6Du+J4VY8NxGLA+vC+00g3jGkRcWrZesjakeN2t06yCKKr8LH+m J4TIbiGJJXLqTyJtjJUIbsSAQBiUVJsgoyoMh7wB3JnX0qNYgzCHQoHOm5Q/QlFhYX7m a6idB6HozigFSxZhCVXkAcjXGR67JrAnSMCc/nX44dUH+uEttbNlaVr/yYOxUnmWMVco fc3CxhBT4GqsydZy78H8Q3jvCKO4t09rYXIi4Wa8HFMq9VuPeXjD/Q2fh0ncWnoytduV AiMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UTxQ8lvg; 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 f7-20020adff587000000b0032d82d5edcfsi860656wro.225.2023.10.11.03.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:49 -0700 (PDT) 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=UTxQ8lvg; 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 505A086D02; Wed, 11 Oct 2023 12:07:43 +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="UTxQ8lvg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C785D86CF6; Wed, 11 Oct 2023 12:07:41 +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-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) (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 84DE980834 for ; Wed, 11 Oct 2023 12:07:28 +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-x433.google.com with SMTP id d2e1a72fcca58-6a4ff9d7e86so634761b3a.0 for ; Wed, 11 Oct 2023 03:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018847; x=1697623647; 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=Aeq5VDuothqtLHwhLqrA5oAGFjFITjlkK3Z4L9cq6tI=; b=UTxQ8lvg6o2ZhPOXhhUXE+mdNtqb+1UtdSOJQzDSpxMQl+QFLo1yMY5UP/XnR3xAZN uFAxhck0wYmXiE+eSdTQbXoy/G4hysDZQRHkBW+dZbLGFJt4uaXUgUhXRgjAJAodNNW/ XX3MEIBdrkmV1dA7K5j74El/0ebAwNh0+EJfbMjdlV/ti/mk7fwIqo28zScntmQk/ybh ruIWWcta7gOoZEBUKOwDuagz+rYk1+LP0J1gCYqR+aQR2xvJHezY/i9b4yZ3jeTZslhN s/2iUV/XlazkuPTYG8nzt8rB/L0eZJVsYd3+dn7RfAMyUa9aFtIEW+mZa28fvkb8C3+Q mh8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018847; x=1697623647; 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=Aeq5VDuothqtLHwhLqrA5oAGFjFITjlkK3Z4L9cq6tI=; b=dQ4SVUSwOv6M2r33dlSxdPDrQS1NNaUke5IVjysBRF5+Yz14j5ff9B2R7uN7T42Kia MGlkHHQ5S0uB2XNN9+MmFD6Ekw4Vsor2thFE34r2HBmQk7LYKtRepDNsSEcbaMqvB235 hrP6axzXHKkvx0PggH2SlMZiRYYYZuYGb2DED1U185cn1IadqA4+XPnD9wuQQ4fpgnx5 D5UYwpllVrHQYQrQkIBN8vAlAuCCK+vlMlq+oBTWKSmuCETlSxdzUoyjhCoGJIqwf5ba ++dVHJ/6qBgUHw0yVTfjhkYr9cbHnGIqXBAp+HjwWJuZckg0DTGcZa3WWL9VDukl7leP AFpw== X-Gm-Message-State: AOJu0YzsK2WXXN9euGhAxnlOqvvNq8BuYsmFuI6NhHx0VDnps+oTlFng J2Um8dISPVzFDV7p2B2SmyzYPQhW54rqDXLUMVE6zA== X-Received: by 2002:a05:6a00:1d94:b0:690:d314:38d with SMTP id z20-20020a056a001d9400b00690d314038dmr23409309pfw.1.1697018846728; Wed, 11 Oct 2023 03:07:26 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:26 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 01/14] scmi: refactor the code to hide a channel from devices Date: Wed, 11 Oct 2023 19:06:54 +0900 Message-Id: <20231011100707.1007417-2-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 The commit 85dc58289238 ("firmware: scmi: prepare uclass to pass channel reference") added an explicit parameter, channel, but it seems to make the code complex. Hiding this parameter will allow for adding a generic (protocol-agnostic) helper function, i.e. for PROTOCOL_VERSION, in a later patch. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v5 * correct the size for per_child_auto v4 * revive scmi_bind_protocols which was accidentally removed * remove .per_child_auto from the driver declaration as it is not needed v3 * fix an issue on ST board (reported by Etienne) by taking care of cases where probed devices are children of SCMI protocol device (i.e. clock devices under CCF) See find_scmi_protocol_device(). * move "per_device_plato_auto" to a succeeding right patch v2 * new patch --- drivers/clk/clk_scmi.c | 27 ++---- drivers/firmware/scmi/scmi_agent-uclass.c | 105 ++++++++++++++++------ drivers/power/regulator/scmi_regulator.c | 26 ++---- drivers/reset/reset-scmi.c | 19 +--- include/scmi_agent.h | 15 ++-- 5 files changed, 104 insertions(+), 88 deletions(-) diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c index d172fed24c9d..34a49363a51a 100644 --- a/drivers/clk/clk_scmi.c +++ b/drivers/clk/clk_scmi.c @@ -13,17 +13,8 @@ #include #include -/** - * struct scmi_clk_priv - Private data for SCMI clocks - * @channel: Reference to the SCMI channel to use - */ -struct scmi_clk_priv { - struct scmi_channel *channel; -}; - static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) { - struct scmi_clk_priv *priv = dev_get_priv(dev); struct scmi_clk_protocol_attr_out out; struct scmi_msg msg = { .protocol_id = SCMI_PROTOCOL_ID_CLOCK, @@ -33,7 +24,7 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) }; int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret) return ret; @@ -44,7 +35,6 @@ static int scmi_clk_get_num_clock(struct udevice *dev, size_t *num_clocks) static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) { - struct scmi_clk_priv *priv = dev_get_priv(dev); struct scmi_clk_attribute_in in = { .clock_id = clkid, }; @@ -59,7 +49,7 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) }; int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret) return ret; @@ -70,7 +60,6 @@ static int scmi_clk_get_attibute(struct udevice *dev, int clkid, char **name) static int scmi_clk_gate(struct clk *clk, int enable) { - struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_state_in in = { .clock_id = clk->id, .attributes = enable, @@ -81,7 +70,7 @@ static int scmi_clk_gate(struct clk *clk, int enable) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret) return ret; @@ -100,7 +89,6 @@ static int scmi_clk_disable(struct clk *clk) static ulong scmi_clk_get_rate(struct clk *clk) { - struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_rate_get_in in = { .clock_id = clk->id, }; @@ -110,7 +98,7 @@ static ulong scmi_clk_get_rate(struct clk *clk) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret < 0) return ret; @@ -123,7 +111,6 @@ static ulong scmi_clk_get_rate(struct clk *clk) static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) { - struct scmi_clk_priv *priv = dev_get_priv(clk->dev); struct scmi_clk_rate_set_in in = { .clock_id = clk->id, .flags = SCMI_CLK_RATE_ROUND_CLOSEST, @@ -136,7 +123,7 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) in, out); int ret; - ret = devm_scmi_process_msg(clk->dev, priv->channel, &msg); + ret = devm_scmi_process_msg(clk->dev, &msg); if (ret < 0) return ret; @@ -149,12 +136,11 @@ static ulong scmi_clk_set_rate(struct clk *clk, ulong rate) static int scmi_clk_probe(struct udevice *dev) { - struct scmi_clk_priv *priv = dev_get_priv(dev); struct clk *clk; size_t num_clocks, i; int ret; - ret = devm_scmi_of_get_channel(dev, &priv->channel); + ret = devm_scmi_of_get_channel(dev); if (ret) return ret; @@ -205,5 +191,4 @@ U_BOOT_DRIVER(scmi_clock) = { .id = UCLASS_CLK, .ops = &scmi_clk_ops, .probe = scmi_clk_probe, - .priv_auto = sizeof(struct scmi_clk_priv *), }; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 02de692d66f3..ec58ccd2bc5d 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -110,18 +111,23 @@ static int scmi_bind_protocols(struct udevice *dev) return ret; } -static struct udevice *find_scmi_transport_device(struct udevice *dev) +static struct udevice *find_scmi_protocol_device(struct udevice *dev) { - struct udevice *parent = dev; + struct udevice *parent = NULL, *protocol; - do { - parent = dev_get_parent(parent); - } while (parent && device_get_uclass_id(parent) != UCLASS_SCMI_AGENT); + for (protocol = dev; protocol; protocol = parent) { + parent = dev_get_parent(protocol); + if (!parent || + device_get_uclass_id(parent) == UCLASS_SCMI_AGENT) + break; + } - if (!parent) + if (!parent) { dev_err(dev, "Invalid SCMI device, agent not found\n"); + return NULL; + } - return parent; + return protocol; } static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) @@ -129,43 +135,90 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) return (const struct scmi_agent_ops *)dev->driver->ops; } -int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) +/** + * scmi_of_get_channel() - Get SCMI channel handle + * + * @dev: SCMI agent device + * @channel: Output reference to the SCMI channel upon success + * + * On return, @channel will be set. + * Return 0 on success and a negative errno on failure + */ +static int scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) { - struct udevice *parent; + const struct scmi_agent_ops *ops; - parent = find_scmi_transport_device(dev); - if (!parent) + ops = transport_dev_ops(dev); + if (ops->of_get_channel) + return ops->of_get_channel(dev, channel); + else + return -EPROTONOSUPPORT; +} + +int devm_scmi_of_get_channel(struct udevice *dev) +{ + struct udevice *protocol; + struct scmi_agent_proto_priv *priv; + int ret; + + protocol = find_scmi_protocol_device(dev); + if (!protocol) return -ENODEV; - if (transport_dev_ops(parent)->of_get_channel) - return transport_dev_ops(parent)->of_get_channel(parent, channel); + priv = dev_get_parent_priv(protocol); + ret = scmi_of_get_channel(protocol->parent, &priv->channel); + if (ret == -EPROTONOSUPPORT) { + /* Drivers without a get_channel operator don't need a channel ref */ + priv->channel = NULL; - /* Drivers without a get_channel operator don't need a channel ref */ - *channel = NULL; + return 0; + } - return 0; + return ret; } -int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, - struct scmi_msg *msg) +/** + * scmi_process_msg() - Send and process an SCMI message + * + * Send a message to an SCMI server. + * Caller sets scmi_msg::out_msg_sz to the output message buffer size. + * + * @dev: SCMI agent device + * @channel: Communication channel for the device + * @msg: Message structure reference + * + * On return, scmi_msg::out_msg_sz stores the response payload size. + * Return: 0 on success and a negative errno on failure + */ +static int scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, + struct scmi_msg *msg) { const struct scmi_agent_ops *ops; - struct udevice *parent; - parent = find_scmi_transport_device(dev); - if (!parent) - return -ENODEV; + ops = transport_dev_ops(dev); + if (ops->process_msg) + return ops->process_msg(dev, channel, msg); + else + return -EPROTONOSUPPORT; +} - ops = transport_dev_ops(parent); +int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg) +{ + struct udevice *protocol; + struct scmi_agent_proto_priv *priv; - if (ops->process_msg) - return ops->process_msg(parent, channel, msg); + protocol = find_scmi_protocol_device(dev); + if (!protocol) + return -ENODEV; + + priv = dev_get_parent_priv(protocol); - return -EPROTONOSUPPORT; + return scmi_process_msg(protocol->parent, priv->channel, msg); } UCLASS_DRIVER(scmi_agent) = { .id = UCLASS_SCMI_AGENT, .name = "scmi_agent", .post_bind = scmi_bind_protocols, + .per_child_auto = sizeof(struct scmi_agent_proto_priv), }; diff --git a/drivers/power/regulator/scmi_regulator.c b/drivers/power/regulator/scmi_regulator.c index 801148036ff6..9c72c35d039e 100644 --- a/drivers/power/regulator/scmi_regulator.c +++ b/drivers/power/regulator/scmi_regulator.c @@ -25,18 +25,9 @@ struct scmi_regulator_platdata { u32 domain_id; }; -/** - * struct scmi_regulator_priv - Private data for SCMI voltage regulator - * @channel: Reference to the SCMI channel to use - */ -struct scmi_regulator_priv { - struct scmi_channel *channel; -}; - static int scmi_voltd_set_enable(struct udevice *dev, bool enable) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); - struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_config_set_in in = { .domain_id = pdata->domain_id, .config = enable ? SCMI_VOLTD_CONFIG_ON : SCMI_VOLTD_CONFIG_OFF, @@ -47,7 +38,7 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) in, out); int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret) return ret; @@ -57,7 +48,6 @@ static int scmi_voltd_set_enable(struct udevice *dev, bool enable) static int scmi_voltd_get_enable(struct udevice *dev) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); - struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_config_get_in in = { .domain_id = pdata->domain_id, }; @@ -67,7 +57,7 @@ static int scmi_voltd_get_enable(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -80,7 +70,6 @@ static int scmi_voltd_get_enable(struct udevice *dev) static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) { - struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_level_set_in in = { .domain_id = pdata->domain_id, @@ -92,7 +81,7 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) in, out); int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -101,7 +90,6 @@ static int scmi_voltd_set_voltage_level(struct udevice *dev, int uV) static int scmi_voltd_get_voltage_level(struct udevice *dev) { - struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_regulator_platdata *pdata = dev_get_plat(dev); struct scmi_voltd_level_get_in in = { .domain_id = pdata->domain_id, @@ -112,7 +100,7 @@ static int scmi_voltd_get_voltage_level(struct udevice *dev) in, out); int ret; - ret = devm_scmi_process_msg(dev, priv->channel, &msg); + ret = devm_scmi_process_msg(dev, &msg); if (ret < 0) return ret; @@ -140,7 +128,6 @@ static int scmi_regulator_of_to_plat(struct udevice *dev) static int scmi_regulator_probe(struct udevice *dev) { struct scmi_regulator_platdata *pdata = dev_get_plat(dev); - struct scmi_regulator_priv *priv = dev_get_priv(dev); struct scmi_voltd_attr_in in = { 0 }; struct scmi_voltd_attr_out out = { 0 }; struct scmi_msg scmi_msg = { @@ -153,14 +140,14 @@ static int scmi_regulator_probe(struct udevice *dev) }; int ret; - ret = devm_scmi_of_get_channel(dev->parent, &priv->channel); + ret = devm_scmi_of_get_channel(dev); if (ret) return ret; /* Check voltage domain is known from SCMI server */ in.domain_id = pdata->domain_id; - ret = devm_scmi_process_msg(dev, priv->channel, &scmi_msg); + ret = devm_scmi_process_msg(dev, &scmi_msg); if (ret) { dev_err(dev, "Failed to query voltage domain %u: %d\n", pdata->domain_id, ret); @@ -184,7 +171,6 @@ U_BOOT_DRIVER(scmi_regulator) = { .probe = scmi_regulator_probe, .of_to_plat = scmi_regulator_of_to_plat, .plat_auto = sizeof(struct scmi_regulator_platdata), - .priv_auto = sizeof(struct scmi_regulator_priv *), }; static int scmi_regulator_bind(struct udevice *dev) diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c index 122556162ec3..b76711f0a8fb 100644 --- a/drivers/reset/reset-scmi.c +++ b/drivers/reset/reset-scmi.c @@ -13,17 +13,8 @@ #include #include -/** - * struct scmi_reset_priv - Private data for SCMI reset controller - * @channel: Reference to the SCMI channel to use - */ -struct scmi_reset_priv { - struct scmi_channel *channel; -}; - static int scmi_reset_set_level(struct reset_ctl *rst, bool assert_not_deassert) { - struct scmi_reset_priv *priv = dev_get_priv(rst->dev); struct scmi_rd_reset_in in = { .domain_id = rst->id, .flags = assert_not_deassert ? SCMI_RD_RESET_FLAG_ASSERT : 0, @@ -35,7 +26,7 @@ static int scmi_reset_set_level(struct reset_ctl *rst, bool assert_not_deassert) in, out); int ret; - ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg); + ret = devm_scmi_process_msg(rst->dev, &msg); if (ret) return ret; @@ -54,7 +45,6 @@ static int scmi_reset_deassert(struct reset_ctl *rst) static int scmi_reset_request(struct reset_ctl *rst) { - struct scmi_reset_priv *priv = dev_get_priv(rst->dev); struct scmi_rd_attr_in in = { .domain_id = rst->id, }; @@ -68,7 +58,7 @@ static int scmi_reset_request(struct reset_ctl *rst) * We don't really care about the attribute, just check * the reset domain exists. */ - ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg); + ret = devm_scmi_process_msg(rst->dev, &msg); if (ret) return ret; @@ -83,9 +73,7 @@ static const struct reset_ops scmi_reset_domain_ops = { static int scmi_reset_probe(struct udevice *dev) { - struct scmi_reset_priv *priv = dev_get_priv(dev); - - return devm_scmi_of_get_channel(dev, &priv->channel); + return devm_scmi_of_get_channel(dev); } U_BOOT_DRIVER(scmi_reset_domain) = { @@ -93,5 +81,4 @@ U_BOOT_DRIVER(scmi_reset_domain) = { .id = UCLASS_RESET, .ops = &scmi_reset_domain_ops, .probe = scmi_reset_probe, - .priv_auto = sizeof(struct scmi_reset_priv *), }; diff --git a/include/scmi_agent.h b/include/scmi_agent.h index ee6286366df7..577892029ff8 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -15,6 +15,14 @@ struct udevice; struct scmi_channel; +/** + * struct scmi_agent_proto_priv - Private data in device for SCMI agent + * @channel: Reference to the SCMI channel to use + */ +struct scmi_agent_proto_priv { + struct scmi_channel *channel; +}; + /* * struct scmi_msg - Context of a SCMI message sent and the response received * @@ -49,10 +57,9 @@ struct scmi_msg { * devm_scmi_of_get_channel() - Get SCMI channel handle from SCMI agent DT node * * @dev: Device requesting a channel - * @channel: Output reference to the SCMI channel upon success * @return 0 on success and a negative errno on failure */ -int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel); +int devm_scmi_of_get_channel(struct udevice *dev); /** * devm_scmi_process_msg() - Send and process an SCMI message @@ -62,12 +69,10 @@ int devm_scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) * On return, scmi_msg::out_msg_sz stores the response payload size. * * @dev: SCMI device - * @channel: Communication channel for the device * @msg: Message structure reference * Return: 0 on success and a negative errno on failure */ -int devm_scmi_process_msg(struct udevice *dev, struct scmi_channel *channel, - struct scmi_msg *msg); +int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg); /** * scmi_to_linux_errno() - Convert an SCMI error code into a Linux errno code From patchwork Wed Oct 11 10:06:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731919 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315437wrv; Wed, 11 Oct 2023 03:08:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBsyEaqoZ0Zo/yH7iq6GouNcv0Z2DiAlWcuftoMtcPIK+AQTwdR3woMiS2Ob6zgfvdrJ78 X-Received: by 2002:a7b:cd85:0:b0:404:7670:90b8 with SMTP id y5-20020a7bcd85000000b00404767090b8mr19144052wmj.27.1697018895074; Wed, 11 Oct 2023 03:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018895; cv=none; d=google.com; s=arc-20160816; b=m1ugD+vO/0A9QSZ5huLW17hDd6gpMIraTlytIDI9lYWpN+u8Oyl8CkveRZQdNpCOPB TI6nxopS9pGCq2IGCunCSI9m4Jl2b/FroUMuPEM89Aorg35lSH2XCbvv4vL6fXVSTO+h NcSw8oblyd1woWQiZlL+/G1Nel0mCvHMoy1y8u7T+7ZBYqzS0QAqSRgC/keKR2t4e5yc u39SjN5hV0dDiWJNfIEv8bjsr+0bKCp2CAUsos7ouIGShfW59D5uC7M5h80yWv7JvFQY FgmLiM9J0m/1pCGcL9KSSrtUtQAJ8/sPwO0QRl+Hk6a6bWQfdFB5zR9Zr248Xu8vcjEE yuPg== 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=XMyS9Mv1/6J9CH/5Zv0yLlNhoVLQLPUWRVvbnhVVa8VzBwL+XjZzvwwi0M/Cafeone J0vYljvf1wFL0X3T7lw5rK27IwUyMJHJ4DInySbUKE48NyL5hMFObVf+o5n1r1S/eVmb lazztM6OlPNhD9NKUomSqVXQvmcAFM4x2ql4IHXOHCXCLwvKgO1bRynZkZNDk3YQjjWt tTPMnmm1MmkMYqZHGSLMarTqVMuiOwFVRh6c5ic17stQeBsIx+rciLAiuXue/IGMJbQ2 DIanZ0sNjFAQpV581Z6oiy2oAwr29xY3Gp8iVndx6EXlQAzyza9jw162eCq7Z/2vkGtI arQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pjq50QDA; 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 p7-20020a05600c2e8700b00401fbd5c687si7367252wmn.206.2023.10.11.03.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:08:15 -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=Pjq50QDA; 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 CF51F86D3D; Wed, 11 Oct 2023 12:07:43 +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="Pjq50QDA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F7BD80834; Wed, 11 Oct 2023 12:07:42 +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-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 BF55F86CFD for ; Wed, 11 Oct 2023 12:07:30 +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-oo1-xc2d.google.com with SMTP id 006d021491bc7-57bf04841ccso1417466eaf.0 for ; Wed, 11 Oct 2023 03:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018849; x=1697623649; 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; b=Pjq50QDAXcu9bsk1NPSEvC6N0Jydr9C55BFhNAHXEM0nAkcFvf2z3o1NvA555Xqji/ XvWkkwAYGEVzcDgNxcNwYT8hgV78kAmS9Qq85ZGGYw2wvHpTDm99H+ErYHAPR+Vpzxrt n+OYiOCdYFSor/bOLXenU+jDWniTPV773cTtI7WW4joSEAXwX5PjrKHTDqtyNYS1xk+y NfZ8UXyEfjXEOPrpYmtyNWO40PyVwBhUxZDw6xNc1QpJyKcoSn4I78AVbqwPu7s7FIGC PsiLgDaemxAGss0F4l7d9neQTeAi5jBVlwvn6EDo+Lm/kAz9gttYkna0B7/eBzsxOxLx 8ttg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018849; x=1697623649; 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=bDu7bAvkhNecfz3m6azvakeg84FYjWil9+D/bGFqSDQ=; b=cxqzr1oI4eWKVxIBNhhK/gqROuftOujatWoQ497nTbFtPevPDLitZ/1KPmTx1tEcMP YP4yb1/yerPY2b7swThtMVhMzcck12af9q+iWw+RFu+rXRixBkibEmhT0Y8geq7xXIc7 uw/evRH/URG96ZOhWKGRns766ANgUtfliihPteh/Upk60NBGQoxVvxO5NjHy5jzqY5oX 7m77mNTdZ90SOeWRBoAP7WIcYSH0VwhROQqIfFsXbOL1GPWlxQm/Dr84t08CXXHJyf9d fQxEIl2YEJWINmlmyRJuAr0VWuzGCE4RLPtmfzaz6+B+jIr0N+0M8kH0hJhNKKNwIZFt lyJQ== X-Gm-Message-State: AOJu0YzTOYQM2QIuwinnahH0ELawSOx7r8PvoxXguJMob7PXs/8H5utw 3EWnZAxS7gGmJ17ZB6HXSzvdZYx4sJRflQSFLYl2VQ== X-Received: by 2002:a05:6359:203:b0:15b:73a6:3ce8 with SMTP id ej3-20020a056359020300b0015b73a63ce8mr18098753rwb.2.1697018848911; Wed, 11 Oct 2023 03:07:28 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:28 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 02/14] firmware: scmi: use a protocol's own channel if assigned Date: Wed, 11 Oct 2023 19:06:55 +0900 Message-Id: <20231011100707.1007417-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 SCMI specification allows any protocol to have its own channel for the transport. While the current SCMI driver may assign its channel from a device tree, the core function, devm_scmi_process_msg(), doesn't use a protocol's channel, but always use an agent's channel. With this commit, devm_scmi_process_msg() tries to find and use a protocol's channel. If it doesn't exist, use an agent's. Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere Reviewed-by: Simon Glass --- v5 * new commit (fixing a potential bug) --- drivers/firmware/scmi/mailbox_agent.c | 5 +++-- drivers/firmware/scmi/optee_agent.c | 5 +++-- drivers/firmware/scmi/scmi_agent-uclass.c | 7 ++++--- drivers/firmware/scmi/smccc_agent.c | 5 +++-- include/scmi_agent-uclass.h | 8 +++++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/scmi/mailbox_agent.c b/drivers/firmware/scmi/mailbox_agent.c index 8277c1860606..7ad3e8da9f08 100644 --- a/drivers/firmware/scmi/mailbox_agent.c +++ b/drivers/firmware/scmi/mailbox_agent.c @@ -94,13 +94,14 @@ static int setup_channel(struct udevice *dev, struct scmi_mbox_channel *chan) } static int scmi_mbox_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_mbox_channel *base_chan = dev_get_plat(dev); struct scmi_mbox_channel *chan; int ret; - if (!dev_read_prop(dev, "shmem", NULL)) { + if (!dev_read_prop(protocol, "shmem", NULL)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -112,7 +113,7 @@ static int scmi_mbox_get_channel(struct udevice *dev, return -ENOMEM; /* Setup a dedicated channel for the protocol */ - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/drivers/firmware/scmi/optee_agent.c b/drivers/firmware/scmi/optee_agent.c index db927fb21405..e3e462774045 100644 --- a/drivers/firmware/scmi/optee_agent.c +++ b/drivers/firmware/scmi/optee_agent.c @@ -324,6 +324,7 @@ static int setup_channel(struct udevice *dev, struct scmi_optee_channel *chan) } static int scmi_optee_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_optee_channel *base_chan = dev_get_plat(dev); @@ -331,7 +332,7 @@ static int scmi_optee_get_channel(struct udevice *dev, u32 channel_id; int ret; - if (dev_read_u32(dev, "linaro,optee-channel-id", &channel_id)) { + if (dev_read_u32(protocol, "linaro,optee-channel-id", &channel_id)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -343,7 +344,7 @@ static int scmi_optee_get_channel(struct udevice *dev, if (!chan) return -ENOMEM; - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index ec58ccd2bc5d..a28692f39f4d 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -144,13 +144,14 @@ static const struct scmi_agent_ops *transport_dev_ops(struct udevice *dev) * On return, @channel will be set. * Return 0 on success and a negative errno on failure */ -static int scmi_of_get_channel(struct udevice *dev, struct scmi_channel **channel) +static int scmi_of_get_channel(struct udevice *dev, struct udevice *protocol, + struct scmi_channel **channel) { const struct scmi_agent_ops *ops; ops = transport_dev_ops(dev); if (ops->of_get_channel) - return ops->of_get_channel(dev, channel); + return ops->of_get_channel(dev, protocol, channel); else return -EPROTONOSUPPORT; } @@ -166,7 +167,7 @@ int devm_scmi_of_get_channel(struct udevice *dev) return -ENODEV; priv = dev_get_parent_priv(protocol); - ret = scmi_of_get_channel(protocol->parent, &priv->channel); + ret = scmi_of_get_channel(protocol->parent, protocol, &priv->channel); if (ret == -EPROTONOSUPPORT) { /* Drivers without a get_channel operator don't need a channel ref */ priv->channel = NULL; diff --git a/drivers/firmware/scmi/smccc_agent.c b/drivers/firmware/scmi/smccc_agent.c index 6a52cd75d67b..972c6addde21 100644 --- a/drivers/firmware/scmi/smccc_agent.c +++ b/drivers/firmware/scmi/smccc_agent.c @@ -81,6 +81,7 @@ static int setup_channel(struct udevice *dev, struct scmi_smccc_channel *chan) } static int scmi_smccc_get_channel(struct udevice *dev, + struct udevice *protocol, struct scmi_channel **channel) { struct scmi_smccc_channel *base_chan = dev_get_plat(dev); @@ -88,7 +89,7 @@ static int scmi_smccc_get_channel(struct udevice *dev, u32 func_id; int ret; - if (dev_read_u32(dev, "arm,smc-id", &func_id)) { + if (dev_read_u32(protocol, "arm,smc-id", &func_id)) { /* Uses agent base channel */ *channel = container_of(base_chan, struct scmi_channel, ref); @@ -100,7 +101,7 @@ static int scmi_smccc_get_channel(struct udevice *dev, if (!chan) return -ENOMEM; - ret = setup_channel(dev, chan); + ret = setup_channel(protocol, chan); if (ret) { free(chan); return ret; diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index b1c93532c0ea..eee46c880a56 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -16,16 +16,18 @@ struct scmi_agent_ops { /* * of_get_channel - Get SCMI channel from SCMI agent device tree node * - * @dev: SCMI protocol device using the transport + * @dev: SCMI agent device using the transport + * @protocol: SCMI protocol device using the transport * @channel: Output reference to SCMI channel upon success * Return 0 upon success and a negative errno on failure */ - int (*of_get_channel)(struct udevice *dev, struct scmi_channel **channel); + int (*of_get_channel)(struct udevice *dev, struct udevice *protocol, + struct scmi_channel **channel); /* * process_msg - Request transport to get the SCMI message processed * - * @dev: SCMI protocol device using the transport + * @dev: SCMI agent device using the transport * @msg: SCMI message to be transmitted */ int (*process_msg)(struct udevice *dev, struct scmi_channel *channel, From patchwork Wed Oct 11 10:06:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731922 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315941wrv; Wed, 11 Oct 2023 03:09:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG37lz1UxSG0cEDXihREVDjhzM01ugBKvtbbSj+cUj5leoh7Y889jszaXhXNnpeWKogdysY X-Received: by 2002:a5d:6b4b:0:b0:323:1ded:311f with SMTP id x11-20020a5d6b4b000000b003231ded311fmr14585458wrw.25.1697018961900; Wed, 11 Oct 2023 03:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018961; cv=none; d=google.com; s=arc-20160816; b=fEVzuqnXRU9ElLucY+nKRqDCbp2dEBtj5JcRMuJEwFA1NDiiY3BPFdNrIdyOGe3Wep nUHepPHoLIUa+93w2VwwCQKR1ldXhTSQjthlstoUfuFVlRayLoZma+2O/yc4JWPB6D6V Zdp5dG7wCMlBUaJkbSSLJVOl8AHvwlsSW5dmM2bW4iwE54ZTwtxFIhDgJ4Hukyv9zbNl Q1WisE3eMOTLc++Si4GWtdapUzPp4c3XLPXpNoc6enPNM2/PySUXmrQV+Ew8p9pd7mOX ql3VIus7EEyLNZ5BR/lLqk3LA2BkBvMp4HmYaRMHOZMElrIFzP/s2rG/H9WAbbRjuzZh 0pag== 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=E9niEcLvTFyojjLWMgGyRta4gakIEX/Uqr4ljUUPhKU=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=cIGo+ceFxhsH8IIX4nRsv93Jiod3JCUGhDZbVSJINBC9ypU7rWAwZe8huYKxr51m5/ Jxzvzz9g4m7QhKKck+gA9aI4a9qZjSiGtDLbLDud9BePioWH2oosvp6ZUtPE9X4zhPP1 F/lMfYc7mzSrodU195ai7xyBOxYShIUp+4UV1IM2F56O+Hfc0nF7uz8F4+YJMJJNXpuk EuCR9jUD9atwr6NAxFYs1+0/F1VVtkXOzI4/l6oxqJiINR1iQ9ctsMV445c+XuLeKFMo uXnp5wtaZcWAdO3gf/HWjW3nloVlajOHsa5JOakbuvq0py5sSZyTp3WJ0ailUJzElkse 4Izw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FQa9uXNJ; 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 i12-20020a05600c354c00b003feed91ad26si8845109wmq.184.2023.10.11.03.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:09:21 -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=FQa9uXNJ; 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 D255F86DC7; Wed, 11 Oct 2023 12:07:57 +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="FQa9uXNJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 27AE386D12; Wed, 11 Oct 2023 12:07:54 +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-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) (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 938BB86CF6 for ; Wed, 11 Oct 2023 12:07:42 +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-oi1-x233.google.com with SMTP id 5614622812f47-3a707bc2397so977800b6e.0 for ; Wed, 11 Oct 2023 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018851; x=1697623651; 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=E9niEcLvTFyojjLWMgGyRta4gakIEX/Uqr4ljUUPhKU=; b=FQa9uXNJvMdHqYDz8O1H1zS2pYI+/y09fviwuosMPVua2oR/BHYVfvXmnt+XRe1tIy qCQbTJAoM5AHOctquTybroZdkdP8saqJ9xD6+Kt0TWqz2NOQJw04FI2g+90uKTPVM5vI YdCXZ5Sz/e539Vzu2y+ox/+OZM/KH2tLoi9fBeyLQH3z8tnlRVdd7BL1QbNMtfmVztP3 k/sgSLcjIsXV8COMQunHA/bWyPnQj2/hWR5ETAR6hai7G3xo37w66stRVazc1p2fYNyH jSci77Hr556uvkkXwFrowMSADHIrkU6G4NyM6wHtEptYzrHFmYaZ1g4pcI6eLW2NisqC Y9GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018851; x=1697623651; 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=E9niEcLvTFyojjLWMgGyRta4gakIEX/Uqr4ljUUPhKU=; b=EvcdBUSuUMsS5fjV41da2iaDZuS1321nocd813toZo9L64uR/g11O3/3Vb9JEEIPVS vkGccOSMEL8IVW+YQ5B389VBJs0iLZYYJ5nbS4ZufkLprR0O35HY80KY7z8McKNt1Dat vcHZ9Ub8EdTuMBJp0UIzzfAyBPoa83LEvWD+vqitm+8bZ5od6iau4UIhobwbwEd2fP+2 vqjlId90aN1RGJsCtk6P0HnLGRQ3Xyv35zMPMbBUCHmK0PHrcIxO1ZMoAwuvw7w00kFf rJAA13tK56GG0IJFJY3zC7Jqw9qocw/Z2YOs/ZTxcKfAYvD1TsK22RF4MktWvvqfeUjr Nbyw== X-Gm-Message-State: AOJu0Yw8lEGAy3pk6Uh/oxD02dlkaYRGg1xYAw0jE4b1fldmGlYlMXxw zVBuMvS/gV8nCSqsxdUzcifU1w== X-Received: by 2002:a05:6359:b9a:b0:147:eb87:3665 with SMTP id gf26-20020a0563590b9a00b00147eb873665mr16337030rwb.3.1697018851163; Wed, 11 Oct 2023 03:07:31 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:30 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 03/14] firmware: scmi: support dummy channels for sandbox agent Date: Wed, 11 Oct 2023 19:06:56 +0900 Message-Id: <20231011100707.1007417-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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, From patchwork Wed Oct 11 10:06:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731925 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp316652wrv; Wed, 11 Oct 2023 03:11:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEeqmUX3L9BmuyJNiBnNB7N0WYYMcNRjQmwsmx+ko4Ntjg4RjI7MS55kGOgWYik9kWzpb3Z X-Received: by 2002:a7b:ca54:0:b0:405:3885:490a with SMTP id m20-20020a7bca54000000b004053885490amr18368103wml.0.1697019061824; Wed, 11 Oct 2023 03:11:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019061; cv=none; d=google.com; s=arc-20160816; b=HjrLZaOjj8OQ5IvCOQezeyc7qjriRYh3U7eoWRTHPMMSjQKp+V63aJ8aeYbr1Dn6VR 4OttQgU5cHX6WndGLEtZYJeFFBUEHzAidysuqdXErUP131ELR1JyX5O8P13Z5CppfA9R cP1TGBchyU+T3Pk/Gw2gpISXJ2xokquas0v9c6gfruHasD7d5aGBCsEz4nsYmk9+dD8f Eu/UbeRH9IVeDyKHnJVtcCstduefNqm4/tDrIL8aU3246/0Did3zsZXdmAFA3NENUIq9 9W6GvhfAFhwUjnFXnL/ElwyxlmlpNzS20muSEpE/gQJLdT5Ydj31frROSGOLxfxJATbx lsWA== 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=pCRhEiNZjXNhx0qdWTCaYuD1CA83EGtZrc+sEunGweE=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=F25cAXQrp1u7OV0RAXYh2xc8+CJdLKnQOVnjdrmtoD/Jsik2mHixLpEoQcVFVEtRDL AHCdDyxX5PNg4xpAIpAsptIATijyq41QFWkszbObFTs//4rBvyoR6LdPVD9iMEQBXflW 2pXcbd/qdNiJN2eCKrSmI2F40D0BDX2fL34oYaF53z52WDOQS1uqMFMHdZJ7yYjNo8FI sWrQFDVXXrMTvquNklHvWhSFpiS/PP5qMd6T4ndmjVGgx/1fdkr3NRVZ6TJ75hTPDiCQ CPrx4+0r5zyzKlYKxkELNjJJH6WhA32z718doRXVBQtrDBziHatEat/6X2tYH3Jy6ivZ yp0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HkxfjMHM; 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 jh1-20020a05600ca08100b00401bbfba12esi8531802wmb.234.2023.10.11.03.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:11:01 -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=HkxfjMHM; 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 1385686D0B; Wed, 11 Oct 2023 12:08:14 +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="HkxfjMHM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AD6F886591; Wed, 11 Oct 2023 12:08:05 +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=unavailable autolearn_force=no version=3.4.2 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 9384286591 for ; Wed, 11 Oct 2023 12:07:42 +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-oi1-x236.google.com with SMTP id 5614622812f47-3af59a017a5so1172021b6e.1 for ; Wed, 11 Oct 2023 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018853; x=1697623653; 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=pCRhEiNZjXNhx0qdWTCaYuD1CA83EGtZrc+sEunGweE=; b=HkxfjMHMDdBLhBlta1fFmf4E0D8NjMvCPKBTVzzkXiFDkUB/DPW6C9mhHTQdtJIhYe B2IM4vWB2ND37yk+o++Ie5MR+qjouViPx4Hj4UKEaI0bzgGACw9pCxHv9Xm2T3H1eKkp h4r0tN+x1uA7FhlcAdsw502Ce1MXVBG5zulWvTI37GdUoQRiNl5pqTHE5/fvga+uI4Ar mrEtJ/4I5AyCtZi016rIKHiYyB6c6S1EKtoOd5lub+GIBc2E3WsJdM1pmWnY+OBN/WcD aedzt7JC/NR1mXuAAtph12c8Bp5+wSuytSKwwANZRnN6Eu6Gu0cPmmhR4Va9UHWufecT lJhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018853; x=1697623653; 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=pCRhEiNZjXNhx0qdWTCaYuD1CA83EGtZrc+sEunGweE=; b=cY4j+hfjQvgY82/bZXXbN/i9SKdDUFP4wbzSjZTZp9rUugqbyWBAMEYHeDH24GgMqk l+MFtQg2T0MMg61H/cFUpw6+0OrLDrBIUoKsjFGnVStg2RXrjMpM45BuTGtF8/Ct0BNg 5iITBs/CVai/RLj3BiPij9szg/QXSGr5cZs1nQf/kPYlW1lvrpwh8wwxH7tUw8zBDCx8 0k1cJ79My5P/UPwYEL29KiLFJVbc7lGxhHZqP3i5TpEKEhuEGeYmBQt3mHZdfiWfKCsB ATrP6i3OYqJrKGAiAQB2nFz/XgFPV8SNd5BiR4rSalokmS6XwmGeKvSLqw7ThbkMLvbp BZVw== X-Gm-Message-State: AOJu0YxnsGBB0HjbQoy1QjcRAggQlkEA7sFMRJG5OjhGt3DhgSgq7kIG NtnQHUAWZa7OKqSpZjNhMRAm3g== X-Received: by 2002:a05:6358:e908:b0:147:47f2:2d54 with SMTP id gk8-20020a056358e90800b0014747f22d54mr16670058rwb.0.1697018853124; Wed, 11 Oct 2023 03:07:33 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:32 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 04/14] firmware: scmi: move scmi_bind_protocols() backward Date: Wed, 11 Oct 2023 19:06:57 +0900 Message-Id: <20231011100707.1007417-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Move the location of scmi_bind_protocols() backward for changes in later patches. There is no change in functionality. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v4 * remove scmi_bind_protocols() from the original place. See patch#1 * s/depeding/depending/ --- drivers/firmware/scmi/scmi_agent-uclass.c | 118 +++++++++++----------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index a28692f39f4d..1fa1e9eef966 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -52,65 +52,6 @@ int scmi_to_linux_errno(s32 scmi_code) return -EPROTO; } -/* - * SCMI agent devices binds devices of various uclasses depeding on - * the FDT description. scmi_bind_protocol() is a generic bind sequence - * called by the uclass at bind stage, that is uclass post_bind. - */ -static int scmi_bind_protocols(struct udevice *dev) -{ - int ret = 0; - ofnode node; - const char *name; - - dev_for_each_subnode(node, dev) { - struct driver *drv = NULL; - u32 protocol_id; - - if (!ofnode_is_enabled(node)) - continue; - - if (ofnode_read_u32(node, "reg", &protocol_id)) - continue; - - name = ofnode_get_name(node); - switch (protocol_id) { - case SCMI_PROTOCOL_ID_CLOCK: - if (CONFIG_IS_ENABLED(CLK_SCMI)) - drv = DM_DRIVER_GET(scmi_clock); - break; - case SCMI_PROTOCOL_ID_RESET_DOMAIN: - if (IS_ENABLED(CONFIG_RESET_SCMI)) - drv = DM_DRIVER_GET(scmi_reset_domain); - break; - case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: - if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) { - node = ofnode_find_subnode(node, "regulators"); - if (!ofnode_valid(node)) { - dev_err(dev, "no regulators node\n"); - return -ENXIO; - } - drv = DM_DRIVER_GET(scmi_voltage_domain); - } - break; - default: - break; - } - - if (!drv) { - dev_dbg(dev, "Ignore unsupported SCMI protocol %#x\n", - protocol_id); - continue; - } - - ret = device_bind(dev, drv, name, NULL, node, NULL); - if (ret) - break; - } - - return ret; -} - static struct udevice *find_scmi_protocol_device(struct udevice *dev) { struct udevice *parent = NULL, *protocol; @@ -217,6 +158,65 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg) return scmi_process_msg(protocol->parent, priv->channel, msg); } +/* + * SCMI agent devices binds devices of various uclasses depending on + * the FDT description. scmi_bind_protocol() is a generic bind sequence + * called by the uclass at bind stage, that is uclass post_bind. + */ +static int scmi_bind_protocols(struct udevice *dev) +{ + int ret = 0; + ofnode node; + const char *name; + + dev_for_each_subnode(node, dev) { + struct driver *drv = NULL; + u32 protocol_id; + + if (!ofnode_is_enabled(node)) + continue; + + if (ofnode_read_u32(node, "reg", &protocol_id)) + continue; + + name = ofnode_get_name(node); + switch (protocol_id) { + case SCMI_PROTOCOL_ID_CLOCK: + if (CONFIG_IS_ENABLED(CLK_SCMI)) + drv = DM_DRIVER_GET(scmi_clock); + break; + case SCMI_PROTOCOL_ID_RESET_DOMAIN: + if (IS_ENABLED(CONFIG_RESET_SCMI)) + drv = DM_DRIVER_GET(scmi_reset_domain); + break; + case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) { + node = ofnode_find_subnode(node, "regulators"); + if (!ofnode_valid(node)) { + dev_err(dev, "no regulators node\n"); + return -ENXIO; + } + drv = DM_DRIVER_GET(scmi_voltage_domain); + } + break; + default: + break; + } + + if (!drv) { + dev_dbg(dev, "Ignore unsupported SCMI protocol %#x\n", + protocol_id); + continue; + } + + ret = device_bind(dev, drv, name, NULL, node, NULL); + if (ret) + break; + } + + return ret; +} + UCLASS_DRIVER(scmi_agent) = { .id = UCLASS_SCMI_AGENT, .name = "scmi_agent", From patchwork Wed Oct 11 10:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731920 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315536wrv; Wed, 11 Oct 2023 03:08:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDCaXcVUDaRyyCqVps4BXxhq+uqg450LKasfvUlAhx4UciX/+TPIscWUcZ1UnReSWAAYG2 X-Received: by 2002:a5d:4449:0:b0:323:31a6:c1db with SMTP id x9-20020a5d4449000000b0032331a6c1dbmr14873376wrr.21.1697018911208; Wed, 11 Oct 2023 03:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018911; cv=none; d=google.com; s=arc-20160816; b=oLMwlTmSMDWwHhcBKA+Lw9VS2ujSvrdDx+p2nPtdNeed8uOzh46bD7ADpiQ1Fa6pPM T/jOCyP6WTJHIXyaQhHsEHnONQAOODlT63ldnZ7aUmbwVv7SpTOT3qfefIt4DG/hZHO1 D6qdLMXFuzQ3TyQjyVo/AYX1iW1gcr2t+sYDmqODBFsyE/XL1qOGw1gBlaqMRWiJ2o5w nk6dYCobpABDf+oIBqb0bhg1zO0zYy2Wl8jHpXc+tG91WS7vcgQPybzHHmBJ4QFDuGL7 7Pi5+c6q4bLz5WGfVa38VLtoAKxYTKC7mJmM+BSoRGmlhvtcjaiuQ+CE8F6/NiZA/D9d rtGA== 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=/oj53KjJfNhldfcxUVxj9tMYDMweOvK4DG03MksuRKE=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=uLUxDyuUNzebs0rUgxjpE8OCpV54DeO3b//6p0Kt1CZQt0R4wI2FZYYZo6DPsyCGur CBJlY5JwgNuBtCd0u2TR4B+zYcYjgYvUYZDi974yxc5lGl5LlJjYXWj6TYNxfDQXC3+7 +O2HhQnq78uk2RGvbn8mJzRgGMWEGqnjarAOsu6mfEDyHEqACBwS93qobArSAenkk8AP wdB2RCcz7R97e0LcHsc8rfhH+yW/bT6ktxVh7nGoGkbU9IMrqhrJJiOR7O2Y5mCMRlBN BAwYXVxIIXutNSKMPzUF8s+2IUYxh3B+dU+9rQLA70cggI+RlAu3Oyl6jvlu3UC6VWvl gYPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jbjiH+lw; 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 n18-20020adff092000000b003233a22b9c8si5529930wro.35.2023.10.11.03.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:08:31 -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=jbjiH+lw; 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 2090786D0A; Wed, 11 Oct 2023 12:07:54 +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="jbjiH+lw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 42E3C86D05; Wed, 11 Oct 2023 12:07:49 +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-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (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 9340380834 for ; Wed, 11 Oct 2023 12:07:42 +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-oi1-x22c.google.com with SMTP id 5614622812f47-3ae473c0bd6so1173526b6e.0 for ; Wed, 11 Oct 2023 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018855; x=1697623655; 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=/oj53KjJfNhldfcxUVxj9tMYDMweOvK4DG03MksuRKE=; b=jbjiH+lwCM6Xtp1U/kdN+/KaUE7oOls2TThvCChKNel+j+A6+jEDOad05Vle246sli 8JYxA4ubd1xT8xEwoZeW4dYQ0b1G+HmU3xFze2sQoPsthFC7M456OMJIxQ0vGENmFF7X za9AoQsnF8m6caprIgAuXegMLbA8SJsEMhXOiRFgd6sppiX56oxwscKKyE9JRflwTEAM rLRb+CUfT/PqIGeSATzBjDsC4S5D/xgPyZnrDv+DvmK05gTs2S1PRT1vdy3Tmiqefnjo Lba2VghEqSKIv4VjO+tmfhu2Zn71qn6HFDO4a0ji94xu5BM22Kl+0p1WkTLT78sM+njA MrLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018855; x=1697623655; 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=/oj53KjJfNhldfcxUVxj9tMYDMweOvK4DG03MksuRKE=; b=rTknk1VZ0KEcv59PTtr5LFzHBNJt0tI9SVIrpLYEWOwkuKRdA+JqR+vfbs2yXbqFHC X2UpOhDVVZEP/KQ+TNxk5poCMF+hHp1Fea8D96paAhApfcY5gWiyZvJjACNtXwabhMIU K7WQ8frVpXwTUwMtn5+yFVkdwpXuqWK3XByICdELYT1LLPX5hEQw64yy9IBGOofzqG0o is1tYBRcu5TkLGNKjIjruw084EBZ8hsQb22y/ItTBFnUTCQyg8B40IyyaOqg4Ne4v2+S EDC0vPW/zPzkm3vnxMTaaJWGY3tuDSu8jAn3LbynYrKxlRRy6nxG991JLW9B9F483bzs Kvog== X-Gm-Message-State: AOJu0YwgYbbQSt9zfwP+zS4N3oCWhD1OgmcWFvZE2HCyWguL51nPW1V0 oYEWzwjpoR6MqicRp5SpMIOQew== X-Received: by 2002:a05:6358:e908:b0:147:47f2:2d54 with SMTP id gk8-20020a056358e90800b0014747f22d54mr16670157rwb.0.1697018855363; Wed, 11 Oct 2023 03:07:35 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:35 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 05/14] firmware: scmi: framework for installing additional protocols Date: Wed, 11 Oct 2023 19:06:58 +0900 Message-Id: <20231011100707.1007417-6-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 This framework allows SCMI protocols to be installed and bound to the agent so that the agent can manage and utilize them later. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v6 * remove global 'scmi_agent' variable which is never used v4 * remove 'agent' variable as it should be added in the following commit v3 * move "per_device_plat_auto" from a earlier patch * fix comments in "scmi_agent_priv" * modify an order of include files in scmi_agent.h v2 * check for availability of protocols --- drivers/firmware/scmi/scmi_agent-uclass.c | 91 ++++++++++++++++++++++- include/scmi_agent-uclass.h | 15 +++- include/scmi_agent.h | 14 ++++ 3 files changed, 116 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index 1fa1e9eef966..b4d008835180 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -38,6 +38,80 @@ static const struct error_code scmi_linux_errmap[] = { { .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, }, }; +struct udevice *scmi_get_protocol(struct udevice *dev, + enum scmi_std_protocol id) +{ + struct scmi_agent_priv *priv; + struct udevice *proto; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return NULL; + } + + switch (id) { + case SCMI_PROTOCOL_ID_CLOCK: + proto = priv->clock_dev; + break; + case SCMI_PROTOCOL_ID_RESET_DOMAIN: + proto = priv->resetdom_dev; + break; + case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + proto = priv->voltagedom_dev; + break; + default: + dev_err(dev, "Protocol not supported\n"); + proto = NULL; + break; + } + if (proto && device_probe(proto)) + dev_err(dev, "Probe failed\n"); + + return proto; +} + +/** + * scmi_add_protocol - add protocol to agent + * @dev: SCMI agent device + * @proto_id: SCMI protocol ID + * @proto: SCMI protocol device + * + * Associate the protocol instance, @proto, to the agent, @dev, + * for later use. + * + * Return: 0 on success, error code on failure + */ +static int scmi_add_protocol(struct udevice *dev, + enum scmi_std_protocol proto_id, + struct udevice *proto) +{ + struct scmi_agent_priv *priv; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return -ENODEV; + } + + switch (proto_id) { + case SCMI_PROTOCOL_ID_CLOCK: + priv->clock_dev = proto; + break; + case SCMI_PROTOCOL_ID_RESET_DOMAIN: + priv->resetdom_dev = proto; + break; + case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: + priv->voltagedom_dev = proto; + break; + default: + dev_err(dev, "Protocol not supported\n"); + return -EPROTO; + } + + return 0; +} + int scmi_to_linux_errno(s32 scmi_code) { int n; @@ -168,9 +242,10 @@ static int scmi_bind_protocols(struct udevice *dev) int ret = 0; ofnode node; const char *name; + struct driver *drv; + struct udevice *proto; dev_for_each_subnode(node, dev) { - struct driver *drv = NULL; u32 protocol_id; if (!ofnode_is_enabled(node)) @@ -179,6 +254,7 @@ static int scmi_bind_protocols(struct udevice *dev) if (ofnode_read_u32(node, "reg", &protocol_id)) continue; + drv = NULL; name = ofnode_get_name(node); switch (protocol_id) { case SCMI_PROTOCOL_ID_CLOCK: @@ -209,9 +285,17 @@ static int scmi_bind_protocols(struct udevice *dev) continue; } - ret = device_bind(dev, drv, name, NULL, node, NULL); - if (ret) + ret = device_bind(dev, drv, name, NULL, node, &proto); + if (ret) { + dev_err(dev, "failed to bind %s protocol\n", drv->name); break; + } + ret = scmi_add_protocol(dev, protocol_id, proto); + if (ret) { + dev_err(dev, "failed to add protocol: %s, ret: %d\n", + proto->name, ret); + break; + } } return ret; @@ -221,5 +305,6 @@ UCLASS_DRIVER(scmi_agent) = { .id = UCLASS_SCMI_AGENT, .name = "scmi_agent", .post_bind = scmi_bind_protocols, + .per_device_plat_auto = sizeof(struct scmi_agent_priv), .per_child_auto = sizeof(struct scmi_agent_proto_priv), }; diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index eee46c880a56..258aa0f37596 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -5,10 +5,23 @@ #ifndef _SCMI_AGENT_UCLASS_H #define _SCMI_AGENT_UCLASS_H -struct udevice; +#include + struct scmi_msg; struct scmi_channel; +/** + * struct scmi_agent_priv - private data maintained by agent instance + * @clock_dev: SCMI clock protocol device + * @resetdom_dev: SCMI reset domain protocol device + * @voltagedom_dev: SCMI voltage domain protocol device + */ +struct scmi_agent_priv { + struct udevice *clock_dev; + struct udevice *resetdom_dev; + struct udevice *voltagedom_dev; +}; + /** * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. */ diff --git a/include/scmi_agent.h b/include/scmi_agent.h index 577892029ff8..755986d6c424 100644 --- a/include/scmi_agent.h +++ b/include/scmi_agent.h @@ -10,6 +10,7 @@ #ifndef SCMI_AGENT_H #define SCMI_AGENT_H +#include #include struct udevice; @@ -74,6 +75,19 @@ int devm_scmi_of_get_channel(struct udevice *dev); */ int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg); +/** + * scmi_get_protocol() - get protocol instance + * + * @dev: SCMI agent device + * @id: SCMI protocol ID + * + * Obtain the device instance for given protocol ID, @id. + * + * Return: Pointer to the device if found, null otherwise + */ +struct udevice *scmi_get_protocol(struct udevice *dev, + enum scmi_std_protocol id); + /** * scmi_to_linux_errno() - Convert an SCMI error code into a Linux errno code * From patchwork Wed Oct 11 10:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731923 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp316177wrv; Wed, 11 Oct 2023 03:09:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG+XYlveOC7jp2JfgkF1JdT/ohqfXV8rcLBZa5802VzuLXT0gPJCPdFTORGRveOPz1/nOD3 X-Received: by 2002:a19:9148:0:b0:504:2d54:b4d0 with SMTP id y8-20020a199148000000b005042d54b4d0mr17858110lfj.19.1697018993482; Wed, 11 Oct 2023 03:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018993; cv=none; d=google.com; s=arc-20160816; b=HfFL640ijYIQ7SzPI+Frp2ylOQG6A8Hp8p4CnfBYGsnYl1TPENrszUUJhRS8Pm6I1a alPL+Fl/BN78XAZ9+E6eDz2OTXgK5Xvup30IACVGirWMQvdB/9JsDjZ/WUQSG+xOHV2Z mZGfYNQUvJK2dOVfUi0b3G8BJ/zWsy73H3aTMjLu237Y8us/5pavY4cuBlUuax+P3F7U MGfzPpGYJdbzBfLpd8g7NwFefgRKLWJ4POS0baG4G8spdnUi+ZVzjQb/XhtIyVI9az9h vSk2B/tLqxjcpUk6iTrkZsQ9Ek4jiWYQguxTOqxUD6YOw8kzDXvYK19YVh0YAZmlc8pt lkag== 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=bKQCA4NmtQLw2v1OtVuIkV/l8UfbIwEX1Xgxft/0LvQ=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=hMc06NOB8pFTLKKzjdop+Zxq2OJO9SAFTgVaSAZGFVdK5jqg+RuX7dOFSbXy9ThZUy PbztRfP5sU4qksXY7f5d6aTWi9zs0DL6qeRV+17CvwU8JPLvNhUFfMDm8+gWc+tFpaTO cgrt4NIXjySaoQ9ZsGfrNvzIJpnEkr4vcZ1xHFcIcqoSSXab/O5a+JxHGNSeTkvHBo08 Wxh0TonfAFD3Z0l1xxCyHePzEb+FKK0GPTmDlgrUONvQzFMnWivAwiwd0CZVEiGvymmD sap0bQlQ1U0qdPi2QyBCdeLn7n9BsiRJHM6zCXZGGuXbIykEyof6GO0JzSQWFdOhP9pg /t+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aEkAq1yH; 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 v5-20020a05600c428500b004047ef37bbfsi7361291wmc.218.2023.10.11.03.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:09:53 -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=aEkAq1yH; 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 708E986D5E; Wed, 11 Oct 2023 12:08:07 +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="aEkAq1yH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4A58386D01; Wed, 11 Oct 2023 12:07:55 +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-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) (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 D316586CFD for ; Wed, 11 Oct 2023 12:07:42 +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-oi1-x22d.google.com with SMTP id 5614622812f47-3ae473c0bd6so1173534b6e.0 for ; Wed, 11 Oct 2023 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018858; x=1697623658; 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=bKQCA4NmtQLw2v1OtVuIkV/l8UfbIwEX1Xgxft/0LvQ=; b=aEkAq1yHxNa5Qbe0T6SPEOgzekI5yoJb/jIX21Rw6XEM++pHDuq6IJD7JqCCjz9il6 FBuKtOHjEfWRJkufQjD/O1hw9LzKA2RWSbs1TKQZSWh5bPKVNMT8nuMqwWK+cLjm0m+p 1pn76Bkf5waSI7hLTLjcnnm72wegi2mwTgJKgRReCg37IUf/DHLQqS16LnGQqJKv9shS aWDbSWyyM+Pr8EnqKGWClzMJ+z7V55tyLZfxd+AchRy51Wct7nRdF10ExlsuFYXwg9t9 GeFiIqMNvu5yo0I0JjpX/JEuvKsUdAgxUWDysSAa9AtEBNwqDZuPNVWa46qjrXBzVNko xzTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018858; x=1697623658; 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=bKQCA4NmtQLw2v1OtVuIkV/l8UfbIwEX1Xgxft/0LvQ=; b=hGghDV3M56y7t1kxS2nWHrwg6PgzO+cvb15XITobuxb2/CIrQop9lInAXDzg2vDIJK FXfhNNSgkMmTK1qTaBBe7SS+ucF8KVNDaPIoQoby4asdaG5vCZdqNHkQSYVl4mE+8+3l Y86xsKLRS+mvbjx1zJNZ8DvNYHPtZ3v8sX4NjecPh44u7GvmVHfeliPw34Mw8lh0ii0O TnucjADdTdp+QwnhbMmX4gwhgEvlCLiQTqaz8W8CJbJA+Zt1cBNqieeLMUtcAuDBAPkv Z9vgv954R+ZG++0LsOOiJFuXh1hGN1Bs2W36PgpHiVOEuQdb5VwyVIdM37WEzPpCDcqo cs+Q== X-Gm-Message-State: AOJu0YymNbWAQVxhCas8It6+EedvtBoZWbg6KMLnJRXC9A/y5e11vPFK BCUPCZlQ7jR12kiR3yv4XnIlxBpo1smC8RmpnjNQ+Q== X-Received: by 2002:a05:6808:3008:b0:3ad:af12:2fe0 with SMTP id ay8-20020a056808300800b003adaf122fe0mr23806151oib.3.1697018857755; Wed, 11 Oct 2023 03:07:37 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:37 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 06/14] test: dm: add protocol-specific channel test Date: Wed, 11 Oct 2023 19:06:59 +0900 Message-Id: <20231011100707.1007417-7-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Any SCMI protocol may have its own channel. Test this feature on sandbox as the necessary framework was added in a prior commit. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v6 * add missing header files (scmi_agent.h, scmi_protocols.h) v5 * new commit --- arch/sandbox/dts/test.dts | 1 + test/dm/scmi.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 057e1ca1f4a8..73224e385b8a 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -700,6 +700,7 @@ clk_scmi: protocol@14 { reg = <0x14>; #clock-cells = <1>; + linaro,sandbox-channel-id = <0x14>; }; reset_scmi: protocol@16 { diff --git a/test/dm/scmi.c b/test/dm/scmi.c index d87e2731ce42..8db3ad32f85e 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include #include #include @@ -109,7 +111,7 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts) struct sandbox_scmi_devices *scmi_devices; struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; - struct udevice *dev; + struct udevice *agent_dev, *clock_dev, *dev; int ret_dev; int ret; @@ -124,6 +126,14 @@ static int dm_test_scmi_clocks(struct unit_test_state *uts) agent = scmi_ctx->agent; ut_assertnonnull(agent); + /* Sandbox SCMI clock protocol has its own channel */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + clock_dev = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_CLOCK); + ut_assertnonnull(clock_dev); + ut_asserteq(0x14, sandbox_scmi_channel_id(clock_dev)); + /* Test SCMI clocks rate manipulation */ ut_asserteq(333, agent->clk[0].rate); ut_asserteq(200, agent->clk[1].rate); @@ -172,7 +182,7 @@ static int dm_test_scmi_resets(struct unit_test_state *uts) struct sandbox_scmi_devices *scmi_devices; struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; - struct udevice *dev = NULL; + struct udevice *agent_dev, *reset_dev, *dev = NULL; int ret; ret = load_sandbox_scmi_test_devices(uts, &dev); @@ -186,6 +196,14 @@ static int dm_test_scmi_resets(struct unit_test_state *uts) agent = scmi_ctx->agent; ut_assertnonnull(agent); + /* Sandbox SCMI reset protocol doesn't have its own channel */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + reset_dev = scmi_get_protocol(agent_dev, SCMI_PROTOCOL_ID_RESET_DOMAIN); + ut_assertnonnull(reset_dev); + ut_asserteq(0x0, sandbox_scmi_channel_id(reset_dev)); + /* Test SCMI resect controller manipulation */ ut_assert(!agent->reset[0].asserted); From patchwork Wed Oct 11 10:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731921 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp315757wrv; Wed, 11 Oct 2023 03:08:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExIQmzfXwUVEfGyzJLKofzc3OkjoachS8axqLT7WRU+iCno1sou6f2bg7Rvw78m4/WolyK X-Received: by 2002:a05:6000:1c02:b0:32d:4545:3832 with SMTP id ba2-20020a0560001c0200b0032d45453832mr3790906wrb.14.1697018938089; Wed, 11 Oct 2023 03:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697018938; cv=none; d=google.com; s=arc-20160816; b=nz8/rpAe0WZX1Uz6XXOt5PGWsFmkCOphIr+G4VHVo6iiVUV6tuNk5l6BJZNbD3nrXu 6/RZHMfR4ZLYzGFY1poWaDCVVtJtwyc59utE8aGBBVFTnaKy/bRb/M1H9ktg5Dt82Hqm S+0ApwzGWDaVRaTFZbeE3vF46zttxOn6RG4yR1zjNPjAK2PNdJlvag/8pNry0twJ0uV9 mo7b4LPdgNkAKUTjPku36GiE2u69VNrfPe7A9DDwDBhlngt3+6kLO984r5/AQEyCthoi b0EEt0xZauIPERT3yifxIYs3A1KNVZwxrOyQ1v5J9mzAnX0Ikg44noTGLOKPO2P1gP3S Ua3g== 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=2R9WQiMopt71oBdYFpeWzlpOzx8LaAQ3Ht40XSMAvaA=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=sedG+I4TyY8Ec3TDmYgNzbkz6eP9wxBsq5QRIzdyz51ChuUmC1DV8AxullAvDFred+ nvd+MqJpbVJ8EwGVdUHf5H5F7yfudNRGVG3H//IndmPV29h6uG1viYWA+2wSi/B6hQXR KhAZ9mwnYClovWNTsGdgOikKL8T4ZVBckMBYMCU0Ryw5c0p7/0TfNO+E4RjPeFq+oP8f aubN59cnZSS0AINl6n3MK7b7kOPejw9ph0PD1796bWW0tgsUFPYmD/XETpXo6K96TCfF GcP+xshCRpMVvHp76lkqKJlVQagvZWdPVXSg4X+f8Uq6xpKrwnDmwCjOUAQoT2F8ghP2 O06A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v5X38XXv; 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 jb6-20020a05600c54e600b004052f798ae8si8509203wmb.151.2023.10.11.03.08.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:08:58 -0700 (PDT) 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=v5X38XXv; 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 1150A86CFD; Wed, 11 Oct 2023 12:07:56 +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="v5X38XXv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D6EA186D0A; Wed, 11 Oct 2023 12:07:49 +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-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) (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 D400086CFF for ; Wed, 11 Oct 2023 12:07:42 +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-ot1-x336.google.com with SMTP id 46e09a7af769-6c61dd1c229so1793008a34.0 for ; Wed, 11 Oct 2023 03:07:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018860; x=1697623660; 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=2R9WQiMopt71oBdYFpeWzlpOzx8LaAQ3Ht40XSMAvaA=; b=v5X38XXvL8SjS6hKTAt1z6arbvCuFDmqSUBa10c3/DbqGvmxgOOEuriNTGtF8O7/my YhqfSmPxmvcNVxMDJFNX7xIKkL4B+m9x/6RGMduRBwhfl52CDJAzgv54qSn7xBplVSVM S5VCoelBa3mrLjJbAFI5IkGWHOST4jPFpTTVcimj0UnuboMwWwLFQG7NTmD9YejKa/7p S+7og6Aa4eGQK44tHreLuTzBCbBg767oTiCBSEdyfaWa2OLfZW0A3v6wJdiWobdQCgKQ XcW603XjwmK7pdiAql+Gq2pdo1Xzy8dpOL4jBwFxJeiRDD1yMFK8+BI+huWRnsIiGqVt YLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018860; x=1697623660; 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=2R9WQiMopt71oBdYFpeWzlpOzx8LaAQ3Ht40XSMAvaA=; b=NHRsQhGs3a/ur9GCnb2cXMN4amDUv4HxVak2Qm2not1QTfCTOVUau648OV+Barn8c/ 7D3UlRk+9ZRaVzScA8Y4DfWPLyjmTS2B5waEHesolBMlYJR13Utbk6NTPeWIRc0T3VQj IAgG1Woc1FQ/bTA8m1/DyYte9UTAhETPYH6GnNk8ViutpWOJD6pUZDiccRUoozComh52 lBQ8bBBCxUdSCAFq42u/IKQ5jhgzE1DGqoC16fv3P9j3LWSEJ0b8c2KPEfT6W8V/OUtS /+KJ2sjnOBpqFRzgjaqEqJ1w2RAEvgAECbIrSd/9UxRnz9hbnGqyj0hgNq/37yiT9F5w NQfg== X-Gm-Message-State: AOJu0Ywx7aHZPmdJrQ+Dk0L5kdpgCdDA7KXWg7UT14AZpDhUiDQL0nwM 9UxWMgmVUChx66NkdsZVy6Ck8T484+YTFOq+yIZZ9w== X-Received: by 2002:a9d:5f88:0:b0:6c7:aab5:6e50 with SMTP id g8-20020a9d5f88000000b006c7aab56e50mr19759609oti.2.1697018859900; Wed, 11 Oct 2023 03:07:39 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:39 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 07/14] firmware: scmi: implement SCMI base protocol Date: Wed, 11 Oct 2023 19:07:00 +0900 Message-Id: <20231011100707.1007417-8-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 SCMI base protocol is mandatory according to the SCMI specification. With this patch, SCMI base protocol can be accessed via SCMI transport layers. All the commands, except SCMI_BASE_NOTIFY_ERRORS, are supported. This is because U-Boot doesn't support interrupts and the current transport layers are not able to handle asynchronous messages properly. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v6 * add comments to all the global helper functions * declare scmi_base_ops as static v3 * strncpy (TODO) * remove a duplicated function prototype * use newly-allocated memory when return vendor name or agent name * revise function descriptions in a header v2 * add helper functions, removing direct uses of ops * add function descriptions for each of functions in ops --- drivers/firmware/scmi/Makefile | 1 + drivers/firmware/scmi/base.c | 656 +++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/scmi_protocols.h | 495 +++++++++++++++++++++++++ 4 files changed, 1153 insertions(+) create mode 100644 drivers/firmware/scmi/base.c diff --git a/drivers/firmware/scmi/Makefile b/drivers/firmware/scmi/Makefile index b2ff483c75a1..1a23d4981709 100644 --- a/drivers/firmware/scmi/Makefile +++ b/drivers/firmware/scmi/Makefile @@ -1,4 +1,5 @@ obj-y += scmi_agent-uclass.o +obj-y += base.o obj-y += smt.o obj-$(CONFIG_SCMI_AGENT_SMCCC) += smccc_agent.o obj-$(CONFIG_SCMI_AGENT_MAILBOX) += mailbox_agent.o diff --git a/drivers/firmware/scmi/base.c b/drivers/firmware/scmi/base.c new file mode 100644 index 000000000000..ee84e261945a --- /dev/null +++ b/drivers/firmware/scmi/base.c @@ -0,0 +1,656 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * SCMI Base protocol as U-Boot device + * + * Copyright (C) 2023 Linaro Limited + * author: AKASHI Takahiro + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * scmi_generic_protocol_version - get protocol version + * @dev: SCMI device + * @id: SCMI protocol ID + * @version: Pointer to SCMI protocol version + * + * Obtain the protocol version number in @version. + * + * Return: 0 on success, error code on failure + */ +int scmi_generic_protocol_version(struct udevice *dev, + enum scmi_std_protocol id, u32 *version) +{ + struct scmi_protocol_version_out out; + struct scmi_msg msg = { + .protocol_id = id, + .message_id = SCMI_PROTOCOL_VERSION, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *version = out.version; + + return 0; +} + +/** + * scmi_base_protocol_version_int - get Base protocol version + * @dev: SCMI device + * @version: Pointer to SCMI protocol version + * + * Obtain the protocol version number in @version for Base protocol. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_protocol_version_int(struct udevice *dev, u32 *version) +{ + return scmi_generic_protocol_version(dev, SCMI_PROTOCOL_ID_BASE, + version); +} + +/** + * scmi_protocol_attrs_int - get protocol attributes + * @dev: SCMI device + * @num_agents: Number of SCMI agents + * @num_protocols: Number of SCMI protocols + * + * Obtain the protocol attributes, the number of agents and the number + * of protocols, in @num_agents and @num_protocols respectively, that + * the device provides. + * + * Return: 0 on success, error code on failure + */ +static int scmi_protocol_attrs_int(struct udevice *dev, u32 *num_agents, + u32 *num_protocols) +{ + struct scmi_protocol_attrs_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_PROTOCOL_ATTRIBUTES, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *num_agents = SCMI_PROTOCOL_ATTRS_NUM_AGENTS(out.attributes); + *num_protocols = SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(out.attributes); + + return 0; +} + +/** + * scmi_protocol_message_attrs_int - get message-specific attributes + * @dev: SCMI device + * @message_id: SCMI message ID + * @attributes: Message-specific attributes + * + * Obtain the message-specific attributes in @attributes. + * This command succeeds if the message is implemented and available. + * + * Return: 0 on success, error code on failure + */ +static int scmi_protocol_message_attrs_int(struct udevice *dev, u32 message_id, + u32 *attributes) +{ + struct scmi_protocol_msg_attrs_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_PROTOCOL_MESSAGE_ATTRIBUTES, + .in_msg = (u8 *)&message_id, + .in_msg_sz = sizeof(message_id), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *attributes = out.attributes; + + return 0; +} + +/** + * scmi_base_discover_vendor_int - get vendor name + * @dev: SCMI device + * @vendor: Pointer to vendor name + * + * Obtain the vendor's name in @vendor. + * It is a caller's responsibility to free @vendor. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_discover_vendor_int(struct udevice *dev, u8 **vendor) +{ + struct scmi_base_discover_vendor_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_VENDOR, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + if (!vendor) + return -EINVAL; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *vendor = strdup(out.vendor_identifier); + if (!*vendor) + return -ENOMEM; + + return 0; +} + +/** + * scmi_base_discover_sub_vendor_int - get sub-vendor name + * @dev: SCMI device + * @sub_vendor: Pointer to sub-vendor name + * + * Obtain the sub-vendor's name in @sub_vendor. + * It is a caller's responsibility to free @sub_vendor. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_discover_sub_vendor_int(struct udevice *dev, + u8 **sub_vendor) +{ + struct scmi_base_discover_vendor_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_SUB_VENDOR, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + if (!sub_vendor) + return -EINVAL; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *sub_vendor = strdup(out.vendor_identifier); + if (!*sub_vendor) + return -ENOMEM; + + return 0; +} + +/** + * scmi_base_discover_impl_version_int - get implementation version + * @dev: SCMI device + * @impl_version: Pointer to implementation version + * + * Obtain the implementation version number in @impl_version. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_discover_impl_version_int(struct udevice *dev, + u32 *impl_version) +{ + struct scmi_base_discover_impl_version_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_IMPL_VERSION, + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + *impl_version = out.impl_version; + + return 0; +} + +/** + * scmi_base_discover_list_protocols_int - get list of protocols + * @dev: SCMI device + * @protocols: Pointer to array of SCMI protocols + * + * Obtain the list of protocols provided in @protocols. + * The number of elements in @protocols always match to the number of + * protocols returned by smci_protocol_attrs() when this function succeeds. + * It is a caller's responsibility to free @protocols. + * + * Return: the number of protocols in @protocols on success, error code on + * failure + */ +static int scmi_base_discover_list_protocols_int(struct udevice *dev, + u8 **protocols) +{ + struct scmi_base_discover_list_protocols_out out; + int cur; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_LIST_PROTOCOLS, + .in_msg = (u8 *)&cur, + .in_msg_sz = sizeof(cur), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + u32 num_agents, num_protocols; + u8 *buf; + int i, ret; + + ret = scmi_base_protocol_attrs(dev, &num_agents, &num_protocols); + if (ret) + return ret; + + buf = calloc(sizeof(u8), num_protocols); + if (!buf) + return -ENOMEM; + + cur = 0; + do { + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + goto err; + if (out.status) { + ret = scmi_to_linux_errno(out.status); + goto err; + } + + for (i = 0; i < out.num_protocols; i++, cur++) + buf[cur] = out.protocols[i / 4] >> ((i % 4) * 8); + } while (cur < num_protocols); + + *protocols = buf; + + return num_protocols; +err: + free(buf); + + return ret; +} + +/** + * scmi_base_discover_agent_int - identify agent + * @dev: SCMI device + * @agent_id: SCMI agent ID + * @ret_agent_id: Pointer to SCMI agent ID + * @name: Pointer to SCMI agent name + * + * Obtain the agent's name in @name. If @agent_id is equal to 0xffffffff, + * this function returns the caller's agent id in @ret_agent_id. + * It is a caller's responsibility to free @name. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_discover_agent_int(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 **name) +{ + struct scmi_base_discover_agent_out out; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_DISCOVER_AGENT, + .in_msg = (u8 *)&agent_id, + .in_msg_sz = sizeof(agent_id), + .out_msg = (u8 *)&out, + .out_msg_sz = sizeof(out), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (out.status) + return scmi_to_linux_errno(out.status); + + if (ret_agent_id) + *ret_agent_id = out.agent_id; + if (name) { + *name = strdup(out.name); + if (!*name) + return -ENOMEM; + } + + return 0; +} + +/** + * scmi_base_set_device_permissions_int - configure access permission to device + * @dev: SCMI device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_set_device_permissions_int(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags) +{ + struct scmi_base_set_device_permissions_in in = { + .agent_id = agent_id, + .device_id = device_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_SET_DEVICE_PERMISSIONS, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_set_protocol_permissions_int - configure access permission to + * protocol on device + * @dev: SCMI device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @command_id: SCMI command ID + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the protocol, @command_id, + * on the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_set_protocol_permissions_int(struct udevice *dev, + u32 agent_id, u32 device_id, + u32 command_id, u32 flags) +{ + struct scmi_base_set_protocol_permissions_in in = { + .agent_id = agent_id, + .device_id = device_id, + .command_id = command_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_SET_PROTOCOL_PERMISSIONS, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_reset_agent_configuration_int - reset resource settings + * @dev: SCMI device + * @agent_id: SCMI agent ID + * @flags: A set of flags + * + * Reset all the resource settings against @agent_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_reset_agent_configuration_int(struct udevice *dev, + u32 agent_id, u32 flags) +{ + struct scmi_base_reset_agent_configuration_in in = { + .agent_id = agent_id, + .flags = flags, + }; + s32 status; + struct scmi_msg msg = { + .protocol_id = SCMI_PROTOCOL_ID_BASE, + .message_id = SCMI_BASE_RESET_AGENT_CONFIGURATION, + .in_msg = (u8 *)&in, + .in_msg_sz = sizeof(in), + .out_msg = (u8 *)&status, + .out_msg_sz = sizeof(status), + }; + int ret; + + ret = devm_scmi_process_msg(dev, &msg); + if (ret) + return ret; + if (status) + return scmi_to_linux_errno(status); + + return 0; +} + +/** + * scmi_base_probe - probe base protocol device + * @dev: SCMI device + * + * Probe the device for SCMI base protocol and initialize the private data. + * + * Return: 0 on success, error code on failure + */ +static int scmi_base_probe(struct udevice *dev) +{ + int ret; + + ret = devm_scmi_of_get_channel(dev); + if (ret) { + dev_err(dev, "get_channel failed\n"); + return ret; + } + + return ret; +} + +static struct scmi_base_ops scmi_base_ops = { + /* Commands */ + .protocol_version = scmi_base_protocol_version_int, + .protocol_attrs = scmi_protocol_attrs_int, + .protocol_message_attrs = scmi_protocol_message_attrs_int, + .base_discover_vendor = scmi_base_discover_vendor_int, + .base_discover_sub_vendor = scmi_base_discover_sub_vendor_int, + .base_discover_impl_version = scmi_base_discover_impl_version_int, + .base_discover_list_protocols = scmi_base_discover_list_protocols_int, + .base_discover_agent = scmi_base_discover_agent_int, + .base_notify_errors = NULL, + .base_set_device_permissions = scmi_base_set_device_permissions_int, + .base_set_protocol_permissions = scmi_base_set_protocol_permissions_int, + .base_reset_agent_configuration = + scmi_base_reset_agent_configuration_int, +}; + +int scmi_base_protocol_version(struct udevice *dev, u32 *version) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->protocol_version) + return (*ops->protocol_version)(dev, version); + + return -EOPNOTSUPP; +} + +int scmi_base_protocol_attrs(struct udevice *dev, u32 *num_agents, + u32 *num_protocols) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->protocol_attrs) + return (*ops->protocol_attrs)(dev, num_agents, num_protocols); + + return -EOPNOTSUPP; +} + +int scmi_base_protocol_message_attrs(struct udevice *dev, u32 message_id, + u32 *attributes) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->protocol_message_attrs) + return (*ops->protocol_message_attrs)(dev, message_id, + attributes); + + return -EOPNOTSUPP; +} + +int scmi_base_discover_vendor(struct udevice *dev, u8 **vendor) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_discover_vendor) + return (*ops->base_discover_vendor)(dev, vendor); + + return -EOPNOTSUPP; +} + +int scmi_base_discover_sub_vendor(struct udevice *dev, u8 **sub_vendor) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_discover_sub_vendor) + return (*ops->base_discover_sub_vendor)(dev, sub_vendor); + + return -EOPNOTSUPP; +} + +int scmi_base_discover_impl_version(struct udevice *dev, u32 *impl_version) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_discover_impl_version) + return (*ops->base_discover_impl_version)(dev, impl_version); + + return -EOPNOTSUPP; +} + +int scmi_base_discover_list_protocols(struct udevice *dev, u8 **protocols) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_discover_list_protocols) + return (*ops->base_discover_list_protocols)(dev, protocols); + + return -EOPNOTSUPP; +} + +int scmi_base_discover_agent(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 **name) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_discover_agent) + return (*ops->base_discover_agent)(dev, agent_id, ret_agent_id, + name); + + return -EOPNOTSUPP; +} + +int scmi_base_notify_errors(struct udevice *dev, u32 enable) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_notify_errors) + return (*ops->base_notify_errors)(dev, enable); + + return -EOPNOTSUPP; +} + +int scmi_base_set_device_permissions(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_set_device_permissions) + return (*ops->base_set_device_permissions)(dev, agent_id, + device_id, flags); + + return -EOPNOTSUPP; +} + +int scmi_base_set_protocol_permissions(struct udevice *dev, + u32 agent_id, u32 device_id, + u32 command_id, u32 flags) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_set_protocol_permissions) + return (*ops->base_set_protocol_permissions)(dev, agent_id, + device_id, + command_id, + flags); + + return -EOPNOTSUPP; +} + +int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id, + u32 flags) +{ + const struct scmi_base_ops *ops = device_get_ops(dev); + + if (ops->base_reset_agent_configuration) + return (*ops->base_reset_agent_configuration)(dev, agent_id, + flags); + + return -EOPNOTSUPP; +} + +U_BOOT_DRIVER(scmi_base_drv) = { + .id = UCLASS_SCMI_BASE, + .name = "scmi_base_drv", + .ops = &scmi_base_ops, + .probe = scmi_base_probe, +}; + +UCLASS_DRIVER(scmi_base) = { + .id = UCLASS_SCMI_BASE, + .name = "scmi_base", +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 0432c95c9edc..ab315803dad7 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -123,6 +123,7 @@ enum uclass_id { UCLASS_RNG, /* Random Number Generator */ UCLASS_RTC, /* Real time clock device */ UCLASS_SCMI_AGENT, /* Interface with an SCMI server */ + UCLASS_SCMI_BASE, /* Interface for SCMI Base protocol */ UCLASS_SCSI, /* SCSI device */ UCLASS_SERIAL, /* Serial UART */ UCLASS_SIMPLE_BUS, /* Bus with child devices */ diff --git a/include/scmi_protocols.h b/include/scmi_protocols.h index a220cb2a91ad..163647a57b95 100644 --- a/include/scmi_protocols.h +++ b/include/scmi_protocols.h @@ -49,6 +49,501 @@ enum scmi_discovery_id { SCMI_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2, }; +/* + * SCMI Base Protocol + */ +#define SCMI_BASE_PROTOCOL_VERSION 0x20000 + +enum scmi_base_message_id { + SCMI_BASE_DISCOVER_VENDOR = 0x3, + SCMI_BASE_DISCOVER_SUB_VENDOR = 0x4, + SCMI_BASE_DISCOVER_IMPL_VERSION = 0x5, + SCMI_BASE_DISCOVER_LIST_PROTOCOLS = 0x6, + SCMI_BASE_DISCOVER_AGENT = 0x7, + SCMI_BASE_NOTIFY_ERRORS = 0x8, + SCMI_BASE_SET_DEVICE_PERMISSIONS = 0x9, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS = 0xa, + SCMI_BASE_RESET_AGENT_CONFIGURATION = 0xb, +}; + +#define SCMI_BASE_NAME_LENGTH_MAX 16 + +/** + * struct scmi_protocol_version_out - Response for SCMI_PROTOCOL_VERSION + * command + * @status: SCMI command status + * @version: Protocol version + */ +struct scmi_protocol_version_out { + s32 status; + u32 version; +}; + +/** + * struct scmi_protocol_attrs_out - Response for SCMI_PROTOCOL_ATTRIBUTES + * command + * @status: SCMI command status + * @attributes: Protocol attributes or implementation details + */ +struct scmi_protocol_attrs_out { + s32 status; + u32 attributes; +}; + +#define SCMI_PROTOCOL_ATTRS_NUM_AGENTS(attributes) \ + (((attributes) & GENMASK(15, 8)) >> 8) +#define SCMI_PROTOCOL_ATTRS_NUM_PROTOCOLS(attributes) \ + ((attributes) & GENMASK(7, 0)) + +/** + * struct scmi_protocol_msg_attrs_out - Response for + * SCMI_PROTOCOL_MESSAGE_ATTRIBUTES command + * @status: SCMI command status + * @attributes: Message-specific attributes + */ +struct scmi_protocol_msg_attrs_out { + s32 status; + u32 attributes; +}; + +/** + * struct scmi_base_discover_vendor_out - Response for + * SCMI_BASE_DISCOVER_VENDOR or + * SCMI_BASE_DISCOVER_SUB_VENDOR command + * @status: SCMI command status + * @vendor_identifier: Name of vendor or sub-vendor in string + */ +struct scmi_base_discover_vendor_out { + s32 status; + u8 vendor_identifier[SCMI_BASE_NAME_LENGTH_MAX]; +}; + +/** + * struct scmi_base_discover_impl_version_out - Response for + * SCMI_BASE_DISCOVER_IMPL_VERSION command + * @status: SCMI command status + * @impl_version: Vendor-specific implementation version + */ +struct scmi_base_discover_impl_version_out { + s32 status; + u32 impl_version; +}; + +/** + * struct scmi_base_discover_list_protocols_out - Response for + * SCMI_BASE_DISCOVER_LIST_PROTOCOLS command + * @status: SCMI command status + * @num_protocols: Number of SCMI protocols in @protocol + * @protocols: Array of packed SCMI protocol ID's + */ +struct scmi_base_discover_list_protocols_out { + s32 status; + u32 num_protocols; + u32 protocols[3]; +}; + +/** + * struct scmi_base_discover_agent_out - Response for + * SCMI_BASE_DISCOVER_AGENT command + * @status: SCMI command status + * @agent_id: SCMI agent ID + * @name: Name of agent in string + */ +struct scmi_base_discover_agent_out { + s32 status; + u32 agent_id; + u8 name[SCMI_BASE_NAME_LENGTH_MAX]; +}; + +#define SCMI_BASE_NOTIFY_ERRORS_ENABLE BIT(0) + +/** + * struct scmi_base_set_device_permissions_in - Parameters for + * SCMI_BASE_SET_DEVICE_PERMISSIONS command + * @agent_id: SCMI agent ID + * @device_id: device ID + * @flags: A set of flags + */ +struct scmi_base_set_device_permissions_in { + u32 agent_id; + u32 device_id; + u32 flags; +}; + +#define SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS BIT(0) + +/** + * struct scmi_base_set_protocol_permissions_in - Parameters for + * SCMI_BASE_SET_PROTOCOL_PERMISSIONS command + * @agent_id: SCMI agent ID + * @device_id: device ID + * @command_id: command ID + * @flags: A set of flags + */ +struct scmi_base_set_protocol_permissions_in { + u32 agent_id; + u32 device_id; + u32 command_id; + u32 flags; +}; + +#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_COMMAND GENMASK(7, 0) +#define SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS BIT(0) + +/** + * struct scmi_base_reset_agent_configuration_in - Parameters for + * SCMI_BASE_RESET_AGENT_CONFIGURATION command + * @agent_id: SCMI agent ID + * @flags: A set of flags + */ +struct scmi_base_reset_agent_configuration_in { + u32 agent_id; + u32 flags; +}; + +#define SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS BIT(0) + +/** + * struct scmi_base_ops - SCMI base protocol interfaces + */ +struct scmi_base_ops { + /** + * protocol_version - get Base protocol version + * @dev: SCMI protocol device + * @version: Pointer to SCMI protocol version + * + * Obtain the protocol version number in @version for Base protocol. + * + * Return: 0 on success, error code on failure + */ + int (*protocol_version)(struct udevice *dev, u32 *version); + /** + * protocol_attrs - get protocol attributes + * @dev: SCMI protocol device + * @num_agents: Number of SCMI agents + * @num_protocols: Number of SCMI protocols + * + * Obtain the protocol attributes, the number of agents and the number + * of protocols, in @num_agents and @num_protocols respectively, that + * the device provides. + * + * Return: 0 on success, error code on failure + */ + int (*protocol_attrs)(struct udevice *dev, u32 *num_agents, + u32 *num_protocols); + /** + * protocol_message_attrs - get message-specific attributes + * @dev: SCMI protocol device + * @message_id: SCMI message ID + * @attributes: Message-specific attributes + * + * Obtain the message-specific attributes in @attributes. + * This command succeeds if the message is implemented and available. + * + * Return: 0 on success, error code on failure + */ + int (*protocol_message_attrs)(struct udevice *dev, u32 message_id, + u32 *attributes); + /** + * base_discover_vendor - get vendor name + * @dev: SCMI protocol device + * @vendor: Pointer to vendor name + * + * Obtain the vendor's name in @vendor. + * It is a caller's responsibility to free @vendor. + * + * Return: 0 on success, error code on failure + */ + int (*base_discover_vendor)(struct udevice *dev, u8 **vendor); + /** + * base_discover_sub_vendor - get sub-vendor name + * @dev: SCMI protocol device + * @sub_vendor: Pointer to sub-vendor name + * + * Obtain the sub-vendor's name in @sub_vendor. + * It is a caller's responsibility to free @sub_vendor. + * + * Return: 0 on success, error code on failure + */ + int (*base_discover_sub_vendor)(struct udevice *dev, u8 **sub_vendor); + /** + * base_discover_impl_version - get implementation version + * @dev: SCMI protocol device + * @impl_version: Pointer to implementation version + * + * Obtain the implementation version number in @impl_version. + * + * Return: 0 on success, error code on failure + */ + int (*base_discover_impl_version)(struct udevice *dev, + u32 *impl_version); + /** + * base_discover_list_protocols - get list of protocols + * @dev: SCMI protocol device + * @protocols: Pointer to array of SCMI protocols + * + * Obtain the list of protocols provided in @protocols. + * The number of elements in @protocols always match to the number of + * protocols returned by smci_protocol_attrs() when this function + * succeeds. + * It is a caller's responsibility to free @protocols. + * + * Return: the number of protocols in @protocols on success, + * error code on failure + */ + int (*base_discover_list_protocols)(struct udevice *dev, + u8 **protocols); + /** + * base_discover_agent - identify agent + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @ret_agent_id: Pointer to SCMI agent ID + * @name: Pointer to SCMI agent name + * + * Obtain the agent's name in @name. If @agent_id is equal to + * 0xffffffff, * this function returns the caller's agent id in + * @ret_agent_id. + * It is a caller's responsibility to free @name. + * + * Return: 0 on success, error code on failure + */ + int (*base_discover_agent)(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 **name); + /** + * base_notify_errors - configure error notification + * @dev: SCMI protocol device + * @enable: Operation + * + * Enable or disable error notification from SCMI firmware. + * + * Return: 0 on success, error code on failure + */ + int (*base_notify_errors)(struct udevice *dev, u32 enable); + /** + * base_set_device_permissions - configure access permission to device + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the device, + * @device_id. The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ + int (*base_set_device_permissions)(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags); + /** + * base_set_protocol_permissions - configure access permission to + * protocol on device + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @command_id: command ID + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the protocol, + * @command_id, on the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ + int (*base_set_protocol_permissions)(struct udevice *dev, u32 agent_id, + u32 device_id, u32 command_id, + u32 flags); + /** + * base_reset_agent_configuration - reset resource settings + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @flags: A set of flags + * + * Reset all the resource settings against @agent_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ + int (*base_reset_agent_configuration)(struct udevice *dev, u32 agent_id, + u32 flags); +}; + +/** + * scmi_generic_protocol_version - get protocol version + * @dev: SCMI protocol device + * @id: SCMI protocol ID + * @version: Pointer to SCMI protocol version + * + * Obtain the protocol version number in @version. + * + * Return: 0 on success, error code on failure + */ +int scmi_generic_protocol_version(struct udevice *dev, + enum scmi_std_protocol id, u32 *version); + +/** + * scmi_base_protocol_version - get Base protocol version + * @dev: SCMI protocol device + * @version: Pointer to SCMI protocol version + * + * Obtain the protocol version number in @version for Base protocol. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_protocol_version(struct udevice *dev, u32 *version); + +/** + * scmi_protocol_attrs - get protocol attributes + * @dev: SCMI protocol device + * @num_agents: Number of SCMI agents + * @num_protocols: Number of SCMI protocols + * + * Obtain the protocol attributes, the number of agents and the number + * of protocols, in @num_agents and @num_protocols respectively, that + * the device provides. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_protocol_attrs(struct udevice *dev, u32 *num_agents, + u32 *num_protocols); + +/** + * scmi_protocol_message_attrs - get message-specific attributes + * @dev: SCMI protocol device + * @message_id: SCMI message ID + * @attributes: Message-specific attributes + * + * Obtain the message-specific attributes in @attributes. + * This command succeeds if the message is implemented and available. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_protocol_message_attrs(struct udevice *dev, u32 message_id, + u32 *attributes); + +/** + * scmi_base_discover_vendor - get vendor name + * @dev: SCMI protocol device + * @vendor: Pointer to vendor name + * + * Obtain the vendor's name in @vendor. + * It is a caller's responsibility to free @vendor. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_discover_vendor(struct udevice *dev, u8 **vendor); + +/** + * scmi_base_discover_sub_vendor - get sub-vendor name + * @dev: SCMI protocol device + * @sub_vendor: Pointer to sub-vendor name + * + * Obtain the sub-vendor's name in @sub_vendor. + * It is a caller's responsibility to free @sub_vendor. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_discover_sub_vendor(struct udevice *dev, u8 **sub_vendor); + +/** + * scmi_base_discover_impl_version - get implementation version + * @dev: SCMI protocol device + * @impl_version: Pointer to implementation version + * + * Obtain the implementation version number in @impl_version. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_discover_impl_version(struct udevice *dev, u32 *impl_version); + +/** + * scmi_base_discover_list_protocols - get list of protocols + * @dev: SCMI protocol device + * @protocols: Pointer to array of SCMI protocols + * + * Obtain the list of protocols provided in @protocols. + * The number of elements in @protocols always match to the number of + * protocols returned by smci_protocol_attrs() when this function succeeds. + * It is a caller's responsibility to free @protocols. + * + * Return: the number of protocols in @protocols on success, error code on + * failure + */ +int scmi_base_discover_list_protocols(struct udevice *dev, u8 **protocols); + +/** + * scmi_base_discover_agent - identify agent + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @ret_agent_id: Pointer to SCMI agent ID + * @name: Pointer to SCMI agent name + * + * Obtain the agent's name in @name. If @agent_id is equal to 0xffffffff, + * this function returns the caller's agent id in @ret_agent_id. + * It is a caller's responsibility to free @name. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_discover_agent(struct udevice *dev, u32 agent_id, + u32 *ret_agent_id, u8 **name); + +/** + * scmi_base_notify_errors - configure error notification + * @dev: SCMI protocol device + * @enable: Operation + * + * Enable or disable error notification from SCMI firmware. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_notify_errors(struct udevice *dev, u32 enable); + +/** + * scmi_base_set_device_permissions - configure access permission to device + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_set_device_permissions(struct udevice *dev, u32 agent_id, + u32 device_id, u32 flags); + +/** + * scmi_base_set_protocol_permissions - configure access permission to + * protocol on device + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @device_id: ID of device to access + * @command_id: SCMI command ID + * @flags: A set of flags + * + * Ask for allowing or denying access permission to the protocol, @command_id, + * on the device, @device_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_set_protocol_permissions(struct udevice *dev, + u32 agent_id, u32 device_id, + u32 command_id, u32 flags); + +/** + * scmi_base_reset_agent_configuration - reset resource settings + * @dev: SCMI protocol device + * @agent_id: SCMI agent ID + * @flags: A set of flags + * + * Reset all the resource settings against @agent_id. + * The meaning of @flags is defined in SCMI specification. + * + * Return: 0 on success, error code on failure + */ +int scmi_base_reset_agent_configuration(struct udevice *dev, u32 agent_id, + u32 flags); + /* * SCMI Clock Protocol */ From patchwork Wed Oct 11 10:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731924 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp316564wrv; Wed, 11 Oct 2023 03:10:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGecJW6YVduT0cuZxkUvTKlt0q7VLqNeDZpVz/fbgEMO6KySAl77wB/8khPV8h42dgjp6GF X-Received: by 2002:a05:600c:468d:b0:407:4944:76dc with SMTP id p13-20020a05600c468d00b00407494476dcmr8007774wmo.20.1697019050755; Wed, 11 Oct 2023 03:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019050; cv=none; d=google.com; s=arc-20160816; b=SYBv+O+q+b7GnCR4F0vNSMpEUifGYp4353ESCQz+kjGgyHzt3pIl1TN7974Hia91W8 gNlD43nWXTZnSZ9D5DFYNTcdE8DB/IteSI9M8EhiuItA8JWYkSeMmU5b2ZTZRmY5zFgF XP9dE6EtRNPgbB6HxnJExnzBbkTv5xihBjV2ewZUKpkVv0Wxvc4nPGo16oU4LdfcASHE 77baXnEWgY66HZpZLHgJWiSWdNxvul2vXOvoErpVDPSWNppTDTTqR8gzOVhBxAE20zJu rXpFK0ox83BAZkAE/iOzlSs7e3yJFK8C4PLJOV8yxN9iPGUqRH3EJQuzoqYr2wL8sBwu Jqkw== 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=elX7B9lHvziN8IPqrJUEHKLzx5CF1FboA+ePTZUlIak=; fh=+s9SE2w9oguEKAMcR35TXtqntCOeVFhiK9u/Kju91lo=; b=phVPDYU64syYVcfMxzv9D5pGp4sGxdcntDIh8eVJ2d3GY7NjGvuwWkPxZIdYPWULrX Qab4Xrbq7oW9IgmmQeTeI/6VhKDEmUf6xwkaaORP8NbpgvysShEK4yEKYYaCFSvl72iZ GOT4iU+cfoBPFKJbNBKIVtw5UMW6YiYNp/xmGSDiBCXzzlpJN5kz23i+9ZFpElajRhcj 8hlp5lj2eB6vmMHhKWrLTzks9HALAiRrPAuIrfnLacpKbaHXZPw4cs8gKw6gGkhC+olC X/HZ1T8cwTZfSAmLcLixbeggtfKithZXz8TnxJlvQQS1/zOUsThdwRbsV9HMg9Invch9 Xm8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=paBxZM4t; 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 s7-20020a7bc387000000b00401261d3455si7384629wmj.61.2023.10.11.03.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:10:50 -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=paBxZM4t; 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 3A03E86DFD; Wed, 11 Oct 2023 12:08:09 +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="paBxZM4t"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB99786DE7; Wed, 11 Oct 2023 12:08:04 +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-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) (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 864DA86D20 for ; Wed, 11 Oct 2023 12:07:43 +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-oi1-x236.google.com with SMTP id 5614622812f47-3a707bc2397so977839b6e.0 for ; Wed, 11 Oct 2023 03:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018862; x=1697623662; 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=elX7B9lHvziN8IPqrJUEHKLzx5CF1FboA+ePTZUlIak=; b=paBxZM4t5Mz8x7ApK+ULS/0+KPuI5U9E8D8Sx1MhYVJbDY4yhUiFmgIXu4UTyCDPyw mOZdi4hlVJMWfun+bZzVH/JP6t/itNJfsm7GN/vTmbI9TwDYvGCyfIt0HJAY62Osi5hU EQHpCv48kVKuX1y6CeIsKlvrwMpHbF8eIhXuz3QnboVUNU1CAlCndrAZRYqEx1cw6x6O h6FLNgW5zAeMmPqd6orqd6I1tnfBPEeOn/WGqg8+HUMul4vOuPB7oY7SJHaztM/zJBMJ ZrVuZyHonnVsz4J9WQxvVD7yAfWXET+pWPmdlFLpcJJyzzDr1AO0qYXLh3nq29Zfy+Ym 7bLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018862; x=1697623662; 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=elX7B9lHvziN8IPqrJUEHKLzx5CF1FboA+ePTZUlIak=; b=AcNx4HOUA5POpULoxrqgmlf37Q6wSMXqoWsPO956UjqAp9f331fDtIjI61GXBIQuah rY41D9ntNJk96YbhQjE//lW10N1GrvIRhPbqwJE2u6UfJQwpc+0LqxdFJNnlghmj5TG4 TpRBb4YQVYWKnQANjT48Yp14qslmHdxpqCxK2HztiCvjMQGyfzJ1g0BUIZzpRTG0C87/ PTodK+bOzi9XOf0odegLiUnCZU/rekziaeuvRlCNq1ZBOsFSEF9+3LnvLCxlHjRpmx9Q vYc/adPbQWcFFFZwCBmVwqNptKC2eA4qzt4uX5lEilrKTpcR6El3SRyb3ONT6COtOOXm hz7w== X-Gm-Message-State: AOJu0YyyGfdNAvWHtJ4AlNfri94qot6X+v37VZmLVlRRm7CSvaEzP08L piX1nmEUpfomuORD8r7W/2HLDw== X-Received: by 2002:a05:6359:b9a:b0:147:eb87:3665 with SMTP id gf26-20020a0563590b9a00b00147eb873665mr16337393rwb.3.1697018861985; Wed, 11 Oct 2023 03:07:41 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:41 -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 v6 08/14] firmware: scmi: add a version check against base protocol Date: Wed, 11 Oct 2023 19:07:01 +0900 Message-Id: <20231011100707.1007417-9-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 SCMI base protocol version 2 (0x20000), new interfaces, BASE_SET_DEVICE_PERMISSIONS/BASE_SET_PROTOCOL_PERMISSIONS/ BASE_RESET_AGENT_CONFIGURATION, were added. Moreover, the api of BASE_DISCOVER_AGENT was changed to support self-agent discovery. So the driver expects SCMI firmware support version 2 of base protocol. Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere --- v6 * new commit --- drivers/firmware/scmi/base.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/scmi/base.c b/drivers/firmware/scmi/base.c index ee84e261945a..1d41a8a98fc6 100644 --- a/drivers/firmware/scmi/base.c +++ b/drivers/firmware/scmi/base.c @@ -481,6 +481,7 @@ static int scmi_base_reset_agent_configuration_int(struct udevice *dev, */ static int scmi_base_probe(struct udevice *dev) { + u32 version; int ret; ret = devm_scmi_of_get_channel(dev); @@ -488,6 +489,13 @@ static int scmi_base_probe(struct udevice *dev) dev_err(dev, "get_channel failed\n"); return ret; } + ret = scmi_base_protocol_version_int(dev, &version); + if (ret) { + dev_err(dev, "getting protocol version failed\n"); + return ret; + } + if (version < SCMI_BASE_PROTOCOL_VERSION) + return -EINVAL; return ret; } From patchwork Wed Oct 11 10:07:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731926 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp316773wrv; Wed, 11 Oct 2023 03:11:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjx53IvBKC3DU0BsGFINYcg93cpIBEGisZBnXdr1vBr3BB9ACQfwJKR44FMQK61E/clc6K X-Received: by 2002:a1c:4c10:0:b0:402:f8eb:28d8 with SMTP id z16-20020a1c4c10000000b00402f8eb28d8mr17675691wmf.6.1697019079779; Wed, 11 Oct 2023 03:11:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019079; cv=none; d=google.com; s=arc-20160816; b=BA9L53Cl+yS8P0qmk64a9tNE9/5Z9n7toOmBMr46isJPN3wTiG+ZiQxro6rKFzlbV0 Bxct8v0CoO0CQUxRJleUopNQx21go94Pwf2sOyE6vLL4Xz2NWAJkenssy/otZnLh2XBL mNmPuSG58aowoYLePnRptOhaEX2vtew7pRMjKjeWI1t2dqWQY83dQOXdSl6UUvmeuUjQ sYdaGpL5E93GuKbCrMZaDqGt+aAjqgHunl5oMZY5ExOtCRmlurb8s40/vi0xGF6HbsZc KlGFLtkqN1qUewLiGvSjwR9TkEiaYJ222A8biWH2W1sQ3EJxY5MqP9LTQ69ja4Oszydc tzfQ== 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=w0VkA5ZEvMMrQPxzvrsI3HC9P2fb4sVO3QHTMu1u/8Y=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=MENjUgLVw9QR2k3iEuiJ3/dS88etKrgZz1TyMUfjTV9JyziLkdRNxVCS7kkU9GNuN6 wM8ElA28y7A4qywBkWJsWJ2mZzXZVrRYMlL4pNjH9ujW8fmGCxhubhxALEFfZgIbRvM1 IPDlniP5m/27uqU7gIPzPqdVZJ973IegGJ2L0ogt5HDao1aDMYPTk3PgdDuYIL10mAYf ClKUqgVcvSalUHeXwj3WczI9Df2oW3PnYk0h56azfoI9jIDJghYeGHMlIIMbFD9vOA3/ Db4MPt1wMEUwx8IgQDGuFt/RQarc5EPCuz6sxqUVPakSPZdkaqgR2KZbgU2KVhSnNlSd gwTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GpwhXPrV; 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 gw25-20020a05600c851900b0040479c4b0cdsi7439337wmb.140.2023.10.11.03.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:11:19 -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=GpwhXPrV; 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 E7EBD86D94; Wed, 11 Oct 2023 12:08:14 +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="GpwhXPrV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B461A86D05; Wed, 11 Oct 2023 12:08:05 +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-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 C13A686D05 for ; Wed, 11 Oct 2023 12:07:49 +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-oi1-x229.google.com with SMTP id 5614622812f47-3af59a017a5so1172036b6e.1 for ; Wed, 11 Oct 2023 03:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018864; x=1697623664; 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=w0VkA5ZEvMMrQPxzvrsI3HC9P2fb4sVO3QHTMu1u/8Y=; b=GpwhXPrVFr+pPgljRjgl50HnBU22wkyINy9GAF4ZUPQal9xYgqEo67zV0rGZS1aSUJ qSClpPPXj6GEUEiPoZHCQU7/yWvteYMBZgohm71iRDSpUesI9KyEAbCbfVb3giBZKHWG Y5eAlgHBoB3CVIPVJcE8sXEQ04bgEA8ZFmzA7n/gOO9COsAWdXhWfWZqqXeDAyFDk4Sc Rh/v71896ehsEoKL8pK5cI1UtUr863gKILD1fK2UtU36a33HzWUKGqSIDqKYxnIwIo3E 6hru/bRTK8Wpx3qT1TXuPxG47rOV3SuAAgFmAlr5KA1qMuf8+khf07AJSdNFAjLOP+bk arFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018864; x=1697623664; 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=w0VkA5ZEvMMrQPxzvrsI3HC9P2fb4sVO3QHTMu1u/8Y=; b=CY5qt+2zgLWDCOZIT27lk+t+DmEmrVKX2vY+EOff/rJVtJeiNmKQ4K0mkohIksQZX6 umxjrE9y2fXqMNOu25RMpq1ejQmq2FUn8Pq/c0snLfe2gTJnaccBSETOcEQsUrnhBavF wk41Sr2NSb4zUFvPgNnTwbopgxCskrHjHYSQCTvV86WUsTqSNKdf0UfDIelv6yhVK13V 2jM7NNmSDQPT6J1c1kEiN4DzF9puCo/edJdHBtaBbyhKveP6+SIJUFZC4S2iyJIgRoyu oo1du7lTWRWueZXQ+qYJFPeT93kOZo+UR6Z4o9eL/NnH4/lxV81hmUZEESH774YLoF49 WP+w== X-Gm-Message-State: AOJu0YzOl/8sP47d9UdxLnNBICDdM0e7zYeP6sAPwVaXY6nSnRvs/Jaq oXa6148WHAIqXL/135/zhi1sAw== X-Received: by 2002:a05:6808:3008:b0:3ad:af12:2fe0 with SMTP id ay8-20020a056808300800b003adaf122fe0mr23806415oib.3.1697018864363; Wed, 11 Oct 2023 03:07:44 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:44 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 09/14] firmware: scmi: fake base protocol commands on sandbox Date: Wed, 11 Oct 2023 19:07:02 +0900 Message-Id: <20231011100707.1007417-10-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 This is a simple implementation of SCMI base protocol for sandbox. The main use is in SCMI unit test. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v4 * move this patch forward in this series before installing base protocol to avoid collapsing existing SCMI test. v3 * type fixes: s/udevice/dev/ in function descriptions --- drivers/firmware/scmi/sandbox-scmi_agent.c | 359 ++++++++++++++++++++- 1 file changed, 358 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 394df043918f..716bbf97d5c9 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -14,11 +14,14 @@ #include #include #include +#include +#include /* * The sandbox SCMI agent driver simulates to some extend a SCMI message * processing. It simulates few of the SCMI services for some of the * SCMI protocols embedded in U-Boot. Currently: + * - SCMI base protocol * - SCMI clock protocol emulates an agent exposing 2 clocks * - SCMI reset protocol emulates an agent exposing a reset controller * - SCMI voltage domain protocol emulates an agent exposing 2 regulators @@ -33,6 +36,13 @@ * various uclass devices, as clocks and reset controllers. */ +#define SANDBOX_SCMI_BASE_PROTOCOL_VERSION SCMI_BASE_PROTOCOL_VERSION +#define SANDBOX_SCMI_VENDOR "U-Boot" +#define SANDBOX_SCMI_SUB_VENDOR "Sandbox" +#define SANDBOX_SCMI_IMPL_VERSION 0x1 +#define SANDBOX_SCMI_AGENT_NAME "OSPM" +#define SANDBOX_SCMI_PLATFORM_NAME "platform" + /** * struct sandbox_channel - Description of sandbox transport * @channel_id: Channel identifier @@ -53,6 +63,14 @@ struct scmi_channel { struct sandbox_channel ref; }; +static u8 protocols[] = { + SCMI_PROTOCOL_ID_CLOCK, + SCMI_PROTOCOL_ID_RESET_DOMAIN, + SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN, +}; + +#define NUM_PROTOCOLS ARRAY_SIZE(protocols) + static struct sandbox_scmi_clk scmi_clk[] = { { .rate = 333 }, { .rate = 200 }, @@ -134,6 +152,316 @@ static struct sandbox_scmi_voltd *get_scmi_voltd_state(uint domain_id) * Sandbox SCMI agent ops */ +/* Base Protocol */ + +/** + * sandbox_scmi_base_protocol_version - implement SCMI_BASE_PROTOCOL_VERSION + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_VERSION command. + */ +static int sandbox_scmi_base_protocol_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_version_out *)msg->out_msg; + out->version = SANDBOX_SCMI_BASE_PROTOCOL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_protocol_attrs - implement SCMI_BASE_PROTOCOL_ATTRIBUTES + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_ATTRIBUTES command. + */ +static int sandbox_scmi_base_protocol_attrs(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_protocol_attrs_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_protocol_attrs_out *)msg->out_msg; + out->attributes = FIELD_PREP(0xff00, 2) | NUM_PROTOCOLS; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_message_attrs - implement + * SCMI_BASE_PROTOCOL_MESSAGE_ATTRIBUTES + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_PROTOCOL_MESSAGE_ATTRIBUTES command. + */ +static int sandbox_scmi_base_message_attrs(struct udevice *dev, + struct scmi_msg *msg) +{ + u32 message_id; + struct scmi_protocol_msg_attrs_out *out = NULL; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(message_id) || + !msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + message_id = *(u32 *)msg->in_msg; + out = (struct scmi_protocol_msg_attrs_out *)msg->out_msg; + + if (message_id >= SCMI_PROTOCOL_VERSION && + message_id <= SCMI_BASE_RESET_AGENT_CONFIGURATION && + message_id != SCMI_BASE_NOTIFY_ERRORS) { + out->attributes = 0; + out->status = SCMI_SUCCESS; + } else { + out->status = SCMI_NOT_FOUND; + } + + return 0; +} + +/** + * sandbox_scmi_base_discover_vendor - implement SCMI_BASE_DISCOVER_VENDOR + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_VENDOR command + */ +static int sandbox_scmi_base_discover_vendor(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_vendor_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_vendor_out *)msg->out_msg; + strcpy(out->vendor_identifier, SANDBOX_SCMI_VENDOR); + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_sub_vendor - implement + * SCMI_BASE_DISCOVER_SUB_VENDOR + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_SUB_VENDOR command + */ +static int sandbox_scmi_base_discover_sub_vendor(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_vendor_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_vendor_out *)msg->out_msg; + strcpy(out->vendor_identifier, SANDBOX_SCMI_SUB_VENDOR); + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_impl_version - implement + * SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION command + */ +static int sandbox_scmi_base_discover_impl_version(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_impl_version_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_impl_version_out *)msg->out_msg; + out->impl_version = SANDBOX_SCMI_IMPL_VERSION; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_list_protocols - implement + * SCMI_BASE_DISCOVER_LIST_PROTOCOLS + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_LIST_PROTOCOLS command + */ +static int sandbox_scmi_base_discover_list_protocols(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_discover_list_protocols_out *out = NULL; + + if (!msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + out = (struct scmi_base_discover_list_protocols_out *)msg->out_msg; + memcpy(out->protocols, protocols, sizeof(protocols)); + out->num_protocols = NUM_PROTOCOLS; + out->status = SCMI_SUCCESS; + + return 0; +} + +/** + * sandbox_scmi_base_discover_agent - implement SCMI_BASE_DISCOVER_AGENT + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_DISCOVER_AGENT command + */ +static int sandbox_scmi_base_discover_agent(struct udevice *dev, + struct scmi_msg *msg) +{ + u32 agent_id; + struct scmi_base_discover_agent_out *out = NULL; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(agent_id) || + !msg->out_msg || msg->out_msg_sz < sizeof(*out)) + return -EINVAL; + + agent_id = *(u32 *)msg->in_msg; + out = (struct scmi_base_discover_agent_out *)msg->out_msg; + out->status = SCMI_SUCCESS; + if (agent_id == 0xffffffff || agent_id == 1) { + out->agent_id = 1; + strcpy(out->name, SANDBOX_SCMI_AGENT_NAME); + } else if (!agent_id) { + out->agent_id = agent_id; + strcpy(out->name, SANDBOX_SCMI_PLATFORM_NAME); + } else { + out->status = SCMI_NOT_FOUND; + } + + return 0; +} + +/** + * sandbox_scmi_base_set_device_permissions - implement + * SCMI_BASE_SET_DEVICE_PERMISSIONS + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_SET_DEVICE_PERMISSIONS command + */ +static int sandbox_scmi_base_set_device_permissions(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_set_device_permissions_in *in = NULL; + u32 *status; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_set_device_permissions_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + if (in->agent_id != 1 || in->device_id != 0) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS) + *status = SCMI_INVALID_PARAMETERS; + else if (in->flags & SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS) + *status = SCMI_SUCCESS; + else + /* unset not allowed */ + *status = SCMI_DENIED; + + return 0; +} + +/** + * sandbox_scmi_base_set_protocol_permissions - implement + * SCMI_BASE_SET_PROTOCOL_PERMISSIONS + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_SET_PROTOCOL_PERMISSIONS command + */ +static int sandbox_scmi_base_set_protocol_permissions(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_set_protocol_permissions_in *in = NULL; + u32 *status; + int i; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_set_protocol_permissions_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + for (i = 0; i < ARRAY_SIZE(protocols); i++) + if (protocols[i] == in->command_id) + break; + if (in->agent_id != 1 || in->device_id != 0 || + i == ARRAY_SIZE(protocols)) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS) + *status = SCMI_INVALID_PARAMETERS; + else if (in->flags & SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS) + *status = SCMI_SUCCESS; + else + /* unset not allowed */ + *status = SCMI_DENIED; + + return 0; +} + +/** + * sandbox_scmi_base_reset_agent_configuration - implement + * SCMI_BASE_RESET_AGENT_CONFIGURATION + * @dev: SCMI device + * @msg: SCMI message + * + * Implement SCMI_BASE_RESET_AGENT_CONFIGURATION command + */ +static int sandbox_scmi_base_reset_agent_configuration(struct udevice *dev, + struct scmi_msg *msg) +{ + struct scmi_base_reset_agent_configuration_in *in = NULL; + u32 *status; + + if (!msg->in_msg || msg->in_msg_sz < sizeof(*in) || + !msg->out_msg || msg->out_msg_sz < sizeof(*status)) + return -EINVAL; + + in = (struct scmi_base_reset_agent_configuration_in *)msg->in_msg; + status = (u32 *)msg->out_msg; + + if (in->agent_id != 1) + *status = SCMI_NOT_FOUND; + else if (in->flags & ~SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS) + *status = SCMI_INVALID_PARAMETERS; + else + *status = SCMI_DENIED; + + return 0; +} + +/* Clock Protocol */ + static int sandbox_scmi_clock_protocol_attribs(struct udevice *dev, struct scmi_msg *msg) { @@ -562,6 +890,36 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, struct scmi_msg *msg) { switch (msg->protocol_id) { + case SCMI_PROTOCOL_ID_BASE: + switch (msg->message_id) { + case SCMI_PROTOCOL_VERSION: + return sandbox_scmi_base_protocol_version(dev, msg); + case SCMI_PROTOCOL_ATTRIBUTES: + return sandbox_scmi_base_protocol_attrs(dev, msg); + case SCMI_PROTOCOL_MESSAGE_ATTRIBUTES: + return sandbox_scmi_base_message_attrs(dev, msg); + case SCMI_BASE_DISCOVER_VENDOR: + return sandbox_scmi_base_discover_vendor(dev, msg); + case SCMI_BASE_DISCOVER_SUB_VENDOR: + return sandbox_scmi_base_discover_sub_vendor(dev, msg); + case SCMI_BASE_DISCOVER_IMPL_VERSION: + return sandbox_scmi_base_discover_impl_version(dev, msg); + case SCMI_BASE_DISCOVER_LIST_PROTOCOLS: + return sandbox_scmi_base_discover_list_protocols(dev, msg); + case SCMI_BASE_DISCOVER_AGENT: + return sandbox_scmi_base_discover_agent(dev, msg); + case SCMI_BASE_NOTIFY_ERRORS: + break; + case SCMI_BASE_SET_DEVICE_PERMISSIONS: + return sandbox_scmi_base_set_device_permissions(dev, msg); + case SCMI_BASE_SET_PROTOCOL_PERMISSIONS: + return sandbox_scmi_base_set_protocol_permissions(dev, msg); + case SCMI_BASE_RESET_AGENT_CONFIGURATION: + return sandbox_scmi_base_reset_agent_configuration(dev, msg); + default: + break; + } + break; case SCMI_PROTOCOL_ID_CLOCK: switch (msg->message_id) { case SCMI_PROTOCOL_ATTRIBUTES: @@ -604,7 +962,6 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, break; } break; - case SCMI_PROTOCOL_ID_BASE: case SCMI_PROTOCOL_ID_POWER_DOMAIN: case SCMI_PROTOCOL_ID_SYSTEM: case SCMI_PROTOCOL_ID_PERF: From patchwork Wed Oct 11 10:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731927 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp316959wrv; Wed, 11 Oct 2023 03:11:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELYkrJs8Ha0cDxqQSt9giETYVdgrtq9qNS2mhr8Mph+BFTy9CYOve7hTqAfeIjTYM1B9eF X-Received: by 2002:a5d:40c6:0:b0:31f:dcbb:f81c with SMTP id b6-20020a5d40c6000000b0031fdcbbf81cmr16558272wrq.10.1697019096689; Wed, 11 Oct 2023 03:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019096; cv=none; d=google.com; s=arc-20160816; b=kGYem9ZNXRQ9RaULhGWJwrm4+dSW9LwJIYrGWNWVDqOSRIHbfaok2GOXMXIAbAmR+J Wpc4BzCclyWv5DzsfWM5FEjo7l5uTPTbyx9ZxyWn1FZ0hjgZigESKYaylJOKacsSn9jg Npf/M9YYT2Y/DeS2P2sAWm00Eh3BETwOdkhJaMI9FlURsAuEXu7CBDuorP7AqFqtw/lC 5fuHkKICls9hZ1DjXZyuX4I/5EjhZYb/+UIGBggK4vW298oisIfQB1+zdQbIjmYeKDEZ wLGxt8qUF4+8wJraoeBvGpUL6okBY8qfrvjIH2BUnOY4rRjmegWU4KYw7iIuWQqSoOtZ 6CfQ== 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=rakCvDE9tZqz9G3HX+dIGiG+qRW5YupxXYivPaan/vA=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=mZNXMR6OsRBU0nK6+y345f3LYVJPGN9TLt4U5QSo8jf11xlFf81hX2lxgaQlnEvm1e MU17hONOdTwRe18a2NF4lLe++rGDryBB5409lxArapO4UJwx7wuPav5nwEC2NMFokFo9 9HqVt2nKqN9MZs2Ir5n57xe8bkHUzSqtSrqYOQjOfW33bZbt9GqtreDVrmqDNejjPhqX rNd+/evLga5+fnTzBiooFLwtdI1ajMSacmtUjsTPyJNwDGw1JByeViOUFuI/WygfnO67 DXJqUPYAg06iYCOXo8NmrqDEjICf8W+4pokMq6SwUq7ItSmGFPqnQL1yPiK6GNCnAmmn ZEvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xLNvnnHB; 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 b5-20020a056000054500b0031f84b86206si5568846wrf.892.2023.10.11.03.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:11:36 -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=xLNvnnHB; 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 B3B3A86DFA; Wed, 11 Oct 2023 12:08:15 +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="xLNvnnHB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AE9686DC4; Wed, 11 Oct 2023 12:08:07 +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-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (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 DDCD486CFF for ; Wed, 11 Oct 2023 12:07:49 +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-x430.google.com with SMTP id d2e1a72fcca58-690d935dbc2so1301805b3a.1 for ; Wed, 11 Oct 2023 03:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018867; x=1697623667; 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=rakCvDE9tZqz9G3HX+dIGiG+qRW5YupxXYivPaan/vA=; b=xLNvnnHBL0h932MeqjKZxVpXDpqnLzEw/YHEXmqUuJvxawHuuxS9Hs8ErB3ipoUXxP YSm7DwkqAIlyFLYDDwf6WLQicw4DdjsErNAGfT7FuG5rlXn+6hPD3oZcGdkqQLUOk3we 8YKQm+7bUFJV4k+lalEENopP+Cz38rt+x4VaINRoEfxdjSu2bmYgtfRscNhyAsqzbHDl LCd+SFCjsZG087rN6WLFl/5KKEK6/VSJY1dgwwRnYb2GehmdWgJRD8nQKvNZlEKg5J6H pZ+K4Q2ZQJsw25VQNIHZ9saHa7Bc5RqUtGXijeGQ4pHRLm4ycyqeZ5+H02OJaJaRsi61 Vksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018867; x=1697623667; 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=rakCvDE9tZqz9G3HX+dIGiG+qRW5YupxXYivPaan/vA=; b=lBWt+eeJDfRYI5QH7R+M+e/0MJFsbUkdXLiFUJaC1qDyceq6ylQL2srTBLPlBl1Wwi ljUYCBHTW/CKyfbK+UvQAiKH48M1z13eipXufjPVoWqQ1BqAJSd40rRiLu3qB76PY7wF ZsW/yAVCS7p+CQLk2Ii6nKqmr+H2rR+mv48AVWaJC/2KnUzbRPMrmOpnx+tON6LXQkSa VCOtXvke9o9oa3MlM+E8EN0bss1u/r+mHsJuiDQ7WHKUz3hwC93KoqjvL9rGfPHI9bk8 cB7bsxG3lCif4tl7BQOnlXVwQryBY/l00m1lwQWJx+tXGaX2aXbv4r0QT5dQQgtQAtNJ 792Q== X-Gm-Message-State: AOJu0YwqDrYKn0AL1B0E/DrUxwIBoQq/83TTYz1dNUPW8HYJeN4nNpM3 RYe94A7l4fyBDmyR5/07/0Uojw== X-Received: by 2002:a05:6a00:2d1b:b0:68e:3eff:e93a with SMTP id fa27-20020a056a002d1b00b0068e3effe93amr22233685pfb.2.1697018866594; Wed, 11 Oct 2023 03:07:46 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:46 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 10/14] test: dm: simplify SCMI unit test on sandbox Date: Wed, 11 Oct 2023 19:07:03 +0900 Message-Id: <20231011100707.1007417-11-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Adding SCMI base protocol makes it inconvenient to hold the agent instance (udevice) locally since the agent device will be re-created per each test. Just remove it and simplify the test flows. The test scenario is not changed at all. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v4 * move this patch forward in this series before installing base protocol to avoid collapsing existing SCMI test. --- arch/sandbox/include/asm/scmi_test.h | 6 +- drivers/firmware/scmi/sandbox-scmi_agent.c | 20 +------ test/dm/scmi.c | 64 +++++++--------------- 3 files changed, 26 insertions(+), 64 deletions(-) diff --git a/arch/sandbox/include/asm/scmi_test.h b/arch/sandbox/include/asm/scmi_test.h index 75cb462a5584..ccb0df6c148f 100644 --- a/arch/sandbox/include/asm/scmi_test.h +++ b/arch/sandbox/include/asm/scmi_test.h @@ -98,9 +98,11 @@ unsigned int sandbox_scmi_channel_id(struct udevice *dev); /** * sandbox_scmi_service_ctx - Get the simulated SCMI services context + * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context + * @dev: Reference to the test agent * @return: Reference to backend simulated resources state */ -struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); +struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev); /** * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI @@ -114,7 +116,7 @@ inline unsigned int sandbox_scmi_channel_id(struct udevice *dev); return 0; } -static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) +static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) { return NULL; } diff --git a/drivers/firmware/scmi/sandbox-scmi_agent.c b/drivers/firmware/scmi/sandbox-scmi_agent.c index 716bbf97d5c9..eb567dd900d7 100644 --- a/drivers/firmware/scmi/sandbox-scmi_agent.c +++ b/drivers/firmware/scmi/sandbox-scmi_agent.c @@ -86,11 +86,9 @@ static struct sandbox_scmi_voltd scmi_voltd[] = { { .id = 1, .voltage_uv = 1800000 }, }; -static struct sandbox_scmi_service sandbox_scmi_service_state; - -struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) +struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) { - return &sandbox_scmi_service_state; + return dev_get_priv(dev); } static void debug_print_agent_state(struct udevice *dev, char *str) @@ -985,16 +983,8 @@ static int sandbox_scmi_test_process_msg(struct udevice *dev, static int sandbox_scmi_test_remove(struct udevice *dev) { - struct sandbox_scmi_agent *agent = dev_get_priv(dev); - - if (agent != sandbox_scmi_service_ctx()->agent) - return -EINVAL; - debug_print_agent_state(dev, "removed"); - /* We only need to dereference the agent in the context */ - sandbox_scmi_service_ctx()->agent = NULL; - return 0; } @@ -1002,9 +992,6 @@ static int sandbox_scmi_test_probe(struct udevice *dev) { struct sandbox_scmi_agent *agent = dev_get_priv(dev); - if (sandbox_scmi_service_ctx()->agent) - return -EINVAL; - *agent = (struct sandbox_scmi_agent){ .clk = scmi_clk, .clk_count = ARRAY_SIZE(scmi_clk), @@ -1016,9 +1003,6 @@ static int sandbox_scmi_test_probe(struct udevice *dev) debug_print_agent_state(dev, "probed"); - /* Save reference for tests purpose */ - sandbox_scmi_service_ctx()->agent = agent; - return 0; }; diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 8db3ad32f85e..a7d05f66b753 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -25,22 +25,11 @@ #include #include -static int ut_assert_scmi_state_preprobe(struct unit_test_state *uts) -{ - struct sandbox_scmi_service *scmi_ctx = sandbox_scmi_service_ctx(); - - ut_assertnonnull(scmi_ctx); - ut_assertnull(scmi_ctx->agent); - - return 0; -} - static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, + struct sandbox_scmi_agent *agent, struct udevice *dev) { struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; - struct sandbox_scmi_agent *agent; /* Device references to check context against test sequence */ scmi_devices = sandbox_scmi_devices_ctx(dev); @@ -50,10 +39,6 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, ut_asserteq(2, scmi_devices->regul_count); /* State of the simulated SCMI server exposed */ - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); ut_asserteq(3, agent->clk_count); ut_assertnonnull(agent->clk); ut_asserteq(1, agent->reset_count); @@ -65,27 +50,32 @@ static int ut_assert_scmi_state_postprobe(struct unit_test_state *uts, } static int load_sandbox_scmi_test_devices(struct unit_test_state *uts, + struct sandbox_scmi_agent **ctx, struct udevice **dev) { - int ret; + struct udevice *agent_dev; - ret = ut_assert_scmi_state_preprobe(uts); - if (ret) - return ret; + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + *ctx = sandbox_scmi_agent_ctx(agent_dev); + ut_assertnonnull(*ctx); + + /* probe */ ut_assertok(uclass_get_device_by_name(UCLASS_MISC, "sandbox_scmi", dev)); ut_assertnonnull(*dev); - return ut_assert_scmi_state_postprobe(uts, *dev); + return ut_assert_scmi_state_postprobe(uts, *ctx, *dev); } static int release_sandbox_scmi_test_devices(struct unit_test_state *uts, struct udevice *dev) { + /* un-probe */ ut_assertok(device_remove(dev, DM_REMOVE_NORMAL)); - /* Not sure test devices are fully removed, agent may not be visible */ return 0; } @@ -95,10 +85,11 @@ static int release_sandbox_scmi_test_devices(struct unit_test_state *uts, */ static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts) { + struct sandbox_scmi_agent *ctx; struct udevice *dev = NULL; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &ctx, &dev); if (!ret) ret = release_sandbox_scmi_test_devices(uts, dev); @@ -108,23 +99,18 @@ DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT); static int dm_test_scmi_clocks(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct udevice *agent_dev, *clock_dev, *dev; int ret_dev; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Sandbox SCMI clock protocol has its own channel */ ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", @@ -179,22 +165,17 @@ DM_TEST(dm_test_scmi_clocks, UT_TESTF_SCAN_FDT); static int dm_test_scmi_resets(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct udevice *agent_dev, *reset_dev, *dev = NULL; int ret; - ret = load_sandbox_scmi_test_devices(uts, &dev); + ret = load_sandbox_scmi_test_devices(uts, &agent, &dev); if (ret) return ret; scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Sandbox SCMI reset protocol doesn't have its own channel */ ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", @@ -219,21 +200,16 @@ DM_TEST(dm_test_scmi_resets, UT_TESTF_SCAN_FDT); static int dm_test_scmi_voltage_domains(struct unit_test_state *uts) { - struct sandbox_scmi_devices *scmi_devices; - struct sandbox_scmi_service *scmi_ctx; struct sandbox_scmi_agent *agent; + struct sandbox_scmi_devices *scmi_devices; struct dm_regulator_uclass_plat *uc_pdata; struct udevice *dev; struct udevice *regul0_dev; - ut_assertok(load_sandbox_scmi_test_devices(uts, &dev)); + ut_assertok(load_sandbox_scmi_test_devices(uts, &agent, &dev)); scmi_devices = sandbox_scmi_devices_ctx(dev); ut_assertnonnull(scmi_devices); - scmi_ctx = sandbox_scmi_service_ctx(); - ut_assertnonnull(scmi_ctx); - agent = scmi_ctx->agent; - ut_assertnonnull(agent); /* Set/Get an SCMI voltage domain level */ regul0_dev = scmi_devices->regul[0]; From patchwork Wed Oct 11 10:07:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731929 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp317240wrv; Wed, 11 Oct 2023 03:12:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaGcBEFZTEmBaeRSHkFM0LDCij0Wp26JHtmiB3P8MQ+bzCVhdUGmf6owpCNkdM+nM7nT7U X-Received: by 2002:a05:600c:2108:b0:402:ea8c:ea57 with SMTP id u8-20020a05600c210800b00402ea8cea57mr14795922wml.7.1697019136083; Wed, 11 Oct 2023 03:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019136; cv=none; d=google.com; s=arc-20160816; b=wrVJ1gYXBNO1dTvkvsg72c4jsSI9aFtNJgxAIF9p/h9RnE1k7HoMBz0FYTo7Bapl7Y D7EIgpNvB/4ui5pqz2YC65PG4nxZyF30mOzxqwHTnZE2Md+3ngR6Y2et1G6A9Ct6Q5Z5 Xvs523AiySynB8m1gneYnVzdx9Tlyrr2Wic9yCikrOqnaWiiUnICfQKIx0whO0p4Ea82 5kyhOaUljW7RgeziHuq3pCMPnQlQfBdm3LOPKIsfZ+SWJ3c1Ymqgv/PPjhrj8IxbpULW ORX1h3oI1kZdt/ZCCw1acyNM1U9KilTgcb2pgO5zn8zF400bglqhx0xccAisXGqx6Xto 81Aw== 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=rTdm6SW79mLHljnSGoRxWGpVn8avzB5Z44W3qR0Rq5k=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=bww5a7wUpSlWcvl5qz7Mrd/u4u18nBh2OmFNzMfq8uzZpQp0mzKViU9CLDsqUPAEH8 mJxmm3M7+mcpwzlfMtXPgcRDkoqaYXyC9Y6d/wyiffVnNuOJlRbqAUDYvnzDIhI+xtAs ghddgUjiYGY1aYB7mCyNsvwsAoAX0e2PJJK0Mh12kSnDagEoy7dHNtgDg5yuSji92NWd Afbge6+cLXsyvD2GqoyV+ICqtJRT1TiiqiVrjZ+BsAcGlfgQm9I/4asTXea74qs8sc/X dh3HzG/a8h8UZIeNneyh3+cZSdhyEmqwXrx8FedzPo3FsMJ8ox3tt95EXZidMWMTZzL2 dqGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D4PpJ2Kt; 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 w19-20020a05600c099300b0040653ab52d0si8588714wmp.26.2023.10.11.03.12.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:12:16 -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=D4PpJ2Kt; 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 B5B8786E15; Wed, 11 Oct 2023 12:08: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=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="D4PpJ2Kt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CDA6E86DF6; Wed, 11 Oct 2023 12:08:09 +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-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) (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 68D6A86D77 for ; Wed, 11 Oct 2023 12:07:54 +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-x42a.google.com with SMTP id d2e1a72fcca58-692af7b641cso1184276b3a.1 for ; Wed, 11 Oct 2023 03:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018869; x=1697623669; 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=rTdm6SW79mLHljnSGoRxWGpVn8avzB5Z44W3qR0Rq5k=; b=D4PpJ2KtLi5RRg7Sp+R4pB5gxIJJMcQZkTQlUFlBgvEt5K1z2jseHP+M1QX90bs1o5 kjgGdHiamREDlVa8ZJz77P7o62AM+1AOc71qwPa4Sa2AigEd68Zv/lYVAom9E6Maojst TlJOFVBtKQYnAKgsPHgV6rs0cAmDC/S6wmfkHGlCQJ79RLzg/RnYMIoo6IO6GLFpxAyG XM+9sAAdjqymdWs0rPATXFL/dQDsTR5lP4+Q6THvRRdgHBsmMorhfQYf//C36C6Z5QQv JsznbQZPAXLnqFoJ1FcSWdP6aHD7p6LR93jCxVLHldBo3RPOAZItoI3lSt7x74D4Ol4j IKUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018869; x=1697623669; 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=rTdm6SW79mLHljnSGoRxWGpVn8avzB5Z44W3qR0Rq5k=; b=MO1uy2/a89AhBfNTkLRXh7iKAI6EPYZ2K/Kzrs8lcsP/L9+/43DRhUx6YJRQH83mjS fmcIPG0ztqmAJY3byXwaBIW/vk3gy/feVkiWTGsSIldesnxckDyj0Hlq4458giRvdd4g WS8kb950O9ALr9PsvPodzrzTNboJpkwr7vA310Aq1DOKy2uo2VPqInBWkxJivKtEIb2o twRtpRm8ZGHmH4TAsIZ9Pcimmd7prvbzL8GWqfv5fF/qTxBNIrejv57xFLN9M3nytyCR eswhEMwUEJKyphNcVL2vJUKfoPah0+KPHFPqTY+Lmkk8OVIYE3XrGKg0o0oAH4naDL2f MqZw== X-Gm-Message-State: AOJu0YyCW4DAwpFq65V2DY8Xy/kuVpWPRUmyG3kHMKV46MKMvMnYtvW/ o0RgMXjDGuoE//rqAXPgWJKVqg== X-Received: by 2002:a05:6a00:3916:b0:68e:2fd4:288a with SMTP id fh22-20020a056a00391600b0068e2fd4288amr23374521pfb.3.1697018868805; Wed, 11 Oct 2023 03:07:48 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:48 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 11/14] firmware: scmi: install base protocol to SCMI agent Date: Wed, 11 Oct 2023 19:07:04 +0900 Message-Id: <20231011100707.1007417-12-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 SCMI base protocol is mandatory, and once SCMI node is found in a device tree, the protocol handle (udevice) is unconditionally installed to the agent. Then basic information will be retrieved from SCMI server via the protocol and saved into the agent instance's local storage. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- v4 * remove 'scmi_agent' global variable as it is never utilized * add 'agent' variable in scmi_bind_protocols() * return an appropriate error (EPROTO) when scmi_base_discover_list_protocols() fails * fix misc typos v3 * typo fix: add '@' for argument name in function description * eliminate dev_get_uclass_plat()'s repeated in inline * modify the code for dynamically allocated sub-vendor/agent names v2 * use helper functions, removing direct uses of ops --- drivers/firmware/scmi/scmi_agent-uclass.c | 118 +++++++++++++++++++++- include/scmi_agent-uclass.h | 66 ++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index b4d008835180..b1a9c36310c1 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -51,6 +51,9 @@ struct udevice *scmi_get_protocol(struct udevice *dev, } switch (id) { + case SCMI_PROTOCOL_ID_BASE: + proto = priv->base_dev; + break; case SCMI_PROTOCOL_ID_CLOCK: proto = priv->clock_dev; break; @@ -95,6 +98,9 @@ static int scmi_add_protocol(struct udevice *dev, } switch (proto_id) { + case SCMI_PROTOCOL_ID_BASE: + priv->base_dev = proto; + break; case SCMI_PROTOCOL_ID_CLOCK: priv->clock_dev = proto; break; @@ -232,6 +238,83 @@ int devm_scmi_process_msg(struct udevice *dev, struct scmi_msg *msg) return scmi_process_msg(protocol->parent, priv->channel, msg); } +/** + * scmi_fill_base_info - get base information about SCMI server + * @agent: SCMI agent device + * @dev: SCMI protocol device + * + * By using Base protocol commands, collect the base information + * about SCMI server. + * + * Return: 0 on success, error code on failure + */ +static int scmi_fill_base_info(struct udevice *agent, struct udevice *dev) +{ + struct scmi_agent_priv *priv = dev_get_uclass_plat(agent); + int ret; + + ret = scmi_base_protocol_version(dev, &priv->version); + if (ret) { + dev_err(dev, "protocol_version() failed (%d)\n", ret); + return ret; + } + /* check for required version */ + if (priv->version < SCMI_BASE_PROTOCOL_VERSION) { + dev_err(dev, "base protocol version (%d) lower than expected\n", + priv->version); + return -EPROTO; + } + + ret = scmi_base_protocol_attrs(dev, &priv->num_agents, + &priv->num_protocols); + if (ret) { + dev_err(dev, "protocol_attrs() failed (%d)\n", ret); + return ret; + } + ret = scmi_base_discover_vendor(dev, &priv->vendor); + if (ret) { + dev_err(dev, "base_discover_vendor() failed (%d)\n", ret); + return ret; + } + ret = scmi_base_discover_sub_vendor(dev, &priv->sub_vendor); + if (ret) { + if (ret != -EOPNOTSUPP) { + dev_err(dev, "base_discover_sub_vendor() failed (%d)\n", + ret); + return ret; + } + priv->sub_vendor = "NA"; + } + ret = scmi_base_discover_impl_version(dev, &priv->impl_version); + if (ret) { + dev_err(dev, "base_discover_impl_version() failed (%d)\n", + ret); + return ret; + } + + ret = scmi_base_discover_agent(dev, 0xffffffff, + &priv->agent_id, &priv->agent_name); + if (ret) { + if (ret != -EOPNOTSUPP) { + dev_err(dev, + "base_discover_agent() failed for myself (%d)\n", + ret); + return ret; + } + priv->agent_id = 0xffffffff; + priv->agent_name = "NA"; + } + + ret = scmi_base_discover_list_protocols(dev, &priv->protocols); + if (ret != priv->num_protocols) { + dev_err(dev, "base_discover_list_protocols() failed (%d)\n", + ret); + return -EPROTO; + } + + return 0; +} + /* * SCMI agent devices binds devices of various uclasses depending on * the FDT description. scmi_bind_protocol() is a generic bind sequence @@ -243,7 +326,40 @@ static int scmi_bind_protocols(struct udevice *dev) ofnode node; const char *name; struct driver *drv; - struct udevice *proto; + struct udevice *agent, *proto; + + if (!uclass_get_device(UCLASS_SCMI_AGENT, 1, &agent)) { + /* This is a second SCMI agent */ + dev_err(dev, "Cannot have more than one SCMI agent\n"); + return -EEXIST; + } + + /* initialize the device from device tree */ + drv = DM_DRIVER_GET(scmi_base_drv); + name = "scmi-base.0"; + ret = device_bind(dev, drv, name, NULL, ofnode_null(), &proto); + if (ret) { + dev_err(dev, "failed to bind base protocol\n"); + return ret; + } + ret = scmi_add_protocol(dev, SCMI_PROTOCOL_ID_BASE, proto); + if (ret) { + dev_err(dev, "failed to add protocol: %s, ret: %d\n", + proto->name, ret); + return ret; + } + + ret = device_probe(proto); + if (ret) { + dev_err(dev, "failed to probe base protocol\n"); + return ret; + } + + ret = scmi_fill_base_info(dev, proto); + if (ret) { + dev_err(dev, "failed to get base information\n"); + return ret; + } dev_for_each_subnode(node, dev) { u32 protocol_id; diff --git a/include/scmi_agent-uclass.h b/include/scmi_agent-uclass.h index 258aa0f37596..35d96069645e 100644 --- a/include/scmi_agent-uclass.h +++ b/include/scmi_agent-uclass.h @@ -5,6 +5,7 @@ #ifndef _SCMI_AGENT_UCLASS_H #define _SCMI_AGENT_UCLASS_H +#include #include struct scmi_msg; @@ -12,16 +13,81 @@ struct scmi_channel; /** * struct scmi_agent_priv - private data maintained by agent instance + * @version: Version + * @num_agents: Number of agents + * @num_protocols: Number of protocols + * @impl_version: Implementation version + * @protocols: Array of protocol IDs + * @vendor: Vendor name + * @sub_vendor: Sub-vendor name + * @agent_name: Agent name + * @agent_id: Identifier of agent + * @base_dev: SCMI base protocol device * @clock_dev: SCMI clock protocol device * @resetdom_dev: SCMI reset domain protocol device * @voltagedom_dev: SCMI voltage domain protocol device */ struct scmi_agent_priv { + u32 version; + u32 num_agents; + u32 num_protocols; + u32 impl_version; + u8 *protocols; + u8 *vendor; + u8 *sub_vendor; + u8 *agent_name; + u32 agent_id; + struct udevice *base_dev; struct udevice *clock_dev; struct udevice *resetdom_dev; struct udevice *voltagedom_dev; }; +static inline u32 scmi_version(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->version; +} + +static inline u32 scmi_num_agents(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_agents; +} + +static inline u32 scmi_num_protocols(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->num_protocols; +} + +static inline u32 scmi_impl_version(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->impl_version; +} + +static inline u8 *scmi_protocols(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->protocols; +} + +static inline u8 *scmi_vendor(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->vendor; +} + +static inline u8 *scmi_sub_vendor(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->sub_vendor; +} + +static inline u8 *scmi_agent_name(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_name; +} + +static inline u32 scmi_agent_id(struct udevice *dev) +{ + return ((struct scmi_agent_priv *)dev_get_uclass_plat(dev))->agent_id; +} + /** * struct scmi_transport_ops - The functions that a SCMI transport layer must implement. */ From patchwork Wed Oct 11 10:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731928 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp317134wrv; Wed, 11 Oct 2023 03:12:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJKv6IEf8B/gQRFQJTOci/TYqc62wXMqED5v7dTbi3WLBHxnrF3zc4smUMzaV1aVrQX7/o X-Received: by 2002:adf:f005:0:b0:31f:db12:f5db with SMTP id j5-20020adff005000000b0031fdb12f5dbmr17696412wro.32.1697019120685; Wed, 11 Oct 2023 03:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019120; cv=none; d=google.com; s=arc-20160816; b=h8wFBGXyEowAVr8TscIMk5Fl9rzGeajFPoTgZdNmyBkFZ2F6BIMzbHoxhfuQunKfjf cEs61g1N/Ba852aSoVor/2im9vCRfc6KbTK21JS5AB079PzcQWXOPR1n1QeFX80Y/nki 2roO0ylpjSpH2r2Sh4wSDP0At71OXBxqtCbUogzWkzXcOIrHVk3RCljVPzl3Rk7i1rAL rjkRxplBiWXl4dX7t4xBKqfVkezZF0VQ+/WDwS8Orj7LmDabIXuO/OrPdkCPVA/4OcwF UXNFQNthHQNdTguRUGQ0Zl2WASy/hVobP08dU7R86MHROTwuNBkpTbrNtdFH6BIhWNAr 7+tA== 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=5fJTch9PB9zkacUWjbf2mgcKlFFPGY+OkV/KT1STzU0=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=FI6dzIp27iGspiYdUHehtg1Dmnr51YknWWT4LdrJ3X1FK7VrvRX4c+9GM/KdNgjehe 4aHqmdTNPDZ24j0rQ2G5j3dPllXmcNogGDdYglxPMspUeJvFD3KktnbZv5Ql71IBhBiY 7JC+oNjLXi2Z4Cq47m+ab8omxHJiE+gY4+kdnEWb7nGvAApm5WyBgga2uwn6MdP7EnQt rDRi4fVEQmh1e1NZa0LghPETrpyH8EGg/TZacQgzD7Cj1A8swNTIYrdrKQSf2KSA4Nsg UzFV7fvlo7G80tADfG8ZW7et5TvwafVJFhYag4YOS/NBG8ndCt1SCzJHoTDpFWOc1w7W WnaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s07xYLfu; 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 t18-20020a5d49d2000000b0032320f3294fsi5679673wrs.554.2023.10.11.03.12.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:12:00 -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=s07xYLfu; 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 F0CE586E0B; Wed, 11 Oct 2023 12:08:17 +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="s07xYLfu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6700286DF2; Wed, 11 Oct 2023 12:08:09 +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-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) (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 9999B86D85 for ; Wed, 11 Oct 2023 12:07:54 +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-oo1-xc2c.google.com with SMTP id 006d021491bc7-57c0775d4fcso790187eaf.0 for ; Wed, 11 Oct 2023 03:07:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018871; x=1697623671; 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=5fJTch9PB9zkacUWjbf2mgcKlFFPGY+OkV/KT1STzU0=; b=s07xYLfu52l4MW8FMKr+h5t/DIzRtVOBw+yPm74IcFxEfQp742s+yXYyW/s36OTXeJ np2cm5kzvEiDnPlKVl2HdFXgJ4HfpFUAlH/1gilpGaPuyzvwn5tViSbwGuucU6vlQzsZ Ne4bz1+oRU7qNcZRsM8sJjGRsH8Oz4O50uxmRKMB/G+yJYiWVu8OwFWN6M2i9BaciNSY 4SEQvoRqoZt+UzEI0kKzLGEAfbC/qFjR0w7F1CQiasHkbs6DlbmylmopG0I8KjCx9R/1 wbWknxc8qUt+ZdR2/uL+cgS8Tj9ia3bkJBU7jN7UBqjE8KWJMBhCYKyJAvGVuQJaIKB5 R83Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018871; x=1697623671; 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=5fJTch9PB9zkacUWjbf2mgcKlFFPGY+OkV/KT1STzU0=; b=gDHJvCrH7NLJZaXLrrRanvlLwmVCjXQaeej4iBCoTJW9Y5aQt9pmbSc0IPhsFneRwC owhqfrpWINgsRge6EjxkR5/JrNYxksaMFleh22MvbGsV6NAA9fJX8FLWl4oSv21shFcR /v4dxqKsu7AO97qPZ7DmIpPpk7aDeLKUbF1ud2SQWnYk4wUQBtd/vPxUFI2H6T1Zsx0L sUitDej1rMOZJ/0YpBmJOdmiEcfCtrOsLLbfFltVhRWgfbswZ//vwmbL6parQbHJi4LC vAXMA4VVUqYmZdBrldG47So9LK1mxH+1VUywoKOEE4GRD4ZRd0oF3JcIvusDlbWn5NGh vaxQ== X-Gm-Message-State: AOJu0YyegDAN8lhZTJztJ/f9FoFW0gVkQukYJgJOf6RMJrSKdzbVItSq p68P1SijkEG+0Fx/t6HpAfKXoo5mU2XxZEi3KDn6tA== X-Received: by 2002:a05:6358:f17:b0:14d:8792:1cec with SMTP id b23-20020a0563580f1700b0014d87921cecmr13236828rwj.1.1697018871022; Wed, 11 Oct 2023 03:07:51 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:50 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 12/14] sandbox: remove SCMI base node definition from test.dts Date: Wed, 11 Oct 2023 19:07:05 +0900 Message-Id: <20231011100707.1007417-13-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 SCMI base protocol is mandatory and doesn't need to be listed in a device tree. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass Reviewed-by: Etienne Carriere --- arch/sandbox/dts/test.dts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 73224e385b8a..a335445b984b 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -693,10 +693,6 @@ #address-cells = <1>; #size-cells = <0>; - protocol@10 { - reg = <0x10>; - }; - clk_scmi: protocol@14 { reg = <0x14>; #clock-cells = <1>; From patchwork Wed Oct 11 10:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731930 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp317451wrv; Wed, 11 Oct 2023 03:12:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+44D0NPtD0oWiEjMsPCoM8fSh9qHhhngScngJJW33vzXmQyKQWLyAIpEC0IeTzhHhikHV X-Received: by 2002:a05:600c:2946:b0:405:4daa:6e3d with SMTP id n6-20020a05600c294600b004054daa6e3dmr18002295wmd.39.1697019167038; Wed, 11 Oct 2023 03:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019167; cv=none; d=google.com; s=arc-20160816; b=SqK2oWFMqH9x7m62EYHBWenJnpFtcA7zblalWe5RIE0FVnZxKQjMV9mis86YWC5uDS nf/rloCCBO52W1kH5Y+xNh6B06GxgUrEYPanOcfIKfgEQeG4WDFQxJD5TU+dGW0riI0r 4Vfnen86ukZ5HkwZLenmhfD9izqDM6CoIqsN7secy9kw6vyxqbDbXwvkpsaPiIkesRg4 bDxD9cG4vfixdTlyyMh0yxu7ixzpo/473D0FoK5UYnKCfNWxFEkmYPO4M2fPozYKWnqn +th/pcgg7MYHhMzpAihw1JtYCYCsNMxqsDPuFjUhy9FMvVGD7FoAikv0rV4kyzCYz9Lt OINQ== 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=/nj98gsJlcxoLzaXSFIprsnNSBVTV3jRN9vqJRZp6D0=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=OXmf8uftPUfyRjMjDi6HG6ltH4zWvYPu4OyhvsFukxiDTHwC29dyO5VqHPdiCcHngl +Y9OisFdCva0DCphBMuaAWs9s/NvS3hfrLpmeHgNVUns4511xblUJVE+MDE4QGIzFDzt aIL7h6iJaUXIkYhT4wyt0QEaf6x7ka0uwzzyVtstjDvWOcRkcx7W28iE6dFM+BpswHOL pSqUO7VJ1pFAKFooVjhYMleLfHUWTIcgmsUQktUlbyPy837xgoseCYu+NVRTO0iAKOr3 kHt8nic7NZJ0wChBJerm20IBj9GKHQwcuA2/XrF30vsBW+VV7Pxvpci3laBYmYjAxI6D pcBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Zx8WNuEa; 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 iw17-20020a05600c54d100b00405740025dcsi7275218wmb.204.2023.10.11.03.12.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:12:47 -0700 (PDT) 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=Zx8WNuEa; 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 7540A86E22; Wed, 11 Oct 2023 12:08:25 +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="Zx8WNuEa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 162C586D77; Wed, 11 Oct 2023 12:08:10 +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-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (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 10E9F86D1D for ; Wed, 11 Oct 2023 12:07:55 +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-oi1-x231.google.com with SMTP id 5614622812f47-3ae0df6494bso972420b6e.1 for ; Wed, 11 Oct 2023 03:07:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018873; x=1697623673; 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=/nj98gsJlcxoLzaXSFIprsnNSBVTV3jRN9vqJRZp6D0=; b=Zx8WNuEaHST98fTpwMmHaKZ6CJEmGbT/YSk6ovqEdoIKrztJWXbLvi7gVxzEYNfK5U lzTtS8Wuf4FTr5zaPPOOf94qU3hQCuBhjX+trfDJ5UWbcFZLg+c+EOEPRVG9jkADz602 ps1E3FplGetCaE3cWt7omQgFIIqhzFqmLs3p8iEJFMA9AqiggXeLNouQByo0IXk1yzNc MpesMkRodOdHeKjX98E7JriYu4Rx/ohkiXkJHmv6N0C7UyN7ogpj4yqEo//eeauo94dy OGcWV2TA/PTEVxTJo50x3L1Y7f0FibIiUjSb59sswZsXvS4+pn68Blw/YyRVLs58Lnnl +Ekw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018873; x=1697623673; 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=/nj98gsJlcxoLzaXSFIprsnNSBVTV3jRN9vqJRZp6D0=; b=gYfBHraFth9D1IXxyjF0l61y6pLu3crVR/Y9YIpX8rnjzULYRh2PZV7SoXVwP64iaI dqdFPkuz8y3gNWdyHvlQaDZcW7tj1I5rSdNVvTf3gdd8jdhRUqyFhWW8mMYkaQQVTcp8 xABs1bSZSVG2UPCeThsHYR/Crv+8ub1L+opOBCoaBgMHUwXXhrkORPHlZcJxBWfXHfQw f8RGrRWsn8qlxNk93FprEVzhsLeNTXRSbv14UwyOmJVCD5q9aHMSZqJnG0rhcQ3SqKPt ZdVphGdQhCnkOB/DRVuIaCa+yjAltD4NhZgRquaLZZt7fJo6SYAbM04NOrRMR59OWZv8 5uPg== X-Gm-Message-State: AOJu0YwDu4Y4roSg2igjS70h3++Klz0ChAXmq/kUqp1XdEy7GvSUFAND 5LncperAsGt57YUnTWcBjil+GQ== X-Received: by 2002:a05:6358:2d94:b0:163:e0a:68a4 with SMTP id m20-20020a0563582d9400b001630e0a68a4mr13694548rwn.2.1697018873277; Wed, 11 Oct 2023 03:07:53 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:52 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 13/14] test: dm: add SCMI base protocol test Date: Wed, 11 Oct 2023 19:07:06 +0900 Message-Id: <20231011100707.1007417-14-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Added is a new unit test for SCMI base protocol, which will exercise all the commands provided by the protocol, except SCMI_BASE_NOTIFY_ERRORS. $ ut dm scmi_base It is assumed that test.dtb is used as sandbox's device tree. Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere Reviewed-by: Simon Glass --- v4 * fix a typo fix in v3 s/scmi_protocol_message_attrs/scmi_base_protocol_message_attrs/ v3 * typo: s/scmi_base_protocol_attrs/scmi_base_protocol_message_attrs/ * modify the code for dynamically allocated vendor/agent names v2 * use helper functions, removing direct uses of ops --- test/dm/scmi.c | 109 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/dm/scmi.c b/test/dm/scmi.c index a7d05f66b753..d4ff60e00069 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,114 @@ static int dm_test_scmi_sandbox_agent(struct unit_test_state *uts) } DM_TEST(dm_test_scmi_sandbox_agent, UT_TESTF_SCAN_FDT); +static int dm_test_scmi_base(struct unit_test_state *uts) +{ + struct udevice *agent_dev, *base; + struct scmi_agent_priv *priv; + u32 version, num_agents, num_protocols, impl_version; + u32 attributes, agent_id; + u8 *vendor, *agent_name, *protocols; + int ret; + + /* preparation */ + ut_assertok(uclass_get_device_by_name(UCLASS_SCMI_AGENT, "scmi", + &agent_dev)); + ut_assertnonnull(agent_dev); + ut_assertnonnull(priv = dev_get_uclass_plat(agent_dev)); + ut_assertnonnull(base = scmi_get_protocol(agent_dev, + SCMI_PROTOCOL_ID_BASE)); + + /* version */ + ret = scmi_base_protocol_version(base, &version); + ut_assertok(ret); + ut_asserteq(priv->version, version); + + /* protocol attributes */ + ret = scmi_base_protocol_attrs(base, &num_agents, &num_protocols); + ut_assertok(ret); + ut_asserteq(priv->num_agents, num_agents); + ut_asserteq(priv->num_protocols, num_protocols); + + /* discover vendor */ + ret = scmi_base_discover_vendor(base, &vendor); + ut_assertok(ret); + ut_asserteq_str(priv->vendor, vendor); + free(vendor); + + /* message attributes */ + ret = scmi_base_protocol_message_attrs(base, + SCMI_BASE_DISCOVER_SUB_VENDOR, + &attributes); + ut_assertok(ret); + ut_assertok(attributes); + + /* discover sub vendor */ + ret = scmi_base_discover_sub_vendor(base, &vendor); + ut_assertok(ret); + ut_asserteq_str(priv->sub_vendor, vendor); + free(vendor); + + /* impl version */ + ret = scmi_base_discover_impl_version(base, &impl_version); + ut_assertok(ret); + ut_asserteq(priv->impl_version, impl_version); + + /* discover agent (my self) */ + ret = scmi_base_discover_agent(base, 0xffffffff, &agent_id, + &agent_name); + ut_assertok(ret); + ut_asserteq(priv->agent_id, agent_id); + ut_asserteq_str(priv->agent_name, agent_name); + free(agent_name); + + /* discover protocols */ + ret = scmi_base_discover_list_protocols(base, &protocols); + ut_asserteq(num_protocols, ret); + ut_asserteq_mem(priv->protocols, protocols, sizeof(u8) * num_protocols); + free(protocols); + + /* + * NOTE: Sandbox SCMI driver handles device-0 only. It supports setting + * access and protocol permissions, but doesn't allow unsetting them nor + * resetting the configurations. + */ + /* set device permissions */ + ret = scmi_base_set_device_permissions(base, agent_id, 0, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = scmi_base_set_device_permissions(base, agent_id, 1, + SCMI_BASE_SET_DEVICE_PERMISSIONS_ACCESS); + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ + ret = scmi_base_set_device_permissions(base, agent_id, 0, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* set protocol permissions */ + ret = scmi_base_set_protocol_permissions(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); + ut_assertok(ret); /* SCMI_SUCCESS */ + ret = scmi_base_set_protocol_permissions(base, agent_id, 1, + SCMI_PROTOCOL_ID_CLOCK, + SCMI_BASE_SET_PROTOCOL_PERMISSIONS_ACCESS); + ut_asserteq(-ENOENT, ret); /* SCMI_NOT_FOUND */ + ret = scmi_base_set_protocol_permissions(base, agent_id, 0, + SCMI_PROTOCOL_ID_CLOCK, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + /* reset agent configuration */ + ret = scmi_base_reset_agent_configuration(base, agent_id, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = scmi_base_reset_agent_configuration(base, agent_id, + SCMI_BASE_RESET_ALL_ACCESS_PERMISSIONS); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + ret = scmi_base_reset_agent_configuration(base, agent_id, 0); + ut_asserteq(-EACCES, ret); /* SCMI_DENIED */ + + return 0; +} + +DM_TEST(dm_test_scmi_base, UT_TESTF_SCAN_FDT); + static int dm_test_scmi_clocks(struct unit_test_state *uts) { struct sandbox_scmi_agent *agent; From patchwork Wed Oct 11 10:07:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 731931 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp317531wrv; Wed, 11 Oct 2023 03:12:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG6vSsoZ3Ku2Zf88ZgaE7/bgPdbqVtRVLXIiM1tV/4BaboeHV13fCX5ybNf1W/H7lsalbe7 X-Received: by 2002:a5d:61ce:0:b0:31a:d8c0:cb8b with SMTP id q14-20020a5d61ce000000b0031ad8c0cb8bmr17694354wrv.25.1697019175531; Wed, 11 Oct 2023 03:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697019175; cv=none; d=google.com; s=arc-20160816; b=OjVU/LSMR+QqJloZETO3m3iahVExcJnjPSbkfvJD6M0uQ4ICRAa4exK3l4SZLETJfO kYoEkLur21QKxcsKTl195quIyPsPP5Il1KP/hb3kIy25M9m3BLxdlq3mHW3olT5GD0xq Db09yFwseVIUo1SbebU1+LCGHz4GioAnviP1d0WcYU4o/thVlw8yjLbeYb/SXao3+2bw 95RsX/oWFJo7Q8Mb9xVabk1/RkrKrZJHUtbCF4h1OOLtL6mGWNmmoq1FwVo4DlC4DOrH z3HEfSYj5PRXPJl2nYl2mQ1k7YcuD9tahOUSoJETTrmU91TZPs3sx3ez5/sGC52QI7Jp qjSg== 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=PumAqkPF3JV1thj0tBRnw6UxrxXN5hm1ojA9b+rWeFA=; fh=K4dQhL74gef2glEqNOnE2YOBTqRi7qf0ycKBewrN6K8=; b=kKrD4G5hw9orZ1U744Ov5pLjjrzo6ZDOGjCTv52fypYv2rvlb1D0zq0/riK8sqUeke hocLjuYli7hHVadbdwbT6e7gkpqH2SGOn1fDOWQXRtxa2PgYv8V2cjfMhiq3/TjLhJQn 3XfpyOMMWQzr9xt5Vzg1FmnKShrKEERVhV4NGvPQKCcnzoefnpIoHLjbd7Wq1dmhBa4F NEkRYY+Le3k/eS3x06zOR/vkJWWQTrJHlmNlzClgaNrHBQPbr4uDpwUrHfy0CSmez/gS p9LLd+0d7YfWzN2KVx68wrIf0l4cM1cex13drfGyleSOQKhJuzuLsJ3rzLvLEN0D3gu9 8mgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="wKx/vE2F"; 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 r5-20020adfda45000000b0031752d46de5si5921356wrl.1027.2023.10.11.03.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:12:55 -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="wKx/vE2F"; 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 E9CDC86E2F; Wed, 11 Oct 2023 12:08:25 +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="wKx/vE2F"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2A6C186CFF; Wed, 11 Oct 2023 12:08:15 +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-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) (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 440D286D20 for ; Wed, 11 Oct 2023 12:08:06 +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-il1-x12f.google.com with SMTP id e9e14a558f8ab-351610727adso3352085ab.0 for ; Wed, 11 Oct 2023 03:08:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697018875; x=1697623675; 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=PumAqkPF3JV1thj0tBRnw6UxrxXN5hm1ojA9b+rWeFA=; b=wKx/vE2Fu+ZZCzKngJBjy1MlGmNMnprJMpKekZnx22wd5pBU6kZr6hH0lmxVbo0NJV ny9+9AV/QpIxgFCHpmYgep+T7NPsN127ZJTN3ozqpBVNI3Zp/q9ZEbxj8sjw9tJvQG4M xdRRWtqfypJ2vT1hXU6mg6b8hfq+srd0eueY+KHgvcJG1Np0R+gISgx93MZqc6IXhGh/ wp8x3JGwFGd3o7Pb9Bvm8/NCzal2Wqip/+j+K8+1xtRb7dpAzq0qydjPKQey1OGlUoaT PrDQiWf7VViI7Jg1gNebNtUbnVJkC3xaeTRd5gr2ZkjnnycKPbmQy+Y9lPsKQbHN9zuQ bf9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697018875; x=1697623675; 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=PumAqkPF3JV1thj0tBRnw6UxrxXN5hm1ojA9b+rWeFA=; b=VLlBsZ0fV+nHZeSFaVEmQzwXrPV+aI/dazxPJmIuS3Me+ro3m9Ggkpe1Voq5C81TH1 bdjldPZdqkZGe738imYzE7CW11dI/dpn2s+TlqmSp3z3YWkXcGuz0VD3zvBwxE4yVePn OBN0y922hQxCV5x7W+kdd36jpBGw0/21bt37iRi4SFzM+xuxcbxuRE1AZcGjG2mDXJv6 d4kUIE2xfehgZ3jzFvQjFJiG6P1glOYdzWn4akv+oZ6vHeeQlsUUp0eIN1m/dgHlh9XD t8ZteW/k9bgkWRy8rdF/O57e6gNTvKH8zBaBJdBrux0XqrfsPmgDyZGFAnxnJf/mxGpL ipsQ== X-Gm-Message-State: AOJu0Yw9/6XXhc9l0p5b8Zi4zIeY+e5olU3h0FXFGTgMY8qlyQBoNbYY zAcTQ1hQvlnOlz7OKXx/BfyWNA== X-Received: by 2002:a05:6602:3a05:b0:792:6be4:3dcb with SMTP id by5-20020a0566023a0500b007926be43dcbmr21372237iob.2.1697018875523; Wed, 11 Oct 2023 03:07:55 -0700 (PDT) Received: from octopus.. ([2400:4050:c3e1:100:5c6c:b11a:476c:8ebb]) by smtp.gmail.com with ESMTPSA id e4-20020a62ee04000000b006889664aa6csm9663358pfi.5.2023.10.11.03.07.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:07:55 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com, sjg@chromium.org Cc: etienne.carriere@st.com, u-boot@lists.denx.de, AKASHI Takahiro , Etienne Carriere Subject: [PATCH v6 14/14] firmware: scmi: add a check against availability of protocols Date: Wed, 11 Oct 2023 19:07:07 +0900 Message-Id: <20231011100707.1007417-15-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231011100707.1007417-1-takahiro.akashi@linaro.org> References: <20231011100707.1007417-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 Now that we have Base protocol support, we will be able to check if a given protocol is really supported by the SCMI server (firmware). Signed-off-by: AKASHI Takahiro Reviewed-by: Etienne Carriere Reviewed-by: Simon Glass --- v3 * new; import this patch from my followup patch set --- drivers/firmware/scmi/scmi_agent-uclass.c | 41 +++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/scmi/scmi_agent-uclass.c b/drivers/firmware/scmi/scmi_agent-uclass.c index b1a9c36310c1..6f585b96f740 100644 --- a/drivers/firmware/scmi/scmi_agent-uclass.c +++ b/drivers/firmware/scmi/scmi_agent-uclass.c @@ -38,6 +38,38 @@ static const struct error_code scmi_linux_errmap[] = { { .scmi = SCMI_PROTOCOL_ERROR, .errno = -EPROTO, }, }; +/** + * scmi_protocol_is_supported - check availability of protocol + * @dev: SCMI agent device + * @proto_id: Identifier of protocol + * + * check if the protocol, @proto_id, is provided by the SCMI agent, + * @dev. + * + * Return: 0 on success, error code otherwise + */ +static bool scmi_protocol_is_supported(struct udevice *dev, + enum scmi_std_protocol proto_id) +{ + struct scmi_agent_priv *priv; + int i; + + if (proto_id == SCMI_PROTOCOL_ID_BASE) + return true; + + priv = dev_get_uclass_plat(dev); + if (!priv) { + dev_err(dev, "No priv data found\n"); + return false; + } + + for (i = 0; i < priv->num_protocols; i++) + if (priv->protocols[i] == proto_id) + return true; + + return false; +} + struct udevice *scmi_get_protocol(struct udevice *dev, enum scmi_std_protocol id) { @@ -374,15 +406,18 @@ static int scmi_bind_protocols(struct udevice *dev) name = ofnode_get_name(node); switch (protocol_id) { case SCMI_PROTOCOL_ID_CLOCK: - if (CONFIG_IS_ENABLED(CLK_SCMI)) + if (CONFIG_IS_ENABLED(CLK_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) drv = DM_DRIVER_GET(scmi_clock); break; case SCMI_PROTOCOL_ID_RESET_DOMAIN: - if (IS_ENABLED(CONFIG_RESET_SCMI)) + if (IS_ENABLED(CONFIG_RESET_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) drv = DM_DRIVER_GET(scmi_reset_domain); break; case SCMI_PROTOCOL_ID_VOLTAGE_DOMAIN: - if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI)) { + if (IS_ENABLED(CONFIG_DM_REGULATOR_SCMI) && + scmi_protocol_is_supported(dev, protocol_id)) { node = ofnode_find_subnode(node, "regulators"); if (!ofnode_valid(node)) { dev_err(dev, "no regulators node\n");