1.Support SPI Nand and SLC Nand in mtd case;
2.Only support address and length erasesize aligned case;
Change-Id: I8e76274677c153fb61616ebf320e1b86d5060439
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Prepare to read data, then data is transmitted in background.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Iab560f7f903549a0b6c27f7e8e2ac984ae2ac75c
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
The default ubi part info must be corrected while the part info will
be changed when enable a/b.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: I84db2e284f732f62014d3d14d99217fb707b85c0
1.Check map table block address overflow
2.Reinit map table original value
Change-Id: I4450b5a6856e38e2624da9db31d5eb98de7f5696
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
1.Logical offset should not mix with map address
2.Format with nand_read_skip_bad
Change-Id: I0e5adec374ce4de437e4ce7368caec4c7c07e83b
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
The blk_dread will occor error if the image is packed with multiple
firmwares, for example boot.img, when nand or spi nand have bad block.
So call mtd_blk_map_table_init to remap part address to make sure
reading correct data.
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Change-Id: Icebc6b1c5a10758efa615424d0706b9ed6ec23ad
1.SPI Nand MTD partition bad block will not be detected if the address
isn't begin with the partition first block.
2.To avoid this problem, we should use map partition block address to
get right data.
3.It's compatible if the map table isn't initialed.
Change-Id: I11858b9b30a8fffecdbad804b1bad7b247b51d23
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Find the first useful block in the end, and it is the end of
the nand storage.
Change-Id: I83203cbd764b2a6a6baa69694407f75339f176d5
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Since func nand_read_skip_bad is used in uboot, so just build it in
uboot build. And use func mtd_read to replace it.
Change-Id: Ic5e161f7f03cd2da0099891812360af67a2b9db8
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Since mtd_read() can not skip bad block if meet bad block, so use
nand_read_skip_bad().
Change-Id: Ic2364b7f29de193412353fad36c86dc6e289e02d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
In the nand mtd, we will use chip info to operate nand, and get the chip
through mtd_to_nand(). So we should get mtd through dev_get_priv() but not
dev_get_uclass_platdata.
Change-Id: I1bacbec49158d04dc947a880dbe3a8043fe3123d
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Reserve one block space for gpt table in mtd part info,
otherwise gpt table will be erased by user program.
Change-Id: I0545c55f7da2b5518ab766ed763b074b7558fd4f
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
The desc->lba is based on mtd->size: desc->lba = mtd->size >> 9;
If the mtd storage is spi nand or nand flash, reserve 4 blocks
for BBT(Bad Block Table). Then desc->lba is
desc->lba = (mtd->size >> 9) - (mtd->erasesize >> 9) * 4;
Change-Id: I70702623895fe05cec614c4c3ca5f3f6c41d26ca
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>
Attach the mtd driver to block device, then we can call common interface
(blk_dread & blk_dwrite) to operate storage in application layer.
Usage:
Open CONFIG_MTD_BLK & CONFIG_MTD.
Change-Id: I47a969322e2d20c12d46898bdc88f4104e1a15bf
Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com>