|
|
@@ -2512,10 +2512,10 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
{
|
|
|
- struct nand_chip *chip = mtd->priv;
|
|
|
+ struct nand_chip *chip = mtd_to_nand(mtd);
|
|
|
+ int chipnr = (int)(to >> chip->chip_shift);
|
|
|
struct mtd_oob_ops ops;
|
|
|
int ret;
|
|
|
-
|
|
|
-@@ -2722,15 +2757,12 @@ static int nand_do_write_oob(struct mtd_
|
|
|
+@@ -2725,15 +2760,12 @@ static int nand_do_write_oob(struct mtd_
|
|
|
struct mtd_oob_ops *ops)
|
|
|
{
|
|
|
int chipnr, page, status, len;
|
|
|
@@ -2533,7 +2533,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
/* Do not allow write past end of page */
|
|
|
if ((ops->ooboffs + ops->ooblen) > len) {
|
|
|
-@@ -2847,7 +2879,7 @@ out:
|
|
|
+@@ -2850,7 +2882,7 @@ out:
|
|
|
*/
|
|
|
static int single_erase(struct mtd_info *mtd, int page)
|
|
|
{
|
|
|
@@ -2542,7 +2542,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
/* Send commands to erase a block */
|
|
|
chip->cmdfunc(mtd, NAND_CMD_ERASE1, -1, page);
|
|
|
chip->cmdfunc(mtd, NAND_CMD_ERASE2, -1, -1);
|
|
|
-@@ -2879,7 +2911,7 @@ int nand_erase_nand(struct mtd_info *mtd
|
|
|
+@@ -2882,7 +2914,7 @@ int nand_erase_nand(struct mtd_info *mtd
|
|
|
int allowbbt)
|
|
|
{
|
|
|
int page, status, pages_per_block, ret, chipnr;
|
|
|
@@ -2551,7 +2551,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
loff_t len;
|
|
|
|
|
|
pr_debug("%s: start = 0x%012llx, len = %llu\n",
|
|
|
-@@ -2918,7 +2950,7 @@ int nand_erase_nand(struct mtd_info *mtd
|
|
|
+@@ -2921,7 +2953,7 @@ int nand_erase_nand(struct mtd_info *mtd
|
|
|
while (len) {
|
|
|
/* Check if we have a bad block, we do not erase bad blocks! */
|
|
|
if (nand_block_checkbad(mtd, ((loff_t) page) <<
|
|
|
@@ -2560,7 +2560,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
pr_warn("%s: attempt to erase a bad block at page 0x%08x\n",
|
|
|
__func__, page);
|
|
|
instr->state = MTD_ERASE_FAILED;
|
|
|
-@@ -3005,7 +3037,20 @@ static void nand_sync(struct mtd_info *m
|
|
|
+@@ -3008,7 +3040,20 @@ static void nand_sync(struct mtd_info *m
|
|
|
*/
|
|
|
static int nand_block_isbad(struct mtd_info *mtd, loff_t offs)
|
|
|
{
|
|
|
@@ -2582,7 +2582,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
-@@ -3094,7 +3139,7 @@ static int nand_suspend(struct mtd_info
|
|
|
+@@ -3097,7 +3142,7 @@ static int nand_suspend(struct mtd_info
|
|
|
*/
|
|
|
static void nand_resume(struct mtd_info *mtd)
|
|
|
{
|
|
|
@@ -2591,7 +2591,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
if (chip->state == FL_PM_SUSPENDED)
|
|
|
nand_release_device(mtd);
|
|
|
-@@ -3266,7 +3311,7 @@ ext_out:
|
|
|
+@@ -3269,7 +3314,7 @@ ext_out:
|
|
|
|
|
|
static int nand_setup_read_retry_micron(struct mtd_info *mtd, int retry_mode)
|
|
|
{
|
|
|
@@ -2600,7 +2600,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
uint8_t feature[ONFI_SUBFEATURE_PARAM_LEN] = {retry_mode};
|
|
|
|
|
|
return chip->onfi_set_features(mtd, chip, ONFI_FEATURE_ADDR_READ_RETRY,
|
|
|
-@@ -3937,10 +3982,13 @@ ident_done:
|
|
|
+@@ -3940,10 +3985,13 @@ ident_done:
|
|
|
return type;
|
|
|
}
|
|
|
|
|
|
@@ -2617,7 +2617,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
if (of_get_nand_bus_width(dn) == 16)
|
|
|
chip->options |= NAND_BUSWIDTH_16;
|
|
|
-@@ -3949,6 +3997,7 @@ static int nand_dt_init(struct mtd_info
|
|
|
+@@ -3952,6 +4000,7 @@ static int nand_dt_init(struct mtd_info
|
|
|
chip->bbt_options |= NAND_BBT_USE_FLASH;
|
|
|
|
|
|
ecc_mode = of_get_nand_ecc_mode(dn);
|
|
|
@@ -2625,7 +2625,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
ecc_strength = of_get_nand_ecc_strength(dn);
|
|
|
ecc_step = of_get_nand_ecc_step_size(dn);
|
|
|
|
|
|
-@@ -3961,6 +4010,9 @@ static int nand_dt_init(struct mtd_info
|
|
|
+@@ -3964,6 +4013,9 @@ static int nand_dt_init(struct mtd_info
|
|
|
if (ecc_mode >= 0)
|
|
|
chip->ecc.mode = ecc_mode;
|
|
|
|
|
|
@@ -2635,7 +2635,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
if (ecc_strength >= 0)
|
|
|
chip->ecc.strength = ecc_strength;
|
|
|
|
|
|
-@@ -3984,15 +4036,16 @@ int nand_scan_ident(struct mtd_info *mtd
|
|
|
+@@ -3987,15 +4039,16 @@ int nand_scan_ident(struct mtd_info *mtd
|
|
|
struct nand_flash_dev *table)
|
|
|
{
|
|
|
int i, nand_maf_id, nand_dev_id;
|
|
|
@@ -2658,7 +2658,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
if (!mtd->name && mtd->dev.parent)
|
|
|
mtd->name = dev_name(mtd->dev.parent);
|
|
|
-@@ -4055,7 +4108,7 @@ EXPORT_SYMBOL(nand_scan_ident);
|
|
|
+@@ -4058,7 +4111,7 @@ EXPORT_SYMBOL(nand_scan_ident);
|
|
|
*/
|
|
|
static bool nand_ecc_strength_good(struct mtd_info *mtd)
|
|
|
{
|
|
|
@@ -2667,7 +2667,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
struct nand_ecc_ctrl *ecc = &chip->ecc;
|
|
|
int corr, ds_corr;
|
|
|
|
|
|
-@@ -4083,10 +4136,10 @@ static bool nand_ecc_strength_good(struc
|
|
|
+@@ -4086,10 +4139,10 @@ static bool nand_ecc_strength_good(struc
|
|
|
*/
|
|
|
int nand_scan_tail(struct mtd_info *mtd)
|
|
|
{
|
|
|
@@ -2680,7 +2680,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
/* New bad blocks should be marked in OOB, flash-based BBT, or both */
|
|
|
BUG_ON((chip->bbt_options & NAND_BBT_NO_OOB_BBM) &&
|
|
|
-@@ -4113,19 +4166,15 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4116,19 +4169,15 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
/*
|
|
|
* If no default placement scheme is given, select an appropriate one.
|
|
|
*/
|
|
|
@@ -2703,7 +2703,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
break;
|
|
|
default:
|
|
|
pr_warn("No oob scheme defined for oobsize %d\n",
|
|
|
-@@ -4168,7 +4217,7 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4171,7 +4220,7 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
ecc->write_oob = nand_write_oob_std;
|
|
|
if (!ecc->read_subpage)
|
|
|
ecc->read_subpage = nand_read_subpage;
|
|
|
@@ -2712,7 +2712,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
ecc->write_subpage = nand_write_subpage_hwecc;
|
|
|
|
|
|
case NAND_ECC_HW_SYNDROME:
|
|
|
-@@ -4246,10 +4295,8 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4249,10 +4298,8 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
}
|
|
|
|
|
|
/* See nand_bch_init() for details. */
|
|
|
@@ -2725,7 +2725,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
if (!ecc->priv) {
|
|
|
pr_warn("BCH ECC initialization failed!\n");
|
|
|
BUG();
|
|
|
-@@ -4280,20 +4327,9 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4283,20 +4330,9 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
if (!ecc->write_oob_raw)
|
|
|
ecc->write_oob_raw = ecc->write_oob;
|
|
|
|
|
|
@@ -2749,7 +2749,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
|
|
|
/*
|
|
|
* Set the number of read / write steps for one page depending on ECC
|
|
|
-@@ -4306,6 +4342,21 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4309,6 +4345,21 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
}
|
|
|
ecc->total = ecc->steps * ecc->bytes;
|
|
|
|
|
|
@@ -2771,7 +2771,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
/* Allow subpage writes up to ecc.steps. Not possible for MLC flash */
|
|
|
if (!(chip->options & NAND_NO_SUBPAGE_WRITE) && nand_is_slc(chip)) {
|
|
|
switch (ecc->steps) {
|
|
|
-@@ -4362,10 +4413,6 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
+@@ -4365,10 +4416,6 @@ int nand_scan_tail(struct mtd_info *mtd)
|
|
|
mtd->_block_markbad = nand_block_markbad;
|
|
|
mtd->writebufsize = mtd->writesize;
|
|
|
|
|
|
@@ -2782,7 +2782,7 @@ Signed-off-by: John Crispin <[email protected]>
|
|
|
/*
|
|
|
* Initialize bitflip_threshold to its default prior scan_bbt() call.
|
|
|
* scan_bbt() might invoke mtd_read(), thus bitflip_threshold must be
|
|
|
-@@ -4421,7 +4468,7 @@ EXPORT_SYMBOL(nand_scan);
|
|
|
+@@ -4424,7 +4471,7 @@ EXPORT_SYMBOL(nand_scan);
|
|
|
*/
|
|
|
void nand_release(struct mtd_info *mtd)
|
|
|
{
|