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 max_hw_heartbeat = wdt_dev->max_hw_heartbeat_ms / 1000;
|
||||||
unsigned int counts;
|
unsigned int counts;
|
||||||
|
|
||||||
|
pr_info("wdt==>max_hw_heartbeat:%d\n", max_hw_heartbeat);
|
||||||
wdt_dev->timeout = timeout;
|
wdt_dev->timeout = timeout;
|
||||||
|
|
||||||
counts = drvdata->clk_rate * min(timeout, max_hw_heartbeat);
|
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 ls2x_wdt_drvdata *drvdata;
|
||||||
struct watchdog_device *ls2x_wdt;
|
struct watchdog_device *ls2x_wdt;
|
||||||
unsigned long clk_rate;
|
u32 clk_rate;
|
||||||
|
u32 max_hw_heartbeat_s;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int err;
|
int err;
|
||||||
|
struct device_node *np = pdev->dev.of_node;
|
||||||
|
|
||||||
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
|
drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL);
|
||||||
if (!drvdata)
|
if (!drvdata)
|
||||||
@@ -101,6 +104,9 @@ static int ls2x_wdt_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(drvdata->base))
|
if (IS_ERR(drvdata->base))
|
||||||
return PTR_ERR(drvdata->base);
|
return PTR_ERR(drvdata->base);
|
||||||
|
|
||||||
|
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");
|
drvdata->clk = devm_clk_get(&pdev->dev, "wdt-clk");
|
||||||
if (IS_ERR(drvdata->clk))
|
if (IS_ERR(drvdata->clk))
|
||||||
return PTR_ERR(drvdata->clk);
|
return PTR_ERR(drvdata->clk);
|
||||||
@@ -110,22 +116,25 @@ static int ls2x_wdt_probe(struct platform_device *pdev)
|
|||||||
dev_err(&pdev->dev, "clk enable failed\n");
|
dev_err(&pdev->dev, "clk enable failed\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
clk_rate = clk_get_rate(drvdata->clk);
|
clk_rate = clk_get_rate(drvdata->clk);
|
||||||
if (!clk_rate) {
|
if (!clk_rate) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto err0;
|
goto err0;
|
||||||
}
|
}
|
||||||
drvdata->clk_rate = clk_rate;
|
drvdata->clk_rate = clk_rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
max_hw_heartbeat_s = U32_MAX / clk_rate;
|
||||||
|
|
||||||
ls2x_wdt = &drvdata->wdt;
|
ls2x_wdt = &drvdata->wdt;
|
||||||
ls2x_wdt->info = &ls2x_wdt_info;
|
ls2x_wdt->info = &ls2x_wdt_info;
|
||||||
ls2x_wdt->ops = &ls2x_wdt_ops;
|
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->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;
|
ls2x_wdt->parent = &pdev->dev;
|
||||||
|
|
||||||
|
pr_info("wdt timeout:%ds\n", ls2x_wdt->timeout);
|
||||||
watchdog_init_timeout(ls2x_wdt, heartbeat, &pdev->dev);
|
watchdog_init_timeout(ls2x_wdt, heartbeat, &pdev->dev);
|
||||||
watchdog_set_nowayout(ls2x_wdt, nowayout);
|
watchdog_set_nowayout(ls2x_wdt, nowayout);
|
||||||
watchdog_set_drvdata(ls2x_wdt, drvdata);
|
watchdog_set_drvdata(ls2x_wdt, drvdata);
|
||||||
|
|||||||
Reference in New Issue
Block a user