Messages in this thread | ![/](/images/icornerl.gif) | | Date | Wed, 24 Jan 2024 19:13:45 -0800 | Subject | Re: [PATCH v3 06/10] mtd: rawnand: brcmnand: Add support for getting ecc setting from strap | From | William Zhang <> |
| |
Hi Miquel,
On 1/24/24 09:32, Miquel Raynal wrote: > 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. > Maybe the comment confuse you... I will make it more clear. But the logic here is exactly what you said. If no properties are set, the core value is already set in chip->ecc.strength and chip->ecc.size and it clear the use_strap flag too.
>> + 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 [unhandled content-type:application/pkcs7-signature] | ![\](/images/icornerr.gif) |