Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12312

Device tree issue for Hardware GPIO Watchdog in Linux

$
0
0

I have an OrangePi PC Plus board which runs Linux (ubuntu 18.04) with kernel 4.19.57 on Allwinner H3 processor.

We have designed a hardware watchdog using STWD100 ASIC. This IC has a gpio which should be toggled at least once a second, otherwise it resets the board. On the other hand, I have googled on this subject and I realized that Linux kernel has a driver called gpio watchdog (in KERNEL_SOURCE_PATH/drivers/watchdog/gpio_wdt.c file)

Because of the project requirement, watchdog gpio connected to pin PA19 of processor should begin toggling as soon as the kernel is decompressed and executed, or board is forced reboot by STWD100. For making the issue more complicated, I should add that we can not make any circuit modification. In order to prevent STWD100 from resetting our board before the kernel is loaded, we have a timer which disables STWD100 for about 5~8 seconds and we can not change this time interval (because it is fixed in the circuit). Therefore, we should run our gpio watchdog driver in Linux kernel as soon as control is passed to the kernel.

What I have done so far:

  1. Added printk("============================\n"); to gpio_wdt_probe function of gpio-watchdog driver.
  2. Cross-compiled kernel with CONFIG_GPIO_WATCHDOG=y ,CONFIG_GPIO_WATCHDOG_ARCH_INITCALL=y .
  3. Decompiled board device tree using dtc to get device tree sourcecode from dtb file.
  4. Modified my device tree source code as follows (according tothis link):
/dts-v1/;/ {    ...    soc {        ...        pinctrl@1c20800 {            ...            /* Node added by me */            gpio_wdt: gpio_wdt {                                        pins = "PA19";                function = "gpio_out";                phandle = <0x74>;            };            /* Node added by me */            gpio1: gpio1 {                gpio-controller;                #gpio-cells = <2>;            };        };              ...         /* This node is part of original dts file which triggers internal processor watchdog*/        watchdog@1c20ca0 {                      compatible = "allwinner,sun6i-a31-wdt";            reg = <0x1c20ca0 0x20>;            interrupts = <0x00 0x19 0x04>;            phandle = <0x57>;        };        ...    };    ...    /* Node added by me */    watchdog-gpio {        compatible = "linux,wdt-gpio";        gpios = <&gpio1 19 1>;          /* PA19 should be toggled */        hw_algo = "toggle";        hw_margin_ms = <200>;        always_running;        phandle = <0x75>;           };    ...    __symbols__ {        ...        /* Symbol added by me */        gpiowdt = "/watchdog-gpio";    };};

In the source ... depicts some other nodes which I did not modify.

  1. compiled modified device tree using dtc command.

When kernel runs, I can see ============================ in multiple occasions in kernel logs on UART port. This demonstrates that my builtin gpio watchdog driver is being probed, but my PA19 pin is not toggling.In the case above, I do not get any warning from dtc compiler, but if I replace watchdog-gpio instead of gpio1 in the watchdog-gpio node, when compiling device tree I get the following warning from dtc compiler:

Warning (gpios_property): /watchdog-gpio: Missing property '#gpio-cells' in node /soc/pinctrl@1c20800/gpio_wdt or bad phandle (referred from gpios[0])

Could anyone help me find the issue?

Thanks for reading my post.


Viewing all articles
Browse latest Browse all 12312

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>