2024-01-24 03:07:37

by David Regan

[permalink] [raw]
Subject: [PATCH v3 07/10] mtd: rawnand: brcmnand: Support write protection setting from dts

From: William Zhang <[email protected]>

The write protection feature is controlled by the module parameter wp_on
with default set to enabled. But not all the board use this feature
especially in BCMBCA broadband board. And module parameter is not
sufficient as different board can have different option. Add a device
tree property and allow this feature to be configured through the board
dts on per board basis.

Signed-off-by: William Zhang <[email protected]>
Reviewed-by: Florian Fainelli <[email protected]>
Reviewed-by: Kamal Dasu <[email protected]>
Reviewed-by: David Regan <[email protected]>
---
Changes in v3: None
---
Changes in v2: None
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 869ea64e9189..9a904c7c6dad 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -3081,7 +3081,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
struct brcmnand_controller *ctrl;
struct brcmnand_host *host;
struct resource *res;
- int ret;
+ int ret, wp_dt;

if (dn && !of_match_node(brcmnand_of_match, dn))
return -ENODEV;
@@ -3218,6 +3218,12 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
/* Disable XOR addressing */
brcmnand_rmw_reg(ctrl, BRCMNAND_CS_XOR, 0xff, 0, 0);

+ /* Not all boards support write protect (WP), check DT property */
+ if (of_property_read_u32(dn, "brcm,nand-use-wp", &wp_dt) == 0) {
+ if (wp_dt >= 0 && wp_dt <= 2)
+ wp_on = wp_dt;
+ }
+
if (ctrl->features & BRCMNAND_HAS_WP) {
/* Permanently disable write protection */
if (wp_on == 2)
--
2.37.3