public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Dalon Westergreen <dwesterg@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3] arm: socfpga: fix issue with warm reset when CSEL is 0
Date: Fri, 17 Feb 2017 17:34:56 -0800	[thread overview]
Message-ID: <1487381696-6409-1-git-send-email-dwesterg@gmail.com> (raw)

When CSEL=0x0 the socfpga bootrom does not touch the clock
configuration for the device.  This can lead to a boot failure
on warm resets. This patch disables warm resets when CSEL=0.
This results in the clock and pll configurations being reset
on any reset issued when CSEL=0.

Signed-off-by: Dalon Westergreen <dwesterg@gmail.com>

Changes in v3:
 - Change implementation to rely on cold reset for CSEL=0. Which
   is a much simpler approach to dealing with this special case
   during boot.
Changes in v2:
 - Fix checkpatch issues predominently due to whitespace issues
---
 arch/arm/mach-socfpga/include/mach/system_manager.h |  3 +++
 arch/arm/mach-socfpga/misc.c                        | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/include/mach/system_manager.h b/arch/arm/mach-socfpga/include/mach/system_manager.h
index c45edea..c9c0b33 100644
--- a/arch/arm/mach-socfpga/include/mach/system_manager.h
+++ b/arch/arm/mach-socfpga/include/mach/system_manager.h
@@ -137,6 +137,9 @@ struct socfpga_system_manager {
 
 #define SYSMGR_SDMMC_DRVSEL_SHIFT	0
 
+#define SYSMGR_BOOTINFO_CSEL_MASK	0x18
+#define SYSMGR_BOOTINFO_CSEL_LSB	3
+
 /* EMAC Group Bit definitions */
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII	0x0
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII		0x1
diff --git a/arch/arm/mach-socfpga/misc.c b/arch/arm/mach-socfpga/misc.c
index dd6b53b..9792138 100644
--- a/arch/arm/mach-socfpga/misc.c
+++ b/arch/arm/mach-socfpga/misc.c
@@ -356,6 +356,7 @@ static uint32_t iswgrp_handoff[8];
 int arch_early_init_r(void)
 {
 	int i;
+	unsigned int csel;
 
 	/*
 	 * Write magic value into magic register to unlock support for
@@ -363,8 +364,18 @@ int arch_early_init_r(void)
 	 * value to be written into the register by the bootloader, so
 	 * to support that old code, we write it here instead of in the
 	 * reset_cpu() function just before resetting the CPU.
+	 *
+	 * For CSEL = 0 we do not want to enable warm resets to ensure that
+	 * on reset the clocks and plls are reset to their default states as
+	 * the bootrom, for CSEL=0, leaves the clocks untouched.  If the clocks
+	 * and plls are not reset, the bootrom will fail to load the spl image.
 	 */
-	writel(0xae9efebc, &sysmgr_regs->romcodegrp_warmramgrp_enable);
+
+	csel = (readl(&sysmgr_regs->bootinfo) & SYSMGR_BOOTINFO_CSEL_MASK) >>
+		SYSMGR_BOOTINFO_CSEL_LSB;
+
+	if (csel)
+		writel(0xae9efebc, &sysmgr_regs->romcodegrp_warmramgrp_enable);
 
 	for (i = 0; i < 8; i++)	/* Cache initial SW setting regs */
 		iswgrp_handoff[i] = readl(&sysmgr_regs->iswgrp_handoff[i]);
-- 
2.7.4

             reply	other threads:[~2017-02-18  1:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-18  1:34 Dalon Westergreen [this message]
2017-02-20  9:07 ` [U-Boot] [PATCH v3] arm: socfpga: fix issue with warm reset when CSEL is 0 Marek Vasut
2017-02-20 14:10   ` Dalon Westergreen
2017-02-20 14:14     ` Marek Vasut
2017-02-20 14:21       ` Dalon Westergreen
2017-02-20 14:24         ` Marek Vasut
2017-02-20 14:35           ` Dalon Westergreen
2017-02-20 14:38             ` Marek Vasut
2017-02-28 14:45             ` Dalon Westergreen
2017-03-05 17:38               ` Dalon Westergreen
2017-03-05 17:49                 ` Marek Vasut
2017-03-06  2:25                   ` Dalon Westergreen
2017-03-07  3:46                     ` 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=1487381696-6409-1-git-send-email-dwesterg@gmail.com \
    --to=dwesterg@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