2 * Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
4 * Derived from linux/arch/mips/bcm63xx/reset.c:
5 * Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
7 * SPDX-License-Identifier: GPL-2.0+
13 #include <reset-uclass.h>
18 struct bcm6345_reset_priv {
22 static int bcm6345_reset_assert(struct reset_ctl *rst)
24 struct bcm6345_reset_priv *priv = dev_get_priv(rst->dev);
26 clrbits_be32(priv->regs, BIT(rst->id));
32 static int bcm6345_reset_deassert(struct reset_ctl *rst)
34 struct bcm6345_reset_priv *priv = dev_get_priv(rst->dev);
36 setbits_be32(priv->regs, BIT(rst->id));
42 static int bcm6345_reset_free(struct reset_ctl *rst)
47 static int bcm6345_reset_request(struct reset_ctl *rst)
49 if (rst->id >= MAX_RESETS)
52 return bcm6345_reset_assert(rst);
55 struct reset_ops bcm6345_reset_reset_ops = {
56 .free = bcm6345_reset_free,
57 .request = bcm6345_reset_request,
58 .rst_assert = bcm6345_reset_assert,
59 .rst_deassert = bcm6345_reset_deassert,
62 static const struct udevice_id bcm6345_reset_ids[] = {
63 { .compatible = "brcm,bcm6345-reset" },
67 static int bcm6345_reset_probe(struct udevice *dev)
69 struct bcm6345_reset_priv *priv = dev_get_priv(dev);
73 addr = dev_get_addr_size_index(dev, 0, &size);
74 if (addr == FDT_ADDR_T_NONE)
77 priv->regs = ioremap(addr, size);
82 U_BOOT_DRIVER(bcm6345_reset) = {
83 .name = "bcm6345-reset",
85 .of_match = bcm6345_reset_ids,
86 .ops = &bcm6345_reset_reset_ops,
87 .probe = bcm6345_reset_probe,
88 .priv_auto_alloc_size = sizeof(struct bcm6345_reset_priv),