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>
13 #include <linux/bitops.h>
15 struct hisi_reset_priv {
19 static int hisi_reset_deassert(struct reset_ctl *rst)
21 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
24 val = readl(priv->base + rst->data);
25 if (rst->polarity & DEASSERT_SET)
29 writel(val, priv->base + rst->data);
34 static int hisi_reset_assert(struct reset_ctl *rst)
36 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
39 val = readl(priv->base + rst->data);
40 if (rst->polarity & ASSERT_SET)
44 writel(val, priv->base + rst->data);
49 static int hisi_reset_of_xlate(struct reset_ctl *rst,
50 struct ofnode_phandle_args *args)
52 if (args->args_count != 3) {
53 debug("Invalid args_count: %d\n", args->args_count);
57 /* Use .data field as register offset and .id field as bit shift */
58 rst->data = args->args[0];
59 rst->id = args->args[1];
60 rst->polarity = args->args[2];
65 static const struct reset_ops hisi_reset_reset_ops = {
66 .of_xlate = hisi_reset_of_xlate,
67 .rst_assert = hisi_reset_assert,
68 .rst_deassert = hisi_reset_deassert,
71 static const struct udevice_id hisi_reset_ids[] = {
72 { .compatible = "hisilicon,hi3798cv200-reset" },
76 static int hisi_reset_probe(struct udevice *dev)
78 struct hisi_reset_priv *priv = dev_get_priv(dev);
80 priv->base = dev_remap_addr(dev);
87 U_BOOT_DRIVER(hisi_reset) = {
88 .name = "hisilicon_reset",
90 .of_match = hisi_reset_ids,
91 .ops = &hisi_reset_reset_ops,
92 .probe = hisi_reset_probe,
93 .priv_auto = sizeof(struct hisi_reset_priv),