1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019, Linaro Limited
10 #include <dt-bindings/reset/ti-syscon.h>
11 #include <reset-uclass.h>
13 struct hisi_reset_priv {
17 static int hisi_reset_deassert(struct reset_ctl *rst)
19 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
22 val = readl(priv->base + rst->data);
23 if (rst->polarity & DEASSERT_SET)
27 writel(val, priv->base + rst->data);
32 static int hisi_reset_assert(struct reset_ctl *rst)
34 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
37 val = readl(priv->base + rst->data);
38 if (rst->polarity & ASSERT_SET)
42 writel(val, priv->base + rst->data);
47 static int hisi_reset_free(struct reset_ctl *rst)
52 static int hisi_reset_request(struct reset_ctl *rst)
57 static int hisi_reset_of_xlate(struct reset_ctl *rst,
58 struct ofnode_phandle_args *args)
60 if (args->args_count != 3) {
61 debug("Invalid args_count: %d\n", args->args_count);
65 /* Use .data field as register offset and .id field as bit shift */
66 rst->data = args->args[0];
67 rst->id = args->args[1];
68 rst->polarity = args->args[2];
73 static const struct reset_ops hisi_reset_reset_ops = {
74 .of_xlate = hisi_reset_of_xlate,
75 .request = hisi_reset_request,
76 .rfree = hisi_reset_free,
77 .rst_assert = hisi_reset_assert,
78 .rst_deassert = hisi_reset_deassert,
81 static const struct udevice_id hisi_reset_ids[] = {
82 { .compatible = "hisilicon,hi3798cv200-reset" },
86 static int hisi_reset_probe(struct udevice *dev)
88 struct hisi_reset_priv *priv = dev_get_priv(dev);
90 priv->base = dev_remap_addr(dev);
97 U_BOOT_DRIVER(hisi_reset) = {
98 .name = "hisilicon_reset",
100 .of_match = hisi_reset_ids,
101 .ops = &hisi_reset_reset_ops,
102 .probe = hisi_reset_probe,
103 .priv_auto_alloc_size = sizeof(struct hisi_reset_priv),