hwrng: bcm2835: add reset support
Subsystems (5)
v5 cover hwrng: bcm2835: add reset support
v5: remove reset_control_rearm() and apply on latest herbert/cryptodev-2.6.git.
v4: fix documentation, add reset_control_rearm().
v3: make resets required if brcm,bcm6368-rng.
v2: document reset support.
Álvaro Fernández Rojas (2):
dt-bindings: rng: bcm2835: document reset support
hwrng: bcm2835: add reset support
.../devicetree/bindings/rng/brcm,bcm2835.yaml | 17 +++++++++++++++++ drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++ 2 files changed, 27 insertions(+)
Signature · 1 line
2.20.1
PATCH v5 1/2 dt-bindings: rng: bcm2835: document reset support
Some devices may need to perform a reset before using the RNG, such as the BCM6368.
---
v5: no changes.
v4: pass dt_binding_check.
v3: make resets required if brcm,bcm6368-rng.
v2: document reset support.
.../devicetree/bindings/rng/brcm,bcm2835.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +17 -0
@@ -37,6 +37,21 @@ required: additionalProperties: false +if: + properties: + compatible: + enum: + - brcm,bcm6368-rng +then: + properties: + resets: + maxItems: 1 + required: + - resets +else: + properties: + resets: false + examples: - | rng@7e104000 {
@@ -58,4 +73,6 @@ examples: clocks = <&periph_clk 18>; clock-names = "ipsec"; + + resets = <&periph_rst 4>; };
Signature · 1 line
2.20.1
Re: [PATCH v5 1/2] dt-bindings: rng: bcm2835: document reset support
Sorry Alvaro I missed you sent a v5 already. See my comments in v3.
Regards,
Nicolas
Quoted 49 lines · Álvaro Fernández Rojas
Some devices may need to perform a reset before using the RNG, such as the BCM6368.
Signed-off-by Álvaro Fernández Rojas <[email protected]>---
v5: no changes.
v4: passdt_binding_check.
v3: make resets required if brcm,bcm6368-rng.
v2: document reset support..../devicetree/bindings/rng/brcm,bcm2835.yaml | 17 +++++++++++++++++
1 file changed, 17 insertions(+)Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +0
-0@@ -37,6 +37,21 @@ required:additionalProperties: false
Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +15
-0+if: + properties: + compatible: + enum: + - brcm,bcm6368-rng +then: + properties: + resets: + maxItems: 1 + required: + - resets +else: + properties: + resets: false +examples:
- |
rng@7e104000 {Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +0
-0@@ -58,4 +73,6 @@ examples:clocks = <
&periph_clk18>;
clock-names = "ipsec";Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml +2
-0+ + resets = <&periph_rst 4>;};
Rob Herring
maintainerRe: [PATCH v5 1/2] dt-bindings: rng: bcm2835: document reset support
In reply to Álvaro Fernández RojasQuoted 4 lines · Álvaro Fernández Rojas
Some devices may need to perform a reset before using the RNG, such as the BCM6368.
Signed-off-by Álvaro Fernández Rojas <[email protected]>
Quoted 9 lines
---
v5: no changes.
v4: passdt_binding_check.
v3: make resets required if brcm,bcm6368-rng.
v2: document reset support..../devicetree/bindings/rng/brcm,bcm2835.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rng/brcm,bcm2835.example.dt.yaml: rng@10004180: 'resets' does not match any of the regexes: 'pinctrl-[0-9]+'
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/rng/brcm,bcm2835.yaml
See https://patchwork.ozlabs.org/patch/1447144
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v5 2/2 hwrng: bcm2835: add reset support
In reply to Álvaro Fernández RojasBCM6368 devices need to reset the in order to generate true random numbers. This is what BCM6368 produces without a reset:
root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000 rngtest 6.10 Copyright (c) 2004 by Henrique de Moraes Holschuh This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 0
rngtest: FIPS 140-2 failures: 1000
rngtest: FIPS 140-2(2001-10-10) Monobit: 2
rngtest: FIPS 140-2(2001-10-10) Poker: 1000
rngtest: FIPS 140-2(2001-10-10) Runs: 1000
rngtest: FIPS 140-2(2001-10-10) Long run: 30
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s
rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s
rngtest: Program run time: 1336176 microseconds
cat: write error: Broken pipe
---
v5: remove reset_control_rearm().
v4: add reset_control_rearm().
v3: no changes.
v2: no changes.
drivers/char/hw_random/bcm2835-rng.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/char/hw_random/bcm2835-rng.c +10 -0
@@ -13,6 +13,7 @@#include <linux/platform_device.h> #include <linux/printk.h> #include <linux/clk.h> +#include <linux/reset.h> #define RNG_CTRL 0x0#define RNG_STATUS 0x4
@@ -32,6 +33,7 @@ struct bcm2835_rng_priv {void __iomem *base;bool mask_interrupts;struct clk *clk; +struct reset_control *reset; };static inline struct bcm2835_rng_priv *to_rng_priv (struct hwrng *rng)
@@ -92,6 +94,10 @@ static int bcm2835_rng_init(struct hwrng *rng)if (ret)return ret; + ret =reset_control_reset (priv->reset); +if (ret) +return ret; +if (priv->mask_interrupts) {/* mask the interrupt */ val =rng_readl (priv,RNG_INT_MASK );
@@ -156,6 +162,10 @@ static int bcm2835_rng_probe(struct platform_device *pdev)if (IS_ERR (priv->clk))return PTR_ERR (priv->clk); + priv->reset =devm_reset_control_get_optional_exclusive (dev,NULL ); +if (IS_ERR (priv->reset)) +return PTR_ERR (priv->reset); + priv->rng.name = pdev->name; priv->rng.init = bcm2835_rng_init; priv->rng.read = bcm2835_rng_read;
Signature · 1 line
2.20.1
Quoted 21 lines · Álvaro Fernández Rojas
BCM6368 devices need to reset the in order to generate true random numbers. This is what BCM6368 produces without a reset:
root@OpenWrt:/# cat /dev/hwrng | rngtest -c 1000 rngtest 6.10 Copyright (c) 2004 by Henrique de Moraes Holschuh This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.rngtest: starting FIPS tests...
rngtest: bits received from input: 20000032
rngtest: FIPS 140-2 successes: 0
rngtest: FIPS 140-2 failures: 1000
rngtest: FIPS 140-2(2001-10-10) Monobit: 2
rngtest: FIPS 140-2(2001-10-10) Poker: 1000
rngtest: FIPS 140-2(2001-10-10) Runs: 1000
rngtest: FIPS 140-2(2001-10-10) Long run: 30
rngtest: FIPS 140-2(2001-10-10) Continuous run: 0
rngtest: input channel speed: (min=37.253; avg=320.827; max=635.783)Mibits/s
rngtest: FIPS tests speed: (min=12.141; avg=15.034; max=16.428)Mibits/s
rngtest: Program run time: 1336176 microseconds
cat: write error: Broken pipe
Quoted 3 lines
Signed-off-by Álvaro Fernández Rojas <[email protected]>---
v5: removereset_control_rearm().
regards
Philipp
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel