1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019, Linaro Limited
11 #include <dt-bindings/reset/ti-syscon.h>
12 #include <reset-uclass.h>
14 struct hisi_reset_priv {
18 static int hisi_reset_deassert(struct reset_ctl *rst)
20 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
23 val = readl(priv->base + rst->data);
24 if (rst->polarity & DEASSERT_SET)
28 writel(val, priv->base + rst->data);
33 static int hisi_reset_assert(struct reset_ctl *rst)
35 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
38 val = readl(priv->base + rst->data);
39 if (rst->polarity & ASSERT_SET)
43 writel(val, priv->base + rst->data);
48 static int hisi_reset_free(struct reset_ctl *rst)
53 static int hisi_reset_request(struct reset_ctl *rst)
58 static int hisi_reset_of_xlate(struct reset_ctl *rst,
59 struct ofnode_phandle_args *args)
61 if (args->args_count != 3) {
62 debug("Invalid args_count: %d\n", args->args_count);
66 /* Use .data field as register offset and .id field as bit shift */
67 rst->data = args->args[0];
68 rst->id = args->args[1];
69 rst->polarity = args->args[2];
74 static const struct reset_ops hisi_reset_reset_ops = {
75 .of_xlate = hisi_reset_of_xlate,
76 .request = hisi_reset_request,
77 .rfree = hisi_reset_free,
78 .rst_assert = hisi_reset_assert,
79 .rst_deassert = hisi_reset_deassert,
82 static const struct udevice_id hisi_reset_ids[] = {
83 { .compatible = "hisilicon,hi3798cv200-reset" },
87 static int hisi_reset_probe(struct udevice *dev)
89 struct hisi_reset_priv *priv = dev_get_priv(dev);
91 priv->base = dev_remap_addr(dev);
98 U_BOOT_DRIVER(hisi_reset) = {
99 .name = "hisilicon_reset",
101 .of_match = hisi_reset_ids,
102 .ops = &hisi_reset_reset_ops,
103 .probe = hisi_reset_probe,
104 .priv_auto_alloc_size = sizeof(struct hisi_reset_priv),