Re: [U-Boot] [RFC][PATCH] NAND boot: MPC8536DS support

2009-09-13 Thread Hu Mingkai-B21284
 

 -Original Message-
 From: Kumar Gala [mailto:ga...@kernel.crashing.org] 
 Sent: Saturday, September 12, 2009 3:22 AM
 To: Hu Mingkai-B21284
 Cc: Wood Scott-B07421; U-Boot-Denx List
 Subject: Re: [U-Boot] [RFC][PATCH] NAND boot: MPC8536DS support
 
 
 On Sep 11, 2009, at 2:17 PM, Kumar Gala
 
  Makefile   |1 +
  board/freescale/mpc8536ds/config.mk|7 ++
  board/freescale/mpc8536ds/tlb.c|   11 ++
  cpu/mpc85xx/nand_init.c|   73 ++
 
 how about renaming nand_init.c to cpu_init_nand.c
 
Ok, I'll fix it.

 
  diff --git a/cpu/mpc85xx/nand_init.c b/cpu/mpc85xx/nand_init.c new 
  file mode 100644 index 000..dcbbc8d
  --- /dev/null
  +++ b/cpu/mpc85xx/nand_init.c
  @@ -0,0 +1,73 @@
  +/*
  + * Copyright (C) 2009 Freescale Semiconductor, Inc.
 
 the '(C)' isnt needed.
 
Ok, thanks.

 
  diff --git a/include/configs/MPC8536DS.h 
 b/include/configs/MPC8536DS.h 
  index 4746e2e..6fab240 100644
  --- a/include/configs/MPC8536DS.h
  +++ b/include/configs/MPC8536DS.h
  @@ -31,6 +31,12 @@
  #define CONFIG_PHYS_64BIT   1
  #endif
 
  +#ifdef CONFIG_MPC8536DS_NAND
 
 I think I changed this to make it build.  Once we resolve how 
 we are tweaking mkconfig we can figure this out.
 
Ok.

  +#define CONFIG_NAND_U_BOOT 1
  +#define CONFIG_RAMBOOT_NAND1
  +#define CONFIG_RAMBOOT_TEXT_BASE   0xf8f82000
  +#endif
  +
 
 [snip]
 
  diff --git a/nand_spl/board/freescale/mpc8536ds/nand_boot.c b/ 
  nand_spl/board/freescale/mpc8536ds/nand_boot.c
  new file mode 100644
  index 000..77973d1
  --- /dev/null
  +++ b/nand_spl/board/freescale/mpc8536ds/nand_boot.c
  @@ -0,0 +1,99 @@
  +/*
  + * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights
  reserved.
 
 'All rights reserved' isn't acceptable (remove it).  Also get 
 rid of '(C)'
 
Ok.

  + *
  + * 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
  + *
  + */
 [snip]
 
 
 Also, we need to add MPC8536DS_NAND to MAKEALL
 
Ok, thanks.
Mingkai
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC][PATCH] NAND boot: MPC8536DS support

2009-09-11 Thread Kumar Gala
MPC8536E can support booting from NAND flash which uses the
image u-boot-nand.bin. This image contains two parts: a 4K
NAND loader and a main U-Boot image. The former is appended
to the latter to produce u-boot-nand.bin. The 4K NAND loader
includes the corresponding nand_spl directory, along with the
code twisted by CONFIG_NAND_SPL. The main U-Boot image just
like a general U-Boot image except the parts that included by
CONFIG_SYS_RAMBOOT.

When power on, eLBC will automatically load from bank 0 the
4K NAND loader into the FCM buffer RAM where CPU can execute
the boot code directly. In the first stage, the NAND loader
copies itself to RAM or L2SRAM to free up the FCM buffer RAM,
then loads the main image from NAND flash to RAM or L2SRAM
and boot from it.

This patch implements the NAND loader to load the main image
into L2SRAM, so the main image can configure the RAM by using
SPD EEPROM. In the first stage, the NAND loader copies itself
to the second to last 4K address space, and uses the last 4K
address space as the initial RAM for stack.

Obviously, the size of L2SRAM shouldn't be less than the size
of the image used. If so, the workaround is to generate another
image that includes the code to configure the RAM by SPD and
load it to L2SRAM first, then relocate the main image to RAM
to boot up.

Signed-off-by: Mingkai Hu mingkai...@freescale.com
Signed-off-by: Kumar Gala ga...@kernel.crashing.org
---
I've made some changes:

* Fixed white space in mpc8536ds/u-boot.lds
* Fixed nand_spl/board/freescale/mpc8536ds/Makefile:
  - added dependancy on fixed_ivor.S (fixes build issue w/-jN)
  - added cpu_init_early.c to files we pull in from cpu/mpc85xx
* Use cpu_init_early.c and killed code out of nand_init.c

I'll follow up with other's that still need to be made.

- k

 Makefile   |1 +
 board/freescale/mpc8536ds/config.mk|7 ++
 board/freescale/mpc8536ds/tlb.c|   11 ++
 cpu/mpc85xx/nand_init.c|   73 ++
 include/configs/MPC8536DS.h|   96 ++
 nand_spl/board/freescale/mpc8536ds/Makefile|  127 
 nand_spl/board/freescale/mpc8536ds/nand_boot.c |   99 ++
 nand_spl/board/freescale/mpc8536ds/u-boot.lds  |   67 +
 8 files changed, 461 insertions(+), 20 deletions(-)
 create mode 100644 cpu/mpc85xx/nand_init.c
 create mode 100644 nand_spl/board/freescale/mpc8536ds/Makefile
 create mode 100644 nand_spl/board/freescale/mpc8536ds/nand_boot.c
 create mode 100644 nand_spl/board/freescale/mpc8536ds/u-boot.lds

diff --git a/Makefile b/Makefile
index 9764cea..de1ba50 100644
--- a/Makefile
+++ b/Makefile
@@ -2446,6 +2446,7 @@ vme8349_config:   unconfig
 ATUM8548_config:   unconfig
@$(MKCONFIG) $(@:_config=) ppc mpc85xx atum8548

+MPC8536DS_NAND_config \
 MPC8536DS_36BIT_config \
 MPC8536DS_config:   unconfig
@mkdir -p $(obj)include
diff --git a/board/freescale/mpc8536ds/config.mk 
b/board/freescale/mpc8536ds/config.mk
index c1d0525..b59df48 100644
--- a/board/freescale/mpc8536ds/config.mk
+++ b/board/freescale/mpc8536ds/config.mk
@@ -23,6 +23,13 @@
 #
 # mpc8536ds board
 #
+ifndef NAND_SPL
+ifeq ($(CONFIG_MK_MPC8536DS_NAND), y)
+TEXT_BASE = $(CONFIG_RAMBOOT_TEXT_BASE)
+LDSCRIPT := $(TOPDIR)/cpu/$(CPU)/u-boot-nand.lds
+endif
+endif
+
 ifndef TEXT_BASE
 TEXT_BASE = 0xeff8
 endif
diff --git a/board/freescale/mpc8536ds/tlb.c b/board/freescale/mpc8536ds/tlb.c
index 35a13d4..dc52d7f 100644
--- a/board/freescale/mpc8536ds/tlb.c
+++ b/board/freescale/mpc8536ds/tlb.c
@@ -71,6 +71,17 @@ struct fsl_e_tlb_entry tlb_table[] = {
SET_TLB_ENTRY(1, CONFIG_SYS_NAND_BASE, CONFIG_SYS_NAND_BASE_PHYS,
  MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
  0, 4, BOOKE_PAGESZ_1M, 1),
+
+#if defined(CONFIG_SYS_RAMBOOT)  defined(CONFIG_SYS_INIT_L2_ADDR)
+   /* *I*G - L2SRAM */
+   SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR, CONFIG_SYS_INIT_L2_ADDR_PHYS,
+ MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+ 0, 5, BOOKE_PAGESZ_256K, 1),
+   SET_TLB_ENTRY(1, CONFIG_SYS_INIT_L2_ADDR + 0x4,
+ CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x4,
+ MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
+ 0, 6, BOOKE_PAGESZ_256K, 1),
+#endif
 };

 int num_tlb_entries = ARRAY_SIZE(tlb_table);
diff --git a/cpu/mpc85xx/nand_init.c b/cpu/mpc85xx/nand_init.c
new file mode 100644
index 000..dcbbc8d
--- /dev/null
+++ b/cpu/mpc85xx/nand_init.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2009 Freescale Semiconductor, Inc.
+ *
+ * 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 

Re: [U-Boot] [RFC][PATCH] NAND boot: MPC8536DS support

2009-09-11 Thread Kumar Gala

On Sep 11, 2009, at 2:17 PM, Kumar Gala

 Makefile   |1 +
 board/freescale/mpc8536ds/config.mk|7 ++
 board/freescale/mpc8536ds/tlb.c|   11 ++
 cpu/mpc85xx/nand_init.c|   73 ++

how about renaming nand_init.c to cpu_init_nand.c

[snip]

 diff --git a/cpu/mpc85xx/nand_init.c b/cpu/mpc85xx/nand_init.c
 new file mode 100644
 index 000..dcbbc8d
 --- /dev/null
 +++ b/cpu/mpc85xx/nand_init.c
 @@ -0,0 +1,73 @@
 +/*
 + * Copyright (C) 2009 Freescale Semiconductor, Inc.

the '(C)' isnt needed.

 + *
 + * 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 asm/io.h
 +#include asm/mmu.h
 +#include asm/fsl_law.h
 +
 +DECLARE_GLOBAL_DATA_PTR;
 +
 +void cpu_init_f(void)
 +{
 + ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
 +
 + /*
 +  * LCRR - Clock Ratio Register - set up local bus timing
 +  * when needed
 +  */
 + out_be32(lbc-lcrr, LCRR_DBYP | LCRR_CLKDIV_8);
 +
 +#if defined(CONFIG_NAND_BR_PRELIM)  \
 +  defined(CONFIG_NAND_OR_PRELIM)
 + out_be32(lbc-br0, CONFIG_NAND_BR_PRELIM);
 + out_be32(lbc-or0, CONFIG_NAND_OR_PRELIM);
 + /* for FPGA */
 + out_be32(lbc-br3, CONFIG_SYS_BR3_PRELIM);
 + out_be32(lbc-or3, CONFIG_SYS_OR3_PRELIM);
 +#else
 +#error  CONFIG_NAND_BR_PRELIM, CONFIG_NAND_OR_PRELIM must be defined
 +#endif
 +
 +#if defined(CONFIG_SYS_RAMBOOT)  defined(CONFIG_SYS_INIT_L2_ADDR)
 + ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
 + uint l2srbar;
 + int i;
 +
 + l2srbar = CONFIG_SYS_INIT_L2_ADDR;
 + out_be32(l2cache-l2srbar0, l2srbar);
 +
 + /* set MBECCDIS=1, SBECCDIS=1 */
 + out_be32(l2cache-l2errdis,
 + (MPC85xx_L2ERRDIS_MBECC |
 +  MPC85xx_L2ERRDIS_SBECC));
 +
 + /* set L2E=1  L2SRAM=001 */
 + out_be32(l2cache-l2ctl,
 + (MPC85xx_L2CTL_L2E |
 +  MPC85xx_L2CTL_L2SRAM_ENTIRE));
 +
 + /* Initialize L2 SRAM to zero */
 + for (i = 0; i  CONFIG_SYS_L2_SIZE; i++)
 + ((char *)l2srbar)[i] = 0;
 +#endif
 +}


 diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h
 index 4746e2e..6fab240 100644
 --- a/include/configs/MPC8536DS.h
 +++ b/include/configs/MPC8536DS.h
 @@ -31,6 +31,12 @@
 #define CONFIG_PHYS_64BIT 1
 #endif

 +#ifdef CONFIG_MPC8536DS_NAND

I think I changed this to make it build.  Once we resolve how we are  
tweaking mkconfig we can figure this out.

 +#define CONFIG_NAND_U_BOOT   1
 +#define CONFIG_RAMBOOT_NAND  1
 +#define CONFIG_RAMBOOT_TEXT_BASE 0xf8f82000
 +#endif
 +

[snip]

 diff --git a/nand_spl/board/freescale/mpc8536ds/nand_boot.c b/ 
 nand_spl/board/freescale/mpc8536ds/nand_boot.c
 new file mode 100644
 index 000..77973d1
 --- /dev/null
 +++ b/nand_spl/board/freescale/mpc8536ds/nand_boot.c
 @@ -0,0 +1,99 @@
 +/*
 + * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights  
 reserved.

'All rights reserved' isn't acceptable (remove it).  Also get rid of  
'(C)'

 + *
 + * 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
 + *
 + */
[snip]


Also, we need to add MPC8536DS_NAND to MAKEALL

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