Skip to contentSkip to conversation

dt-bindings: mtd: brcmnand: Make nand-ecc-strength and nand-ecc-step-size optional

PATCH Superseded Kamal Dasu 3 participants 8 messages May 17, 2019 – Jun 13, 2019

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kamal Dasu

author
#0 lore raw

PATCH 1/2 dt-bindings: mtd: brcmnand: Make nand-ecc-strength and nand-ecc-step-size optional

nand-ecc-strength and nand-ecc-step-size can be made optional as brcmanand driver can support using the nand_base driver detected values.

---
 Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt +2 -2
index bcda1df..29feaba 100644
@@ -101,10 +101,10 @@ Required properties:
                               number (e.g., 0, 1, 2, etc.)
 - #address-cells            : see partition.txt
 - #size-cells               : see partition.txt
-- nand-ecc-strength         : see nand.txt
-- nand-ecc-step-size        : must be 512 or 1024. See nand.txt
 
 Optional properties:
+- nand-ecc-strength         : see nand.txt
+- nand-ecc-step-size        : must be 512 or 1024. See nand.txt
 - nand-on-flash-bbt         : boolean, to enable the on-flash BBT for this
                               chip-select. See nand.txt
 - brcm,nand-oob-sector-size : integer, to denote the spare area sector size
Signature · 1 line
1.9.0.138.g2de3478
author
#1 lore raw

PATCH 2/2 mtd: nand: raw: brcmnand: fallback to detected ecc-strength, ecc-step-size

This change supports nand-ecc-step-size and nand-ecc-strenght fields in brcmnand dt node to be optional.
see: Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

If both nand-ecc-strength and nand-ecc-step-size are not specified in device tree node for NAND, nand_base driver does detect onfi ext ecc info from ONFI extended parameter page for parts using ONFI >= 2.1. In case of non-onfi NAND there could be a nand_id table entry with the ecc info. If there is a valid device tree entry for nand-ecc-strength and nand-ecc-step-size fields it still shall override the detected values.

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +10 -0
index ce0b8ff..e967b30 100644
@@ -2144,6 +2144,16 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)
 		return -EINVAL;
 	}
 
+	if (!(chip->ecc.size > 0 && chip->ecc.strength > 0) &&
+	    (chip->base.eccreq.strength > 0 &&
+	     chip->base.eccreq.step_size > 0)) {
+		/* use detected ecc parameters */
+		chip->ecc.size = chip->base.eccreq.step_size;
+		chip->ecc.strength = chip->base.eccreq.strength;
+		pr_info("Using detected nand-ecc-step-size %d, nand-ecc-strength %d\n",
+			chip->ecc.size, chip->ecc.strength);
+	}
+
 	switch (chip->ecc.size) {
 	case 512:
 		if (chip->ecc.algo == NAND_ECC_HAMMING)
Signature · 1 line
1.9.0.138.g2de3478
maintainer
#2 lore raw

Re: [PATCH 2/2] mtd: nand: raw: brcmnand: fallback to detected ecc-strength, ecc-step-size

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Fri, 17 May 2019 14:29:55 -0400:

Quoted 1 line

This change supports nand-ecc-step-size and nand-ecc-strenght fields in

strength

Quoted 1 line

brcmnand dt node to be optional.

DT ^ extra space

Quoted 4 lines

see: Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

If both nand-ecc-strength and nand-ecc-step-size are not specified in device tree node for NAND, nand_base driver does detect onfi ext ecc

s/nand_base driver/the raw NAND layer/
s/onfi/ONFI/
s/ecc/ECC/

What is "ext"? Please use plain English here.

Quoted 1 line

info from ONFI extended parameter page for parts using ONFI >= 2.1. In

s/info/information/

Quoted 1 line

case of non-onfi NAND there could be a nand_id table entry with the ecc

s/ecc/ECC/

Quoted 13 lines

info. If there is a valid device tree entry for nand-ecc-strength and nand-ecc-step-size fields it still shall override the detected values.

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index ce0b8ff..e967b30 100644

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2147

Quoted 4 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -0
@@ -2144,6 +2144,16 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)
 		return -EINVAL;
 	}
 
