From 1b5c6be7b6dc6c096e1fd55ce10809d350e3afab Mon Sep 17 00:00:00 2001
From: Linus Walleij <linusw@kernel.org>
Date: Mon, 26 Jan 2026 08:09:04 +0100
Subject: [PATCH] gemini: augment DTS with botched partitions

We override the RedBoot FIS partition table with a custom one
using fixed-partitions.

Mostly this is a 1-to-1 copy, but the three partitions called
"Kern", "Ramdisk" and "Application" are combined into one
called "firmware" which is optimal for OpenWrt.

The RedBoot bootloader still sees the three partitions and will
load the first two into memory to boot the system, which
is fine: the kernel will still be there.

To avoid confusing the MTD partition splitter we also need to
remove any command line root partition arguments.

Signed-off-by: Linus Walleij <linusw@kernel.org>
---
 arch/arm/boot/dts/gemini/gemini-nas4220b.dts | 39 ++++++++++++++++++--
 1 file changed, 35 insertions(+), 4 deletions(-)

--- a/arch/arm/boot/dts/gemini/gemini-nas4220b.dts
+++ b/arch/arm/boot/dts/gemini/gemini-nas4220b.dts
@@ -20,7 +20,7 @@
 	};
 
 	chosen {
-		bootargs = "console=ttyS0,19200n8 root=/dev/mtdblock3 rw rootfstype=squashfs,jffs2 rootwait";
+		bootargs = "console=ttyS0,19200n8";
 		stdout-path = &uart0;
 	};
 
@@ -82,10 +82,41 @@
 			/* 16MB of flash */
 			reg = <0x30000000 0x01000000>;
 
+			/*
+			 * Override the RedBoot partition table with fixed partitions
+			 * in order to create a coherent "firmware" partition so that
+			 * we can have optimal flash usage with OpenWrt in a big
+			 * MTD-splitted "firmware" partition.
+			 */
 			partitions {
-				compatible = "redboot-fis";
-				/* Eraseblock at 0xfe0000 */
-				fis-index-block = <0x7f>;
+				compatible = "fixed-partitions";
+				#address-cells = <1>;
+				#size-cells = <1>;
+				partition@0 {
+					label = "BOOT";
+					reg = <0x00000000 0x00020000>;
+					read-only;
+				};
+				partition@1 {
+					compatible = "openwrt,executable-prolog";
+					label = "firmware";
+					reg = <0x00020000 0x00f00000>;
+				};
+				partition@2 {
+					label = "VCTL";
+					reg = <0x00f20000 0x00020000>;
+					read-only;
+				};
+				partition@3 {
+					label = "CurConf";
+					reg = <0x00f40000 0x000a0000>;
+					read-only;
+				};
+				partition@4 {
+					label = "FIS directory";
+					reg = <0x00fe0000 0x00020000>;
+					read-only;
+				};
 			};
 		};
 
