1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2021 Xilinx, Inc. - Michal Simek
6 #define LOG_CATEGORY UCLASS_RESET
10 #include <dm/device_compat.h>
11 #include <reset-uclass.h>
12 #include <zynqmp_firmware.h>
14 #define ZYNQMP_NR_RESETS (ZYNQMP_PM_RESET_END - ZYNQMP_PM_RESET_START)
15 #define ZYNQMP_RESET_ID ZYNQMP_PM_RESET_START
17 struct zynqmp_reset_priv {
22 static int zynqmp_pm_reset_assert(const u32 reset,
23 const enum zynqmp_pm_reset_action assert_flag)
25 return xilinx_pm_request(PM_RESET_ASSERT, reset, assert_flag, 0, 0,
29 static int zynqmp_reset_assert(struct reset_ctl *rst)
31 struct zynqmp_reset_priv *priv = dev_get_priv(rst->dev);
33 dev_dbg(rst->dev, "%s(rst=%p) (id=%lu)\n", __func__, rst, rst->id);
35 return zynqmp_pm_reset_assert(priv->reset_id + rst->id,
36 PM_RESET_ACTION_ASSERT);
39 static int zynqmp_reset_deassert(struct reset_ctl *rst)
41 struct zynqmp_reset_priv *priv = dev_get_priv(rst->dev);
43 dev_dbg(rst->dev, "%s(rst=%p) (id=%lu)\n", __func__, rst, rst->id);
45 return zynqmp_pm_reset_assert(priv->reset_id + rst->id,
46 PM_RESET_ACTION_RELEASE);
49 static int zynqmp_reset_request(struct reset_ctl *rst)
51 struct zynqmp_reset_priv *priv = dev_get_priv(rst->dev);
53 dev_dbg(rst->dev, "%s(rst=%p) (id=%lu) (nr_reset=%d)\n", __func__,
54 rst, rst->id, priv->nr_reset);
56 if (priv->nr_reset && rst->id > priv->nr_reset)
62 static int zynqmp_reset_probe(struct udevice *dev)
64 struct zynqmp_reset_priv *priv = dev_get_priv(dev);
66 if (device_is_compatible(dev, "xlnx,zynqmp-reset")) {
67 priv->reset_id = ZYNQMP_RESET_ID;
68 priv->nr_reset = ZYNQMP_NR_RESETS;
74 const struct reset_ops zynqmp_reset_ops = {
75 .request = zynqmp_reset_request,
76 .rst_assert = zynqmp_reset_assert,
77 .rst_deassert = zynqmp_reset_deassert,
80 static const struct udevice_id zynqmp_reset_ids[] = {
81 { .compatible = "xlnx,zynqmp-reset" },
82 { .compatible = "xlnx,versal-reset" },
83 { .compatible = "xlnx,versal-net-reset" },
87 U_BOOT_DRIVER(zynqmp_reset) = {
88 .name = "zynqmp_reset",
90 .of_match = zynqmp_reset_ids,
91 .ops = &zynqmp_reset_ops,
92 .probe = zynqmp_reset_probe,
93 .priv_auto = sizeof(struct zynqmp_reset_priv),