Voipac PXA270 OneNAND SPL
Subsystems (2)
cover Voipac PXA270 OneNAND SPL
Convert OneNAND IPL to SPL framework and make Voipac PXA270 board use it.
This series triggers some checkpatch warnings:
* Warnings in start.S due to length of line. Since I reused the start.S from other CPU (arm1136), I'd rather investigate if it'd be possible to create one common start.S for armv5?
* Warnings due to used externs. pxa_dram_init() will be cleaned up in a subsequent series in all boards.
Marek Vasut (4):
PXA: Drop Voipac PXA270 OneNAND IPL
PXA: Rework start.S to be closer to other ARMs
OneNAND: Add simple OneNAND SPL
PXA: Adapt Voipac PXA270 to OneNAND SPL
arch/arm/cpu/pxa/cpu.c | 16 + arch/arm/cpu/pxa/start.S | 382 +++++++++----------------- board/vpac270/Makefile | 6 + board/vpac270/onenand.c | 136 +++++++++ board/vpac270/vpac270.c | 2 + drivers/mtd/onenand/Makefile | 4 + drivers/mtd/onenand/onenand_spl.c | 130 +++++++++ include/configs/vpac270.h | 25 ++- include/onenand_uboot.h | 18 ++ onenand_ipl/board/vpac270/Makefile | 79 ------ onenand_ipl/board/vpac270/config.mk | 1 - onenand_ipl/board/vpac270/u-boot.onenand.lds | 51 ---- onenand_ipl/board/vpac270/vpac270.c | 42 --- spl/Makefile | 1 + 14 files changed, 469 insertions(+), 424 deletions(-) create mode 100644 board/vpac270/onenand.c create mode 100644 drivers/mtd/onenand/onenand_spl.c delete mode 100644 onenand_ipl/board/vpac270/Makefile delete mode 100644 onenand_ipl/board/vpac270/config.mk delete mode 100644 onenand_ipl/board/vpac270/u-boot.onenand.lds delete mode 100644 onenand_ipl/board/vpac270/vpac270.c
Signature · 1 line
1.7.6.3
PATCH 1/4 PXA: Drop Voipac PXA270 OneNAND IPL
This OneNAND IPL will be replaced by OneNAND SPL.
--- onenand_ipl/board/vpac270/Makefile | 79 -------------------------- onenand_ipl/board/vpac270/config.mk | 1 - onenand_ipl/board/vpac270/u-boot.onenand.lds | 51 ----------------- onenand_ipl/board/vpac270/vpac270.c | 42 -------------- 4 files changed, 0 insertions(+), 173 deletions(-) delete mode 100644 onenand_ipl/board/vpac270/Makefile delete mode 100644 onenand_ipl/board/vpac270/config.mk delete mode 100644 onenand_ipl/board/vpac270/u-boot.onenand.lds delete mode 100644 onenand_ipl/board/vpac270/vpac270.c
onenand_ipl/board/vpac270/Makefile deleted +0 -79
@@ -1,79 +0,0 @@ - -include $(TOPDIR)/config.mk -include $(TOPDIR)/board/$(BOARDDIR)/config.mk - -LDSCRIPT= $(TOPDIR)/onenand_ipl/board/$(BOARDDIR)/u-boot.onenand.lds -LDFLAGS = -Bstatic -T $(onenandobj)u-boot.lds -Ttext $(CONFIG_SYS_TEXT_BASE) $(PLATFORM_LDFLAGS) -AFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_ONENAND_IPL -CFLAGS += -DCONFIG_SPL_BUILD -DCONFIG_ONENAND_IPL -OBJCFLAGS += --gap-fill=0x00 - -SOBJS += start.o -COBJS := vpac270.o -COBJS += onenand_read.o -COBJS += onenand_boot.o - -SRCS := $(addprefix $(obj),$(SOBJS:.o=.S) $(COBJS:.o=.c)) -OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) -__OBJS := $(SOBJS) $(COBJS) -LNDIR := $(OBJTREE)/onenand_ipl/board/$(BOARDDIR) - -onenandobj := $(OBJTREE)/onenand_ipl/ - -ALL = $(onenandobj)onenand-ipl $(onenandobj)onenand-ipl.bin $(onenandobj)onenand-ipl-2k.bin - -all: $(obj).depend $(ALL) - -$(onenandobj)onenand-ipl-2k.bin: $(onenandobj)onenand-ipl - $(OBJCOPY) ${OBJCFLAGS} --pad-to=0x0800 -O binary $< $@ - -$(onenandobj)onenand-ipl.bin: $(onenandobj)onenand-ipl - $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@ - -$(onenandobj)onenand-ipl: $(OBJS) $(onenandobj)u-boot.lds - cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \ - -Map [email protected] -o $@ - -$(onenandobj)u-boot.lds: $(LDSCRIPT) - $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ - -# create symbolic links from common files - -# from cpu directory -$(obj)start.S: - @rm -f $@ - ln -s $(SRCTREE)/$(CPUDIR)/start.S $@ - -# from onenand_ipl directory -$(obj)onenand_ipl.h: - @rm -f $@ - ln -s $(SRCTREE)/onenand_ipl/onenand_ipl.h $@ - -$(obj)onenand_boot.c: $(obj)onenand_ipl.h - @rm -f $@ - ln -s $(SRCTREE)/onenand_ipl/onenand_boot.c $@ - -$(obj)onenand_read.c: $(obj)onenand_ipl.h - @rm -f $@ - ln -s $(SRCTREE)/onenand_ipl/onenand_read.c $@ - -ifneq ($(OBJTREE), $(SRCTREE)) -$(obj)vpac270.c: - @rm -f $@ - ln -s $(SRCTREE)/onenand_ipl/board/$(BOARDDIR)/vpac270.c $@ -endif - -######################################################################### - -$(obj)%.o: $(obj)%.S - $(CC) $(AFLAGS) -c -o $@ $< - -$(obj)%.o: $(obj)$.c - $(CC) $(CFLAGS) -c -o $@ $< - -# defines $(obj).depend target -include $(SRCTREE)/rules.mk - -sinclude $(obj).depend - -#########################################################################
onenand_ipl/board/vpac270/config.mk deleted +0 -1
@@ -1 +0,0 @@ -CONFIG_SYS_TEXT_BASE = 0x5c03fc00
onenand_ipl/board/vpac270/u-boot.onenand.lds deleted +0 -51
51 lines not on this page · raw message
onenand_ipl/board/vpac270/vpac270.c deleted +0 -42
42 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH 2/4 PXA: Rework start.S to be closer to other ARMs
In reply to Marek VasutThe start.S on PXA was very obscure. This reworks it back to be close to arm1136 start.S and others.
--- arch/arm/cpu/pxa/cpu.c | 16 ++ arch/arm/cpu/pxa/start.S | 382 ++++++++++++++++----------------------------- 2 files changed, 152 insertions(+), 246 deletions(-)
arch/arm/cpu/pxa/cpu.c +16 -0
@@ -328,3 +328,19 @@ void i2c_clk_enable(void)writel (readl (CKEN ) |CKEN14_I2C ,CKEN );#endif } + +void reset_cpu (ulong ignored) __attribute__((noreturn)); + +void reset_cpu (ulong ignored) +{ +uint32_t tmp; + +setbits_le32 (OWER ,OWER_WME ); + + tmp =readl (OSCR ); + tmp +=0x1000 ; +writel (tmp,OSMR3 ); + +for (;;) + ; +}
arch/arm/cpu/pxa/start.S +136 -246
546 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH v2 2/4 PXA: Rework start.S to be closer to other ARMs
The start.S on PXA was very obscure. This reworks it back to be close to arm1136 start.S and others.
--- arch/arm/cpu/pxa/cpu.c | 16 ++ arch/arm/cpu/pxa/start.S | 384 ++++++++++++++++----------------------------- 2 files changed, 153 insertions(+), 247 deletions(-)
V2: Don't compile in relocation support if building SPL
arch/arm/cpu/pxa/cpu.c +16 -0
@@ -328,3 +328,19 @@ void i2c_clk_enable(void)writel (readl (CKEN ) |CKEN14_I2C ,CKEN );#endif } + +void reset_cpu (ulong ignored) __attribute__((noreturn)); + +void reset_cpu (ulong ignored) +{ +uint32_t tmp; + +setbits_le32 (OWER ,OWER_WME ); + + tmp =readl (OSCR ); + tmp +=0x1000 ; +writel (tmp,OSMR3 ); + +for (;;) + ; +}
arch/arm/cpu/pxa/start.S +137 -247
552 lines not on this page · raw message
Signature · 1 line
1.7.6.3
PATCH 2/4 PXA: Rework start.S to be closer to other ARMs
In reply to Marek VasutAm 31.10.2011 14:23, schrieb Marek Vasut:
Quoted 9 lines
The
start.Son PXA was very obscure. This reworks it back to be close to arm1136start.Sand others.Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>--- arch/arm/cpu/pxa/cpu.c | 16 ++ arch/arm/cpu/pxa/start.S | 382 ++++++++++++++++----------------------------- 2 files changed, 152 insertions(+), 246 deletions(-)
Hi Marek,
if I understand your code right, you change the initial memory from cache to SRAM,
but this is not available on the pxa255. Do you plan to drop the pxa255 support?
Do you plan to update the pxa boards config?
I assume that I can drop my patch to fix the relocation on pxa.
Regards,
Stefan
PATCH 2/4 PXA: Rework start.S to be closer to other ARMs
Quoted 13 lines
Am 31.10.2011 14:23, schrieb Marek Vasut:
Quoted 11 lines
The
start.Son PXA was very obscure. This reworks it back to be close to arm1136start.Sand others.Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
arch/arm/cpu/pxa/cpu.c | 16 ++ arch/arm/cpu/pxa/start.S | 382++++++++++++++++----------------------------- 2 files changed, 152 insertions(+), 246 deletions(-)
Quoted 6 lines
Hi Marek,
if I understand your code right, you change the initial memory from cache to SRAM,
but this is not available on the pxa255. Do you plan to drop the pxa255 support?
No, you're right. I'll probably have to add a workaround for this issue for pxa25x and 26x. Damn.
Quoted 4 lines
Do you plan to update the pxa boards config?
I assume that I can drop my patch to fix the relocation on pxa.
Do you have any pxa250 board and are you willing to help with this patch?
Quoted 3 lines
Regards,
Stefan
PATCH 2/4 PXA: Rework start.S to be closer to other ARMs
Am 02.11.2011 11:25, schrieb Marek Vasut:
Quoted 18 lines
Quoted 12 lines
Am 31.10.2011 14:23, schrieb Marek Vasut:
Quoted 11 lines
The
start.Son PXA was very obscure. This reworks it back to be close to arm1136start.Sand others.Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
arch/arm/cpu/pxa/cpu.c | 16 ++ arch/arm/cpu/pxa/start.S | 382++++++++++++++++----------------------------- 2 files changed, 152 insertions(+), 246 deletions(-)
Quoted 6 lines
Hi Marek,
if I understand your code right, you change the initial memory from cache to SRAM,
but this is not available on the pxa255. Do you plan to drop the pxa255 support?
Quoted 6 lines
No, you're right. I'll probably have to add a workaround for this issue for pxa25x and 26x. Damn.
Quoted 3 lines
Do you plan to update the pxa boards config?
I assume that I can drop my patch to fix the relocation on pxa.
Do you have any pxa250 board and are you willing to help with this patch?
I have only my customised pxa270 board.
PATCH 3/4 OneNAND: Add simple OneNAND SPL
In reply to Marek VasutThis introduces small OneNAND loader, fitting into 1kB of space (smallest possible OneNAND RAM size). Some devices equipped with such crappy chips will use this.
--- drivers/mtd/onenand/Makefile | 4 + drivers/mtd/onenand/onenand_spl.c | 130 +++++++++++++++++++++++++++++++++++++ include/onenand_uboot.h | 18 +++++ spl/Makefile | 1 + 4 files changed, 153 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/onenand/onenand_spl.c
drivers/mtd/onenand/Makefile +4 -0
@@ -25,8 +25,12 @@ include $(TOPDIR)/config.mk LIB := $(obj)libonenand.o +ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o +else +COBJS-y := onenand_spl.o +endif COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mtd/onenand/onenand_spl.c new file +130 -0
130 lines not on this page · raw message
include/onenand_uboot.h +18 -0
@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;
@@ -52,4 +54,20 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +#define ONENAND_PAGES_PER_BLOCK 64 + +struct spl_onenand_data { +uint32_t pagesize; +uint32_t erasesize; +}; + +void spl_onenand_get_geometry (struct spl_onenand_data *data); +int spl_onenand_read_page (uint32_t block,uint32_t page, +uint8_t *buf,int pagesize); +int spl_onenand_read_block (uint32_t block,uint8_t *buf,uint32_t *read); + +#endif +#endif /* __UBOOT_ONENAND_H */
spl/Makefile +1 -0
@@ -54,6 +54,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o ifeq ($(SOC),omap3)
Signature · 1 line
1.7.6.3
PATCH 3/4 OneNAND: Add simple OneNAND SPL
drivers/mtd/onenand/onenand_spl.c line 40
Quoted 9 lines · Marek Vasut
drivers/mtd/onenand/onenand_spl.c new file +9
-0+inline uint16_t onenand_readw (uint32_t addr) +{ +return readw (CONFIG_SYS_ONENAND_BASE + addr); +} + +inline void onenand_writew (uint16_t value,uint32_t addr) +{ +writew (value,CONFIG_SYS_ONENAND_BASE + addr); +}
static
drivers/mtd/onenand/onenand_spl.c line 46
Quoted 4 lines
drivers/mtd/onenand/onenand_spl.c new file +4
-0+#define onenand_block_address (block) (block) +#define onenand_sector_address (page) (page << 2) +#define onenand_buffer_address () ((1 << 3) << 8) +#define onenand_bufferram_address (block) (0)
Space rather than tab after #define
Quoted 18 lines
drivers/mtd/onenand/onenand_spl.c new file +18
-0+void spl_onenand_get_geometry (struct spl_onenand_data *data) +{ +uint32_t tmp; +uint32_t dev_id, density; + +/* Default geometry -- 2048b page, 128k erase block. */ + data->pagesize =2048 ; + data->erasesize =0x20000 ; + + tmp =onenand_readw (ONENAND_REG_TECHNOLOGY ); +if (tmp) + goto dev_4k; + + dev_id =onenand_readw (ONENAND_REG_DEVICE_ID ); + density = dev_id >>ONENAND_DEVICE_DENSITY_SHIFT ; + density &=ONENAND_DEVICE_DENSITY_MASK ; + +if (density < ONENAND_DEVICE_DENSITY_4Gb)
drivers/mtd/onenand/onenand_spl.c line 75
Quoted 10 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+return ; + +if (dev_id &ONENAND_DEVICE_IS_DDP ) +return ; + +/* 4k device geometry -- 4096b page, 256k erase block. */ +dev_4k: + data->pagesize =4096 ; + data->erasesize =0x40000 ; +}
This seems like a gratuitous use of goto...
Quoted 4 lines
drivers/mtd/onenand/onenand_spl.c new file +4
-0+int spl_onenand_read_block (uint32_t block,uint8_t *buf,uint32_t *read) +{ +struct spl_onenand_data data; +uint32_t page;
drivers/mtd/onenand/onenand_spl.c line 125
Quoted 10 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+int ret; + +spl_onenand_get_geometry (&data); + +for (page =0 ; page <ONENAND_PAGES_PER_BLOCK ; page++) { + ret =spl_onenand_read_page (block, page, buf, data.pagesize); +if (ret) +return ret; + buf += data.pagesize; + }
Shouldn't this do bad block skipping rather than error on the first bad block it sees? The current onenand IPL does this.
drivers/mtd/onenand/onenand_spl.c line 127
Quoted 1 line
drivers/mtd/onenand/onenand_spl.c new file +1
-0+ *read = ((block *ONENAND_PAGES_PER_BLOCK ) + page) * data.pagesize;
We only read one block here, but we return the byte address of the next block? A little odd, and if it's really what's intended, needs to be documented.
Quoted 22 lines
include/onenand_uboot.h +7
-0@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;@@ -52,4 +54,20 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +#define ONENAND_PAGES_PER_BLOCK 64 + +struct spl_onenand_data {
include/onenand_uboot.h extern int flexonenand_set_boundary(struct mtd_info *mtd, int die, · line 71
Quoted 10 lines
include/onenand_uboot.h +10
-0+uint32_t pagesize; + uint32_t erasesize; +}; + +void spl_onenand_get_geometry (struct spl_onenand_data *data); +int spl_onenand_read_page (uint32_t block,uint32_t page, +uint8_t *buf,int pagesize); +int spl_onenand_read_block (uint32_t block,uint8_t *buf,uint32_t *read); + +#endif
Do these really need to be #ifdeffed?
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
In reply to Marek VasutThis introduces small OneNAND loader, fitting into 1kB of space (smallest possible OneNAND RAM size). Some devices equipped with such crappy chips will use this.
--- drivers/mtd/onenand/Makefile | 4 + drivers/mtd/onenand/onenand_spl.c | 151 +++++++++++++++++++++++++++++++++++++ include/onenand_uboot.h | 8 ++ spl/Makefile | 1 + 4 files changed, 164 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/onenand/onenand_spl.c
V2: Introduce spl_onenand_load_image() to load data from OneNAND in SPL
drivers/mtd/onenand/Makefile +4 -0
@@ -25,8 +25,12 @@ include $(TOPDIR)/config.mk LIB := $(obj)libonenand.o +ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o +else +COBJS-y := onenand_spl.o +endif COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mtd/onenand/onenand_spl.c new file +151 -0
151 lines not on this page · raw message
include/onenand_uboot.h +8 -0
@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;
@@ -52,4 +54,10 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +int spl_onenand_load_image (uint32_t dst,uint32_t offset,uint32_t len); + +#endif +#endif /* __UBOOT_ONENAND_H */
spl/Makefile +1 -0
@@ -54,6 +54,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o ifeq ($(SOC),omap3)
Signature · 1 line
1.7.6.3
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 18 lines · Marek Vasut
drivers/mtd/onenand/onenand_spl.c new file +18
-0+static void spl_onenand_get_geometry (struct spl_onenand_data *data) +{ +uint32_t tmp; +uint32_t dev_id, density; + +/* Default geometry -- 2048b page, 128k erase block. */ + data->pagesize =2048 ; + data->erasesize =0x20000 ; + + tmp =onenand_readw (ONENAND_REG_TECHNOLOGY ); +if (tmp) + goto dev_4k; + + dev_id =onenand_readw (ONENAND_REG_DEVICE_ID ); + density = dev_id >>ONENAND_DEVICE_DENSITY_SHIFT ; + density &=ONENAND_DEVICE_DENSITY_MASK ; + +if (density < ONENAND_DEVICE_DENSITY_4Gb)
drivers/mtd/onenand/onenand_spl.c line 80
Quoted 10 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+return ; + +if (dev_id &ONENAND_DEVICE_IS_DDP ) +return ; + +/* 4k device geometry -- 4096b page, 256k erase block. */ +dev_4k: + data->pagesize =4096 ; + data->erasesize =0x40000 ; +}
Drop the goto and "tmp" variable, just do:
if (!onenand_readw(ONENAND_REG_TECHNOLOGY)) {
dev_id = onenand_readw(ONENAND_REG_DEVICE_ID);
density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT;
density &= ONENAND_DEVICE_DENSITY_MASK;
if (density < ONENAND_DEVICE_DENSITY_4Gb)
return;
if (dev_id & ONENAND_DEVICE_IS_DDP)
return;
}Quoted 1 line
+int
spl_onenand_load_image(uint32_t dst, uint32_t offset, uint32_t len)
Please use the same name and arguments as nand_spl_load_image() in nand_spl_simple.c.
Review
Quoted 2 lines
(quoted diff) +2
-0+{ + uint32_t *addr = (uint32_t *)dst;
Why not pass it in as a pointer in the first place? I know U-Boot is unlkely to support being built as 64-bit any time soon, but why introduce gratuitous 64-bit-uncleanliness?
Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c new file +8
-0+struct spl_onenand_data data; +uint32_t total_pages; +uint32_t block; +uint32_t page, rpage; +int ret, err =0 ; + +spl_onenand_get_geometry (&data); +
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 10 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 ); + }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }
What's wrong with DIV_ROUND_UP? It should produce smaller code than what you've done here...
drivers/mtd/onenand/onenand_spl.c line 148
Quoted 10 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+for (; page <= total_pages; page++) { + block = page /ONENAND_PAGES_PER_BLOCK ; + rpage = page & (ONENAND_PAGES_PER_BLOCK -1 ); + ret =spl_onenand_read_page (block, rpage, addr, data.pagesize); +if (ret) { + total_pages++; + err |=1 ; + }else + addr += data.pagesize /4 ; + }
As discussed, please retain the existing block-skipping semantics. And if you do skip a block, that's not an error to be propagated upward (as opposed to something like an uncorrectable ECC error).
If one side of an if statement requires braces, both sides should have them.
include/onenand_uboot.h line 20
Quoted 10 lines
include/onenand_uboot.h +2
-0@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +
Please use a space rather than a tab after #define, #ifndef, etc.
include/onenand_uboot.h extern int flexonenand_set_boundary(struct mtd_info *mtd, int die, · line 61
Quoted 12 lines
include/onenand_uboot.h +5
-0/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;@@ -52,4 +54,10 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +int spl_onenand_load_image (uint32_t dst,uint32_t offset,uint32_t len); + +#endif
Why does this need to be ifdeffed at all? We normally don't ifdef header declarations.
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{
[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );
Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
Quoted 52 lines
drivers/mtd/onenand/onenand_spl.c line 148
Quoted 11 lines
drivers/mtd/onenand/onenand_spl.c new file +10
-0+for (; page <= total_pages; page++) { + block = page /ONENAND_PAGES_PER_BLOCK ; + rpage = page & (ONENAND_PAGES_PER_BLOCK -1 ); + ret =spl_onenand_read_page (block, rpage, addr, data.pagesize); +if (ret) { + total_pages++; + err |=1 ; + }else + addr += data.pagesize /4 ; + }As discussed, please retain the existing block-skipping semantics. And if you do skip a block, that's not an error to be propagated upward (as opposed to something like an uncorrectable ECC error).
If one side of an if statement requires braces, both sides should have them.
include/onenand_uboot.h line 20
Quoted 10 lines
include/onenand_uboot.h +2
-0@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +Please use a space rather than a tab after #define, #ifndef, etc.
Quoted 5 lines
include/onenand_uboot.h +0
-0/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;include/onenand_uboot.h extern int flexonenand_set_boundary(struct mtd_info · line 61
Quoted 10 lines
include/onenand_uboot.h +5
-0@@ -52,4 +54,10 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die, extern void s3c64xx_onenand_init(struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +int spl_onenand_load_image (uint32_t dst,uint32_t offset,uint32_t len); + +#endif Why does this need to be ifdeffed at all? We normally don't ifdef header declarations.
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Hi all,
Marek, did you see the onenand_ipl/onenand_read.c at u-boot? It's already implemented and used for OneNAND boot.
How do you think migrate this file into generic SPL framework?
Thank you,
Kyungmin Park
-----Original Message-----
From: Marek Vasut [mailto:marek.vasut at gmail.com]
Sent: Thursday, November 03, 2011 9:16 AM
To: Scott Wood
Cc: u-boot at lists.denx.de; Albert ARIBAUD; Kyungmin Park
Subject: Re: [PATCH 3/4 V2] OneNAND: Add simple OneNAND SPL
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{
[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );
Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +4
-0+for (; page <= total_pages; page++) { + block = page /ONENAND_PAGES_PER_BLOCK ; + rpage = page & (ONENAND_PAGES_PER_BLOCK -1 ); + ret = spl_onenand_read_page(block, rpage, addr,
data.pagesize);
Quoted 34 lines
drivers/mtd/onenand/onenand_spl.c line 148
Quoted 6 lines
drivers/mtd/onenand/onenand_spl.c new file +6
-0+if (ret) { + total_pages++; + err |=1 ; + }else + addr += data.pagesize /4 ; + }As discussed, please retain the existing block-skipping semantics. And if you do skip a block, that's not an error to be propagated upward (as opposed to something like an uncorrectable ECC error).
If one side of an if statement requires braces, both sides should have them.
include/onenand_uboot.h line 20
Quoted 10 lines
include/onenand_uboot.h +2
-0@@ -16,6 +16,8 @@#include <linux/types.h> +#ifndef CONFIG_SPL_BUILD +Please use a space rather than a tab after #define, #ifndef, etc.
Quoted 7 lines
include/onenand_uboot.h +0
-0/* Forward declarations */ struct mtd_info ;struct mtd_oob_ops ;@@ -52,4 +54,10 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,
Quoted 6 lines
include/onenand_uboot.h extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,
Quoted 6 lines
include/onenand_uboot.h +3
-0extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +#else + +int spl_onenand_load_image(uint32_t dst, uint32_t offset, uint32_t
len);
Quoted 7 lines
include/onenand_uboot.h
Quoted 2 lines
include/onenand_uboot.h +2
-0+ +#endif Why does this need to be ifdeffed at all? We normally don't ifdef header declarations.
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 6 lines
Hi all,
Marek, did you see the
onenand_ipl/onenand_read.cat u-boot? It's already implemented and used for OneNAND boot.How do you think migrate this file into generic SPL framework?
That's basically what I did, with a little polishing.
Quoted 3 lines
Thank you,
Kyungmin Park
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
In reply to Marek VasutQuoted 19 lines · Marek Vasut
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...
Quoted 1 line
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
It shouldn't do that if the divisor is a constant power of 2. The compiler will turn it into a shift, just like with the other divides in the above code fragment.
You can't use DIV_ROUND_UP directly on data.pagesize, but you can use it in each branch of the if statement instead of that awkward and slightly more expensive !!(len & 4095) construct.
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 24 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...Quoted 2 lines
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
Quoted 7 lines
It shouldn't do that if the divisor is a constant power of 2. The compiler will turn it into a shift, just like with the other divides in the above code fragment.
You can't use
DIV_ROUND_UPdirectly on data.pagesize, but you can use it in each branch of the if statement instead of that awkward and slightly more expensive !!(len & 4095) construct.
Expensive in what way? Either way, I don't think this matters that much.
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 28 lines · Marek Vasut
Quoted 28 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...Quoted 2 lines
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
It shouldn't do that if the divisor is a constant power of 2. The compiler will turn it into a shift, just like with the other divides in the above code fragment.
Quoted 5 lines
Quoted 3 lines
You can't use
DIV_ROUND_UPdirectly on data.pagesize, but you can use it in each branch of the if statement instead of that awkward and slightly more expensive !!(len & 4095) construct.Expensive in what way?
Compare the resulting asm code. You're replacing this:
a = (b + 4095) >> 12;
with this:
a = b >> 12; if (b & 4095) a++;
Quoted 1 line
Either way, I don't think this matters that much.
This is code that has to fit in 1K -- why waste instructions by writing code in a way that is *less* readable?
-Scott
PATCH v2 3/4 OneNAND: Add simple OneNAND SPL
Quoted 41 lines · Marek Vasut
Quoted 28 lines
Quoted 28 lines · Marek Vasut
Quoted 20 lines
Quoted 3 lines · Marek Vasut
Quoted 2 lines
(quoted diff) +2
-0+static void spl_onenand_get_geometry(struct spl_onenand_data *data) +{[...]
Quoted 5 lines
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ +if (data.pagesize ==2048 ) { + total_pages = len /2048 ; + page = offset /2048 ; + total_pages += !!(len &2047 );Quoted 8 lines
drivers/mtd/onenand/onenand_spl.c line 137
Quoted 5 lines
drivers/mtd/onenand/onenand_spl.c new file +5
-0+ }else if (data.pagesize ==4096 ) { + total_pages = len /4096 ; + page = offset /4096 ; + total_pages += !!(len &4095 ); + }What's wrong with
DIV_ROUND_UP? It should produce smaller code than what you've done here...Quoted 2 lines
It pulls in aeabi_*div* functions, which won't fit into block 0 of Onenand.
It shouldn't do that if the divisor is a constant power of 2. The compiler will turn it into a shift, just like with the other divides in the above code fragment.
Quoted 5 lines
Quoted 3 lines
You can't use
DIV_ROUND_UPdirectly on data.pagesize, but you can use it in each branch of the if statement instead of that awkward and slightly more expensive !!(len & 4095) construct.Expensive in what way?
Compare the resulting asm code. You're replacing this:
a = (b + 4095) >> 12;with this:
Quoted 8 lines
a = b >> 12; if (b & 4095) a++;Quoted 1 line
Either way, I don't think this matters that much.
This is code that has to fit in 1K -- why waste instructions by writing code in a way that is *less* readable?
The size is the same (tested). I'll submit a patch with DIV_ROUND_UP, whatever.
Quoted 2 lines
-Scott
PATCH v3 3/4 OneNAND: Add simple OneNAND SPL
In reply to Marek VasutThis introduces small OneNAND loader, fitting into 1kB of space (smallest possible OneNAND RAM size). Some devices equipped with such crappy chips will use this.
--- drivers/mtd/onenand/Makefile | 4 + drivers/mtd/onenand/onenand_spl.c | 148 +++++++++++++++++++++++++++++++++++++ include/onenand_uboot.h | 3 + spl/Makefile | 1 + 4 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/onenand/onenand_spl.c
V2: Introduce spl_onenand_load_image() to load data from OneNAND in SPL
V3: Cleanup, align with nand_spl. Skip whole blocks.
drivers/mtd/onenand/Makefile +4 -0
@@ -25,8 +25,12 @@ include $(TOPDIR)/config.mk LIB := $(obj)libonenand.o +ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o +else +COBJS-y := onenand_spl.o +endif COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mtd/onenand/onenand_spl.c new file +148 -0
148 lines not on this page · raw message
include/onenand_uboot.h +3 -0
@@ -52,4 +52,7 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +/* SPL */ +void onenand_spl_load_image (uint32_t offs,uint32_t size,void *dst); +#endif /* __UBOOT_ONENAND_H */
spl/Makefile +1 -0
@@ -54,6 +54,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o ifeq ($(SOC),omap3)
Signature · 1 line
1.7.6.3
PATCH v4 3/4 OneNAND: Add simple OneNAND SPL
This introduces small OneNAND loader, fitting into 1kB of space (smallest possible OneNAND RAM size). Some devices equipped with such crappy chips will use this.
--- drivers/mtd/onenand/Makefile | 4 + drivers/mtd/onenand/onenand_spl.c | 146 +++++++++++++++++++++++++++++++++++++ include/onenand_uboot.h | 3 + spl/Makefile | 1 + 4 files changed, 154 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/onenand/onenand_spl.c
V2: Introduce spl_onenand_load_image() to load data from OneNAND in SPL
V3: Cleanup, align with nand_spl. Skip whole blocks.
V4: Use DIV_ROUND_UP.
drivers/mtd/onenand/Makefile +4 -0
@@ -25,8 +25,12 @@ include $(TOPDIR)/config.mk LIB := $(obj)libonenand.o +ifndef CONFIG_SPL_BUILD COBJS-$(CONFIG_CMD_ONENAND) := onenand_uboot.o onenand_base.o onenand_bbt.o COBJS-$(CONFIG_SAMSUNG_ONENAND) += samsung.o +else +COBJS-y := onenand_spl.o +endif COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mtd/onenand/onenand_spl.c new file +146 -0
146 lines not on this page · raw message
include/onenand_uboot.h +3 -0
@@ -52,4 +52,7 @@ extern int flexonenand_set_boundary(struct mtd_info *mtd, int die,extern void s3c64xx_onenand_init (struct mtd_info *);extern void s3c64xx_set_width_regs (struct onenand_chip *); +/* SPL */ +void onenand_spl_load_image (uint32_t offs,uint32_t size,void *dst); +#endif /* __UBOOT_ONENAND_H */
spl/Makefile +1 -0
@@ -54,6 +54,7 @@ LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o +LIBS-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/libonenand.o LIBS-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/libdma.o ifeq ($(SOC),omap3)
Signature · 1 line
1.7.6.3
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
In reply to Marek Vasut--- board/vpac270/Makefile | 6 ++ board/vpac270/onenand.c | 136 +++++++++++++++++++++++++++++++++++++++++++++ board/vpac270/vpac270.c | 2 + include/configs/vpac270.h | 25 +++++++-- 4 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 board/vpac270/onenand.c
board/vpac270/Makefile +6 -0
@@ -23,7 +23,13 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o +ifndef CONFIG_SPL_BUILD COBJS := vpac270.o +endif + +ifdef CONFIG_SPL_BUILD +COBJS := onenand.o +endif SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/vpac270/onenand.c new file +136 -0
136 lines not on this page · raw message
board/vpac270/vpac270.c +2 -0
@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }
include/configs/vpac270.h +20 -5
@@ -27,7 +27,17 @@*/ #define CONFIG_PXA27X 1/* Marvell PXA270 CPU */ #define CONFIG_VPAC270 1/* Voipac PXA270 board */ -#define CONFIG_SYS_TEXT_BASE 0x0 +#define CONFIG_SYS_TEXT_BASE 0xa0000000 + +#ifdef CONFIG_ONENAND +#define CONFIG_SPL +#define CONFIG_SPL_ONENAND_SUPPORT +#define CONFIG_SPL_ONENAND_LOAD_ADDR 0x2000 +#define CONFIG_SPL_ONENAND_LOAD_SIZE \ + (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR) +#define CONFIG_SPL_TEXT_BASE 0x5c000000 +#define CONFIG_SPL_LDSCRIPT "board/vpac270/u-boot-spl.lds" +#endif /* * Environment settings
@@ -46,12 +56,19 @@"bootm 0xa4000000; " \"fi; " \ "bootm 0x60000;" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "update_onenand=" \ + "onenand erase 0x0 0x80000 ; " \ + "onenand write 0xa0000000 0x0 0x80000" +#define CONFIG_BOOTARGS "console=tty0 console=ttyS0,115200"#define CONFIG_TIMESTAMP #define CONFIG_BOOTDELAY 2/* Autoboot delay */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_LZMA /* LZMA compression support */ +#define CONFIG_OF_LIBFDT /* * Serial Console Configuration
@@ -179,16 +196,14 @@#define CONFIG_SYS_MEMTEST_END 0xa0800000/* 4 ... 8 MB in DRAM */ #define CONFIG_SYS_LOAD_ADDR PHYS_SDRAM_1 -#define CONFIG_SYS_IPL_LOAD_ADDR (0x5c000000)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -#define CONFIG_SYS_INIT_SP_ADDR \ - (PHYS_SDRAM_1 + GENERATED_GBL_DATA_SIZE + 2048) +#define CONFIG_SYS_INIT_SP_ADDR 0x5c010000/* * NOR FLASH */ #define CONFIG_SYS_MONITOR_BASE 0x0 -#define CONFIG_SYS_MONITOR_LEN 0x40000 +#define CONFIG_SYS_MONITOR_LEN 0x80000#define CONFIG_ENV_ADDR \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)#define CONFIG_ENV_SIZE 0x4000
Signature · 1 line
1.7.6.3
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 15 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>--- board/vpac270/Makefile | 6 ++ board/vpac270/onenand.c | 136 +++++++++++++++++++++++++++++++++++++++++++++ board/vpac270/vpac270.c | 2 + include/configs/vpac270.h | 25 +++++++-- 4 files changed, 164 insertions(+), 5 deletions(-) create mode 100644 board/vpac270/onenand.cboard/vpac270/Makefile +0
-0
board/vpac270/Makefile include $(TOPDIR)/config.mk · line 32
Quoted 10 lines
board/vpac270/Makefile +6
-0@@ -23,7 +23,13 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o +ifndef CONFIG_SPL_BUILD COBJS := vpac270.o +endif + +ifdef CONFIG_SPL_BUILD +COBJS := onenand.o +endif
else?
Quoted 45 lines
board/vpac270/Makefile +0
-0SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))board/vpac270/onenand.c new file +37
-0@@ -0,0 +1,136 @@ +/* +* Voipac PXA270 OneNAND SPL +* +* Copyright (C) 2011 Marek Vasut <[email protected]> +* +* 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 <config.h> +#include <asm/io.h> +#include <onenand_uboot.h> + +extern void pxa_dram_init (void ); + +inline void spl_copy_self (void ) +{ +extern uint32_t _end; +struct spl_onenand_data data; +uint32_t page; +uint32_t total_bytes = (uint32_t )&_end -CONFIG_SPL_TEXT_BASE ;
board/vpac270/onenand.c line 47
Quoted 10 lines
board/vpac270/onenand.c new file +10
-0+uint32_t total_pages; +uint8_t *addr = (uint8_t *)CONFIG_SPL_TEXT_BASE ; +int ret; + +spl_onenand_get_geometry (&data); + +/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ + total_pages = total_bytes >>11 ; +if (data.pagesize ==4096 ) + total_pages >>=1 ;
total_bytes / 2048 and total_pages / 2 are more readable and should generate exactly the same code.
board/vpac270/onenand.c line 56
Quoted 8 lines
board/vpac270/onenand.c new file +8
-0+for (page =0 ; page <= total_pages; page++) { + ret =spl_onenand_read_page (0 , page, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}
You want to skip to the next block if spl_onenand_read_page() fails (which can occur after you've already read some of the block).
How much of this is board-specific?
Quoted 19 lines
board/vpac270/onenand.c new file +19
-0+inline void spl_copy_uboot (void ) +{ +uint8_t *addr = (uint8_t *)CONFIG_SYS_TEXT_BASE ; +struct spl_onenand_data data; +uint32_t total_pages; +uint32_t block; +uint32_t page, rpage; +int ret; + +spl_onenand_get_geometry (&data); + +/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ + total_pages =CONFIG_SPL_ONENAND_LOAD_SIZE >>11 ; + page =CONFIG_SPL_ONENAND_LOAD_ADDR >>11 ; +if (data.pagesize ==4096 ) { + total_pages >>=1 ; + page >>=1 ; + } +
board/vpac270/onenand.c line 86
Quoted 10 lines
board/vpac270/onenand.c new file +10
-0+for (; page <= total_pages; page++) { + block = page >>6 ; + rpage = page &0xff ; + ret =spl_onenand_read_page (block, rpage, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}
What is so different about this compared to spl_copy_self, that warrants such duplication? Can't you just pass in offset, length, and destination as parameters? Or just have the OneNAND SPL driver export nand_spl_load_image(), as any other NAND SPL driver would?
board/vpac270/onenand.c line 99
Quoted 12 lines
board/vpac270/onenand.c new file +12
-0+inline void board_init_f (unsigned long unused) +{ +uint32_t tmp; + + asmvolatile ("mov %0, pc" :"=r" (tmp)); + tmp >>=24 ; + +/* The code runs from OneNAND RAM, copy SPL to SRAM and execute it. */ +if (tmp ==0 ) { +spl_copy_self (); + asmvolatile ("mov pc, %0" : :"r" (CONFIG_SPL_TEXT_BASE )); + }
Is it not possible to use a simple memcpy for spl_copy_self()? If the CPU can run the code, you'd think it could read it.
board/vpac270/onenand.c line 115
Quoted 5 lines
board/vpac270/onenand.c new file +5
-0+inline void board_init_r (gd_t *id,ulong dest_addr) +{ +for (;;) + ; +}
This doesn't seem like a useful board_init_r(). If you don't need it, maybe make sure it's not called, and save yourself some bytes in the SPL. Likewise for the other stub functions, where practical.
Quoted 10 lines
board/vpac270/onenand.c new file +10
-0+inline int printf (const char *fmt, ...) +{ +return 0 ; +} + +inline void __coloured_LED_init (void ) {} +inline void __red_LED_on (void ) {} +void coloured_LED_init (void ) + __attribute__((weak,alias ("__coloured_LED_init" ))); +void red_LED_on (void )
board/vpac270/onenand.c line 136
Quoted 10 lines
board/vpac270/onenand.c new file +10
-0+ __attribute__((weak, alias("__red_LED_on"))); +void hang (void ) __attribute__ ((noreturn)); +void hang (void ) +{ +for (;;) + ; +} + +inline void icache_disable (void ) {} +inline void dcache_disable (void ) {}
Why are you specifying inline on just about everything, even functions that are not used in this file?
Why are you not specifying static on things that are not needed outside this file?
Quoted 5 lines
board/vpac270/vpac270.c +0
-0
board/vpac270/vpac270.c struct serial_device *default_serial_console(void) · line 64
Quoted 9 lines
board/vpac270/vpac270.c +2
-0@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }
Should this really be about whether OneNAND support is present, or should it be based on whether you're using the OneNAND SPL?
-Scott
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 4 lines · Marek Vasut
Quoted 3 lines
Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
[...]
Quoted 12 lines
board/vpac270/onenand.c line 56
Quoted 9 lines
board/vpac270/onenand.c new file +8
-0+for (page =0 ; page <= total_pages; page++) { + ret =spl_onenand_read_page (0 , page, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}You want to skip to the next block if
spl_onenand_read_page()fails (which can occur after you've already read some of the block).
I want to skip to next page, not next block.
Quoted 29 lines
How much of this is board-specific?
Quoted 26 lines
board/vpac270/onenand.c new file +26
-0+inline void spl_copy_uboot (void ) +{ +uint8_t *addr = (uint8_t *)CONFIG_SYS_TEXT_BASE ; +struct spl_onenand_data data; +uint32_t total_pages; +uint32_t block; +uint32_t page, rpage; +int ret; + +spl_onenand_get_geometry (&data); + +/* The page can be either 2k or 4k, avoid using DIV_ROUND_UP. */ + total_pages =CONFIG_SPL_ONENAND_LOAD_SIZE >>11 ; + page =CONFIG_SPL_ONENAND_LOAD_ADDR >>11 ; +if (data.pagesize ==4096 ) { + total_pages >>=1 ; + page >>=1 ; + } + +for (; page <= total_pages; page++) { + block = page >>6 ; + rpage = page &0xff ; + ret =spl_onenand_read_page (block, rpage, addr, data.pagesize); +if (ret) + total_pages++; +else
Quoted 8 lines
board/vpac270/onenand.c line 56
Quoted 3 lines
board/vpac270/onenand.c new file +3
-0+ addr += data.pagesize; + } +}What is so different about this compared to
spl_copy_self, that warrants such duplication? Can't you just pass in offset, length, and destination as parameters? Or just have the OneNAND SPL driver exportnand_spl_load_image(), as any other NAND SPL driver would?
Good idea.
Quoted 16 lines
board/vpac270/onenand.c line 99
Quoted 13 lines
board/vpac270/onenand.c new file +12
-0+inline void board_init_f (unsigned long unused) +{ +uint32_t tmp; + + asmvolatile ("mov %0, pc" :"=r" (tmp)); + tmp >>=24 ; + +/* The code runs from OneNAND RAM, copy SPL to SRAM and execute it. */ +if (tmp ==0 ) { +spl_copy_self (); + asmvolatile ("mov pc, %0" : :"r" (CONFIG_SPL_TEXT_BASE )); + }Is it not possible to use a simple memcpy for
spl_copy_self()? If the CPU can run the code, you'd think it could read it.
Not exactly. The OneNAND only exposes first 1kb of the contents (aka 1 half of the page 0 in my case). That's why I link all of the relevant code there and the rest of the SPL is aligned beyond that. Then I copy the whole SPL to SRAM and execute it again. Then I init DRAM, copy U-Boot there and run it. Simple, isn't it.
Quoted 26 lines
board/vpac270/onenand.c line 115
Quoted 6 lines
board/vpac270/onenand.c new file +5
-0+inline void board_init_r (gd_t *id,ulong dest_addr) +{ +for (;;) + ; +}This doesn't seem like a useful
board_init_r(). If you don't need it, maybe make sure it's not called, and save yourself some bytes in the SPL. Likewise for the other stub functions, where practical.Quoted 15 lines
board/vpac270/onenand.c new file +15
-0+inline int printf (const char *fmt, ...) +{ +return 0 ; +} + +inline void __coloured_LED_init (void ) {} +inline void __red_LED_on (void ) {} +void coloured_LED_init (void ) + __attribute__((weak,alias ("__coloured_LED_init" ))); +void red_LED_on (void ) + __attribute__((weak,alias ("__red_LED_on" ))); +void hang (void ) __attribute__ ((noreturn)); +void hang (void ) +{ +for (;;)
Quoted 8 lines
board/vpac270/onenand.c line 136
Quoted 5 lines
board/vpac270/onenand.c new file +5
-0+ ; +} + +inline void icache_disable (void ) {} +inline void dcache_disable (void ) {}Why are you specifying inline on just about everything, even functions that are not used in this file?
They are, by dram_init();
Quoted 3 lines
Why are you not specifying static on things that are not needed outside this file?
They are actually needed outside.
Quoted 17 lines
Quoted 17 lines
board/vpac270/vpac270.c +2
-0@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif
Quoted 7 lines
board/vpac270/vpac270.c struct serial_device *default_serial_console(void) · line 64
Quoted 4 lines
board/vpac270/vpac270.c +0
-0gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }Should this really be about whether OneNAND support is present, or should it be based on whether you're using the OneNAND SPL?
Basically, on this board this is the same thing.
Quoted 2 lines
-Scott
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 19 lines · Marek Vasut
Quoted 4 lines · Marek Vasut
Quoted 3 lines
Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
[...]
Quoted 12 lines
board/vpac270/onenand.c line 56
Quoted 9 lines
board/vpac270/onenand.c new file +8
-0+for (page =0 ; page <= total_pages; page++) { + ret =spl_onenand_read_page (0 , page, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}You want to skip to the next block if
spl_onenand_read_page()fails (which can occur after you've already read some of the block).
Quoted 1 line
I want to skip to next page, not next block.
That's not how we normally do things, and is not what the current OneNAND IPL does.
Bad block markers apply to the entire block -- unless this is a difference I'm not aware of between NAND and OneNAND.
Quoted 8 lines
Quoted 2 lines
Is it not possible to use a simple memcpy for
spl_copy_self()? If the CPU can run the code, you'd think it could read it.Not exactly. The OneNAND only exposes first 1kb of the contents (aka 1 half of the page 0 in my case). That's why I link all of the relevant code there and the rest of the SPL is aligned beyond that. Then I copy the whole SPL to SRAM and execute it again. Then I init DRAM, copy U-Boot there and run it. Simple, isn't it.
Where do you ensure that the stuff used so far is within the 1K? What parts are not within the 1K?
I don't see a linker script.
Quoted 7 lines
Quoted 5 lines
board/vpac270/onenand.c line 136
Quoted 2 lines
board/vpac270/onenand.c new file +2
-0+inline void icache_disable (void ) {} +inline void dcache_disable (void ) {}Why are you specifying inline on just about everything, even functions that are not used in this file?
They are, by
dram_init();
There's no point marking something inline if it's not used later on in the same file -- functions aren't inlined across file boundaries. You've got inline functions at the very end of the file.
For that matter, there's not much point marking anything inline that isn't a static inline in a header file (where the compiler must not generate a non-inline version) -- the compiler has heuristics for inlining things, and excessive inlining tends to make things bigger rather than smaller.
Quoted 4 lines
Quoted 2 lines
Why are you not specifying static on things that are not needed outside this file?
They are actually needed outside.
All of them, including spl_copy_uboot and spl_copy_self?
Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
board/vpac270/vpac270.c +2
-0@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ;
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
}
Should this really be about whether OneNAND support is present, or should it be based on whether you're using the OneNAND SPL?
Basically, on this board this is the same thing.
If you can turn off onenand at all, that suggests there's another boot source. Is it not possible to access onenand when using that other boot source?
In any case, best to use the symbol that most closely matches the reason you're skipping it, which is something SPL-related.
-Scott
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 20 lines · Marek Vasut
Quoted 19 lines
Quoted 4 lines · Marek Vasut
Quoted 3 lines
Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
[...]
Quoted 11 lines
board/vpac270/onenand.c line 56
Quoted 8 lines
board/vpac270/onenand.c new file +8
-0+for (page =0 ; page <= total_pages; page++) { + ret =spl_onenand_read_page (0 , page, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}You want to skip to the next block if
spl_onenand_read_page()fails (which can occur after you've already read some of the block).
Quoted 7 lines
Quoted 1 line
I want to skip to next page, not next block.
That's not how we normally do things, and is not what the current OneNAND IPL does.
Bad block markers apply to the entire block -- unless this is a difference I'm not aware of between NAND and OneNAND.
Well then it will fail reading the whole block and continue onwards ... it's a bit slower like this.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
Is it not possible to use a simple memcpy for
spl_copy_self()? If the CPU can run the code, you'd think it could read it.Not exactly. The OneNAND only exposes first 1kb of the contents (aka 1 half of the page 0 in my case). That's why I link all of the relevant code there and the rest of the SPL is aligned beyond that. Then I copy the whole SPL to SRAM and execute it again. Then I init DRAM, copy U-Boot there and run it. Simple, isn't it.
Quoted 4 lines
Where do you ensure that the stuff used so far is within the 1K? What parts are not within the 1K?
I don't see a linker script.
Is in V2, missing.
Quoted 50 lines
Quoted 8 lines
Quoted 6 lines
board/vpac270/onenand.c line 136
Quoted 3 lines
board/vpac270/onenand.c new file +2
-0+inline void icache_disable (void ) {} +inline void dcache_disable (void ) {}Why are you specifying inline on just about everything, even functions that are not used in this file?
They are, by
dram_init();There's no point marking something inline if it's not used later on in the same file -- functions aren't inlined across file boundaries. You've got inline functions at the very end of the file.
For that matter, there's not much point marking anything inline that isn't a static inline in a header file (where the compiler must not generate a non-inline version) -- the compiler has heuristics for inlining things, and excessive inlining tends to make things bigger rather than smaller.
Quoted 4 lines
Quoted 2 lines
Why are you not specifying static on things that are not needed outside this file?
They are actually needed outside.
All of them, including
spl_copy_ubootandspl_copy_self?Quoted 24 lines
Quoted 23 lines
Quoted 10 lines
board/vpac270/vpac270.c +0
-0@@ -56,7 +56,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) {board/vpac270/vpac270.c struct serial_device *default_serial_console(void) · line 64
Quoted 10 lines
board/vpac270/vpac270.c +2
-0+#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }Should this really be about whether OneNAND support is present, or should it be based on whether you're using the OneNAND SPL?
Quoted 5 lines
Quoted 1 line
Basically, on this board this is the same thing.
If you can turn off onenand at all, that suggests there's another boot source. Is it not possible to access onenand when using that other boot source?
No, they are mutually exclusive.
Quoted 5 lines
In any case, best to use the symbol that most closely matches the reason you're skipping it, which is something SPL-related.
-Scott
PATCH 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 22 lines · Marek Vasut
Quoted 22 lines · Marek Vasut
Quoted 20 lines
Quoted 4 lines · Marek Vasut
Quoted 3 lines
Signed-off-by Marek Vasut <[email protected]>Cc Albert ARIBAUD <[email protected]>---
[...]
Quoted 11 lines
board/vpac270/onenand.c line 56
Quoted 8 lines
board/vpac270/onenand.c new file +8
-0+for (page =0 ; page <= total_pages; page++) { + ret =spl_onenand_read_page (0 , page, addr, data.pagesize); +if (ret) + total_pages++; +else + addr += data.pagesize; + } +}You want to skip to the next block if
spl_onenand_read_page()fails (which can occur after you've already read some of the block).I want to skip to next page, not next block.
Quoted 8 lines
Quoted 5 lines
That's not how we normally do things, and is not what the current OneNAND IPL does.
Bad block markers apply to the entire block -- unless this is a difference I'm not aware of between NAND and OneNAND.
Well then it will fail reading the whole block and continue onwards ... it's a bit slower like this.
It doesn't work like that. The bad block marker is in the first page of the block only (sometimes the second page can be used). The bad block marker is not placed on every page in the block, so if you continue to subsequent pages it will not fail, but you won't be getting the data you're expecting.
-Scott
PATCH v2 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
In reply to Marek Vasut--- board/vpac270/Makefile | 4 ++ board/vpac270/onenand.c | 66 ++++++++++++++++++++++++++++ board/vpac270/u-boot-spl.lds | 97 ++++++++++++++++++++++++++++++++++++++++++ board/vpac270/vpac270.c | 2 + include/configs/vpac270.h | 25 +++++++++-- 5 files changed, 189 insertions(+), 5 deletions(-) create mode 100644 board/vpac270/onenand.c create mode 100644 board/vpac270/u-boot-spl.lds
V2: Add missing u-boot-spl.lds, convert bitshifts to division,
convert to spl_onenand_load_image()
board/vpac270/Makefile +4 -0
@@ -23,7 +23,11 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o +ifndef CONFIG_SPL_BUILD COBJS := vpac270.o +else +COBJS := onenand.o +endif SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/vpac270/onenand.c new file +66 -0
66 lines not on this page · raw message
board/vpac270/u-boot-spl.lds new file +97 -0
97 lines not on this page · raw message
board/vpac270/vpac270.c +2 -0
@@ -57,7 +57,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }
include/configs/vpac270.h +20 -5
@@ -27,7 +27,17 @@*/ #define CONFIG_PXA27X 1/* Marvell PXA270 CPU */ #define CONFIG_VPAC270 1/* Voipac PXA270 board */ -#define CONFIG_SYS_TEXT_BASE 0x0 +#define CONFIG_SYS_TEXT_BASE 0xa0000000 + +#ifdef CONFIG_ONENAND +#define CONFIG_SPL +#define CONFIG_SPL_ONENAND_SUPPORT +#define CONFIG_SPL_ONENAND_LOAD_ADDR 0x2000 +#define CONFIG_SPL_ONENAND_LOAD_SIZE \ + (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR) +#define CONFIG_SPL_TEXT_BASE 0x5c000000 +#define CONFIG_SPL_LDSCRIPT "board/vpac270/u-boot-spl.lds" +#endif /* * Environment settings
@@ -46,12 +56,19 @@"bootm 0xa4000000; " \"fi; " \ "bootm 0x60000;" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "update_onenand=" \ + "onenand erase 0x0 0x80000 ; " \ + "onenand write 0xa0000000 0x0 0x80000" +#define CONFIG_BOOTARGS "console=tty0 console=ttyS0,115200"#define CONFIG_TIMESTAMP #define CONFIG_BOOTDELAY 2/* Autoboot delay */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_LZMA /* LZMA compression support */ +#define CONFIG_OF_LIBFDT /* * Serial Console Configuration
@@ -180,16 +197,14 @@#define CONFIG_SYS_MEMTEST_END 0xa0800000/* 4 ... 8 MB in DRAM */ #define CONFIG_SYS_LOAD_ADDR PHYS_SDRAM_1 -#define CONFIG_SYS_IPL_LOAD_ADDR (0x5c000000)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -#define CONFIG_SYS_INIT_SP_ADDR \ - (PHYS_SDRAM_1 + GENERATED_GBL_DATA_SIZE + 2048) +#define CONFIG_SYS_INIT_SP_ADDR 0x5c010000/* * NOR FLASH */ #define CONFIG_SYS_MONITOR_BASE 0x0 -#define CONFIG_SYS_MONITOR_LEN 0x40000 +#define CONFIG_SYS_MONITOR_LEN 0x80000#define CONFIG_ENV_ADDR \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)#define CONFIG_ENV_SIZE 0x4000
Signature · 1 line
1.7.6.3
PATCH v2 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 1 line · Marek Vasut
+inline void
board_init_f(unsigned long unused)
Drop the inline.
Quoted 10 lines
board/vpac270/u-boot-spl.lds new file +10
-0+ /* Start of the rest of the SPL */ + . = CONFIG_SPL_TEXT_BASE + 0x800; + + .text.1 : + { + *(.text*) + } + + . = ALIGN(4); + .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
board/vpac270/u-boot-spl.lds line 63
Quoted 10 lines
board/vpac270/u-boot-spl.lds new file +10
-0+ + . = ALIGN(4); + .data : { + *(.data) + } + + . = ALIGN(4); + __u_boot_cmd_start = .; + .u_boot_cmd : { *(.u_boot_cmd) } + __u_boot_cmd_end = .;
Commands in an SPL?
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
In reply to Marek Vasut--- board/vpac270/Makefile | 4 ++ board/vpac270/onenand.c | 66 ++++++++++++++++++++++++++++++ board/vpac270/u-boot-spl.lds | 92 ++++++++++++++++++++++++++++++++++++++++++ board/vpac270/vpac270.c | 2 + include/configs/vpac270.h | 25 +++++++++-- 5 files changed, 184 insertions(+), 5 deletions(-) create mode 100644 board/vpac270/onenand.c create mode 100644 board/vpac270/u-boot-spl.lds
V2: Add missing u-boot-spl.lds, convert bitshifts to division,
convert to spl_onenand_load_image()
V3: Drop inlines, update linker script, update to conform new onenand_spl.
board/vpac270/Makefile +4 -0
@@ -23,7 +23,11 @@ include $(TOPDIR)/config.mk LIB = $(obj)lib$(BOARD).o +ifndef CONFIG_SPL_BUILD COBJS := vpac270.o +else +COBJS := onenand.o +endif SRCS := $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))
board/vpac270/onenand.c new file +66 -0
66 lines not on this page · raw message
board/vpac270/u-boot-spl.lds new file +92 -0
92 lines not on this page · raw message
board/vpac270/vpac270.c +2 -0
@@ -57,7 +57,9 @@ struct serial_device *default_serial_console(void)extern void pxa_dram_init (void );int dram_init (void ) { +#ifndef CONFIG_ONENAND pxa_dram_init (); +#endif gd->ram_size =PHYS_SDRAM_1_SIZE ;return 0 ; }
include/configs/vpac270.h +20 -5
@@ -27,7 +27,17 @@*/ #define CONFIG_PXA27X 1/* Marvell PXA270 CPU */ #define CONFIG_VPAC270 1/* Voipac PXA270 board */ -#define CONFIG_SYS_TEXT_BASE 0x0 +#define CONFIG_SYS_TEXT_BASE 0xa0000000 + +#ifdef CONFIG_ONENAND +#define CONFIG_SPL +#define CONFIG_SPL_ONENAND_SUPPORT +#define CONFIG_SPL_ONENAND_LOAD_ADDR 0x2000 +#define CONFIG_SPL_ONENAND_LOAD_SIZE \ + (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR) +#define CONFIG_SPL_TEXT_BASE 0x5c000000 +#define CONFIG_SPL_LDSCRIPT "board/vpac270/u-boot-spl.lds" +#endif /* * Environment settings
@@ -46,12 +56,19 @@"bootm 0xa4000000; " \"fi; " \ "bootm 0x60000;" + +#define CONFIG_EXTRA_ENV_SETTINGS \ + "update_onenand=" \ + "onenand erase 0x0 0x80000 ; " \ + "onenand write 0xa0000000 0x0 0x80000" +#define CONFIG_BOOTARGS "console=tty0 console=ttyS0,115200"#define CONFIG_TIMESTAMP #define CONFIG_BOOTDELAY 2/* Autoboot delay */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_LZMA /* LZMA compression support */ +#define CONFIG_OF_LIBFDT /* * Serial Console Configuration
@@ -180,16 +197,14 @@#define CONFIG_SYS_MEMTEST_END 0xa0800000/* 4 ... 8 MB in DRAM */ #define CONFIG_SYS_LOAD_ADDR PHYS_SDRAM_1 -#define CONFIG_SYS_IPL_LOAD_ADDR (0x5c000000)#define CONFIG_SYS_SDRAM_BASE PHYS_SDRAM_1 -#define CONFIG_SYS_INIT_SP_ADDR \ - (PHYS_SDRAM_1 + GENERATED_GBL_DATA_SIZE + 2048) +#define CONFIG_SYS_INIT_SP_ADDR 0x5c010000/* * NOR FLASH */ #define CONFIG_SYS_MONITOR_BASE 0x0 -#define CONFIG_SYS_MONITOR_LEN 0x40000 +#define CONFIG_SYS_MONITOR_LEN 0x80000#define CONFIG_ENV_ADDR \ (CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN)#define CONFIG_ENV_SIZE 0x4000
Signature · 1 line
1.7.6.3
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
board/vpac270/onenand.c line 52
Quoted 3 lines · Marek Vasut
board/vpac270/onenand.c new file +3
-0+onenand_spl_load_image (CONFIG_SPL_ONENAND_LOAD_ADDR , +CONFIG_SPL_ONENAND_LOAD_SIZE , + (void *)CONFIG_SYS_TEXT_BASE );
If we make it "nand_spl_load_image", and make the #defines conform, we can have the same code call the function for nand and onenand. I don't see any reason why onenand is a completely different subsystem in general, rather than just another NAND driver. The NAND subsystem's driver interface is lower level than it should be, but that affects other NAND controllers as well (such as fsl_elbc).
Switching to the generic nand_boot() in
http://patchwork.ozlabs.org/patch/123219/ would get you the ability to load the environment during the SPL.
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 12 lines · Marek Vasut
board/vpac270/onenand.c line 52
Quoted 3 lines
board/vpac270/onenand.c new file +3
-0+onenand_spl_load_image (CONFIG_SPL_ONENAND_LOAD_ADDR , +CONFIG_SPL_ONENAND_LOAD_SIZE , + (void *)CONFIG_SYS_TEXT_BASE );If we make it "
nand_spl_load_image", and make the #defines conform, we can have the same code call the function for nand and onenand. I don't see any reason why onenand is a completely different subsystem in general, rather than just another NAND driver. The NAND subsystem's driver interface is lower level than it should be, but that affects other NAND controllers as well (such asfsl_elbc).
Quoted 5 lines
Switching to the generic
nand_boot()in
http://patchwork.ozlabs.org/patch/123219/ would get you the ability to load the environment during the SPL.-Scott
I don't think I understand. Why do you want to mix onenand and nand ? Also, will your approach still allow me to squeeze the important code into the first 1kb for the initial copying of SPL?
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 12 lines · Marek Vasut
Quoted 12 lines · Marek Vasut
board/vpac270/onenand.c line 52
Quoted 3 lines
board/vpac270/onenand.c new file +3
-0+onenand_spl_load_image (CONFIG_SPL_ONENAND_LOAD_ADDR , +CONFIG_SPL_ONENAND_LOAD_SIZE , + (void *)CONFIG_SYS_TEXT_BASE );If we make it "
nand_spl_load_image", and make the #defines conform, we can have the same code call the function for nand and onenand. I don't see any reason why onenand is a completely different subsystem in general, rather than just another NAND driver. The NAND subsystem's driver interface is lower level than it should be, but that affects other NAND controllers as well (such asfsl_elbc).
Quoted 7 lines
Quoted 5 lines
Switching to the generic
nand_boot()in
http://patchwork.ozlabs.org/patch/123219/ would get you the ability to load the environment during the SPL.-Scott
I don't think I understand. Why do you want to mix onenand and nand ?
Why do we want to separate them? What is the fundamental difference between OneNAND, and a high-level NAND controller such as fsl_elbc? Maybe there would be some differences on init if we can't produce "normal" ID data, but that doesn't justify duplicating the whole subsystem.
Why should the code that just wants to use an API to move data around need to care which it is? Why should there be behavioral differences that aren't rooted in the actual hardware? Another approach might be to use MTD as the common interface, but factor out common code into libraries that drivers can use, and avoid the main nand_base.c code even for things like fsl_elbc.
This is not a new complaint -- I've asked for this before but nobody's put the time into sorting out the mess (and I have neither time nor hardware nor documentation). The SPL load_image function is a simple enough interface to start with, though. :-)
In fact, it should probably just be spl_load_image() with whatever boot source has been configured into this SPL build.
Quoted 2 lines
Also, will your approach still allow me to squeeze the important code into the first 1kb for the initial copying of SPL?
If you can't fit the common load sequence in, then of course don't use it, but there's no need for the function name to be different.
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 17 lines · Marek Vasut
Quoted 16 lines
Quoted 16 lines · Marek Vasut
board/vpac270/onenand.c line 52
Quoted 3 lines
board/vpac270/onenand.c new file +3
-0+onenand_spl_load_image (CONFIG_SPL_ONENAND_LOAD_ADDR , +CONFIG_SPL_ONENAND_LOAD_SIZE , + (void *)CONFIG_SYS_TEXT_BASE );If we make it "
nand_spl_load_image", and make the #defines conform, we can have the same code call the function for nand and onenand. I don't see any reason why onenand is a completely different subsystem in general, rather than just another NAND driver. The NAND subsystem's driver interface is lower level than it should be, but that affects other NAND controllers as well (such asfsl_elbc).Switching to the generic
nand_boot()in
http://patchwork.ozlabs.org/patch/123219/ would get you the ability to load the environment during the SPL.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
-Scott
I don't think I understand. Why do you want to mix onenand and nand ?
Why do we want to separate them? What is the fundamental difference between OneNAND, and a high-level NAND controller such as
fsl_elbc?
Honestly, I'm not the author of the subsystem, but please check the documentation. The way we retrieve data from onenand is different to NAND.
Quoted 2 lines
Maybe there would be some differences on init if we can't produce "normal" ID data, but that doesn't justify duplicating the whole subsystem.
Where do you see such duplication? cmd_onenand ?
Quoted 7 lines
Why should the code that just wants to use an API to move data around need to care which it is? Why should there be behavioral differences that aren't rooted in the actual hardware? Another approach might be to use MTD as the common interface, but factor out common code into libraries that drivers can use, and avoid the main
nand_base.ccode even for things likefsl_elbc.
I think you're mistaken here. OneNAND != NAND.
Quoted 5 lines
This is not a new complaint -- I've asked for this before but nobody's put the time into sorting out the mess (and I have neither time nor hardware nor documentation). The SPL
load_imagefunction is a simple enough interface to start with, though. :-)
Well, it seems what you are proposing is way beyond the scope of this patchset.
Quoted 3 lines
In fact, it should probably just be
spl_load_image()with whatever boot source has been configured into this SPL build.
What if you have two boot sources?
Quoted 8 lines
Quoted 3 lines
Also, will your approach still allow me to squeeze the important code into the first 1kb for the initial copying of SPL?
If you can't fit the common load sequence in, then of course don't use it, but there's no need for the function name to be different.
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 6 lines · Marek Vasut
Quoted 3 lines · Marek Vasut
Why do we want to separate them? What is the fundamental difference between OneNAND, and a high-level NAND controller such as
fsl_elbc?Honestly, I'm not the author of the subsystem, but please check the documentation. The way we retrieve data from onenand is different to NAND.
What documentation? How is it different? There are substantial differences in how we "retrieve data" between drivers that use the NAND subsystem. Surely you've seen that in the mxs_nand driver. :-)
Quoted 4 lines
Quoted 2 lines
Maybe there would be some differences on init if we can't produce "normal" ID data, but that doesn't justify duplicating the whole subsystem.
Where do you see such duplication?
cmd_onenand?
cmd_onenand and env_onenand are the most irritating, since they're at a layer that really shouldn't care about the differences -- we should probably have a plain "mtd" command instead, for most of the functionality.
There's also onenand_bbt.c -- what are the hardware-based differences in how the bad block table is managed?
nand_base.c/onenand_base.c are less clear. Obviously much of what is in onenand_base.c would be in the controller driver if it used the NAND subsystem. But it looks like some of it is duplication.
Quoted 8 lines
Quoted 6 lines
Why should the code that just wants to use an API to move data around need to care which it is? Why should there be behavioral differences that aren't rooted in the actual hardware? Another approach might be to use MTD as the common interface, but factor out common code into libraries that drivers can use, and avoid the main
nand_base.ccode even for things likefsl_elbc.I think you're mistaken here. OneNAND != NAND.
Well, last I tried I couldn't find any public documentation, so all I have to go on is the code, some marketing-type info, and asking questions of people that appear to know more about OneNAND than I do. :-)
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 85 lines · Marek Vasut
Quoted 7 lines
Quoted 3 lines · Marek Vasut
Why do we want to separate them? What is the fundamental difference between OneNAND, and a high-level NAND controller such as
fsl_elbc?Honestly, I'm not the author of the subsystem, but please check the documentation. The way we retrieve data from onenand is different to NAND.
What documentation? How is it different? There are substantial differences in how we "retrieve data" between drivers that use the NAND subsystem. Surely you've seen that in the
mxs_nanddriver. :-)Quoted 5 lines
Quoted 3 lines
Maybe there would be some differences on init if we can't produce "normal" ID data, but that doesn't justify duplicating the whole subsystem.
Where do you see such duplication?
cmd_onenand?
cmd_onenandandenv_onenandare the most irritating, since they're at a layer that really shouldn't care about the differences -- we should probably have a plain "mtd" command instead, for most of the functionality.There's also
onenand_bbt.c-- what are the hardware-based differences in how the bad block table is managed?
nand_base.c/onenand_base.care less clear. Obviously much of what is inonenand_base.cwould be in the controller driver if it used the NAND subsystem. But it looks like some of it is duplication.Quoted 8 lines
Quoted 6 lines
Why should the code that just wants to use an API to move data around need to care which it is? Why should there be behavioral differences that aren't rooted in the actual hardware? Another approach might be to use MTD as the common interface, but factor out common code into libraries that drivers can use, and avoid the main
nand_base.ccode even for things likefsl_elbc.I think you're mistaken here. OneNAND != NAND.
Well, last I tried I couldn't find any public documentation, so all I have to go on is the code, some marketing-type info, and asking questions of people that appear to know more about OneNAND than I do. :-)
From what I can see, it looks like NAND with an integrated controller that exposes an unusual command set, but still for the most part provides the same operations. Several of our existing NAND-subsystem drivers have to fake the command set for the generic layer as well. Initialization/identification might be a problem area that current drivers don't have to deal with, though. Actually integrating OneNAND with NAND would likely involve an already-needed restructuring of the subsystem.
If the answer really is that it makes sense to consider OneNAND to be a totally different thing from NAND, then it's outside my jurisdiction as NAND custodian -- which is fine with me. Frankly, even if it does make sense to merge them, I'd rather not be custodian of the OneNAND stuff unless someone is actually willing to do the merge. I don't have access to hardware or documentation, and it's an entirely separate codebase. People just started sending me the patches a few years back.
Quoted 5 lines
Quoted 4 lines
This is not a new complaint -- I've asked for this before but nobody's put the time into sorting out the mess (and I have neither time nor hardware nor documentation). The SPL
load_imagefunction is a simple enough interface to start with, though. :-)Quoted 7 lines
Well, it seems what you are proposing is way beyond the scope of this patchset.
Quoted 2 lines
In fact, it should probably just be
spl_load_image()with whatever boot source has been configured into this SPL build.What if you have two boot sources?
Traditionally SPL has been small and purpose-built to do exactly one thing -- so we decide at compile-time things that we might otherwise decide at runtime.
If there's a requirement for multiple boot sources decided at runtime, then we'll obviously need a runtime mechanism. -- but it seems a bit hackish to why does it matter whether it's two different types of device, or two of the same type of device (possibly with different controller types)? If the answer is that, for example, NAND versus USB versus MMC is a likely use case, but two different NANDs is not likely, is NAND versus OneNAND any more likely?
Quoted 9 lines
Maybe
spl_load_imageshould be a function pointer that board code sets, with each implementation being distinctly named (in which casenand_spl_load_imagewould becomenand_spl_simple_load_image, unless we move it tonand_spl_load.cand makenand_read_pagea function pointer).
If needed to save a few bytes, we could use #defines to eliminate the
function pointers in a single-target SPL build.For now, until we decide to do something SPL-wide, call it what you want.
Well basically from what I see, you'd like me to do the NAND/OneNAND merge. As I already said, that's way out of the scope of this patchset so I'm not doing that. Either way, are you OK with current state of the patch?
M
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 6 lines · Marek Vasut
Quoted 2 lines
For now, until we decide to do something SPL-wide, call it what you want.
Well basically from what I see, you'd like me to do the NAND/OneNAND merge. As I already said, that's way out of the scope of this patchset so I'm not doing that.
Oh, I didn't mean to imply that was within the scope of this patch. I was just describing the background behind why I'm frustrated with the OneNAND situation, and this looked like an extension of the "onenand is a totally different thing" model, in an independent context.
Quoted 1 line
Either way, are you OK with current state of the patch?
I won't block it.
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
Quoted 12 lines · Marek Vasut
Quoted 6 lines
Quoted 2 lines
For now, until we decide to do something SPL-wide, call it what you want.
Well basically from what I see, you'd like me to do the NAND/OneNAND merge. As I already said, that's way out of the scope of this patchset so I'm not doing that.
Oh, I didn't mean to imply that was within the scope of this patch. I was just describing the background behind why I'm frustrated with the OneNAND situation, and this looked like an extension of the "onenand is a totally different thing" model, in an independent context.
Well I suppose this is rooted in Linux. It's different subsys there too.
Quoted 4 lines
Quoted 2 lines
Either way, are you OK with current state of the patch?
I won't block it.
That's what I meant.
Quoted 2 lines
-Scott
PATCH v3 4/4 PXA: Adapt Voipac PXA270 to OneNAND SPL
In reply to Scott WoodQuoted 13 lines · Marek Vasut
Quoted 6 lines
Quoted 2 lines
For now, until we decide to do something SPL-wide, call it what you want.
Well basically from what I see, you'd like me to do the NAND/OneNAND merge. As I already said, that's way out of the scope of this patchset so I'm not doing that.
Oh, I didn't mean to imply that was within the scope of this patch. I was just describing the background behind why I'm frustrated with the OneNAND situation, and this looked like an extension of the "onenand is a totally different thing" model, in an independent context.
Quoted 5 lines
Quoted 1 line
Either way, are you OK with current state of the patch?
I won't block it.
-Scott
Ok, I'll queue this patchset and submit to Albert when I re-add the PXA250 support to start.S (done already, but I need to test it).