From 9a4935687d6d79e0eeae37204794fc68e17c8b68 Mon Sep 17 00:00:00 2001
From: Michael Lee <igvtee@gmail.com>
Date: Sat, 28 May 2016 22:22:10 +0800
Subject: [PATCH] ramips: add support for DuZun DM06

DuZun DM06 is a develop board based on mt7628
64M RAM, 8M SPI Flash, 1 WAN, 1 LAN.
wm8960 codec with line out, line in and speaker output.

Signed-off-by: Michael Lee <igvtee@gmail.com>
---
 .../ramips/base-files/etc/board.d/02_network  |   4 +
 target/linux/ramips/base-files/lib/ramips.sh  |   3 +
 .../ramips/base-files/lib/upgrade/platform.sh |   1 +
 target/linux/ramips/dts/DUZUN-DM06.dts        | 155 ++++++++++++++++++
 target/linux/ramips/image/mt7628.mk           |   8 +
 5 files changed, 171 insertions(+)
 create mode 100644 target/linux/ramips/dts/DUZUN-DM06.dts

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 4728c75312..6807eede31 100755
--- a/target/linux/ramips/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/base-files/etc/board.d/02_network
@@ -172,6 +172,10 @@ ramips_setup_interfaces()
 	wrh-300cr)
 		ucidef_set_interface_lan "eth0"
 		;;
+	duzun-dm06)
+		ucidef_add_switch "switch0" \
+			"1:lan" "0:wan" "6@eth0"
+		;;
 	e1700|\
 	mt7620a_mt7530)
 		ucidef_add_switch "switch1" \
diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh
index cbe455d77d..567e5066f8 100755
--- a/target/linux/ramips/base-files/lib/ramips.sh
+++ b/target/linux/ramips/base-files/lib/ramips.sh
@@ -151,6 +151,9 @@ ramips_board_detect() {
 	*"Dovado Tiny AC")
 		name="tiny-ac"
 		;;
+	*"DuZun DM06")
+		name="duzun-dm06"
+		;;
 	*"E1700")
 		name="e1700"
 		;;
diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh
index 91c999799f..c71fc64917 100755
--- a/target/linux/ramips/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh
@@ -50,6 +50,7 @@ platform_check_image() {
 	dir-620-a1|\
 	dir-620-d1|\
 	dir-810l|\
+	duzun-dm06|\
 	e1700|\
 	esr-9753|\
 	ex2700|\
diff --git a/target/linux/ramips/dts/DUZUN-DM06.dts b/target/linux/ramips/dts/DUZUN-DM06.dts
new file mode 100644
index 0000000000..946a421c3a
--- /dev/null
+++ b/target/linux/ramips/dts/DUZUN-DM06.dts
@@ -0,0 +1,155 @@
+/dts-v1/;
+
+/include/ "mt7628an.dtsi"
+
+/ {
+	compatible = "duzun,dm06-mt7628an", "mediatek,mt7628an-soc";
+	model = "DuZun DM06";
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x4000000>;
+	};
+
+	gpio-keys-polled {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+		poll-interval = <100>;
+
+		reset {
+			label = "reset";
+			gpios = <&gpio1 14 1>;
+			linux,code = <0x198>;
+		};
+
+		wps {
+			label = "wps";
+			gpios = <&gpio1 6 1>;
+			linux,code = <0x211>;
+		};
+	};
+
+	sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "Audio-I2S";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,bitclock-master = <&dailink0_master>;
+		simple-audio-card,frame-master = <&dailink0_master>;
+		simple-audio-card,widgets =
+			"Headphone", "Headphones";
+		simple-audio-card,routing =
+			"Headphones", "HP_L",
+			"Headphones", "HP_R";
+		simple-audio-card,mclk-fs = <256>;
+
+		simple-audio-card,cpu {
+			sound-dai = <&i2s>;
+		};
+
+		dailink0_master: simple-audio-card,codec {
+			sound-dai = <&codec>;
+		};
+	};
+};
+
+&pinctrl {
+	state_default: pinctrl0 {
+		gpio {
+			ralink,group = "wdt", "uart1";
+			ralink,function = "gpio";
+		};
+	};
+
+	i2s_pins: i2s {
+		i2s {
+			ralink,group = "i2s";
+			ralink,function = "i2s";
+		};
+	};
+
+	wm8960_mclk_pins: wm8960_mclk {
+		wm8960_mclk {
+			ralink,group = "refclk";
+			ralink,function = "reclk";
+		};
+	};
+};
+
+&gpio1 {
+	status = "okay";
+};
+
+&i2c {
+	status = "okay";
+
+	codec: wm8960@1a {
+		#sound-dai-cells = <0>;
+		compatible = "wlf,wm8960";
+		reg = <0x1a>;
+
+		wlf,shared-lrclk;
+	};
+};
+
+&ethernet {
+	mtd-mac-address = <&factory 0x4>;
+};
+
+&esw {
+	mediatek,portmap = <0x3>;
+	mediatek,portdisable = <0x3c>;
+};
+
+&i2s {
+	#sound-dai-cells = <0>;
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2s_pins>, <&wm8960_mclk_pins>;
+};
+
+&sdhci {
+	status = "okay";
+};
+
+&gdma {
+	status = "okay";
+};
+
+&spi0 {
+	status = "okay";
+
+	m25p80@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		linux,modalias = "m25p80";
+		spi-max-frequency = <60000000>;
+		m25p,chunked-io = <32>;
+		m25p,fast-read;
+
+		partition@0 {
+			label = "u-boot";
+			reg = <0x0 0x30000>;
+			read-only;
+		};
+
+		partition@30000 {
+			label = "u-boot-env";
+			reg = <0x30000 0x10000>;
+			read-only;
+		};
+
+		factory: partition@40000 {
+			label = "factory";
+			reg = <0x40000 0x10000>;
+			read-only;
+		};
+
+		partition@50000 {
+			label = "firmware";
+			reg = <0x50000 0x7b0000>;
+		};
+	};
+};
diff --git a/target/linux/ramips/image/mt7628.mk b/target/linux/ramips/image/mt7628.mk
index 8274e11f17..fa7d1e77f2 100644
--- a/target/linux/ramips/image/mt7628.mk
+++ b/target/linux/ramips/image/mt7628.mk
@@ -25,3 +25,11 @@ define Device/wrtnode2p
   DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-ledtrig-usbdev
 endef
 TARGET_DEVICES += wrtnode2p
+
+define Device/duzun-dm06
+  DTS := DUZUN-DM06
+  IMAGE_SIZE := $(ralink_default_fw_size_8M)
+  DEVICE_TITLE := DuZun DM06
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-ledtrig-usbdev
+endef
+TARGET_DEVICES += duzun-dm06
-- 
GitLab