ramips: add support for JCG Y2
authorChukun Pan <amadeus@jmu.edu.cn>
Mon, 8 Feb 2021 08:28:10 +0000 (16:28 +0800)
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>
Tue, 9 Feb 2021 12:10:33 +0000 (13:10 +0100)
JCG Y2 is an AC1300M router

Hardware specs:
  SoC: MediaTek MT7621AT
  Flash: Winbond W25Q128JVSQ 16MiB
  RAM: Nanya NT5CB128M16 256MiB
  WLAN: 2.4/5 GHz 2T2R (1x MediaTek MT7615)
  Ethernet: 10/100/1000 Mbps x5
  LED: POWER, INTERNET, 2.4G, 5G
  Button: Reset
  Power: DC 12V,1A

Flash instructions:
  Upload factory.bin in stock firmware's upgrade page.

MAC addresses map:
  0x0004  *:c8  wlan2g/wlan5g/label
  0xe000  *:c7  lan
  0xe006  *:c6  wan

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
target/linux/ramips/dts/mt7621_jcg_y2.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
target/linux/ramips/mt7621/base-files/etc/board.d/02_network

diff --git a/target/linux/ramips/dts/mt7621_jcg_y2.dts b/target/linux/ramips/dts/mt7621_jcg_y2.dts
new file mode 100644 (file)
index 0000000..06d6579
--- /dev/null
@@ -0,0 +1,130 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "jcg,y2", "mediatek,mt7621-soc";
+       model = "JCG Y2";
+
+       aliases {
+               led-boot = &led_internet;
+               led-failsafe = &led_internet;
+               led-upgrade = &led_internet;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_internet: internet {
+                       label = "blue:internet";
+                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+};
+
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               compatible = "jedec,spi-nor";
+               reg = <0>;
+               spi-max-frequency = <80000000>;
+               m25p,fast-read;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "bootloader";
+                               reg = <0x0 0x30000>;
+                               read-only;
+                       };
+
+                       partition@30000 {
+                               label = "config";
+                               reg = <0x30000 0x10000>;
+                               read-only;
+                       };
+
+                       factory: partition@40000 {
+                               label = "factory";
+                               reg = <0x40000 0x10000>;
+                               read-only;
+                       };
+
+                       partition@50000 {
+                               compatible = "denx,uimage";
+                               label = "firmware";
+                               reg = <0x50000 0xfb0000>;
+                       };
+               };
+       };
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie0 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x0>;
+       };
+};
+
+&gmac0 {
+       mtd-mac-address = <&factory 0xe000>;
+};
+
+&switch0 {
+       ports {
+               port@0 {
+                       status = "okay";
+                       label = "lan4";
+               };
+
+               port@1 {
+                       status = "okay";
+                       label = "lan3";
+               };
+
+               port@2 {
+                       status = "okay";
+                       label = "lan2";
+               };
+
+               port@3 {
+                       status = "okay";
+                       label = "lan1";
+               };
+
+               wan: port@4 {
+                       status = "okay";
+                       label = "wan";
+                       mtd-mac-address = <&factory 0xe006>;
+               };
+       };
+};
+
+&state_default {
+       gpio {
+               groups = "jtag", "wdt";
+               function = "gpio";
+       };
+};
index 3aaa8f2..39a4d03 100644 (file)
@@ -684,6 +684,19 @@ define Device/jcg_jhr-ac876m
 endef
 TARGET_DEVICES += jcg_jhr-ac876m
 
+define Device/jcg_y2
+  $(Device/dsa-migration)
+  $(Device/uimage-lzma-loader)
+  IMAGE_SIZE := 16064k
+  IMAGES += factory.bin
+  IMAGE/factory.bin := $$(sysupgrade_bin) | check-size | jcg-header 95.1
+  JCG_MAXSIZE := 16064k
+  DEVICE_VENDOR := JCG
+  DEVICE_MODEL := Y2
+  DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware kmod-usb3
+endef
+TARGET_DEVICES += jcg_y2
+
 define Device/lenovo_newifi-d1
   $(Device/dsa-migration)
   $(Device/uimage-lzma-loader)
index 8d91b36..5fa9ad3 100755 (executable)
@@ -19,6 +19,7 @@ d-team,newifi-d2)
        ;;
 d-team,pbr-m1|\
 gehua,ghl-r-001|\
+jcg,y2|\
 xzwifi,creativebox-v1)
        ucidef_set_led_netdev "internet" "internet" "blue:internet" "wan"
        ;;
index dbb8e04..46cb65f 100755 (executable)
@@ -113,6 +113,14 @@ ramips_setup_macs()
                wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr)
                label_mac=$wan_mac
                ;;
+       jcg,y2|\
+       wavlink,wl-wn531a6|\
+       winstars,ws-wn583a6|\
+       zbtlink,zbt-we1326|\
+       zbtlink,zbt-wg3526-16m|\
+       zbtlink,zbt-wg3526-32m)
+               label_mac=$(mtd_get_mac_binary factory 0x4)
+               ;;
        linksys,ea7300-v1|\
        linksys,ea7300-v2|\
        linksys,ea7500-v2)
@@ -128,13 +136,6 @@ ramips_setup_macs()
                wan_mac=$label_mac
                lan_mac=$(macaddr_add $label_mac 1)
                ;;
-       wavlink,wl-wn531a6|\
-       winstars,ws-wn583a6|\
-       zbtlink,zbt-we1326|\
-       zbtlink,zbt-wg3526-16m|\
-       zbtlink,zbt-wg3526-32m)
-               label_mac=$(mtd_get_mac_binary factory 0x4)
-               ;;
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac