]> git.ipfire.org Git - thirdparty/u-boot.git/blame - drivers/sysreset/sysreset_ast.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / drivers / sysreset / sysreset_ast.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0
4697abea 2/*
3 * (C) Copyright 2016 Google, Inc
4697abea 4 */
5
d678a59d 6#include <common.h>
4697abea 7#include <dm.h>
8#include <errno.h>
f7ae49fc 9#include <log.h>
4697abea 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>
4a84cf06 15#include <hang.h>
4697abea 16
4697abea 17static int ast_sysreset_request(struct udevice *dev, enum sysreset_t type)
18{
99f8ad73 19 struct udevice *wdt;
20 u32 reset_mode;
c726fc01 21 int ret = uclass_first_device_err(UCLASS_WDT, &wdt);
4697abea 22
99f8ad73 23 if (ret)
24 return ret;
4697abea 25
26 switch (type) {
27 case SYSRESET_WARM:
28 reset_mode = WDT_CTRL_RESET_CPU;
29 break;
30 case SYSRESET_COLD:
31 reset_mode = WDT_CTRL_RESET_CHIP;
32 break;
33 default:
34 return -EPROTONOSUPPORT;
35 }
36
4a84cf06 37#if !defined(CONFIG_SPL_BUILD)
99f8ad73 38 ret = wdt_expire_now(wdt, reset_mode);
39 if (ret) {
40 debug("Sysreset failed: %d", ret);
41 return ret;
42 }
4a84cf06
CWW
43#else
44 hang();
45#endif
4697abea 46
47 return -EINPROGRESS;
48}
49
50static struct sysreset_ops ast_sysreset = {
51 .request = ast_sysreset_request,
52};
53
54U_BOOT_DRIVER(sysreset_ast) = {
55 .name = "ast_sysreset",
56 .id = UCLASS_SYSRESET,
57 .ops = &ast_sysreset,
58};