]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/sysreset/sysreset_ast.c
Merge git://git.denx.de/u-boot-dm
[people/ms/u-boot.git] / drivers / sysreset / sysreset_ast.c
CommitLineData
4697abea 1/*
2 * (C) Copyright 2016 Google, Inc
3 *
4 * SPDX-License-Identifier: GPL-2.0
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <errno.h>
10#include <sysreset.h>
99f8ad73 11#include <wdt.h>
4697abea 12#include <asm/io.h>
13#include <asm/arch/wdt.h>
14#include <linux/err.h>
15
4697abea 16static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
17{
99f8ad73 18 struct udevice *wdt;
19 u32 reset_mode;
20 int ret = uclass_first_device(UCLASS_WDT, &wdt);
4697abea 21
99f8ad73 22 if (ret)
23 return ret;
4697abea 24
25 switch (type) {
26 case SYSRESET_WARM:
27 reset_mode = WDT_CTRL_RESET_CPU;
28 break;
29 case SYSRESET_COLD:
30 reset_mode = WDT_CTRL_RESET_CHIP;
31 break;
32 default:
33 return -EPROTONOSUPPORT;
34 }
35
99f8ad73 36 ret = wdt_expire_now(wdt, reset_mode);
37 if (ret) {
38 debug("Sysreset failed: %d", ret);
39 return ret;
40 }
4697abea 41
42 return -EINPROGRESS;
43}
44
45static struct sysreset_ops ast_sysreset = {
46 .request = ast_sysreset_request,
47};
48
49U_BOOT_DRIVER(sysreset_ast) = {
50 .name = "ast_sysreset",
51 .id = UCLASS_SYSRESET,
52 .ops = &ast_sysreset,
53};