2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-01-18 21:44:55 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2016 Google, Inc
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <errno.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2017-01-18 21:44:55 +00:00
|
|
|
#include <sysreset.h>
|
2017-04-17 19:00:26 +00:00
|
|
|
#include <wdt.h>
|
2017-01-18 21:44:55 +00:00
|
|
|
#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)
|
|
|
|
{
|
2017-04-17 19:00:26 +00:00
|
|
|
struct udevice *wdt;
|
|
|
|
u32 reset_mode;
|
|
|
|
int ret = uclass_first_device(UCLASS_WDT, &wdt);
|
2017-01-18 21:44:55 +00:00
|
|
|
|
2017-04-17 19:00:26 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2017-01-18 21:44:55 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-17 19:00:26 +00:00
|
|
|
ret = wdt_expire_now(wdt, reset_mode);
|
|
|
|
if (ret) {
|
|
|
|
debug("Sysreset failed: %d", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2017-01-18 21:44:55 +00:00
|
|
|
|
|
|
|
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,
|
|
|
|
};
|