All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen-Yu Tsai <wens@csie.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH resend v2 12/13] sunxi: Add PSCI support for R40
Date: Tue, 18 Apr 2017 10:20:28 +0800	[thread overview]
Message-ID: <20170418022029.23894-13-wens@csie.org> (raw)
In-Reply-To: <20170418022029.23894-1-wens@csie.org>

The R40's CPU controls are a combination of sun6i and sun7i.

All controls are in the CPUCFG block, and it seems the R40 does not
have a PRCM block. The core reset, power gating and clamp controls
are grouped like sun6i.

Last, the R40 does not have a secure SRAM block.

This patch adds a PSCI implementation for CPU bring-up and hotplug
for the R40.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/cpu/armv7/sunxi/psci.c | 35 ++++++++++++++++++++++++++++++++---
 board/sunxi/Kconfig             |  3 +++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/arch/arm/cpu/armv7/sunxi/psci.c b/arch/arm/cpu/armv7/sunxi/psci.c
index 104dc909bc53..b3a34de1aafe 100644
--- a/arch/arm/cpu/armv7/sunxi/psci.c
+++ b/arch/arm/cpu/armv7/sunxi/psci.c
@@ -27,6 +27,17 @@
 #define	GICD_BASE	(SUNXI_GIC400_BASE + GIC_DIST_OFFSET)
 #define	GICC_BASE	(SUNXI_GIC400_BASE + GIC_CPU_OFFSET_A15)
 
+/*
+ * R40 is different from other single cluster SoCs.
+ *
+ * The power clamps are located in the unused space after the per-core
+ * reset controls for core 3. The secondary core entry address register
+ * is in the SRAM controller address range.
+ */
+#define SUN8I_R40_PWROFF			(0x110)
+#define SUN8I_R40_PWR_CLAMP(cpu)		(0x120 + (cpu) * 0x4)
+#define SUN8I_R40_SRAMC_SOFT_ENTRY_REG0		(0xbc)
+
 static void __secure cp15_write_cntp_tval(u32 tval)
 {
 	asm volatile ("mcr p15, 0, %0, c14, c2, 0" : : "r" (tval));
@@ -68,7 +79,8 @@ static void __secure __mdelay(u32 ms)
 static void __secure clamp_release(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
-	defined(CONFIG_MACH_SUN8I_H3)
+	defined(CONFIG_MACH_SUN8I_H3) || \
+	defined(CONFIG_MACH_SUN8I_R40)
 	u32 tmp = 0x1ff;
 	do {
 		tmp >>= 1;
@@ -82,7 +94,8 @@ static void __secure clamp_release(u32 __maybe_unused *clamp)
 static void __secure clamp_set(u32 __maybe_unused *clamp)
 {
 #if defined(CONFIG_MACH_SUN6I) || defined(CONFIG_MACH_SUN7I) || \
-	defined(CONFIG_MACH_SUN8I_H3)
+	defined(CONFIG_MACH_SUN8I_H3) || \
+	defined(CONFIG_MACH_SUN8I_R40)
 	writel(0xff, clamp);
 #endif
 }
@@ -115,7 +128,17 @@ static void __secure sunxi_cpu_set_power(int __always_unused cpu, bool on)
 	sunxi_power_switch(&cpucfg->cpu1_pwr_clamp, &cpucfg->cpu1_pwroff,
 			   on, 0);
 }
-#else /* ! CONFIG_MACH_SUN7I */
+#elif defined CONFIG_MACH_SUN8I_R40
+static void __secure sunxi_cpu_set_power(int cpu, bool on)
+{
+	struct sunxi_cpucfg_reg *cpucfg =
+		(struct sunxi_cpucfg_reg *)SUNXI_CPUCFG_BASE;
+
+	sunxi_power_switch((void *)cpucfg + SUN8I_R40_PWR_CLAMP(cpu),
+			   (void *)cpucfg + SUN8I_R40_PWROFF,
+			   on, 0);
+}
+#else /* ! CONFIG_MACH_SUN7I && ! CONFIG_MACH_SUN8I_R40 */
 static void __secure sunxi_cpu_set_power(int cpu, bool on)
 {
 	struct sunxi_prcm_reg *prcm =
@@ -213,7 +236,13 @@ int __secure psci_cpu_on(u32 __always_unused unused, u32 mpidr, u32 pc)
 	psci_save_target_pc(cpu, pc);
 
 	/* Set secondary core power on PC */
+#ifdef CONFIG_MACH_SUN8I_R40
+	/* secondary core entry address is programmed differently */
+	writel((u32)&psci_cpu_entry,
+	       SUNXI_SRAMC_BASE + SUN8I_R40_SRAMC_SOFT_ENTRY_REG0);
+#else
 	writel((u32)&psci_cpu_entry, &cpucfg->priv0);
+#endif
 
 	/* Assert reset on target CPU */
 	writel(0, &cpucfg->cpu[cpu].rst);
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig
index 5bc4ce037f54..811eb47dc17f 100644
--- a/board/sunxi/Kconfig
+++ b/board/sunxi/Kconfig
@@ -137,6 +137,9 @@ config MACH_SUN8I_H3
 config MACH_SUN8I_R40
 	bool "sun8i (Allwinner R40)"
 	select CPU_V7
+	select CPU_V7_HAS_NONSEC
+	select CPU_V7_HAS_VIRT
+	select ARCH_SUPPORT_PSCI
 	select SUNXI_GEN_SUN6I
 	select SUPPORT_SPL
 
-- 
2.11.0

  parent reply	other threads:[~2017-04-18  2:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-18  2:20 [U-Boot] [PATCH resend v2 00/13] sunxi: Add support for R40 SoC Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 01/13] sunxi: Split up long Kconfig lines Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 02/13] sunxi: Add initial support for R40 Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 03/13] sunxi: Enable AXP221s in I2C mode with the R40 SoC Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 04/13] sunxi: Fix watchdog reset function for R40 Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 05/13] sunxi: Add mmc[1-3] pinmux settings " Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 06/13] sunxi: Set PLL lock enable bits " Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 07/13] sunxi: Provide defaults for R40 DRAM settings Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 08/13] gpio: sunxi: Add compatible string for R40 PIO Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 09/13] sunxi: Use H3/A64 DRAM initialization code for R40 Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 10/13] sunxi: Enable SPL " Chen-Yu Tsai
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 11/13] sunxi: Fix CPUCFG address " Chen-Yu Tsai
2017-04-18  2:20 ` Chen-Yu Tsai [this message]
2017-04-18  2:20 ` [U-Boot] [PATCH resend v2 13/13] sunxi: Add support for Bananapi M2 Ultra Chen-Yu Tsai
2017-04-21  6:57 ` [U-Boot] [PATCH resend v2 00/13] sunxi: Add support for R40 SoC Maxime Ripard

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=20170418022029.23894-13-wens@csie.org \
    --to=wens@csie.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.