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>
132 lines
2.8 KiB
C
132 lines
2.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Watchdog driver for SBSA
|
|
*
|
|
* Copyright 2020 NXP
|
|
*/
|
|
|
|
#include <asm/io.h>
|
|
#include <common.h>
|
|
#include <dm/device.h>
|
|
#include <dm/fdtaddr.h>
|
|
#include <dm/read.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/err.h>
|
|
#include <watchdog.h>
|
|
#include <wdt.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
/* SBSA Generic Watchdog register definitions */
|
|
/* refresh frame */
|
|
#define SBSA_GWDT_WRR 0x000
|
|
|
|
/* control frame */
|
|
#define SBSA_GWDT_WCS 0x000
|
|
#define SBSA_GWDT_WOR 0x008
|
|
#define SBSA_GWDT_WCV 0x010
|
|
|
|
/* refresh/control frame */
|
|
#define SBSA_GWDT_W_IIDR 0xfcc
|
|
#define SBSA_GWDT_IDR 0xfd0
|
|
|
|
/* Watchdog Control and Status Register */
|
|
#define SBSA_GWDT_WCS_EN BIT(0)
|
|
#define SBSA_GWDT_WCS_WS0 BIT(1)
|
|
#define SBSA_GWDT_WCS_WS1 BIT(2)
|
|
|
|
struct sbsa_gwdt_priv {
|
|
void __iomem *reg_refresh;
|
|
void __iomem *reg_control;
|
|
};
|
|
|
|
static int sbsa_gwdt_reset(struct udevice *dev)
|
|
{
|
|
struct sbsa_gwdt_priv *priv = dev_get_priv(dev);
|
|
|
|
writel(0, priv->reg_refresh + SBSA_GWDT_WRR);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sbsa_gwdt_start(struct udevice *dev, u64 timeout, ulong flags)
|
|
{
|
|
struct sbsa_gwdt_priv *priv = dev_get_priv(dev);
|
|
u32 clk;
|
|
|
|
/*
|
|
* it work in the single stage mode in u-boot,
|
|
* The first signal (WS0) is ignored,
|
|
* the timeout is (WOR * 2), so the WOR should be configured
|
|
* to half value of timeout.
|
|
*/
|
|
clk = get_tbclk();
|
|
writel(clk / (2 * 1000) * timeout,
|
|
priv->reg_control + SBSA_GWDT_WOR);
|
|
|
|
/* writing WCS will cause an explicit watchdog refresh */
|
|
writel(SBSA_GWDT_WCS_EN, priv->reg_control + SBSA_GWDT_WCS);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sbsa_gwdt_stop(struct udevice *dev)
|
|
{
|
|
struct sbsa_gwdt_priv *priv = dev_get_priv(dev);
|
|
|
|
writel(0, priv->reg_control + SBSA_GWDT_WCS);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sbsa_gwdt_expire_now(struct udevice *dev, ulong flags)
|
|
{
|
|
sbsa_gwdt_start(dev, 0, flags);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sbsa_gwdt_probe(struct udevice *dev)
|
|
{
|
|
debug("%s: Probing wdt%u (sbsa-gwdt)\n", __func__, dev_seq(dev));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sbsa_gwdt_of_to_plat(struct udevice *dev)
|
|
{
|
|
struct sbsa_gwdt_priv *priv = dev_get_priv(dev);
|
|
|
|
priv->reg_control = (void __iomem *)dev_read_addr_index(dev, 0);
|
|
if (IS_ERR(priv->reg_control))
|
|
return PTR_ERR(priv->reg_control);
|
|
|
|
priv->reg_refresh = (void __iomem *)dev_read_addr_index(dev, 1);
|
|
if (IS_ERR(priv->reg_refresh))
|
|
return PTR_ERR(priv->reg_refresh);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct wdt_ops sbsa_gwdt_ops = {
|
|
.start = sbsa_gwdt_start,
|
|
.reset = sbsa_gwdt_reset,
|
|
.stop = sbsa_gwdt_stop,
|
|
.expire_now = sbsa_gwdt_expire_now,
|
|
};
|
|
|
|
static const struct udevice_id sbsa_gwdt_ids[] = {
|
|
{ .compatible = "arm,sbsa-gwdt" },
|
|
{}
|
|
};
|
|
|
|
U_BOOT_DRIVER(sbsa_gwdt) = {
|
|
.name = "sbsa_gwdt",
|
|
.id = UCLASS_WDT,
|
|
.of_match = sbsa_gwdt_ids,
|
|
.probe = sbsa_gwdt_probe,
|
|
.priv_auto = sizeof(struct sbsa_gwdt_priv),
|
|
.of_to_plat = sbsa_gwdt_of_to_plat,
|
|
.ops = &sbsa_gwdt_ops,
|
|
};
|