您尚未登录。

楼主 #1 2020-11-07 16:24:51

九重天
会员
注册时间: 2020-10-06
已发帖子: 25
积分: 17.5

DA906X I2C看门狗 linux 驱动分析

手册: https://www.dialog-semiconductor.com/sites/default/files/da9061-a_datasheet_2v3.pdf





Documentation/devicetree/bindings/watchdog/da9062-wdt.txt

* Dialog Semiconductor DA9062/61 Watchdog Timer

Required properties:

- compatible: should be one of the following valid compatible string lines:
        "dlg,da9061-watchdog", "dlg,da9062-watchdog"
        "dlg,da9062-watchdog"

Optional properties:
- dlg,use-sw-pm: Add this property to disable the watchdog during suspend.
        Only use this option if you can't use the watchdog automatic suspend
        function during a suspend (see register CONTROL_B).

Example: DA9062

        pmic0: da9062@58 {
                watchdog {
                        compatible = "dlg,da9062-watchdog";
                };
        };

Example: DA9061 using a fall-back compatible for the DA9062 watchdog driver

        pmic0: da9061@58 {
                watchdog {
                        compatible = "dlg,da9061-watchdog", "dlg,da9062-watchdog";
                };
        };

include/linux/mfd/da9062/registers.h

/* DA9062AA_CONTROL_F = 0x013 */
#define DA9062AA_WATCHDOG_SHIFT         0
#define DA9062AA_WATCHDOG_MASK          0x01
#define DA9062AA_SHUTDOWN_SHIFT         1
#define DA9062AA_SHUTDOWN_MASK          BIT(1)
#define DA9062AA_WAKE_UP_SHIFT          2
#define DA9062AA_WAKE_UP_MASK           BIT(2)

drivers/watchdog/da9062_wdt.c

static int da9062_wdt_restart(struct watchdog_device *wdd, unsigned long action,
                              void *data)
{
        struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
        struct i2c_client *client = to_i2c_client(wdt->hw->dev);
        int ret;

        /* Don't use regmap because it is not atomic safe */
        ret = i2c_smbus_write_byte_data(client, DA9062AA_CONTROL_F,
                                        DA9062AA_SHUTDOWN_MASK);
        if (ret < 0)
                dev_alert(wdt->hw->dev, "Failed to shutdown (err = %d)\n",
                          ret);

        /* wait for reset to assert... */
        mdelay(500);

        return ret;
}

离线

#2 2020-11-07 23:57:04

梁上君子
会员
注册时间: 2020-10-11
已发帖子: 7
积分: 6

Re: DA906X I2C看门狗 linux 驱动分析

watchdog: watchdog {
compatible="linux,wdt-gpio";
gpios=<&gpio3 17 GPIO_ACTIVE_LOW>;
hw_algo=”toggle”;
hw_margin_ms=<1600>;
};

这个GPIO的看门狗也不错噢

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn