Skip to contentSkip to conversation

Add support for hwrng on PolarFire SoC

PATCH Superseded [email protected] 2 participants 6 messages Apr 8, 2022 – Apr 15, 2022

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH v2 1/1 Add support for hwrng on PolarFire SoC

From: Conor Dooley <[email protected]>

As it says on the tin, add support for the hardware rng on PolarFire SoC, which is accessed via the system controller.
I dropped the maintainers entry change that v1 had, I will send a single update via RISCV to avoid any conflicts.

On v1 I replied saying there was a refcount issue, but that's not actually the case, so no changes required there.

Thanks,
Conor

Changes since v1:
- Rebased on v5.18-rc1
- Dropped the MAINTAINERS change
- Added quality estimation

Conor Dooley (1):
hwrng: mpfs - add polarfire soc hwrng support

 drivers/char/hw_random/Kconfig    |  13 ++++
 drivers/char/hw_random/Makefile   |   1 +
 drivers/char/hw_random/mpfs-rng.c | 104 ++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/char/hw_random/mpfs-rng.c
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH v2 1/1 hwrng: mpfs - add polarfire soc hwrng support

From: Conor Dooley <[email protected]>

Add a driver to access the hardware random number generator on the Polarfire SoC. The hwrng can only be accessed via the system controller, so use the mailbox interface the system controller exposes to access the hwrng.

---
 drivers/char/hw_random/Kconfig    |  13 ++++
 drivers/char/hw_random/Makefile   |   1 +
 drivers/char/hw_random/mpfs-rng.c | 104 ++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/char/hw_random/mpfs-rng.c
drivers/char/hw_random/Kconfig +13 -0
index a087156a5818..c3a9f17bf31c 100644
@@ -385,6 +385,19 @@ config HW_RANDOM_PIC32
 
 	  If unsure, say Y.
 
+config HW_RANDOM_POLARFIRE_SOC
+	tristate "Microchip PolarFire SoC Random Number Generator support"
+	depends on HW_RANDOM && POLARFIRE_SOC_SYS_CTRL
+	help
+	  This driver provides kernel-side support for the Random Number
+	  Generator hardware found on PolarFire SoC (MPFS).
+
+	  To compile this driver as a module, choose M here. The
+	  module will be called mfps_rng.
+
+	  If unsure, say N.
+
+
 config HW_RANDOM_MESON
 	tristate "Amlogic Meson Random Number Generator support"
 	depends on HW_RANDOM
drivers/char/hw_random/Makefile +1 -0
index 584d47ba32f7..3e948cf04476 100644
@@ -46,3 +46,4 @@ obj-$(CONFIG_HW_RANDOM_CCTRNG) += cctrng.o
 obj-$(CONFIG_HW_RANDOM_XIPHERA) += xiphera-trng.o
 obj-$(CONFIG_HW_RANDOM_ARM_SMCCC_TRNG) += arm_smccc_trng.o
 obj-$(CONFIG_HW_RANDOM_CN10K) += cn10k-rng.o
+obj-$(CONFIG_HW_RANDOM_POLARFIRE_SOC) += mpfs-rng.o
drivers/char/hw_random/mpfs-rng.c new file +104 -0

104 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer
#2 lore raw

hwrng: mpfs - Enable COMPILE_TEST

The dependency on HW_RANDOM is redundant so this patch removes it. As this driver seems to cross-compile just fine we could also enable COMPILE_TEST.

drivers/char/hw_random/Kconfig +1 -1
index 18aa97974b8b..dad084c0ecee 100644
@@ -387,7 +387,7 @@ config HW_RANDOM_PIC32
 
 config HW_RANDOM_POLARFIRE_SOC
 	tristate "Microchip PolarFire SoC Random Number Generator support"
-	depends on HW_RANDOM && POLARFIRE_SOC_SYS_CTRL
+	depends on POLARFIRE_SOC_SYS_CTRL || COMPILE_TEST
 	help
 	  This driver provides kernel-side support for the Random Number
 	  Generator hardware found on PolarFire SoC (MPFS).
Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer Reviewed-by
#3 lore raw

Re: hwrng: mpfs - Enable COMPILE_TEST

Quoted 3 lines · Herbert Xu

The dependency on HW_RANDOM is redundant so this patch removes it. As this driver seems to cross-compile just fine we could also enable COMPILE_TEST.

Sorry about that. Compile test makes sense to me too.

Thanks for applying my patch :)
Conor

Quoted 16 lines
drivers/char/hw_random/Kconfig +1 -1
index 18aa97974b8b..dad084c0ecee 100644
@@ -387,7 +387,7 @@ config HW_RANDOM_PIC32
 
  config HW_RANDOM_POLARFIRE_SOC
  	tristate "Microchip PolarFire SoC Random Number Generator support"
-	depends on HW_RANDOM && POLARFIRE_SOC_SYS_CTRL
+	depends on POLARFIRE_SOC_SYS_CTRL || COMPILE_TEST
  	help
  	  This driver provides kernel-side support for the Random Number
  	  Generator hardware found on PolarFire SoC (MPFS).
author maintainer Reviewed-by
#4 lore raw

Re: hwrng: mpfs - Enable COMPILE_TEST

Quoted 10 lines · On 15/04/2022 10:18, [email protected] wrote:

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Quoted 3 lines · Herbert Xu

The dependency on HW_RANDOM is redundant so this patch removes it. As this driver seems to cross-compile just fine we could also enable COMPILE_TEST.

Sorry about that. Compile test makes sense to me too.

woops, missing a >.

Quoted 24 lines

Thanks for applying my patch :)
Conor

Quoted 8 lines
drivers/char/hw_random/Kconfig +0 -0
index 18aa97974b8b..dad084c0ecee 100644

drivers/char/hw_random/Kconfig config HW_RANDOM_PIC32 · line 393

Quoted 8 lines
drivers/char/hw_random/Kconfig +1 -1
@@ -387,7 +387,7 @@ config HW_RANDOM_PIC32
 
   config HW_RANDOM_POLARFIRE_SOC
       tristate "Microchip PolarFire SoC Random Number Generator support"
-     depends on HW_RANDOM && POLARFIRE_SOC_SYS_CTRL
+     depends on POLARFIRE_SOC_SYS_CTRL || COMPILE_TEST
       help
         This driver provides kernel-side support for the Random Number
         Generator hardware found on PolarFire SoC (MPFS).

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv

maintainer
#5 lore raw

Re: [PATCH v2 1/1] hwrng: mpfs - add polarfire soc hwrng support

In reply to [email protected]
Quoted 7 lines · On Fri, Apr 08, 2022 at 10:09:12AM +0000, [email protected] wrote:

From: Conor Dooley <[email protected]>

Add a driver to access the hardware random number generator on the Polarfire SoC. The hwrng can only be accessed via the system controller, so use the mailbox interface the system controller exposes to access the hwrng.

Quoted 7 lines
---
 drivers/char/hw_random/Kconfig    |  13 ++++
 drivers/char/hw_random/Makefile   |   1 +
 drivers/char/hw_random/mpfs-rng.c | 104 ++++++++++++++++++++++++++++++
 3 files changed, 118 insertions(+)
 create mode 100644 drivers/char/hw_random/mpfs-rng.c

Patch applied. Thanks.

Signature · 8 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv