blob: f353f9b4c79dac081fa1beb1e7ccc1c84a3f53b3 [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
6#include <common.h>
7#include <dm.h>
8#include <errno.h>
9#include <sysreset.h>
Kever Yang9fbe17c2019-03-28 11:01:23 +080010#include <asm/arch-rockchip/clock.h>
11#include <asm/arch-rockchip/cru_rk3328.h>
12#include <asm/arch-rockchip/hardware.h>
Kever Yang536dea82017-11-03 15:16:12 +080013#include <linux/err.h>
14
15int rockchip_sysreset_request(struct udevice *dev, enum sysreset_t type)
16{
17 struct sysreset_reg *offset = dev_get_priv(dev);
18 unsigned long cru_base = (unsigned long)rockchip_get_cru();
19
20 if (IS_ERR_VALUE(cru_base))
21 return (int)cru_base;
22
23 switch (type) {
24 case SYSRESET_WARM:
25 writel(0xeca8, cru_base + offset->glb_srst_snd_value);
26 break;
27 case SYSRESET_COLD:
28 writel(0xfdb9, cru_base + offset->glb_srst_fst_value);
29 break;
30 default:
31 return -EPROTONOSUPPORT;
32 }
33
34 return -EINPROGRESS;
35}
36
37static struct sysreset_ops rockchip_sysreset = {
38 .request = rockchip_sysreset_request,
39};
40
41U_BOOT_DRIVER(sysreset_rockchip) = {
42 .name = "rockchip_sysreset",
43 .id = UCLASS_SYSRESET,
44 .ops = &rockchip_sysreset,
45};