Make board_nand_init() return 0 on success and -1 on failure for boards that dynamically detect if NAND flashes are available. Signed-off-by: Hans Zuidam --- board/dave/PPChameleonEVB/nand.c | 4 +++- board/delta/nand.c | 4 +++- board/nc650/nand.c | 4 +++- board/netstar/nand.c | 4 +++- board/prodrive/pdnb3/nand.c | 4 +++- board/zylonite/nand.c | 4 +++- cpu/ppc4xx/ndfc.c | 4 +++- drivers/nand/nand.c | 5 ++--- nand_spl/nand_boot.c | 4 ++-- 9 files changed, 25 insertions(+), 12 deletions(-) diff --git a/board/dave/PPChameleonEVB/nand.c b/board/dave/PPChameleonEVB/nand.c index 40a827c..2842a1d 100644 --- a/board/dave/PPChameleonEVB/nand.c +++ b/board/dave/PPChameleonEVB/nand.c @@ -105,7 +105,7 @@ static int ppchameleonevb_device_ready(s * Members with a "?" were not set in the merged testing-NAND branch, * so they are not set here either. */ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { nand->hwcontrol = ppchameleonevb_hwcontrol; @@ -113,5 +113,7 @@ void board_nand_init(struct nand_chip *n nand->eccmode = NAND_ECC_SOFT; nand->chip_delay = NAND_BIG_DELAY_US; nand->options = NAND_SAMSUNG_LP_OPTIONS; + + return 0; } #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */ diff --git a/board/delta/nand.c b/board/delta/nand.c index fe648fc..5a35d53 100644 --- a/board/delta/nand.c +++ b/board/delta/nand.c @@ -448,7 +448,7 @@ static void dfc_gpio_init(void) * Members with a "?" were not set in the merged testing-NAND branch, * so they are not set here either. */ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { unsigned long tCH, tCS, tWH, tWP, tRH, tRP, tRP_high, tR, tWHR, tAR; @@ -576,6 +576,8 @@ #endif /* CFG_TIMING_TIGHT */ nand->cmdfunc = dfc_cmdfunc; nand->autooob = &delta_oob; nand->badblock_pattern = &delta_bbt_descr; + + return 0; } #else diff --git a/board/nc650/nand.c b/board/nc650/nand.c index de54386..be3fbaa 100644 --- a/board/nc650/nand.c +++ b/board/nc650/nand.c @@ -106,12 +106,14 @@ #endif * Members with a "?" were not set in the merged testing-NAND branch, * so they are not set here either. */ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { nand->hwcontrol = nc650_hwcontrol; nand->eccmode = NAND_ECC_SOFT; nand->chip_delay = 12; /* nand->options = NAND_SAMSUNG_LP_OPTIONS;*/ + + return 0; } #endif /* (CONFIG_COMMANDS & CFG_CMD_NAND) */ diff --git a/board/netstar/nand.c b/board/netstar/nand.c index f470c1a..1c0dbc0 100644 --- a/board/netstar/nand.c +++ b/board/netstar/nand.c @@ -55,12 +55,14 @@ static int netstar_nand_ready(struct mtd } ***/ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { nand->options = NAND_SAMSUNG_LP_OPTIONS; nand->eccmode = NAND_ECC_SOFT; nand->hwcontrol = netstar_nand_hwcontrol; /* nand->dev_ready = netstar_nand_ready; */ nand->chip_delay = 18; + + return 0; } #endif diff --git a/board/prodrive/pdnb3/nand.c b/board/prodrive/pdnb3/nand.c index 1931d64..8b47069 100644 --- a/board/prodrive/pdnb3/nand.c +++ b/board/prodrive/pdnb3/nand.c @@ -148,7 +148,7 @@ static int pdnb3_nand_dev_ready(struct m return 1; } -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { pdnb3_ndfc = (struct pdnb3_ndfc_regs *)CFG_NAND_BASE; @@ -167,5 +167,7 @@ void board_nand_init(struct nand_chip *n nand->read_buf = pdnb3_nand_read_buf; nand->verify_buf = pdnb3_nand_verify_buf; nand->dev_ready = pdnb3_nand_dev_ready; + + return 0; } #endif diff --git a/board/zylonite/nand.c b/board/zylonite/nand.c index 5d2cd65..7d73f7b 100644 --- a/board/zylonite/nand.c +++ b/board/zylonite/nand.c @@ -448,7 +448,7 @@ static void dfc_gpio_init(void) * Members with a "?" were not set in the merged testing-NAND branch, * so they are not set here either. */ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { unsigned long tCH, tCS, tWH, tWP, tRH, tRP, tRP_high, tR, tWHR, tAR; @@ -576,6 +576,8 @@ #endif /* CFG_TIMING_TIGHT */ nand->cmdfunc = dfc_cmdfunc; nand->autooob = &delta_oob; nand->badblock_pattern = &delta_bbt_descr; + + return 0; } #else diff --git a/cpu/ppc4xx/ndfc.c b/cpu/ppc4xx/ndfc.c index c255f93..87f0d0d 100644 --- a/cpu/ppc4xx/ndfc.c +++ b/cpu/ppc4xx/ndfc.c @@ -142,7 +142,7 @@ static int ndfc_verify_buf(struct mtd_in } #endif /* #ifndef CONFIG_NAND_SPL */ -void board_nand_init(struct nand_chip *nand) +int board_nand_init(struct nand_chip *nand) { nand->eccmode = NAND_ECC_SOFT; @@ -170,6 +170,8 @@ #endif /* Chip select 3, 1col x 2 rows */ out32(CFG_NAND_BASE + NDFC_CCR, 0x00000000 | (CFG_NAND_CS << 24)); out32(CFG_NAND_BASE + NDFC_BCFG0 + (CFG_NAND_CS << 2), 0x80002222); + + return 0; } #endif diff --git a/drivers/nand/nand.c b/drivers/nand/nand.c index e1781fc..8865c0a 100644 --- a/drivers/nand/nand.c +++ b/drivers/nand/nand.c @@ -39,7 +39,7 @@ static ulong base_address[CFG_MAX_NAND_D static const char default_nand_name[] = "nand"; -extern void board_nand_init(struct nand_chip *nand); +extern int board_nand_init(struct nand_chip *nand); static void nand_init_chip(struct mtd_info *mtd, struct nand_chip *nand, ulong base_addr) @@ -47,9 +47,8 @@ static void nand_init_chip(struct mtd_in mtd->priv = nand; nand->IO_ADDR_R = nand->IO_ADDR_W = (void __iomem *)base_addr; - board_nand_init(nand); - if (nand_scan(mtd, 1) == 0) { + if ((board_nand_init(nand) == 0) && (nand_scan(mtd, 1) == 0)) { if (!mtd->name) mtd->name = (char *)default_nand_name; } else diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c index 6e3af13..45560e4 100644 --- a/nand_spl/nand_boot.c +++ b/nand_spl/nand_boot.c @@ -24,7 +24,7 @@ #include #define CFG_NAND_READ_DELAY \ { volatile int dummy; int i; for (i=0; i<10000; i++) dummy = i; } -extern void board_nand_init(struct nand_chip *nand); +extern int board_nand_init(struct nand_chip *nand); extern void ndfc_hwcontrol(struct mtd_info *mtdinfo, int cmd); extern void ndfc_write_byte(struct mtd_info *mtdinfo, u_char byte); extern u_char ndfc_read_byte(struct mtd_info *mtdinfo); @@ -161,7 +161,7 @@ void nand_boot(void) nand_info.priv = &nand_chip; nand_chip.IO_ADDR_R = nand_chip.IO_ADDR_W = (void __iomem *)CFG_NAND_BASE; nand_chip.dev_ready = NULL; /* preset to NULL */ - board_nand_init(&nand_chip); + (void) board_nand_init(&nand_chip); /* * Load U-Boot image from NAND into RAM -- 1.4.1