Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: c3577f6100ca ("hwrng: iproc-rng200 - Add support for BCM7278")
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Florian Fainelli and committed by
Herbert Xu
8e03dd62 d88bdbd9

+25
+25
drivers/char/hw_random/iproc-rng200.c
··· 181 181 return PTR_ERR(priv->base); 182 182 } 183 183 184 + dev_set_drvdata(dev, priv); 185 + 184 186 priv->rng.name = "iproc-rng200"; 185 187 priv->rng.read = iproc_rng200_read; 186 188 priv->rng.init = iproc_rng200_init; ··· 200 198 return 0; 201 199 } 202 200 201 + static int __maybe_unused iproc_rng200_suspend(struct device *dev) 202 + { 203 + struct iproc_rng200_dev *priv = dev_get_drvdata(dev); 204 + 205 + iproc_rng200_cleanup(&priv->rng); 206 + 207 + return 0; 208 + } 209 + 210 + static int __maybe_unused iproc_rng200_resume(struct device *dev) 211 + { 212 + struct iproc_rng200_dev *priv = dev_get_drvdata(dev); 213 + 214 + iproc_rng200_init(&priv->rng); 215 + 216 + return 0; 217 + } 218 + 219 + static const struct dev_pm_ops iproc_rng200_pm_ops = { 220 + SET_SYSTEM_SLEEP_PM_OPS(iproc_rng200_suspend, iproc_rng200_resume) 221 + }; 222 + 203 223 static const struct of_device_id iproc_rng200_of_match[] = { 204 224 { .compatible = "brcm,bcm2711-rng200", }, 205 225 { .compatible = "brcm,bcm7211-rng200", }, ··· 235 211 .driver = { 236 212 .name = "iproc-rng200", 237 213 .of_match_table = iproc_rng200_of_match, 214 + .pm = &iproc_rng200_pm_ops, 238 215 }, 239 216 .probe = iproc_rng200_probe, 240 217 };