mirror of
https://gitee.com/open-loongarch/linux-6.12.git
synced 2026-10-25 12:37:11 +08:00
wdt:Correct default heartbeat timeout
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn>
This commit is contained in:
@@ -44,6 +44,7 @@ static int ls2x_wdt_set_timeout(struct watchdog_device *wdt_dev,
|
||||
unsigned int max_hw_heartbeat = wdt_dev->max_hw_heartbeat_ms / 1000;
|
||||
unsigned int counts;
|
||||
|
||||
pr_info("wdt==>max_hw_heartbeat:%d\n", max_hw_heartbeat);
|
||||
wdt_dev->timeout = timeout;
|
||||
|
||||
counts = drvdata->clk_rate * min(timeout, max_hw_heartbeat);
|
||||
@@ -88,9 +89,11 @@ static int ls2x_wdt_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct ls2x_wdt_drvdata *drvdata;
|
||||
struct watchdog_device *ls2x_wdt;
|
||||
unsigned long clk_rate;
|
||||
u32 clk_rate;
|
||||
u32 max_hw_heartbeat_s;
|
||||
struct resource *res;
|
||||
int err;
|
||||
struct device_node *np = pdev->dev.of_node;
|
||||
|
||||
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
|
||||
if (!drvdata)
|
||||
@@ -101,31 +104,37 @@ static int ls2x_wdt_probe(struct platform_device *pdev)
|
||||
if (IS_ERR(drvdata->base))
|
||||
return PTR_ERR(drvdata->base);
|
||||
|
||||
drvdata->clk = devm_clk_get(&pdev->dev, "wdt-clk");
|
||||
if (IS_ERR(drvdata->clk))
|
||||
return PTR_ERR(drvdata->clk);
|
||||
if(!of_property_read_u32(np,"clock-frequency",&clk_rate)) {
|
||||
drvdata->clk_rate = clk_rate;
|
||||
}else {
|
||||
drvdata->clk = devm_clk_get(&pdev->dev, "wdt-clk");
|
||||
if (IS_ERR(drvdata->clk))
|
||||
return PTR_ERR(drvdata->clk);
|
||||
|
||||
err = clk_prepare_enable(drvdata->clk);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "clk enable failed\n");
|
||||
return err;
|
||||
err = clk_prepare_enable(drvdata->clk);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "clk enable failed\n");
|
||||
return err;
|
||||
}
|
||||
clk_rate = clk_get_rate(drvdata->clk);
|
||||
if (!clk_rate) {
|
||||
err = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
drvdata->clk_rate = clk_rate;
|
||||
}
|
||||
|
||||
clk_rate = clk_get_rate(drvdata->clk);
|
||||
if (!clk_rate) {
|
||||
err = -EINVAL;
|
||||
goto err0;
|
||||
}
|
||||
drvdata->clk_rate = clk_rate;
|
||||
max_hw_heartbeat_s = U32_MAX / clk_rate;
|
||||
|
||||
ls2x_wdt = &drvdata->wdt;
|
||||
ls2x_wdt->info = &ls2x_wdt_info;
|
||||
ls2x_wdt->ops = &ls2x_wdt_ops;
|
||||
ls2x_wdt->timeout = DEFAULT_HEARTBEAT;
|
||||
ls2x_wdt->timeout = DEFAULT_HEARTBEAT > max_hw_heartbeat_s ? max_hw_heartbeat_s : DEFAULT_HEARTBEAT;
|
||||
ls2x_wdt->min_timeout = 1;
|
||||
ls2x_wdt->max_hw_heartbeat_ms = U32_MAX / clk_rate * 1000;
|
||||
ls2x_wdt->max_hw_heartbeat_ms = max_hw_heartbeat_s * 1000;
|
||||
ls2x_wdt->parent = &pdev->dev;
|
||||
|
||||
pr_info("wdt timeout:%ds\n", ls2x_wdt->timeout);
|
||||
watchdog_init_timeout(ls2x_wdt, heartbeat, &pdev->dev);
|
||||
watchdog_set_nowayout(ls2x_wdt, nowayout);
|
||||
watchdog_set_drvdata(ls2x_wdt, drvdata);
|
||||
|
||||
Reference in New Issue
Block a user