From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Wed, 12 Jun 2013 17:28:33 -0500 Subject: [U-Boot] [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL In-Reply-To: <1370757283-20276-1-git-send-email-ying.zhang@freescale.com> (from ying.zhang@freescale.com on Sun Jun 9 00:54:43 2013) Message-ID: <1371076113.18413.55@snotra> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/09/2013 12:54:43 AM, ying.zhang at freescale.com wrote: > From: Ying Zhang > > Due to the nand SPL on the board P1022DS has a size limit, it can not > be > more than 4K. So, the SPL cannot initialize the DDR with the SPD code. > This patch introduces TPL to enable a loader stub that runs in the L2 > SRAM, > after being loaded by the code from the SPL. It initializes the DDR > with > the SPD. > > The TPL's size is sizeable, the maximum size must not exceed the size > of L2 > SRAM. It initializes the DDR through SPD code, and copys final uboot > image > to DDR. So there are three stage uboot images: > * spl_boot, 4KB size, pad to 128K byte. > * tpl_boot, 88K size, pad to 128K size. The env variables are > copied to L2 SRAM, so that ddr SPD code can get the interleaving > mode setting in env. It loads final uboot image from offset > 256KB. > * final uboot image, size is variable depends on the functions > enabled. > > This patch is on top of the patch: > powerpc/p1022ds: boot from SD Card with SPL > > Signed-off-by: Ying Zhang > --- > Makefile | 25 +++- > README | 55 ++++++- > arch/powerpc/config.mk | 2 + > arch/powerpc/cpu/mpc85xx/spl_minimal.c | 16 ++ > arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds | 80 +++++++++ > .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c | 4 +- > arch/powerpc/lib/Makefile | 2 + > board/freescale/p1022ds/Makefile | 3 + > board/freescale/p1022ds/spl_minimal.c | 56 +------ > board/freescale/p1022ds/tlb.c | 4 +- > board/freescale/p1022ds/tpl.c | 101 > ++++++++++++ > common/Makefile | 9 + > common/cmd_nvedit.c | 8 +- > config.mk | 32 ++++ > doc/README.TPL | 93 +++++++++++ > drivers/mtd/nand/Makefile | 8 + > drivers/mtd/nand/fsl_elbc_tpl.c | 168 > ++++++++++++++++++++ > drivers/serial/serial.c | 2 +- > include/bootstage.h | 3 +- > include/configs/P1022DS.h | 75 +++++++-- > tpl/Makefile | 161 > +++++++++++++++++++ > 21 files changed, 824 insertions(+), 83 deletions(-) > create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds > create mode 100644 board/freescale/p1022ds/tpl.c > create mode 100644 doc/README.TPL > create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c > create mode 100644 tpl/Makefile > > diff --git a/Makefile b/Makefile > index ef154aa..65849d1 100644 > --- a/Makefile > +++ b/Makefile > @@ -118,10 +118,11 @@ endif # ifneq ($(BUILD_DIR),) > > OBJTREE := $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR)) > SPLTREE := $(OBJTREE)/spl > +TPLTREE := $(OBJTREE)/tpl > SRCTREE := $(CURDIR) > TOPDIR := $(SRCTREE) > LNDIR := $(OBJTREE) > -export TOPDIR SRCTREE OBJTREE SPLTREE > +export TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE > > MKCONFIG := $(SRCTREE)/mkconfig > export MKCONFIG > @@ -412,9 +413,14 @@ ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin > $(obj)System.map > ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin > ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin > ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin > +ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin > ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin > ifneq ($(CONFIG_SPL_TARGET),) > ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET)) > +else > +ifneq ($(CONFIG_TPL_TARGET),) > +ALL-$(CONFIG_TPL) += $(obj)$(subst ",,$(CONFIG_TPL_TARGET)) > +endif > endif > > # enable combined SPL/u-boot/dtb rules for tegra > @@ -498,6 +504,18 @@ $(obj)u-boot-with-spl.bin: > $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin > cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@ > rm $(obj)spl/u-boot-spl-pad.bin > > +$(obj)u-boot-with-tpl.bin: $(obj)spl/u-boot-spl.bin > $(obj)tpl/u-boot-tpl.bin \ > + $(obj)u-boot.bin > + $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SPL_PAD_TO) \ > + -I binary -O binary \ > + $(obj)spl/u-boot-spl.bin > $(obj)spl/u-boot-spl-pad.bin > + $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_TPL_PAD_TO) \ > + -I binary -O binary \ > + $(obj)tpl/u-boot-tpl.bin > $(obj)tpl/u-boot-tpl-pad.bin > + cat $(obj)spl/u-boot-spl-pad.bin > $(obj)tpl/u-boot-tpl-pad.bin \ > + $(obj)u-boot.bin > $@ > + rm $(obj)spl/u-boot-spl-pad.bin > $(obj)tpl/u-boot-tpl-pad.bin > + > $(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin > $(MAKE) -C $(SRCTREE)/arch/arm/imx-common \ > $(OBJTREE)/u-boot-with-spl.imx > @@ -622,6 +640,9 @@ $(obj)u-boot-nand.bin: nand_spl > $(obj)u-boot.bin > $(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend > $(MAKE) -C spl all > > +$(obj)tpl/u-boot-tpl.bin: $(SUBDIR_TOOLS) depend > + $(MAKE) -C tpl all > + > updater: > $(MAKE) -C tools/updater all > > @@ -870,6 +891,8 @@ clobber: tidy > @rm -f > $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map} > @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map} > @rm -f $(obj)spl/u-boot-spl.lds > + @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map} > + @rm -f $(obj)tpl/u-boot-tpl.lds > @rm -f $(obj)MLO MLO.byteswap > @rm -f $(obj)SPL > @rm -f $(obj)tools/xway-swap-bytes > diff --git a/README b/README > index 7add6d4..04f9aa5 100644 > --- a/README > +++ b/README > @@ -2985,9 +2985,10 @@ FIT uImage format: > Set for the SPL on PPC mpc8xxx targets, support for > arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary. > > - CONFIG_SPL_COMMON_INIT_DDR > + CONFIG_COMMON_INIT_DDR > Set for common ddr init with serial presence detect in > - SPL binary. > + SPL binary or TPL binary. > + > CONFIG_SYS_NAND_5_ADDR_CYCLE, > CONFIG_SYS_NAND_PAGE_COUNT, > CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE, > CONFIG_SYS_NAND_BLOCK_SIZE, > CONFIG_SYS_NAND_BAD_BLOCK_POS, > @@ -3058,6 +3059,56 @@ FIT uImage format: > option to re-enable it. This will affect the output of > the > bootm command when booting a FIT image. > > +- TPL framework > + CONFIG_TPL > + Enable building of TPL globally. > + > + CONFIG_TPL_LDSCRIPT > + LDSCRIPT for linking the TPL binary. > + > + CONFIG_TPL_MAX_SIZE > + Maximum size of the TPL image (text, data, rodata, and > + linker lists sections), BSS excluded. > + When defined, the linker checks that the actual size > does > + not exceed it. > + > + CONFIG_SPL_TEXT_BASE > + TEXT_BASE for linking the TPL binary. > + > + CONFIG_TPL_LIBCOMMON_SUPPORT > + Support for common/libcommon.o in TPL binary > + > + CONFIG_TPL_LIBDISK_SUPPORT > + Support for disk/libdisk.o in TPL binary > + > + CONFIG_TPL_I2C_SUPPORT > + Support for drivers/i2c/libi2c.o in TPL binary > + > + CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT > + Set for the TPL on PPC mpc8xxx targets, support for > + arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary. > + > + CONFIG_TPL_SERIAL_SUPPORT > + Support for drivers/serial/libserial.o in TPL binary > + > + CONFIG_TPL_LIBGENERIC_SUPPORT > + Support for lib/libgeneric.o in TPL binary > + > + CONFIG_TPL_ENV_SUPPORT > + Support for the environment operating in TPL binary > + > + CONFIG_TPL_PAD_TO > + Image offset to which the TPL should be padded before > appending > + the TPL payload. By default, this is defined as > + CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is > undefined. > + CONFIG_TPL_PAD_TO must be either 0, meaning to append > the TPL > + payload without any padding, or >= CONFIG_TPL_MAX_SIZE. > + > + CONFIG_TPL_TARGET > + Final target image containing SPL and payload. Some > TPLs > + use an arch-specific makefile fragment instead, for > + example if more than one image needs to be produced. Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's generalize it into multiple U-Boot phases, each of which has its own autoconf.mk. The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared under different ifdefs. > diff --git a/arch/powerpc/cpu/mpc85xx/spl_minimal.c > b/arch/powerpc/cpu/mpc85xx/spl_minimal.c > index c6b9cd0..a2d9417 100644 > --- a/arch/powerpc/cpu/mpc85xx/spl_minimal.c > +++ b/arch/powerpc/cpu/mpc85xx/spl_minimal.c > @@ -30,8 +30,19 @@ DECLARE_GLOBAL_DATA_PTR; > > void cpu_init_f(void) > { > +#if defined(CONFIG_SYS_NAND_BR_PRELIM) && > defined(CONFIG_SYS_NAND_OR_PRELIM) > + set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM); > + set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM); > +#endif > +#if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM) > + set_lbc_or(2, CONFIG_SYS_OR2_PRELIM); > + set_lbc_br(2, CONFIG_SYS_BR2_PRELIM); > +#endif > + > #ifdef CONFIG_SYS_INIT_L2_ADDR > ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR; > + char *l2srbar; > + int i; > > out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR); > > @@ -42,6 +53,11 @@ void cpu_init_f(void) > /* set L2E=1 & L2SRAM=001 */ > out_be32(&l2cache->l2ctl, > (MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE)); > + > + /* Initialize L2 SRAM to zero */ > + l2srbar = (char *)CONFIG_SYS_INIT_L2_ADDR; > + for (i = 0; i < CONFIG_SYS_L2_SIZE; i++) > + l2srbar[i] = 0; Please do not commingle TPL infrastructure with 85xx or p1022ds implementation details. They should be separate patches. > diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds > b/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds > new file mode 100644 > index 0000000..344c325 > --- /dev/null > +++ b/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds What is different about this compared to every other 85xx linker script that justifies a separate copy? > +Estimating stack usage > +---------------------- > + > +With gcc 4.6 (and later) and the use of GNU cflow it is possible to > estimate > +stack usage at various points in run sequence of TPL. The > -fstack-usage option > +to gcc will produce '.su' files (such as > arch/arm/cpu/armv7/syslib.su) that > +will give stack usage information and cflow can construct program > flow. > + > +Must have gcc 4.6 or later, which supports -fstack-usage > + > +1) Build normally > +2) Perform the following shell command to generate a list of C files > used in > +TPL: > +$ find tpl -name '*.su' | sed -e 's:^tpl/::' -e 's:[.]su$:.c:' > > used-tpl.list > +3) Execute cflow: > +$ cflow --main=board_init_r `cat used-tpl.list` 2>&1 | $PAGER > + > +cflow will spit out a number of warnings as it does not parse > +the config files and picks functions based on #ifdef. Parsing the > '.i' > +files instead introduces another set of headaches. These warnings > are > +not usually important to understanding the flow, however. Really, you even duplicated this stuff for TPL? > diff --git a/drivers/mtd/nand/fsl_elbc_tpl.c > b/drivers/mtd/nand/fsl_elbc_tpl.c > new file mode 100644 > index 0000000..09868c4 > --- /dev/null > +++ b/drivers/mtd/nand/fsl_elbc_tpl.c ...and here you duplicated an entire driver! NACK -Scott