public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: John Tobias <john.tobias.ph@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/7] imx6sl: add SPL support for iMX6SL-evk
Date: Sun,  9 Nov 2014 09:51:27 -0800	[thread overview]
Message-ID: <1415555488-37665-7-git-send-email-john.tobias.ph@gmail.com> (raw)
In-Reply-To: <1415555488-37665-1-git-send-email-john.tobias.ph@gmail.com>

This patch support the SPL features for iMX6SL.
It tested to boot on SD1, SD2 and SD3 mmc ports.
---
 board/freescale/mx6slevk/mx6slevk.c | 168 +++++++++++++++++++++++++++++++++++-
 1 file changed, 167 insertions(+), 1 deletion(-)

diff --git a/board/freescale/mx6slevk/mx6slevk.c b/board/freescale/mx6slevk/mx6slevk.c
index e76c343..2c11c4a 100644
--- a/board/freescale/mx6slevk/mx6slevk.c
+++ b/board/freescale/mx6slevk/mx6slevk.c
@@ -42,7 +42,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE);
+	gd->ram_size = imx_ddr_size();
 
 	return 0;
 }
@@ -275,3 +275,169 @@ int checkboard(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_SPL_BUILD
+#include <spl.h>
+#include <libfdt.h>
+
+#define BOOT_CFG	0x20D8004
+#define __REG(x)        (*((volatile u32 *)(x)))
+
+struct fsl_esdhc_cfg spl_usdhc_cfg;
+/*
+ * Got it from imximage.cfg file
+ */
+static void spl_dram_mx6slevk(void)
+{
+	__REG(0x020e0344) = 0x00003030;
+	__REG(0x020e0348) = 0x00003030;
+	__REG(0x020e034c) = 0x00003030;
+	__REG(0x020e0350) = 0x00003030;
+	__REG(0x020e030c) = 0x00000030;
+	__REG(0x020e0310) = 0x00000030;
+	__REG(0x020e0314) = 0x00000030;
+	__REG(0x020e0318) = 0x00000030;
+	__REG(0x020e0300) = 0x00000030;
+	__REG(0x020e031c) = 0x00000030;
+	__REG(0x020e0338) = 0x00000028;
+	__REG(0x020e0320) = 0x00000030;
+	__REG(0x020e032c) = 0x00000000;
+	__REG(0x020e033c) = 0x00000008;
+	__REG(0x020e0340) = 0x00000008;
+	__REG(0x020e05c4) = 0x00000030;
+	__REG(0x020e05cc) = 0x00000030;
+	__REG(0x020e05d4) = 0x00000030;
+	__REG(0x020e05d8) = 0x00000030;
+	__REG(0x020e05ac) = 0x00000030;
+	__REG(0x020e05c8) = 0x00000030;
+	__REG(0x020e05b0) = 0x00020000;
+	__REG(0x020e05b4) = 0x00000000;
+	__REG(0x020e05c0) = 0x00020000;
+	__REG(0x020e05d0) = 0x00080000;
+
+	__REG(0x021b001c) = 0x00008000;
+	__REG(0x021b085c) = 0x1b4700c7;
+	__REG(0x021b0800) = 0xa1390003;
+	__REG(0x021b0890) = 0x00300000;
+	__REG(0x021b08b8) = 0x00000800;
+	__REG(0x021b081c) = 0x33333333;
+	__REG(0x021b0820) = 0x33333333;
+	__REG(0x021b0824) = 0x33333333;
+	__REG(0x021b0828) = 0x33333333;
+	__REG(0x021b082c) = 0xf3333333;
+	__REG(0x021b0830) = 0xf3333333;
+	__REG(0x021b0834) = 0xf3333333;
+	__REG(0x021b0838) = 0xf3333333;
+	__REG(0x021b0848) = 0x4241444a;
+	__REG(0x021b0850) = 0x3030312b;
+	__REG(0x021b083c) = 0x20000000;
+	__REG(0x021b0840) = 0x00000000;
+	__REG(0x021b08c0) = 0x24911492;
+	__REG(0x021b08b8) = 0x00000800;
+	__REG(0x021b000c) = 0x33374133;
+	__REG(0x021b0004) = 0x00020024;
+	__REG(0x021b0010) = 0x00100A82;
+	__REG(0x021b0014) = 0x00000093;
+	__REG(0x021b0018) = 0x00001688;
+	__REG(0x021b002c) = 0x0f9f26d2;
+	__REG(0x021b0030) = 0x0000020e;
+	__REG(0x021b0038) = 0x00190778;
+	__REG(0x021b0008) = 0x00000000;
+	__REG(0x021b0040) = 0x0000004f;
+	__REG(0x021b0000) = 0xc3110000;
+	__REG(0x021b001c) = 0x003f8030;
+	__REG(0x021b001c) = 0xff0a8030;
+	__REG(0x021b001c) = 0x82018030;
+	__REG(0x021b001c) = 0x04028030;
+	__REG(0x021b001c) = 0x02038030;
+	__REG(0x021b001c) = 0xff0a8038;
+	__REG(0x021b001c) = 0x82018038;
+	__REG(0x021b001c) = 0x04028038;
+	__REG(0x021b001c) = 0x02038038;
+	__REG(0x021b0800) = 0xa1310003;
+	__REG(0x021b0020) = 0x00001800;
+	__REG(0x021b0818) = 0x00000000;
+	__REG(0x021b08b8) = 0x00000800;
+	__REG(0x021b0004) = 0x00025564;
+	__REG(0x021b0404) = 0x00011006;
+	__REG(0x021b001c) = 0x00000000;
+}
+
+/*
+ * This section require the differentiation
+ * between iMX6 SL.
+ * But for now, it will configure only for
+ * iMX6SL-evk.
+ */
+static void spl_dram_init(void)
+{
+	spl_dram_mx6slevk();
+}
+
+int spl_board_mmc_init(bd_t *bis)
+{
+	unsigned reg = readl(BOOT_CFG) >> 11;
+	/*
+	 * Upon reading BOOT_CFG register the following map is done:
+	 * Bit 11 and 12 of BOOT_CFG register can determine the current
+	 * mmc port
+	 * 0x0                  SD1
+	 * 0x1                  SD2
+	 * 0x2                  SD3
+	 */
+
+	switch (reg & 0x3) {
+	case 0x0:
+		imx_iomux_v3_setup_multiple_pads(
+			usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
+		spl_usdhc_cfg.esdhc_base = USDHC1_BASE_ADDR;
+		spl_usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+		gd->arch.sdhc_clk = spl_usdhc_cfg.sdhc_clk;
+		break;
+	case 0x1:
+		imx_iomux_v3_setup_multiple_pads(
+			usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
+		spl_usdhc_cfg.esdhc_base = USDHC2_BASE_ADDR;
+		spl_usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
+		gd->arch.sdhc_clk = spl_usdhc_cfg.sdhc_clk;
+		break;
+	case 0x2:
+		imx_iomux_v3_setup_multiple_pads(
+			usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
+		spl_usdhc_cfg.esdhc_base = USDHC3_BASE_ADDR;
+		spl_usdhc_cfg.sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+		gd->arch.sdhc_clk = spl_usdhc_cfg.sdhc_clk;
+		break;
+	}
+
+	return fsl_esdhc_initialize(bis, &spl_usdhc_cfg);
+}
+
+void board_init_f(ulong dummy)
+{
+	/* setup AIPS and disable watchdog */
+	arch_cpu_init();
+
+	/* iomux and setup of i2c */
+	board_early_init_f();
+
+	/* setup GP timer */
+	timer_init();
+
+	/* UART clocks enabled and gd valid - init serial console */
+	preloader_console_init();
+
+	/* DDR initialization */
+	spl_dram_init();
+
+	/* Clear the BSS. */
+	memset(__bss_start, 0, __bss_end - __bss_start);
+
+	/* load/boot image from boot device */
+	board_init_r(NULL, 0);
+}
+
+void reset_cpu(ulong addr)
+{
+}
+#endif
-- 
1.9.1

  parent reply	other threads:[~2014-11-09 17:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-09 17:51 [U-Boot] [PATCH 0/7] *** iMX6SL-evk SPL Support *** John Tobias
2014-11-09 17:51 ` [U-Boot] [PATCH 1/7] imx6: add macro define inclusion John Tobias
2014-11-09 23:26   ` Fabio Estevam
2014-11-09 23:42     ` John Tobias
2014-11-09 17:51 ` [U-Boot] [PATCH 2/7] imx6sl: update DCD configuration file John Tobias
2014-11-09 21:31   ` Stefano Babic
2014-11-10  0:33     ` John Tobias
2014-11-09 17:51 ` [U-Boot] [PATCH 3/7] imx6sl: add spl on board configuration John Tobias
2014-11-09 17:51 ` [U-Boot] [PATCH 4/7] imx6: add additional flexibility for defining macros John Tobias
2014-11-09 17:51 ` [U-Boot] [PATCH 5/7] imx6sl: add spl in include header file John Tobias
2014-11-09 17:51 ` John Tobias [this message]
2014-11-09 17:51 ` [U-Boot] [PATCH 7/7] kconfig: imx6sl: add add SUPPORT_SPL John Tobias
2014-11-09 22:59 ` [U-Boot] [PATCH 0/7] *** iMX6SL-evk SPL Support *** Andreas Färber
2014-11-09 23:22   ` John Tobias

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=1415555488-37665-7-git-send-email-john.tobias.ph@gmail.com \
    --to=john.tobias.ph@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