Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Kever Yang | 536dea8 | 2017-11-03 15:16:12 +0800 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2017 Rockchip Electronics Co., Ltd |
Kever Yang | 536dea8 | 2017-11-03 15:16:12 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
Kever Yang | 536dea8 | 2017-11-03 15:16:12 +0800 | [diff] [blame] | 6 | #include <dm.h> |
| 7 | #include <errno.h> |
| 8 | #include <sysreset.h> |
Kever Yang | 9fbe17c | 2019-03-28 11:01:23 +0800 | [diff] [blame] | 9 | #include <asm/arch-rockchip/clock.h> |
| 10 | #include <asm/arch-rockchip/cru_rk3328.h> |
| 11 | #include <asm/arch-rockchip/hardware.h> |
Kever Yang | 536dea8 | 2017-11-03 15:16:12 +0800 | [diff] [blame] | 12 | #include <linux/err.h> |
| 13 | |
| 14 | int 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 | |
| 36 | static struct sysreset_ops rockchip_sysreset = { |
| 37 | .request = rockchip_sysreset_request, |
| 38 | }; |
| 39 | |
| 40 | U_BOOT_DRIVER(sysreset_rockchip) = { |
| 41 | .name = "rockchip_sysreset", |
| 42 | .id = UCLASS_SYSRESET, |
| 43 | .ops = &rockchip_sysreset, |
| 44 | }; |