blob: 00308f9a33b7939cf7da1cd0e992a14c4b48f56b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Kever Yang536dea82017-11-03 15:16:12 +08002/*
3 * (C) Copyright 2017 Rockchip Electronics Co., Ltd
Kever Yang536dea82017-11-03 15:16:12 +08004 */
5
Kever Yang536dea82017-11-03 15:16:12 +08006#include <dm.h>
7#include <errno.h>
8#include <sysreset.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +08009#include <asm/arch-rockchip/clock.h>
10#include <asm/arch-rockchip/cru_rk3328.h>
11#include <asm/arch-rockchip/hardware.h>
Kever Yang536dea82017-11-03 15:16:12 +080012#include <linux/err.h>
13
14int rockchip_sysreset_request(struct udevice *dev, enum sysreset_t type)
15{
16 struct sysreset_reg *offset = dev_get_priv(dev);
17 unsigned long cru_base = (unsigned long)rockchip_get_cru();
18
19 if (IS_ERR_VALUE(cru_base))
20 return (int)cru_base;
21
22 switch (type) {
23 case SYSRESET_WARM:
24 writel(0xeca8, cru_base + offset->glb_srst_snd_value);
25 break;
26 case SYSRESET_COLD:
27 writel(0xfdb9, cru_base + offset->glb_srst_fst_value);
28 break;
29 default:
30 return -EPROTONOSUPPORT;
31 }
32
33 return -EINPROGRESS;
34}
35
36static struct sysreset_ops rockchip_sysreset = {
37 .request = rockchip_sysreset_request,
38};
39
40U_BOOT_DRIVER(sysreset_rockchip) = {
41 .name = "rockchip_sysreset",
42 .id = UCLASS_SYSRESET,
43 .ops = &rockchip_sysreset,
44};