2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2017-05-03 13:10:21 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 Álvaro Fernández Rojas <noltari@gmail.com>
|
|
|
|
*
|
|
|
|
* Derived from linux/arch/mips/bcm63xx/reset.c:
|
|
|
|
* Copyright (C) 2012 Jonas Gorski <jonas.gorski@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-02-03 14:36:16 +00:00
|
|
|
#include <malloc.h>
|
2017-05-03 13:10:21 +00:00
|
|
|
#include <reset-uclass.h>
|
|
|
|
#include <asm/io.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2020-05-10 17:40:11 +00:00
|
|
|
#include <linux/delay.h>
|
2017-05-03 13:10:21 +00:00
|
|
|
|
|
|
|
#define MAX_RESETS 32
|
|
|
|
|
|
|
|
struct bcm6345_reset_priv {
|
|
|
|
void __iomem *regs;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int bcm6345_reset_assert(struct reset_ctl *rst)
|
|
|
|
{
|
|
|
|
struct bcm6345_reset_priv *priv = dev_get_priv(rst->dev);
|
|
|
|
|
|
|
|
clrbits_be32(priv->regs, BIT(rst->id));
|
|
|
|
mdelay(20);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6345_reset_deassert(struct reset_ctl *rst)
|
|
|
|
{
|
|
|
|
struct bcm6345_reset_priv *priv = dev_get_priv(rst->dev);
|
|
|
|
|
|
|
|
setbits_be32(priv->regs, BIT(rst->id));
|
|
|
|
mdelay(20);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int bcm6345_reset_request(struct reset_ctl *rst)
|
|
|
|
{
|
|
|
|
if (rst->id >= MAX_RESETS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return bcm6345_reset_assert(rst);
|
|
|
|
}
|
|
|
|
|
|
|
|
struct reset_ops bcm6345_reset_reset_ops = {
|
|
|
|
.request = bcm6345_reset_request,
|
|
|
|
.rst_assert = bcm6345_reset_assert,
|
|
|
|
.rst_deassert = bcm6345_reset_deassert,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct udevice_id bcm6345_reset_ids[] = {
|
|
|
|
{ .compatible = "brcm,bcm6345-reset" },
|
|
|
|
{ /* sentinel */ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int bcm6345_reset_probe(struct udevice *dev)
|
|
|
|
{
|
|
|
|
struct bcm6345_reset_priv *priv = dev_get_priv(dev);
|
|
|
|
|
2018-03-22 18:39:31 +00:00
|
|
|
priv->regs = dev_remap_addr(dev);
|
|
|
|
if (!priv->regs)
|
2017-05-03 13:10:21 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_DRIVER(bcm6345_reset) = {
|
|
|
|
.name = "bcm6345-reset",
|
|
|
|
.id = UCLASS_RESET,
|
|
|
|
.of_match = bcm6345_reset_ids,
|
|
|
|
.ops = &bcm6345_reset_reset_ops,
|
|
|
|
.probe = bcm6345_reset_probe,
|
2020-12-03 23:55:17 +00:00
|
|
|
.priv_auto = sizeof(struct bcm6345_reset_priv),
|
2017-05-03 13:10:21 +00:00
|
|
|
};
|