linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Matt Mackall <mpm@selenic.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM
	BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...),
	Eric Anholt <eric@anholt.net>,
	Stefan Wahren <stefan.wahren@i2se.com>,
	PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Harald Freudenberger <freude@linux.vnet.ibm.com>,
	Sean Wang <sean.wang@mediatek.com>,
	Martin Kaiser <martin@kaiser.cx>,
	Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	linux-crypto@vger.k
Subject: [PATCH 09/12] hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors
Date: Wed,  1 Nov 2017 18:04:05 -0700	[thread overview]
Message-ID: <20171102010408.27736-10-f.fainelli@gmail.com> (raw)
In-Reply-To: <20171102010408.27736-1-f.fainelli@gmail.com>

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>
---
 drivers/char/hw_random/bcm2835-rng.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 500275d55044..650e0033c273 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -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)
 {
-	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,
 			      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,
-- 
2.9.3

  parent reply	other threads:[~2017-11-02  1:04 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  1:03 [PATCH 00/12] bcm63xx-rng conversion to bcm2835-rng Florian Fainelli
2017-11-02  1:03 ` [PATCH 02/12] hwrng: bcm2835-rng: Define a driver private context Florian Fainelli
2017-11-02  1:03 ` [PATCH 03/12] hwrng: bcm2835-rng: Move enabling to hwrng::init Florian Fainelli
2017-11-02  1:04 ` [PATCH 04/12] hwrng: bcm2835-rng: Implementation cleanup callback Florian Fainelli
2017-11-02  1:04 ` [PATCH 05/12] hwrng: bcm2835-rng: Use device managed helpers Florian Fainelli
     [not found] ` <20171102010408.27736-1-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-02  1:03   ` [PATCH 01/12] hwrng: bcm2835-rng: Obtain base register via resource Florian Fainelli
2017-11-02  1:04   ` [PATCH 06/12] hwrng: bcm2835-rng: Rework interrupt masking Florian Fainelli
2017-11-02  1:04   ` [PATCH 08/12] hwrng: bcm2835-rng: Abstract I/O accessors Florian Fainelli
     [not found]     ` <20171102010408.27736-9-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-03 20:19       ` Eric Anholt
     [not found]         ` <874lqbru7i.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2017-11-03 22:04           ` Florian Fainelli
2017-11-02 19:00   ` [PATCH 00/12] bcm63xx-rng conversion to bcm2835-rng Stefan Wahren
2017-11-02  1:04 ` [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock Florian Fainelli
2017-11-04 13:50   ` Stefan Wahren
     [not found]     ` <944505791.223880.1509803454887-7tX72C7vayboQLBSYMtkGA@public.gmane.org>
2017-11-04 17:59       ` Florian Fainelli
2017-11-04 18:22         ` Stefan Wahren
     [not found]           ` <547786283.132202.1509819754396-7tX72C7vayboQLBSYMtkGA@public.gmane.org>
2017-11-04 19:37             ` Andrew Lunn
     [not found]               ` <20171104193731.GA751-g2DYL2Zd6BY@public.gmane.org>
2017-11-04 20:08                 ` Russell King - ARM Linux
2017-11-04 20:17                   ` Andrew Lunn
2017-11-02  1:04 ` Florian Fainelli [this message]
2017-11-02  1:04 ` [PATCH 10/12] dt-bindings: rng: Incorporate brcm,bcm6368.txt binding Florian Fainelli
2017-11-06 21:38   ` Rob Herring
2017-11-02  1:04 ` [PATCH 11/12] hwrng: bcm2835-rng: Enable BCM2835 RNG to work on BCM63xx platforms Florian Fainelli
2017-11-04 18:27   ` Stefan Wahren
2017-11-06 20:16     ` Florian Fainelli
2017-11-07  6:45       ` Stefan Wahren
2017-11-07 23:27         ` Stefan Wahren
2017-11-02  1:04 ` [PATCH 12/12] hwrng: bcm63xx-rng: Remove since bcm2835-rng takes over Florian Fainelli
     [not found]   ` <20171102010408.27736-13-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-11-03 20:18     ` Eric Anholt
     [not found]       ` <877ev7ru97.fsf-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>
2017-11-03 21:58         ` Florian Fainelli
2017-11-02 19:01 ` [PATCH 00/12] bcm63xx-rng conversion to bcm2835-rng Stefan Wahren
     [not found]   ` <1329593033.127526.1509649260041-7tX72C7vayboQLBSYMtkGA@public.gmane.org>
2017-11-02 19:06     ` Florian Fainelli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171102010408.27736-10-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=eric@anholt.net \
    --cc=freude@linux.vnet.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=krzk@kernel.org \
    --cc=linux-crypto@vger.k \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin@kaiser.cx \
    --cc=mpm@selenic.com \
    --cc=prasannatsmkumar@gmail.com \
    --cc=rjui@broadcom.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=robh+dt@kernel.org \
    --cc=s.trumtrar@pengutronix.de \
    --cc=sbranden@broadcom.com \
    --cc=sean.wang@mediatek.com \
    --cc=stefan.wahren@i2se.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).