Skip to content

Commit

Permalink
patches: openwrt: only unconditionally unlock the whole flash of airM…
Browse files Browse the repository at this point in the history
…ax Boards
  • Loading branch information
herbetom committed Dec 11, 2024
1 parent b180fc2 commit 8f9c3a7
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
From: David Bauer <[email protected]>
Date: Thu, 4 Jan 2024 12:47:08 +0100
Subject: mtd: spi-nor: add property to unlock entire chip

Add a new device-tree porperty "swp-disable" which can be added to
spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.

This avoids changing the default behavior of all SPI-NOR chips and helps
to indicate devices which require the old kernel behavior explicitly.

Signed-off-by: David Bauer <[email protected]>
[backport to openwrt-23.05]
Signed-off-by: Tom Herbers <[email protected]>

diff --git a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
index 36f5331bd017f9727185889f33f0575c93397952..d0caed4d579ab1c3a18f5dffb32b7ab5ec91dfbc 100644
--- a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
+++ b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
@@ -10,7 +10,7 @@ Signed-off-by: Abhimanyu Vishwakarma <[email protected]>

--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
-@@ -3108,6 +3108,7 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -3110,6 +3110,7 @@ int spi_nor_scan(struct spi_nor *nor, co
struct device *dev = nor->dev;
struct mtd_info *mtd = &nor->mtd;
struct device_node *np = spi_nor_get_flash_node(nor);
@@ -18,7 +18,7 @@ Signed-off-by: Abhimanyu Vishwakarma <[email protected]>
int ret;
int i;

-@@ -3162,7 +3163,12 @@ int spi_nor_scan(struct spi_nor *nor, co
+@@ -3164,7 +3165,12 @@ int spi_nor_scan(struct spi_nor *nor, co
if (ret)
return ret;

diff --git a/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
new file mode 100644
index 0000000000000000000000000000000000000000..2ebac01bde5401d0a137058c2ed7fa777b31266d
--- /dev/null
+++ b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
@@ -0,0 +1,34 @@
+From 228fcb0738a9e582a15666e717bb2fc5078c694c Mon Sep 17 00:00:00 2001
+From: David Bauer <[email protected]>
+Date: Thu, 4 Jan 2024 12:44:06 +0100
+Subject: [PATCH] mtd: spi-nor: add property to unlock entire chip
+
+Add a new device-tree porperty "swp-disable" which can be added to
+spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.
+
+This avoids changing the default behavior of all SPI-NOR chips and helps
+to indicate devices which require the old kernel behavior explicitly.
+
+Signed-off-by: David Bauer <[email protected]>
+---
+ drivers/mtd/spi-nor/core.c | 2 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/mtd/spi-nor/core.c
++++ b/drivers/mtd/spi-nor/core.c
+@@ -2820,6 +2820,7 @@ static int spi_nor_quad_enable(struct sp
+
+ static int spi_nor_init(struct spi_nor *nor)
+ {
++ struct device_node *np = spi_nor_get_flash_node(nor);
+ int err;
+
+ err = spi_nor_octal_dtr_enable(nor, true);
+@@ -2845,6 +2846,7 @@ static int spi_nor_init(struct spi_nor *
+ * SNOR_F_SWP_IS_VOLATILE.
+ */
+ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE) ||
++ of_property_read_bool(np, "swp-disable") ||
+ (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE) &&
+ nor->flags & SNOR_F_SWP_IS_VOLATILE))
+ spi_nor_try_unlock_all(nor);
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
From: David Bauer <[email protected]>
Date: Sun, 7 Jan 2024 21:16:07 +0100
Subject: ath79: unlock full flash on Ubiquiti airMax boards

Instead of unlocking full flash on all devices, selectively unlock the
full flash on Ubiquiti airMax boards.

The flash unlock was only necessary on these boards in the first place.

Signed-off-by: David Bauer <[email protected]>
[added swp-disable flag for qca955x_ubnt_xc]
Signed-off-by: Tom Herbers <[email protected]>

diff --git a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
index 341d0bad0d6f700abfc4bbee69c776ed21839c93..66779042555705e57c9316342103098df12d6849 100644
--- a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
+++ b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
@@ -22,6 +22,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
index ba0f7ad23e52940b1bc4ec2971a8d8e8c73062a6..60d930e434a866a6a891814b7eaec1025d898aef 100644
--- a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
+++ b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
@@ -36,6 +36,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
index ce49c10e5ccb5bc634444cd2dbbce1deb60ef73c..5ddf89488ceb3958926465413515de33506e5817 100644
--- a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
+++ b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
@@ -64,6 +64,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
diff --git a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
index 0f803945db632873a6d7e97cb0a482106354e8c2..196e1b5382f5508610a65247832e47006a3ca11b 100644
--- a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
+++ b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
@@ -16,6 +16,7 @@
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <25000000>;
+ swp-disable;

partitions {
compatible = "fixed-partitions";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
From: Tom Herbers <[email protected]>
Date: Wed, 31 Jul 2024 14:43:13 +0200
Subject: Revert "ath79: generic: disable SPI-NOR write protect unconditionally"

This reverts commit c55aaa7c9a98e7c0a5e1ea8293a534dc5b395cf3.

diff --git a/target/linux/ath79/generic/config-default b/target/linux/ath79/generic/config-default
index 09ea9d93d7a567897c9de5fdd925cb13de332930..06f264b626a72be16854e6f984a2ee4f8b3b906a 100644
--- a/target/linux/ath79/generic/config-default
+++ b/target/linux/ath79/generic/config-default
@@ -14,8 +14,6 @@ CONFIG_LEDS_RESET=y
CONFIG_MARVELL_PHY=y
CONFIG_MICREL_PHY=y
CONFIG_MTD_REDBOOT_PARTS=y
-CONFIG_MTD_SPI_NOR_SWP_DISABLE=y
-# CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE is not set
CONFIG_MTD_SPLIT_EVA_FW=y
CONFIG_NVMEM_SYSFS=y
CONFIG_NVMEM_U_BOOT_ENV=y

0 comments on commit 8f9c3a7

Please sign in to comment.