kernel: backport brcmnand support for "brcm,wp-not-connected"
authorRafał Miłecki <rafal@milecki.pl>
Thu, 28 Mar 2024 07:41:51 +0000 (08:41 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Thu, 28 Mar 2024 07:52:23 +0000 (08:52 +0100)
It's required to support NAND controllers with WP pin on boards that
don't have it connected to NAND chip.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
target/linux/bcm47xx/patches-5.15/100-v5.18-mtd-rawnand-brcmnand-Assign-soc-as-early-as-possible.patch
target/linux/bcm47xx/patches-5.15/103-v5.18-mtd-rawnand-brcmnand-Move-OF-operations-out-of-brcmnand_init_cs.patch
target/linux/bcm47xx/patches-5.15/104-v5.18-mtd-rawnand-brcmnand-Allow-working-without-interrupts.patch
target/linux/bcm47xx/patches-5.15/106-v5.18-mtd-rawnand-brcmnand-Allow-platform-data-instantation.patch
target/linux/generic/backport-5.15/411-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch [new file with mode: 0644]
target/linux/generic/backport-6.1/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch [new file with mode: 0644]
target/linux/generic/backport-6.6/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch [new file with mode: 0644]

index 30b6d97a8582dd9bf89ed9841a3113353f8f1e81..f6f90a81651184bc34ca686a0d1b52ebf31fbfa1 100644 (file)
@@ -22,7 +22,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
  
        /* Enable the static key if the soc provides I/O operations indicating
         * that a non-memory mapped IO access path must be used
-@@ -3205,8 +3206,6 @@ int brcmnand_probe(struct platform_devic
+@@ -3209,8 +3210,6 @@ int brcmnand_probe(struct platform_devic
         * interesting ways
         */
        if (soc) {
index 6a17ea7182ab8ed9c859c08ea43e09ded2bf01ef..fdfd35a44f9844f026f42fc9185f5b1c1aace8d6 100644 (file)
@@ -43,7 +43,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
        nand_set_controller_data(chip, host);
        mtd->name = devm_kasprintf(dev, GFP_KERNEL, "brcmnand.%d",
                                   host->cs);
-@@ -3236,7 +3229,16 @@ int brcmnand_probe(struct platform_devic
+@@ -3240,7 +3233,16 @@ int brcmnand_probe(struct platform_devic
                        host->pdev = pdev;
                        host->ctrl = ctrl;
  
index ecc3e954ce65bc5fd4e9a892d73f473b6a4343f9..08cecf3d4a99345518fe6b1a9f1541e9e34e9cb5 100644 (file)
@@ -32,7 +32,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
                /* switch to interrupt polling and PIO mode */
                disable_ctrl_irqs(ctrl);
                sts = bcmnand_ctrl_poll_status(ctrl, NAND_CTRL_RDY,
-@@ -3187,33 +3187,29 @@ int brcmnand_probe(struct platform_devic
+@@ -3191,33 +3191,29 @@ int brcmnand_probe(struct platform_devic
        }
  
        /* IRQ */
index b9ad82ecf96465c6ea4015842940569801a2916f..4942389b5a5ffdcb7d2f0cf3fd41afed4019ca7b 100644 (file)
@@ -72,7 +72,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
                return PTR_ERR(ctrl->nand_base);
  
        /* Enable clock before using NAND registers */
-@@ -3214,7 +3214,6 @@ int brcmnand_probe(struct platform_devic
+@@ -3218,7 +3218,6 @@ int brcmnand_probe(struct platform_devic
  
        for_each_available_child_of_node(dn, child) {
                if (of_device_is_compatible(child, "brcm,nandcs")) {
@@ -80,7 +80,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
  
                        host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
                        if (!host) {
-@@ -3234,7 +3233,7 @@ int brcmnand_probe(struct platform_devic
+@@ -3238,7 +3237,7 @@ int brcmnand_probe(struct platform_devic
  
                        nand_set_flash_node(&host->chip, child);
  
@@ -89,7 +89,7 @@ Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
                        if (ret) {
                                devm_kfree(dev, host);
                                continue; /* Try all chip-selects */
-@@ -3244,6 +3243,32 @@ int brcmnand_probe(struct platform_devic
+@@ -3248,6 +3247,32 @@ int brcmnand_probe(struct platform_devic
                }
        }
  
diff --git a/target/linux/generic/backport-5.15/411-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch b/target/linux/generic/backport-5.15/411-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch
new file mode 100644 (file)
index 0000000..dce2c91
--- /dev/null
@@ -0,0 +1,36 @@
+From 8e7daa85641c9559c113f6b217bdc923397de77c Mon Sep 17 00:00:00 2001
+From: William Zhang <william.zhang@broadcom.com>
+Date: Thu, 22 Feb 2024 19:47:58 -0800
+Subject: [PATCH] mtd: rawnand: brcmnand: Support write protection setting from
+ dts
+
+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@broadcom.com>
+Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com>
+Reviewed-by: David Regan <dregan@broadcom.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20240223034758.13753-14-william.zhang@broadcom.com
+---
+ drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+@@ -3184,6 +3184,10 @@ int brcmnand_probe(struct platform_devic
+       /* Disable XOR addressing */
+       brcmnand_rmw_reg(ctrl, BRCMNAND_CS_XOR, 0xff, 0, 0);
++      /* Check if the board connects the WP pin */
++      if (of_property_read_bool(dn, "brcm,wp-not-connected"))
++              wp_on = 0;
++
+       if (ctrl->features & BRCMNAND_HAS_WP) {
+               /* Permanently disable write protection */
+               if (wp_on == 2)
diff --git a/target/linux/generic/backport-6.1/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch b/target/linux/generic/backport-6.1/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch
new file mode 100644 (file)
index 0000000..ba01bac
--- /dev/null
@@ -0,0 +1,36 @@
+From 8e7daa85641c9559c113f6b217bdc923397de77c Mon Sep 17 00:00:00 2001
+From: William Zhang <william.zhang@broadcom.com>
+Date: Thu, 22 Feb 2024 19:47:58 -0800
+Subject: [PATCH] mtd: rawnand: brcmnand: Support write protection setting from
+ dts
+
+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@broadcom.com>
+Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com>
+Reviewed-by: David Regan <dregan@broadcom.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20240223034758.13753-14-william.zhang@broadcom.com
+---
+ drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+@@ -3188,6 +3188,10 @@ int brcmnand_probe(struct platform_devic
+       /* Disable XOR addressing */
+       brcmnand_rmw_reg(ctrl, BRCMNAND_CS_XOR, 0xff, 0, 0);
++      /* Check if the board connects the WP pin */
++      if (of_property_read_bool(dn, "brcm,wp-not-connected"))
++              wp_on = 0;
++
+       if (ctrl->features & BRCMNAND_HAS_WP) {
+               /* Permanently disable write protection */
+               if (wp_on == 2)
diff --git a/target/linux/generic/backport-6.6/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch b/target/linux/generic/backport-6.6/400-v6.9-mtd-rawnand-brcmnand-Support-write-protection-settin.patch
new file mode 100644 (file)
index 0000000..2576241
--- /dev/null
@@ -0,0 +1,36 @@
+From 8e7daa85641c9559c113f6b217bdc923397de77c Mon Sep 17 00:00:00 2001
+From: William Zhang <william.zhang@broadcom.com>
+Date: Thu, 22 Feb 2024 19:47:58 -0800
+Subject: [PATCH] mtd: rawnand: brcmnand: Support write protection setting from
+ dts
+
+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@broadcom.com>
+Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
+Reviewed-by: Kamal Dasu <kamal.dasu@broadcom.com>
+Reviewed-by: David Regan <dregan@broadcom.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20240223034758.13753-14-william.zhang@broadcom.com
+---
+ drivers/mtd/nand/raw/brcmnand/brcmnand.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+@@ -3189,6 +3189,10 @@ int brcmnand_probe(struct platform_devic
+       /* Disable XOR addressing */
+       brcmnand_rmw_reg(ctrl, BRCMNAND_CS_XOR, 0xff, 0, 0);
++      /* Check if the board connects the WP pin */
++      if (of_property_read_bool(dn, "brcm,wp-not-connected"))
++              wp_on = 0;
++
+       if (ctrl->features & BRCMNAND_HAS_WP) {
+               /* Permanently disable write protection */
+               if (wp_on == 2)