The initial support for the Buffalo WHR-HP-G300N box. The code was confirmed to boot and run, but not tested in depth.
Known problem: iw phy phy0 info shows: Coverage class: 0 (up to 0m) Available Antennas: TX 0 RX 0 Signed-off-by: Yoichi Shinoda <shin...@jaist.ac.jp> --- Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-whr-hp-g300n.c =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/mach-whr-hp-g300n.c (revision 0) +++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-whr-hp-g300n.c (revision 0) @@ -0,0 +1,171 @@ +/* + * Buffalo WHR-HP-G300N board support + * + * based on ... + * + * TP-LINK TL-WR741ND board support + * + * Copyright (C) 2009-2010 Gabor Juhos <juh...@openwrt.org> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 as published + * by the Free Software Foundation. + */ + +#include <linux/mtd/mtd.h> +#include <linux/mtd/partitions.h> + +#include <asm/mach-ar71xx/ar71xx.h> + +#include "machtype.h" +#include "devices.h" +#include "dev-m25p80.h" +#include "dev-ap91-pci.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" + +#define WHRHPG300N_GPIO_LED_SECURITY 0 +#define WHRHPG300N_GPIO_LED_DIAG 1 +#define WHRHPG300N_GPIO_LED_ROUTER 6 + +#define WHRHPG300N_GPIO_BTN_ROUTER_ON 7 +#define WHRHPG300N_GPIO_BTN_ROUTER_AUTO 8 +#define WHRHPG300N_GPIO_BTN_RESET 11 +#define WHRHPG300N_GPIO_BTN_AOSS 12 + +#define WHRHPG300N_KEYS_POLL_INTERVAL 20 /* msecs */ +#define WHRHPG300N_KEYS_DEBOUNCE_INTERVAL (3 * WHRHPG300N_KEYS_POLL_INTERVAL) + +#define WHRHPG300N_MAC_OFFSET 0x20c + +#ifdef CONFIG_MTD_PARTITIONS +static struct mtd_partition whrhpg300n_partitions[] = { + { + .name = "u-boot", + .offset = 0, + .size = 0x03e000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "u-boot-env", + .offset = 0x03e000, + .size = 0x002000, + }, { + .name = "kernel", + .offset = 0x040000, + .size = 0x0e0000, + }, { + .name = "rootfs", + .offset = 0x120000, + .size = 0x2c0000, + }, { + .name = "NVRAM", + .offset = 0x3e0000, + .size = 0x010000, + }, { + .name = "ART", + .offset = 0x3f0000, + .size = 0x010000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "firmware", + .offset = 0x040000, + .size = 0x3a0000, + } +}; +#endif /* CONFIG_MTD_PARTITIONS */ + +static struct flash_platform_data whrhpg300n_flash_data = { +#ifdef CONFIG_MTD_PARTITIONS + .parts = whrhpg300n_partitions, + .nr_parts = ARRAY_SIZE(whrhpg300n_partitions), +#endif +}; + +static struct gpio_led whrhpg300n_leds_gpio[] __initdata = { + { + .name = "whr_hp_g300n:orange:security", + .gpio = WHRHPG300N_GPIO_LED_SECURITY, + .active_low = 1, + }, { + .name = "whr_hp_g300n:red:diag", + .gpio = WHRHPG300N_GPIO_LED_DIAG, + .active_low = 1, + }, { + .name = "whr_hp_g300n:green:router", + .gpio = WHRHPG300N_GPIO_LED_ROUTER, + .active_low = 1, + } +}; + +static struct gpio_keys_button whrhpg300n_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL, + .gpio = WHRHPG300N_GPIO_BTN_RESET, + .active_low = 1, + }, { + .desc = "aoss/wps", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .gpio = WHRHPG300N_GPIO_BTN_AOSS, + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL, + .active_low = 1, + }, { + .desc = "router_on", + .type = EV_KEY, + .code = BTN_2, + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_ON, + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL, + .active_low = 1, + }, { + .desc = "router_auto", + .type = EV_KEY, + .code = BTN_3, + .gpio = WHRHPG300N_GPIO_BTN_ROUTER_AUTO, + .debounce_interval = WHRHPG300N_KEYS_DEBOUNCE_INTERVAL, + .active_low = 1, + } +}; + +static void __init whrhpg300n_setup(void) +{ + u8 *ee = (u8 *) KSEG1ADDR(0x1fff1000); + u8 *mac = (u8 *) KSEG1ADDR(ee + WHRHPG300N_MAC_OFFSET); + + ar71xx_add_device_m25p80(&whrhpg300n_flash_data); + + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(whrhpg300n_leds_gpio), + whrhpg300n_leds_gpio); + + ar71xx_register_gpio_keys_polled(-1, WHRHPG300N_KEYS_POLL_INTERVAL, + ARRAY_SIZE(whrhpg300n_gpio_keys), + whrhpg300n_gpio_keys); + + ar71xx_eth1_data.has_ar7240_switch = 1; + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); + + /* WAN port */ + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; + ar71xx_eth0_data.speed = SPEED_100; + ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_eth0_data.phy_mask = BIT(4); + + /* LAN ports */ + ar71xx_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RMII; + ar71xx_eth1_data.speed = SPEED_1000; + ar71xx_eth1_data.duplex = DUPLEX_FULL; + + ar71xx_add_device_mdio(0x0); + ar71xx_add_device_eth(1); + ar71xx_add_device_eth(0); + + ap91_pci_setup_wmac_led_pin(1); + + ap91_pci_init(ee, mac); +} + +MIPS_MACHINE(AR71XX_MACH_WHR_HP_G300N, "WHR-HP-G300N", "Buffalo WHR-HP-G300N", + whrhpg300n_setup); Index: target/linux/ar71xx/files/arch/mips/ar71xx/Makefile =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/Makefile (revision 28023) +++ target/linux/ar71xx/files/arch/mips/ar71xx/Makefile (working copy) @@ -65,3 +65,4 @@ obj-$(CONFIG_AR71XX_MACH_WZR_HP_G300NH) += mach-wzr-hp-g300nh.o obj-$(CONFIG_AR71XX_MACH_WZR_HP_AG300H) += mach-wzr-hp-ag300h.o obj-$(CONFIG_AR71XX_MACH_ZCN_1523H) += mach-zcn-1523h.o +obj-$(CONFIG_AR71XX_MACH_WHR_HP_G300N) += mach-whr-hp-g300n.o Index: target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h (revision 28023) +++ target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h (working copy) @@ -64,6 +64,7 @@ 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_WHR_HP_G300N, /* Buffalo WHR-HP-G300N */ 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 */ Index: target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig (revision 28023) +++ target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig (working copy) @@ -154,6 +154,15 @@ select RTL8366_SMI default y +config AR71XX_MACH_WHR_HP_G300N + bool "Buffalo WHR-HP-G300N board support" + select SOC_AR724X + select AR71XX_DEV_M25P80 + select AR71XX_DEV_AP91_PCI if PCI + select AR71XX_DEV_GPIO_BUTTONS + select AR71XX_DEV_LEDS_GPIO + default y + config AR71XX_MACH_WP543 bool "Compex WP543/WPJ543 board support" select SOC_AR71XX Index: target/linux/ar71xx/image/Makefile =================================================================== --- target/linux/ar71xx/image/Makefile (revision 28023) +++ target/linux/ar71xx/image/Makefile (working copy) @@ -144,6 +144,24 @@ fi endef +define Image/Build/WHRHPG300N + $(call MkuImageLzma,$(2),$(3)) + $(call Sysupgrade/KR,$(1),$(2),917504,2883584) + if [ -e "$(call sysupname,$(1),$(2))" ]; then \ + ( \ + echo -n -e "# Airstation Public Fmt1\x00\x00\x00\x00\x00\x00\x00\x00"; \ + dd if=$(call sysupname,$(1),$(2)); \ + ) > $(call imgname,$(1),$(2))-tftp.bin; \ + buffalo-enc -p $(4) -v 1.76 \ + -i $(call sysupname,$(1),$(2)) \ + -o $(KDIR)/$(2).enc; \ + buffalo-tag -b $(4) -p $(4) -a ath -v 1.76 -m 1.01 -l mlang8 \ + -w 3 -c 0x80041000 -d 0x801e8000 -f 1 -r M_ \ + -i $(KDIR)/$(2).enc \ + -o $(call factoryname,$(1),$(2)); \ + fi +endef + define Image/Build/Cameo $(call MkuImageLzma,$(2),$(3) $($(4))) $(call Sysupgrade/KR,$(1),$(2),$(5),$(6)) @@ -657,7 +675,7 @@ wzrhpg300nh_cmdline=board=WZR-HP-G300NH console=ttyS0,115200 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),WHRHPG300N,wzr-hp-g300nh,$(wzrhpg300nh_cmdline),WZR-HP-G300NH) endef wzrhpag300h_cmdline=board=WZR-HP-AG300H console=ttyS0,115200 @@ -665,6 +683,11 @@ $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-ag300h,$(wzrhpag300h_cmdline),WZR-HP-AG300H) endef +whrhpg300n_cmdline=board=WHR-HP-G300N console=ttyS0,115200 +define Image/Build/Profile/WHRHPG300N + $(call Image/Build/Template/$(fs_64k)/$(1),WHRHPG300N,whr-hp-g300n,$(whrhpg300n_cmdline),whrhpg300n_mtdlayout,WHR-HP-G300N) +endef + zcn1523h28_cmdline=board=ZCN-1523H-2 console=ttyS0,115200 define Image/Build/Profile/ZCN1523H28 $(call Image/Build/Template/$(fs_64k)/$(1),Zcomax,zcn-1523h-2-8,$(zcn1523h28_cmdline)) @@ -719,6 +742,7 @@ $(call Image/Build/Profile/WRT160NL,$(1)) $(call Image/Build/Profile/WZRHPG300NH,$(1)) $(call Image/Build/Profile/WZRHPAG300H,$(1)) + $(call Image/Build/Profile/WHRHPG300N,$(1)) $(call Image/Build/Profile/ZCN1523H28,$(1)) $(call Image/Build/Profile/ZCN1523H516,$(1)) endef Index: target/linux/ar71xx/config-2.6.39 =================================================================== --- target/linux/ar71xx/config-2.6.39 (revision 28023) +++ target/linux/ar71xx/config-2.6.39 (working copy) @@ -49,6 +49,7 @@ CONFIG_AR71XX_MACH_WRT400N=y CONFIG_AR71XX_MACH_WZR_HP_AG300H=y CONFIG_AR71XX_MACH_WZR_HP_G300NH=y +CONFIG_AR71XX_MACH_WHR_HP_G300N=y CONFIG_AR71XX_MACH_ZCN_1523H=y CONFIG_AR71XX_NVRAM=y CONFIG_AR71XX_PCI_ATH9K_FIXUP=y Index: target/linux/ar71xx/generic/profiles/buffalo.mk =================================================================== --- target/linux/ar71xx/generic/profiles/buffalo.mk (revision 28023) +++ target/linux/ar71xx/generic/profiles/buffalo.mk (working copy) @@ -26,3 +26,14 @@ endef $(eval $(call Profile,WZRHPAG300H)) + +define Profile/WHRHPG300N + NAME:=Buffalo WHR-HP-G300N + PACKAGES:=kmod-ath9k wpad-mini +endef + +define Profile/WHRHPG300N/Description + Package set optimized for the Buffalo WHR-HP-G300N +endef + +$(eval $(call Profile,WHRHPG300N)) _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel