mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
99f8ad7321
This change switches all existing users of ast2500 Watchdog to Driver Model based Watchdog driver. To perform system reset Sysreset Driver uses first Watchdog device found via uclass_first_device call. Since the system is going to be reset anyway it does not make much difference which watchdog is used. Instead of using Watchdog to reset itself, SDRAM driver now uses Reset driver to do that. These were the only users of the old Watchdog API, so that API is removed. This all is done in one change to avoid having to maintain dual API for watchdog in between. Signed-off-by: Maxim Sloyko <maxims@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
53 lines
947 B
C
53 lines
947 B
C
/*
|
|
* (C) Copyright 2016 Google, Inc
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <sysreset.h>
|
|
#include <wdt.h>
|
|
#include <asm/io.h>
|
|
#include <asm/arch/wdt.h>
|
|
#include <linux/err.h>
|
|
|
|
static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
|
|
{
|
|
struct udevice *wdt;
|
|
u32 reset_mode;
|
|
int ret = uclass_first_device(UCLASS_WDT, &wdt);
|
|
|
|
if (ret)
|
|
return ret;
|
|
|
|
switch (type) {
|
|
case SYSRESET_WARM:
|
|
reset_mode = WDT_CTRL_RESET_CPU;
|
|
break;
|
|
case SYSRESET_COLD:
|
|
reset_mode = WDT_CTRL_RESET_CHIP;
|
|
break;
|
|
default:
|
|
return -EPROTONOSUPPORT;
|
|
}
|
|
|
|
ret = wdt_expire_now(wdt, reset_mode);
|
|
if (ret) {
|
|
debug("Sysreset failed: %d", ret);
|
|
return ret;
|
|
}
|
|
|
|
return -EINPROGRESS;
|
|
}
|
|
|
|
static struct sysreset_ops ast_sysreset = {
|
|
.request = ast_sysreset_request,
|
|
};
|
|
|
|
U_BOOT_DRIVER(sysreset_ast) = {
|
|
.name = "ast_sysreset",
|
|
.id = UCLASS_SYSRESET,
|
|
.ops = &ast_sysreset,
|
|
};
|