Lines Matching +full:msc313e +full:- +full:wdt

1 // SPDX-License-Identifier: GPL-2.0
3 * MStar WDT driver
5 * Copyright (C) 2019 - 2021 Daniel Palmer
41 err = clk_prepare_enable(priv->clk); in msc313e_wdt_start()
45 timeout = wdev->timeout * clk_get_rate(priv->clk); in msc313e_wdt_start()
46 writew(timeout & 0xffff, priv->base + REG_WDT_MAX_PRD_L); in msc313e_wdt_start()
47 writew((timeout >> 16) & 0xffff, priv->base + REG_WDT_MAX_PRD_H); in msc313e_wdt_start()
48 writew(1, priv->base + REG_WDT_CLR); in msc313e_wdt_start()
56 writew(1, priv->base + REG_WDT_CLR); in msc313e_wdt_ping()
64 writew(0, priv->base + REG_WDT_MAX_PRD_L); in msc313e_wdt_stop()
65 writew(0, priv->base + REG_WDT_MAX_PRD_H); in msc313e_wdt_stop()
66 writew(0, priv->base + REG_WDT_CLR); in msc313e_wdt_stop()
67 clk_disable_unprepare(priv->clk); in msc313e_wdt_stop()
73 wdev->timeout = new_time; in msc313e_wdt_settimeout()
79 .identity = "MSC313e watchdog",
92 { .compatible = "mstar,msc313e-wdt", },
99 struct device *dev = &pdev->dev; in msc313e_wdt_probe()
102 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in msc313e_wdt_probe()
104 return -ENOMEM; in msc313e_wdt_probe()
106 priv->base = devm_platform_ioremap_resource(pdev, 0); in msc313e_wdt_probe()
107 if (IS_ERR(priv->base)) in msc313e_wdt_probe()
108 return PTR_ERR(priv->base); in msc313e_wdt_probe()
110 priv->clk = devm_clk_get(dev, NULL); in msc313e_wdt_probe()
111 if (IS_ERR(priv->clk)) { in msc313e_wdt_probe()
113 return PTR_ERR(priv->clk); in msc313e_wdt_probe()
116 priv->wdev.info = &msc313e_wdt_ident, in msc313e_wdt_probe()
117 priv->wdev.ops = &msc313e_wdt_ops, in msc313e_wdt_probe()
118 priv->wdev.parent = dev; in msc313e_wdt_probe()
119 priv->wdev.min_timeout = MSC313E_WDT_MIN_TIMEOUT; in msc313e_wdt_probe()
120 priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk); in msc313e_wdt_probe()
121 priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT; in msc313e_wdt_probe()
123 /* If the period is non-zero the WDT is running */ in msc313e_wdt_probe()
124 if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16)) in msc313e_wdt_probe()
125 set_bit(WDOG_HW_RUNNING, &priv->wdev.status); in msc313e_wdt_probe()
127 watchdog_set_drvdata(&priv->wdev, priv); in msc313e_wdt_probe()
129 watchdog_init_timeout(&priv->wdev, timeout, dev); in msc313e_wdt_probe()
130 watchdog_stop_on_reboot(&priv->wdev); in msc313e_wdt_probe()
131 watchdog_stop_on_unregister(&priv->wdev); in msc313e_wdt_probe()
133 return devm_watchdog_register_device(dev, &priv->wdev); in msc313e_wdt_probe()
140 if (watchdog_active(&priv->wdev)) in msc313e_wdt_suspend()
141 msc313e_wdt_stop(&priv->wdev); in msc313e_wdt_suspend()
150 if (watchdog_active(&priv->wdev)) in msc313e_wdt_resume()
151 msc313e_wdt_start(&priv->wdev); in msc313e_wdt_resume()
160 .name = "msc313e-wdt",
169 MODULE_DESCRIPTION("Watchdog driver for MStar MSC313e");