[From nobody Thu Jun 25 05:55:17 2020
Received: from smtpbg520.qq.com ([203.205.250.49] helo=smtpbg.qq.com)
 by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux))
 id 1hpAXK-0003gw-Mg
 for openwrt-devel@lists.openwrt.org; Sun, 21 Jul 2019 12:02:01 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512;
 t=1563710478; bh=h7ybGguFhbDGItETp16LNoXBEYBEjVW/NxF2LLBm5I0=;
 h=From:To:Subject:Date:Message-Id;
 b=LvyV2Yb02VVqWtkXDHdg9UUhxMbuY0c3TgwlnCuGoJYSkd6v2qRlhHiPCs1AVIzlz
 Iy6aA1LlNbWI3TQRxG2hdKbUp9WebCK4ZtQ29zruj1yo4Y4GKokziW95VcSikU1Q69
 esf+1H0zL2By5ioxgqj3ahsMo/7CNi8xeLn4KF0c=
X-QQ-mid: esmtp5t1563710477tc5waqvwn
Received: from localhost.localdomain (unknown [125.121.24.57])
 by esmtp4.qq.com (ESMTP) with 
 id ; Sun, 21 Jul 2019 20:01:16 +0800 (CST)
X-QQ-SSF: B1000000000000F0FH100F00000000Z
X-QQ-FEAT: jfJxHuYZxOAnSQB0RsqFfnFsRW/cYG348sZ26tt9DFMYxfxj3wGXrSoL+uCVP
 qtCyObqiU1DuK4+NDDUk9NoT/iy1V95UMgneJ44yv16IyDArAkwuAVVRwclIYzo5S6mWD/Q
 K7H7x8PJDhV4qTfFUdksYkvxOkzB1rIE21HmKVuRqtzTCFp4DXe315J3hBoL51MqkHEoZVm
 tXtQw3RUVdpNlmYMiNdrGdQKUAvN1xMu6rnN+RgBH1CJNkHwlRRjjeW6y7XL91n5aMtOn80
 fsJ1I8sw/A3uv5fT7UbJB0SzQPAR1/tARsF5DEh+zGp/UmEVtWCw+yNWw=
X-QQ-GoodBg: 0
From: Robinson Wu &lt;wurobinson@qq.com&gt;
To: openwrt-devel@lists.openwrt.org
Cc: Robinson Wu &lt;wurobinson@qq.com&gt;
Subject: [PATCH] ramips: add support to JS7628 development board
Date: Sun, 21 Jul 2019 20:00:11 +0800
Message-Id: &lt;1563710411-54574-1-git-send-email-wurobinson@qq.com&gt;
X-Mailer: git-send-email 2.7.4
X-QQ-SENDSIZE: 520
Feedback-ID: esmtp:qq.com:bgweb:bgweb5
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 
X-CRM114-CacheID: sfid-20190721_050156_961013_335E2475 
X-CRM114-Status: GOOD (  10.68  )
X-Spam-Score: -0.2 (/)
X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary:
 Content analysis details:   (-0.2 points)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (wurobinson[at]qq.com)
 -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from
 envelope-from domain
 -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from
 author's domain
 -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature
 0.1 DKIM_SIGNED            Message has a DKIM or DK signature, not necessarily
 valid

This commit adds support for the ZhuoTK JS7628 development board,
The device has the following specifications:

- SOC:MT7628AN/NN
- RAM:64/128/256 MB (DDR2)
- FLASH:8/16/32 MB (SPI NOR)
- Ethernet:3x 10/100 Mbps ethernet ports (MT7628 built-in switch)
- WIFI:1x 2T2R 2.4 GHz Wi-Fi
- LEDs:1x system status green LED, 1x wifi green LED,
       3x ethernet green LED
- Buttons:1x reset button, 2x user defined button
- 1x microSD slot
- 4x USB 2.0 port
- 1x mini-usb debug UART
- 1x DC jack for main power (DC 5V)
- 1x TTL/RS232 UART
- 1x TTL/RS485 UART
- 13x GPIO header
- 1x audio codec(wm8960)

Installation via OpenWrt:

The original firmware is OpenWrt, so both LuCI or sysupgrade can be used.

Installation via U-boot web:

1. Power on board with reset button or key1 button pressed, release it
   after wifi led start blinking.
2. Setup static IP 192.168.1.123/4 on your PC.
3. Go to 192.168.1.8 in browser and upload &quot;sysupgrade&quot; image.

Installation via U-boot tftp:
1. Connect to serial console at the mini usb, which has been connected to UART0
   on board (115200 8N1)
