nand boot for 85xx
Subsystems (2)
RFC 1/1 nand boot for 85xx
---
The patch is to be done, It is only giving the context why move the definition of fsl_law from .c to .h.
Makefile | 13 +- board/freescale/mpc8572ds/config.mk | 5 + board/freescale/mpc8572ds/nand_boot.c | 75 ++++ board/freescale/mpc8572ds/u-boot-nand.lds | 140 ++++++++ cpu/mpc85xx/nand_init.c | 102 ++++++ cpu/mpc85xx/nand_start.S | 469 +++++++++++++++++++++++++ cpu/mpc85xx/start.S | 3 + drivers/misc/fsl_law.c | 9 +- include/asm-ppc/fsl_law.h | 2 + include/configs/MPC8572DS.h | 64 ++++- nand_spl/board/freescale/mpc8572ds/Makefile | 110 ++++++ nand_spl/board/freescale/mpc8572ds/u-boot.lds | 56 +++ 12 files changed, 1040 insertions(+), 8 deletions(-) create mode 100644 board/freescale/mpc8572ds/nand_boot.c create mode 100644 board/freescale/mpc8572ds/u-boot-nand.lds create mode 100644 cpu/mpc85xx/nand_init.c create mode 100644 cpu/mpc85xx/nand_start.S create mode 100644 nand_spl/board/freescale/mpc8572ds/Makefile create mode 100644 nand_spl/board/freescale/mpc8572ds/u-boot.lds
Makefile +11 -2
@@ -2364,8 +2364,17 @@ MPC8555CDS_config: unconfig MPC8568MDS_config: unconfig @$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8568mds freescale -MPC8572DS_config: unconfig - @$(MKCONFIG) $(@:_config=) ppc mpc85xx mpc8572ds freescale +MPC8572DS_config \ +MPC8572DS_NAND_config: unconfig + @if [ "$(findstring _NAND_,$@)" ] ; then \ + $(XECHO) -n "...NAND..." ; \ + echo "TEXT_BASE = 0x01001000" > $(obj)board/freescale/mpc8572ds/config.tmp ; \ + echo "#define CONFIG_NAND_U_BOOT" >>$(obj)include/config.h ; \ + fi ; + @$(MKCONFIG) -a MPC8572DS ppc mpc85xx mpc8572ds freescale + @if [ "$(findstring _NAND_,$@)" ] ; then \ + echo "CONFIG_NAND_U_BOOT = y" >> $(obj)include/config.mk ; \ + fi ; PM854_config: unconfig @$(MKCONFIG) $(@:_config=) ppc mpc85xx pm854
board/freescale/mpc8572ds/config.mk +5 -0
@@ -23,6 +23,11 @@ # # mpc8572ds board # + +ifndef NAND_SPL +sinclude $(OBJTREE)/board/$(BOARDDIR)/config.tmp +endif + ifndef TEXT_BASE TEXT_BASE = 0xeff80000 endif
board/freescale/mpc8572ds/nand_boot.c new file +75 -0
75 lines not on this page · raw message
board/freescale/mpc8572ds/u-boot-nand.lds new file +140 -0
140 lines not on this page · raw message
cpu/mpc85xx/nand_init.c new file +102 -0
102 lines not on this page · raw message
cpu/mpc85xx/nand_start.S new file +469 -0
469 lines not on this page · raw message
cpu/mpc85xx/start.S +3 -0
@@ -183,6 +183,7 @@ _start_e500: mtspr DBCR0,r0 #endif +#ifndef CONFIG_NAND_U_BOOT /* create a temp mapping in AS=1 to the boot window */ lis r6,FSL_BOOKE_MAS0(1, 15, 0)@h ori r6,r6,FSL_BOOKE_MAS0(1, 15, 0)@l
@@ -254,6 +255,8 @@ switch_as: addi r3,r3,CONFIG_SYS_CACHELINE_SIZE bdnz 1b +#endif + /* Jump out the last 4K page and continue to 'normal' start */ #ifdef CONFIG_SYS_RAMBOOT b _start_cont
drivers/misc/fsl_law.c +7 -2
@@ -29,7 +29,6 @@DECLARE_GLOBAL_DATA_PTR ; -#define LAWAR_EN 0x80000000/* number of LAWs in the hw implementation */ #if defined(CONFIG_MPC8540 ) || defined(CONFIG_MPC8541 ) || \ defined(CONFIG_MPC8560 ) || defined(CONFIG_MPC8555 )
@@ -166,7 +165,13 @@ void init_laws(void)int i; gd->used_laws = ~((1 <<FSL_HW_NUM_LAWS ) -1 ); - +#ifdef CONFIG_NAND_U_BOOT +/* +* keep the LAW0 reserved as DDR@NAND boot case +* we init already the LAW0 for DDR in SPL nand stage +*/ + gd->used_laws |= (1 <<0 ); +#endif for (i =0 ; i < num_law_entries; i++) {if (law_table[i].index ==-1 ) set_next_law(law_table[i].addr, law_table[i].size,
include/asm-ppc/fsl_law.h +2 -0
@@ -9,6 +9,8 @@#define SET_LAW (a, sz, trgt) \ { .index = -1, .addr = a, .size = sz, .trgt_id = trgt } +#define LAWAR_EN 0x80000000 +enum law_size {LAW_SIZE_4K =0xb ,LAW_SIZE_8K ,
include/configs/MPC8572DS.h +60 -4
129 lines not on this page · raw message
nand_spl/board/freescale/mpc8572ds/Makefile new file +110 -0
110 lines not on this page · raw message
nand_spl/board/freescale/mpc8572ds/u-boot.lds new file +56 -0
56 lines not on this page · raw message
Signature · 1 line
1.5.4
Quoted 45 lines · Dave Liu
board/freescale/ renamed from board/freescale/mpc8572ds/nand_boot.c +0
-0
mpc8572ds/nand_boot.c
new file mode 100644
index 0000000..1fb0acdboard/freescale/mpc8572ds/nand_boot.c new file +27
-0@@ -0,0 +1,75 @@ +/* + +#include <common.h> +#include <ns16550.h> +#include <nand.h> +#include <asm/mmu.h> +#include <asm/immap_85xx.h> +#include <asm/fsl_law.h> +#include <asm/io.h> + +unsigned long get_bus_clk(void); +void tlb_set(u32 mas0, u32 mas1, u32 mas2, u32 mas3); +phys_size_t fixed_sdram (void); + +DECLARE_GLOBAL_DATA_PTR; + +void putc(char c) +{ +if (c == '\n') +NS16550_putc((NS16550_t)(CONFIG_SYS_CCSRBAR + 0x4500), '\r'); + +NS16550_putc((NS16550_t)(CONFIG_SYS_CCSRBAR + 0x4500), c); +} + +void board_init_f(ulong bootflag) +{ +volatile ccsr_local_ecm_t *ecm = (void *) (
CONFIG_SYS_MPC85xx_ECM_ADDR);board/freescale/mpc8572ds/nand_boot.c new file +9
-0+u32 mas0, mas1, mas2, mas3; + +/* init serial port */ +NS16550_init ((NS16550_t)(CONFIG_SYS_CCSRBAR +0x4500 ), +get_bus_clk () /16 /CONFIG_BAUDRATE ); +puts ("NAND boot... " ); +init_timebase (); + +/* set TLB1[8] for DDR mapping */
board/freescale/mpc8572ds/nand_boot.c line 63
Quoted 10 lines
board/freescale/mpc8572ds/nand_boot.c new file +10
-0+ mas0 =FSL_BOOKE_MAS0 (1 ,8 ,0 ); + mas1 =FSL_BOOKE_MAS1 (1 ,1 ,0 ,0 ,BOOKE_PAGESZ_1G ); + mas2 =FSL_BOOKE_MAS2 (0 ,0 ); + mas3 =FSL_BOOKE_MAS3 (0 ,0 ,MAS3_SX |MAS3_SW |MAS3_SR ); +tlb_set (mas0, mas1, mas2, mas3); + +/* set LAW0 for DDR access */ +out_be32 (&ecm->lawbar0,0 ); +out_be32 (&ecm->lawar0,LAWAR_EN | (LAW_TRGT_IF_DDR <<20 ) + |LAW_SIZE_512M );
we should use the last law not the first one in general.
board/freescale/mpc8572ds/nand_boot.c line 75
Quoted 13 lines
board/freescale/mpc8572ds/nand_boot.c new file +12
-0+/* init DDR memory controller */ +fixed_sdram (); + +/* relocate the first bootstrap */ +relocate_code (CONFIG_SYS_NAND_U_BOOT_RELOC +0x10000 , (gd_t *)gd, +CONFIG_SYS_NAND_U_BOOT_RELOC ); +} + +void board_init_r (gd_t *gd,ulong dest_addr) +{ +nand_boot (); +}
This code is part of the first stage (first 4k?) or second stage loader?
what is the entry point of the second stage loader?
- k
Quoted 17 lines
Quoted 17 lines
board/freescale/mpc8572ds/nand_boot.c new file +3
-0+void board_init_f (ulong bootflag) +{ + volatile ccsr_local_ecm_t *ecm = (void *)(
CONFIG_SYS_MPC85xx_ECM_ADDR);board/freescale/mpc8572ds/nand_boot.c new file +13
-0+u32 mas0, mas1, mas2, mas3; + +/* init serial port */ +NS16550_init ((NS16550_t)(CONFIG_SYS_CCSRBAR +0x4500 ), +get_bus_clk () /16 /CONFIG_BAUDRATE ); +puts ("NAND boot... " ); +init_timebase (); + +/* set TLB1[8] for DDR mapping */ + mas0 =FSL_BOOKE_MAS0 (1 ,8 ,0 ); + mas1 =FSL_BOOKE_MAS1 (1 ,1 ,0 ,0 ,BOOKE_PAGESZ_1G ); + mas2 =FSL_BOOKE_MAS2 (0 ,0 ); + mas3 =FSL_BOOKE_MAS3 (0 ,0 ,MAS3_SX |MAS3_SW |MAS3_SR );
Quoted 8 lines
board/freescale/mpc8572ds/nand_boot.c line 63
Quoted 6 lines
board/freescale/mpc8572ds/nand_boot.c new file +6
-0+tlb_set (mas0, mas1, mas2, mas3); + +/* set LAW0 for DDR access */ +out_be32 (&ecm->lawbar0,0 ); +out_be32 (&ecm->lawar0,LAWAR_EN | (LAW_TRGT_IF_DDR <<20 ) + |LAW_SIZE_512M );we should use the last law not the first one in general.
The last law is also good choice, I want to make better way to handle the LAW.
Quoted 6 lines
board/freescale/mpc8572ds/nand_boot.c
Quoted 5 lines
board/freescale/mpc8572ds/nand_boot.c new file +5
-0+/* init DDR memory controller */ +fixed_sdram (); + +/* relocate the first bootstrap */ + relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC + 0x10000,(
gd_t*)gd,
Quoted 10 lines
board/freescale/mpc8572ds/nand_boot.c line 75
Quoted 7 lines
board/freescale/mpc8572ds/nand_boot.c new file +7
-0+ CONFIG_SYS_NAND_U_BOOT_RELOC); +} + +void board_init_r (gd_t *gd,ulong dest_addr) +{ +nand_boot (); +}This code is part of the first stage (first 4k?) or second stage loader?
The first stage(first 4K)
Quoted 1 line
what is the entry point of the second stage loader?
_start_e500.
Quoted 18 lines · Dave Liu
---
The patch is to be done, It is only giving the context why move the definition offsl_lawfrom .c to .h.Makefile | 13 +- board/freescale/mpc8572ds/config.mk | 5 + board/freescale/mpc8572ds/nand_boot.c | 75 ++++ board/freescale/mpc8572ds/u-boot-nand.lds | 140 ++++++++ cpu/mpc85xx/nand_init.c | 102 ++++++ cpu/mpc85xx/nand_start.S | 469 ++++++++++++++++ +++++++++ cpu/mpc85xx/start.S | 3 + drivers/misc/fsl_law.c | 9 +- include/asm-ppc/fsl_law.h | 2 + include/configs/MPC8572DS.h | 64 ++++- nand_spl/board/freescale/mpc8572ds/Makefile | 110 ++++++ nand_spl/board/freescale/mpc8572ds/u-boot.lds | 56 +++ 12 files changed, 1040 insertions(+), 8 deletions(-)
Quoted 6 lines
create mode 100644
board/freescale/mpc8572ds/nand_boot.ccreate mode 100644board/freescale/mpc8572ds/u-boot-nand.ldscreate mode 100644cpu/mpc85xx/nand_init.c
create mode 100644cpu/mpc85xx/nand_start.S
create mode 100644 nand_spl/board/freescale/mpc8572ds/Makefile create mode 100644nand_spl/board/freescale/mpc8572ds/u-boot.lds
While I know Dave is posting this patch for my query on law changes I do have some comments now that I understand it better.
1. patch should be split into at least two patches. One for the first stage loader changes and one for the second stage u-boot
2. we should look at refactoring common code so not to duplicate it. For example can we put a fair amount of common code w/start.S in a header to share w/nand_start.S
Also, how much space do we have for the first stage loader? How big is the current u-boot created first stage loader (how much free space do we have?)?
- k
Quoted 4 lines
1. patch should be split into at least two patches. One for the first stage loader changes and one for the second stage u-boot
absolutely correct. It is also my desired.
Because you query the LAW, I submit the patch for that purpose.
Quoted 3 lines
2. we should look at refactoring common code so not to duplicate it. For example can we put a fair amount of common code
w/start.Sin a header to sharew/nand_start.S
You are right, I was considering the idea.
make the first 4K (bootpage) shareable for NOR and NAND boot.
Quoted 4 lines
Also, how much space do we have for the first stage loader? How big is the current u-boot created first stage loader (how much free space
do we have?)?
4K for the first stage loader. currently the first stage loader occupy 60~70% of the 4K bootpage.
Another issue is, could we split the relocate code from 4xx/83xx/85xx/86xx
to on common/ppc/relocate.S?
Quoted 6 lines
4K for the first stage loader. currently the first stage loader occupy 60~70% of the 4K bootpage.
Another issue is, could we split the relocate code from 4xx/83xx/85xx/86xx
to oncommon/ppc/relocate.S?
If its common I don't see why not.
- k