ping...

Am So, 14.10.2012, 21:13 schrieb Mathias Adam:
> This patch adds support for Huawei E970 wireless gateway devices.
> It has been tested on an E970 labelled as T-Mobile web'n'walk Box IV.
> E960/B970 should work too, from what I know it's basically the same
> hardware.
>
> The device has a Broadcom BCM5354 SoC and a built-in 3G USB modem.
> For reference, it has already been addressed in this open ticket:
> <https://dev.openwrt.org/ticket/2711>
>
> The device has a hardware watchdog which needs GPIO-7 to be toggled at
> least
> every 1-2 seconds. Therefore a timer is being setup early in the boot
> process
> in order to take care of this  (see arch/mips/bcm47xx/time.c).
>
> Tested and works:  3G wan,  wlan+LED,  VLAN config,  failsafe using reset
> button,   image to be used for upgrade from OEM firmware's web interface
>
> Link to the wiki page I've created:
> <http://wiki.openwrt.org/toh/huawei/e970>
>
> Issue:
>
> * lzma-loader crashes, so gzipped kernel is used. Presumably due to
> watchdog
>   reset during kernel decompress.
>
> Signed-off-by: Mathias Adam <m.adam--open...@adamis.de>
>
> ---
>
> Changes from previous patch:
>
> * rebased to svn-rev. 33761
> * b43 wireless now works out of box (no changes were necessary on my part)
> * modifications according to comments by Hauke Mehrtens on 2012-04-25
> * header for factory update package now created using dd and echo, no need
>   for binary header template file anymore
>
>
> diff --git a/package/broadcom-diag/src/diag.c
> b/package/broadcom-diag/src/diag.c
> index 7e0ff02..0780f3f 100644
> --- a/package/broadcom-diag/src/diag.c
> +++ b/package/broadcom-diag/src/diag.c
> @@ -149,6 +149,9 @@ enum {
>
>       /* Edimax */
>       PS1208MFG,
> +
> +     /* Huawei */
> +     HUAWEI_E970,
>  };
>
>  static void __init bcm4780_init(void) {
> @@ -1016,6 +1019,16 @@ static struct platform_t __initdata platforms[] = {
>                       { .name = "wlan",       .gpio = 1 << 0, .polarity = 
> NORMAL },
>               },
>       },
> +     /* Huawei */
> +     [HUAWEI_E970] = {
> +             .name   = "Huawei E970",
> +             .buttons        = {
> +                     { .name = "reset",      .gpio = 1 << 6 },
> +             },
> +             .leds     = {
> +                     { .name = "wlan",       .gpio = 1 << 0, .polarity = 
> NORMAL },
> +             },
> +     },
>  };
>
>  static struct platform_t __init *platform_detect(void)
> @@ -1279,6 +1292,9 @@ static struct platform_t __init
> *platform_detect(void)
>               !strcmp(getvar("status_gpio"), "1")) /* gpio based detection */
>               return &platforms[PS1208MFG];
>
> +     if (!strcmp(boardnum, "0x5347") && !strcmp(boardtype, "0x048e"))  /*
> Huawei E970 */
> +             return &platforms[HUAWEI_E970];
> +
>       /* not found */
>       return NULL;
>  }
> diff --git a/target/linux/brcm47xx/image/Makefile
> b/target/linux/brcm47xx/image/Makefile
> index 33290ff..7e7c81b 100644
> --- a/target/linux/brcm47xx/image/Makefile
> +++ b/target/linux/brcm47xx/image/Makefile
> @@ -13,6 +13,7 @@ endef
>
>  define Image/Prepare
>       cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1
> -lp2 -pb2 > $(KDIR)/vmlinux.lzma
> +     gzip -nc9 $(KDIR)/vmlinux > $(KDIR)/vmlinux.gz
>       rm -f $(KDIR)/loader.gz
>       $(MAKE) -C lzma-loader \
>               BUILD_DIR="$(KDIR)" \
> @@ -51,6 +52,12 @@ define Image/Build/Edi
>       $(STAGING_DIR_HOST)/bin/trx2edips $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx
> $(BIN_DIR)/openwrt-$(2)-$(3).bin
>  endef
>
> +define Image/Build/Huawei
> +     dd if=/dev/zero of=$(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin bs=92 count=1
> +     echo -ne 'HDR0\x08\x00\x00\x00' >> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
> +     cat $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx >>
> $(BIN_DIR)/openwrt-$(2)-$(3)-gz.bin
> +endef
> +
>  define trxalign/jffs2-128k
>  -a 0x20000 -f $(KDIR)/root.$(1)
>  endef
> @@ -109,9 +116,13 @@ define Image/Build
>       $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1).trx \
>               -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma \
>               $(call trxalign/$(1),$(1))
> +     $(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-gz.trx \
> +             -f $(KDIR)/vmlinux.gz \
> +             $(call trxalign/$(1),$(1))
>       $(call Image/Build/$(1),$(1))
>       $(call Image/Build/Motorola,$(1),wr850g,1,$(1))
>       $(call Image/Build/USR,$(1),usr5461,$(1))
> +     $(call Image/Build/Huawei,$(1),e970,$(1))
>  #    $(call Image/Build/Chk,$(1),wgr614_v8,U12H072T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
>  #    $(call Image/Build/Chk,$(1),wgr614_v9,U12H094T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
>  #    $(call Image/Build/Chk,$(1),wndr3300,U12H093T00_NETGEAR,2,$(patsubst
> jffs2-%,jffs2,$(1)))
> diff --git
> a/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
> b/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
> new file mode 100644
> index 0000000..2d83d24
> --- /dev/null
> +++ b/target/linux/brcm47xx/patches-3.3/830-huawei_e970_support.patch
> @@ -0,0 +1,120 @@
> +--- a/arch/mips/bcm47xx/time.c
> ++++ b/arch/mips/bcm47xx/time.c
> +@@ -25,9 +25,75 @@
> +
> + #include <linux/init.h>
> + #include <linux/ssb/ssb.h>
> ++#include <linux/gpio.h>
> + #include <asm/time.h>
> ++#include <asm/mach-bcm47xx/nvram.h>
> + #include <bcm47xx.h>
> +
> ++#define ROUTER_HUAWEI_E970          1
> ++
> ++#define E970_GPIO_WDT_INTERVAL              HZ
> ++#define E970_GPIO_WDT_PIN           7
> ++
> ++
> ++static struct bcm47xx_gpiowdt {
> ++    struct timer_list timer;
> ++    unsigned long interval;
> ++    unsigned gpio;
> ++    int gstate;
> ++} bcm47xx_gpiowdt;
> ++
> ++
> ++static void bcm47xx_gpiowdt_timer_tick(unsigned long unused)
> ++{
> ++    bcm47xx_gpiowdt.gstate = !bcm47xx_gpiowdt.gstate;
> ++    gpio_set_value(bcm47xx_gpiowdt.gpio, bcm47xx_gpiowdt.gstate);
> ++
> ++    mod_timer(&bcm47xx_gpiowdt.timer, jiffies + bcm47xx_gpiowdt.interval);
> ++}
> ++
> ++static void bcm47xx_gpiowdt_setup(unsigned long interval, unsigned gpio)
> ++{
> ++    int ret;
> ++
> ++    bcm47xx_gpiowdt.interval = interval;
> ++    bcm47xx_gpiowdt.gpio = gpio;
> ++    bcm47xx_gpiowdt.gstate = 1;
> ++
> ++    ret = gpio_request(bcm47xx_gpiowdt.gpio, "bcm47xx-gpio-wdt");
> ++    if (ret < 0) {
> ++            printk(KERN_INFO "bcm47xx: failed to request gpio\n");
> ++            return;
> ++    }
> ++    ret = gpio_direction_output(bcm47xx_gpiowdt.gpio,
> bcm47xx_gpiowdt.gstate);
> ++    if (ret < 0) {
> ++            printk(KERN_INFO "bcm47xx: failed to set gpio as output\n");
> ++            return;
> ++    }
> ++
> ++    setup_timer(&bcm47xx_gpiowdt.timer, bcm47xx_gpiowdt_timer_tick, 0L);
> ++    bcm47xx_gpiowdt_timer_tick(0);
> ++}
> ++
> ++static int get_router(void)
> ++{
> ++    char buf[20];
> ++    u32 boardnum = 0;
> ++    u16 boardtype = 0;
> ++
> ++    if (nvram_getenv("boardnum", buf, sizeof(buf)) >= 0)
> ++            boardnum = simple_strtoul(buf, NULL, 0);
> ++    if (nvram_getenv("boardtype", buf, sizeof(buf)) >= 0)
> ++            boardtype = simple_strtoul(buf, NULL, 0);
> ++
> ++    if (boardnum == 0x5347 && boardtype == 0x048e) {
> ++            /* Huawei E970 */
> ++                return ROUTER_HUAWEI_E970;
> ++    }
> ++
> ++    return 0;
> ++}
> ++
> + void __init plat_time_init(void)
> + {
> +     unsigned long hz = 0;
> +@@ -57,4 +123,11 @@ void __init plat_time_init(void)
> +
> +     /* Set MIPS counter frequency for fixed_rate_gettimeoffset() */
> +     mips_hpt_frequency = hz;
> ++
> ++    /* device-specific initializations */
> ++    switch (get_router()) {
> ++    case ROUTER_HUAWEI_E970:
> ++            printk(KERN_INFO "bcm47xx: detected Huawei E970, starting gpio
> watchdog pet timer\n");
> ++            bcm47xx_gpiowdt_setup(E970_GPIO_WDT_INTERVAL, 
> E970_GPIO_WDT_PIN);
> ++    }
> + }
> +--- a/drivers/mtd/bcm47xxpart.c
> ++++ b/drivers/mtd/bcm47xxpart.c
> +@@ -84,6 +84,7 @@ struct trx_header {
> + #define ROUTER_NETGEAR_WNR3500L             4
> + #define ROUTER_SIMPLETECH_SIMPLESHARE       5
> + #define ROUTER_NETGEAR_WNDR3400             6
> ++#define ROUTER_HUAWEI_E970          7
> +
> + static int
> + find_cfe_size(struct mtd_info *mtd)
> +@@ -405,6 +406,11 @@ static int get_router(void)
> +             return ROUTER_SIMPLETECH_SIMPLESHARE;
> +     }
> +
> ++    if (boardnum == 0x5347 && boardtype == 0x048e) {
> ++            /* Huawei E970 */
> ++                return ROUTER_HUAWEI_E970;
> ++    }
> ++
> +     return 0;
> + }
> +
> +@@ -446,6 +452,7 @@ static int parse_bcm47xx_partitions(stru
> +             case ROUTER_NETGEAR_WNDR3300:
> +             case ROUTER_NETGEAR_WNR3500L:
> +             case ROUTER_NETGEAR_WNDR3400:
> ++            case ROUTER_HUAWEI_E970:
> +                     /* Netgear: checksum is @ 0x003AFFF8 for 4M flash or 
> checksum
> +                      * is @ 0x007AFFF8 for 8M flash
> +                      */
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>
>


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to