mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-07 05:34:28 +00:00
720620e691
-----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAl/0YVIACgkQFHw5/5Y0 tywtEwv/cJWlKgcSnYjuJrxwuJdauUTfXdbUgtCxOtBw/BP4dsKkbGTJPw5q5M+4 LJJSKyksmJVTX26h1dpkzQjOpWtTDnWqm5CTIxD52oQD7pxK+zCQ9T6S+QbQD0Se ogHmZluzFoluxbNgo8tiO52xvMhDO3TVAzxsNDdGfkd5/tAXOHClPc34RmAkdRHU VsR89AKdT2q543fiUfrRZYDzdctaNWhRGXMDcJ4+QU/8hQhrpcr8EtHbF+3mWX4K pA01pDz150Rn4UI6S2xKEWrjSTHe55fxVj/Qj0rq9z2E/+NqGXemf5s13AR0G/z3 PqHdVLHzDe64pbOvmyU1pVQ0aMb8vMJUnqx68SQZY3On2c+MjRWQ+7aVVaKOcPGp uatk6QMrggHp3Li+3yZrLBE0qPr/sNMVb7mUesdZb6lFd2VIs8siwhfeGXMS+nDI xePzsR43Fnn5Q5KIqqvcWUb+TTTqUDUff0wyAU8NBgCaIBIZK8h2ppS1jjnbms0I mr8Er2vb =Dfum -----END PGP SIGNATURE----- Merge tag 'v2021.01-rc5' into next Prepare v2021.01-rc5 Signed-off-by: Tom Rini <trini@konsulko.com>
105 lines
2.6 KiB
C
105 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (C) 2017, STMicroelectronics - All Rights Reserved
|
|
* Author(s): Patrice Chotard, <patrice.chotard@foss.st.com> for STMicroelectronics.
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <log.h>
|
|
#include <malloc.h>
|
|
#include <reset-uclass.h>
|
|
#include <stm32_rcc.h>
|
|
#include <asm/io.h>
|
|
#include <linux/bitops.h>
|
|
|
|
/* offset of register without set/clear management */
|
|
#define RCC_MP_GCR_OFFSET 0x10C
|
|
|
|
/* reset clear offset for STM32MP RCC */
|
|
#define RCC_CL 0x4
|
|
|
|
struct stm32_reset_priv {
|
|
fdt_addr_t base;
|
|
};
|
|
|
|
static int stm32_reset_request(struct reset_ctl *reset_ctl)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int stm32_reset_free(struct reset_ctl *reset_ctl)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int stm32_reset_assert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
|
|
int offset = reset_ctl->id % BITS_PER_LONG;
|
|
debug("%s: reset id = %ld bank = %d offset = %d)\n", __func__,
|
|
reset_ctl->id, bank, offset);
|
|
|
|
if (dev_get_driver_data(reset_ctl->dev) == STM32MP1)
|
|
if (bank != RCC_MP_GCR_OFFSET)
|
|
/* reset assert is done in rcc set register */
|
|
writel(BIT(offset), priv->base + bank);
|
|
else
|
|
clrbits_le32(priv->base + bank, BIT(offset));
|
|
else
|
|
setbits_le32(priv->base + bank, BIT(offset));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int stm32_reset_deassert(struct reset_ctl *reset_ctl)
|
|
{
|
|
struct stm32_reset_priv *priv = dev_get_priv(reset_ctl->dev);
|
|
int bank = (reset_ctl->id / BITS_PER_LONG) * 4;
|
|
int offset = reset_ctl->id % BITS_PER_LONG;
|
|
debug("%s: reset id = %ld bank = %d offset = %d)\n", __func__,
|
|
reset_ctl->id, bank, offset);
|
|
|
|
if (dev_get_driver_data(reset_ctl->dev) == STM32MP1)
|
|
if (bank != RCC_MP_GCR_OFFSET)
|
|
/* reset deassert is done in rcc clr register */
|
|
writel(BIT(offset), priv->base + bank + RCC_CL);
|
|
else
|
|
setbits_le32(priv->base + bank, BIT(offset));
|
|
else
|
|
clrbits_le32(priv->base + bank, BIT(offset));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct reset_ops stm32_reset_ops = {
|
|
.request = stm32_reset_request,
|
|
.rfree = stm32_reset_free,
|
|
.rst_assert = stm32_reset_assert,
|
|
.rst_deassert = stm32_reset_deassert,
|
|
};
|
|
|
|
static int stm32_reset_probe(struct udevice *dev)
|
|
{
|
|
struct stm32_reset_priv *priv = dev_get_priv(dev);
|
|
|
|
priv->base = dev_read_addr(dev);
|
|
if (priv->base == FDT_ADDR_T_NONE) {
|
|
/* for MFD, get address of parent */
|
|
priv->base = dev_read_addr(dev->parent);
|
|
if (priv->base == FDT_ADDR_T_NONE)
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_DRIVER(stm32_rcc_reset) = {
|
|
.name = "stm32_rcc_reset",
|
|
.id = UCLASS_RESET,
|
|
.probe = stm32_reset_probe,
|
|
.priv_auto = sizeof(struct stm32_reset_priv),
|
|
.ops = &stm32_reset_ops,
|
|
};
|