Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d91d1cb

Browse files
committedJan 20, 2024
patches: openwrt: unconditionally unlock the whole flash of airMax Boards
1 parent 43beae5 commit d91d1cb

3 files changed

+180
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
From: David Bauer <mail@david-bauer.net>
2+
Date: Thu, 4 Jan 2024 12:47:08 +0100
3+
Subject: mtd: spi-nor: add property to unlock entire chip
4+
5+
Add a new device-tree porperty "swp-disable" which can be added to
6+
spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.
7+
8+
This avoids changing the default behavior of all SPI-NOR chips and helps
9+
to indicate devices which require the old kernel behavior explicitly.
10+
11+
Signed-off-by: David Bauer <mail@david-bauer.net>
12+
[backport to openwrt-23.05]
13+
Signed-off-by: Tom Herbers <mail@tomherbers.de>
14+
15+
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
16+
index 36f5331bd017f9727185889f33f0575c93397952..d0caed4d579ab1c3a18f5dffb32b7ab5ec91dfbc 100644
17+
--- a/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
18+
+++ b/target/linux/ath79/patches-5.15/401-mtd-nor-support-mtd-name-from-device-tree.patch
19+
@@ -10,7 +10,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
20+
21+
--- a/drivers/mtd/spi-nor/core.c
22+
+++ b/drivers/mtd/spi-nor/core.c
23+
-@@ -3108,6 +3108,7 @@ int spi_nor_scan(struct spi_nor *nor, co
24+
+@@ -3110,6 +3110,7 @@ int spi_nor_scan(struct spi_nor *nor, co
25+
struct device *dev = nor->dev;
26+
struct mtd_info *mtd = &nor->mtd;
27+
struct device_node *np = spi_nor_get_flash_node(nor);
28+
@@ -18,7 +18,7 @@ Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
29+
int ret;
30+
int i;
31+
32+
-@@ -3162,7 +3163,12 @@ int spi_nor_scan(struct spi_nor *nor, co
33+
+@@ -3164,7 +3165,12 @@ int spi_nor_scan(struct spi_nor *nor, co
34+
if (ret)
35+
return ret;
36+
37+
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
38+
new file mode 100644
39+
index 0000000000000000000000000000000000000000..2ebac01bde5401d0a137058c2ed7fa777b31266d
40+
--- /dev/null
41+
+++ b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
42+
@@ -0,0 +1,34 @@
43+
+From 228fcb0738a9e582a15666e717bb2fc5078c694c Mon Sep 17 00:00:00 2001
44+
+From: David Bauer <mail@david-bauer.net>
45+
+Date: Thu, 4 Jan 2024 12:44:06 +0100
46+
+Subject: [PATCH] mtd: spi-nor: add property to unlock entire chip
47+
+
48+
+Add a new device-tree porperty "swp-disable" which can be added to
49+
+spi-nor OF-nodes to indicate the whole flash-chip should be unlocked.
50+
+
51+
+This avoids changing the default behavior of all SPI-NOR chips and helps
52+
+to indicate devices which require the old kernel behavior explicitly.
53+
+
54+
+Signed-off-by: David Bauer <mail@david-bauer.net>
55+
+---
56+
+ drivers/mtd/spi-nor/core.c | 2 +++
57+
+ 1 file changed, 3 insertions(+)
58+
+
59+
+--- a/drivers/mtd/spi-nor/core.c
60+
++++ b/drivers/mtd/spi-nor/core.c
61+
+@@ -2820,6 +2820,7 @@ static int spi_nor_quad_enable(struct sp
62+
+
63+
+ static int spi_nor_init(struct spi_nor *nor)
64+
+ {
65+
++ struct device_node *np = spi_nor_get_flash_node(nor);
66+
+ int err;
67+
+
68+
+ err = spi_nor_octal_dtr_enable(nor, true);
69+
+@@ -2845,6 +2846,7 @@ static int spi_nor_init(struct spi_nor *
70+
+ * SNOR_F_SWP_IS_VOLATILE.
71+
+ */
72+
+ if (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE) ||
73+
++ of_property_read_bool(np, "swp-disable") ||
74+
+ (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE) &&
75+
+ nor->flags & SNOR_F_SWP_IS_VOLATILE))
76+
+ spi_nor_try_unlock_all(nor);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From: David Bauer <mail@david-bauer.net>
2+
Date: Sun, 7 Jan 2024 21:16:07 +0100
3+
Subject: ath79: unlock full flash on Ubiquiti airMax boards
4+
5+
Instead of unlocking full flash on all devices, selectively unlock the
6+
full flash on Ubiquiti airMax boards.
7+
8+
The flash unlock was only necessary on these boards in the first place.
9+
10+
Signed-off-by: David Bauer <mail@david-bauer.net>
11+
[added swp-disable flag for qca955x_ubnt_xc]
12+
Signed-off-by: Tom Herbers <mail@tomherbers.de>
13+
14+
diff --git a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
15+
index 341d0bad0d6f700abfc4bbee69c776ed21839c93..66779042555705e57c9316342103098df12d6849 100644
16+
--- a/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
17+
+++ b/target/linux/ath79/dts/ar724x_ubnt_xm.dtsi
18+
@@ -22,6 +22,7 @@
19+
compatible = "jedec,spi-nor";
20+
reg = <0>;
21+
spi-max-frequency = <25000000>;
22+
+ swp-disable;
23+
24+
partitions {
25+
compatible = "fixed-partitions";
26+
diff --git a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
27+
index ba0f7ad23e52940b1bc4ec2971a8d8e8c73062a6..60d930e434a866a6a891814b7eaec1025d898aef 100644
28+
--- a/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
29+
+++ b/target/linux/ath79/dts/ar9342_ubnt_wa.dtsi
30+
@@ -36,6 +36,7 @@
31+
compatible = "jedec,spi-nor";
32+
reg = <0>;
33+
spi-max-frequency = <25000000>;
34+
+ swp-disable;
35+
36+
partitions {
37+
compatible = "fixed-partitions";
38+
diff --git a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
39+
index ce49c10e5ccb5bc634444cd2dbbce1deb60ef73c..5ddf89488ceb3958926465413515de33506e5817 100644
40+
--- a/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
41+
+++ b/target/linux/ath79/dts/ar9342_ubnt_xw.dtsi
42+
@@ -64,6 +64,7 @@
43+
compatible = "jedec,spi-nor";
44+
reg = <0>;
45+
spi-max-frequency = <25000000>;
46+
+ swp-disable;
47+
48+
partitions {
49+
compatible = "fixed-partitions";
50+
diff --git a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
51+
index 0f803945db632873a6d7e97cb0a482106354e8c2..196e1b5382f5508610a65247832e47006a3ca11b 100644
52+
--- a/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
53+
+++ b/target/linux/ath79/dts/qca955x_ubnt_xc.dtsi
54+
@@ -16,6 +16,7 @@
55+
compatible = "jedec,spi-nor";
56+
reg = <0>;
57+
spi-max-frequency = <25000000>;
58+
+ swp-disable;
59+
60+
partitions {
61+
compatible = "fixed-partitions";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From: Tom Herbers <mail@tomherbers.de>
2+
Date: Fri, 19 Jan 2024 13:37:15 +0100
3+
Subject: add unconditional unlock logging
4+
5+
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
6+
index 2ebac01bde5401d0a137058c2ed7fa777b31266d..867b5dac44b2d5750d9ee626e76a645afd0ab9c0 100644
7+
--- a/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
8+
+++ b/target/linux/generic/hack-5.15/400-mtd-spi-nor-add-property-to-unlock-entire-chip.patch
9+
@@ -14,8 +14,10 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
10+
drivers/mtd/spi-nor/core.c | 2 +++
11+
1 file changed, 3 insertions(+)
12+
13+
---- a/drivers/mtd/spi-nor/core.c
14+
-+++ b/drivers/mtd/spi-nor/core.c
15+
+Index: linux-5.15.147/drivers/mtd/spi-nor/core.c
16+
+===================================================================
17+
+--- linux-5.15.147.orig/drivers/mtd/spi-nor/core.c
18+
++++ linux-5.15.147/drivers/mtd/spi-nor/core.c
19+
@@ -2820,6 +2820,7 @@ static int spi_nor_quad_enable(struct sp
20+
21+
static int spi_nor_init(struct spi_nor *nor)
22+
@@ -24,11 +26,19 @@ Signed-off-by: David Bauer <mail@david-bauer.net>
23+
int err;
24+
25+
err = spi_nor_octal_dtr_enable(nor, true);
26+
-@@ -2845,6 +2846,7 @@ static int spi_nor_init(struct spi_nor *
27+
+@@ -2844,10 +2845,14 @@ static int spi_nor_init(struct spi_nor *
28+
+ * protection bits are volatile. The latter is indicated by
29+
* SNOR_F_SWP_IS_VOLATILE.
30+
*/
31+
++ printk("checking for unconditional unlock");
32+
if (IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE) ||
33+
+ of_property_read_bool(np, "swp-disable") ||
34+
(IS_ENABLED(CONFIG_MTD_SPI_NOR_SWP_DISABLE_ON_VOLATILE) &&
35+
- nor->flags & SNOR_F_SWP_IS_VOLATILE))
36+
+- nor->flags & SNOR_F_SWP_IS_VOLATILE))
37+
++ nor->flags & SNOR_F_SWP_IS_VOLATILE)) {
38+
++ printk("unconditional unlocking");
39+
spi_nor_try_unlock_all(nor);
40+
++ }
41+
+
42+
+ if (nor->addr_width == 4 &&
43+
+ nor->read_proto != SNOR_PROTO_8_8_8_DTR &&

0 commit comments

Comments
 (0)
Please sign in to comment.