[U-Boot] [PATCH v4 7/8] am335x_evm: Add support to boot from NOR.

2013-07-18 Thread Tom Rini
From: Steve Kipisz 

NOR requires that s_init be within the first 4KiB of the image so that
we can perform the rest of the required pinmuxing to talk with the rest
of NOR that we are found on.  When NOR_BOOT is set we save our
environment in NOR at 512KiB and a redundant copy at 768KiB.  We avoid
using SPL for this case and u-boot.bin is written directly to the start
of NOR.

We enclose the DMM-related parts of arch/arm/cpu/armv7/am33xx/emif4.c
with TI81xx checks as at this time U-Boot does not discard unused
sections in the main build and this code relies on functions specific to
(and only provided in) ti81xx-related code.

Cc: Albert ARIBAUD 
Signed-off-by: Steve Kipisz 
Signed-off-by: Tom Rini 

---
Changes in v4:
- Rebase to current.  Note that the asm statements seemingly conflict
  with the save_omap_boot_params call, but I don't see why.

Changes in v3:
- Explain TI81xx changes

Changes in v2:
- Reword commit message slightly
---
 arch/arm/cpu/armv7/am33xx/board.c |2 +-
 arch/arm/cpu/armv7/am33xx/emif4.c |6 +-
 board/ti/am335x/Makefile  |2 +-
 board/ti/am335x/board.c   |   33 +--
 board/ti/am335x/mux.c |6 +-
 board/ti/am335x/u-boot.lds|  117 +
 boards.cfg|1 +
 include/configs/am335x_evm.h  |   26 -
 8 files changed, 182 insertions(+), 11 deletions(-)
 create mode 100644 board/ti/am335x/u-boot.lds

diff --git a/arch/arm/cpu/armv7/am33xx/board.c 
b/arch/arm/cpu/armv7/am33xx/board.c
index b935a29..3085292 100644
--- a/arch/arm/cpu/armv7/am33xx/board.c
+++ b/arch/arm/cpu/armv7/am33xx/board.c
@@ -150,7 +150,7 @@ int arch_misc_init(void)
return 0;
 }
 
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
 void rtc32k_enable(void)
 {
struct rtc_regs *rtc = (struct rtc_regs *)RTC_BASE;
diff --git a/arch/arm/cpu/armv7/am33xx/emif4.c 
b/arch/arm/cpu/armv7/am33xx/emif4.c
index aa84e96..370230b 100644
--- a/arch/arm/cpu/armv7/am33xx/emif4.c
+++ b/arch/arm/cpu/armv7/am33xx/emif4.c
@@ -43,9 +43,11 @@ void dram_init_banksize(void)
 }
 
 
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
+#ifdef CONFIG_TI81XX
 static struct dmm_lisa_map_regs *hw_lisa_map_regs =
(struct dmm_lisa_map_regs *)DMM_BASE;
+#endif
 static struct vtp_reg *vtpreg[2] = {
(struct vtp_reg *)VTP0_CTRL_ADDR,
(struct vtp_reg *)VTP1_CTRL_ADDR};
@@ -53,6 +55,7 @@ static struct vtp_reg *vtpreg[2] = {
 static struct ddr_ctrl *ddrctrl = (struct ddr_ctrl *)DDR_CTRL_ADDR;
 #endif
 
+#ifdef CONFIG_TI81XX
 void config_dmm(const struct dmm_lisa_map_regs *regs)
 {
enable_dmm_clocks();
@@ -67,6 +70,7 @@ void config_dmm(const struct dmm_lisa_map_regs *regs)
writel(regs->dmm_lisa_map_1, &hw_lisa_map_regs->dmm_lisa_map_1);
writel(regs->dmm_lisa_map_0, &hw_lisa_map_regs->dmm_lisa_map_0);
 }
+#endif
 
 static void config_vtp(int nr)
 {
diff --git a/board/ti/am335x/Makefile b/board/ti/am335x/Makefile
index 67a87a1..1795e3e 100644
--- a/board/ti/am335x/Makefile
+++ b/board/ti/am335x/Makefile
@@ -18,7 +18,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)lib$(BOARD).o
 
-ifdef CONFIG_SPL_BUILD
+ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_NOR_BOOT),y)
 COBJS  := mux.o
 endif
 
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 7bcaa98..81ab04a 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -91,7 +91,7 @@ static int read_eeprom(struct am335x_baseboard_id *header)
return 0;
 }
 
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_NOR_BOOT)
 static const struct ddr_data ddr2_data = {
.datardsratio0 = ((MT47H128M16RT25E_RD_DQS<<30) |
  (MT47H128M16RT25E_RD_DQS<<20) |
@@ -257,10 +257,28 @@ int spl_start_uboot(void)
  */
 void s_init(void)
 {
-#ifdef CONFIG_SPL_BUILD
-   struct am335x_baseboard_id header;
+   __maybe_unused struct am335x_baseboard_id header;
 
/*
+* The ROM will only have set up sufficient pinmux to allow for the
+* first 4KiB NOR to be read, we must finish doing what we know of
+* the NOR mux in this space in order to continue.
+*/
+#ifdef CONFIG_NOR_BOOT
+   asm("stmfd  sp!, {r2 - r4}");
+   asm("movw   r4, #0x8A4");
+   asm("movw   r3, #0x44E1");
+   asm("orrr4, r4, r3, lsl #16");
+   asm("movr2, #9");
+   asm("movr3, #8");
+   asm("gpmc_mux:  str r2, [r4], #4");
+   asm("subs   r3, r3, #1");
+   asm("bnegpmc_mux");
+   asm("ldmfd  sp!, {r2 - r4}");
+#endif
+
+#ifdef CONFIG_SPL_BUILD
+   /*
 * Save the boot parameters passed from romcode.
 * We cannot delay the saving further than this,
 * to prevent overwrites.
@@ -278,7 +296,7 @@ void s_init(void)
while

Re: [U-Boot] [PATCH v4 7/8] am335x_evm: Add support to boot from NOR.

2013-07-18 Thread Albert ARIBAUD
Hi Tom,

On Thu, 18 Jul 2013 15:13:04 -0400, Tom Rini  wrote:

> Changes in v4:
> - Rebase to current.  Note that the asm statements seemingly conflict
>   with the save_omap_boot_params call, but I don't see why.

How exactly does the conflict manifest itself?

Amicalement,
-- 
Albert.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 7/8] am335x_evm: Add support to boot from NOR.

2013-07-18 Thread Tom Rini
On Thu, Jul 18, 2013 at 09:21:33PM +0200, Albert ARIBAUD wrote:
> Hi Tom,
> 
> On Thu, 18 Jul 2013 15:13:04 -0400, Tom Rini  wrote:
> 
> > Changes in v4:
> > - Rebase to current.  Note that the asm statements seemingly conflict
> >   with the save_omap_boot_params call, but I don't see why.
> 
> How exactly does the conflict manifest itself?

What I end up seeing (and I didn't get a debugger attached) was that the
i2c init fails (one of the i2c error messages is sent out), so i2c probe
fails so we can't init the hardware.  And it's left in such a bizarro
state that trying to boot again via UART instead for example still fails
that way, a power cycle is required to clear things out.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot