From 54ede248290368aadbd2012a3ca564e2e42bfef9 Mon Sep 17 00:00:00 2001 From: Gabor Juhos Date: Tue, 12 Apr 2011 09:29:10 +0000 Subject: [PATCH] ar71xx: Add support for WZR-HP-G301NH Add support for the Buffalo WZR-HP-G301NH. The only difference between it and the WZR-HP-G00NH is that it has a RTL8366RB instead of a RTL8366S. Since we don't do runtime detection of the switch, we need a separate machine definition for it. While we are at it, also rename the profile to reflect that it now is for more than one device. Signed-off-by: Jonas Gorski SVN-Revision: 26601 --- .../etc/defconfig/wzr-hp-g301nh/network | 26 +++++++++ target/linux/ar71xx/base-files/etc/diag.sh | 2 +- .../base-files/etc/uci-defaults/wzr-hp-g300nh | 2 +- 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 | 54 ++++++++++++++++--- .../ar71xx/files/arch/mips/ar71xx/machtype.h | 1 + .../linux/ar71xx/generic/profiles/buffalo.mk | 10 ++-- target/linux/ar71xx/image/Makefile | 9 ++-- 9 files changed, 90 insertions(+), 19 deletions(-) create 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-g301nh/network b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network new file mode 100644 index 0000000000..72a4c881d7 --- /dev/null +++ b/target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g301nh/network @@ -0,0 +1,26 @@ +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 d61a78d83e..6cd6043f8f 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-g300nh | wzr-hp-g301nh) 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 1308a7bb04..1448e1f9a5 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" ]; then +if [ "${board}" == "wzr-hp-g300nh" || "${board}" == "wzr-hp-g301nh" ]; then wzrhpg300nh_set_leds fi diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 15f3250e80..25915616fd 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -148,6 +148,9 @@ 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 f0fdd88378..4ccacf4ef1 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -69,7 +69,7 @@ platform_check_image() { [ "$ARGC" -gt 1 ] && return 1 case "$board" in - 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 | 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-g301nh | 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 383d87b5f4..2806f3bf28 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 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -225,21 +226,43 @@ static struct platform_device wzrhpg300nh_rtl8366s_device = { } }; -static void __init wzrhpg300nh_setup(void) +static struct rtl8366rb_platform_data wzrhpg301nh_rtl8366rb_data = { + .gpio_sda = WZRHPG300NH_GPIO_RTL8366_SDA, + .gpio_sck = WZRHPG300NH_GPIO_RTL8366_SCK, +}; + +static struct platform_device wzrhpg301nh_rtl8366rb_device = { + .name = RTL8366RB_DRIVER_NAME, + .id = -1, + .dev = { + .platform_data = &wzrhpg301nh_rtl8366rb_data, + } +}; + +static void __init wzrhpg30xnh_setup(bool hasrtl8366rb) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET; ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); - ar71xx_eth0_pll_data.pll_1000 = 0x1e000100; - ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); + + if (hasrtl8366rb) { + ar71xx_eth0_pll_data.pll_1000 = 0x1f000000; + ar71xx_eth0_data.mii_bus_dev = &wzrhpg301nh_rtl8366rb_device.dev; + ar71xx_eth1_pll_data.pll_1000 = 0x100; + ar71xx_eth1_data.mii_bus_dev = &wzrhpg301nh_rtl8366rb_device.dev; + } else { + ar71xx_eth0_pll_data.pll_1000 = 0x1e000100; + ar71xx_eth0_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; + ar71xx_eth1_pll_data.pll_1000 = 0x1e000100; + ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; + } + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth0_data.speed = SPEED_1000; ar71xx_eth0_data.duplex = DUPLEX_FULL; - ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); - ar71xx_eth1_pll_data.pll_1000 = 0x1e000100; - ar71xx_eth1_data.mii_bus_dev = &wzrhpg300nh_rtl8366s_device.dev; ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; ar71xx_eth1_data.phy_mask = 0x10; @@ -251,7 +274,11 @@ static void __init wzrhpg300nh_setup(void) platform_device_register(&wzrhpg300nh_74hc153_device); platform_device_register(&wzrhpg300nh_flash_device); - platform_device_register(&wzrhpg300nh_rtl8366s_device); + + if (hasrtl8366rb) + platform_device_register(&wzrhpg301nh_rtl8366rb_device); + else + platform_device_register(&wzrhpg300nh_rtl8366s_device); ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh_leds_gpio), wzrhpg300nh_leds_gpio); @@ -262,5 +289,18 @@ static void __init wzrhpg300nh_setup(void) } +static void __init wzrhpg300nh_setup(void) +{ + wzrhpg30xnh_setup(false); +} + +static void __init wzrhpg301nh_setup(void) +{ + wzrhpg30xnh_setup(true); +} + MIPS_MACHINE(AR71XX_MACH_WZR_HP_G300NH, "WZR-HP-G300NH", "Buffalo WZR-HP-G300NH", wzrhpg300nh_setup); + +MIPS_MACHINE(AR71XX_MACH_WZR_HP_G301NH, "WZR-HP-G301NH", + "Buffalo WZR-HP-G301NH", wzrhpg301nh_setup); diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h index e7e57956b2..4b2a08ca6f 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h @@ -61,6 +61,7 @@ enum ar71xx_mach_type { AR71XX_MACH_WRT160NL, /* Linksys WRT160NL */ AR71XX_MACH_WRT400N, /* Linksys WRT400N */ 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 35c7cc34b6..59ddd86cb3 100644 --- a/target/linux/ar71xx/generic/profiles/buffalo.mk +++ b/target/linux/ar71xx/generic/profiles/buffalo.mk @@ -5,13 +5,13 @@ # See /LICENSE for more information. # -define Profile/WZRHPG300NH - NAME:=Buffalo WZR-HP-G300NH +define Profile/WZRHPG30XNH + NAME:=Buffalo WZR-HP-G30XNH PACKAGES:=kmod-ath9k wpad-mini kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev endef -define Profile/WZRHPG300NH/Description - Package set optimized for the Buffalo WZR-HP-G300NH +define Profile/WZRHPG30XNH/Description + Package set optimized for the Buffalo WZR-HP-G300NH and WZR-HP-G301NH endef -$(eval $(call Profile,WZRHPG300NH)) +$(eval $(call Profile,WZRHPG30XNH)) diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index ca5e280428..e7d2f0efa2 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -118,7 +118,7 @@ define Image/Build/DIR825B1 fi; fi endef -define Image/Build/WZRHPG300NH +define Image/Build/WZRHPG30XNH $(call PatchKernelLzma,$(2),$(3)) if [ `stat -c%s "$(KDIR)/vmlinux-$(2).bin.lzma"` -gt 1048576 ]; then \ echo "Warning: $(KDIR)/vmlinux-$(2).bin.lzma is too big"; \ @@ -688,8 +688,9 @@ define Image/Build/Profile/WRT160NL $(call Image/Build/Template/$(fs_64k)/$(1),CyberTAN,wrt160nl,board=WRT160NL,1.00.01) endef -define Image/Build/Profile/WZRHPG300NH - $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG300NH,wzr-hp-g300nh,board=WZR-HP-G300NH) +define Image/Build/Profile/WZRHPG30XNH + $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g300nh,board=WZR-HP-G300NH) + $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g301nh,board=WZR-HP-G301NH) endef define Image/Build/Profile/ZCN1523H28 @@ -740,7 +741,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/WZRHPG300NH,$(1)) + $(call Image/Build/Profile/WZRHPG30XNH,$(1)) $(call Image/Build/Profile/ZCN1523H28,$(1)) $(call Image/Build/Profile/ZCN1523H516,$(1)) endef -- 2.25.1