[PATCH 12/12] mtd: rawnand: brcmnand: Support write protection setting from dts

From: William Zhang
Date: Tue Jun 06 2023 - 19:15:34 EST


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 <william.zhang@xxxxxxxxxxxx>
Reviewed-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
Reviewed-by: Kamal Dasu <kamal.dasu@xxxxxxxxxxxx>

---

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 8c7cea36ac71..4fc23077a5b5 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -3106,7 +3106,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;
@@ -3243,6 +3243,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

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature