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

Rafał Miłecki
2021-11-03T15:11:36Z

From: Rafał Miłecki <rafal@milecki.pl>

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

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index f75929783b94..8b6167457f0c 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -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;
--
2.31.1