Hi David, > @@ -2622,19 +2667,43 @@ static int brcmnand_setup_dev(struct brcmnand_host *host) > nanddev_get_memorg(&chip->base); > struct brcmnand_controller *ctrl = host->ctrl; > struct brcmnand_cfg *cfg = &host->hwcfg; > - char msg[128]; > + struct device_node *np = nand_get_flash_node(chip); > u32 offs, tmp, oob_sector; > - int ret; > + int ret, sector_size_1k = 0; > + bool use_strap = false; > + char msg[128]; > > memset(cfg, 0, sizeof(*cfg)); > + use_strap = of_property_read_bool(np, "brcm,nand-ecc-use-strap"); > > - ret = of_property_read_u32(nand_get_flash_node(chip), > - "brcm,nand-oob-sector-size", > + /* > + * Set ECC size and strength based on hw configuration from strap > + * if device tree does not specify them and use strap property is set > + * If ecc strength is set in dts, don't use strap setting. > + */ You would have to use the strap settings only if the property is set. If not property is set, the default from the core should apply I guess. > + if (chip->ecc.strength) > + use_strap = 0; > + > + if (use_strap) { > + chip->ecc.strength = brcmnand_get_ecc_strength(host); > + sector_size_1k = brcmnand_get_sector_size_1k(host); > + if (chip->ecc.size == 0) { > + if (sector_size_1k < 0) > + chip->ecc.size = 512; > + else > + chip->ecc.size = 512 << sector_size_1k; > + } > + } > + > + ret = of_property_read_u32(np, "brcm,nand-oob-sector-size", > &oob_sector); > if (ret) { > - /* Use detected size */ > - cfg->spare_area_size = mtd->oobsize / > - (mtd->writesize >> FC_SHIFT); > + if (use_strap) > + cfg->spare_area_size = brcmnand_get_spare_size(host); > + else > + /* Use detected size */ > + cfg->spare_area_size = mtd->oobsize / > + (mtd->writesize >> FC_SHIFT); > } else { > cfg->spare_area_size = oob_sector; > } Thanks, Miquèl