|
12 | 12 | #include <linux/module.h>
|
13 | 13 | #include <linux/of.h>
|
14 | 14 | #include <linux/platform_device.h>
|
| 15 | +#include <linux/pm_domain.h> |
15 | 16 | #include <linux/pm_runtime.h>
|
16 | 17 | #include <linux/reset.h>
|
17 | 18 | #include <linux/units.h>
|
@@ -166,8 +167,22 @@ static int rzg2l_wdt_restart(struct watchdog_device *wdev,
|
166 | 167 | struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev);
|
167 | 168 | int ret;
|
168 | 169 |
|
169 |
| - clk_prepare_enable(priv->pclk); |
170 |
| - clk_prepare_enable(priv->osc_clk); |
| 170 | + /* |
| 171 | + * In case of RZ/G3S the watchdog device may be part of an IRQ safe power |
| 172 | + * domain that is currently powered off. In this case we need to power |
| 173 | + * it on before accessing registers. Along with this the clocks will be |
| 174 | + * enabled. We don't undo the pm_runtime_resume_and_get() as the device |
| 175 | + * need to be on for the reboot to happen. |
| 176 | + * |
| 177 | + * For the rest of SoCs not registering a watchdog IRQ safe power |
| 178 | + * domain it is safe to call pm_runtime_resume_and_get() as the |
| 179 | + * irq_safe_dev_in_sleep_domain() call in genpd_runtime_resume() |
| 180 | + * returns non zero value and the genpd_lock() is avoided, thus, there |
| 181 | + * will be no invalid wait context reported by lockdep. |
| 182 | + */ |
| 183 | + ret = pm_runtime_resume_and_get(wdev->parent); |
| 184 | + if (ret) |
| 185 | + return ret; |
171 | 186 |
|
172 | 187 | if (priv->devtype == WDT_RZG2L) {
|
173 | 188 | ret = reset_control_deassert(priv->rstc);
|
@@ -275,6 +290,7 @@ static int rzg2l_wdt_probe(struct platform_device *pdev)
|
275 | 290 |
|
276 | 291 | priv->devtype = (uintptr_t)of_device_get_match_data(dev);
|
277 | 292 |
|
| 293 | + pm_runtime_irq_safe(&pdev->dev); |
278 | 294 | pm_runtime_enable(&pdev->dev);
|
279 | 295 |
|
280 | 296 | priv->wdev.info = &rzg2l_wdt_ident;
|
|
0 commit comments