From e18ceb1dac82bf340a8d4c82bfd727a4ca4cec06 Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Thu, 28 Jul 2011 11:57:51 +0000
Subject: [PATCH] ar71xx: merge WZR-HP-G301NH support into WZR-HP-G300NH

Now that we can use a generic name for the switch there is no need for a
separate image for the WZR-HP-G301NH.
Update the default network config and remove the extra image.

SVN-Revision: 27814
---
 .../etc/defconfig/wzr-hp-g300nh/network       |  4 +--
 .../etc/defconfig/wzr-hp-g301nh/network       | 26 -------------------
 target/linux/ar71xx/base-files/etc/diag.sh    |  2 +-
 .../base-files/etc/uci-defaults/wzr-hp-g300nh |  4 +--
 target/linux/ar71xx/base-files/lib/ar71xx.sh  |  3 ---
 .../ar71xx/base-files/lib/upgrade/platform.sh |  2 +-
 .../arch/mips/ar71xx/mach-wzr-hp-g300nh.c     | 15 +++++------
 .../ar71xx/files/arch/mips/ar71xx/machtype.h  |  1 -
 .../linux/ar71xx/generic/profiles/buffalo.mk  |  8 +++---
 target/linux/ar71xx/image/Makefile            |  6 ++---
 10 files changed, 18 insertions(+), 53 deletions(-)
 delete mode 100644 target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network

diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network
index 79f4799f94..20dd9444de 100644
--- a/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network
+++ b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh/network
@@ -16,11 +16,11 @@ config interface wan
 	option proto	dhcp
 
 config switch
-	option name	rtl8366s
+	option name	switch0
 	option reset	1
 	option enable_vlan 1
 
 config switch_vlan
-	option device	rtl8366s
+	option device	switch0
 	option vlan 	1
 	option ports	"0 1 2 3 5t"
diff --git a/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network
deleted file mode 100644
index 72a4c881d7..0000000000
--- a/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network
+++ /dev/null
@@ -1,26 +0,0 @@
-config interface loopback
-	option ifname	lo
-	option proto	static
-	option ipaddr	127.0.0.1
-	option netmask	255.0.0.0
-
-config interface lan
-	option ifname	eth0.1
-	option type	bridge
-	option proto	static
-	option ipaddr	192.168.1.1
-	option netmask	255.255.255.0
-
-config interface wan
-	option ifname	eth1
-	option proto	dhcp
-
-config switch
-	option name	rtl8366rb
-	option reset	1
-	option enable_vlan 1
-
-config switch_vlan
-	option device	rtl8366rb
-	option vlan 	1
-	option ports	"0 1 2 3 5t"
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh
index 6cd6043f8f..d61a78d83e 100755
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -123,7 +123,7 @@ get_status_led() {
 	wrt160nl)
 		status_led="wrt160nl:blue:wps"
 		;;
-	wzr-hp-g300nh | wzr-hp-g301nh)
+	wzr-hp-g300nh)
 		status_led="wzr-hp-g300nh:green:router"
 		;;
 	zcn-1523h-2 | zcn-1523h-5)
diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/wzr-hp-g300nh b/target/linux/ar71xx/base-files/etc/uci-defaults/wzr-hp-g300nh
index db8d9f489f..1308a7bb04 100755
--- a/target/linux/ar71xx/base-files/etc/uci-defaults/wzr-hp-g300nh
+++ b/target/linux/ar71xx/base-files/etc/uci-defaults/wzr-hp-g300nh
@@ -32,6 +32,6 @@ commit system
 EOF
 }
 
-if [ "${board}" == "wzr-hp-g300nh" -o "${board}" == "wzr-hp-g301nh" ]; then
+if [ "${board}" == "wzr-hp-g300nh" ]; then
 	wzrhpg300nh_set_leds
-fi
\ No newline at end of file
+fi
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index e23ac28de1..92b0e66c6f 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -160,9 +160,6 @@ ar71xx_board_name() {
 	*WZR-HP-G300NH)
 		name="wzr-hp-g300nh"
 		;;
-	*WZR-HP-G301NH)
-		name="wzr-hp-g301nh"
-		;;
 	*ZCN-1523H-2)
 		name="zcn-1523h-2"
 		;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 3de0c863b7..ab0adb2e8b 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -76,7 +76,7 @@ platform_check_image() {
 		}
 		return 0
 		;;
-	ap81 | ap83 | dir-600-a1 | dir-615-c1 | dir-825-b1 | mzk-w04nu | mzk-w300nh | tew-632brp | wrt400n | bullet-m | nanostation-m | rocket-m | wzr-hp-g300nh | wzr-hp-g301nh | wzr-hp-ag300h | nbg460n_550n_550nh | unifi )
+	ap81 | ap83 | dir-600-a1 | dir-615-c1 | dir-825-b1 | mzk-w04nu | mzk-w300nh | tew-632brp | wrt400n | bullet-m | nanostation-m | rocket-m | wzr-hp-g300nh | wzr-hp-ag300h | nbg460n_550n_550nh | unifi )
 		[ "$magic" != "2705" ] && {
 			echo "Invalid image type."
 			return 1
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
index 308f93141a..9a1fbea391 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
@@ -226,7 +226,7 @@ static struct platform_device wzrhpg300nh_rtl8366s_device = {
 	}
 };
 
-static struct platform_device wzrhpg301nh_rtl8366rb_device = {
+static struct platform_device wzrhpg300nh_rtl8366rb_device = {
 	.name           = RTL8366RB_DRIVER_NAME,
 	.id             = -1,
 	.dev = {
@@ -234,7 +234,7 @@ static struct platform_device wzrhpg301nh_rtl8366rb_device = {
 	}
 };
 
-static void __init wzrhpg30xnh_setup(void)
+static void __init wzrhpg300nh_setup(void)
 {
 	u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000);
 	u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET;
@@ -248,9 +248,9 @@ static void __init wzrhpg30xnh_setup(void)
 
 	if (hasrtl8366rb) {
 		ar71xx_eth0_pll_data.pll_1000 = 0x1f000000;
-		ar71xx_eth0_data.mii_bus_dev = &wzrhpg301nh_rtl8366rb_device.dev;
+		ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
 		ar71xx_eth1_pll_data.pll_1000 = 0x100;
-		ar71xx_eth1_data.mii_bus_dev = &wzrhpg301nh_rtl8366rb_device.dev;
+		ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366rb_device.dev;
 	} else {
 		ar71xx_eth0_pll_data.pll_1000 = 0x1e000100;
 		ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev;
@@ -275,7 +275,7 @@ static void __init wzrhpg30xnh_setup(void)
 	platform_device_register(&wzrhpg300nh_flash_device);
 
 	if (hasrtl8366rb)
-		platform_device_register(&wzrhpg301nh_rtl8366rb_device);
+		platform_device_register(&wzrhpg300nh_rtl8366rb_device);
 	else
 		platform_device_register(&wzrhpg300nh_rtl8366s_device);
 
@@ -289,7 +289,4 @@ static void __init wzrhpg30xnh_setup(void)
 }
 
 MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH, "WZR-HP-G300NH",
-	     "Buffalo WZR-HP-G300NH", wzrhpg30xnh_setup);
-
-MIPS_MACHINE(AR71XX_MACH_WZR_HP_G301NH, "WZR-HP-G301NH",
-	     "Buffalo WZR-HP-G301NH", wzrhpg30xnh_setup);
+	     "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup);
diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h
index 3071792f28..823f3ffb95 100644
--- a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h
+++ b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h
@@ -64,7 +64,6 @@ enum ar71xx_mach_type {
 	AR71XX_MACH_WRT400N,	/* Linksys WRT400N */
 	AR71XX_MACH_WZR_HP_AG300H, /* Buffalo WZR-HP-AG300H */
 	AR71XX_MACH_WZR_HP_G300NH, /* Buffalo WZR-HP-G300NH */
-	AR71XX_MACH_WZR_HP_G301NH, /* Buffalo WZR-HP-G301NH */
 	AR71XX_MACH_EAP7660D,	/* Senao EAP7660D */
 	AR71XX_MACH_ZCN_1523H_2, /* Zcomax ZCN-1523H-2-xx */
 	AR71XX_MACH_ZCN_1523H_5, /* Zcomax ZCN-1523H-5-xx */
diff --git a/target/linux/ar71xx/generic/profiles/buffalo.mk b/target/linux/ar71xx/generic/profiles/buffalo.mk
index 5d9bab5406..2b39f379ac 100644
--- a/target/linux/ar71xx/generic/profiles/buffalo.mk
+++ b/target/linux/ar71xx/generic/profiles/buffalo.mk
@@ -5,16 +5,16 @@
 # See /LICENSE for more information.
 #
 
-define Profile/WZRHPG30XNH
-	NAME:=Buffalo WZR-HP-G30XNH
+define Profile/WZRHPG300NH
+	NAME:=Buffalo WZR-HP-G300NH
 	PACKAGES:=kmod-ath9k wpad-mini kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev
 endef
 
-define Profile/WZRHPG30XNH/Description
+define Profile/WZRHPG300NH/Description
 	Package set optimized for the Buffalo WZR-HP-G300NH and WZR-HP-G301NH
 endef
 
-$(eval $(call Profile,WZRHPG30XNH))
+$(eval $(call Profile,WZRHPG300NH))
 
 define Profile/WZRHPAG300H
 	NAME:=Buffalo WZR-HP-AG300H
diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile
index cc45e4e855..7814e53fd4 100644
--- a/target/linux/ar71xx/image/Makefile
+++ b/target/linux/ar71xx/image/Makefile
@@ -777,10 +777,8 @@ define Image/Build/Profile/WRT160NL
 endef
 
 wzrhpg300nh_cmdline=board=WZR-HP-G300NH console=ttyS0,115200
-wzrhpg301nh_cmdline=board=WZR-HP-G301NH console=ttyS0,115200
-define Image/Build/Profile/WZRHPG30XNH
+define Image/Build/Profile/WZRHPG300NH
 	$(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g300nh,$(wzrhpg300nh_cmdline),WZR-HP-G300NH)
-	$(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g301nh,$(wzrhpg301nh_cmdline),WZR-HP-G301NH)
 endef
 
 wzrhpag300h_cmdline=board=WZR-HP-AG300H console=ttyS0,115200
@@ -840,7 +838,7 @@ define Image/Build/Profile/Default
 	$(call Image/Build/Profile/AP96,$(1))
 	$(call Image/Build/Profile/WRT400N,$(1))
 	$(call Image/Build/Profile/WRT160NL,$(1))
-	$(call Image/Build/Profile/WZRHPG30XNH,$(1))
+	$(call Image/Build/Profile/WZRHPG300NH,$(1))
 	$(call Image/Build/Profile/WZRHPAG300H,$(1))
 	$(call Image/Build/Profile/ZCN1523H28,$(1))
 	$(call Image/Build/Profile/ZCN1523H516,$(1))
-- 
2.30.2