public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Yan <andy.yan@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/7] rockchip: rk3368: Add sysreset driver
Date: Fri, 21 Apr 2017 10:32:13 +0800	[thread overview]
Message-ID: <1492741933-7734-1-git-send-email-andy.yan@rock-chips.com> (raw)
In-Reply-To: <1492741780-7489-1-git-send-email-andy.yan@rock-chips.com>

Add sysreset driver to reset rk3368 SOC.

Signed-off-by: Andy Yan <andy.yan@rock-chips.com>
---

 drivers/sysreset/Makefile          |  1 +
 drivers/sysreset/sysreset_rk3368.c | 58 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)
 create mode 100644 drivers/sysreset/sysreset_rk3368.c

diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 49b8bb6..ffc61c3 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -12,6 +12,7 @@ endif
 obj-$(CONFIG_ROCKCHIP_RK3188) += sysreset_rk3188.o
 obj-$(CONFIG_ROCKCHIP_RK3288) += sysreset_rk3288.o
 obj-$(CONFIG_ROCKCHIP_RK3328) += sysreset_rk3328.o
+obj-$(CONFIG_ROCKCHIP_RK3368) += sysreset_rk3368.o
 obj-$(CONFIG_ROCKCHIP_RK3399) += sysreset_rk3399.o
 obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
 obj-$(CONFIG_ARCH_SNAPDRAGON) += sysreset_snapdragon.o
diff --git a/drivers/sysreset/sysreset_rk3368.c b/drivers/sysreset/sysreset_rk3368.c
new file mode 100644
index 0000000..32ebc47
--- /dev/null
+++ b/drivers/sysreset/sysreset_rk3368.c
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright Rockchip Electronics Co., Ltd
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <sysreset.h>
+#include <asm/io.h>
+#include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3368.h>
+#include <asm/arch/hardware.h>
+#include <linux/err.h>
+
+static void rk3368_pll_enter_slow_mode(struct rk3368_cru *cru)
+{
+	struct rk3368_pll *pll;
+	int i;
+
+	for (i = 0; i < 6; i++) {
+		pll = &cru->pll[i];
+		rk_clrreg(&pll->con3, PLL_MODE_MASK);
+	}
+}
+
+static int rk3368_sysreset_request(struct udevice *dev, enum sysreset_t type)
+{
+	struct rk3368_cru *cru = rockchip_get_cru();
+
+	if (IS_ERR(cru))
+		return PTR_ERR(cru);
+	switch (type) {
+	case SYSRESET_WARM:
+		rk3368_pll_enter_slow_mode(cru);
+		writel(0xeca8, &cru->glb_srst_snd_val);
+		break;
+	case SYSRESET_COLD:
+		rk3368_pll_enter_slow_mode(cru);
+		writel(0xfdb9, &cru->glb_srst_fst_val);
+		break;
+	default:
+		return -EPROTONOSUPPORT;
+	}
+
+	return -EINPROGRESS;
+}
+
+static struct sysreset_ops rk3368_sysreset = {
+	.request	= rk3368_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_rk3368) = {
+	.name	= "rk3368_sysreset",
+	.id	= UCLASS_SYSRESET,
+	.ops	= &rk3368_sysreset,
+};
-- 
2.7.4

  parent reply	other threads:[~2017-04-21  2:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21  2:29 [U-Boot] [PATCH 0/7] Add basic support for Rockchip RK3368 SOC Andy Yan
2017-04-21  2:31 ` [U-Boot] [PATCH 1/7] rockchip: rk3368: Add clok drvier Andy Yan
2017-04-29  0:26   ` Simon Glass
2017-05-04  8:48     ` Andy Yan
2017-05-04 16:49       ` Simon Glass
2017-04-29  0:28   ` Simon Glass
2017-04-29  8:54     ` Andreas Färber
2017-04-30  8:33     ` Andreas Färber
2017-04-21  2:31 ` [U-Boot] [PATCH 2/7] rockchip: rk3368: Add pinctrl driver Andy Yan
2017-04-29  0:26   ` Simon Glass
2017-04-21  2:31 ` [U-Boot] [PATCH 3/7] rockchip: rk3368: Add core start-up code for RK3368 Andy Yan
2017-04-29  0:26   ` Simon Glass
2017-04-21  2:32 ` Andy Yan [this message]
2017-04-29  0:26   ` [U-Boot] [PATCH 4/7] rockchip: rk3368: Add sysreset driver Simon Glass
2017-04-21  2:32 ` [U-Boot] [PATCH 5/7] rockchip: rk3368: Add initial support for RK3368 based GeekBox Andy Yan
2017-04-21  2:59   ` Andreas Färber
2017-04-21  6:17     ` Andy Yan
2017-04-30  9:17       ` Andreas Färber
2017-05-01 17:41         ` [U-Boot] [PATCH] rockchip: rk3368: Set fdtfile Andreas Färber
2017-05-01 17:48           ` Andreas Färber
2017-05-08 16:38             ` Simon Glass
2017-05-09  8:05               ` Andreas Färber
2017-05-15  3:02                 ` Simon Glass
2017-04-21  2:33 ` [U-Boot] [PATCH 6/7] rockchip: rk3368: Add PX5 Evaluation board Andy Yan
2017-04-29  0:26   ` Simon Glass
2017-05-01 17:44   ` Andreas Färber
2017-05-02 11:27     ` Simon Glass
2017-04-21  2:33 ` [U-Boot] [PATCH 7/7] rockchip: rk3368: add Sheep board Andy Yan
2017-04-29  0:26   ` Simon Glass
2017-04-21  7:58 ` [U-Boot] [PATCH 0/7] Add basic support for Rockchip RK3368 SOC Kever Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1492741933-7734-1-git-send-email-andy.yan@rock-chips.com \
    --to=andy.yan@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox