Skip to contentSkip to conversation

NAND boot: MPC8536DS support

PATCH Superseded Mingkai Hu 6 participants 17 messages Sep 18, 2009 – Sep 23, 2009 Kbuild

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Mingkai Hu

author
#0 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

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.

---

Change over v2:
- Intergrated Kumar's comments.
- Aligned to the leatest git tree

 MAKEALL                                        |    1 +
 Makefile                                       |    1 +
 board/freescale/mpc8536ds/config.mk            |    7 ++
 board/freescale/mpc8536ds/tlb.c                |   11 ++
 cpu/mpc85xx/cpu_init_nand.c                    |   69 +++++++++++++
 include/configs/MPC8536DS.h                    |   96 +++++++++++++++----
 nand_spl/board/freescale/mpc8536ds/Makefile    |  123 ++++++++++++++++++++++++
 nand_spl/board/freescale/mpc8536ds/nand_boot.c |   99 +++++++++++++++++++
 nand_spl/board/freescale/mpc8536ds/u-boot.lds  |   67 +++++++++++++
 9 files changed, 454 insertions(+), 20 deletions(-)
 create mode 100644 cpu/mpc85xx/cpu_init_nand.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
MAKEALL +1 -0
index 1d50c34..283add0 100755
@@ -378,6 +378,7 @@ LIST_83xx="		\
 LIST_85xx="		\
 	ATUM8548	\
 	MPC8536DS	\
+	MPC8536DS_NAND	\
 	MPC8540ADS	\
 	MPC8540EVAL	\
 	MPC8541CDS	\
Makefile +1 -0
index 99837a3..4d18a9f 100644
@@ -2446,6 +2446,7 @@ vme8349_config:		unconfig
 ATUM8548_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx atum8548
 
+MPC8536DS_NAND_config \
 MPC8536DS_36BIT_config \
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) -t $(@:_config=) MPC8536DS ppc mpc85xx mpc8536ds freescale
board/freescale/mpc8536ds/config.mk +7 -0
index c1d0525..d6490b5 100644
@@ -23,6 +23,13 @@
 #
 # mpc8536ds board
 #
+ifndef NAND_SPL
+ifeq ($(CONFIG_MK_NAND), y)
+TEXT_BASE = $(CONFIG_RAMBOOT_TEXT_BASE)
+LDSCRIPT := $(TOPDIR)/cpu/$(CPU)/u-boot-nand.lds
+endif
+endif
+
 ifndef TEXT_BASE
 TEXT_BASE = 0xeff80000
 endif
board/freescale/mpc8536ds/tlb.c +11 -0
index 35a13d4..dc52d7f 100644
@@ -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 + 0x40000,
+		      CONFIG_SYS_INIT_L2_ADDR_PHYS + 0x40000,
+		      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);
cpu/mpc85xx/cpu_init_nand.c new file +69 -0

69 lines not on this page · raw message

include/configs/MPC8536DS.h +76 -20

167 lines not on this page · raw message

nand_spl/board/freescale/mpc8536ds/Makefile new file +123 -0

123 lines not on this page · raw message

nand_spl/board/freescale/mpc8536ds/nand_boot.c new file +99 -0

99 lines not on this page · raw message

nand_spl/board/freescale/mpc8536ds/u-boot.lds new file +67 -0

67 lines not on this page · raw message

Signature · 1 line
1.6.4
author
#1 lore raw

PATCH v3 2/3 On-chip ROM boot: MPC8536DS support

The MPC8536E is capable of booting from the on-chip ROM - boot from eSDHC and boot from eSPI. When power on, the porcessor excutes the ROM code to initialize the eSPI/eSDHC controller, and loads the mian U-Boot image from the memory device that interfaced to the controller, such as the SDCard or SPI EEPROM, to the target memory, e.g. SDRAM or L2SRAM, then boot from it.

The memory device should contain a specific data structure with control word and config word at the fixed address. The config word direct the process how to config the memory device, and the control word direct the processor where to find the image on the memory device, or where copy the main image to. The user can use any method to store the data structure to the memory device, only if store it on the assigned address.

The on-chip ROM code will map the whole 4GB address space by setting entry0 in the TLB1, so the main image need to switch to Address space 1 to disable this mapping and map the address space again.

This patch implements loading the mian U-Boot image into L2SRAM, so the image can configure the system memory by using SPD EEPROM.

---

Change over v2:
- Intergrated Kumar's comments.
- Aligned to the leatest git tree

 MAKEALL                             |    2 ++
 Makefile                            |    2 ++
 board/freescale/mpc8536ds/config.mk |   12 ++++++++++++
 include/configs/MPC8536DS.h         |   17 ++++++++++++++++-
 4 files changed, 32 insertions(+), 1 deletions(-)
MAKEALL +2 -0
index 283add0..97600f2 100755
@@ -379,6 +379,8 @@ LIST_85xx="		\
 	ATUM8548	\
 	MPC8536DS	\
 	MPC8536DS_NAND	\
+	MPC8536DS_SDCARD	\
+	MPC8536DS_SPIFLASH	\
 	MPC8540ADS	\
 	MPC8540EVAL	\
 	MPC8541CDS	\
Makefile +2 -0
index 4d18a9f..8f7f7c3 100644
@@ -2447,6 +2447,8 @@ ATUM8548_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx atum8548
 
 MPC8536DS_NAND_config \
+MPC8536DS_SDCARD_config \
+MPC8536DS_SPIFLASH_config \
 MPC8536DS_36BIT_config \
 MPC8536DS_config:       unconfig
 	@$(MKCONFIG) -t $(@:_config=) MPC8536DS ppc mpc85xx mpc8536ds freescale
board/freescale/mpc8536ds/config.mk +12 -0
index d6490b5..e38af73 100644
@@ -30,8 +30,20 @@ LDSCRIPT := $(TOPDIR)/cpu/$(CPU)/u-boot-nand.lds
 endif
 endif
 
+ifeq ($(CONFIG_MK_SDCARD), y)
+TEXT_BASE = $(CONFIG_RAMBOOT_TEXT_BASE)
+RESET_VECTOR_ADDRESS = 0xf8fffffc
+endif
+
+ifeq ($(CONFIG_MK_SPIFLASH), y)
+TEXT_BASE = $(CONFIG_RAMBOOT_TEXT_BASE)
+RESET_VECTOR_ADDRESS = 0xf8fffffc
+endif
+
 ifndef TEXT_BASE
 TEXT_BASE = 0xeff80000
 endif
 
+ifndef RESET_VECTOR_ADDRESS
 RESET_VECTOR_ADDRESS = 0xeffffffc
+endif
include/configs/MPC8536DS.h +16 -1
index b6f1e60..97091d4 100644
@@ -37,6 +37,16 @@
 #define CONFIG_RAMBOOT_TEXT_BASE	0xf8f82000
 #endif
 
+#ifdef CONFIG_MK_SDCARD
+#define CONFIG_RAMBOOT_SDCARD		1
+#define CONFIG_RAMBOOT_TEXT_BASE	0xf8f80000
+#endif
+
+#ifdef CONFIG_MK_SPIFLASH
+#define CONFIG_RAMBOOT_SPIFLASH		1
+#define CONFIG_RAMBOOT_TEXT_BASE	0xf8f80000
+#endif
+
 /* High Level Configuration Options */
 #define CONFIG_BOOKE		1	/* BOOKE */
 #define CONFIG_E500		1	/* BOOKE e500 family */
@@ -231,7 +241,8 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 
 #define CONFIG_SYS_MONITOR_BASE	TEXT_BASE	/* start of monitor */
 
-#if defined(CONFIG_SYS_SPL) || defined(CONFIG_RAMBOOT_NAND)
+#if defined(CONFIG_SYS_SPL) || defined(CONFIG_RAMBOOT_NAND) \
+	|| defined(CONFIG_RAMBOOT_SDCARD) || defined(CONFIG_RAMBOOT_SPIFLASH)
 #define CONFIG_SYS_RAMBOOT
 #else
 #undef CONFIG_SYS_RAMBOOT
@@ -622,6 +633,10 @@ extern unsigned long get_board_ddr_clk(unsigned long dummy);
 	#define CONFIG_ENV_IS_IN_NAND	1
 	#define CONFIG_ENV_SIZE		CONFIG_SYS_NAND_BLOCK_SIZE
 	#define CONFIG_ENV_OFFSET	((512 * 1024) + CONFIG_SYS_NAND_BLOCK_SIZE)
+#elif defined(CONFIG_RAMBOOT_SDCARD) || defined(CONFIG_RAMBOOT_SPIFLASH)
+	#define CONFIG_ENV_IS_NOWHERE	1	/* Store ENV in memory only */
+	#define CONFIG_ENV_ADDR		(CONFIG_SYS_MONITOR_BASE - 0x1000)
+	#define CONFIG_ENV_SIZE		0x2000
 #endif
 #else
 	#define CONFIG_ENV_IS_IN_FLASH	1
Signature · 1 line
1.6.4
author
#2 lore raw

PATCH v3 3/3 Add README.mpc8536ds

Add boot from NAND/eSDHC/eSPI description

---

No change over v2, it comes here for the pick up convience.

 doc/README.mpc8536ds |  127 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.mpc8536ds
doc/README.mpc8536ds new file +127 -0
new file mode 100644
index 0000000..4d0bee0
@@ -0,0 +1,127 @@
+Overview:
+=========
+
+The MPC8536E integrates a PowerPC processor core with system logic
+required for imaging, networking, and communications applications.
+
+Boot from NAND:
+===============
+
+The MPC8536E is capable of booting from NAND flash which uses the image
+u-boot-nand.bin. This image contains two parts: a first stage image(also
+call 4K NAND loader and a second stage image. The former is appended to
+the latter to produce u-boot-nand.bin.
+
+The bootup process can be divided into two stages: the first stage will
+configure the L2SRAM, then copy the second stage image to L2SRAM and jump
+to it. The second stage image is to configure all the hardware and boot up
+to U-Boot command line.
+
+The 4K NAND loader's code comes from the corresponding nand_spl directory,
+along with the code twisted by CONFIG_NAND_SPL. The macro CONFIG_NAND_SPL
+is mainly used to shrink the code size to the 4K size limitation.
+
+The macro CONFIG_SYS_RAMBOOT is used to control the code to produce the
+second stage image. It's set in the board config file when boot from NAND
+is selected.
+
+Build and boot steps
+--------------------
+
+1. Building image
+	make MPC8536DS_NAND_config
+	make CROSS_COMPILE=powerpc-none-linux-gnuspe- all
+
+2. Change dip-switch
+	SW2[5-8] = 1011
+	SW9[1-3] = 101
+	Note: 1 stands for 'on', 0 stands for 'off'
+
+3. Flash image
+	tftp 1000000 u-boot-nand.bin
+	nand erase 0 a0000
+	nand write 1000000 0 a0000
+
+Boot from On-chip ROM:
+======================
+
+The MPC8536E is capable of booting from the on-chip ROM - boot from eSDHC
+and boot from eSPI. When power on, the porcessor excutes the ROM code to
+initialize the eSPI/eSDHC controller, and loads the mian U-Boot image from
+the memory device that interfaced to the controller, such as the SDCard or
+SPI EEPROM, to the target memory, e.g. SDRAM or L2SRAM, then boot from it.
+
+The memory device should contain a specific data structure with control word
+and config word at the fixed address. The config word direct the process how
+to config the memory device, and the control word direct the processor where
+to find the image on the memory device, or where copy the main image to. The
+user can use any method to store the data structure to the memory device, only
+if store it on the assigned address.
+
+Build and boot steps
+--------------------
+
+For boot from eSDHC:
+1. Build image
+	make MPC8536DS_SDCARD_config
+	make CROSS_COMPILE=powerpc-none-linux-gnuspe- all
+
+2. Change dip-switch
+	SW2[5-8] = 0111
+	SW3[1]   = 0
+	SW8[7]   = 0 - The on-board SD/MMC slot is active
+	SW8[7]   = 1 - The externel SD/MMC slot is active
+
+3. Put image to SDCard
+	Put the follwing info at the assigned address on the SDCard:
+
+	   Offset   |   Data     | Description
+	--------------------------------------------------------
+	| 0x40-0x43 | 0x424F4F54 | BOOT signature              |
+	--------------------------------------------------------
+	| 0x48-0x4B | 0x00080000 | u-boot.bin's size           |
+	--------------------------------------------------------
+	| 0x50-0x53 | 0x???????? | u-boot.bin's Addr on SDCard |
+	--------------------------------------------------------
+	| 0x58-0x5B | 0xF8F80000 | Target Address              |
+	-------------------------------------------------------
+	| 0x60-0x63 | 0xF8FFF000 | Execution Starting Address  |
+	--------------------------------------------------------
+	| 0x68-0x6B | 0x6        | Number of Config Addr/Data  |
+	--------------------------------------------------------
+	| 0x80-0x83 | 0xFF720100 | Config Addr 1               |
+	| 0x84-0x87 | 0xF8F80000 | Config Data 1               |
+	--------------------------------------------------------
+	| 0x88-0x8b | 0xFF720e44 | Config Addr 2               |
+	| 0x8c-0x8f | 0x0000000C | Config Data 2               |
+	--------------------------------------------------------
+	| 0x90-0x93 | 0xFF720000 | Config Addr 3               |
+	| 0x94-0x97 | 0x80010000 | Config Data 3               |
+	--------------------------------------------------------
+	| 0x98-0x9b | 0xFF72e40e | Config Addr 4               |
+	| 0x9c-0x9f | 0x00000040 | Config Data 4               |
+	--------------------------------------------------------
+	| 0xa0-0xa3 | 0x40000001 | Config Addr 5               |
+	| 0xa4-0xa7 | 0x00000100 | Config Data 5               |
+	--------------------------------------------------------
+	| 0xa8-0xab | 0x80000001 | Config Addr 6               |
+	| 0xac-0xaf | 0x80000001 | Config Data 6               |
+	--------------------------------------------------------
+	|              ......                                  |
+	--------------------------------------------------------
+	| 0x???????? | u-boot.bin                              |
+	--------------------------------------------------------
+
+	then insert the SDCard to the active slot to boot up.
+
+For boot from eSPI:
+1. Build image
+	make MPC8536DS_SPIFLASH_config
+	make CROSS_COMPILE=powerpc-none-linux-gnuspe- all
+
+2. Change dip-switch
+	SW2[5-8] = 0110
+
+3. Put image to SPI flash
+	Put the info in the above table onto the SPI flash, then
+	boot up.
Signature · 1 line
1.6.4
#4 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 9 lines

-----Original Message-----
From: Kumar Gala [mailto:galak at kernel.crashing.org]
Sent: Friday, September 18, 2009 9:55 PM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Wood Scott-B07421
Subject: Re: [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 4 lines

Looks good.

Any plans on adding support on 8572 and/or p2020?

Time is tight for 8536 final release now. After the release, I'll add for it.

Thanks,
Mingkai

#5 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Mingkai Hu

Makefile vme8349_config: unconfig · line 2451

Quoted 11 lines · Mingkai Hu
Makefile +1 -0
index 99837a3..4d18a9f 100644
@@ -2446,6 +2446,7 @@ vme8349_config:		unconfig
 ATUM8548_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx atum8548
 
+MPC8536DS_NAND_config \
 MPC8536DS_36BIT_config \
 MPC8536DS_config:       unconfig

NAND and 36BIT are orthogonal.

How about changing it to:

# Options: NAND, 36BIT
MPC8536DS_%_config MPC8536DS_config: unconfig

Makefile vme8349_config: unconfig

Quoted 7 lines
Makefile +7 -0
+#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);

Those last two lines should probably be #ifdef CONFIG_SYS_BR3_PRELIM.

Quoted 11 lines
Makefile +11 -0
+#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 |

Makefile

Quoted 10 lines
Makefile +10 -0
+			 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;

"uint" is not a valid type for either virtual or physical addresses.

Use a pointer (or uintptr_t if you must) for the former, and phys_addr_t for the latter.

You're using it as char *, so why not just declare it that way?

Makefile

Quoted 3 lines
Makefile +3 -0
+void board_init_f(ulong bootflag)
+{
+	u8 sysclk_ratio;

You're not saving any space over plain int/uint...

Quoted 23 lines
Makefile +23 -0
+	uint plat_ratio, bus_clk, sys_clk;
+	volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
+
+	/* initialize selected port with appropriate baud rate */
+	sysclk_ratio = *((volatile unsigned char *)(PIXIS_BASE + PIXIS_SPD));
+	sysclk_ratio &= 0x7;
+	switch (sysclk_ratio) {
+	case 0:
+		sys_clk = 33333000;
+		break;
+	case 1:
+		sys_clk = 39999600;
+		break;
+	case 2:
+		sys_clk = 49999500;
+		break;
+	case 3:
+		sys_clk = 66666000;
+		break;
+	case 4:
+		sys_clk = 83332500;
+		break;
+	case 5:

Makefile

Quoted 10 lines
Makefile +10 -0
+		sys_clk = 99999000;
+		break;
+	case 6:
+		sys_clk = 133332000;
+		break;
+	case 7:
+		sys_clk = 166665000;
+		break;
+	default:
+		sys_clk = 0;

This default: case is impossible to reach.

Makefile

Quoted 2 lines
Makefile +2 -0
+		break;
+	}

We could save some space by putting this in a table.

Makefile

Quoted 1 line
Makefile +1 -0
+	plat_ratio = (gur->porpllsr) & 0x0000003e;

Unnecessary parens.

Makefile

Quoted 1 line
Makefile +1 -0
+	plat_ratio >>= 1;

plat_ratio /= 2 is more readable and should generate identical code.

-Scott

#6 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 24 lines

-----Original Message-----
From: Wood Scott-B07421
Sent: Saturday, September 19, 2009 12:37 AM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; galak at kernel.crashing.org
Subject: Re: [PATCH v3 1/3] NAND boot: MPC8536DS support

Makefile vme8349_config: unconfig · line 2451

Quoted 11 lines · Mingkai Hu
Makefile +1 -0
index 99837a3..4d18a9f 100644
@@ -2446,6 +2446,7 @@ vme8349_config:		unconfig
 ATUM8548_config:	unconfig
 	@$(MKCONFIG) $(@:_config=) ppc mpc85xx atum8548
 
+MPC8536DS_NAND_config \
 MPC8536DS_36BIT_config \
 MPC8536DS_config:       unconfig

NAND and 36BIT are orthogonal.

Quoted 5 lines

How about changing it to:

# Options: NAND, 36BIT
MPC8536DS_%_config MPC8536DS_config: unconfig

I don't get it. what's the '%'? or how to use it?

Quoted 10 lines

Makefile vme8349_config: unconfig

Quoted 7 lines
Makefile +7 -0
+#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);

Those last two lines should probably be #ifdef CONFIG_SYS_BR3_PRELIM.

Ok.

Quoted 24 lines
Quoted 11 lines
Makefile +11 -0
+#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 |

Makefile

Quoted 10 lines
Makefile +10 -0
+			 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;

"uint" is not a valid type for either virtual or physical addresses.

Quoted 5 lines

Use a pointer (or uintptr_t if you must) for the former, and phys_addr_t for the latter.

You're using it as char *, so why not just declare it that way?

Ok, change to char *.

Quoted 49 lines

Makefile

Quoted 3 lines
Makefile +3 -0
+void board_init_f(ulong bootflag)
+{
+	u8 sysclk_ratio;

You're not saving any space over plain int/uint...

Makefile

Quoted 2 lines
Makefile +2 -0
+	uint plat_ratio, bus_clk, sys_clk;
+	volatile ccsr_gur_t *gur = (void 

*)(CONFIG_SYS_MPC85xx_GUTS_ADDR);

Makefile

Quoted 3 lines
Makefile +3 -0
+
+	/* initialize selected port with appropriate baud rate */
+	sysclk_ratio = *((volatile unsigned char *)(PIXIS_BASE 

+ PIXIS_SPD));

Quoted 18 lines
Makefile +18 -0
+	sysclk_ratio &= 0x7;
+	switch (sysclk_ratio) {
+	case 0:
+		sys_clk = 33333000;
+		break;
+	case 1:
+		sys_clk = 39999600;
+		break;
+	case 2:
+		sys_clk = 49999500;
+		break;
+	case 3:
+		sys_clk = 66666000;
+		break;
+	case 4:
+		sys_clk = 83332500;
+		break;
+	case 5:

Makefile

Quoted 10 lines
Makefile +10 -0
+		sys_clk = 99999000;
+		break;
+	case 6:
+		sys_clk = 133332000;
+		break;
+	case 7:
+		sys_clk = 166665000;
+		break;
+	default:
+		sys_clk = 0;

This default: case is impossible to reach.

Makefile

Quoted 2 lines
Makefile +2 -0
+		break;
+	}

We could save some space by putting this in a table.

Quoted 8 lines

Makefile

Quoted 1 line
Makefile +1 -0
+	plat_ratio = (gur->porpllsr) & 0x0000003e;

Unnecessary parens.

Makefile

Quoted 1 line
Makefile +1 -0
+	plat_ratio >>= 1;

plat_ratio /= 2 is more readable and should generate identical code.

Reshaped this function(board_init_f) by table-driven method.

Thanks,
Mingkai

#7 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 6 lines · On Sun, Sep 20, 2009 at 11:40:33PM -0700, Hu Mingkai-B21284 wrote:
Quoted 5 lines

How about changing it to:

# Options: NAND, 36BIT
MPC8536DS_%_config MPC8536DS_config: unconfig

I don't get it. what's the '%'? or how to use it?

It is a wildcard (or more specifically, a pattern rule). It will match anything that begins with MPC8536DS_ and ends with _config.

-Scott

#8 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Mingkai Hu
Quoted 1 line · Mingkai Hu

nand_spl/board/freescale/mpc8536ds/u-boot.lds | 67 +++++++++++++

Can we move this to some common location? cpu/mpc85xx/u- boot_nand_spl.lds?

- k

#9 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 10 lines

-----Original Message-----
From: Kumar Gala [mailto:galak at kernel.crashing.org]
Sent: Saturday, September 19, 2009 2:41 AM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Wood Scott-B07421
Subject: Re: [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 7 lines
Quoted 1 line · Mingkai Hu

nand_spl/board/freescale/mpc8536ds/u-boot.lds | 67 +++++++++++++

Can we move this to some common location? cpu/mpc85xx/u- boot_nand_spl.lds?

Yes, I think it can. Thanks

Mingkai

#10 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Mingkai Hu
Quoted 42 lines · Mingkai Hu
cpu/mpc85xx/cpu_init_nand.c new file +36 -0
new file mode 100644
index 0000000..e62f8d3
@@ -0,0 +1,69 @@
+/*
+ * Copyright 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 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>
+
+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)  \

cpu/mpc85xx/cpu_init_nand.c line 46

Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +10 -0
+	&& 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
+

Should we not have br/or1, br/or2, etc?

- k

#11 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 22 lines
Quoted 11 lines
cpu/mpc85xx/cpu_init_nand.c new file +9 -0
 
+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);

cpu/mpc85xx/cpu_init_nand.c

Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +10 -0
+
+#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

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+

Should we not have br/or1, br/or2, etc?

And FPGA stuff put here cpu/mpc85xx.....
It is *not* good practice and should be move out from here. I know the FPGA is for UART clock.

#12 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Hi Liu,

I have posted the patch for the same.
Have a look at the attachment.

Thanks
Dipen

-----Original Message-----
From: [email protected] [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Liu Dave-R63238
Sent: Saturday, September 19, 2009 5:31 AM
To: Kumar Gala; Hu Mingkai-B21284
Cc: Wood Scott-B07421; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 21 lines
Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +8 -0
 
+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
+	 */

cpu/mpc85xx/cpu_init_nand.c

Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +10 -0
+	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

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+

Should we not have br/or1, br/or2, etc?

And FPGA stuff put here cpu/mpc85xx.....
It is *not* good practice and should be move out from here. I know the FPGA is for UART clock.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

-------------- next part --------------
An embedded message was scrubbed...
From: "Dudhat Dipen-B09055" <[email protected]>
Subject: [ubootdev] [PATCH v1]ppc/85xx/NAND:Check to program BR3/OR3 required or not
Date: Fri, 18 Sep 2009 19:21:57 +0530
Size: 2728
Url: http://lists.denx.de/pipermail/u-boot/attachments/20090920/5f38317b/attachment.eml

#13 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Liu Dave-R63238
Quoted 36 lines

-----Original Message-----
From: Liu Dave-R63238
Sent: Saturday, September 19, 2009 8:01 AM
To: Kumar Gala; Hu Mingkai-B21284
Cc: Wood Scott-B07421; u-boot at lists.denx.de
Subject: RE: [U-Boot] [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 21 lines
Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +8 -0
 
+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
+	 */

cpu/mpc85xx/cpu_init_nand.c

Quoted 10 lines
cpu/mpc85xx/cpu_init_nand.c new file +10 -0
+	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

Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+#endif
+

Should we not have br/or1, br/or2, etc?

Quoted 4 lines

And FPGA stuff put here cpu/mpc85xx.....
It is *not* good practice and should be move out from here. I know the FPGA is for UART clock.

Yes, it's only used for getting the SYSCLK. Where should we put it to? to the nand_spl/board/freescale/mpc8536ds/nand_boot.c?

Thanks,
Mingkai

#14 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Kumar Gala
Quoted 26 lines

-----Original Message-----
From: Kumar Gala [mailto:galak at kernel.crashing.org]
Sent: Saturday, September 19, 2009 2:42 AM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Wood Scott-B07421
Subject: Re: [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 17 lines
cpu/mpc85xx/cpu_init_nand.c new file +17 -0
+
+#include <common.h>
+#include <asm/io.h>
+
+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);
Quoted 9 lines

cpu/mpc85xx/cpu_init_nand.c line 46

Quoted 6 lines
cpu/mpc85xx/cpu_init_nand.c new file +6 -0
+	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
+

Should we not have br/or1, br/or2, etc?

In order to boot from NAND, it should be connected on br/or0, so we don't care br/or1, br/or2.
The br/or3 shoud be moved to board specific file nand_boot.c, as dave pointed, owing to different
connection between the different borads.

Thanks,
Mingkai

#15 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

In reply to Mingkai Hu

Dear Mingkai Hu,

Quoted 28 lines · In message <[email protected]> you…

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.

Quoted 6 lines

---

Change over v2:
- Intergrated Kumar's comments.
- Aligned to the leatest git tree

I am a bit surprised about your way to number patch versions ;-)

We had a "[PATCH v3 1/3] NAND boot: MPC8536DS support" on Sep 18 already, and now again.

But OK, the things I complained about for the old version are still present, too.

Please fix - but then update the version, too, please.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Without freedom of choice there is no creativity.
	-- Kirk, "The return of the Archons", stardate 3157.4
#16 lore raw

PATCH v3 1/3 NAND boot: MPC8536DS support

Quoted 10 lines

-----Original Message-----
From: Wolfgang Denk [mailto:wd at denx.de]
Sent: Wednesday, September 23, 2009 5:11 AM
To: Hu Mingkai-B21284
Cc: u-boot at lists.denx.de; Wood Scott-B07421; galak at kernel.crashing.org
Subject: Re: [U-Boot] [PATCH v3 1/3] NAND boot: MPC8536DS support

Quoted 1 line
Quoted 9 lines
Quoted 3 lines

Change over v2:
- Intergrated Kumar's comments.
- Aligned to the leatest git tree

I am a bit surprised about your way to number patch versions ;-)

We had a "[PATCH v3 1/3] NAND boot: MPC8536DS support" on Sep 18 already, and now again.

Actually this patch you replied is the patch sent on Sep 18 :-)

Quoted 3 lines

But OK, the things I complained about for the old version are still present, too.

The version you complained about is v2, it should be v3, and this version v3 should be v4,
but I sent this version as v3, wanted to make it continuous with v2 and didn't leave a sudden v4.

Quoted 2 lines

Please fix - but then update the version, too, please.

Ok, the next version should be v4, is that OK? :-)

Thanks,
Mingkai