The Rockchip boot ROM only checks for nand chip 0 and with
reduced ecc strength. Currently only the read page functions
have a condition check added. Fix by adding the same condition
to all read and write page functions.
The NAND_IS_BOOT_MEDIUM option was introduced more recently
then this driver. Use it to behave identical with the Linux
driver.
Fixes: b12dc5d6fa76 ("mtd: nand: NFC drivers for RK3308, RK2928 and others")
Signed-off-by: Johan Jonker <[email protected]>
---
drivers/mtd/nand/raw/rockchip_nfc.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/raw/rockchip_nfc.c
b/drivers/mtd/nand/raw/rockchip_nfc.c
index ea8e67d1a23e..e788fda22a95 100644
--- a/drivers/mtd/nand/raw/rockchip_nfc.c
+++ b/drivers/mtd/nand/raw/rockchip_nfc.c
@@ -440,7 +440,8 @@ static int rk_nfc_write_page_raw(struct mtd_info *mtd,
int i, pages_per_blk;
pages_per_blk = mtd->erasesize / mtd->writesize;
- if ((page < (pages_per_blk * rknand->boot_blks)) &&
+ if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+ (page < (pages_per_blk * rknand->boot_blks)) &&
rknand->boot_ecc != ecc->strength) {
/*
* There's currently no method to notify the MTD framework that
@@ -560,7 +561,8 @@ static int rk_nfc_write_page_hwecc(struct mtd_info *mtd,
*
* Configure the ECC algorithm supported by the boot ROM.
*/
- if (page < (pages_per_blk * rknand->boot_blks)) {
+ if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+ (page < (pages_per_blk * rknand->boot_blks))) {
boot_rom_mode = 1;
if (rknand->boot_ecc != ecc->strength)
rk_nfc_hw_ecc_setup(chip, rknand->boot_ecc);
@@ -624,8 +626,8 @@ static int rk_nfc_read_page_raw(struct mtd_info *mtd,
int i, pages_per_blk;
pages_per_blk = mtd->erasesize / mtd->writesize;
- if ((page < (pages_per_blk * rknand->boot_blks)) &&
- nfc->selected_bank == 0 &&
+ if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+ (page < (pages_per_blk * rknand->boot_blks)) &&
rknand->boot_ecc != ecc->strength) {
/*
* There's currently no method to notify the MTD framework that
@@ -700,8 +702,8 @@ static int rk_nfc_read_page_hwecc(struct mtd_info *mtd,
* are used by the boot ROM.
* Configure the ECC algorithm supported by the boot ROM.
*/
- if (page < (pages_per_blk * rknand->boot_blks) &&
- nfc->selected_bank == 0) {
+ if ((chip->options & NAND_IS_BOOT_MEDIUM) &&
+ (page < (pages_per_blk * rknand->boot_blks))) {
boot_rom_mode = 1;
if (rknand->boot_ecc != ecc->strength)
rk_nfc_hw_ecc_setup(chip, rknand->boot_ecc);
--
2.39.5