--- /dev/null
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7620a.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+/ {
+ aliases {
+ label-mac-device = ðernet;
+
+ led-boot = &status_green;
+ led-failsafe = &status_amber;
+ led-running = &status_green;
+ led-upgrade = &status_amber;
+ };
+
+ keys {
+ compatible = "gpio-keys";
+
+ button-0 {
+ label = "reset";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
+ debounce-interval = <60>;
+ };
+
+ button-1 {
+ label = "wps";
+ linux,code = <KEY_RESTART>;
+ gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
+ debounce-interval = <60>;
+ };
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ status_green: led-0 {
+ label = "green:status";
+ gpios = <&gpio0 9 GPIO_ACTIVE_LOW>;
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_STATUS;
+ };
+
+ status_amber: led-1 {
+ label = "amber:status";
+ gpios = <&gpio0 10 GPIO_ACTIVE_LOW>;
+ color = <LED_COLOR_ID_AMBER>;
+ function = LED_FUNCTION_STATUS;
+ };
+
+ led-2 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_WAN;
+ gpios = <&gpio2 0 GPIO_ACTIVE_LOW>;
+ };
+
+ led-3 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_LAN;
+ function-enumerator = <1>;
+ gpios = <&gpio2 1 GPIO_ACTIVE_LOW>;
+ };
+
+ led-4 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_LAN;
+ function-enumerator = <2>;
+ gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
+ };
+
+ led-5 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_LAN;
+ function-enumerator = <3>;
+ gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
+ };
+
+ led-6 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_LAN;
+ function-enumerator = <4>;
+ gpios = <&gpio2 4 GPIO_ACTIVE_LOW>;
+ };
+
+ led-7 {
+ color = <LED_COLOR_ID_GREEN>;
+ function = LED_FUNCTION_WLAN;
+ function-enumerator = <24>;
+ gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
+ linux,default-trigger = "phy1tpt";
+ };
+ };
+
+ virtual_flash {
+ compatible = "mtd-concat";
+
+ devices = <&fwconcat0 &fwconcat1>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ compatible = "openwrt,uimage";
+ /* sercomm krnl hdr with fw chksums */
+ openwrt,offset = <0x100>;
+ label = "firmware";
+ reg = <0x0 0x0>;
+ };
+ };
+ };
+};
+
+ðernet {
+ nvmem-cells = <&macaddr_label 0>;
+ nvmem-cell-names = "mac-address";
+};
+
+&gpio1 {
+ status = "okay";
+};
+
+&gpio2 {
+ status = "okay";
+};
+
+&gpio3 {
+ status = "okay";
+};
+
+&pcie {
+ status = "okay";
+};
+
+/* mt7612 */
+&pcie0 {
+ wifi@0,0 {
+ compatible = "mediatek,mt76";
+ reg = <0x0000 0 0 0 0>;
+ ieee80211-freq-limit = <5000000 6000000>;
+
+ nvmem-cells = <&eeprom_factory_8000>, <&macaddr_label 6>;
+ nvmem-cell-names = "eeprom", "mac-address";
+
+ /* 5 GHz WLAN phy green led */
+ led {
+ led-sources = <2>;
+ led-active-low;
+ };
+ };
+};
+
+&spi0 {
+ status = "okay";
+
+ flash@0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <70000000>;
+ m25p,fast-read;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ /* whole flash */
+ partition@0_all {
+ label = "ALL";
+ reg = <0x0 0x1000000>;
+ read-only;
+ };
+
+ partition@0 {
+ label = "u-boot";
+ reg = <0x0 0x30000>;
+ read-only;
+ };
+
+ partition@30000 {
+ label = "ftd_and_bootflag";
+ reg = <0x30000 0x20000>;
+ };
+
+ factory: partition@50000 {
+ label = "Factory";
+ reg = <0x50000 0x10000>;
+ read-only;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ eeprom_factory_8000: eeprom@8000 {
+ reg = <0x8000 0x200>;
+ };
+ };
+ };
+
+ partition@60000 {
+ label = "SC Nvram(permanent data)";
+ reg = <0x60000 0x10000>;
+ read-only;
+
+ nvmem-layout {
+ compatible = "fixed-layout";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ macaddr_label: macaddr@0 {
+ compatible = "mac-base";
+ reg = <0x0 0x6>;
+ #nvmem-cell-cells = <1>;
+ };
+ };
+ };
+
+ fwconcat0: partition@70000 {
+ label = "Firmware";
+ reg = <0x70000 0x790000>;
+
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "Kernel";
+ reg = <0x0 0x200000>;
+ };
+
+ partition@200000 {
+ label = "RootFS";
+ reg = <0x200000 0x590000>;
+ };
+ };
+
+ fwconcat1: partition@800000 {
+ label = "Firmware2";
+ reg = <0x800000 0x790000>;
+
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "Kernel2";
+ reg = <0x0 0x200000>;
+ };
+
+ partition@200000 {
+ label = "RootFS2";
+ reg = <0x200000 0x590000>;
+ };
+ };
+
+ partition@f90000 {
+ label = "MAC IP";
+ reg = <0xf90000 0x10000>;
+ read-only;
+ };
+
+ partition@fa0000 {
+ label = "Critical Log";
+ reg = <0xfa0000 0x10000>;
+ read-only;
+ };
+
+ partition@fb000 {
+ label = "Critical Log Bak";
+ reg = <0xfb0000 0x10000>;
+ read-only;
+ };
+
+ partition@fc0000 {
+ label = "Xml Config";
+ reg = <0xfc0000 0x20000>;
+ read-only;
+ };
+
+ partition@fe0000 {
+ label = "Xml Config Bak";
+ reg = <0xfe0000 0x20000>;
+ read-only;
+ };
+ };
+ };
+};
+
+&state_default {
+ gpio {
+ groups = "ephy", "rgmii1", "uartf", "wled";
+ function = "gpio";
+ };
+};
+
+/* mt7620 */
+&wmac {
+ nvmem-cells = <&macaddr_label 2>;
+ nvmem-cell-names = "mac-address";
+
+ ralink,mtd-eeprom = <&factory 0x0>;
+};
rm -f $@.enc $@.key
endef
+define Build/sercomm-factory-cpj
+ dd bs=$$((0x1fff00)) count=1 if=$@ of=$@.kernel conv=notrunc \
+ 2>/dev/null
+ dd bs=$$((0x1fff00)) skip=1 if=$@ of=$@.rootfs1 conv=notrunc \
+ 2>/dev/null
+ cp $@.rootfs1 $@.rootfs2
+ $(TOPDIR)/scripts/sercomm-kernel-header.py \
+ --kernel-image $@.kernel \
+ --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
+ --rootfs-image $@.rootfs1 \
+ --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
+ --output-header $@.header1
+ $(TOPDIR)/scripts/sercomm-kernel-header.py \
+ --kernel-image $@.kernel \
+ --kernel-offset $(SERCOMM_KERNEL2_OFFSET) \
+ --rootfs-image $@.rootfs2 \
+ --rootfs-offset $(SERCOMM_ROOTFS2_OFFSET) \
+ --output-header $@.header2
+ cat $@.header1 $@.kernel > $@.kernel1
+ cat $@.header2 $@.kernel > $@.kernel2
+ rm $@.header1 $@.header2 $@.kernel
+ $(call Build/sercomm-part-tag-common,kernel $@.kernel1)
+ $(call Build/sercomm-part-tag-common,kernel2 $@.kernel2)
+ $(call Build/sercomm-part-tag-common,rootfs $@.rootfs1)
+ $(call Build/sercomm-part-tag-common,rootfs2 $@.rootfs2)
+ cat $@.kernel2 $@.rootfs2 $@.kernel1 $@.rootfs1 > $@
+ rm $@.kernel1 $@.rootfs1 $@.kernel2 $@.rootfs2
+endef
+
define Build/sercomm-factory-cqr
$(TOPDIR)/scripts/sercomm-pid.py \
--hw-version $(SERCOMM_HWVER) \
dd of=$@ seek=$$((0x118)) bs=1 conv=notrunc 2>/dev/null
endef
+define Build/sercomm-sysupgrade-cpj
+ dd bs=$$((0x1fff00)) count=1 if=$@ of=$@.kernel conv=notrunc \
+ 2>/dev/null
+ dd bs=$$((0x1fff00)) skip=1 if=$@ of=$@.rootfs conv=notrunc \
+ 2>/dev/null
+ $(TOPDIR)/scripts/sercomm-kernel-header.py \
+ --kernel-image $@.kernel \
+ --kernel-offset $(SERCOMM_KERNEL_OFFSET) \
+ --rootfs-image $@.rootfs \
+ --rootfs-offset $(SERCOMM_ROOTFS_OFFSET) \
+ --output-header $@.header
+ cat $@.header $@.kernel $@.rootfs > $@
+ rm $@.header $@.kernel $@.rootfs
+endef
+
define Device/sercomm
$(Device/nand)
LOADER_TYPE := bin
IMAGES += factory.img
endef
+define Device/sercomm_cpj
+ SOC := mt7620a
+ DEVICE_VENDOR := Rostelecom
+ DEVICE_ALT0_VENDOR := Sercomm
+ IMAGE_SIZE := 7743k
+ SERCOMM_HWID := CPJ
+ SERCOMM_HWVER := 10000
+ SERCOMM_SWVER := 1001
+ SERCOMM_KERNEL_OFFSET := 0x70100
+ SERCOMM_ROOTFS_OFFSET := 0x270000
+ SERCOMM_KERNEL2_OFFSET := 0x800100
+ SERCOMM_ROOTFS2_OFFSET := 0xa00000
+ IMAGE/sysupgrade.bin := append-kernel | append-rootfs | \
+ sercomm-sysupgrade-cpj | pad-rootfs | check-size | \
+ append-metadata
+ ARTIFACTS := initramfs-factory.img
+ DEVICE_PACKAGES := kmod-mt76x2
+endef
+
define Device/sercomm_cxx_dxx
$(Device/sercomm)
KERNEL_SIZE := 6144k