From: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Florian Fainelli
<f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Matt Mackall <mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org>,
Herbert Xu
<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
Ray Jui <rjui-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
Scott Branden <sbranden-dY08KVG/lbpWk0Htik3J/w@public.gmane.org>,
bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org
(maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...),
Eric Anholt <eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org>,
Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>,
PrasannaKumar Muralidharan
<prasannatsmkumar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Russell King <rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>,
Krzysztof Kozlowski
<krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Harald Freudenberger
<freude-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
Sean Wang <sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org>,
Martin Kaiser <martin-XxZfDwE/svGeZLLa646FqQ@public.gmane.org>,
Steffen Trumtrar
<s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>,
linux-crypto@vger.k
Subject: [PATCH 06/12] hwrng: bcm2835-rng: Rework interrupt masking
Date: Wed, 1 Nov 2017 18:04:02 -0700 [thread overview]
Message-ID: <20171102010408.27736-7-f.fainelli@gmail.com> (raw)
In-Reply-To: <20171102010408.27736-1-f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
The interrupt masking done for Northstart Plus and Northstar (BCM5301X)
is moved from being a function pointer mapped to of_device_id::data into
a proper part of the hwrng::init callback. While at it, we also make the
of_data be a proper structure indicating the platform specifics, since
the day we need to add a second type of platform information, we would
have to do that anyway.
Signed-off-by: Florian Fainelli <f.fainelli-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/char/hw_random/bcm2835-rng.c | 39 +++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 16 deletions(-)
diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
index 67b9bd3be28d..ed20e0b6b7ae 100644
--- a/drivers/char/hw_random/bcm2835-rng.c
+++ b/drivers/char/hw_random/bcm2835-rng.c
@@ -32,18 +32,9 @@
struct bcm2835_rng_priv {
struct hwrng rng;
void __iomem *base;
+ bool mask_interrupts;
};
-static void __init nsp_rng_init(void __iomem *base)
-{
- u32 val;
-
- /* mask the interrupt */
- val = readl(base + RNG_INT_MASK);
- val |= RNG_INT_OFF;
- writel(val, base + RNG_INT_MASK);
-}
-
static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
{
return container_of(rng, struct bcm2835_rng_priv, rng);
@@ -75,6 +66,14 @@ static int bcm2835_rng_read(struct hwrng *rng, void *buf, size_t max,
static int bcm2835_rng_init(struct hwrng *rng)
{
struct bcm2835_rng_priv *priv = to_rng_priv(rng);
+ u32 val;
+
+ if (priv->mask_interrupts) {
+ /* mask the interrupt */
+ val = readl(priv->base + RNG_INT_MASK);
+ val |= RNG_INT_OFF;
+ writel(val, priv->base + RNG_INT_MASK);
+ }
/* set warm-up count & enable */
__raw_writel(RNG_WARMUP_COUNT, priv->base + RNG_STATUS);
@@ -91,18 +90,26 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)
__raw_writel(0, priv->base + RNG_CTRL);
}
+struct bcm2835_rng_of_data {
+ bool mask_interrupts;
+};
+
+static const struct bcm2835_rng_of_data nsp_rng_of_data = {
+ .mask_interrupts = true,
+};
+
static const struct of_device_id bcm2835_rng_of_match[] = {
{ .compatible = "brcm,bcm2835-rng"},
- { .compatible = "brcm,bcm-nsp-rng", .data = nsp_rng_init},
- { .compatible = "brcm,bcm5301x-rng", .data = nsp_rng_init},
+ { .compatible = "brcm,bcm-nsp-rng", .data = &nsp_rng_of_data },
+ { .compatible = "brcm,bcm5301x-rng", .data = &nsp_rng_of_data },
{},
};
static int bcm2835_rng_probe(struct platform_device *pdev)
{
+ const struct bcm2835_rng_of_data *of_data;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node;
- void (*rng_setup)(void __iomem *base);
const struct of_device_id *rng_id;
struct bcm2835_rng_priv *priv;
struct resource *r;
@@ -133,9 +140,9 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
return -EINVAL;
/* Check for rng init function, execute it */
- rng_setup = rng_id->data;
- if (rng_setup)
- rng_setup(priv->base);
+ of_data = rng_id->data;
+ if (of_data)
+ priv->mask_interrupts = of_data->mask_interrupts;
/* register driver */
err = devm_hwrng_register(dev, &priv->rng);
--
2.9.3
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev 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
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 ` [PATCH 09/12] hwrng: bcm2835-rng: Add Broadcom MIPS I/O accessors Florian Fainelli
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
[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 ` Florian Fainelli [this message]
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 19:01 ` 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-7-f.fainelli@gmail.com \
--to=f.fainelli-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=bcm-kernel-feedback-list-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=eric-WhKQ6XTQaPysTnJN9+BGXg@public.gmane.org \
--cc=freude-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
--cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org \
--cc=krzk-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=linux-crypto@vger.k \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=martin-XxZfDwE/svGeZLLa646FqQ@public.gmane.org \
--cc=mpm-VDJrAJ4Gl5ZBDgjK7y7TUQ@public.gmane.org \
--cc=prasannatsmkumar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=rjui-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=rmk+kernel-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=s.trumtrar-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=sbranden-dY08KVG/lbpWk0Htik3J/w@public.gmane.org \
--cc=sean.wang-NuS5LvNUpcJWk0Htik3J/w@public.gmane.org \
--cc=stefan.wahren-eS4NqCHxEME@public.gmane.org \
/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).