+	if (!(chip->ecc.size > 0 && chip->ecc.strength > 0) &&

Is the case where only size OR strength is valid handled?

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2150

Quoted 3 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +3 -0
+	    (chip->base.eccreq.strength > 0 &&
+	     chip->base.eccreq.step_size > 0)) {
+		/* use detected ecc parameters */

Use ECC

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2159

Quoted 9 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -0
+		chip->ecc.size = chip->base.eccreq.step_size;
+		chip->ecc.strength = chip->base.eccreq.strength;
+		pr_info("Using detected nand-ecc-step-size %d, nand-ecc-strength %d\n",
+			chip->ecc.size, chip->ecc.strength);
+	}
+
 	switch (chip->ecc.size) {
 	case 512:
 		if (chip->ecc.algo == NAND_ECC_HAMMING)

Thanks,
Miquèl

author
#3 lore raw

Re: [PATCH 2/2] mtd: nand: raw: brcmnand: fallback to detected ecc-strength, ecc-step-size

Will make the changes and send a V2 patch.

Quoted 49 lines · Miquel Raynal

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Fri, 17 May 2019 14:29:55 -0400:

Quoted 1 line

This change supports nand-ecc-step-size and nand-ecc-strenght fields in

strength

Quoted 1 line

brcmnand dt node to be optional.

DT ^ extra space

Quoted 4 lines

see: Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

If both nand-ecc-strength and nand-ecc-step-size are not specified in device tree node for NAND, nand_base driver does detect onfi ext ecc

s/nand_base driver/the raw NAND layer/
s/onfi/ONFI/
s/ecc/ECC/

What is "ext"? Please use plain English here.

Quoted 1 line

info from ONFI extended parameter page for parts using ONFI >= 2.1. In

s/info/information/

Quoted 1 line

case of non-onfi NAND there could be a nand_id table entry with the ecc

s/ecc/ECC/

Quoted 16 lines

info. If there is a valid device tree entry for nand-ecc-strength and nand-ecc-step-size fields it still shall override the detected values.

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index ce0b8ff..e967b30 100644
@@ -2144,6 +2144,16 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)
              return -EINVAL;
      }
 
Quoted 3 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2147

Quoted 1 line
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -0
+     if (!(chip->ecc.size > 0 && chip->ecc.strength > 0) &&

Is the case where only size OR strength is valid handled?

Both strength and need to be valid, else the driver will behave like before and will fail the probe.

Quoted 18 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2150

Quoted 4 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +3 -0
+         (chip->base.eccreq.strength > 0 &&
+          chip->base.eccreq.step_size > 0)) {
+             /* use detected ecc parameters */

Use ECC

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2159

Quoted 9 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -0
+             chip->ecc.size = chip->base.eccreq.step_size;
+             chip->ecc.strength = chip->base.eccreq.strength;
+             pr_info("Using detected nand-ecc-step-size %d, nand-ecc-strength %d\n",
+                     chip->ecc.size, chip->ecc.strength);
+     }
+
      switch (chip->ecc.size) {
      case 512:
              if (chip->ecc.algo == NAND_ECC_HAMMING)
Quoted 2 lines

Thanks,
Miquèl

Kamal

maintainer
#4 lore raw

Re: [PATCH 2/2] mtd: nand: raw: brcmnand: fallback to detected ecc-strength, ecc-step-size

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Mon, 20 May 2019 13:31:52 -0400:

Quoted 52 lines

Will make the changes and send a V2 patch.

Quoted 49 lines · Miquel Raynal

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Fri, 17 May 2019 14:29:55 -0400:

Quoted 1 line

This change supports nand-ecc-step-size and nand-ecc-strenght fields in

strength

Quoted 1 line

brcmnand dt node to be optional.

DT ^ extra space

Quoted 4 lines

see: Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

If both nand-ecc-strength and nand-ecc-step-size are not specified in device tree node for NAND, nand_base driver does detect onfi ext ecc

s/nand_base driver/the raw NAND layer/
s/onfi/ONFI/
s/ecc/ECC/

What is "ext"? Please use plain English here.

Quoted 1 line

info from ONFI extended parameter page for parts using ONFI >= 2.1. In

s/info/information/

Quoted 1 line

case of non-onfi NAND there could be a nand_id table entry with the ecc

s/ecc/ECC/

Quoted 16 lines

info. If there is a valid device tree entry for nand-ecc-strength and nand-ecc-step-size fields it still shall override the detected values.

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index ce0b8ff..e967b30 100644
@@ -2144,6 +2144,16 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)
              return -EINVAL;
      }
 
Quoted 6 lines
Quoted 3 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2147

Quoted 1 line
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -0
+     if (!(chip->ecc.size > 0 && chip->ecc.strength > 0) &&  

Is the case where only size OR strength is valid handled?

Both strength and need to be valid, else the driver will behave like before and will fail the probe.

Yes, but you do not handle the case when either strength OR size is not valid but the other one is. Is it one purpose?

Quoted 19 lines
Quoted 19 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2150

Quoted 5 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +3 -0
+         (chip->base.eccreq.strength > 0 &&
+          chip->base.eccreq.step_size > 0)) {
+             /* use detected ecc parameters */  

Use ECC

Quoted 9 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -0
+             chip->ecc.size = chip->base.eccreq.step_size;
+             chip->ecc.strength = chip->base.eccreq.strength;
+             pr_info("Using detected nand-ecc-step-size %d, nand-ecc-strength %d\n",
+                     chip->ecc.size, chip->ecc.strength);
+     }
+
      switch (chip->ecc.size) {
      case 512:
              if (chip->ecc.algo == NAND_ECC_HAMMING)  
Quoted 4 lines
Quoted 2 lines

Thanks,
Miquèl

Kamal

Thanks,
Miquèl

author
#5 lore raw

Re: [PATCH 2/2] mtd: nand: raw: brcmnand: fallback to detected ecc-strength, ecc-step-size

Quoted 62 lines · Miquel Raynal

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Mon, 20 May 2019 13:31:52 -0400:

Quoted 56 lines

Will make the changes and send a V2 patch.

Quoted 52 lines · Miquel Raynal

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Fri, 17 May 2019 14:29:55 -0400:

Quoted 1 line

This change supports nand-ecc-step-size and nand-ecc-strenght fields in

strength

Quoted 1 line

brcmnand dt node to be optional.

DT ^ extra space

Quoted 4 lines

see: Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt

If both nand-ecc-strength and nand-ecc-step-size are not specified in device tree node for NAND, nand_base driver does detect onfi ext ecc

s/nand_base driver/the raw NAND layer/
s/onfi/ONFI/
s/ecc/ECC/

What is "ext"? Please use plain English here.

Quoted 1 line

info from ONFI extended parameter page for parts using ONFI >= 2.1. In

s/info/information/

Quoted 1 line

case of non-onfi NAND there could be a nand_id table entry with the ecc

s/ecc/ECC/

Quoted 13 lines

info. If there is a valid device tree entry for nand-ecc-strength and nand-ecc-step-size fields it still shall override the detected values.

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index ce0b8ff..e967b30 100644

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2147

Quoted 4 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +1 -0
@@ -2144,6 +2144,16 @@ static int brcmnand_setup_dev(struct brcmnand_host *host)
              return -EINVAL;
      }
 
+     if (!(chip->ecc.size > 0 && chip->ecc.strength > 0) &&

Is the case where only size OR strength is valid handled?

Quoted 6 lines
Quoted 2 lines

Both strength and need to be valid, else the driver will behave like before and will fail the probe.

Yes, but you do not handle the case when either strength OR size is not valid but the other one is. Is it one purpose?

If I understand you want me to use the following check:

if (ecc->mode != NAND_ECC_NONE && (!ecc->size || !ecc->strength)) {

if (chip->base.eccreq.step_size && chip->base.eccreq.strength) {
     /* use the base values */
}
Quoted 22 lines
Quoted 22 lines
Quoted 21 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2150

Quoted 5 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +3 -0
+         (chip->base.eccreq.strength > 0 &&
+          chip->base.eccreq.step_size > 0)) {
+             /* use detected ecc parameters */

Use ECC

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_setup_dev(struct brcmnand_host *host) · line 2159

Quoted 9 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +6 -0
+             chip->ecc.size = chip->base.eccreq.step_size;
+             chip->ecc.strength = chip->base.eccreq.strength;
+             pr_info("Using detected nand-ecc-step-size %d, nand-ecc-strength %d\n",
+                     chip->ecc.size, chip->ecc.strength);
+     }
+
      switch (chip->ecc.size) {
      case 512:
              if (chip->ecc.algo == NAND_ECC_HAMMING)

Thanks,
Miquèl

Quoted 7 lines
Quoted 1 line

Kamal

Thanks,
Miquèl

Kamal

maintainer Reviewed-by on v1 1/2
#6 lore raw
In reply to Kamal Dasu

Hi Kamal,

Kamal Dasu <[email protected]> wrote on Fri, 17 May 2019 14:29:54 -0400:

Quoted 2 lines

nand-ecc-strength and nand-ecc-step-size can be made optional as brcmanand driver can support using the nand_base driver detected

^ typo raw NAND layer

Quoted 4 lines

values.

---

With this addressed:

Quoted 10 lines
 Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt +0 -0
index bcda1df..29feaba 100644
@@ -101,10 +101,10 @@ Required properties:
                               number (e.g., 0, 1, 2, etc.)
 - #address-cells            : see partition.txt

Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt Required properties: · line 110

Quoted 10 lines
Documentation/devicetree/bindings/mtd/brcm,brcmnand.txt +2 -2
 - #size-cells               : see partition.txt
-- nand-ecc-strength         : see nand.txt
-- nand-ecc-step-size        : must be 512 or 1024. See nand.txt
 
 Optional properties:
+- nand-ecc-strength         : see nand.txt
+- nand-ecc-step-size        : must be 512 or 1024. See nand.txt
 - nand-on-flash-bbt         : boolean, to enable the on-flash BBT for this
                               chip-select. See nand.txt
 - brcm,nand-oob-sector-size : integer, to denote the spare area sector size

Thanks,
Miquèl