1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019, Linaro Limited
9 #include <dt-bindings/reset/ti-syscon.h>
10 #include <reset-uclass.h>
12 struct hisi_reset_priv {
16 static int hisi_reset_deassert(struct reset_ctl *rst)
18 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
21 val = readl(priv->base + rst->data);
22 if (rst->polarity & DEASSERT_SET)
26 writel(val, priv->base + rst->data);
31 static int hisi_reset_assert(struct reset_ctl *rst)
33 struct hisi_reset_priv *priv = dev_get_priv(rst->dev);
36 val = readl(priv->base + rst->data);
37 if (rst->polarity & ASSERT_SET)
41 writel(val, priv->base + rst->data);
46 static int hisi_reset_free(struct reset_ctl *rst)
51 static int hisi_reset_request(struct reset_ctl *rst)
56 static int hisi_reset_of_xlate(struct reset_ctl *rst,
57 struct ofnode_phandle_args *args)
59 if (args->args_count != 3) {
60 debug("Invalid args_count: %d\n", args->args_count);
64 /* Use .data field as register offset and .id field as bit shift */
65 rst->data = args->args[0];
66 rst->id = args->args[1];
67 rst->polarity = args->args[2];
72 static const struct reset_ops hisi_reset_reset_ops = {
73 .of_xlate = hisi_reset_of_xlate,
74 .request = hisi_reset_request,
75 .rfree = hisi_reset_free,
76 .rst_assert = hisi_reset_assert,
77 .rst_deassert = hisi_reset_deassert,
80 static const struct udevice_id hisi_reset_ids[] = {
81 { .compatible = "hisilicon,hi3798cv200-reset" },
85 static int hisi_reset_probe(struct udevice *dev)
87 struct hisi_reset_priv *priv = dev_get_priv(dev);
89 priv->base = dev_remap_addr(dev);
96 U_BOOT_DRIVER(hisi_reset) = {
97 .name = "hisilicon_reset",
99 .of_match = hisi_reset_ids,
100 .ops = &hisi_reset_reset_ops,
101 .probe = hisi_reset_probe,
102 .priv_auto_alloc_size = sizeof(struct hisi_reset_priv),