linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Raspberry Pi 4 HWRNG Support
@ 2019-11-18  7:58 Stephen Brennan
  2019-11-18  7:58 ` [PATCH 1/3] dt-bindings: rng: add BCM2711 RNG compatible Stephen Brennan
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stephen Brennan @ 2019-11-18  7:58 UTC (permalink / raw)
  To: stephen
  Cc: Matt Mackall, Herbert Xu, Rob Herring, Mark Rutland, Ray Jui,
	Scott Branden, bcm-kernel-feedback-list, Eric Anholt,
	Stefan Wahren, Arnd Bergmann, Greg Kroah-Hartman,
	Florian Fainelli, linux-crypto, devicetree, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel

This patch series enables support for the HWRNG included on the Raspberry
Pi 4.  It is simply a rebase of Stefan's branch [1]. I went ahead and
tested this out on a Pi 4.  Prior to this patch series, attempting to use
the hwrng gives:

    $ head -c 2 /dev/hwrng
    head: /dev/hwrng: Input/output error

After this patch, the same command gives two random bytes.

[1]: https://github.com/lategoodbye/rpi-zero/tree/bcm2711-hwrng

---

Stefan Wahren (3):
  dt-bindings: rng: add BCM2711 RNG compatible
  hwrng: iproc-rng200: Add support for BCM2711
  ARM: dts: bcm2711: Enable HWRNG support

 Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt | 1 +
 arch/arm/boot/dts/bcm2711.dtsi                              | 5 ++---
 drivers/char/hw_random/Kconfig                              | 2 +-
 drivers/char/hw_random/iproc-rng200.c                       | 1 +
 4 files changed, 5 insertions(+), 4 deletions(-)

-- 
2.24.0




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] dt-bindings: rng: add BCM2711 RNG compatible
  2019-11-18  7:58 [PATCH 0/3] Raspberry Pi 4 HWRNG Support Stephen Brennan
@ 2019-11-18  7:58 ` Stephen Brennan
  2019-11-18  7:58 ` [PATCH 2/3] hwrng: iproc-rng200: Add support for BCM2711 Stephen Brennan
  2019-11-18  7:58 ` [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support Stephen Brennan
  2 siblings, 0 replies; 7+ messages in thread
From: Stephen Brennan @ 2019-11-18  7:58 UTC (permalink / raw)
  To: stephen
  Cc: Matt Mackall, Herbert Xu, Rob Herring, Mark Rutland, Ray Jui,
	Scott Branden, bcm-kernel-feedback-list, Eric Anholt,
	Stefan Wahren, Arnd Bergmann, Greg Kroah-Hartman,
	Florian Fainelli, linux-crypto, devicetree, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel

From: Stefan Wahren <wahrenst@gmx.net>

The BCM2711 has a RNG200 block, so document its compatible string.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Stephen Brennan <stephen@brennan.io>
---
 Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt b/Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt
index c223e54452da..802523196ee5 100644
--- a/Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt
+++ b/Documentation/devicetree/bindings/rng/brcm,iproc-rng200.txt
@@ -2,6 +2,7 @@ HWRNG support for the iproc-rng200 driver
 
 Required properties:
 - compatible : Must be one of:
+	       "brcm,bcm2711-rng200"
 	       "brcm,bcm7211-rng200"
 	       "brcm,bcm7278-rng200"
 	       "brcm,iproc-rng200"
-- 
2.24.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] hwrng: iproc-rng200: Add support for BCM2711
  2019-11-18  7:58 [PATCH 0/3] Raspberry Pi 4 HWRNG Support Stephen Brennan
  2019-11-18  7:58 ` [PATCH 1/3] dt-bindings: rng: add BCM2711 RNG compatible Stephen Brennan
@ 2019-11-18  7:58 ` Stephen Brennan
  2019-11-18  7:58 ` [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support Stephen Brennan
  2 siblings, 0 replies; 7+ messages in thread
From: Stephen Brennan @ 2019-11-18  7:58 UTC (permalink / raw)
  To: stephen
  Cc: Matt Mackall, Herbert Xu, Rob Herring, Mark Rutland, Ray Jui,
	Scott Branden, bcm-kernel-feedback-list, Eric Anholt,
	Stefan Wahren, Arnd Bergmann, Greg Kroah-Hartman,
	Florian Fainelli, linux-crypto, devicetree, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel

From: Stefan Wahren <wahrenst@gmx.net>

BCM2711 features a RNG200 hardware random number generator block.
So make the driver available.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Stephen Brennan <stephen@brennan.io>
---
 drivers/char/hw_random/Kconfig        | 2 +-
 drivers/char/hw_random/iproc-rng200.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 7c7fecfa2fb2..77e848fca531 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -90,7 +90,7 @@ config HW_RANDOM_BCM2835
 
 config HW_RANDOM_IPROC_RNG200
 	tristate "Broadcom iProc/STB RNG200 support"
-	depends on ARCH_BCM_IPROC || ARCH_BRCMSTB
+	depends on ARCH_BCM_IPROC || ARCH_BCM2835 || ARCH_BRCMSTB
 	default HW_RANDOM
 	---help---
 	  This driver provides kernel-side support for the RNG200
diff --git a/drivers/char/hw_random/iproc-rng200.c b/drivers/char/hw_random/iproc-rng200.c
index 899ff25f4f28..32d9fe61a225 100644
--- a/drivers/char/hw_random/iproc-rng200.c
+++ b/drivers/char/hw_random/iproc-rng200.c
@@ -213,6 +213,7 @@ static int iproc_rng200_probe(struct platform_device *pdev)
 }
 
 static const struct of_device_id iproc_rng200_of_match[] = {
+	{ .compatible = "brcm,bcm2711-rng200", },
 	{ .compatible = "brcm,bcm7211-rng200", },
 	{ .compatible = "brcm,bcm7278-rng200", },
 	{ .compatible = "brcm,iproc-rng200", },
-- 
2.24.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support
  2019-11-18  7:58 [PATCH 0/3] Raspberry Pi 4 HWRNG Support Stephen Brennan
  2019-11-18  7:58 ` [PATCH 1/3] dt-bindings: rng: add BCM2711 RNG compatible Stephen Brennan
  2019-11-18  7:58 ` [PATCH 2/3] hwrng: iproc-rng200: Add support for BCM2711 Stephen Brennan
@ 2019-11-18  7:58 ` Stephen Brennan
  2019-11-18 11:44   ` Nicolas Saenz Julienne
  2 siblings, 1 reply; 7+ messages in thread
From: Stephen Brennan @ 2019-11-18  7:58 UTC (permalink / raw)
  To: stephen
  Cc: Matt Mackall, Herbert Xu, Rob Herring, Mark Rutland, Ray Jui,
	Scott Branden, bcm-kernel-feedback-list, Eric Anholt,
	Stefan Wahren, Arnd Bergmann, Greg Kroah-Hartman,
	Florian Fainelli, linux-crypto, devicetree, linux-arm-kernel,
	linux-kernel, linux-rpi-kernel

From: Stefan Wahren <wahrenst@gmx.net>

This enables hardware random number generator support for the BCM2711
on the Raspberry Pi 4 board.

Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Signed-off-by: Stephen Brennan <stephen@brennan.io>
---
 arch/arm/boot/dts/bcm2711.dtsi | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
index ac83dac2e6ba..2c19e5de284a 100644
--- a/arch/arm/boot/dts/bcm2711.dtsi
+++ b/arch/arm/boot/dts/bcm2711.dtsi
@@ -92,10 +92,9 @@ pm: watchdog@7e100000 {
 		};
 
 		rng@7e104000 {
+			compatible = "brcm,bcm2711-rng200";
 			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
-
-			/* RNG is incompatible with brcm,bcm2835-rng */
-			status = "disabled";
+			status = "okay";
 		};
 
 		uart2: serial@7e201400 {
-- 
2.24.0




^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support
  2019-11-18  7:58 ` [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support Stephen Brennan
@ 2019-11-18 11:44   ` Nicolas Saenz Julienne
  2019-11-18 19:44     ` Stefan Wahren
  0 siblings, 1 reply; 7+ messages in thread
From: Nicolas Saenz Julienne @ 2019-11-18 11:44 UTC (permalink / raw)
  To: Stephen Brennan
  Cc: Mark Rutland, devicetree, linux-rpi-kernel, Florian Fainelli,
	Herbert Xu, Scott Branden, Greg Kroah-Hartman, linux-arm-kernel,
	Ray Jui, linux-kernel, Eric Anholt, Rob Herring,
	bcm-kernel-feedback-list, Stefan Wahren, Matt Mackall,
	Arnd Bergmann, linux-crypto

[-- Attachment #1: Type: text/plain, Size: 1265 bytes --]

Hi Stephen,

On Sun, 2019-11-17 at 23:58 -0800, Stephen Brennan wrote:
> From: Stefan Wahren <wahrenst@gmx.net>
> 
> This enables hardware random number generator support for the BCM2711
> on the Raspberry Pi 4 board.
> 
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> Signed-off-by: Stephen Brennan <stephen@brennan.io>
> ---
>  arch/arm/boot/dts/bcm2711.dtsi | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> index ac83dac2e6ba..2c19e5de284a 100644
> --- a/arch/arm/boot/dts/bcm2711.dtsi
> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> @@ -92,10 +92,9 @@ pm: watchdog@7e100000 {
>  		};
>  
>  		rng@7e104000 {
> +			compatible = "brcm,bcm2711-rng200";
>  			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
> -
> -			/* RNG is incompatible with brcm,bcm2835-rng */
> -			status = "disabled";
> +			status = "okay";
>  		};
>  
>  		uart2: serial@7e201400 {

We inherit the reg property from bcm283x.dtsi, on which we only define a size
of 0x10 bytes. I gather from the driver that iproc-rng200's register space is
at least 0x28 bytes big. We should also update the 'reg' property to:

	reg = <0x7e104000 0x28>;

Regards,
Nicolas


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support
  2019-11-18 11:44   ` Nicolas Saenz Julienne
@ 2019-11-18 19:44     ` Stefan Wahren
  2019-11-19  5:49       ` Stephen Brennan
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Wahren @ 2019-11-18 19:44 UTC (permalink / raw)
  To: Nicolas Saenz Julienne, Stephen Brennan
  Cc: Mark Rutland, devicetree, Florian Fainelli, Herbert Xu,
	Scott Branden, Greg Kroah-Hartman, Matt Mackall, linux-kernel,
	Arnd Bergmann, linux-crypto, Eric Anholt, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Ray Jui,
	linux-arm-kernel

Hi,

Am 18.11.19 um 12:44 schrieb Nicolas Saenz Julienne:
> Hi Stephen,
>
> On Sun, 2019-11-17 at 23:58 -0800, Stephen Brennan wrote:
>> From: Stefan Wahren <wahrenst@gmx.net>
>>
>> This enables hardware random number generator support for the BCM2711
>> on the Raspberry Pi 4 board.
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> Signed-off-by: Stephen Brennan <stephen@brennan.io>
>> ---
>>  arch/arm/boot/dts/bcm2711.dtsi | 5 ++---
>>  1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
>> index ac83dac2e6ba..2c19e5de284a 100644
>> --- a/arch/arm/boot/dts/bcm2711.dtsi
>> +++ b/arch/arm/boot/dts/bcm2711.dtsi
>> @@ -92,10 +92,9 @@ pm: watchdog@7e100000 {
>>  		};
>>
>>  		rng@7e104000 {
>> +			compatible = "brcm,bcm2711-rng200";
>>  			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
>> -
>> -			/* RNG is incompatible with brcm,bcm2835-rng */
>> -			status = "disabled";
>> +			status = "okay";
>>  		};
>>
>>  		uart2: serial@7e201400 {
> We inherit the reg property from bcm283x.dtsi, on which we only define a size
> of 0x10 bytes. I gather from the driver that iproc-rng200's register space is
> at least 0x28 bytes big. We should also update the 'reg' property to:
>
> 	reg = <0x7e104000 0x28>;

Thanks for sending and noticing. A proper solution would be to move the
whole rng node from bcm283x.dtsi to bcm283x-common.dtsi and define a
completely new rng node in bcm2711.dtsi.

Regards
Stefan

>
> Regards,
> Nicolas
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support
  2019-11-18 19:44     ` Stefan Wahren
@ 2019-11-19  5:49       ` Stephen Brennan
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Brennan @ 2019-11-19  5:49 UTC (permalink / raw)
  To: Stefan Wahren, Nicolas Saenz Julienne
  Cc: Mark Rutland, devicetree, Florian Fainelli, Herbert Xu,
	Scott Branden, Greg Kroah-Hartman, Matt Mackall, linux-kernel,
	Arnd Bergmann, linux-crypto, Eric Anholt, Rob Herring,
	bcm-kernel-feedback-list, linux-rpi-kernel, Ray Jui,
	linux-arm-kernel

Hello Stefan & Nicolas,

On Mon Nov 18, 2019 at 8:44 PM, Stefan Wahren wrote:
> Hi,
>
> 
> Am 18.11.19 um 12:44 schrieb Nicolas Saenz Julienne:
> > Hi Stephen,
> >
> > On Sun, 2019-11-17 at 23:58 -0800, Stephen Brennan wrote:
> >> From: Stefan Wahren <wahrenst@gmx.net>
> >>
> >> This enables hardware random number generator support for the BCM2711
> >> on the Raspberry Pi 4 board.
> >>
> >> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> >> Signed-off-by: Stephen Brennan <stephen@brennan.io>
> >> ---
> >>  arch/arm/boot/dts/bcm2711.dtsi | 5 ++---
> >>  1 file changed, 2 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/arch/arm/boot/dts/bcm2711.dtsi b/arch/arm/boot/dts/bcm2711.dtsi
> >> index ac83dac2e6ba..2c19e5de284a 100644
> >> --- a/arch/arm/boot/dts/bcm2711.dtsi
> >> +++ b/arch/arm/boot/dts/bcm2711.dtsi
> >> @@ -92,10 +92,9 @@ pm: watchdog@7e100000 {
> >>  		};
> >>
> >>  		rng@7e104000 {
> >> +			compatible = "brcm,bcm2711-rng200";
> >>  			interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>;
> >> -
> >> -			/* RNG is incompatible with brcm,bcm2835-rng */
> >> -			status = "disabled";
> >> +			status = "okay";
> >>  		};
> >>
> >>  		uart2: serial@7e201400 {
> > We inherit the reg property from bcm283x.dtsi, on which we only define a size
> > of 0x10 bytes. I gather from the driver that iproc-rng200's register space is
> > at least 0x28 bytes big. We should also update the 'reg' property to:
> >
> > 	reg = <0x7e104000 0x28>;
>
> 
> Thanks for sending and noticing. A proper solution would be to move the
> whole rng node from bcm283x.dtsi to bcm283x-common.dtsi and define a
> completely new rng node in bcm2711.dtsi.

Thanks both for your time and consideration. I'm not terribly familiar with 
device tree source but I think I understand what you'd like here. I'll send 
a v2 that does this!

Regards,
Stephen

>
> 
> Regards
> Stefan
>
> 
> >
> > Regards,
> > Nicolas
> >
> >
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
> 
>
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-19  5:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-18  7:58 [PATCH 0/3] Raspberry Pi 4 HWRNG Support Stephen Brennan
2019-11-18  7:58 ` [PATCH 1/3] dt-bindings: rng: add BCM2711 RNG compatible Stephen Brennan
2019-11-18  7:58 ` [PATCH 2/3] hwrng: iproc-rng200: Add support for BCM2711 Stephen Brennan
2019-11-18  7:58 ` [PATCH 3/3] ARM: dts: bcm2711: Enable HWRNG support Stephen Brennan
2019-11-18 11:44   ` Nicolas Saenz Julienne
2019-11-18 19:44     ` Stefan Wahren
2019-11-19  5:49       ` Stephen Brennan

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).