On 12/15/2011 11:58 AM, Mark Deneen wrote:
The following patch applies cleanly to r29537 and adds support for the Buffalo WZR-HP-G300NH2. It's still missing a few things, though.
This is an update of my patch earlier today. This includes the updated LED support from Mark above, and tidies up the formatting. For anyone who's not been following, this means that WZR-HP-G300NH, WZR-HP-G300NH2 and WZR-HP-AG300N are supported in a single image.
Index: files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c =================================================================== --- files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c (revision 29557) +++ files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c (working copy) @@ -1,7 +1,12 @@ /* * Buffalo WZR-HP-G300NH board support + * Buffalo WZR-HP-G300NH2 board support + * Buffalo WZR-HP-AG300H board support * * Copyright (C) 2010 Gabor Juhos <juh...@openwrt.org> + * Copyright (C) 2011 Felix Fietkau <n...@openwrt.org> + * Copyright (C) 2011 Mark Deneen <mden...@gmail.com> + * Copyright (C) 2011 Peter Naulls <pe...@chocky.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 @@ -11,8 +16,10 @@ #include <linux/platform_device.h> #include <linux/mtd/mtd.h> #include <linux/mtd/partitions.h> + #include <linux/nxp_74hc153.h> #include <linux/rtl8366.h> +#include <asm/mach-ar71xx/gpio.h> #include <asm/mips_machine.h> #include <asm/mach-ar71xx/ar71xx.h> @@ -24,6 +31,9 @@ #include "dev-gpio-buttons.h" #include "dev-leds-gpio.h" #include "dev-usb.h" +#include "dev-m25p80.h" +#include "dev-ap91-pci.h" +#include "dev-ap94-pci.h" #define WZRHPG300NH_GPIO_LED_USB 0 #define WZRHPG300NH_GPIO_LED_DIAG 1 @@ -53,6 +63,18 @@ #define WZRHPG300NH_MAC_OFFSET 0x20c + +#define WZRHPG300NH2_MAC_OFFSET 0x20c +#define WZRHPG300NH2_KEYS_POLL_INTERVAL 20 /* msecs */ +#define WZRHPG300NH2_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPG300NH2_KEYS_POLL_INTERVAL) + + +#define WZRHPAG300H_MAC_OFFSET 0x20c +#define WZRHPAG300H_KEYS_POLL_INTERVAL 20 /* msecs */ +#define WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL (3 * WZRHPAG300H_KEYS_POLL_INTERVAL) + + + #ifdef CONFIG_MTD_PARTITIONS static struct mtd_partition wzrhpg300nh_flash_partitions[] = { { @@ -89,6 +111,47 @@ .size = 0x1f60000, } }; + + +/* AG300H and G300NH2 use identical flash layouts */ + +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 ar91xx_flash_platform_data wzrhpg300nh_flash_data = { @@ -99,6 +162,16 @@ #endif }; + +static struct flash_platform_data wzrhpg300nh2_flash_data = { +#ifdef CONFIG_MTD_PARTITIONS + .parts = wzrhpg300nh2_flash_partitions, + .nr_parts = ARRAY_SIZE(wzrhpg300nh2_flash_partitions), +#endif +}; + + + #define WZRHPG300NH_FLASH_BASE 0x1e000000 #define WZRHPG300NH_FLASH_SIZE (32 * 1024 * 1024) @@ -120,6 +193,7 @@ } }; + static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = { { .name = "buffalo:orange:security", @@ -144,6 +218,60 @@ } }; + +static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = { + { + .name = "buffalo:red:diag", + .gpio = 1, + .active_low = 1, + }, +}; + + +static struct gpio_led wzrhpg300nh2_leds_gpio[] __initdata = { + { + .name = "buffalo:red:diag", + .gpio = 16, + .active_low = 1, + }, +}; + + +static struct gpio_led wzrhpg300nh2_wmac_leds_gpio[] = { + { + .name = "buffalo:blue:usb", + .gpio = 4, + .active_low = 1, + }, + { + .name = "buffalo:green:wireless", + .gpio = 5, + .active_low = 1, + }, + { + .name = "buffalo:orange:security", + .gpio = 6, + .active_low = 1, + }, + { + .name = "buffalo:green:router", + .gpio = 7, + .active_low = 1, + }, + { + .name = "buffalo:blue:movie_engine_on", + .gpio = 8, + .active_low = 1, + }, + { + .name = "buffalo:blue:movie_engine_off", + .gpio = 9, + .active_low = 1, + }, +}; + + + static struct gpio_keys_button wzrhpg300nh_gpio_keys[] __initdata = { { .desc = "reset", @@ -197,6 +325,78 @@ } }; +/* 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 struct gpio_keys_button wzrhpag300h_gpio_keys[] __initdata = { + { + .desc = "reset", + .type = EV_KEY, + .code = KEY_RESTART, + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, + .gpio = 11, + .active_low = 1, + }, { + .desc = "usb", + .type = EV_KEY, + .code = BTN_2, + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, + .gpio = 3, + .active_low = 1, + }, { + .desc = "aoss", + .type = EV_KEY, + .code = KEY_WPS_BUTTON, + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, + .gpio = 5, + .active_low = 1, + }, { + .desc = "router_auto", + .type = EV_KEY, + .code = BTN_6, + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, + .gpio = 6, + .active_low = 1, + }, { + .desc = "router_off", + .type = EV_KEY, + .code = BTN_5, + .debounce_interval = WZRHPAG300H_KEYS_DEBOUNCE_INTERVAL, + .gpio = 7, + .active_low = 1, + } +}; + static struct nxp_74hc153_platform_data wzrhpg300nh_74hc153_data = { .gpio_base = WZRHPG300NH_GPIO_EXP_BASE, .gpio_pin_s0 = WZRHPG300NH_GPIO_74HC153_S0, @@ -234,12 +434,96 @@ } }; + +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_add_device_m25p80_multi(&wzrhpg300nh2_flash_data); + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac0, 0); + ar71xx_add_device_mdio(0, ~(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); + + ap91_pci_setup_wmac_led_pin(22); + ap91_pci_setup_wmac_leds(wzrhpg300nh2_wmac_leds_gpio, + ARRAY_SIZE(wzrhpg300nh2_wmac_leds_gpio)); + + ap91_pci_init(eeprom, mac0); +} + +static void __init wzrhpag300h_setup(void) +{ + u8 *eeprom1 = (u8 *) KSEG1ADDR(0x1f051000); + u8 *eeprom2 = (u8 *) KSEG1ADDR(0x1f055000); + u8 *mac1 = eeprom1 + WZRHPAG300H_MAC_OFFSET; + u8 *mac2 = eeprom2 + WZRHPAG300H_MAC_OFFSET; + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac1, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac2, 1); + + ar71xx_add_device_mdio(0, ~(BIT(0) | BIT(4))); + + 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_eth1_data.phy_if_mode = PHY_INTERFACE_MODE_RGMII; + ar71xx_eth1_data.phy_mask = BIT(4); + + ar71xx_add_device_eth(0); + ar71xx_add_device_eth(1); + + ar71xx_add_device_usb(); + gpio_request(2, "usb"); + gpio_direction_output(2, 1); + + ar71xx_add_device_leds_gpio(-1, ARRAY_SIZE(wzrhpag300h_leds_gpio), + wzrhpag300h_leds_gpio); + + ar71xx_register_gpio_keys_polled(-1, WZRHPAG300H_KEYS_POLL_INTERVAL, + ARRAY_SIZE(wzrhpag300h_gpio_keys), + wzrhpag300h_gpio_keys); + + ar71xx_add_device_m25p80_multi(&wzrhpg300nh2_flash_data); + + ap94_pci_init(eeprom1, mac1, eeprom2, mac2); +} + static void __init wzrhpg300nh_setup(void) { u8 *eeprom = (u8 *) KSEG1ADDR(0x1fff1000); u8 *mac = eeprom + WZRHPG300NH_MAC_OFFSET; bool hasrtl8366rb = false; + if (ar71xx_soc == AR71XX_SOC_AR7242) { + wzrhpg300nh2_setup(); + return; + } else if (ar71xx_soc == AR71XX_SOC_AR7161) { + wzrhpag300h_setup(); + return; + } + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); Index: files/arch/mips/ar71xx/Kconfig =================================================================== --- files/arch/mips/ar71xx/Kconfig (revision 29557) +++ files/arch/mips/ar71xx/Kconfig (working copy) @@ -137,14 +137,6 @@ select AR71XX_DEV_PB42_PCI if PCI select AR71XX_DEV_LEDS_GPIO -config AR71XX_MACH_WZR_HP_AG300H - bool "Buffalo WZR-HP-AG300H board support" - select SOC_AR71XX - select AR71XX_DEV_M25P80 - select AR71XX_DEV_GPIO_BUTTONS - select AR71XX_DEV_LEDS_GPIO - select AR71XX_DEV_USB - config AR71XX_MACH_WZR_HP_G450H bool "Buffalo WZR-HP-G450H board support" select SOC_AR724X @@ -155,12 +147,16 @@ select AR71XX_DEV_USB config AR71XX_MACH_WZR_HP_G300NH - bool "Buffalo WZR-HP-G300NH board support" + bool "Buffalo WZR-HP-G300NH, G301NH, G300NH2 and AG300H board support" + select SOC_AR71XX + select SOC_AR724X select SOC_AR913X select AR71XX_DEV_AR9XXX_WMAC select AR71XX_DEV_GPIO_BUTTONS select AR71XX_DEV_LEDS_GPIO select AR71XX_DEV_USB + select AR71XX_DEV_M25P80 + select AR71XX_DEV_AP91_PCI if PCI select RTL8366_SMI config AR71XX_MACH_WHR_HP_G300N Signed-off-by: Peter Naulls <pe...@chocky.org>
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel