#include <linux/hw_random.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/printk.h>
#define RNG_INT_MASK 0x10
#define RNG_WARMUP_COUNT 0x40000
struct bcm2835_rng_priv {
static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
return container_of(rng, struct bcm2835_rng_priv, rng);
static inline u32 rng_readl(struct bcm2835_rng_priv *priv, u32 offset)
if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
return __raw_readl(priv->base + offset);
return readl(priv->base + offset);
static inline void rng_writel(struct bcm2835_rng_priv *priv, u32 val,
if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
__raw_writel(val, priv->base + offset);
writel(val, priv->base + offset);
static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,