From 5540ca300e5eff94f2df37ce48da8b801f947bb7 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Mon, 24 Nov 2014 14:44:28 +0000
Subject: [PATCH] brcm63xx: Add DT support for DV-201AMR
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

SVN-Revision: 43361
---
 target/linux/brcm63xx/dts/dv-201amr.dts       | 30 ++++++++++++++++
 target/linux/brcm63xx/image/Makefile          | 36 +++++++++++++------
 ...ulate-the-compatible-to-board_info-l.patch |  3 +-
 .../patches-3.14/514-board_ct536_ct5621.patch |  2 +-
 target/linux/brcm63xx/profiles/davolink.mk    | 15 ++++++++
 5 files changed, 74 insertions(+), 12 deletions(-)
 create mode 100644 target/linux/brcm63xx/dts/dv-201amr.dts
 create mode 100644 target/linux/brcm63xx/profiles/davolink.mk

diff --git a/target/linux/brcm63xx/dts/dv-201amr.dts b/target/linux/brcm63xx/dts/dv-201amr.dts
new file mode 100644
index 0000000000..9f8660ab6f
--- /dev/null
+++ b/target/linux/brcm63xx/dts/dv-201amr.dts
@@ -0,0 +1,30 @@
+/dts-v1/;
+
+/include/ "bcm6348.dtsi"
+
+/ {
+	model = "Davolink DV-201AMR";
+	compatible = "davolink,dv-201amr", "brcm,bcm6348";
+};
+
+&pflash {
+	status = "ok";
+
+	linux,part-probe = "bcm63xxpart";
+
+	backup@0 {
+		label = "backup";
+		reg = <0x000000 0x400000>;
+	};
+
+	cfe@400000 {
+		label = "cfe";
+		reg = <0x400000 0x010000>;
+		read-only;
+	};
+
+	linux@410000 {
+		label = "linux";
+		reg = <0x410000 0x3f0000>;
+	};
+};
diff --git a/target/linux/brcm63xx/image/Makefile b/target/linux/brcm63xx/image/Makefile
index 89eefa3ca7..fc290c6606 100755
--- a/target/linux/brcm63xx/image/Makefile
+++ b/target/linux/brcm63xx/image/Makefile
@@ -57,6 +57,13 @@ define Image/Build/CFEDTB
 		$(7) $(8) $(9) $(10)
 endef
 
+define Image/Build/OLDCFEDTB
+	$(TOPDIR)/scripts/brcmImage.pl -t -p \
+		-b $(3) -c $(4)	-e $(KERNEL_ENTRY) -a $(LOADADDR) \
+		-k $(KDIR)/vmlinux-$(2).lzma.cfe -r $(KDIR)/root.$(1) \
+		-o $(BIN_DIR)/openwrt-$(5)-$(1)-cfe.bin $(6)
+endef
+
 define Image/Build/ZYXCFEDTB
 	# Generate the tagged image
 	$(STAGING_DIR_HOST)/bin/imagetag -i $(KDIR)/vmlinux-$(2).lzma.cfe -f $(KDIR)/root.$(1) \
@@ -94,14 +101,6 @@ define Image/Build/SPW303V
 	rm -f $(BIN_DIR)/openwrt-$(4)-$(1)-cfe.bin.tmp
 endef
 
-define Image/Build/CFEOLD
-	$(TOPDIR)/scripts/brcmImage.pl -t -p	\
-		-b $(2) -c $(3)			\
-		-k $(KDIR)/vmlinux.lzma.cfe	\
-		-r $(KDIR)/root.$(1)		\
-		-o $(BIN_DIR)/openwrt-$(2)-$(1)-cfe.bin
-endef
-
 define Image/Build/HCS
 	$(STAGING_DIR_HOST)/bin/hcsmakeimage --magic_byte=$(3) \
 		--rev_maj=$(4) --rev_min=$(5) --input_file=$(6) \
@@ -193,6 +192,23 @@ define CfeImageDTB
   TARGET_$(1)_IMAGES += $(5)
 endef
 
+# $(1) = Profile
+# $(2) = dtb
+# $(3) = boardname
+# $(4) = chipid
+# $(5) = imagename
+# $(6) = additional options
+define OldCfeImageDTB
+  define Image/Build/$(5)
+        $$(call Image/Build/OLDCFEDTB,$$(1),$(2),$(3),$(4),$(5),$(6))
+  endef
+
+  TARGET_Default_DTBS += $(2)
+  TARGET_Default_IMAGES += $(5)
+  TARGET_$(1)_DTBS += $(2)
+  TARGET_$(1)_IMAGES += $(5)
+endef
+
 # $(1) = Profile
 # $(2) = dtb
 # $(3) = boardname
@@ -237,8 +253,6 @@ define Image/Build
 	# Sagem F@ST2504n
 	$(call Image/Build/CFE,$(1),F@ST2504n,6362,F@ST2504n,OpenWRT-$(REVISION))
 
-	# Davolink DV201AMR
-	$(call Image/Build/CFEOLD,$(1),DV201AMR,6348)
 	# USR 9108
 	$(call Image/Build/CFE,$(1),96348GW-A,6348,USR9108)
 	# NetGear DG834GT, DG834PN
@@ -350,6 +364,8 @@ $(eval $(call CfeImageDTB,DSL274XB_C,dsl-274xb-c,96358GW,6358,DSL274XB-C2))
 $(eval $(call CfeImageDTB,DSL274XB_C,dsl-274xb-c,AW4139,6358,DSL274XB-C3))
 # D-Link DVA-G3810BN/TL
 $(eval $(call CfeImageDTB,DVAG3810BN,dva-g3810bn_tl,96358VW,6358,DVAG3810BN))
+# Davolink DV-201AMR
+$(eval $(call OldCfeImageDTB,DV201AMR,dv-201amr,DV201AMR,6348,DV-201AMR))
 # Huawei HG520v
 $(eval $(call CfeImageDTB,HG520v,hg520v,HW6358GW_B,6358,HG520v,EchoLife_HG520v))
 # Huawei HG553
diff --git a/target/linux/brcm63xx/patches-3.14/369-MIPS-BCM63XX-populate-the-compatible-to-board_info-l.patch b/target/linux/brcm63xx/patches-3.14/369-MIPS-BCM63XX-populate-the-compatible-to-board_info-l.patch
index 765cf2a79f..a602017d38 100644
--- a/target/linux/brcm63xx/patches-3.14/369-MIPS-BCM63XX-populate-the-compatible-to-board_info-l.patch
+++ b/target/linux/brcm63xx/patches-3.14/369-MIPS-BCM63XX-populate-the-compatible-to-board_info-l.patch
@@ -14,7 +14,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -736,6 +736,43 @@ static const struct board_info __initcon
+@@ -736,6 +736,44 @@ static const struct board_info __initcon
  };
  
  static struct of_device_id const bcm963xx_boards_dt[] = {
@@ -37,6 +37,7 @@ Signed-off-by: Jonas Gorski <jogo@openwrt.org>
 +	{ .compatible = "brcm,bcm96348gw-10", .data = &board_96348gw_10, },
 +	{ .compatible = "brcm,bcm96348gw-11", .data = &board_96348gw_11, },
 +	{ .compatible = "brcm,bcm96348gw-a", .data = &board_96348gw_a, },
++	{ .compatible = "davolink,dv-201amr", .data = &board_DV201AMR, },
 +	{ .compatible = "dynalink,rta1025w", .data = &board_rta1025w_16, },
 +	{ .compatible = "sagem,f@st2404", .data = &board_FAST2404, },
 +#endif
diff --git a/target/linux/brcm63xx/patches-3.14/514-board_ct536_ct5621.patch b/target/linux/brcm63xx/patches-3.14/514-board_ct536_ct5621.patch
index 4b5cc13c2f..4c44094d43 100644
--- a/target/linux/brcm63xx/patches-3.14/514-board_ct536_ct5621.patch
+++ b/target/linux/brcm63xx/patches-3.14/514-board_ct536_ct5621.patch
@@ -73,6 +73,6 @@
  	{ .compatible = "brcm,bcm96348gw-a", .data = &board_96348gw_a, },
 +	{ .compatible = "comtrend,ct-536+", .data = &board_ct536_ct5621, },
 +	{ .compatible = "comtrend,ct-5621", .data = &board_ct536_ct5621, },
+ 	{ .compatible = "davolink,dv-201amr", .data = &board_DV201AMR, },
  	{ .compatible = "dynalink,rta1025w", .data = &board_rta1025w_16, },
  	{ .compatible = "sagem,f@st2404", .data = &board_FAST2404, },
- 	{ .compatible = "t-com,spw500v", .data = &board_spw500v, },
diff --git a/target/linux/brcm63xx/profiles/davolink.mk b/target/linux/brcm63xx/profiles/davolink.mk
new file mode 100644
index 0000000000..0097a80aaa
--- /dev/null
+++ b/target/linux/brcm63xx/profiles/davolink.mk
@@ -0,0 +1,15 @@
+#
+# Copyright (C) 2014 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+define Profile/DV201AMR
+  NAME:=Davolink DV-201AMR
+  PACKAGES:=kmod-b43 wpad-mini
+endef
+define Profile/DV201AMR/Description
+  Package set optimized for DV-201AMR.
+endef
+$(eval $(call Profile,DV201AMR))
-- 
2.30.2