Skip to contentSkip to conversation

dt-bindings: mtd: brcmnand: add "no-wp" property

PATCH In review Rafał Miłecki 4 participants 7 messages Nov 3, 2021 – Nov 9, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: mtd: brcmnand: add "no-wp" property

From: Rafał Miłecki <[email protected]>

It's required to properly describe boards without connected WP pin (e.g. Asus GT-AC5300).

---
 Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml +5 -0
index dd5a64969e37..49c7860c0dad 100644
@@ -111,6 +111,11 @@ properties:
       earlier versions of this core that include WP
     type: boolean
 
+  no-wp:
+    description:
+      This property marks boards with WP pin not connected to the NAND chip.
+    type: boolean
+
 patternProperties:
   "^nand@[a-f0-9]$":
     type: object
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 mtd: rawnand: brcmnand: support "no-wp" DT property

From: Rafał Miłecki <[email protected]>

Some boards may use WP-capable controller but still have WP not connected. This change fixes:

[    1.175550] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.184524] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.285547] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.294516] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.395548] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.404517] bcm63138_nand ff801800.nand: nand #WP expected on
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -1
index f75929783b94..8b6167457f0c 100644
@@ -714,7 +714,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	if (ctrl->nand_version >= 0x0500)
 		ctrl->features |= BRCMNAND_HAS_1K_SECTORS;
 
-	if (ctrl->nand_version >= 0x0700)
+	if (ctrl->nand_version >= 0x0700 &&
+	    !of_property_read_bool(ctrl->dev->of_node, "no-wp"))
 		ctrl->features |= BRCMNAND_HAS_WP;
 	else if (of_property_read_bool(ctrl->dev->of_node, "brcm,nand-has-wp"))
 		ctrl->features |= BRCMNAND_HAS_WP;
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH 2/2] mtd: rawnand: brcmnand: support "no-wp" DT property

Quoted 21 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Some boards may use WP-capable controller but still have WP not connected. This change fixes:

[    1.175550] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.184524] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.285547] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.294516] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.395548] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.404517] bcm63138_nand ff801800.nand: nand #WP expected on
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index f75929783b94..8b6167457f0c 100644

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_revision_init(struct brcmnand_controller *ctrl) · line 719

Quoted 7 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -1
@@ -714,7 +714,8 @@ static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
 	if (ctrl->nand_version >= 0x0500)
 		ctrl->features |= BRCMNAND_HAS_1K_SECTORS;
 
-	if (ctrl->nand_version >= 0x0700)
+	if (ctrl->nand_version >= 0x0700 &&
+	    !of_property_read_bool(ctrl->dev->of_node, "no-wp"))
 		ctrl->features |= BRCMNAND_HAS_WP;

Should not this be a logical OR here or rather, should it be moved out of the check on ctrl->nand_version entirely? What revision of the NAND controller do you have on that chip?

Quoted 3 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
 	else if (of_property_read_bool(ctrl->dev->of_node, "brcm,nand-has-wp"))
 		ctrl->features |= BRCMNAND_HAS_WP;
Signature · 1 line
Florian
#3 lore raw

Re: [PATCH 2/2] mtd: rawnand: brcmnand: support "no-wp" DT property

Quoted 26 lines · Florian Fainelli
Quoted 25 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Some boards may use WP-capable controller but still have WP not connected. This change fixes:

[    1.175550] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.184524] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.285547] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.294516] bcm63138_nand ff801800.nand: nand #WP expected on
[    1.395548] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.404517] bcm63138_nand ff801800.nand: nand #WP expected on
---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index f75929783b94..8b6167457f0c 100644
@@ -714,7 +714,8 @@ static int brcmnand_revision_init(struct 
 brcmnand_controller *ctrl)
 	if (ctrl->nand_version >= 0x0500)
 		ctrl->features |= BRCMNAND_HAS_1K_SECTORS;
 
Quoted 8 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_revision_init(struct brcmnand_controller *ctrl) · line 719

Quoted 4 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -1
-	if (ctrl->nand_version >= 0x0700)
+	if (ctrl->nand_version >= 0x0700 &&
+	    !of_property_read_bool(ctrl->dev->of_node, "no-wp"))
 		ctrl->features |= BRCMNAND_HAS_WP;

Should not this be a logical OR here or rather, should it be moved out of the check on ctrl->nand_version entirely? What revision of the NAND controller do you have on that chip?

It's NAND controller version 0x0701 (v7.1) and I think it's correct.

I think we want WP enabled on rev 7.0+ unless it was explicitly disabled.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#4 lore raw

Re: [PATCH 2/2] mtd: rawnand: brcmnand: support "no-wp" DT property

Quoted 40 lines · Rafał Miłecki
Quoted 30 lines · Florian Fainelli
Quoted 29 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Some boards may use WP-capable controller but still have WP not connected. This change fixes:
[    1.175550] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.184524] bcm63138_nand ff801800.nand: nand #WP expected on [    1.285547] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.294516] bcm63138_nand ff801800.nand: nand #WP expected on [    1.395548] bcm63138_nand ff801800.nand: timeout on status poll (expected c0000040 got c00000c0)
[    1.404517] bcm63138_nand ff801800.nand: nand #WP expected on

---
 drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/brcmnand/brcmnand.c +0 -0
index f75929783b94..8b6167457f0c 100644
@@ -714,7 +714,8 @@ static int brcmnand_revision_init(struct
 brcmnand_controller *ctrl)
      if (ctrl->nand_version >= 0x0500)
          ctrl->features |= BRCMNAND_HAS_1K_SECTORS;
 
Quoted 8 lines

drivers/mtd/nand/raw/brcmnand/brcmnand.c static int brcmnand_revision_init(struct brcmnand_controller *ctrl) · line 719

Quoted 4 lines
drivers/mtd/nand/raw/brcmnand/brcmnand.c +2 -1
-    if (ctrl->nand_version >= 0x0700)
+    if (ctrl->nand_version >= 0x0700 &&
+        !of_property_read_bool(ctrl->dev->of_node, "no-wp"))
          ctrl->features |= BRCMNAND_HAS_WP;

Should not this be a logical OR here or rather, should it be moved out of the check on ctrl->nand_version entirely? What revision of the NAND controller do you have on that chip?

Quoted 3 lines

It's NAND controller version 0x0701 (v7.1) and I think it's correct.

I think we want WP enabled on rev 7.0+ unless it was explicitly disabled.

True, I somehow got confused about the negative logic, so maybe we need to combine the logic of all of these lines into a single one:

	if ((ctrl->nand_version >= 0x700 ||

of_property_read_bool(ctrl->dev->of_node, "brcm,nand-has-wp")) && !of_property_read_bool(ctrl->dev->of_node, "no-wp")

such that it is clearer, Kamal, what do you think?

Signature · 1 line
Florian
#5 lore raw
In reply to Rafał Miłecki
Quoted 15 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

It's required to properly describe boards without connected WP pin (e.g. Asus GT-AC5300).

---
  Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml | 5 +++++
  1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml +0 -0
index dd5a64969e37..49c7860c0dad 100644

Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml properties: · line 117

Quoted 7 lines
Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml +4 -0
@@ -111,6 +111,11 @@ properties:
        earlier versions of this core that include WP
      type: boolean
 
+  no-wp:
+    description:
+      This property marks boards with WP pin not connected to the NAND chip.
+    type: boolean

I started rethinking this. Since we already hav "brcm,nand-has-wp" (boolean), would makes more sense:
1. Add "no-wp" boolean (as proposed in this patch)
2. Add "wp" (or similar) with [0, 1] and deprecate "brcm,nand-has-wp"

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

maintainer
#6 lore raw

Hello,

[email protected] wrote on Tue, 9 Nov 2021 08:49:36 +0100:

Quoted 11 lines · Rafał Miłecki
Quoted 10 lines

From: Rafał Miłecki <[email protected]>

It's required to properly describe boards without connected WP pin (e.g. Asus GT-AC5300).

---
  Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml | 5 +++++
  1 file changed, 5 insertions(+)
Quoted 16 lines

Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml properties: · line 116

Quoted 11 lines
Documentation/devicetree/bindings/mtd/brcm,brcmnand.yaml +3 -0
index dd5a64969e37..49c7860c0dad 100644
@@ -111,6 +111,11 @@ properties:
        earlier versions of this core that include WP
      type: boolean  
  > +  no-wp:  
+    description:
+      This property marks boards with WP pin not connected to the NAND chip.
+    type: boolean  

I started rethinking this. Since we already hav "brcm,nand-has-wp" (boolean), would makes more sense:
1. Add "no-wp" boolean (as proposed in this patch)
2. Add "wp" (or similar) with [0, 1] and deprecate "brcm,nand-has-wp"

Maybe this should be a raw NAND wide property, at least in the bindings for now: nand-wp (such as nand-rb) and this property should contain the wp line id.

For me, brcm,nand-has-wp means that the nand wp is connected, not that it "can be" connected. The fact that the controller has a wp pin or not should be internal to the controller driver (different compatible or hw version check).

Thanks,
Miquèl