mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-25 13:14:19 +08:00
MTD: mxs_nand_spl: Redo the way nand_init initializes
Currently the spl system calls nand_init which does nothing. It isn't until an attempt to load from NAND that it gets initialized. Subsequent attempts to load just skip the initialization because NAND is already initialized. This moves the contents of mxs_nand_init to nand_init. In the event of an error, it clears the number of nand chips found. Any attempts to use nand will check if there are nand chips available instead of actually doing the initialization at that time. If there are none, it will return an error to the higher level calls. Signed-off-by: Adam Ford <aford173@gmail.com>
This commit is contained in:
parent
8d0370905c
commit
d46d27d3b6
@ -174,11 +174,11 @@ static int is_badblock(struct mtd_info *mtd, loff_t offs, int allowbbt)
|
||||
}
|
||||
|
||||
/* setup mtd and nand structs and init mxs_nand driver */
|
||||
static int mxs_nand_init(void)
|
||||
void nand_init(void)
|
||||
{
|
||||
/* return if already initalized */
|
||||
if (nand_chip.numchips)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* init mxs nand driver */
|
||||
mxs_nand_init_spl(&nand_chip);
|
||||
@ -191,7 +191,8 @@ static int mxs_nand_init(void)
|
||||
/* identify flash device */
|
||||
if (mxs_flash_ident(mtd)) {
|
||||
printf("Failed to identify\n");
|
||||
return -1;
|
||||
nand_chip.numchips = 0; /* If fail, don't use nand */
|
||||
return;
|
||||
}
|
||||
|
||||
/* allocate and initialize buffers */
|
||||
@ -202,8 +203,6 @@ static int mxs_nand_init(void)
|
||||
mtd->size = nand_chip.chipsize;
|
||||
nand_chip.scan_bbt(mtd);
|
||||
mxs_nand_setup_ecc(mtd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
|
||||
@ -213,9 +212,9 @@ int nand_spl_load_image(uint32_t offs, unsigned int size, void *buf)
|
||||
unsigned int nand_page_per_block;
|
||||
unsigned int sz = 0;
|
||||
|
||||
if (mxs_nand_init())
|
||||
return -ENODEV;
|
||||
chip = mtd_to_nand(mtd);
|
||||
if (!chip->numchips)
|
||||
return -ENODEV;
|
||||
page = offs >> chip->page_shift;
|
||||
nand_page_per_block = mtd->erasesize / mtd->writesize;
|
||||
|
||||
@ -256,10 +255,6 @@ int nand_default_bbt(struct mtd_info *mtd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nand_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void nand_deselect(void)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user