From d9b1c747807973053a2cba599ae247234588e341 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy Date: Sat, 27 Dec 2025 08:28:09 +0300 Subject: [PATCH] airoha: spi: update airoha-snfi patches and en7523 dts Changes: * use upstream patches for airoha-snfi driver * update in kernel en7523 dts to add spinand support Signed-off-by: Mikhail Kshevetskiy Link: https://github.com/openwrt/openwrt/pull/21299 Signed-off-by: Robert Marko --- ...move-unnecessary-restriction-length.patch} | 8 +- ...-unnecessary-switch-to-non-dma-mode.patch} | 9 +- ...airoha-unify-dirmap-read-write-code.patch} | 8 +- ...t-of-dualio-quadio-flash-reading-co.patch} | 8 +- ...setting-of-page-oob-sizes-in-REG_SP.patch} | 8 +- ...-the-number-of-modification-of-REG_.patch} | 14 +-- ...stom-sector-size-equal-to-flash-pag.patch} | 14 +-- ...reading-flash-page-settings-from-SN.patch} | 14 +-- ...ffer-must-be-0xff-ed-before-writing.patch} | 11 +- ...nfi-en7523-workaround-flash-damaging.patch | 97 ----------------- ...en7523-workaround-flash-damaging-if-.patch | 102 ++++++++++++++++++ ...arm-dts-airoha-en7523-add-SNAND-node.patch | 40 +++++++ 12 files changed, 198 insertions(+), 135 deletions(-) rename target/linux/airoha/patches-6.12/{029-02-spi-airoha-remove-unnecessary-restriction-length.patch => 029-05-v6.19-spi-airoha-remove-unnecessary-restriction-length.patch} (73%) rename target/linux/airoha/patches-6.12/{029-04-spi-airoha-remove-unnecessary-switch-to-non-dma-m.patch => 029-06-v6.19-spi-airoha-remove-unnecessary-switch-to-non-dma-mode.patch} (74%) rename target/linux/airoha/patches-6.12/{029-07-spi-airoha-unify-dirmap-read-write-code.patch => 029-07-v6.19-spi-airoha-unify-dirmap-read-write-code.patch} (92%) rename target/linux/airoha/patches-6.12/{029-08-spi-airoha-support-of-dualio-quadio-flash-reading.patch => 029-08-v6.19-spi-airoha-support-of-dualio-quadio-flash-reading-co.patch} (90%) rename target/linux/airoha/patches-6.12/{029-10-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG.patch => 029-09-v6.19-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG_SP.patch} (83%) rename target/linux/airoha/patches-6.12/{029-11-spi-airoha-reduce-the-number-of-modification-of-R.patch => 029-10-v6.19-spi-airoha-reduce-the-number-of-modification-of-REG_.patch} (92%) rename target/linux/airoha/patches-6.12/{029-12-spi-airoha-set-custom-sector-size-equal-to-flash-.patch => 029-11-v6.19-spi-airoha-set-custom-sector-size-equal-to-flash-pag.patch} (91%) rename target/linux/airoha/patches-6.12/{029-13-spi-airoha-avoid-reading-flash-page-settings-from.patch => 029-12-v6.19-spi-airoha-avoid-reading-flash-page-settings-from-SN.patch} (91%) rename target/linux/airoha/patches-6.12/{029-09-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch => 029-13-v6.19-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch} (63%) delete mode 100644 target/linux/airoha/patches-6.12/029-14-spi-airoha-snfi-en7523-workaround-flash-damaging.patch create mode 100644 target/linux/airoha/patches-6.12/029-14-v6.19-spi-airoha-snfi-en7523-workaround-flash-damaging-if-.patch create mode 100644 target/linux/airoha/patches-6.12/029-15-arm-dts-airoha-en7523-add-SNAND-node.patch diff --git a/target/linux/airoha/patches-6.12/029-02-spi-airoha-remove-unnecessary-restriction-length.patch b/target/linux/airoha/patches-6.12/029-05-v6.19-spi-airoha-remove-unnecessary-restriction-length.patch similarity index 73% rename from target/linux/airoha/patches-6.12/029-02-spi-airoha-remove-unnecessary-restriction-length.patch rename to target/linux/airoha/patches-6.12/029-05-v6.19-spi-airoha-remove-unnecessary-restriction-length.patch index e3b9f0ccbe..c99c25921c 100644 --- a/target/linux/airoha/patches-6.12/029-02-spi-airoha-remove-unnecessary-restriction-length.patch +++ b/target/linux/airoha/patches-6.12/029-05-v6.19-spi-airoha-remove-unnecessary-restriction-length.patch @@ -1,7 +1,7 @@ -From 4658f57ba7f60c3bd8e14c1ca7acf2090aee8436 Mon Sep 17 00:00:00 2001 +From 661856ca131c8bf6724905966e02149805660abe Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Tue, 12 Aug 2025 06:21:35 +0300 -Subject: [PATCH v6 02/13] spi: airoha: remove unnecessary restriction length +Date: Sun, 12 Oct 2025 15:16:53 +0300 +Subject: [PATCH 05/14] spi: airoha: remove unnecessary restriction length The "length < 160" restriction is not needed because airoha_snand_write_data() and airoha_snand_read_data() will properly handle data transfers above @@ -9,6 +9,8 @@ SPI_MAX_TRANSFER_SIZE. Signed-off-by: Mikhail Kshevetskiy Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-3-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/target/linux/airoha/patches-6.12/029-04-spi-airoha-remove-unnecessary-switch-to-non-dma-m.patch b/target/linux/airoha/patches-6.12/029-06-v6.19-spi-airoha-remove-unnecessary-switch-to-non-dma-mode.patch similarity index 74% rename from target/linux/airoha/patches-6.12/029-04-spi-airoha-remove-unnecessary-switch-to-non-dma-m.patch rename to target/linux/airoha/patches-6.12/029-06-v6.19-spi-airoha-remove-unnecessary-switch-to-non-dma-mode.patch index 626e5c0ad9..afe496c968 100644 --- a/target/linux/airoha/patches-6.12/029-04-spi-airoha-remove-unnecessary-switch-to-non-dma-m.patch +++ b/target/linux/airoha/patches-6.12/029-06-v6.19-spi-airoha-remove-unnecessary-switch-to-non-dma-mode.patch @@ -1,8 +1,7 @@ -From fb41a3e3bc357592b28a8abb504df99dad642588 Mon Sep 17 00:00:00 2001 +From 7350f8dc15bfbb7abf1ce4babea6fcace1c574c5 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Mon, 11 Aug 2025 13:09:51 +0300 -Subject: [PATCH v6 04/13] spi: airoha: remove unnecessary switch to non-dma - mode +Date: Sun, 12 Oct 2025 15:16:55 +0300 +Subject: [PATCH 06/14] spi: airoha: remove unnecessary switch to non-dma mode The code switches to dma at the start of dirmap operation and returns to non-dma at the end of dirmap operation, so an additional switch to @@ -11,6 +10,8 @@ non-dma at the start of dirmap write is not required. Signed-off-by: Mikhail Kshevetskiy Acked-by: Lorenzo Bianconi Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-5-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/linux/airoha/patches-6.12/029-07-spi-airoha-unify-dirmap-read-write-code.patch b/target/linux/airoha/patches-6.12/029-07-v6.19-spi-airoha-unify-dirmap-read-write-code.patch similarity index 92% rename from target/linux/airoha/patches-6.12/029-07-spi-airoha-unify-dirmap-read-write-code.patch rename to target/linux/airoha/patches-6.12/029-07-v6.19-spi-airoha-unify-dirmap-read-write-code.patch index 4be20c5b55..c85c6861fc 100644 --- a/target/linux/airoha/patches-6.12/029-07-spi-airoha-unify-dirmap-read-write-code.patch +++ b/target/linux/airoha/patches-6.12/029-07-v6.19-spi-airoha-unify-dirmap-read-write-code.patch @@ -1,12 +1,14 @@ -From 995b1a65206ee28d5403db0518cb230f2ce429ef Mon Sep 17 00:00:00 2001 +From 233a22687411ea053a4b169c07324ee6aa33bf38 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Mon, 11 Aug 2025 19:57:43 +0300 -Subject: [PATCH v6 07/13] spi: airoha: unify dirmap read/write code +Date: Sun, 12 Oct 2025 15:16:58 +0300 +Subject: [PATCH 07/14] spi: airoha: unify dirmap read/write code Makes dirmap writing looks similar to dirmap reading. Just a minor refactoring, no behavior change is expected. Signed-off-by: Mikhail Kshevetskiy +Link: https://patch.msgid.link/20251012121707.2296160-8-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 50 ++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/target/linux/airoha/patches-6.12/029-08-spi-airoha-support-of-dualio-quadio-flash-reading.patch b/target/linux/airoha/patches-6.12/029-08-v6.19-spi-airoha-support-of-dualio-quadio-flash-reading-co.patch similarity index 90% rename from target/linux/airoha/patches-6.12/029-08-spi-airoha-support-of-dualio-quadio-flash-reading.patch rename to target/linux/airoha/patches-6.12/029-08-v6.19-spi-airoha-support-of-dualio-quadio-flash-reading-co.patch index 4e00e7c178..7e3fcb4764 100644 --- a/target/linux/airoha/patches-6.12/029-08-spi-airoha-support-of-dualio-quadio-flash-reading.patch +++ b/target/linux/airoha/patches-6.12/029-08-v6.19-spi-airoha-support-of-dualio-quadio-flash-reading-co.patch @@ -1,7 +1,7 @@ -From baaba9b8d3d907575323cbb7fabeae23db2a542b Mon Sep 17 00:00:00 2001 +From 80b09137aeab27e59004383058f8cc696a9ee048 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Mon, 11 Aug 2025 20:52:34 +0300 -Subject: [PATCH v6 08/13] spi: airoha: support of dualio/quadio flash reading +Date: Sun, 12 Oct 2025 15:16:59 +0300 +Subject: [PATCH 08/14] spi: airoha: support of dualio/quadio flash reading commands Airoha snfi spi controller supports acceleration of DUAL/QUAD @@ -12,6 +12,8 @@ DUAL_IO/QUAD_IO one. Signed-off-by: Mikhail Kshevetskiy Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-9-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/target/linux/airoha/patches-6.12/029-10-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG.patch b/target/linux/airoha/patches-6.12/029-09-v6.19-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG_SP.patch similarity index 83% rename from target/linux/airoha/patches-6.12/029-10-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG.patch rename to target/linux/airoha/patches-6.12/029-09-v6.19-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG_SP.patch index 0a3ddc8be3..f8902f7e57 100644 --- a/target/linux/airoha/patches-6.12/029-10-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG.patch +++ b/target/linux/airoha/patches-6.12/029-09-v6.19-spi-airoha-avoid-setting-of-page-oob-sizes-in-REG_SP.patch @@ -1,7 +1,7 @@ -From 4abbbc74306598159fe1dc545f929ae594bf4dd1 Mon Sep 17 00:00:00 2001 +From 70eec454f2d6cdfab547c262781acd38328e11a1 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Thu, 14 Aug 2025 18:00:32 +0300 -Subject: [PATCH v6 10/13] spi: airoha: avoid setting of page/oob sizes in +Date: Sun, 12 Oct 2025 15:17:00 +0300 +Subject: [PATCH 09/14] spi: airoha: avoid setting of page/oob sizes in REG_SPI_NFI_PAGEFMT spi-airoha-snfi uses custom sector size in REG_SPI_NFI_SECCUS_SIZE @@ -9,6 +9,8 @@ register, so setting of page/oob sizes in REG_SPI_NFI_PAGEFMT is not required. Signed-off-by: Mikhail Kshevetskiy +Link: https://patch.msgid.link/20251012121707.2296160-10-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 38 ----------------------------------- 1 file changed, 38 deletions(-) diff --git a/target/linux/airoha/patches-6.12/029-11-spi-airoha-reduce-the-number-of-modification-of-R.patch b/target/linux/airoha/patches-6.12/029-10-v6.19-spi-airoha-reduce-the-number-of-modification-of-REG_.patch similarity index 92% rename from target/linux/airoha/patches-6.12/029-11-spi-airoha-reduce-the-number-of-modification-of-R.patch rename to target/linux/airoha/patches-6.12/029-10-v6.19-spi-airoha-reduce-the-number-of-modification-of-REG_.patch index 2193994ed9..40e2f6ea21 100644 --- a/target/linux/airoha/patches-6.12/029-11-spi-airoha-reduce-the-number-of-modification-of-R.patch +++ b/target/linux/airoha/patches-6.12/029-10-v6.19-spi-airoha-reduce-the-number-of-modification-of-REG_.patch @@ -1,7 +1,7 @@ -From 0d8f58869192df0acdba286d233b57a4feeaf94b Mon Sep 17 00:00:00 2001 +From d1ff30df1d9a4eb4c067795abb5e2a66910fd108 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Thu, 14 Aug 2025 18:49:34 +0300 -Subject: [PATCH v6 11/13] spi: airoha: reduce the number of modification of +Date: Sun, 12 Oct 2025 15:17:01 +0300 +Subject: [PATCH 10/14] spi: airoha: reduce the number of modification of REG_SPI_NFI_CNFG and REG_SPI_NFI_SECCUS_SIZE registers This just reduce the number of modification of REG_SPI_NFI_CNFG and @@ -12,6 +12,8 @@ from SNFI registers during driver startup. Signed-off-by: Mikhail Kshevetskiy Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-11-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 135 +++++++++++++++++++++++++--------- 1 file changed, 102 insertions(+), 33 deletions(-) @@ -103,7 +105,7 @@ Reviewed-by: AngeloGioacchino Del Regno regmap_nfi, REG_SPI_NFI_CMD, 0x0); if (err) goto error_dma_unmap; -@@ -819,7 +855,48 @@ static ssize_t airoha_snand_dirmap_write +@@ -815,7 +851,48 @@ static ssize_t airoha_snand_dirmap_write if (err < 0) return err; @@ -153,7 +155,7 @@ Reviewed-by: AngeloGioacchino Del Regno regmap_nfi, REG_SPI_NFI_SNF_MISC_CTL2, SPI_NFI_PROG_LOAD_BYTE_NUM, val); -@@ -861,22 +946,6 @@ static ssize_t airoha_snand_dirmap_write +@@ -857,22 +942,6 @@ static ssize_t airoha_snand_dirmap_write if (err) goto error_dma_unmap; diff --git a/target/linux/airoha/patches-6.12/029-12-spi-airoha-set-custom-sector-size-equal-to-flash-.patch b/target/linux/airoha/patches-6.12/029-11-v6.19-spi-airoha-set-custom-sector-size-equal-to-flash-pag.patch similarity index 91% rename from target/linux/airoha/patches-6.12/029-12-spi-airoha-set-custom-sector-size-equal-to-flash-.patch rename to target/linux/airoha/patches-6.12/029-11-v6.19-spi-airoha-set-custom-sector-size-equal-to-flash-pag.patch index d9f35366b4..514212835c 100644 --- a/target/linux/airoha/patches-6.12/029-12-spi-airoha-set-custom-sector-size-equal-to-flash-.patch +++ b/target/linux/airoha/patches-6.12/029-11-v6.19-spi-airoha-set-custom-sector-size-equal-to-flash-pag.patch @@ -1,8 +1,8 @@ -From 893ee23d650ca9ee36541b9a5ae0bc18be01a11f Mon Sep 17 00:00:00 2001 +From fb81b5cecb8553e3ca2b45288cf340d43c9c2991 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Thu, 14 Aug 2025 22:47:17 +0300 -Subject: [PATCH v6 12/13] spi: airoha: set custom sector size equal to flash - page size +Date: Sun, 12 Oct 2025 15:17:02 +0300 +Subject: [PATCH 11/14] spi: airoha: set custom sector size equal to flash page + size Set custom sector size equal to flash page size including oob. Thus we will always read a single sector. The maximum custom sector size is @@ -13,6 +13,8 @@ from SNFI registers during driver startup. Signed-off-by: Mikhail Kshevetskiy Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-12-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) @@ -102,7 +104,7 @@ Reviewed-by: AngeloGioacchino Del Regno info.op_tmpl.cmd.opcode; switch (opcode) { case SPI_NAND_OP_PROGRAM_LOAD_SINGLE: -@@ -884,18 +889,17 @@ static ssize_t airoha_snand_dirmap_write +@@ -880,18 +885,17 @@ static ssize_t airoha_snand_dirmap_write goto error_dma_mode_off; /* Set number of sector will be written */ @@ -124,7 +126,7 @@ Reviewed-by: AngeloGioacchino Del Regno -Date: Thu, 14 Aug 2025 23:56:24 +0300 -Subject: [PATCH v6 13/13] spi: airoha: avoid reading flash page settings from +Date: Sun, 12 Oct 2025 15:17:03 +0300 +Subject: [PATCH 12/14] spi: airoha: avoid reading flash page settings from SNFI registers during driver startup The spinand driver do 3 type of dirmap requests: @@ -25,6 +25,8 @@ SNFI registers during driver startup. Also airoha_snand_adjust_op_size() function becomes unnecessary. Signed-off-by: Mikhail Kshevetskiy +Link: https://patch.msgid.link/20251012121707.2296160-13-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 115 ++-------------------------------- 1 file changed, 5 insertions(+), 110 deletions(-) @@ -148,7 +150,7 @@ Signed-off-by: Mikhail Kshevetskiy opcode = desc->info.op_tmpl.cmd.opcode; switch (opcode) { -@@ -1080,7 +1006,6 @@ static int airoha_snand_exec_op(struct s +@@ -1076,7 +1002,6 @@ static int airoha_snand_exec_op(struct s } static const struct spi_controller_mem_ops airoha_snand_mem_ops = { @@ -156,7 +158,7 @@ Signed-off-by: Mikhail Kshevetskiy .supports_op = airoha_snand_supports_op, .exec_op = airoha_snand_exec_op, .dirmap_create = airoha_snand_dirmap_create, -@@ -1105,36 +1030,6 @@ static int airoha_snand_setup(struct spi +@@ -1101,36 +1026,6 @@ static int airoha_snand_setup(struct spi return 0; } @@ -193,7 +195,7 @@ Signed-off-by: Mikhail Kshevetskiy static const struct regmap_config spi_ctrl_regmap_config = { .name = "ctrl", .reg_bits = 32, -@@ -1208,7 +1103,7 @@ static int airoha_snand_probe(struct pla +@@ -1204,7 +1099,7 @@ static int airoha_snand_probe(struct pla ctrl->setup = airoha_snand_setup; device_set_node(&ctrl->dev, dev_fwnode(dev)); diff --git a/target/linux/airoha/patches-6.12/029-09-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch b/target/linux/airoha/patches-6.12/029-13-v6.19-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch similarity index 63% rename from target/linux/airoha/patches-6.12/029-09-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch rename to target/linux/airoha/patches-6.12/029-13-v6.19-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch index 7eef83d562..669f9b2dd4 100644 --- a/target/linux/airoha/patches-6.12/029-09-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch +++ b/target/linux/airoha/patches-6.12/029-13-v6.19-spi-airoha-buffer-must-be-0xff-ed-before-writing.patch @@ -1,7 +1,7 @@ -From 6ca9cd453cb5d8a6411791295771b4dbd1c623de Mon Sep 17 00:00:00 2001 +From 0743acf746a81e0460a56fd5ff847d97fa7eb370 Mon Sep 17 00:00:00 2001 From: Mikhail Kshevetskiy -Date: Mon, 11 Aug 2025 21:18:04 +0300 -Subject: [PATCH v6 09/13] spi: airoha: buffer must be 0xff-ed before writing +Date: Sun, 12 Oct 2025 15:17:04 +0300 +Subject: [PATCH 13/14] spi: airoha: buffer must be 0xff-ed before writing During writing, the entire flash page (including OOB) will be updated with the values from the temporary buffer, so we need to fill the @@ -9,13 +9,16 @@ untouched areas of the buffer with 0xff value to prevent accidental data overwriting. Signed-off-by: Mikhail Kshevetskiy +Reviewed-by: AngeloGioacchino Del Regno +Link: https://patch.msgid.link/20251012121707.2296160-14-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown --- drivers/spi/spi-airoha-snfi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/spi/spi-airoha-snfi.c +++ b/drivers/spi/spi-airoha-snfi.c -@@ -847,7 +847,11 @@ static ssize_t airoha_snand_dirmap_write +@@ -776,7 +776,11 @@ static ssize_t airoha_snand_dirmap_write return -EOPNOTSUPP; } diff --git a/target/linux/airoha/patches-6.12/029-14-spi-airoha-snfi-en7523-workaround-flash-damaging.patch b/target/linux/airoha/patches-6.12/029-14-spi-airoha-snfi-en7523-workaround-flash-damaging.patch deleted file mode 100644 index c40645b002..0000000000 --- a/target/linux/airoha/patches-6.12/029-14-spi-airoha-snfi-en7523-workaround-flash-damaging.patch +++ /dev/null @@ -1,97 +0,0 @@ -From 86f88e604305186aec1fb6eebbf8f0a42c2435d3 Mon Sep 17 00:00:00 2001 -From: Mikhail Kshevetskiy -Date: Thu, 9 Oct 2025 19:33:23 +0300 -Subject: [PATCH] spi: airoha-snfi: en7523: workaround flash damaging - if UART_TXD was short to GND - -We found that some serial console may pull TX line to GROUND during board -boot time. Airoha uses TX line as one of it's BOOT pins. This will lead -to booting in RESERVED boot mode. - -It was found that some flashes operates incorrectly in RESERVED mode. -Micron and Skyhigh flashes are definitely affected by the issue, -Winbond flashes are NOT affected. - -Details: --------- -DMA reading of odd pages on affected flashes operates incorrectly. Page -reading offset (start of the page) on hardware level is replaced by 0x10. -Thus results in incorrect data reading. Usage of UBI make things even -worse. Any attempt to access UBI leads to ubi damaging. As result OS loading -becomes impossible. - -Non-DMA reading is OK. - -This patch detects booting in reserved mode, turn off DMA and print big -fat warning. - -Signed-off-by: Mikhail Kshevetskiy ---- - drivers/spi/spi-airoha-snfi.c | 40 ++++++++++++++++++++++++++++++----- - 1 file changed, 35 insertions(+), 5 deletions(-) - ---- a/drivers/spi/spi-airoha-snfi.c -+++ b/drivers/spi/spi-airoha-snfi.c -@@ -1013,6 +1013,11 @@ static const struct spi_controller_mem_o - .dirmap_write = airoha_snand_dirmap_write, - }; - -+static const struct spi_controller_mem_ops airoha_snand_nodma_mem_ops = { -+ .supports_op = airoha_snand_supports_op, -+ .exec_op = airoha_snand_exec_op, -+}; -+ - static int airoha_snand_setup(struct spi_device *spi) - { - struct airoha_snand_ctrl *as_ctrl; -@@ -1058,7 +1063,8 @@ static int airoha_snand_probe(struct pla - struct device *dev = &pdev->dev; - struct spi_controller *ctrl; - void __iomem *base; -- int err; -+ int err, dma_enabled; -+ u32 sfc_strap; - - ctrl = devm_spi_alloc_host(dev, sizeof(*as_ctrl)); - if (!ctrl) -@@ -1092,12 +1098,36 @@ static int airoha_snand_probe(struct pla - return dev_err_probe(dev, PTR_ERR(as_ctrl->spi_clk), - "unable to get spi clk\n"); - -- err = dma_set_mask(as_ctrl->dev, DMA_BIT_MASK(32)); -- if (err) -- return err; -+ dma_enabled = 1; -+ if (device_is_compatible(dev, "airoha,en7523-snand")) { -+ err = regmap_read(as_ctrl->regmap_ctrl, -+ REG_SPI_CTRL_SFC_STRAP, &sfc_strap); -+ if (err) -+ return err; -+ -+ if (!(sfc_strap & 0x04)) { -+ dma_enabled = 0; -+ printk(KERN_WARNING "\n" -+ "=== WARNING ======================================================\n" -+ "Detected booting in RESERVED mode (UART_TXD was short to GND).\n" -+ "This mode is known for incorrect DMA reading of some flashes.\n" -+ "Usage of DMA for flash operations will be disabled to prevent data\n" -+ "damage. Unplug your serial console and power cycle the board\n" -+ "to boot with full performance.\n" -+ "==================================================================\n\n"); -+ } -+ } -+ -+ if (dma_enabled) { -+ err = dma_set_mask(as_ctrl->dev, DMA_BIT_MASK(32)); -+ if (err) -+ return err; -+ } - - ctrl->num_chipselect = 2; -- ctrl->mem_ops = &airoha_snand_mem_ops; -+ ctrl->mem_ops = dma_enabled ? -+ &airoha_snand_mem_ops : -+ &airoha_snand_nodma_mem_ops; - ctrl->bits_per_word_mask = SPI_BPW_MASK(8); - ctrl->mode_bits = SPI_RX_DUAL; - ctrl->setup = airoha_snand_setup; diff --git a/target/linux/airoha/patches-6.12/029-14-v6.19-spi-airoha-snfi-en7523-workaround-flash-damaging-if-.patch b/target/linux/airoha/patches-6.12/029-14-v6.19-spi-airoha-snfi-en7523-workaround-flash-damaging-if-.patch new file mode 100644 index 0000000000..cd5962445e --- /dev/null +++ b/target/linux/airoha/patches-6.12/029-14-v6.19-spi-airoha-snfi-en7523-workaround-flash-damaging-if-.patch @@ -0,0 +1,102 @@ +From 061795b345aff371df8f71d54ae7c7dc8ae630d0 Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Wed, 26 Nov 2025 02:40:45 +0300 +Subject: [PATCH 14/14] spi: airoha-snfi: en7523: workaround flash damaging if + UART_TXD was short to GND + +Airoha EN7523 specific bug +-------------------------- +We found that some serial console may pull TX line to GROUND during board +boot time. Airoha uses TX line as one of its bootstrap pins. On the EN7523 +SoC this may lead to booting in RESERVED boot mode. + +It was found that some flashes operates incorrectly in RESERVED mode. +Micron and Skyhigh flashes are definitely affected by the issue, +Winbond flashes are not affected. + +Details: +-------- +DMA reading of odd pages on affected flashes operates incorrectly. Page +reading offset (start of the page) on hardware level is replaced by 0x10. +Thus results in incorrect data reading. As result OS loading becomes +impossible. + +Usage of UBI make things even worse. On attaching, UBI will detects +corruptions (because of wrong reading of odd pages) and will try to +recover. For recovering UBI will erase and write 'damaged' blocks with +a valid information. This will destroy all UBI data. + +Non-DMA reading is OK. + +This patch detects booting in reserved mode, turn off DMA and print big +fat warning. + +It's worth noting that the boot configuration is preserved across reboots. +Therefore, to boot normally, you should do the following: +- disconnect the serial console from the board, +- power cycle the board. + +Fixes: a403997c12019 ("spi: airoha: add SPI-NAND Flash controller driver") +Signed-off-by: Mikhail Kshevetskiy +Reviewed-by: AngeloGioacchino Del Regno +Reviewed-by: Andy Shevchenko +Link: https://patch.msgid.link/20251125234047.1101985-2-mikhail.kshevetskiy@iopsys.eu +Signed-off-by: Mark Brown +--- + drivers/spi/spi-airoha-snfi.c | 25 ++++++++++++++++++++++++- + 1 file changed, 24 insertions(+), 1 deletion(-) + +--- a/drivers/spi/spi-airoha-snfi.c ++++ b/drivers/spi/spi-airoha-snfi.c +@@ -1013,6 +1013,11 @@ static const struct spi_controller_mem_o + .dirmap_write = airoha_snand_dirmap_write, + }; + ++static const struct spi_controller_mem_ops airoha_snand_nodma_mem_ops = { ++ .supports_op = airoha_snand_supports_op, ++ .exec_op = airoha_snand_exec_op, ++}; ++ + static int airoha_snand_setup(struct spi_device *spi) + { + struct airoha_snand_ctrl *as_ctrl; +@@ -1057,7 +1062,9 @@ static int airoha_snand_probe(struct pla + struct airoha_snand_ctrl *as_ctrl; + struct device *dev = &pdev->dev; + struct spi_controller *ctrl; ++ bool dma_enable = true; + void __iomem *base; ++ u32 sfc_strap; + int err; + + ctrl = devm_spi_alloc_host(dev, sizeof(*as_ctrl)); +@@ -1092,12 +1099,28 @@ static int airoha_snand_probe(struct pla + return dev_err_probe(dev, PTR_ERR(as_ctrl->spi_clk), + "unable to get spi clk\n"); + ++ if (device_is_compatible(dev, "airoha,en7523-snand")) { ++ err = regmap_read(as_ctrl->regmap_ctrl, ++ REG_SPI_CTRL_SFC_STRAP, &sfc_strap); ++ if (err) ++ return err; ++ ++ if (!(sfc_strap & 0x04)) { ++ dma_enable = false; ++ dev_warn(dev, "Detected booting in RESERVED mode (UART_TXD was short to GND).\n"); ++ dev_warn(dev, "This mode is known for incorrect DMA reading of some flashes.\n"); ++ dev_warn(dev, "Much slower PIO mode will be used to prevent flash data damage.\n"); ++ dev_warn(dev, "Unplug UART cable and power cycle board to get full performance.\n"); ++ } ++ } ++ + err = dma_set_mask(as_ctrl->dev, DMA_BIT_MASK(32)); + if (err) + return err; + + ctrl->num_chipselect = 2; +- ctrl->mem_ops = &airoha_snand_mem_ops; ++ ctrl->mem_ops = dma_enable ? &airoha_snand_mem_ops ++ : &airoha_snand_nodma_mem_ops; + ctrl->bits_per_word_mask = SPI_BPW_MASK(8); + ctrl->mode_bits = SPI_RX_DUAL; + ctrl->setup = airoha_snand_setup; diff --git a/target/linux/airoha/patches-6.12/029-15-arm-dts-airoha-en7523-add-SNAND-node.patch b/target/linux/airoha/patches-6.12/029-15-arm-dts-airoha-en7523-add-SNAND-node.patch new file mode 100644 index 0000000000..bd68440b30 --- /dev/null +++ b/target/linux/airoha/patches-6.12/029-15-arm-dts-airoha-en7523-add-SNAND-node.patch @@ -0,0 +1,40 @@ +From bb2f9b3d71717c7df942deb1488c56e544d4a32c Mon Sep 17 00:00:00 2001 +From: Mikhail Kshevetskiy +Date: Fri, 10 Oct 2025 06:01:33 +0300 +Subject: [PATCH v6 3/3] arm: dts: airoha: en7523: add SNAND node + +Add SNAND node to enable support of attached SPI-NAND on the EN7523 SoC. + +Signed-off-by: Mikhail Kshevetskiy +Reviewed-by: AngeloGioacchino Del Regno +--- + arch/arm/boot/dts/airoha/en7523.dtsi | 20 ++++++++++++++++++++ + 1 file changed, 20 insertions(+) + +--- a/arch/arm/boot/dts/airoha/en7523.dtsi ++++ b/arch/arm/boot/dts/airoha/en7523.dtsi +@@ -203,4 +203,24 @@ + #interrupt-cells = <1>; + }; + }; ++ ++ spi_ctrl: spi@1fa10000 { ++ compatible = "airoha,en7523-snand", "airoha,en7581-snand"; ++ reg = <0x1fa10000 0x140>, ++ <0x1fa11000 0x160>; ++ ++ clocks = <&scu EN7523_CLK_SPI>; ++ clock-names = "spi"; ++ ++ #address-cells = <1>; ++ #size-cells = <0>; ++ ++ nand: nand@0 { ++ compatible = "spi-nand"; ++ reg = <0>; ++ spi-max-frequency = <50000000>; ++ spi-tx-bus-width = <1>; ++ spi-rx-bus-width = <2>; ++ }; ++ }; + }; -- 2.30.2