2. Setup static IP 192.168.1.123/4 on your PC.
3. Place openwrt-firmware.bin on your PC tftp server (192.168.1.123).
3. Connect one of LAN ports on board to your PC.
4. Start terminal software (e.g. screen /dev/ttyUSB0 115200) on PC.
5. Apply power to board.
6. Interrupt U-boot with keypress of &quot;2&quot;.
7. At u-boot prompts:
   Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N) Y
   Input device IP (192.168.1.8) ==:192.168.1.8
   Input server IP (192.168.1.123) ==:192.168.1.123
   Input Linux Kernel filename (root_uImage) ==:openwrt-firmware.bin
8. board will download file from tftp server, write it to flash and reboot.

Other notes:

1. This board is available with three types of RAM with flash
   configuration. Chose one of the right &quot;Target Profile&quot; in
   &quot;make menuconfig&quot; as listed below:

   &quot;ZhuoTK JS7628 8M flash/64M RAM&quot;
   &quot;ZhuoTK JS7628 16M flash/128M RAM&quot;
   &quot;ZhuoTK JS7628 32M flash/256M RAM&quot;

   to fit the board you have.

Vist www.zhuotk.com for further information.

Signed-off-by: Robinson Wu &lt;wurobinson@qq.com&gt;
---
 target/linux/ramips/base-files/etc/board.d/01_leds |  6 ++
 .../linux/ramips/base-files/etc/board.d/02_network |  3 +
 .../ramips/dts/mt7628an_zhuotk_js7628-16m-128m.dts | 61 +++++++++++++++++
 .../ramips/dts/mt7628an_zhuotk_js7628-32m-256m.dts | 61 +++++++++++++++++
 .../ramips/dts/mt7628an_zhuotk_js7628-8m-64m.dts   | 61 +++++++++++++++++
 .../linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi   | 80 ++++++++++++++++++++++
 target/linux/ramips/image/mt76x8.mk                | 33 +++++++++
 7 files changed, 305 insertions(+)
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m-128m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m-256m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m-64m.dts
 create mode 100644 target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi

diff --git a/target/linux/ramips/base-files/etc/board.d/01_leds b/target/linux/ramips/base-files/etc/board.d/01_leds
index 57f0939..0d876c4 100755
--- a/target/linux/ramips/base-files/etc/board.d/01_leds
+++ b/target/linux/ramips/base-files/etc/board.d/01_leds
@@ -458,6 +458,12 @@ zbtlink,zbt-we1226)
 	ucidef_set_led_switch &quot;lan2&quot; &quot;LAN2&quot; &quot;$boardname:green:lan2&quot; &quot;switch0&quot; &quot;0x02&quot;
 	ucidef_set_led_switch &quot;wan&quot; &quot;WAN&quot; &quot;$boardname:green:wan&quot; &quot;switch0&quot; &quot;0x10&quot;
 	;;
+zhuotk,js7628-8m-64m|\
+zhuotk,js7628-16m-128m|\
+zhuotk,js7628-32m-256m)
+	ucidef_set_led_timer &quot;system&quot; &quot;system&quot; &quot;js76x8:green:system&quot; &quot;1000&quot; &quot;1000&quot;
+	set_wifi_led &quot;js76x8:green:wifi&quot;
+	;;
 zorlik,zl5900v2)
 	ucidef_set_led_netdev &quot;lan&quot; &quot;lan&quot; &quot;$boardname:green:lan&quot; eth0
 	;;
diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network
index a2b7d1c..f438b46 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -103,6 +103,9 @@ ramips_setup_interfaces()
 	zbtlink,zbt-wg3526-16m|\
 	zbtlink,zbt-wg3526-32m|\
 	zbtlink,zbt-wr8305rt|\
