public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Adam Ford <aford173@gmail.com>
To: u-boot@lists.denx.de
Cc: marek.vasut+renesas@gmail.com, biju.das.jz@bp.renesas.com,
	Adam Ford <aford173@gmail.com>
Subject: [PATCH 1/2] arm: mach-rmobile:  Move cpu_reset to rzg2-reset.c
Date: Fri, 27 Aug 2021 15:57:17 -0500	[thread overview]
Message-ID: <20210827205718.536008-1-aford173@gmail.com> (raw)

Various RZ/G2[MNH] boards have copies of cpu_reset which
creates duplicate code, so move this to a common file shared
among all users of the RZG2 and declare it weak so it can be
overwritten if necessary.

Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/arch/arm/mach-rmobile/Makefile b/arch/arm/mach-rmobile/Makefile
index 195bbeb5c8..2bd173ec3a 100644
--- a/arch/arm/mach-rmobile/Makefile
+++ b/arch/arm/mach-rmobile/Makefile
@@ -13,7 +13,7 @@ obj-$(CONFIG_SH73A0) += lowlevel_init.o cpu_info-sh73a0.o pfc-sh73a0.o
 obj-$(CONFIG_R8A7740) += lowlevel_init.o cpu_info-r8a7740.o pfc-r8a7740.o
 obj-$(CONFIG_RCAR_GEN2) += lowlevel_init_ca15.o cpu_info-rcar.o
 obj-$(CONFIG_RCAR_GEN3) += lowlevel_init_gen3.o cpu_info-rcar.o memmap-gen3.o
-obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o
+obj-$(CONFIG_RZ_G2) += cpu_info-rzg.o rzg2-reset.o
 
 ifneq ($(CONFIG_R8A779A0),)
 obj-$(CONFIG_ARMV8_PSCI) += psci-r8a779a0.o
diff --git a/arch/arm/mach-rmobile/rzg2-reset.c b/arch/arm/mach-rmobile/rzg2-reset.c
new file mode 100644
index 0000000000..8c3608f34a
--- /dev/null
+++ b/arch/arm/mach-rmobile/rzg2-reset.c
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2021 Renesas Electronics Corporation
+ */
+
+#include <asm/io.h>
+
+#define RST_BASE	0xE6160000
+#define RST_CA57RESCNT	(RST_BASE + 0x40)
+#define RST_CA53RESCNT	(RST_BASE + 0x44)
+#define RST_CA57_CODE	0xA5A5000F
+#define RST_CA53_CODE	0x5A5A000F
+
+__weak void reset_cpu(void)
+{
+	unsigned long midr, cputype;
+
+	asm volatile("mrs %0, midr_el1" : "=r" (midr));
+	cputype = (midr >> 4) & 0xfff;
+
+	if (cputype == 0xd03)
+		writel(RST_CA53_CODE, RST_CA53RESCNT);
+	else
+		writel(RST_CA57_CODE, RST_CA57RESCNT);
+}
+
-- 
2.25.1


             reply	other threads:[~2021-08-27 20:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 20:57 Adam Ford [this message]
2021-08-27 20:57 ` [PATCH 2/2] arm: rmobile: Remove duplicate code from beacon-rzg2m and hihope-rzg2 Adam Ford
2021-08-29 16:22 ` [PATCH 1/2] arm: mach-rmobile: Move cpu_reset to rzg2-reset.c Marek Vasut
2021-08-30 17:52   ` Adam Ford
2021-08-30 17:58     ` Marek Vasut

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=20210827205718.536008-1-aford173@gmail.com \
    --to=aford173@gmail.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=marek.vasut+renesas@gmail.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