blob: b3d21132399265a5d9bb86ab0f43d10747c448ae [file] [log] [blame]
huang lin2bc00e02015-11-17 14:20:18 +08001/*
2 * (C) Copyright 2015 Rockchip Electronics Co., Ltd
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <errno.h>
Stephen Warren11636252016-05-12 12:03:35 -060010#include <sysreset.h>
huang lin2bc00e02015-11-17 14:20:18 +080011#include <asm/io.h>
12#include <asm/arch/clock.h>
13#include <asm/arch/cru_rk3036.h>
14#include <asm/arch/hardware.h>
15#include <linux/err.h>
16
Stephen Warren11636252016-05-12 12:03:35 -060017int rk3036_sysreset_request(struct udevice *dev, enum sysreset_t type)
huang lin2bc00e02015-11-17 14:20:18 +080018{
19 struct rk3036_cru *cru = rockchip_get_cru();
20
21 if (IS_ERR(cru))
22 return PTR_ERR(cru);
23 switch (type) {
Stephen Warren11636252016-05-12 12:03:35 -060024 case SYSRESET_WARM:
huang lin2bc00e02015-11-17 14:20:18 +080025 writel(0xeca8, &cru->cru_glb_srst_snd_value);
26 break;
Stephen Warren11636252016-05-12 12:03:35 -060027 case SYSRESET_COLD:
huang lin2bc00e02015-11-17 14:20:18 +080028 writel(0xfdb9, &cru->cru_glb_srst_fst_value);
29 break;
30 default:
31 return -EPROTONOSUPPORT;
32 }
33
34 return -EINPROGRESS;
35}
36
Stephen Warren11636252016-05-12 12:03:35 -060037static struct sysreset_ops rk3036_sysreset = {
38 .request = rk3036_sysreset_request,
huang lin2bc00e02015-11-17 14:20:18 +080039};
40
Stephen Warren11636252016-05-12 12:03:35 -060041U_BOOT_DRIVER(sysreset_rk3036) = {
42 .name = "rk3036_sysreset",
43 .id = UCLASS_SYSRESET,
44 .ops = &rk3036_sysreset,
huang lin2bc00e02015-11-17 14:20:18 +080045};