+	zhuotk,js7628-8m-64m|\
+	zhuotk,js7628-16m-128m|\
+	zhuotk,js7628-32m-256m|\
 	zyxel,keenetic|\
 	zyxel,keenetic-omni)
 		ucidef_add_switch &quot;switch0&quot; \
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m-128m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m-128m.dts
new file mode 100644
index 0000000..397cd01
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-16m-128m.dts
@@ -0,0 +1,61 @@
+/dts-v1/;
+
+
+#include &quot;mt7628an_zhuotk_js76x8.dtsi&quot;
+
+/ {
+	compatible = &quot;zhuotk,js7628-16m-128m&quot;, &quot;zhuotk,js76x8&quot;, &quot;mediatek,mt7628an-soc&quot;;
+	model = &quot;ZhuoTK JS7628 (16M flash/128M RAM)&quot;;
+};
+
+&amp;spi0 {
+	status = &quot;okay&quot;;
+
+	pinctrl-names = &quot;default&quot;;
+	pinctrl-0 = &lt;&amp;spi_pins&gt;, &lt;&amp;spi_cs1_pins&gt;;
+
+	m25p80@0 {
+		compatible = &quot;jedec,spi-nor&quot;;
+		reg = &lt;0&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+		m25p,chunked-io = &lt;32&gt;;
+
+		partitions {
+			compatible = &quot;fixed-partitions&quot;;
+			#address-cells = &lt;1&gt;;
+			#size-cells = &lt;1&gt;;
+
+			partition@0 {
+				label = &quot;u-boot&quot;;
+				reg = &lt;0x0 0x30000&gt;;
+				read-only;
+			};
+
+			partition@30000 {
+				label = &quot;u-boot-env&quot;;
+				reg = &lt;0x30000 0x10000&gt;;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = &quot;factory&quot;;
+				reg = &lt;0x40000 0x10000&gt;;
+				read-only;
+			};
+
+			partition@50000 {
+				compatible = &quot;denx,uimage&quot;;
+				label = &quot;firmware&quot;;
+				reg = &lt;0x50000 0xfb0000&gt;;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = &lt;1&gt;;
+		#size-cells = &lt;1&gt;;
+		compatible = &quot;linux,spidev&quot;;
+		reg = &lt;1&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m-256m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m-256m.dts
new file mode 100644
index 0000000..10970ea
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-32m-256m.dts
@@ -0,0 +1,61 @@
+/dts-v1/;
+
+
+#include &quot;mt7628an_zhuotk_js76x8.dtsi&quot;
+
+/ {
+	compatible = &quot;zhuotk,js7628-32m-256m&quot;, &quot;zhuotk,js76x8&quot;, &quot;mediatek,mt7628an-soc&quot;;
+	model = &quot;ZhuoTK JS7628 (32M flash/256M RAM)&quot;;
+};
+
+&amp;spi0 {
+	status = &quot;okay&quot;;
+
+	pinctrl-names = &quot;default&quot;;
+	pinctrl-0 = &lt;&amp;spi_pins&gt;, &lt;&amp;spi_cs1_pins&gt;;
+
+	m25p80@0 {
+		compatible = &quot;jedec,spi-nor&quot;;
+		reg = &lt;0&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+		m25p,chunked-io = &lt;32&gt;;
+
+		partitions {
+			compatible = &quot;fixed-partitions&quot;;
+			#address-cells = &lt;1&gt;;
+			#size-cells = &lt;1&gt;;
+
+			partition@0 {
+				label = &quot;u-boot&quot;;
+				reg = &lt;0x0 0x30000&gt;;
+				read-only;
+			};
+
+			partition@30000 {
+				label = &quot;u-boot-env&quot;;
+				reg = &lt;0x30000 0x10000&gt;;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = &quot;factory&quot;;
+				reg = &lt;0x40000 0x10000&gt;;
+				read-only;
+			};
+
+			partition@50000 {
+				compatible = &quot;denx,uimage&quot;;
+				label = &quot;firmware&quot;;
+				reg = &lt;0x50000 0x1fb0000&gt;;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = &lt;1&gt;;
+		#size-cells = &lt;1&gt;;
+		compatible = &quot;linux,spidev&quot;;
+		reg = &lt;1&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m-64m.dts b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m-64m.dts
new file mode 100644
index 0000000..66db75f
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js7628-8m-64m.dts
@@ -0,0 +1,61 @@
+/dts-v1/;
+
+
+#include &quot;mt7628an_zhuotk_js76x8.dtsi&quot;
+
+/ {
+	compatible = &quot;zhuotk,js7628-8m-64m&quot;, &quot;zhuotk,js76x8&quot;, &quot;mediatek,mt7628an-soc&quot;;
+	model = &quot;ZhuoTK JS7628 (8M flash/64M RAM)&quot;;
+};
+
+&amp;spi0 {
+	status = &quot;okay&quot;;
+
+	pinctrl-names = &quot;default&quot;;
+	pinctrl-0 = &lt;&amp;spi_pins&gt;, &lt;&amp;spi_cs1_pins&gt;;
+
+	m25p80@0 {
+		compatible = &quot;jedec,spi-nor&quot;;
+		reg = &lt;0&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+		m25p,chunked-io = &lt;32&gt;;
+
+		partitions {
+			compatible = &quot;fixed-partitions&quot;;
+			#address-cells = &lt;1&gt;;
+			#size-cells = &lt;1&gt;;
+
+			partition@0 {
+				label = &quot;u-boot&quot;;
+				reg = &lt;0x0 0x30000&gt;;
+				read-only;
+			};
+
+			partition@30000 {
+				label = &quot;u-boot-env&quot;;
+				reg = &lt;0x30000 0x10000&gt;;
+				read-only;
+			};
+
+			factory: partition@40000 {
+				label = &quot;factory&quot;;
+				reg = &lt;0x40000 0x10000&gt;;
+				read-only;
+			};
+
+			partition@50000 {
+				compatible = &quot;denx,uimage&quot;;
+				label = &quot;firmware&quot;;
+				reg = &lt;0x50000 0x7b0000&gt;;
+			};
+		};
+	};
+
+	spidev@1 {
+		#address-cells = &lt;1&gt;;
+		#size-cells = &lt;1&gt;;
+		compatible = &quot;linux,spidev&quot;;
+		reg = &lt;1&gt;;
+		spi-max-frequency = &lt;40000000&gt;;
+	};
+};
diff --git a/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
new file mode 100644
index 0000000..0dcfd10
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_zhuotk_js76x8.dtsi
@@ -0,0 +1,80 @@
+#include &quot;mt7628an.dtsi&quot;
+
+#include &lt;dt-bindings/gpio/gpio.h&gt;
+#include &lt;dt-bindings/input/input.h&gt;
+
+/ {
+	compatible = &quot;zhuotk,js76x8&quot;, &quot;mediatek,mt7628an-soc&quot;;
+
+        aliases {
+                led-boot = &amp;led_system;
+                led-failsafe = &amp;led_system;
+                led-running = &amp;led_system;
+                led-upgrade = &amp;led_system;
+        };
+
+        chosen {
+                bootargs = &quot;console=ttyS0,115200&quot;;
+        };
+
+        gpio-leds {
+                compatible = &quot;gpio-leds&quot;;
+
+                led_system: system {
+                        label = &quot;js76x8:green:system&quot;;
+                        gpios = &lt;&amp;gpio1 5 GPIO_ACTIVE_LOW&gt;;
+                };
+
+                wifi {
+                        label = &quot;js76x8:green:wifi&quot;;
+                        gpios = &lt;&amp;gpio1 7 GPIO_ACTIVE_LOW&gt;;
+                };
+        };
+
+	keys {
+		compatible = &quot;gpio-keys-polled&quot;;
+		poll-interval = &lt;20&gt;;
+
+		reset {
+			label = &quot;reset&quot;;
+			gpios = &lt;&amp;gpio1 12 GPIO_ACTIVE_HIGH&gt;;
+			linux,code = &lt;KEY_RESTART&gt;;
+                };
+        };
+};
+
+
+&amp;pinctrl {
+	state_default: pinctrl0 {
+		gpio {
+			ralink,group = &quot;gpio&quot;,&quot;wdt&quot;,&quot;pwm0&quot;,&quot;pwm1&quot;,&quot;spis&quot;,
+				&quot;refclk&quot;;
+			ralink,function = &quot;gpio&quot;;
+		};
+	};
+};
+
+&amp;i2c {
+	status = &quot;okay&quot;;
+};
+
+&amp;uart1 {
+	status = &quot;okay&quot;;
+};
+
+&amp;uart2 {
+	status = &quot;okay&quot;;
+};
+
+&amp;ethernet {
+	mtd-mac-address = &lt;&amp;factory 0x28&gt;;
+};
+
+&amp;sdhci {
+	status = &quot;okay&quot;;
+	mediatek,cd-low;
+};
+
+&amp;wmac {
+	status = &quot;okay&quot;;
+};
diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk
index fae9fb0..f97d78a 100644
--- a/target/linux/ramips/image/mt76x8.mk
+++ b/target/linux/ramips/image/mt76x8.mk
@@ -549,6 +549,39 @@ define Device/zbtlink_zbt-we1226
 endef
 TARGET_DEVICES += zbtlink_zbt-we1226
 
+define Device/zhuotk_js7628-8m-64m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := $(ralink_default_fw_size_8M)
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 8M flash/64M RAM
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+  SUPPORTED_DEVICES += js7628-8m-64m js7688-8m-64m ztk7628p-8m-64m
+endef
+TARGET_DEVICES += zhuotk_js7628-8m-64m
+
+define Device/zhuotk_js7628-16m-128m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := $(ralink_default_fw_size_16M)
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 16M flash/128M RAM
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+  SUPPORTED_DEVICES += js7628-16m-128m js7688-16m-128m ztk7628p-16m-64m
+endef
+TARGET_DEVICES += zhuotk_js7628-16m-128m
+
+define Device/zhuotk_js7628-32m-256m
+  MTK_SOC := mt7628an
+  IMAGE_SIZE := $(ralink_default_fw_size_32M)
+  DEVICE_VENDOR := ZhuoTK
+  DEVICE_MODEL := JS7628
+  DEVICE_VARIANT := 32M flash/256M RAM
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci
+  SUPPORTED_DEVICES += js7628-32m-256 js7688-32m-256m ztk7628p-32m-64m
+endef
+TARGET_DEVICES += zhuotk_js7628-32m-256m
+
 define Device/zyxel_keenetic-extra-ii
   MTK_SOC := mt7628an
   IMAGE_SIZE := 14912k
-- 
2.7.4


]