Hello Florian,

Am 04.12.2011 18:40, schrieb Florian Fainelli:
Hello Mathias,

Le dimanche 04 décembre 2011 18:16:39, Mathias Adam a écrit :

However, the device has a hardware watchdog which needs GPIO7 to be
toggled regularly. Otherwise, the device simply resets after 2-3 secs,
so I wasn't even able to boot into OpenWrt at first.

As a quick fix I put together a small kernel patch which adds a timer to
regularly perform the GPIO toggle. While this does work for me, I think
it could need some cleanup... perhaps, is there already an
infrastructure related to platform-/board-specific watchdogs where this
could be attached to?

Are there other devices already supported by OpenWrt with a similar
watchdog?

The MTX-1 board (AMD Alchemy) is using a similar GPIO-based watchdog:

http://lxr.linux.no/#linux+v3.1.4/drivers/watchdog/mtx-1_wdt.c

such a driver could be made generic by the way.

merci! indeed, from a quick glance it seems very similar to my patch. I'll look into making a generic driver as you suggest.

For the moment I attach the patch which works for me:

--- trunk/build_dir/linux-brcm47xx/linux-3.0.9/drivers/mtd/maps/bcm47xx-pflash.c 2011-11-28 13:40:19.000000000 +0100 +++ trunk_copy111203/build_dir/linux-brcm47xx/linux-3.0.9/drivers/mtd/maps/bcm47xx-pflash.c 2011-12-03 23:01:37.000000000 +0100
@@ -48,13 +48,39 @@
 #include <linux/io.h>
 #include <asm/mach-bcm47xx/bcm47xx.h>
 #include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <linux/timer.h>
+#include <linux/jiffies.h>

 #define WINDOW_ADDR 0x1fc00000
 #define WINDOW_SIZE 0x400000
 #define BUSWIDTH 2

 static struct mtd_info *bcm47xx_mtd;

+static struct timer_list hwwdt_timer;
+
+static void bcm47xx_hwwdt_timer_tick(unsigned long unused)
+{
+        int ret;
+//      printk(KERN_INFO "bcm47xx_timer_tick() called\n");
+
+        ret = gpio_request(7, "test");
+//        printk(KERN_INFO "gpio_request(7)  ret = %i\n", ret);
+
+        ret = gpio_direction_input(7);
+//      printk(KERN_INFO "gpio_direction_input(7)  ret = %i\n", ret);
+        ret = gpio_get_value(7);
+//      printk(KERN_INFO "gpio_get_value(7)  ret = %i\n", ret);
+
+        ret = gpio_direction_output(7, ret ? 0 : 1);
+// printk(KERN_INFO "gpio_direction_output(7, !ret) ret = %i\n", ret);
+
+        gpio_free(7);
+
+       mod_timer(&hwwdt_timer, jiffies + HZ/5);
+}
+
static void bcm47xx_map_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
 {
        if (len == 1) {
@@ -91,6 +117,10 @@
        struct mtd_partition *partitions = NULL;
        int num_partitions = 0;

+ pr_notice("starting hardware watchdog reset timer (for Huawei E970 devices)\n");
+       setup_timer(&hwwdt_timer, bcm47xx_hwwdt_timer_tick, 0L);
+       bcm47xx_hwwdt_timer_tick(0);
+
        switch (bcm47xx_bus_type) {
 #ifdef CONFIG_BCM47XX_SSB
        case BCM47XX_BUS_TYPE_SSB:
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to