@@ -1235,6 +1235,30 @@ static int bch_load_bbt(struct nandi_controller *nandi,
return 0;
}
+static int bch_scan_bbt(struct mtd_info *mtd)
+{
+ struct nand_chip *chip = mtd->priv;
+ struct nandi_controller *nandi = chip->priv;
+ struct nandi_bbt_info *bbt_info = &nandi->info.bbt_info;
+ int err;
+ /* Load Flash-resident BBT */
+ err = bch_load_bbt(nandi, bbt_info);
+ if (err) {
+ dev_warn(nandi->dev,
+ "failed to find BBTs:"
+ " scanning device for bad-block markers\n");
+
+ /* Scan, build, and write BBT */
+ nandi_scan_build_bbt(nandi, bbt_info);
+ err = bch_update_bbts(nandi, bbt_info, NAND_IBBT_UPDATE_BOTH,
+ bbt_info->bbt_vers[0] + 1);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
/*
* Initialisation
*/
@@ -1318,6 +1342,8 @@ static void nandi_set_mtd_defaults(struct nandi_controller *nandi,
chip->ecc.read_page = bch_read;
chip->write_page = bch_write;
+
+ chip->scan_bbt = bch_scan_bbt;
}
/*
If load of existing BBT fails (first run), scan device for factory-set BBMs (Bad-Block Markers) and create a new flash-resident. Signed-off-by: Lee Jones <lee.jones@linaro.org> --- drivers/mtd/nand/stm_nand_bch.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)