[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240124183207.5898cbfd@xps-13>
Date: Wed, 24 Jan 2024 18:32:07 +0100
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: David Regan <dregan@...adcom.com>
Cc: dregan@...l.com, richard@....at, vigneshr@...com, robh+dt@...nel.org,
krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org,
computersforpeace@...il.com, kdasu.kdev@...il.com,
linux-mtd@...ts.infradead.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, joel.peshkin@...adcom.com,
tomer.yacoby@...adcom.com, dan.beygelman@...adcom.com,
william.zhang@...adcom.com, anand.gore@...adcom.com,
kursad.oney@...adcom.com, florian.fainelli@...adcom.com, rafal@...ecki.pl,
bcm-kernel-feedback-list@...adcom.com, andre.przywara@....com,
baruch@...s.co.il, linux-arm-kernel@...ts.infradead.org,
dan.carpenter@...aro.org
Subject: Re: [PATCH v3 06/10] mtd: rawnand: brcmnand: Add support for
getting ecc setting from strap
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
Powered by blists - more mailing lists