public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] MX28: Add CONFIG_MX28_DEBUG
@ 2012-08-29  1:14 Marek Vasut
  2012-08-29  1:14 ` [U-Boot] [PATCH 2/2] MX28: Add LRADC dump into SPL debug Marek Vasut
  2012-08-29  7:54 ` [U-Boot] [PATCH 1/2] MX28: Add CONFIG_MX28_DEBUG Stefano Babic
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2012-08-29  1:14 UTC (permalink / raw)
  To: u-boot

This functionality allows configuring SCRATCH0 and SCRATCH1 registers
to special values, which make the SPL hang after the CPU was properly
initialized.

This is for bootstrap purposes only and MUST BE DISABLED for normal
operation.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Wolfgang Denk <wd@denx.de>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
---
 arch/arm/cpu/arm926ejs/mxs/Makefile    |    3 ++
 arch/arm/cpu/arm926ejs/mxs/mxs_init.h  |    6 +++
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c  |    2 +
 arch/arm/cpu/arm926ejs/mxs/spl_debug.c |   63 ++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+)
 create mode 100644 arch/arm/cpu/arm926ejs/mxs/spl_debug.c

diff --git a/arch/arm/cpu/arm926ejs/mxs/Makefile b/arch/arm/cpu/arm926ejs/mxs/Makefile
index eeecf89..e75eabd 100644
--- a/arch/arm/cpu/arm926ejs/mxs/Makefile
+++ b/arch/arm/cpu/arm926ejs/mxs/Makefile
@@ -29,6 +29,9 @@ COBJS	= clock.o mxs.o iomux.o timer.o
 
 ifdef	CONFIG_SPL_BUILD
 COBJS	+= spl_boot.o spl_lradc_init.o spl_mem_init.o spl_power_init.o
+ifdef	CONFIG_MX28_DEBUG
+COBJS	+= spl_debug.o
+endif
 endif
 
 SRCS	:= $(START:.o=.S) $(COBJS:.o=.c)
diff --git a/arch/arm/cpu/arm926ejs/mxs/mxs_init.h b/arch/arm/cpu/arm926ejs/mxs/mxs_init.h
index 2ddc5bc..e6f837c 100644
--- a/arch/arm/cpu/arm926ejs/mxs/mxs_init.h
+++ b/arch/arm/cpu/arm926ejs/mxs/mxs_init.h
@@ -42,4 +42,10 @@ uint32_t mxs_mem_get_size(void);
 void mxs_lradc_init(void);
 void mxs_lradc_enable_batt_measurement(void);
 
+#ifdef CONFIG_MX28_DEBUG
+void mx28_common_spl_debug_halt(void);
+#else
+static inline void mx28_common_spl_debug_halt(void) {}
+#endif
+
 #endif	/* __M28_INIT_H__ */
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index ad66c57..f4f0c09 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -108,6 +108,8 @@ void mxs_common_spl_init(const iomux_cfg_t *iomux_setup,
 
 	data->boot_mode_idx = bootmode;
 
+	mx28_common_spl_debug_halt();
+
 	mxs_power_wait_pswitch();
 }
 
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_debug.c b/arch/arm/cpu/arm926ejs/mxs/spl_debug.c
new file mode 100644
index 0000000..f0aef20
--- /dev/null
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_debug.c
@@ -0,0 +1,63 @@
+/*
+ * Freescale i.MX28 Boot debug helpers
+ *
+ * Copyright (C) 2012 Marek Vasut <marex@denx.de>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <config.h>
+#include <asm/io.h>
+#include <asm/arch/iomux-mx28.h>
+#include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/gpio.h>
+
+#include "mxs_init.h"
+
+void mx28_common_spl_debug_halt(void)
+{
+	/*
+	 * Check for magic setup of DIGCTL_SCRATCH0 and DIGCTL_SCRATCH1
+	 * registers, which tells the system to halt after initializing
+	 * hardware. This is useful at bootstrap stage, otherwise shall
+	 * be disabled.
+	 */
+	struct mxs_digctl_regs *digctl_regs =
+		(struct mxs_digctl_regs *)MXS_DIGCTL_BASE;
+
+	const uint32_t magic0 = 0xc001f00d;
+	const uint32_t magic1 = 0x1337b4b3;
+	uint32_t reg;
+
+	reg = readl(&digctl_regs->hw_digctl_scratch0);
+	if (reg != magic0)
+		return;
+
+	reg = readl(&digctl_regs->hw_digctl_scratch1);
+	if (reg != magic1)
+		return;
+
+	serial_init();
+	serial_puts("Hardware init complete, SPL halted.\n");
+
+	/* Both magic values matched, hang. */
+	asm volatile("x: b x\n");
+}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-29 10:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-29  1:14 [U-Boot] [PATCH 1/2] MX28: Add CONFIG_MX28_DEBUG Marek Vasut
2012-08-29  1:14 ` [U-Boot] [PATCH 2/2] MX28: Add LRADC dump into SPL debug Marek Vasut
2012-08-29  7:54 ` [U-Boot] [PATCH 1/2] MX28: Add CONFIG_MX28_DEBUG Stefano Babic
2012-08-29 10:59   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox