The following patch adds preliminary support for the Buffalo WZR-HP-G300NH2. Here is the current state:
* Ethernet switch (AR8316) is functional. eth1 is not connected, so the WAN port is simulated using a vlan. * pci wlan (AR9280 Rev:2), is functional. * flash, obviously, is functional. It is nearly identical to the setup used in the AG300H and the code could easily be shared between the two. * GPIO switches, except for the AOSS button * A single LED, the diagnostic button, is functional. * USB is functional The other LEDs and possibly the AOSS button are connected to GPIOs of the wireless mac. nbd kindly offered to look into exposing the ath9k GPIOs so that we can have a complete GPIO implementation. Many thanks to KanjiMonster and nbd for helping me find my way through the OpenWRT source. This patch applies cleanly to r28009. Boot log: http://pastebin.com/SVzMn1gi Please let me know if there is anything which I have overlooked. -M
Index: target/linux/ar71xx/files/arch/mips/ar71xx/Makefile =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/Makefile (revision 28009) +++ target/linux/ar71xx/files/arch/mips/ar71xx/Makefile (working copy) @@ -63,5 +63,6 @@ obj-$(CONFIG_AR71XX_MACH_WRT160NL) += mach-wrt160nl.o obj-$(CONFIG_AR71XX_MACH_WRT400N) += mach-wrt400n.o obj-$(CONFIG_AR71XX_MACH_WZR_HP_G300NH) += mach-wzr-hp-g300nh.o +obj-$(CONFIG_AR71XX_MACH_WZR_HP_G300NH2) += mach-wzr-hp-g300nh2.o obj-$(CONFIG_AR71XX_MACH_WZR_HP_AG300H) += mach-wzr-hp-ag300h.o obj-$(CONFIG_AR71XX_MACH_ZCN_1523H) += mach-zcn-1523h.o Index: target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h (revision 28009) +++ 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_WZR_HP_G300NH2, /* Buffalo WZR-HP-G300NH2 */ 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 28009) +++ target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig (working copy) @@ -154,6 +154,16 @@ select RTL8366_SMI default y +config AR71XX_MACH_WZR_HP_G300NH2 + bool "Buffalo WZR-HP-G300NH2 board support" + select SOC_AR724X + select AR71XX_DEV_M25P80 + select AR71XX_DEV_GPIO_BUTTONS + select AR71XX_DEV_AP91_PCI if PCI + select AR71XX_DEV_LEDS_GPIO + select AR71XX_DEV_USB + default y + config AR71XX_MACH_WP543 bool "Compex WP543/WPJ543 board support" select SOC_AR71XX Index: target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh2.c =================================================================== --- target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh2.c (revision 0) +++ target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-g300nh2.c (revision 0) @@ -0,0 +1,221 @@ +/* + * Buffalo WZR-HP-G300NH2 board support + * + * Copyright (C) 2011 Felix Fietkau <n...@openwrt.org> + * Copyright (C) 2011 Mark Deneen <mden...@gmail.com> + * + * 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/platform_device.h> +#include <linux/mtd/mtd.h> +#include <linux/mtd/partitions.h> +#include <linux/mtd/concat.h> + +#include <asm/mips_machine.h> +#include <asm/mach-ar71xx/ar71xx.h> +#include <asm/mach-ar71xx/gpio.h> + +#include "machtype.h" +#include "devices.h" +#include "dev-ap91-pci.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "dev-usb.h" + + +#define WZRHPG300NH2_MAC_OFFSET 0x20c +#define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */ +#define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL) + +#ifdef CONFIG_MTD_PARTITIONS +static struct mtd_partition wzrhpg300nh2_flash_partitions[] = { + { + .name = "u-boot", + .offset = 0, + .size = 0x0040000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "u-boot-env", + .offset = 0x0040000, + .size = 0x0010000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "art", + .offset = 0x0050000, + .size = 0x0010000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "kernel", + .offset = 0x0060000, + .size = 0x0100000, + }, { + .name = "rootfs", + .offset = 0x0160000, + .size = 0x1e90000, + }, { + .name = "user_property", + .offset = 0x1ff0000, + .size = 0x0010000, + .mask_flags = MTD_WRITEABLE, + }, { + .name = "firmware", + .offset = 0x0060000, + .size = 0x1f90000, + } +}; + +#endif /* CONFIG_MTD_PARTITIONS */ + +static struct mtd_info *concat_devs[2] = { NULL, NULL }; +static struct work_struct mtd_concat_work; + +static void mtd_concat_add_work(struct work_struct *work) +{ + struct mtd_info *mtd; + + mtd = mtd_concat_create(concat_devs, ARRAY_SIZE(concat_devs), "flash"); + +#ifdef CONFIG_MTD_PARTITIONS + add_mtd_partitions(mtd, wzrhpg300nh2_flash_partitions, + ARRAY_SIZE(wzrhpg300nh2_flash_partitions)); +#else + add_mtd_device(mtd); +#endif +} + + +static struct spi_board_info ar71xx_spi_info[] = { + { + .bus_num = 0, + .chip_select = 0, + .max_speed_hz = 25000000, + .modalias = "m25p80", + }, { + .bus_num = 0, + .chip_select = 1, + .max_speed_hz = 25000000, + .modalias = "m25p80", + } +}; + +/* There are more of these, but they must be accessed through ath9k */ +static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = { + { + .name = "wzr-hp-g300nh2:red:diag", + .gpio = 16, + .active_low = 1, + }, +}; + +/* The AOSS button is likely also behind ath9k */ +static struct gpio_keys_button wzrhpg300nh2_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL, + .gpio = 1, + .active_low = 1, + }, { + .desc = "usb", + .type = EV_KEY, + .code = BTN_2, + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL, + .gpio = 7, + .active_low = 1, + }, { + .desc = "qos", + .type = EV_KEY, + .code = BTN_3, + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL, + .gpio = 11, + .active_low = 0, + }, { + .desc = "router_on", + .type = EV_KEY, + .code = BTN_5, + .debounce_interval = WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL, + .gpio = 8, + .active_low = 0, + }, +}; + + +static void mtd_concat_add(struct mtd_info *mtd) +{ + static bool registered = false; + + if (registered) + return; + + if (!strcmp(mtd->name, "spi0.0")) + concat_devs[0] = mtd; + else if (!strcmp(mtd->name, "spi0.1")) + concat_devs[1] = mtd; + else + return; + + if (!concat_devs[0] || !concat_devs[1]) + return; + + registered = true; + INIT_WORK(&mtd_concat_work, mtd_concat_add_work); + schedule_work(&mtd_concat_work); +} + +static void mtd_concat_remove(struct mtd_info *mtd) +{ +} + +static void add_mtd_concat_notifier(void) +{ + static struct mtd_notifier not = { + .add = mtd_concat_add, + .remove = mtd_concat_remove, + }; + + register_mtd_user(¬); +} + +static void __init wzrhpg300nh2_setup(void) +{ + + u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000); + u8 *mac0 = eeprom + WZRHPG300NH2_MAC_OFFSET; + /* There is an eth1 but it is not connected to the switch */ + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac0, 0); + ar71xx_add_device_mdio(~(BIT(0))); + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac0, 0); + ar71xx_eth0_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth0_data.speed = SPEED_1000; + ar71xx_eth0_data.duplex = DUPLEX_FULL; + ar71xx_eth0_data.phy_mask = BIT(0); + + ar71xx_add_device_eth(0); + ar71xx_add_device_usb(); + /* gpio13 is usb power. Turn it on. */ + gpio_request(13, "usb"); + gpio_direction_output(13, 1); + + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpg300nh2_leds_gpio), + wzrhpg300nh2_leds_gpio); + ar71xx_register_gpio_keys_polled(-1, WZRHPG300NH2_KEYS_POLL_INTERVAL, + ARRAY_SIZE(wzrhpg300nh2_gpio_keys), + wzrhpg300nh2_gpio_keys); + ar71xx_add_device_spi(NULL, ar71xx_spi_info, + ARRAY_SIZE(ar71xx_spi_info)); + + add_mtd_concat_notifier(); + + ap91_pci_init(eeprom, mac0); +} + +MIPS_MACHINE(AR71XX_MACH_WZR_HP_AG300H, "WZR-HP-G300NH2", + "Buffalo WZR-HP-G300NH2", wzrhpg300nh2_setup); + Index: target/linux/ar71xx/image/Makefile =================================================================== --- target/linux/ar71xx/image/Makefile (revision 28009) +++ target/linux/ar71xx/image/Makefile (working copy) @@ -660,6 +660,11 @@ $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g300nh,$(wzrhpg300nh_cmdline),WZR-HP-G300NH) endef +wzrhpg300nh2_cmdline=board=WZR-HP-G300NH2 console=ttyS0,115200 +define Image/Build/Profile/WZRHPG300NH2 + $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-g300nh2,$(wzrhpg300nh2_cmdline),WZR-HP-G300NH2) +endef + wzrhpag300h_cmdline=board=WZR-HP-AG300H console=ttyS0,115200 define Image/Build/Profile/WZRHPAG300H $(call Image/Build/Template/$(fs_128k)/$(1),WZRHPG30XNH,wzr-hp-ag300h,$(wzrhpag300h_cmdline),WZR-HP-AG300H) @@ -718,6 +723,7 @@ $(call Image/Build/Profile/WRT400N,$(1)) $(call Image/Build/Profile/WRT160NL,$(1)) $(call Image/Build/Profile/WZRHPG300NH,$(1)) + $(call Image/Build/Profile/WZRHPG300NH2,$(1)) $(call Image/Build/Profile/WZRHPAG300H,$(1)) $(call Image/Build/Profile/ZCN1523H28,$(1)) $(call Image/Build/Profile/ZCN1523H516,$(1)) Index: target/linux/ar71xx/config-2.6.39 =================================================================== --- target/linux/ar71xx/config-2.6.39 (revision 28009) +++ 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_WZR_HP_G300NH2=y CONFIG_AR71XX_MACH_ZCN_1523H=y CONFIG_AR71XX_NVRAM=y CONFIG_AR71XX_PCI_ATH9K_FIXUP=y Index: target/linux/ar71xx/base-files/lib/ar71xx.sh =================================================================== --- target/linux/ar71xx/base-files/lib/ar71xx.sh (revision 28009) +++ target/linux/ar71xx/base-files/lib/ar71xx.sh (working copy) @@ -160,6 +160,9 @@ *WZR-HP-G300NH) name="wzr-hp-g300nh" ;; + *WZR-HP-G300NH2) + name="wzr-hp-g300nh2" + ;; *ZCN-1523H-2) name="zcn-1523h-2" ;; Index: target/linux/ar71xx/base-files/lib/upgrade/platform.sh =================================================================== --- target/linux/ar71xx/base-files/lib/upgrade/platform.sh (revision 28009) +++ target/linux/ar71xx/base-files/lib/upgrade/platform.sh (working copy) @@ -76,7 +76,7 @@ } 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-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 | wzr-hp-g300nh2 | nbg460n_550n_550nh | unifi ) [ "$magic" != "2705" ] && { echo "Invalid image type." return 1 Index: target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh2/network =================================================================== --- target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh2/network (revision 0) +++ target/linux/ar71xx/base-files/etc/defconfig/wzr-hp-g300nh2/network (revision 0) @@ -0,0 +1,31 @@ +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 eth0.2 + option proto dhcp + +config switch + option name eth0 + option reset 1 + option enable_vlan 1 + +config switch_vlan + option device eth0 + option vlan 1 + option ports "0t 1 3 4 5" + +config switch_vlan + option device eth0 + option vlan 2 + option ports "0t 2" Index: target/linux/ar71xx/generic/profiles/buffalo.mk =================================================================== --- target/linux/ar71xx/generic/profiles/buffalo.mk (revision 28009) +++ target/linux/ar71xx/generic/profiles/buffalo.mk (working copy) @@ -16,6 +16,17 @@ $(eval $(call Profile,WZRHPG300NH)) +define Profile/WZRHPG300NH2 + NAME:=Buffalo WZR-HP-G300NH2 + 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-G300NH2 +endef + +$(eval $(call Profile,WZRHPG300NH2)) + define Profile/WZRHPAG300H NAME:=Buffalo WZR-HP-AG300H PACKAGES:=kmod-ath9k wpad-mini kmod-usb-ohci kmod-usb-core kmod-usb2 kmod-ledtrig-usbdev
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel