Lines Matching +full:autosuspend +full:- +full:delay

1 // SPDX-License-Identifier: GPL-2.0-or-later
10 #include <linux/delay.h>
21 /* Runtime PM autosuspend timeout: */
47 err = clk_prepare_enable(priv->clk); in mtk_rng_init()
51 val = readl(priv->base + RNG_CTRL); in mtk_rng_init()
53 writel(val, priv->base + RNG_CTRL); in mtk_rng_init()
63 val = readl(priv->base + RNG_CTRL); in mtk_rng_cleanup()
65 writel(val, priv->base + RNG_CTRL); in mtk_rng_cleanup()
67 clk_disable_unprepare(priv->clk); in mtk_rng_cleanup()
75 ready = readl(priv->base + RNG_CTRL) & RNG_READY; in mtk_rng_wait_ready()
77 readl_poll_timeout_atomic(priv->base + RNG_CTRL, ready, in mtk_rng_wait_ready()
88 pm_runtime_get_sync((struct device *)priv->rng.priv); in mtk_rng_read()
94 *(u32 *)buf = readl(priv->base + RNG_DATA); in mtk_rng_read()
97 max -= sizeof(u32); in mtk_rng_read()
100 pm_runtime_mark_last_busy((struct device *)priv->rng.priv); in mtk_rng_read()
101 pm_runtime_put_sync_autosuspend((struct device *)priv->rng.priv); in mtk_rng_read()
103 return retval || !wait ? retval : -EIO; in mtk_rng_read()
111 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mtk_rng_probe()
113 return -ENOMEM; in mtk_rng_probe()
115 priv->rng.name = pdev->name; in mtk_rng_probe()
117 priv->rng.init = mtk_rng_init; in mtk_rng_probe()
118 priv->rng.cleanup = mtk_rng_cleanup; in mtk_rng_probe()
120 priv->rng.read = mtk_rng_read; in mtk_rng_probe()
121 priv->rng.priv = (unsigned long)&pdev->dev; in mtk_rng_probe()
122 priv->rng.quality = 900; in mtk_rng_probe()
124 priv->clk = devm_clk_get(&pdev->dev, "rng"); in mtk_rng_probe()
125 if (IS_ERR(priv->clk)) { in mtk_rng_probe()
126 ret = PTR_ERR(priv->clk); in mtk_rng_probe()
127 dev_err(&pdev->dev, "no clock for device: %d\n", ret); in mtk_rng_probe()
131 priv->base = devm_platform_ioremap_resource(pdev, 0); in mtk_rng_probe()
132 if (IS_ERR(priv->base)) in mtk_rng_probe()
133 return PTR_ERR(priv->base); in mtk_rng_probe()
135 ret = devm_hwrng_register(&pdev->dev, &priv->rng); in mtk_rng_probe()
137 dev_err(&pdev->dev, "failed to register rng device: %d\n", in mtk_rng_probe()
142 dev_set_drvdata(&pdev->dev, priv); in mtk_rng_probe()
143 pm_runtime_set_autosuspend_delay(&pdev->dev, RNG_AUTOSUSPEND_TIMEOUT); in mtk_rng_probe()
144 pm_runtime_use_autosuspend(&pdev->dev); in mtk_rng_probe()
145 pm_runtime_enable(&pdev->dev); in mtk_rng_probe()
147 dev_info(&pdev->dev, "registered RNG driver\n"); in mtk_rng_probe()
157 mtk_rng_cleanup(&priv->rng); in mtk_rng_runtime_suspend()
166 return mtk_rng_init(&priv->rng); in mtk_rng_runtime_resume()
182 { .compatible = "mediatek,mt7986-rng" },
183 { .compatible = "mediatek,mt7623-rng" },