Skip to content

Commit 8e03dd6

Browse files
ffainelliherbertx
authored andcommitted
hwrng: iproc-rng200 - Implement suspend and resume calls
Chips such as BCM7278 support system wide suspend/resume which will cause the HWRNG block to lose its state and reset to its power on reset register values. We need to cleanup and re-initialize the HWRNG for it to be functional coming out of a system suspend cycle. Fixes: c3577f6 ("hwrng: iproc-rng200 - Add support for BCM7278") Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent d88bdbd commit 8e03dd6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/char/hw_random/iproc-rng200.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ static int iproc_rng200_probe(struct platform_device *pdev)
181181
return PTR_ERR(priv->base);
182182
}
183183

184+
dev_set_drvdata(dev, priv);
185+
184186
priv->rng.name = "iproc-rng200";
185187
priv->rng.read = iproc_rng200_read;
186188
priv->rng.init = iproc_rng200_init;
@@ -198,6 +200,28 @@ static int iproc_rng200_probe(struct platform_device *pdev)
198200
return 0;
199201
}
200202

203+
static int __maybe_unused iproc_rng200_suspend(struct device *dev)
204+
{
205+
struct iproc_rng200_dev *priv = dev_get_drvdata(dev);
206+
207+
iproc_rng200_cleanup(&priv->rng);
208+
209+
return 0;
210+
}
211+
212+
static int __maybe_unused iproc_rng200_resume(struct device *dev)
213+
{
214+
struct iproc_rng200_dev *priv = dev_get_drvdata(dev);
215+
216+
iproc_rng200_init(&priv->rng);
217+
218+
return 0;
219+
}
220+
221+
static const struct dev_pm_ops iproc_rng200_pm_ops = {
222+
SET_SYSTEM_SLEEP_PM_OPS(iproc_rng200_suspend, iproc_rng200_resume)
223+
};
224+
201225
static const struct of_device_id iproc_rng200_of_match[] = {
202226
{ .compatible = "brcm,bcm2711-rng200", },
203227
{ .compatible = "brcm,bcm7211-rng200", },
@@ -211,6 +235,7 @@ static struct platform_driver iproc_rng200_driver = {
211235
.driver = {
212236
.name = "iproc-rng200",
213237
.of_match_table = iproc_rng200_of_match,
238+
.pm = &iproc_rng200_pm_ops,
214239
},
215240
.probe = iproc_rng200_probe,
216241
};

0 commit comments

Comments
 (0)