]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
reset: scmi: support SCMI multi-channel
authorEtienne Carriere <etienne.carriere@linaro.org>
Tue, 31 May 2022 16:09:26 +0000 (18:09 +0200)
committerTom Rini <trini@konsulko.com>
Thu, 23 Jun 2022 17:12:55 +0000 (13:12 -0400)
Update SCMI reset controller driver to get its assigned SCMI channel
during initialization. This change allows SCMI reset domain protocol
to use a dedicated channel when defined in the DT. The reference is
saved in SCMI reset controller driver private data.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
drivers/reset/reset-scmi.c

index 30b26ec9d31de6293cf0e58f2f2700ffc4cca7af..122556162ec3be967683b7d634a0d90c6afa40aa 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- * Copyright (C) 2019-2020 Linaro Limited
+ * Copyright (C) 2019-2022 Linaro Limited
  */
 
 #define LOG_CATEGORY UCLASS_RESET
 #include <scmi_protocols.h>
 #include <asm/types.h>
 
+/**
+ * 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,
@@ -26,7 +35,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, NULL, &msg);
+       ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg);
        if (ret)
                return ret;
 
@@ -45,6 +54,7 @@ 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,
        };
@@ -58,7 +68,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, NULL, &msg);
+       ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg);
        if (ret)
                return ret;
 
@@ -71,8 +81,17 @@ static const struct reset_ops scmi_reset_domain_ops = {
        .rst_deassert   = scmi_reset_deassert,
 };
 
+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);
+}
+
 U_BOOT_DRIVER(scmi_reset_domain) = {
        .name = "scmi_reset_domain",
        .id = UCLASS_RESET,
        .ops = &scmi_reset_domain_ops,
+       .probe = scmi_reset_probe,
+       .priv_auto = sizeof(struct scmi_reset_priv *),
 };