Lines Matching +full:bcm2835 +full:- +full:rng
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2010-2012 Broadcom. All rights reserved.
22 /* enable rng */
31 struct hwrng rng; member
38 static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng) in to_rng_priv() argument
40 return container_of(rng, struct bcm2835_rng_priv, rng); in to_rng_priv()
46 * peripheral registers for CPU-native byte order. in rng_readl()
49 return __raw_readl(priv->base + offset); in rng_readl()
51 return readl(priv->base + offset); in rng_readl()
58 __raw_writel(val, priv->base + offset); in rng_writel()
60 writel(val, priv->base + offset); in rng_writel()
63 static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max, in bcm2835_rng_read() argument
66 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_read()
73 hwrng_yield(rng); in bcm2835_rng_read()
86 static int bcm2835_rng_init(struct hwrng *rng) in bcm2835_rng_init() argument
88 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_init()
92 ret = clk_prepare_enable(priv->clk); in bcm2835_rng_init()
96 ret = reset_control_reset(priv->reset); in bcm2835_rng_init()
98 clk_disable_unprepare(priv->clk); in bcm2835_rng_init()
102 if (priv->mask_interrupts) { in bcm2835_rng_init()
109 /* set warm-up count & enable */ in bcm2835_rng_init()
116 static void bcm2835_rng_cleanup(struct hwrng *rng) in bcm2835_rng_cleanup() argument
118 struct bcm2835_rng_priv *priv = to_rng_priv(rng); in bcm2835_rng_cleanup()
120 /* disable rng hardware */ in bcm2835_rng_cleanup()
123 clk_disable_unprepare(priv->clk); in bcm2835_rng_cleanup()
135 { .compatible = "brcm,bcm2835-rng"},
136 { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data },
137 { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data },
138 { .compatible = "brcm,bcm6368-rng"},
145 struct device *dev = &pdev->dev; in bcm2835_rng_probe()
152 return -ENOMEM; in bcm2835_rng_probe()
155 priv->base = devm_platform_ioremap_resource(pdev, 0); in bcm2835_rng_probe()
156 if (IS_ERR(priv->base)) in bcm2835_rng_probe()
157 return PTR_ERR(priv->base); in bcm2835_rng_probe()
160 priv->clk = devm_clk_get_optional(dev, NULL); in bcm2835_rng_probe()
161 if (IS_ERR(priv->clk)) in bcm2835_rng_probe()
162 return PTR_ERR(priv->clk); in bcm2835_rng_probe()
164 priv->reset = devm_reset_control_get_optional_exclusive(dev, NULL); in bcm2835_rng_probe()
165 if (IS_ERR(priv->reset)) in bcm2835_rng_probe()
166 return PTR_ERR(priv->reset); in bcm2835_rng_probe()
168 priv->rng.name = pdev->name; in bcm2835_rng_probe()
169 priv->rng.init = bcm2835_rng_init; in bcm2835_rng_probe()
170 priv->rng.read = bcm2835_rng_read; in bcm2835_rng_probe()
171 priv->rng.cleanup = bcm2835_rng_cleanup; in bcm2835_rng_probe()
174 rng_id = of_match_node(bcm2835_rng_of_match, dev->of_node); in bcm2835_rng_probe()
176 return -EINVAL; in bcm2835_rng_probe()
178 /* Check for rng init function, execute it */ in bcm2835_rng_probe()
179 of_data = rng_id->data; in bcm2835_rng_probe()
181 priv->mask_interrupts = of_data->mask_interrupts; in bcm2835_rng_probe()
185 err = devm_hwrng_register(dev, &priv->rng); in bcm2835_rng_probe()
197 { .name = "bcm2835-rng" },
198 { .name = "bcm63xx-rng" },
205 .name = "bcm2835-rng",
214 MODULE_DESCRIPTION("BCM2835 Random Number Generator (RNG) driver");