On 12/14/2011 12:52 PM, Felix Fietkau wrote:
If I clean up the common mtd code between the various boards which
concat two partitions together, can we get this applied?
I recently moved the mtd concat code so that it can be shared. I also
added support for registering LEDs from ath9k (based on platform data,
see wzr-hp-g450h). Please update your patch to make use of this, and
I'll make sure it gets merged.
First cut. There are obviously further changes to remove the ag300h
as an explicit target in image generation. But this is the core
arch file change.
Index: files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c
===================================================================
--- files/arch/mips/ar71xx/mach-wzr-hp-g300nh.c (revision 29529)
+++ 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 <[email protected]>
+ * Copyright (C) 2011 Felix Fietkau <[email protected]>
+ * Copyright (C) 2011 Mark Deneen <[email protected]>
+ * Copyright (C) 2011 Peter Naulls <[email protected]>
*
* 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,11 @@
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
+#include <linux/mtd/concat.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>
@@ -20,10 +28,13 @@
#include "machtype.h"
#include "devices.h"
+#include "dev-ap94-pci.h"
#include "dev-ar9xxx-wmac.h"
#include "dev-gpio-buttons.h"
#include "dev-leds-gpio.h"
#include "dev-usb.h"
+#include "dev-ap91-pci.h"
+#include "dev-m25p80.h"
#define WZRHPG300NH_GPIO_LED_USB 0
#define WZRHPG300NH_GPIO_LED_DIAG 1
@@ -53,6 +64,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 +112,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 +163,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 +194,7 @@
}
};
+
static struct gpio_led wzrhpg300nh_leds_gpio[] __initdata = {
{
.name = "buffalo:orange:security",
@@ -144,6 +219,24 @@
}
};
+/* 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,
+ },
+};
+
+
+static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = {
+ {
+ .name = "buffalo:red:diag",
+ .gpio = 1,
+ .active_low = 1,
+ },
+};
+
static struct gpio_keys_button wzrhpg300nh_gpio_keys[] __initdata = {
{
.desc = "reset",
@@ -197,6 +290,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 +399,92 @@
}
};
+
+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(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);
+
+ ar71xx_add_device_m25p80_multi(&wzrhpg300nh2_flash_data);
+
+ 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 29529)
+++ files/arch/mips/ar71xx/Kconfig (working copy)
@@ -128,14 +128,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
@@ -146,12 +138,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
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel