S5PC100: Add onenand_ipl for SMDKC100 support
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
The SMDKC100 Board has 256MB onenand.
So, It's bootable, if this patch is adapted thus the board use onenand_ipl.
---
This patch support onenand boot on SMDKC100 Board.
onenand_ipl/board/samsung/smdkc100/Makefile | 95 ++++++++++++++++++++ .../board/samsung/smdkc100/u-boot-onenand.lds | 53 +++++++++++ onenand_ipl/onenand_ipl.h | 11 +++ onenand_ipl/onenand_read.c | 18 ++++ 4 files changed, 177 insertions(+), 0 deletions(-) create mode 100644 onenand_ipl/board/samsung/smdkc100/Makefile create mode 100644 onenand_ipl/board/samsung/smdkc100/u-boot-onenand.lds
(quoted diff) +0 -0
b/onenand_ipl/board/samsung/smdkc100/Makefile
new file mode 100644
index 0000000..4301938
onenand_ipl/board/samsung/smdkc100/Makefile new file +36 -0
@@ -0,0 +1,95 @@ +# +# Samsung SMDKC100(S5PC100) board OneNAND IPL +# +# Copyright (C) 2009 Samsung Electronics +# Minkyu Kang <[email protected]> +# +# 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. +# + +include $(TOPDIR)/config.mk +TEXT_BASE = 0xD0034000 +TEXT_BASE2K = 0xD0034800 +TEXT_BASE4K = 0xD0035000 + +LDSCRIPT= $(TOPDIR)/onenand_ipl/board/$(BOARDDIR)/u-boot-onenand.lds +LDFLAGS = -Bstatic -T $(LDSCRIPT) -Ttext $(TEXT_BASE) $(PLATFORM_LDFLAGS) +AFLAGS += -DCONFIG_ONENAND_IPL -g +CFLAGS += -DCONFIG_ONENAND_IPL -g +OBJCFLAGS += --gap-fill=0x00 + +SOBJS := lowlevel_init.o mem_setup.o +SOBJS += start.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 $(onenandobj)onenand-ipl-4k.bin +
+all: $(obj).depend $(ALL)
+
+$(onenandobj)onenand-ipl-2k.bin: $(onenandobj)onenand-ipl
+ $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(TEXT_BASE2K) -O binary $< $@
+
+$(onenandobj)onenand-ipl-4k.bin: $(onenandobj)onenand-ipl
+ $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(TEXT_BASE4K) -O binary $< $@
+
+$(onenandobj)onenand-ipl.bin: $(onenandobj)onenand-ipl
+ $(OBJCOPY) ${OBJCFLAGS} -O binary $< $@
+
+$(onenandobj)onenand-ipl: $(OBJS)
+ cd $(LNDIR) && $(LD) $(LDFLAGS) $$UNDEF_SYM $(__OBJS) \
+ -Map [email protected] -o $@
+
+# create symbolic links from common files
+
+# from cpu directory
+$(obj)start.S:
+ @rm -f $@
+ ln -s $(SRCTREE)/cpu/$(CPU)/start.S $@
+
+$(obj)mem_setup.S:
+ ln -sf $(SRCTREE)/board/$(BOARDDIR)/mem_setup.S $@
+
+$(obj)lowlevel_init.S:
+ ln -sf $(SRCTREE)/board/$(BOARDDIR)/lowlevel_init.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 $@
+
+#########################################################################
+
+$(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
+
+clean:
+ rm onenand_boot.c onenand_read.c
+
+#########################################################################
(quoted diff) +0 -0
b/onenand_ipl/board/samsung/smdkc100/u-boot-onenand.lds new file mode 100644
index 0000000..559f9f2
onenand_ipl/board/samsung/smdkc100/u-boot-onenand.lds new file +53 -0
53 lines not on this page · raw message
onenand_ipl/onenand_ipl.h +11 -0
@@ -23,7 +23,18 @@#include <linux/mtd/onenand_regs.h> +#ifdef CONFIG_S5PC1XX +#define AHB_ADDR 0xB0000000 +#define MEM_ADDR (fba, fpa, fsa) (((fba) << 13 | (fpa) << 7 | \ + (fsa) << 5) & 0x3ffffff) +#define CMD_MAP_01 (mem_addr) (AHB_ADDR | (1 << 26) | (mem_addr)) +#define CMD_MAP_11 (addr) (AHB_ADDR | (3 << 26) | ((addr) << 2)) + +#define onenand_readw (a) (readl(CMD_MAP_11((a) >> 1)) & 0xffff) +#else /* CONFIG_S5PC1XX */ #define onenand_readw (a) readw(THIS_ONENAND(a)) +#endif /* CONFIG_S5PC1XX */ +#define onenand_writew (v, a) writew(v, THIS_ONENAND(a))#define THIS_ONENAND (a) (CONFIG_SYS_ONENAND_BASE + (a))
onenand_ipl/onenand_read.c +18 -0
@@ -37,10 +37,24 @@extern void *memcpy32 (void *dest,void *src,int size);#endif + +/* read a page with ECC */ static inline int onenand_read_page (ulong block,ulong page,u_char * buf,int pagesize) { +#ifdef CONFIG_S5PC1XX +unsigned int *p = (unsigned int *) buf; +int mem_addr, i; + + mem_addr =MEM_ADDR (block, page,0 ); + + pagesize >>=2 ; + +for (i =0 ; i < pagesize; i++) + *p++ = *(volatile unsigned int *)(CMD_MAP_01 (mem_addr)); +#else /* CONFIG_S5PC1XX */ +unsigned long *base;#ifndef __HAVE_ARCH_MEMCPY32
@@ -85,6 +99,7 @@ static inline int onenand_read_page(ulong block, ulong page, *p++ = value; }#endif +#endif /* CONFIG_S5PC1XX */ return 0 ; }
@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf) erasesize =ONENAND_PAGES_PER_BLOCK * pagesize; nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1 ) >> erase_shift; +#ifdef CONFIG_S5PC1XX + nblocks =1 ; +#endif /* NOTE: you must read page from page 1 of block 0 */ /* read the block page by page*/
Signature · 1 line
1.5.6.3
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
Dear HeungJun Kim,
Quoted 8 lines · In message <[email protected]> you…
The SMDKC100 Board has 256MB onenand.
So, It's bootable, if this patch is adapted thus the board useonenand_ipl.Signed-off-by HeungJun, Kim <[email protected]>---
This patch support onenand boot on SMDKC100 Board.
...
Quoted 6 lines
onenand_ipl/board/samsung/smdkc100/Makefile new file +0
-0
...
Quoted 2 lines
+ALL = $(onenandobj)onenand-ipl $(onenandobj)onenand-ipl.bin
$(onenandobj)onenand-ipl-2k.bin $(onenandobj)onenand-ipl-4k.bin
This patch is white-space corrupted. I gues this happened here because the line was way too long.
onenand_ipl/onenand_read.c line 41
Quoted 8 lines
onenand_ipl/onenand_read.c +2
-0@@ -37,10 +37,24 @@extern void *memcpy32 (void *dest,void *src,int size);#endif + +
Please do not arbitrary empty lines.
Quoted 7 lines
onenand_ipl/onenand_read.c +3
-0/* read a page with ECC */ static inline int onenand_read_page (ulong block,ulong page,u_char * buf,int pagesize) { +#ifdef CONFIG_S5PC1XX +unsigned int *p = (unsigned int *) buf; +int mem_addr, i;
onenand_ipl/onenand_read.c line 58
Quoted 10 lines
onenand_ipl/onenand_read.c +9
-0+ + mem_addr =MEM_ADDR (block, page,0 ); + + pagesize >>=2 ; + +for (i =0 ; i < pagesize; i++) + *p++ = *(volatile unsigned int *)(CMD_MAP_01 (mem_addr)); +#else /* CONFIG_S5PC1XX */ +unsigned long *base;
I don't like to see such board specific code in global files.
Also, please use I/O accessor functions instead of register accesses.
onenand_ipl/onenand_read.c int onenand_read_block(unsigned char *buf) · line 134
Quoted 7 lines
onenand_ipl/onenand_read.c +3
-0@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf) erasesize =ONENAND_PAGES_PER_BLOCK * pagesize; nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1 ) >> erase_shift; +#ifdef CONFIG_S5PC1XX + nblocks =1 ; +#endif
Again: why do we need such board specific code here?
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I have a very small mind and must live with it. -- Edsger Dijkstra
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
Hi,
Quoted 47 lines · Wolfgang Denk
Dear HeungJun Kim,
Quoted 8 lines · In message <[email protected]> you…
The SMDKC100 Board has 256MB onenand.
So, It's bootable, if this patch is adapted thus the board useonenand_ipl.Signed-off-by HeungJun, Kim <[email protected]>---
This patch support onenand boot on SMDKC100 Board.
...
Quoted 6 lines
onenand_ipl/board/samsung/smdkc100/Makefile new file +0
-0...
Quoted 2 lines
+ALL ?= $(onenandobj)onenand-ipl $(onenandobj)onenand-ipl.bin $(onenandobj)onenand-ipl-2k.bin $(onenandobj)onenand-ipl-4k.bin
This patch is white-space corrupted. I gues this happened here because the line was way too long.
onenand_ipl/onenand_read.c
Quoted 8 lines
onenand_ipl/onenand_read.c +0
-0@@ -37,10 +37,24 @@ ?extern void *memcpy32(void *dest, void *src, int size);?#endif
onenand_ipl/onenand_read.c +2
-0+ +Please do not arbitrary empty lines.
Quoted 11 lines
?/* read a page with ECC */
?static inline intonenand_read_page(ulong block, ulong page, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? u_char * buf, int pagesize)?{onenand_ipl/onenand_read.c +7
-0+#ifdef CONFIG_S5PC1XX + ? ? unsigned int *p = (unsigned int *) buf; + ? ? int mem_addr, i; + + ? ? mem_addr = MEM_ADDR(block, page, 0); + + ? ? pagesize >>= 2;
Quoted 8 lines
Quoted 6 lines
onenand_ipl/onenand_read.c +5
-0+ + ? ? for (i = 0; i < pagesize; i++) + ? ? ? ? ? ? *p++ = *(volatile unsigned int *)(CMD_MAP_01(mem_addr)); +#else ? ? ? ?/* CONFIG_S5PC1XX */ +? ? ? unsigned long *base;
I don't like to see such board specific code in global files.
I think it's not board specific code. S3C64XX and S5PC1XX series have own OneNAND controller and to access the OneNAND, it should use the this controller.
If you don't like the ifdef. we can separate the function but I'm not sure it's really required.
Quoted 2 lines
Also, please use I/O accessor functions instead of register accesses.
readl(...)? If yes, I agree it.
Quoted 11 lines
onenand_ipl/onenand_read.c int onenand_read_block(unsigned char *buf) · line 134
Quoted 8 lines
onenand_ipl/onenand_read.c +3
-0@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf) ? ? ? erasesize = ONENAND_PAGES_PER_BLOCK * pagesize; ? ? ? nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize - 1) >> erase_shift; +#ifdef CONFIG_S5PC1XX + ? ? nblocks = 1; +#endif Again: why do we need such board specific code here?
It should be fixed.
Thank you,
Kyungmin Park
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
Dear Kyungmin Park,
Quoted 21 lines · In message <[email protected]> you…
Quoted 12 lines
Quoted 12 lines
/* read a page with ECC */
static inline int onenand_read_page(ulong block, ulong page,
u_char* buf> , int pagesize)
{onenand_ipl/onenand_read.c +7
-0+#ifdef CONFIG_S5PC1XX +unsigned int *p = (unsigned int *) buf; +int mem_addr, i; + + mem_addr =MEM_ADDR (block, page,0 ); + + pagesize >>=2 ;Quoted 8 lines
onenand_ipl/onenand_read.c line 58
Quoted 6 lines
onenand_ipl/onenand_read.c +5
-0+ +for (i =0 ; i < pagesize; i++) + *p++ = *(volatile unsigned int *)(CMD_MAP_01 > (mem_addr)); +#else /* CONFIG_S5PC1XX */ +unsigned long *base;I don't like to see such board specific code in global files.
Quoted 3 lines
I think it's not board specific code. S3C64XX and S5PC1XX series have own OneNAND controller and to access the OneNAND, it should use the this controller.
OK, so it is SoC specific code in a common file - that's just marginally better.
Quoted 2 lines
If you don't like the ifdef. we can separate the function but I'm not sure it's really required.
It would be great if we can get rid of the #ifdef.
Quoted 3 lines
Quoted 1 line
Also, please use I/O accessor functions instead of register accesses.
readl(...)? If yes, I agree it.
Yes.
Quoted 11 lines
Quoted 9 lines
onenand_ipl/onenand_read.c int onenand_read_block(unsigned char *buf) · line 134
Quoted 7 lines
onenand_ipl/onenand_read.c +3
-0@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf) erasesize =ONENAND_PAGES_PER_BLOCK * pagesize; nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1 ) >> eras> e_shift; +#ifdef CONFIG_S5PC1XX + nblocks =1 ; +#endif Again: why do we need such board specific code here?
It should be fixed.
Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Just about every computer on the market today runs Unix, except the Mac (and nobody cares about it). - Bill Joy 6/21/85
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
Quoted 28 lines · Wolfgang Denk
Dear Kyungmin Park,
Quoted 21 lines · In message <[email protected]> you…
Quoted 12 lines
Quoted 12 lines
?/* read a page with ECC */
?static inline intonenand_read_page(ulong block, ulong page, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? u_char * buf> , int pagesize)?{(quoted diff) +7
-0+#ifdef CONFIG_S5PC1XX + ? ? unsigned int *p = (unsigned int *) buf; + ? ? int mem_addr, i; + + ? ? mem_addr = MEM_ADDR(block, page, 0); + + ? ? pagesize >>= 2;Quoted 8 lines
Quoted 6 lines
(quoted diff) +5
-0+ + ? ? for (i = 0; i < pagesize; i++) + ? ? ? ? ? ? *p++ = *(volatile unsigned int *)(CMD_MAP_01> (mem_addr)); +#else ? ? ? ?/* CONFIG_S5PC1XX */ +? ? ? unsigned long *base;
I don't like to see such board specific code in global files.
Quoted 3 lines
I think it's not board specific code. S3C64XX and S5PC1XX series have own OneNAND controller and to access the OneNAND, it should use the this controller.
Quoted 7 lines
OK, so it is SoC specific code in a common file - that's just marginally better.
Quoted 2 lines
If you don't like the ifdef. we can separate the function but I'm not sure it's really required.
It would be great if we can get rid of the #ifdef.
As you know, OneNAND IPL has size limitation, 1KiB. So it's difficult to co-exist two different function.
Thank you,
Kyungmin Park
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
In reply to HeungJun KimQuoted 16 lines · HeungJun Kim
onenand_ipl/onenand_read.c +12
-0+#ifdef CONFIG_S5PC1XX +unsigned int *p = (unsigned int *) buf; +int mem_addr, i; + + mem_addr =MEM_ADDR (block, page,0 ); + + pagesize >>=2 ; + +for (i =0 ; i < pagesize; i++) + *p++ = *(volatile unsigned int *)(CMD_MAP_01 (mem_addr)); +#else /* CONFIG_S5PC1XX */ +unsigned long *base;#ifndef __HAVE_ARCH_MEMCPY32
onenand_ipl/onenand_read.c static inline int onenand_read_page(ulong block, ulong page, · line 102
Quoted 4 lines
onenand_ipl/onenand_read.c +1
-0@@ -85,6 +99,7 @@ static inline int onenand_read_page(ulong block, ulong page, *p++ = value; }#endif +#endif /* CONFIG_S5PC1XX */
Please put each controller implementation in a separate file, with an appropriate name. Do not make anything which is SoC-specific look generic.
If onenand_read_block() is not controller-specific (looks like everything except the read of ONENAND_REG_TECHNOLOGY is generic), move it to onenand_boot.c.
onenand_ipl/onenand_read.c int onenand_read_block(unsigned char *buf) · line 134
Quoted 7 lines
onenand_ipl/onenand_read.c +3
-0@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf) erasesize =ONENAND_PAGES_PER_BLOCK * pagesize; nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize -1 ) >> erase_shift; +#ifdef CONFIG_S5PC1XX + nblocks =1 ; +#endif
Why?
-Scott
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
hi
Quoted 15 lines · Scott Wood
Quoted 14 lines · HeungJun Kim
(quoted diff) +12
-0+#ifdef CONFIG_S5PC1XX + ? ? unsigned int *p = (unsigned int *) buf; + ? ? int mem_addr, i; + + ? ? mem_addr = MEM_ADDR(block, page, 0); + + ? ? pagesize >>= 2; + + ? ? for (i = 0; i < pagesize; i++) + ? ? ? ? ? ? *p++ = *(volatile unsigned int *)(CMD_MAP_01(mem_addr)); +#else ? ? ? ?/* CONFIG_S5PC1XX */ +? ? ? unsigned long *base;
Quoted 6 lines
Quoted 6 lines
?#ifndef
__HAVE_ARCH_MEMCPY32(quoted diff) +0
-0@@ -85,6 +99,7 @@ static inline int onenand_read_page(ulong block, ulong page, ? ? ? ? ? ? ? *p++ = value; ? ? ? }?#endif
+#endif ? ? ? /*CONFIG_S5PC1XX*/
It should be S5PC100, not used at S5PC110. it uses generic interface with DMA support.
Quoted 4 lines
Please put each controller implementation in a separate file, with an appropriate name. ?Do not make anything which is SoC-specific look generic.
No problem,
One question, how to use use generic & s5pc100 read function simultaneously. Since our test board use two cpu, s5pc100 & s5pc110. but each cpu has different read function.
I want to use it both with only one u-boot image. In this case we have to distinguish and use it properly.
Now I add the function pointer and assign it based on cpu id.
Quoted 7 lines
If
onenand_read_block()is not controller-specific (looks like everything except the read ofONENAND_REG_TECHNOLOGYis generic), move it toonenand_boot.c.Quoted 2 lines
(quoted diff) +0
-0@@ -114,6 +129,9 @@ int onenand_read_block(unsigned char *buf)
Quoted 8 lines
Review int onenand_read_block(unsigned char *buf) · line 134
Quoted 5 lines
(quoted diff) +3
-0? ? ? erasesize = ONENAND_PAGES_PER_BLOCK * pagesize; ? ? ? nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize - 1) >> erase_shift; +#ifdef CONFIG_S5PC1XX + ? ? nblocks = 1; +#endifWhy?
It's developer's mistake, no reason to use 1 block. actually internal ROM read 16KiB data to internal RAM in case of s5pc100.
Thank you,
Kyungmin Park
PATCH 6/6 S5PC100: Add onenand_ipl for SMDKC100 support
Quoted 7 lines · Kyungmin Park
No problem,
One question, how to use use generic & s5pc100 read function simultaneously. Since our test board use two cpu, s5pc100 & s5pc110. but each cpu has different read function.
I want to use it both with only one u-boot image. In this case we have to distinguish and use it properly.
Now I add the function pointer and assign it based on cpu id.
Using a function pointer is OK.
-Scott