|
| 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); |
0 commit comments