From: Felix Fietkau Date: Wed, 1 Jun 2011 02:23:26 +0000 (+0000) Subject: ar71xx: add kernel support for the buffalo wzr-hp-ag300h X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=4f06b8263aad0b689c30c440ec9e51b4088a6675;p=openwrt%2Fstaging%2Fthess.git ar71xx: add kernel support for the buffalo wzr-hp-ag300h SVN-Revision: 27075 --- diff --git a/target/linux/ar71xx/config-2.6.37 b/target/linux/ar71xx/config-2.6.37 index f36b6ee4eb..f7a27f0333 100644 --- a/target/linux/ar71xx/config-2.6.37 +++ b/target/linux/ar71xx/config-2.6.37 @@ -47,6 +47,7 @@ CONFIG_AR71XX_MACH_WNR2000=y CONFIG_AR71XX_MACH_WP543=y CONFIG_AR71XX_MACH_WRT160NL=y CONFIG_AR71XX_MACH_WRT400N=y +CONFIG_AR71XX_MACH_WZR_HP_AG300H=y CONFIG_AR71XX_MACH_WZR_HP_G300NH=y CONFIG_AR71XX_MACH_ZCN_1523H=y CONFIG_AR71XX_NVRAM=y @@ -146,6 +147,7 @@ CONFIG_MIPS_MT_DISABLED=y CONFIG_MTD_AR91XX_FLASH=y # CONFIG_MTD_CFI_INTELEXT is not set CONFIG_MTD_CMDLINE_PARTS=y +CONFIG_MTD_CONCAT=y CONFIG_MTD_JEDECPROBE=y CONFIG_MTD_M25P80=y CONFIG_MTD_MYLOADER_PARTS=y diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig index c540460532..865fc47ac9 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Kconfig @@ -135,6 +135,15 @@ config AR71XX_MACH_AW_NR580 select AR71XX_DEV_LEDS_GPIO default n +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 + default y + config AR71XX_MACH_WZR_HP_G300NH bool "Buffalo WZR-HP-G300NH board support" select SOC_AR913X diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile index 14ca6f2b69..4fc187f3db 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/Makefile @@ -63,4 +63,5 @@ obj-$(CONFIG_AR71XX_MACH_WP543) += mach-wp543.o 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_AG300H) += mach-wzr-hp-ag300h.o obj-$(CONFIG_AR71XX_MACH_ZCN_1523H) += mach-zcn-1523h.o diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-ag300h.c b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-ag300h.c new file mode 100644 index 0000000000..84d88ccdad --- /dev/null +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/mach-wzr-hp-ag300h.c @@ -0,0 +1,232 @@ +/* + * Buffalo WZR-HP-AG300H board support + * + * Copyright (C) 2011 Felix Fietkau + * + * 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 +#include +#include +#include + +#include +#include + +#include "machtype.h" +#include "devices.h" +#include "dev-ap94-pci.h" +#include "dev-gpio-buttons.h" +#include "dev-leds-gpio.h" +#include "dev-m25p80.h" +#include "dev-usb.h" + +#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_CONCAT + +#ifdef CONFIG_MTD_PARTITIONS +static struct mtd_partition wzrhpag300h_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, wzrhpag300h_flash_partitions, + ARRAY_SIZE(wzrhpag300h_flash_partitions)); +#else + add_mtd_device(mtd); +#endif +} + +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(¬); +} + +#endif + +static struct gpio_led wzrhpag300h_leds_gpio[] __initdata = { + { + .name = "wzr-hp-ag300h:red:diag", + .gpio = 1, + .active_low = 1, + }, +}; + + +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 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", + } +}; + +static void __init wzrhpag300h_setup(void) +{ + u8 *eeprom = (u8 *) KSEG1ADDR(0x1f051000); + u8 *mac = eeprom + WZRHPAG300H_MAC_OFFSET; + + ar71xx_init_mac(ar71xx_eth0_data.mac_addr, mac, 0); + ar71xx_init_mac(ar71xx_eth1_data.mac_addr, mac, 1); + + ar71xx_add_device_mdio(~(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(); + + 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_spi(NULL, ar71xx_spi_info, + ARRAY_SIZE(ar71xx_spi_info)); + +#ifdef CONFIG_MTD_CONCAT + add_mtd_concat_notifier(); +#endif + + ap94_pci_init(eeprom, mac, NULL, NULL); +} + +MIPS_MACHINE(AR71XX_MACH_WZR_HP_AG300H, "WZR-HP-AG300H", + "Buffalo WZR-HP-AG300H", wzrhpag300h_setup); + diff --git a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h index 5037dee47b..3071792f28 100644 --- a/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h +++ b/target/linux/ar71xx/files/arch/mips/ar71xx/machtype.h @@ -62,6 +62,7 @@ enum ar71xx_mach_type { AR71XX_MACH_WP543, /* Compex WP543 */ AR71XX_MACH_WRT160NL, /* Linksys WRT160NL */ 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_G301NH, /* Buffalo WZR-HP-G301NH */ AR71XX_MACH_EAP7660D, /* Senao EAP7660D */