Commit a8157775 authored by Florian Fainelli's avatar Florian Fainelli Committed by Herbert Xu

hwrng: bcm2835 - Move enabling to hwrng::init

We should be moving the enabling of the HWRNG into a hwrng::init
callback since we can be disabled and enabled every time a different
hwrng is selected in the system.
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent b788479f
...@@ -72,6 +72,17 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, ...@@ -72,6 +72,17 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
return num_words * sizeof(u32); return num_words * sizeof(u32);
} }
static int bcm2835_rng_init(struct hwrng *rng)
{
struct bcm2835_rng_priv *priv = to_rng_priv(rng);
/* set warm-up count & enable */
__raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
__raw_writel(RNG_RBGEN, priv->base + RNG_CTRL);
return 0;
}
static const struct of_device_id bcm2835_rng_of_match[] = { static const struct of_device_id bcm2835_rng_of_match[] = {
{ .compatible = "brcm,bcm2835-rng"}, { .compatible = "brcm,bcm2835-rng"},
{ .compatible = "brcm,bcm-nsp-rng", .data = nsp_rng_init}, { .compatible = "brcm,bcm-nsp-rng", .data = nsp_rng_init},
...@@ -105,6 +116,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev) ...@@ -105,6 +116,7 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
} }
priv->rng.name = "bcm2835-rng"; priv->rng.name = "bcm2835-rng";
priv->rng.init = bcm2835_rng_init;
priv->rng.read = bcm2835_rng_read; priv->rng.read = bcm2835_rng_read;
rng_id = of_match_node(bcm2835_rng_of_match, np); rng_id = of_match_node(bcm2835_rng_of_match, np);
...@@ -116,10 +128,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev) ...@@ -116,10 +128,6 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
if (rng_setup) if (rng_setup)
rng_setup(priv->base); rng_setup(priv->base);
/* set warm-up count & enable */
__raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
__raw_writel(RNG_RBGEN, priv->base + RNG_CTRL);
/* register driver */ /* register driver */
err = hwrng_register(&priv->rng); err = hwrng_register(&priv->rng);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment