hwrng: Add Cortina Systems CS7542 random number generator
v2 cover hwrng: Add Cortina Systems CS7542 random number generator
Add the Elliptic random number generator integrated in the CS7542, based on the GPL vendor and OpenWrt implementations. Use a syscon regmap for its shared global scratch bit and provide bounded polling, nonblocking pending requests and partial output through the hwrng core.
Hardware ring reseeding is limited to the documented CS7542 A1 path. The vendor driver avoids it on A0 for erratum 28891 and substitutes a RTC/timer-derived nonce. Reject unsupported revisions using the global syscon identification register instead of adopting that workaround. The saved Almond+ capture identifies the tested board as CS7542 A1.
The binding, driver and MAINTAINERS entry apply to Linux v7.4-rc4 without the pending CS75xx platform or clock/pinctrl series.
The existing OpenWrt entropy quality setting of 512 is retained for review. The output smoke tests do not establish an entropy estimate.
The v1 sources passed binding/example checks, ARM built-in and module builds and RAM hardware smoke tests on Almond+. The hardware test returned EAGAIN for the first nonblocking read, then provided 4096 bytes without all-zero or repeated-block output.
No additional hardware run is claimed for v2. The generating path on A1 is unchanged; revision checks and their error paths were tested with the actual C code and mocked resource/regmap/hwrng interfaces. Full ARM W=1 built-in and module builds were repeated for v2.
---
Changes in v2:
- Drop the redundant linux/mod_devicetable.h include as suggested by
Uwe Kleine-König. The existing linux/of.h provides the OF device ID.
- Restrict hardware reseeding to CS7542 A1 after inspecting the vendor
erratum 28891 workaround. Propagate revision-read failures and reject unsupported silicon before registering the hwrng.
- Describe the hardware revision restriction and identification register
in the binding.
- Link to v1: https://lore.kernel.org/all/[email protected]/
To: Fil Dunsky <[email protected]>
To: Olivia Mackall <[email protected]>
To: Herbert Xu <[email protected]>
To: Rob Herring <[email protected]>
To: Krzysztof Kozlowski <[email protected]>
To: Conor Dooley <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
Fil Dunsky (3):
dt-bindings: rng: Add Cortina Systems CS7542 TRNG
hwrng: Add Cortina Systems CS7542 TRNG driver
MAINTAINERS: Add Cortina Systems CS7542 TRNG support
.../bindings/rng/cortina,cs7542-trng.yaml | 43 +++++ MAINTAINERS | 7 + drivers/char/hw_random/Kconfig | 11 ++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/cs75xx-trng.c | 187 +++++++++++++++++++++ 5 files changed, 249 insertions(+)
---
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
change-id: 20261123-b4-cs7542-trng-1a1b9f1cd392
Best regards,
Signature · 1 line
Fil Dunsky <[email protected]>
PATCH v2 1/3 dt-bindings: rng: Add Cortina Systems CS7542 TRNG
Describe the Elliptic TRNG register block and its reference to the shared global control syscon.
--- .../bindings/rng/cortina,cs7542-trng.yaml | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+)
Documentation/devicetree/bindings/rng/cortina,cs7542-trng.yaml new file +43 -0
@@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rng/cortina,cs7542-trng.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cortina Systems CS7542 true random number generator + +description: | + The CS7542 A0 revision is affected by reseeding erratum 28891. + Hardware entropy reseeding requires the CS7542 A1 revision. + +maintainers: + - Fil Dunsky <[email protected]> + +properties: + compatible: + const: cortina,cs7542-trng + + reg: + maxItems: 1 + + cortina,syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Global control syscon containing the SoC identification register at + offset 0x00 and the scratch register at offset 0xc0. + Bit 5 is set before initializing the random number generator. + +required: + - compatible + - reg + - cortina,syscon + +additionalProperties: false + +examples: + - | + rng@f0600000 { + compatible = "cortina,cs7542-trng"; + reg = <0xf0600000 0x20>; + cortina,syscon = <&global_control>; + };
Signature · 1 line
2.53.0
PATCH v2 2/3 hwrng: Add Cortina Systems CS7542 TRNG driver
In reply to Fil DunskyAdapt the OpenWrt implementation to use a syscon regmap for the shared scratch bit. Bound polling and retain a pending request across nonblocking calls instead of entering a blocking poll when wait=false. Handle partial output and wipe the temporary data on error paths.
Retain the existing OpenWrt entropy quality setting of 512 for review. Hardware output smoke tests do not establish an entropy estimate.
Restrict hardware reseeding to the documented CS7542 A1 revision, using identification bits read through the global syscon before registration. The vendor driver avoids ring reseeding on A0 for erratum 28891; its RTC/timer-derived nonce workaround is not a replacement entropy source. Propagate identification errors and reject unsupported revisions.
--- drivers/char/hw_random/Kconfig | 11 +++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/cs75xx-trng.c | 187 +++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+)
drivers/char/hw_random/Kconfig +11 -0
@@ -648,6 +648,17 @@ config HW_RANDOM_QCOM To compile this driver as a module, choose M here. The module will be called qcom-rng. If unsure, say N. + +config HW_RANDOM_CS75XX + tristate "Cortina Systems CS7542 random number generator" + depends on OF && HAS_IOMEM + select MFD_SYSCON + help + Support the Elliptic random number generator in the CS7542 SoC. + Access the shared global control block through a syscon regmap. + Provide polled reads through the hardware RNG framework. + The module will be named cs75xx-trng. + endif # HW_RANDOM config UML_RANDOM
drivers/char/hw_random/Makefile +1 -0
@@ -55,3 +55,4 @@ obj-$(CONFIG_HW_RANDOM_ROCKCHIP) += rockchip-rng.o obj-$(CONFIG_HW_RANDOM_JH7110) += jh7110-trng.o obj-$(CONFIG_HW_RANDOM_XILINX) += xilinx-trng.o obj-$(CONFIG_HW_RANDOM_QCOM) += qcom-rng.o +obj-$(CONFIG_HW_RANDOM_CS75XX) += cs75xx-trng.o
drivers/char/hw_random/cs75xx-trng.c new file +187 -0
187 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH v2 3/3 MAINTAINERS: Add Cortina Systems CS7542 TRNG support
In reply to Fil DunskyRoute changes to the CS7542 random number generator driver and binding to their subsystem mailing list and the platform maintainer.
--- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
@@ -2949,6 +2949,13 @@ F: tools/perf/tests/shell/coresight/* F: tools/perf/util/cs-etm-decoder/* F: tools/perf/util/cs-etm.* +ARM/CORTINA SYSTEMS CS7542 RANDOM NUMBER GENERATOR +M: Fil Dunsky <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/rng/cortina,cs7542-trng.yaml +F: drivers/char/hw_random/cs75xx-trng.c + ARM/CORTINA SYSTEMS GEMINI ARM ARCHITECTURE M: Hans Ulli Kroll <[email protected]> M: Linus Walleij <[email protected]>
Signature · 1 line
2.53.0