mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-11 05:42:58 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
104 lines
2.5 KiB
C
104 lines
2.5 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Socfpga Reset Controller Driver
|
|
*
|
|
* Copyright 2014 Steffen Trumtrar <s.trumtrar@pengutronix.de>
|
|
*
|
|
* based on
|
|
* Allwinner SoCs Reset Controller driver
|
|
*
|
|
* Copyright 2013 Maxime Ripard
|
|
*
|
|
* Maxime Ripard <maxime.ripard@free-electrons.com>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <dm/of_access.h>
|
|
#include <reset-uclass.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/io.h>
|
|
#include <linux/sizes.h>
|
|
|
|
#define BANK_INCREMENT 4
|
|
#define NR_BANKS 8
|
|
|
|
struct socfpga_reset_data {
|
|
void __iomem *membase;
|
|
};
|
|
|
|
static int socfpga_reset_assert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct socfpga_reset_data *data = dev_get_priv(reset_ctl->dev);
|
|
int id = reset_ctl->id;
|
|
int reg_width = sizeof(u32);
|
|
int bank = id / (reg_width * BITS_PER_BYTE);
|
|
int offset = id % (reg_width * BITS_PER_BYTE);
|
|
|
|
setbits_le32(data->membase + (bank * BANK_INCREMENT), BIT(offset));
|
|
return 0;
|
|
}
|
|
|
|
static int socfpga_reset_deassert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct socfpga_reset_data *data = dev_get_priv(reset_ctl->dev);
|
|
int id = reset_ctl->id;
|
|
int reg_width = sizeof(u32);
|
|
int bank = id / (reg_width * BITS_PER_BYTE);
|
|
int offset = id % (reg_width * BITS_PER_BYTE);
|
|
|
|
clrbits_le32(data->membase + (bank * BANK_INCREMENT), BIT(offset));
|
|
return 0;
|
|
}
|
|
|
|
static int socfpga_reset_request(struct reset_ctl *reset_ctl)
|
|
{
|
|
debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__,
|
|
reset_ctl, reset_ctl->dev, reset_ctl->id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int socfpga_reset_free(struct reset_ctl *reset_ctl)
|
|
{
|
|
debug("%s(reset_ctl=%p) (dev=%p, id=%lu)\n", __func__, reset_ctl,
|
|
reset_ctl->dev, reset_ctl->id);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct reset_ops socfpga_reset_ops = {
|
|
.request = socfpga_reset_request,
|
|
.free = socfpga_reset_free,
|
|
.rst_assert = socfpga_reset_assert,
|
|
.rst_deassert = socfpga_reset_deassert,
|
|
};
|
|
|
|
static int socfpga_reset_probe(struct udevice *dev)
|
|
{
|
|
struct socfpga_reset_data *data = dev_get_priv(dev);
|
|
const void *blob = gd->fdt_blob;
|
|
int node = dev_of_offset(dev);
|
|
u32 modrst_offset;
|
|
|
|
data->membase = devfdt_get_addr_ptr(dev);
|
|
|
|
modrst_offset = fdtdec_get_int(blob, node, "altr,modrst-offset", 0x10);
|
|
data->membase += modrst_offset;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct udevice_id socfpga_reset_match[] = {
|
|
{ .compatible = "altr,rst-mgr" },
|
|
{ /* sentinel */ },
|
|
};
|
|
|
|
U_BOOT_DRIVER(socfpga_reset) = {
|
|
.name = "socfpga-reset",
|
|
.id = UCLASS_RESET,
|
|
.of_match = socfpga_reset_match,
|
|
.probe = socfpga_reset_probe,
|
|
.priv_auto_alloc_size = sizeof(struct socfpga_reset_data),
|
|
.ops = &socfpga_reset_ops,
|
|
};
|