Refactor OneNAND IPL code
Refactoring the OneNAND IPL code and some minor fixed: - Remove unnecessary header file - Fix wrong access at read interrupt - The recent OneNAND has 4KiB pagesize Also Board can override OneNAND IPL image Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
This commit is contained in:
parent
a05e3f9a08
commit
ca6189db48
9
Makefile
9
Makefile
|
@ -285,6 +285,7 @@ endif
|
||||||
ifeq ($(CONFIG_ONENAND_U_BOOT),y)
|
ifeq ($(CONFIG_ONENAND_U_BOOT),y)
|
||||||
ONENAND_IPL = onenand_ipl
|
ONENAND_IPL = onenand_ipl
|
||||||
U_BOOT_ONENAND = $(obj)u-boot-onenand.bin
|
U_BOOT_ONENAND = $(obj)u-boot-onenand.bin
|
||||||
|
ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
|
||||||
endif
|
endif
|
||||||
|
|
||||||
__OBJS := $(subst $(obj),,$(OBJS))
|
__OBJS := $(subst $(obj),,$(OBJS))
|
||||||
|
@ -378,8 +379,7 @@ $(ONENAND_IPL): $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
|
||||||
$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
|
$(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
|
||||||
|
|
||||||
$(U_BOOT_ONENAND): $(ONENAND_IPL) $(obj)u-boot.bin
|
$(U_BOOT_ONENAND): $(ONENAND_IPL) $(obj)u-boot.bin
|
||||||
cat $(obj)onenand_ipl/onenand-ipl-2k.bin $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
|
cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
|
||||||
cat $(obj)onenand_ipl/onenand-ipl-4k.bin $(obj)u-boot.bin > $(obj)u-boot-flexonenand.bin
|
|
||||||
|
|
||||||
$(VERSION_FILE):
|
$(VERSION_FILE):
|
||||||
@( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
|
@( printf '#define U_BOOT_VERSION "U-Boot %s%s"\n' "$(U_BOOT_VERSION)" \
|
||||||
|
@ -3223,8 +3223,6 @@ zylonite_config :
|
||||||
#########################################################################
|
#########################################################################
|
||||||
|
|
||||||
apollon_config : unconfig
|
apollon_config : unconfig
|
||||||
@mkdir -p $(obj)include
|
|
||||||
@mkdir -p $(obj)onenand_ipl/board/apollon
|
|
||||||
@echo "#define CONFIG_ONENAND_U_BOOT" > $(obj)include/config.h
|
@echo "#define CONFIG_ONENAND_U_BOOT" > $(obj)include/config.h
|
||||||
@$(MKCONFIG) $(@:_config=) arm arm1136 apollon NULL omap24xx
|
@$(MKCONFIG) $(@:_config=) arm arm1136 apollon NULL omap24xx
|
||||||
@echo "CONFIG_ONENAND_U_BOOT = y" >> $(obj)include/config.mk
|
@echo "CONFIG_ONENAND_U_BOOT = y" >> $(obj)include/config.mk
|
||||||
|
@ -3706,7 +3704,8 @@ clean:
|
||||||
$(obj)cpu/blackfin/bootrom-asm-offsets.[chs]
|
$(obj)cpu/blackfin/bootrom-asm-offsets.[chs]
|
||||||
@rm -f $(obj)include/bmp_logo.h
|
@rm -f $(obj)include/bmp_logo.h
|
||||||
@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,System.map}
|
@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,System.map}
|
||||||
@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl-2k.bin,ipl-4k.bin,ipl.map}
|
@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
|
||||||
|
@rm -f $(ONENAND_BIN)
|
||||||
@rm -f $(obj)onenand_ipl/u-boot.lds
|
@rm -f $(obj)onenand_ipl/u-boot.lds
|
||||||
@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
|
@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
|
||||||
@find $(OBJTREE) -type f \
|
@find $(OBJTREE) -type f \
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <version.h>
|
|
||||||
|
|
||||||
#include "onenand_ipl.h"
|
#include "onenand_ipl.h"
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,9 @@
|
||||||
|
|
||||||
#define THIS_ONENAND(a) (CONFIG_SYS_ONENAND_BASE + (a))
|
#define THIS_ONENAND(a) (CONFIG_SYS_ONENAND_BASE + (a))
|
||||||
|
|
||||||
#define READ_INTERRUPT() \
|
#define READ_INTERRUPT() onenand_readw(ONENAND_REG_INTERRUPT)
|
||||||
onenand_readw(THIS_ONENAND(ONENAND_REG_INTERRUPT))
|
|
||||||
|
|
||||||
|
extern int (*onenand_read_page)(ulong block, ulong page,
|
||||||
|
u_char *buf, int pagesize);
|
||||||
extern int onenand_read_block(unsigned char *buf);
|
extern int onenand_read_block(unsigned char *buf);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* (C) Copyright 2005-2008 Samsung Electronis
|
* (C) Copyright 2005-2009 Samsung Electronics
|
||||||
* Kyungmin Park <kyungmin.park@samsung.com>
|
* Kyungmin Park <kyungmin.park@samsung.com>
|
||||||
*
|
*
|
||||||
* See file CREDITS for list of people who contributed to this
|
* See file CREDITS for list of people who contributed to this
|
||||||
|
@ -37,8 +37,10 @@
|
||||||
extern void *memcpy32(void *dest, void *src, int size);
|
extern void *memcpy32(void *dest, void *src, int size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int (*onenand_read_page)(ulong block, ulong page, u_char *buf, int pagesize);
|
||||||
|
|
||||||
/* read a page with ECC */
|
/* read a page with ECC */
|
||||||
static inline int onenand_read_page(ulong block, ulong page,
|
static int generic_onenand_read_page(ulong block, ulong page,
|
||||||
u_char * buf, int pagesize)
|
u_char * buf, int pagesize)
|
||||||
{
|
{
|
||||||
unsigned long *base;
|
unsigned long *base;
|
||||||
|
@ -89,9 +91,25 @@ static inline int onenand_read_page(ulong block, ulong page,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ONENAND_START_PAGE 1
|
#ifndef CONFIG_ONENAND_START_PAGE
|
||||||
|
#define CONFIG_ONENAND_START_PAGE 1
|
||||||
|
#endif
|
||||||
#define ONENAND_PAGES_PER_BLOCK 64
|
#define ONENAND_PAGES_PER_BLOCK 64
|
||||||
|
|
||||||
|
static void onenand_generic_init(int *page_is_4KiB, int *page)
|
||||||
|
{
|
||||||
|
int dev_id, density;
|
||||||
|
|
||||||
|
if (onenand_readw(ONENAND_REG_TECHNOLOGY))
|
||||||
|
*page_is_4KiB = 1;
|
||||||
|
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 &&
|
||||||
|
!(dev_id & ONENAND_DEVICE_IS_DDP))
|
||||||
|
*page_is_4KiB = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onenand_read_block - Read CONFIG_SYS_MONITOR_LEN from begining
|
* onenand_read_block - Read CONFIG_SYS_MONITOR_LEN from begining
|
||||||
* of OneNAND, skipping bad blocks
|
* of OneNAND, skipping bad blocks
|
||||||
|
@ -99,24 +117,28 @@ static inline int onenand_read_page(ulong block, ulong page,
|
||||||
*/
|
*/
|
||||||
int onenand_read_block(unsigned char *buf)
|
int onenand_read_block(unsigned char *buf)
|
||||||
{
|
{
|
||||||
int block;
|
int block, nblocks;
|
||||||
int page = ONENAND_START_PAGE, offset = 0;
|
int page = CONFIG_ONENAND_START_PAGE, offset = 0;
|
||||||
int pagesize = 0, erase_shift = 0;
|
int pagesize, erasesize, erase_shift;
|
||||||
int erasesize = 0, nblocks = 0;
|
int page_is_4KiB = 0;
|
||||||
|
|
||||||
if (onenand_readw(ONENAND_REG_TECHNOLOGY)) {
|
onenand_read_page = generic_onenand_read_page;
|
||||||
pagesize = 4096; /* MLC OneNAND has 4KiB pagesize */
|
|
||||||
|
onenand_generic_init(&page_is_4KiB, &page);
|
||||||
|
|
||||||
|
if (page_is_4KiB) {
|
||||||
|
pagesize = 4096; /* OneNAND has 4KiB pagesize */
|
||||||
erase_shift = 18;
|
erase_shift = 18;
|
||||||
} else {
|
} else {
|
||||||
pagesize = 2048;
|
pagesize = 2048; /* OneNAND has 2KiB pagesize */
|
||||||
erase_shift = 17;
|
erase_shift = 17;
|
||||||
}
|
}
|
||||||
|
|
||||||
erasesize = ONENAND_PAGES_PER_BLOCK * pagesize;
|
erasesize = (1 << erase_shift);
|
||||||
nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize - 1) >> erase_shift;
|
nblocks = (CONFIG_SYS_MONITOR_LEN + erasesize - 1) >> erase_shift;
|
||||||
|
|
||||||
/* NOTE: you must read page from page 1 of block 0 */
|
/* NOTE: you must read page from page 1 of block 0 */
|
||||||
/* read the block page by page*/
|
/* read the block page by page */
|
||||||
for (block = 0; block < nblocks; block++) {
|
for (block = 0; block < nblocks; block++) {
|
||||||
for (; page < ONENAND_PAGES_PER_BLOCK; page++) {
|
for (; page < ONENAND_PAGES_PER_BLOCK; page++) {
|
||||||
if (onenand_read_page(block, page, buf + offset,
|
if (onenand_read_page(block, page, buf + offset,
|
||||||
|
|
Loading…
Reference in New Issue