1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2019-2022 Linaro Limited
6 #define LOG_CATEGORY UCLASS_RESET
11 #include <reset-uclass.h>
12 #include <scmi_agent.h>
13 #include <scmi_protocols.h>
14 #include <asm/types.h>
17 * struct scmi_reset_priv - Private data for SCMI reset controller
18 * @channel: Reference to the SCMI channel to use
20 struct scmi_reset_priv {
21 struct scmi_channel *channel;
24 static int scmi_reset_set_level(struct reset_ctl *rst, bool assert_not_deassert)
26 struct scmi_reset_priv *priv = dev_get_priv(rst->dev);
27 struct scmi_rd_reset_in in = {
29 .flags = assert_not_deassert ? SCMI_RD_RESET_FLAG_ASSERT : 0,
32 struct scmi_rd_reset_out out;
33 struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_RESET_DOMAIN,
34 SCMI_RESET_DOMAIN_RESET,
38 ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg);
42 return scmi_to_linux_errno(out.status);
45 static int scmi_reset_assert(struct reset_ctl *rst)
47 return scmi_reset_set_level(rst, true);
50 static int scmi_reset_deassert(struct reset_ctl *rst)
52 return scmi_reset_set_level(rst, false);
55 static int scmi_reset_request(struct reset_ctl *rst)
57 struct scmi_reset_priv *priv = dev_get_priv(rst->dev);
58 struct scmi_rd_attr_in in = {
61 struct scmi_rd_attr_out out;
62 struct scmi_msg msg = SCMI_MSG_IN(SCMI_PROTOCOL_ID_RESET_DOMAIN,
63 SCMI_RESET_DOMAIN_ATTRIBUTES,
68 * We don't really care about the attribute, just check
69 * the reset domain exists.
71 ret = devm_scmi_process_msg(rst->dev, priv->channel, &msg);
75 return scmi_to_linux_errno(out.status);
78 static const struct reset_ops scmi_reset_domain_ops = {
79 .request = scmi_reset_request,
80 .rst_assert = scmi_reset_assert,
81 .rst_deassert = scmi_reset_deassert,
84 static int scmi_reset_probe(struct udevice *dev)
86 struct scmi_reset_priv *priv = dev_get_priv(dev);
88 return devm_scmi_of_get_channel(dev, &priv->channel);
91 U_BOOT_DRIVER(scmi_reset_domain) = {
92 .name = "scmi_reset_domain",
94 .ops = &scmi_reset_domain_ops,
95 .probe = scmi_reset_probe,
96 .priv_auto = sizeof(struct scmi_reset_priv *),