Lines Matching +full:timeout +full:- +full:enable
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright (C) 2014 STMicroelectronics -- All Rights Reserved
22 #include <dt-bindings/mfd/st-lpc.h>
57 .compatible = "st,stih407-lpc",
64 static void st_wdog_setup(struct st_wdog *st_wdog, bool enable) in st_wdog_setup() argument
66 /* Type of watchdog reset - 0: Cold 1: Warm */ in st_wdog_setup()
67 if (st_wdog->syscfg->reset_type_reg) in st_wdog_setup()
68 regmap_update_bits(st_wdog->regmap, in st_wdog_setup()
69 st_wdog->syscfg->reset_type_reg, in st_wdog_setup()
70 st_wdog->syscfg->reset_type_mask, in st_wdog_setup()
71 st_wdog->warm_reset); in st_wdog_setup()
74 regmap_update_bits(st_wdog->regmap, in st_wdog_setup()
75 st_wdog->syscfg->enable_reg, in st_wdog_setup()
76 st_wdog->syscfg->enable_mask, in st_wdog_setup()
77 enable ? 0 : st_wdog->syscfg->enable_mask); in st_wdog_setup()
80 static void st_wdog_load_timer(struct st_wdog *st_wdog, unsigned int timeout) in st_wdog_load_timer() argument
82 unsigned long clkrate = st_wdog->clkrate; in st_wdog_load_timer()
84 writel_relaxed(timeout * clkrate, st_wdog->base + LPC_LPA_LSB_OFF); in st_wdog_load_timer()
85 writel_relaxed(1, st_wdog->base + LPC_LPA_START_OFF); in st_wdog_load_timer()
92 writel_relaxed(1, st_wdog->base + LPC_WDT_OFF); in st_wdog_start()
101 writel_relaxed(0, st_wdog->base + LPC_WDT_OFF); in st_wdog_stop()
107 unsigned int timeout) in st_wdog_set_timeout() argument
111 wdd->timeout = timeout; in st_wdog_set_timeout()
112 st_wdog_load_timer(st_wdog, timeout); in st_wdog_set_timeout()
121 st_wdog_load_timer(st_wdog, wdd->timeout); in st_wdog_keepalive()
151 struct device *dev = &pdev->dev; in st_wdog_probe()
152 struct device_node *np = dev->of_node; in st_wdog_probe()
160 ret = of_property_read_u32(np, "st,lpc-mode", &mode); in st_wdog_probe()
163 return -EINVAL; in st_wdog_probe()
168 return -ENODEV; in st_wdog_probe()
172 return -ENOMEM; in st_wdog_probe()
174 st_wdog->syscfg = (struct st_wdog_syscfg *)device_get_match_data(dev); in st_wdog_probe()
192 st_wdog->dev = dev; in st_wdog_probe()
193 st_wdog->base = base; in st_wdog_probe()
194 st_wdog->clk = clk; in st_wdog_probe()
195 st_wdog->regmap = regmap; in st_wdog_probe()
196 st_wdog->warm_reset = of_property_read_bool(np, "st,warm_reset"); in st_wdog_probe()
197 st_wdog->clkrate = clk_get_rate(st_wdog->clk); in st_wdog_probe()
199 if (!st_wdog->clkrate) { in st_wdog_probe()
201 return -EINVAL; in st_wdog_probe()
203 st_wdog_dev.max_timeout = 0xFFFFFFFF / st_wdog->clkrate; in st_wdog_probe()
208 dev_err(dev, "Unable to enable clock\n"); in st_wdog_probe()
218 /* Init Watchdog timeout with value in DT */ in st_wdog_probe()
230 st_wdog->warm_reset ? "warm" : "cold"); in st_wdog_probe()
251 clk_disable(st_wdog->clk); in st_wdog_suspend()
261 ret = clk_enable(st_wdog->clk); in st_wdog_resume()
263 dev_err(dev, "Unable to re-enable clock\n"); in st_wdog_resume()
265 clk_unprepare(st_wdog->clk); in st_wdog_resume()
272 st_wdog_load_timer(st_wdog, st_wdog_dev.timeout); in st_wdog_resume()
284 .name = "st-lpc-wdt",