From: Florian Fainelli <f.fainelli@gmail.com>
To: Stefan Wahren <stefan.wahren@i2se.com>
Cc: Krzysztof Kozlowski <krzk@kernel.org>,
Ray Jui <rjui@broadcom.com>, Eric Anholt <eric@anholt.net>,
Rob Herring <robh+dt@kernel.org>,
Steffen Trumtrar <s.trumtrar@pengutronix.de>,
Harald Freudenberger <freude@linux.vnet.ibm.com>,
Russell King <rmk+kernel@armlinux.org.uk>,
"moderated list:BROADCOM BCM2835 ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>,
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>,
Scott Branden <sbranden@broadcom.com>,
"open list:HARDWARE RANDOM NUMBER GENERATOR CORE"
<linux-crypto@vger.kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
Martin Kaiser <martin@kaiser.cx>, Matt Mackall <mpm@selenic.com>,
"maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE..."
<bcm-kernel-feedback-list@broadcom.com>,
Mark Rutland <mark.rutland@arm.com>,
"moderated list:BROADCOM BCM2835 ARM ARCHITECTURE"
<linux-rpi-kernel@lists.infradead.org>,
linux-kernel@vger.kernel.org, Sean Wang <sean.wang@mediatek.com>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@vger.kernel.org>
Subject: Re: [PATCH 07/12] hwrng: bcm2835-rng: Manage an optional clock
Date: Sat, 4 Nov 2017 10:59:32 -0700 [thread overview]
Message-ID: <e12063f9-86e4-e9ce-2a7f-f85fe2ce352f@gmail.com> (raw)
In-Reply-To: <944505791.223880.1509803454887@email.1und1.de>
Hi Stefan,
On 11/04/2017 06:50 AM, Stefan Wahren wrote:
> Hi Florian,
>
>> Florian Fainelli <f.fainelli@gmail.com> hat am 2. November 2017 um 02:04 geschrieben:
>>
>>
>> One of the last steps before bcm63xx-rng can be eliminated is to manage
>> a clock during hwrng::init and hwrng::cleanup, so fetch it in the probe
>> function, and manage it during these two steps when valid.
>>
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>> drivers/char/hw_random/bcm2835-rng.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>
>> diff --git a/drivers/char/hw_random/bcm2835-rng.c b/drivers/char/hw_random/bcm2835-rng.c
>> index ed20e0b6b7ae..35928efb52e7 100644
>> --- a/drivers/char/hw_random/bcm2835-rng.c
>> +++ b/drivers/char/hw_random/bcm2835-rng.c
>> @@ -15,6 +15,7 @@
>> #include <linux/of_platform.h>
>> #include <linux/platform_device.h>
>> #include <linux/printk.h>
>> +#include <linux/clk.h>
>>
>> #define RNG_CTRL 0x0
>> #define RNG_STATUS 0x4
>> @@ -33,6 +34,7 @@ struct bcm2835_rng_priv {
>> struct hwrng rng;
>> void __iomem *base;
>> bool mask_interrupts;
>> + struct clk *clk;
>> };
>>
>> static inline struct bcm2835_rng_priv *to_rng_priv(struct hwrng *rng)
>> @@ -67,6 +69,11 @@ static int bcm2835_rng_init(struct hwrng *rng)
>> {
>> struct bcm2835_rng_priv *priv = to_rng_priv(rng);
>> u32 val;
>> + int ret;
>> +
>> + ret = clk_prepare_enable(priv->clk);
>> + if (ret)
>> + return ret;
>>
>> if (priv->mask_interrupts) {
>> /* mask the interrupt */
>> @@ -88,6 +95,8 @@ static void bcm2835_rng_cleanup(struct hwrng *rng)
>>
>> /* disable rng hardware */
>> __raw_writel(0, priv->base + RNG_CTRL);
>> +
>> + clk_disable_unprepare(priv->clk);
>> }
>>
>> struct bcm2835_rng_of_data {
>> @@ -130,6 +139,11 @@ static int bcm2835_rng_probe(struct platform_device *pdev)
>> return PTR_ERR(priv->base);
>> }
>>
>> + /* Clock is optional on most platforms */
>> + priv->clk = devm_clk_get(dev, NULL);
>> + if (IS_ERR(priv->clk))
>> + priv->clk = NULL;
>
> at least in case of EPROBE_DEFERED this isn't the expected behavior. Maybe we should better trigger on non-existing clock?
Good point, so more like:
if (IS_ERR(priv->clk) && PTR_ERR(priv->clk) == -ENODEV)?
--
Florian
next prev parent reply other threads:[~2017-11-04 17:59 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 01/12] hwrng: bcm2835-rng: Obtain base register via resource 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 06/12] hwrng: bcm2835-rng: Rework interrupt masking 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
2017-11-04 17:59 ` Florian Fainelli [this message]
2017-11-04 18:22 ` Stefan Wahren
2017-11-04 19:37 ` Andrew Lunn
2017-11-04 20:08 ` Russell King - ARM Linux
2017-11-04 20:17 ` Andrew Lunn
2017-11-02 1:04 ` [PATCH 08/12] hwrng: bcm2835-rng: Abstract I/O accessors Florian Fainelli
2017-11-03 20:19 ` Eric Anholt
2017-11-03 22:04 ` Florian Fainelli
2017-11-02 1:04 ` [PATCH 09/12] hwrng: bcm2835-rng: Add Broadcom MIPS " 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
2017-11-03 20:18 ` Eric Anholt
2017-11-03 21:58 ` 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
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=e12063f9-86e4-e9ce-2a7f-f85fe2ce352f@gmail.com \
--to=f.fainelli@gmail.com \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=devicetree@vger.kernel.org \
--cc=eric@anholt.net \
--cc=freude@linux.vnet.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.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