hwrng: bcm2835 - Add Broadcom MIPS I/O accessors
Broadcom MIPS HW is always strapped to match the system-wide endian such that all I/O access to this RNG block is done with the native CPU endian, account for that. Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
abd42026ea
commit
6f09359a68
1 changed files with 11 additions and 2 deletions
|
@ -44,13 +44,22 @@ static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
|
||||||
|
|
||||||
static inline u32 rng_readl(struct bcm2835_rng_priv *priv, u32 offset)
|
static inline u32 rng_readl(struct bcm2835_rng_priv *priv, u32 offset)
|
||||||
{
|
{
|
||||||
return readl(priv->base + offset);
|
/* MIPS chips strapped for BE will automagically configure the
|
||||||
|
* peripheral registers for CPU-native byte order.
|
||||||
|
*/
|
||||||
|
if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
|
||||||
|
return __raw_readl(priv->base + offset);
|
||||||
|
else
|
||||||
|
return readl(priv->base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void rng_writel(struct bcm2835_rng_priv *priv, u32 val,
|
static inline void rng_writel(struct bcm2835_rng_priv *priv, u32 val,
|
||||||
u32 offset)
|
u32 offset)
|
||||||
{
|
{
|
||||||
writel(val, priv->base + offset);
|
if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
|
||||||
|
__raw_writel(val, priv->base + offset);
|
||||||
|
else
|
||||||
|
writel(val, priv->base + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
|
static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
|
||||||
|
|
Loading…
Reference in a new issue