From eae9b2541ab45f5efa0cf43f5e35af35f3e390a8 Mon Sep 17 00:00:00 2001
From: John Crispin <john@openwrt.org>
Date: Mon, 21 Jul 2014 18:41:52 +0000
Subject: [PATCH] ar71xx: split wndr4300 and wndr3700v4 into 2 seperate mips
 machines

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 41788
---
 target/linux/ar71xx/base-files/etc/diag.sh    |  1 +
 .../etc/hotplug.d/firmware/10-ath9k-eeprom    |  2 +
 .../base-files/etc/uci-defaults/01_leds       |  1 +
 .../base-files/etc/uci-defaults/02_network    |  1 +
 .../etc/uci-defaults/04_led_migration         |  1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh  |  3 ++
 .../ar71xx/base-files/lib/upgrade/platform.sh |  1 +
 .../files/arch/mips/ath79/mach-wndr4300.c     |  4 +-
 target/linux/ar71xx/image/Makefile            |  2 +-
 .../610-MIPS-ath79-openwrt-machines.patch     | 43 +++++++++++--------
 10 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index 566b53dcf3..487a325368 100755
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -250,6 +250,7 @@ get_status_led() {
 		;;
 	wndap360 | \
 	wndr3700 | \
+	wndr3700v4 | \
 	wndr4300 | \
 	wnr2000 | \
 	wnr2200 |\
diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
index ce2392205b..eef7ee1bcd 100644
--- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
+++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom
@@ -38,6 +38,7 @@ board=$(ar71xx_board_name)
 case "$FIRMWARE" in
 "soc_wmac.eeprom")
 	case $board in
+	wndr3700v4 | \
 	wndr4300)
 		ath9k_eeprom_extract "caldata" 4096 2048
 		ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0)
@@ -50,6 +51,7 @@ case "$FIRMWARE" in
 
 "pci_wmac0.eeprom")
 	case $board in
+	wndr3700v4 | \
 	wndr4300)
 		ath9k_eeprom_extract "caldata" 20480 2048
 		ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12)
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
index fa8466110e..23fa628423 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/01_leds
@@ -383,6 +383,7 @@ wndr3700)
 	ucidef_set_led_usbdev "usb" "USB" "netgear:green:usb" "1-1"
 	;;
 
+wndr3700v4 | \
 wndr4300)
 	ucidef_set_led_netdev "wan" "WAN (green)" "netgear:green:wan" "eth0.2"
 	ucidef_set_led_usbdev "usb" "USB" "netgear:green:usb" "1-1"
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
index c3e6f15efa..da7f7d2cc2 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/02_network
@@ -255,6 +255,7 @@ mynet-n750)
 	;;
 
 dir-835-a1 |\
+wndr3700v4 | \
 wndr4300)
 	ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
 	ucidef_add_switch "switch0" "1" "1"
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration b/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration
index 5387b22b38..0fc632c689 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/04_led_migration
@@ -59,6 +59,7 @@ wndr3700)
 	migrate_leds "wndr3700:=netgear:"
 	;;
 
+wndr3700v4 | \
 wndr4300)
 	migrate_leds ":orange:=:amber:"
 	;;
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 2999359796..70f74829ca 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -667,6 +667,9 @@ ar71xx_board_detect() {
 	*"WNDR3700/WNDR3800/WNDRMAC")
 		wndr3700_board_detect "$machine"
 		;;
+	*"WNDR3700v4")
+		name="wndr3700v4"
+		;;
 	*"WNDR4300")
 		name="wndr4300"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 17103ab5ec..de831b2eae 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -345,6 +345,7 @@ platform_check_image() {
 		return 0
 		;;
 	nbg6716 | \
+	wndr3700v4 | \
 	wndr4300 )
 		nand_do_platform_check $board $1
 		return $?;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c b/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
index ae72ab66c4..2884c6c83a 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
@@ -204,5 +204,7 @@ static void __init wndr4300_setup(void)
 	ap91_pci_init_simple();
 }
 
-MIPS_MACHINE(ATH79_MACH_WNDR4300, "WNDR4300", "NETGEAR WNDR3700v4/WNDR4300",
+MIPS_MACHINE(ATH79_MACH_WNDR3700_V4, "WNDR3700_V4", "NETGEAR WNDR3700v4",
+	     wndr4300_setup);
+MIPS_MACHINE(ATH79_MACH_WNDR4300, "WNDR4300", "NETGEAR WNDR4300",
 	     wndr4300_setup);
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index 4350a2d2d3..7a08f2b89a 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -1275,7 +1275,7 @@ $(eval $(call MultiProfile,Madwifi,EAP7660D UBNTRS UBNTRSPRO UBNTLSSR71 WP543))
 endif # ifeq ($(SUBTARGET),generic)
 
 ifeq ($(SUBTARGET),nand)
-$(eval $(call SingleProfile,NetgearNAND,64k,WNDR3700V4,wndr3700v4,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR3700v4,"",-H 29763948+128+128,wndr4300))
+$(eval $(call SingleProfile,NetgearNAND,64k,WNDR3700V4,wndr3700v4,WNDR3700_V4,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR3700v4,"",-H 29763948+128+128,wndr4300))
 $(eval $(call SingleProfile,NetgearNAND,64k,WNDR4300V1,wndr4300,WNDR4300,ttyS0,115200,$$(wndr4300_mtdlayout),0x33373033,WNDR4300,"",-H 29763948+0+128+128+2x2+3x3,wndr4300))
 
 $(eval $(call SingleProfile,ZyXELNAND,128k,NBG6716,nbg6716,NBG6716,ttyS0,115200,NBG6716,$$(zyx_nbg6716_mtdlayout),mem=256M))
diff --git a/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch b/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
index 2dfecd2fda..f66f40cfb8 100644
--- a/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
+++ b/target/linux/ar71xx/patches-3.10/610-MIPS-ath79-openwrt-machines.patch
@@ -1,6 +1,8 @@
---- a/arch/mips/ath79/machtypes.h
-+++ b/arch/mips/ath79/machtypes.h
-@@ -16,22 +16,143 @@
+Index: linux-3.10.49/arch/mips/ath79/machtypes.h
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/machtypes.h	2014-07-18 18:32:42.703897643 +0100
++++ linux-3.10.49/arch/mips/ath79/machtypes.h	2014-07-18 18:36:07.635890025 +0100
+@@ -16,22 +16,144 @@
  
  enum ath79_mach_type {
  	ATH79_MACH_GENERIC = 0,
@@ -126,7 +128,8 @@
 +	ATH79_MACH_WLR8100,		/* SITECOM WLR-8100 */
 +	ATH79_MACH_WNDAP360,		/* NETGEAR WNDAP360 */
 +	ATH79_MACH_WNDR3700,		/* NETGEAR WNDR3700/WNDR3800/WNDRMAC */
-+	ATH79_MACH_WNDR4300,		/* NETGEAR WNDR3700v4/WNDR4300 */
++	ATH79_MACH_WNDR3700_V4,		/* NETGEAR WNDR3700v4 */
++	ATH79_MACH_WNDR4300,		/* NETGEAR WNDR4300 */
 +	ATH79_MACH_WNR2000,		/* NETGEAR WNR2000 */
 +	ATH79_MACH_WNR2000_V3,		/* NETGEAR WNR2000 v3 */
 +	ATH79_MACH_WNR2200,		/* NETGEAR WNR2200 */
@@ -144,9 +147,11 @@
  };
  
  #endif /* _ATH79_MACHTYPE_H */
---- a/arch/mips/ath79/Kconfig
-+++ b/arch/mips/ath79/Kconfig
-@@ -2,6 +2,61 @@ if ATH79
+Index: linux-3.10.49/arch/mips/ath79/Kconfig
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/Kconfig	2014-07-18 18:32:42.707897643 +0100
++++ linux-3.10.49/arch/mips/ath79/Kconfig	2014-07-18 18:34:56.795892658 +0100
+@@ -2,6 +2,61 @@
  
  menu "Atheros AR71XX/AR724X/AR913X machine selection"
  
@@ -208,7 +213,7 @@
  config ATH79_MACH_AP121
  	bool "Atheros AP121 reference board"
  	select SOC_AR933X
-@@ -9,64 +64,736 @@ config ATH79_MACH_AP121
+@@ -9,64 +64,736 @@
  	select ATH79_DEV_GPIO_BUTTONS
  	select ATH79_DEV_LEDS_GPIO
  	select ATH79_DEV_M25P80
@@ -971,7 +976,7 @@
  
  config ATH79_MACH_UBNT_XM
  	bool "Ubiquiti Networks XM/UniFi boards"
-@@ -83,6 +810,65 @@ config ATH79_MACH_UBNT_XM
+@@ -83,6 +810,65 @@
  	  Say 'Y' here if you want your kernel to support the
  	  Ubiquiti Networks XM (rev 1.0) board.
  
@@ -1037,7 +1042,7 @@
  endmenu
  
  config SOC_AR71XX
-@@ -132,7 +918,10 @@ config ATH79_DEV_DSA
+@@ -132,7 +918,10 @@
  config ATH79_DEV_ETH
  	def_bool n
  
@@ -1049,7 +1054,7 @@
  	def_bool n
  
  config ATH79_DEV_GPIO_BUTTONS
-@@ -164,4 +953,7 @@ config ATH79_PCI_ATH9K_FIXUP
+@@ -164,4 +953,7 @@
  config ATH79_ROUTERBOOT
  	def_bool n
  
@@ -1057,9 +1062,11 @@
 +	def_bool n
 +
  endif
---- a/arch/mips/ath79/Makefile
-+++ b/arch/mips/ath79/Makefile
-@@ -38,9 +38,90 @@ obj-$(CONFIG_ATH79_ROUTERBOOT)		+= route
+Index: linux-3.10.49/arch/mips/ath79/Makefile
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/Makefile	2014-07-18 18:32:42.567897648 +0100
++++ linux-3.10.49/arch/mips/ath79/Makefile	2014-07-18 18:34:56.795892658 +0100
+@@ -38,9 +38,90 @@
  #
  # Machines
  #
@@ -1150,9 +1157,11 @@
 +obj-$(CONFIG_ATH79_MACH_WZR_HP_G450H)	+= mach-wzr-hp-g450h.o
 +obj-$(CONFIG_ATH79_MACH_ZCN_1523H)	+= mach-zcn-1523h.o
 +obj-$(CONFIG_ATH79_MACH_CARAMBOLA2)	+= mach-carambola2.o
---- a/arch/mips/ath79/prom.c
-+++ b/arch/mips/ath79/prom.c
-@@ -180,6 +180,12 @@ void __init prom_init(void)
+Index: linux-3.10.49/arch/mips/ath79/prom.c
+===================================================================
+--- linux-3.10.49.orig/arch/mips/ath79/prom.c	2014-07-18 18:32:42.351897656 +0100
++++ linux-3.10.49/arch/mips/ath79/prom.c	2014-07-18 18:32:42.723897642 +0100
+@@ -180,6 +180,12 @@
  			ath79_prom_append_cmdline("board", env);
  		}
  	}
-- 
2.30.2