devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: David Regan <dregan@broadcom.com>
Cc: dregan@mail.com, richard@nod.at, vigneshr@ti.com,
	robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
	conor+dt@kernel.org, computersforpeace@gmail.com,
	kdasu.kdev@gmail.com, linux-mtd@lists.infradead.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	joel.peshkin@broadcom.com, tomer.yacoby@broadcom.com,
	dan.beygelman@broadcom.com, william.zhang@broadcom.com,
	anand.gore@broadcom.com, kursad.oney@broadcom.com,
	florian.fainelli@broadcom.com, rafal@milecki.pl,
	bcm-kernel-feedback-list@broadcom.com, andre.przywara@arm.com,
	baruch@tkos.co.il, linux-arm-kernel@lists.infradead.org,
	dan.carpenter@linaro.org
Subject: Re: [PATCH v3 06/10] mtd: rawnand: brcmnand: Add support for getting ecc setting from strap
Date: Wed, 24 Jan 2024 18:32:07 +0100	[thread overview]
Message-ID: <20240124183207.5898cbfd@xps-13> (raw)
In-Reply-To: <20240124030458.98408-7-dregan@broadcom.com>

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

  reply	other threads:[~2024-01-24 17:32 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24  3:04 [PATCH v3 00/10] mtd: rawnand: brcmnand: driver and doc updates David Regan
2024-01-24  3:04 ` [PATCH v3 01/10] dt-bindings: mtd: brcmnand: Updates for bcmbca SoCs David Regan
2024-01-24 17:24   ` Conor Dooley
2024-01-25  3:01     ` William Zhang
2024-01-25 19:51       ` Conor Dooley
2024-01-26  1:55         ` William Zhang
2024-01-26 16:46           ` Conor Dooley
2024-01-26 18:09             ` William Zhang
2024-01-24 17:24   ` Conor Dooley
2024-01-24 17:34   ` Miquel Raynal
2024-01-25  3:14     ` William Zhang
2024-01-24  3:04 ` [PATCH v3 02/10] ARM: dts: broadcom: bcmbca: Add NAND controller node David Regan
2024-01-24 17:30   ` Miquel Raynal
2024-01-25  3:09     ` William Zhang
2024-01-25  3:34       ` Florian Fainelli
2024-01-25  5:53         ` William Zhang
2024-01-25  9:20           ` Miquel Raynal
2024-01-25 18:14             ` William Zhang
2024-01-24  3:04 ` [PATCH v3 03/10] arm64: " David Regan
2024-01-24  3:04 ` [PATCH v3 04/10] mtd: rawnand: brcmnand: Rename bcm63138 nand driver David Regan
2024-01-24  3:04 ` [PATCH v3 05/10] mtd: rawnand: brcmnand: Add BCMBCA read data bus interface David Regan
2024-01-24  3:04 ` [PATCH v3 06/10] mtd: rawnand: brcmnand: Add support for getting ecc setting from strap David Regan
2024-01-24 17:32   ` Miquel Raynal [this message]
2024-01-25  3:13     ` William Zhang
2024-01-24  3:04 ` [PATCH v3 07/10] mtd: rawnand: brcmnand: Support write protection setting from dts David Regan
2024-01-24  3:04 ` [PATCH v3 08/10] mtd: rawnand: brcmnand: exec_op helper functions return type fixes David Regan
2024-01-24 17:35   ` Miquel Raynal
2024-01-24  3:04 ` [PATCH v3 09/10] mtd: rawnand: brcmnand: update log level messages David Regan
2024-01-24 17:37   ` Miquel Raynal
2024-01-25 18:47     ` David Regan
2024-01-24  3:04 ` [PATCH v3 10/10] mtd: rawnand: brcmnand: allow for on-die ecc David Regan
2024-01-24 17:40   ` Miquel Raynal
2024-01-25 19:47     ` David Regan
2024-01-26  6:19       ` Miquel Raynal
2024-01-26 19:57         ` David Regan
2024-01-29 10:52           ` Miquel Raynal
2024-01-30  8:11             ` William Zhang
2024-01-30 11:01               ` Miquel Raynal
2024-01-30 15:26                 ` David Regan
2024-01-30 18:55                   ` Miquel Raynal
2024-02-01  6:48                     ` William Zhang
2024-02-01  8:25                       ` Miquel Raynal
2024-02-01 18:53                         ` William Zhang
2024-02-02 17:38                         ` David Regan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240124183207.5898cbfd@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=anand.gore@broadcom.com \
    --cc=andre.przywara@arm.com \
    --cc=baruch@tkos.co.il \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=computersforpeace@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=dan.beygelman@broadcom.com \
    --cc=dan.carpenter@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dregan@broadcom.com \
    --cc=dregan@mail.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=joel.peshkin@broadcom.com \
    --cc=kdasu.kdev@gmail.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kursad.oney@broadcom.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=rafal@milecki.pl \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=tomer.yacoby@broadcom.com \
    --cc=vigneshr@ti.com \
    --cc=william.zhang@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).