From f380b140cbb21267ca4217d10afb22ac285fd2c3 Mon Sep 17 00:00:00 2001
From: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Date: Tue, 19 Nov 2024 13:59:30 +0400
Subject: [PATCH] airoha: add en7581_emmc board variant (based on en7581_kite)

---
 airoha/dts/en7581_emmc.dts | 47 ++++++++++++++++++++++++++++++++++++++
 airoha/image/an7581.mk     |  2 +-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 airoha/dts/en7581_emmc.dts

diff --git a/airoha/dts/en7581_emmc.dts b/airoha/dts/en7581_emmc.dts
new file mode 100644
index 000000000..d1b6cbb1a
--- /dev/null
+++ b/airoha/dts/en7581_emmc.dts
@@ -0,0 +1,47 @@
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/leds/common.h>
+#include <dt-bindings/input/input.h>
+
+/dts-v1/;
+
+#include "en7581-base.dtsi"
+
+/* This is a temporary solution until we can use the upstream way of defining partitions in device-tree
+ * Both defines below need to be in sync. U-Boot uses LBA in hex (512bytes), Linux uses MiB/KiB/bytes
+ */
+#define TOSTR_(x...) #x
+#define STRINGIFY(x) TOSTR_(x)
+
+#define PARTITIONS_UBOOT_BLKMAP blkmap create u-boot && blkmap map u-boot 0 800 linear mmc 0.0 0x0 && blkmap create env1 && blkmap map env1 0 400 linear mmc 0.0 0x1000 && blkmap create env2 && blkmap map env2 0 400 linear mmc 0.0 0x1400 && blkmap create art && blkmap map art 0 4000 linear mmc 0.0 0x1800 && blkmap create boarddata && blkmap map boarddata 0 2800 linear mmc 0.0 0x5800 && blkmap create boot1 && blkmap map boot1 0 30000 linear mmc 0.0 0x8000 && blkmap create rootfs1 && blkmap map rootfs1 0 48000 linear mmc 0.0 0x38000 && blkmap create overlay1 && blkmap map overlay1 0 28000 linear mmc 0.0 0x80000 && blkmap create boot2 && blkmap map boot2 0 30000 linear mmc 0.0 0xA8000 && blkmap create rootfs2 && blkmap map rootfs2 0 48000 linear mmc 0.0 0xD8000 && blkmap create overlay2 && blkmap map overlay2 0 28000 linear mmc 0.0 0x120000 && blkmap create usr_data && blkmap map usr_data 0 25B800 linear mmc 0.0 0x148000
+#define PARTITIONS_CMDLINE blkdevparts=mmcblk0:1M@0M(bootloader),512K@2M(env1),512K@2560K(env2),8M@3M(art),5M@11M(boarddata),96M@16M(boot1),144M@112M(rootfs1),80M@256M(overlay1),96M@336M(boot2),144M@432M(rootfs2),80M@576M(overlay2),1207M@656M(usr_data)
+&mmc0 {
+	card@0 {
+		compatible = "mmc-card";
+		reg = <0>;
+
+		partitions {
+			u-boot-blkmap = STRINGIFY(PARTITIONS_UBOOT_BLKMAP);
+			linux-bootargs = STRINGIFY(PARTITIONS_CMDLINE);
+			linux-bootargs1 = STRINGIFY(PARTITIONS_CMDLINE root=/dev/mmcblk0p7);
+			linux-bootargs2 = STRINGIFY(PARTITIONS_CMDLINE root=/dev/mmcblk0p10);
+		};
+	};
+};
+
+/ {
+	model = "EN75xx GENERIC";
+	compatible = "econet,en7581-emmc", "econet,en7581", "airoha,en7581";
+
+	chosen {
+		bootargs = "console=ttyS0,115200n8 qdma_init=bb onu_type=72 serdes_ethernet=112 serdes_wifi1=001 serdes_wifi2=001 serdes_usb1=000 serdes_usb2=002 serdes_pon=000";
+		stdout-path = &uart1;
+	};
+};
+
+
+&voip {
+	slic-power-mode = "none";
+};
+
diff --git a/airoha/image/an7581.mk b/airoha/image/an7581.mk
index 1edb9b962..101aa1a2b 100644
--- a/airoha/image/an7581.mk
+++ b/airoha/image/an7581.mk
@@ -24,7 +24,7 @@ endef
 
 define Device/en7581_evb
   DEVICE_MODEL := EN7581EVB
-  DEVICE_DTS := en7581_evb en7581_eagle en7581_kite
+  DEVICE_DTS := en7581_evb en7581_eagle en7581_kite en7581_emmc
   DEVICE_PACKAGES := $(DEFAULT_DEVICE_PACKAGES) \
                      $(PON_PACKAGES)
 endef
-- 
GitLab