dt-bindings: rng: add support for Airoha EN7581 TRNG
PATCH 1/2 dt-bindings: rng: add support for Airoha EN7581 TRNG
Add support for Airoha EN7581 True Random Number generator.
This module can generate up to 4bytes of raw data at times and support self health test at startup. The module gets noise for randomness from various source from ADC, AP, dedicated clocks and other devices attached to the SoC producing true random numbers.
--- .../bindings/rng/airoha,en7581-trng.yaml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/rng/airoha,en7581-trng.yaml
Documentation/devicetree/bindings/rng/airoha,en7581-trng.yaml new file +38 -0
@@ -0,0 +1,38 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rng/airoha,en7581-trng.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha EN7851 True Random Number Generator + +maintainers: + - Christian Marangi <[email protected]> + +properties: + compatible: + const: airoha,en7581-trng + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + + rng@1faa1000 { + compatible = "airoha,en7581-trng"; + reg = <0x1faa1000 0x1000>; + interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>; + };
Signature · 1 line
2.45.2
PATCH 2/2 hwrng: add support for Airoha EN7581 TRNG
Add support for Airoha TRNG. The Airoha SoC provide a True RNG module that can output 4 bytes of raw data at times.
The module makes use of various noise source to provide True Random Number Generation.
On probe the module is reset to operate Health Test and verify correct execution of it.
The module can also provide DRBG function but the execution mode is mutually exclusive, running as TRNG doesn't permit to also run it as DRBG.
--- drivers/char/hw_random/Kconfig | 13 ++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/airoha-trng.c | 243 +++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 drivers/char/hw_random/airoha-trng.c
drivers/char/hw_random/Kconfig +13 -0
@@ -62,6 +62,19 @@ config HW_RANDOM_AMD If unsure, say Y. +config HW_RANDOM_AIROHA + tristate "Airoha True HW Random Number Generator support" + depends on ARCH_AIROHA || COMPILE_TEST + default HW_RANDOM + help + This driver provides kernel-side support for the True Random Number + Generator hardware found on Airoha SoC. + + To compile this driver as a module, choose M here: the + module will be called airoha-rng. + + If unsure, say Y. + config HW_RANDOM_ATMEL tristate "Atmel Random Number Generator support" depends on (ARCH_AT91 || COMPILE_TEST)
drivers/char/hw_random/Makefile +1 -0
@@ -8,6 +8,7 @@ rng-core-y := core.o obj-$(CONFIG_HW_RANDOM_TIMERIOMEM) += timeriomem-rng.o obj-$(CONFIG_HW_RANDOM_INTEL) += intel-rng.o obj-$(CONFIG_HW_RANDOM_AMD) += amd-rng.o +obj-$(CONFIG_HW_RANDOM_AIROHA) += airoha-trng.o obj-$(CONFIG_HW_RANDOM_ATMEL) += atmel-rng.o obj-$(CONFIG_HW_RANDOM_BA431) += ba431-rng.o obj-$(CONFIG_HW_RANDOM_GEODE) += geode-rng.o
drivers/char/hw_random/airoha-trng.c new file +243 -0
243 lines not on this page · raw message
Signature · 1 line
2.45.2
kernel test robot
build botRe: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG
kernel test robot noticed the following build errors:
Hi Christian,
kernel test robot noticed the following build errors:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on char-misc/char-misc-next char-misc/char-misc-linus robh/for-next herbert-cryptodev-2.6/master linus/master v6.12-rc3 next-20241016] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/hwrng-add-support-for-Airoha-EN7581-TRNG/20241016-232144 base: char-misc/char-misc-testing patch link: https://lore.kernel.org/r/20241016151845.23712-2-ansuelsmth%40gmail.com patch subject: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG config: arc-randconfig-001-20241017 (https://download.01.org/0day-ci/archive/20241017/[email protected]/config) compiler: arceb-elf-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241017/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from drivers/char/hw_random/airoha-trng.c:9:
drivers/char/hw_random/airoha-trng.c: In function 'airoha_trng_init':
>> drivers/char/hw_random/airoha-trng.c:115:34: error: implicit declaration of function 'FIELD_GET' [-Werror=implicit-function-declaration]
115 | FIELD_GET(CNT_TRANS, val) == TRNG_CNT_TRANS_VALID,
| ^~~~~~~~~
include/linux/iopoll.h:47:21: note: in definition of macro 'read_poll_timeout'
47 | if (cond) \
| ^~~~
include/linux/iopoll.h:170:9: note: in expansion of macro 'readx_poll_timeout'
170 | readx_poll_timeout(readl, addr, val, cond, delay_us, timeout_us)
| ^~~~~~~~~~~~~~~~~~
drivers/char/hw_random/airoha-trng.c:114:15: note: in expansion of macro 'readl_poll_timeout'
114 | ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
| ^~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +/FIELD_GET +115 drivers/char/hw_random/airoha-trng.c
75
76 static int airoha_trng_init(struct hwrng *rng)
77 {
78 struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
79 int ret;
80 u32 val;
81
82 val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
83 val |= RNG_EN;
84 writel(val, trng->base + TRNG_NS_SEK_AND_DAT_EN);
85
86 /* Set out of SW Reset */
87 airoha_trng_irq_unmask(trng);
88 writel(0, trng->base + TRNG_HEALTH_TEST_SW_RST);
89
90 ret = wait_for_completion_timeout(&trng->rng_op_done, BUSY_LOOP_TIMEOUT);
91 if (ret <= 0) {
92 dev_err(trng->dev, "Timeout waiting for Health Check\n");
93 airoha_trng_irq_mask(trng);
94 return -ENODEV;
95 }
96
97 /* Check if Health Test Failed */
98 val = readl(trng->base + TRNG_HEALTH_TEST_STATUS);
99 if (val & (RST_STARTUP_AP_TEST_FAIL | RST_STARTUP_RC_TEST_FAIL)) {
100 dev_err(trng->dev, "Health Check fail: %s test fail\n",
101 val & RST_STARTUP_AP_TEST_FAIL ? "AP" : "RC");
102 return -ENODEV;
103 }
104
105 /* Check if IP is ready */
106 ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
107 val & SAMPLE_RDY, 10, 1000);
108 if (ret < 0) {
109 dev_err(trng->dev, "Timeout waiting for IP ready");
110 return -ENODEV;
111 }
112
113 /* CNT_TRANS must be 0x80 for IP to be considered ready */
114 ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
> 115 FIELD_GET(CNT_TRANS, val) == TRNG_CNT_TRANS_VALID, 116 10, 1000);
117 if (ret < 0) {
118 dev_err(trng->dev, "Timeout waiting for IP ready");
119 return -ENODEV;
120 }
121
122 return 0;
123 }
124
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG
In reply to Christian Marangikernel test robot noticed the following build errors:
Hi Christian,
kernel test robot noticed the following build errors:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on char-misc/char-misc-next char-misc/char-misc-linus robh/for-next herbert-cryptodev-2.6/master linus/master v6.12-rc3 next-20241017] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/hwrng-add-support-for-Airoha-EN7581-TRNG/20241016-232144 base: char-misc/char-misc-testing patch link: https://lore.kernel.org/r/20241016151845.23712-2-ansuelsmth%40gmail.com patch subject: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG config: i386-buildonly-randconfig-003-20241017 (https://download.01.org/0day-ci/archive/20241017/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241017/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/char/hw_random/airoha-trng.c:115:6: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
115 | FIELD_GET(CNT_TRANS, val) == TRNG_CNT_TRANS_VALID,
| ^
>> drivers/char/hw_random/airoha-trng.c:115:6: error: call to undeclared function 'FIELD_GET'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]2 errors generated.
vim +/FIELD_GET +115 drivers/char/hw_random/airoha-trng.c
75
76 static int airoha_trng_init(struct hwrng *rng)
77 {
78 struct airoha_trng *trng = container_of(rng, struct airoha_trng, rng);
79 int ret;
80 u32 val;
81
82 val = readl(trng->base + TRNG_NS_SEK_AND_DAT_EN);
83 val |= RNG_EN;
84 writel(val, trng->base + TRNG_NS_SEK_AND_DAT_EN);
85
86 /* Set out of SW Reset */
87 airoha_trng_irq_unmask(trng);
88 writel(0, trng->base + TRNG_HEALTH_TEST_SW_RST);
89
90 ret = wait_for_completion_timeout(&trng->rng_op_done, BUSY_LOOP_TIMEOUT);
91 if (ret <= 0) {
92 dev_err(trng->dev, "Timeout waiting for Health Check\n");
93 airoha_trng_irq_mask(trng);
94 return -ENODEV;
95 }
96
97 /* Check if Health Test Failed */
98 val = readl(trng->base + TRNG_HEALTH_TEST_STATUS);
99 if (val & (RST_STARTUP_AP_TEST_FAIL | RST_STARTUP_RC_TEST_FAIL)) {
100 dev_err(trng->dev, "Health Check fail: %s test fail\n",
101 val & RST_STARTUP_AP_TEST_FAIL ? "AP" : "RC");
102 return -ENODEV;
103 }
104
105 /* Check if IP is ready */
106 ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
107 val & SAMPLE_RDY, 10, 1000);
108 if (ret < 0) {
109 dev_err(trng->dev, "Timeout waiting for IP ready");
110 return -ENODEV;
111 }
112
113 /* CNT_TRANS must be 0x80 for IP to be considered ready */
114 ret = readl_poll_timeout(trng->base + TRNG_IP_RDY, val,
> 115 FIELD_GET(CNT_TRANS, val) == TRNG_CNT_TRANS_VALID, 116 10, 1000);
117 if (ret < 0) {
118 dev_err(trng->dev, "Timeout waiting for IP ready");
119 return -ENODEV;
120 }
121
122 return 0;
123 }
124
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG
In reply to Christian MarangiQuoted 26 lines · Christian Marangi
Add support for Airoha TRNG. The Airoha SoC provide a True RNG module that can output 4 bytes of raw data at times.
The module makes use of various noise source to provide True Random Number Generation.
On probe the module is reset to operate Health Test and verify correct execution of it.
The module can also provide DRBG function but the execution mode is mutually exclusive, running as TRNG doesn't permit to also run it as DRBG.
Signed-off-by Christian Marangi <[email protected]>--- drivers/char/hw_random/Kconfig | 13 ++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/airoha-trng.c | 243 +++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 drivers/char/hw_random/airoha-trng.cdrivers/char/hw_random/Kconfig +0
-0
drivers/char/hw_random/Kconfig config HW_RANDOM_AMD · line 69
Quoted 8 lines
drivers/char/hw_random/Kconfig +4
-0@@ -62,6 +62,19 @@ config HW_RANDOM_AMD If unsure, say Y. +config HW_RANDOM_AIROHA + tristate "Airoha True HW Random Number Generator support" + depends on ARCH_AIROHA || COMPILE_TEST + default HW_RANDOM
This should not be always enabled when HW_RANDOM is enabled. Enabling driver should be a opt-in.
Francesco
Re: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG
Quoted 30 lines · Francesco Dolcini
Quoted 29 lines · Christian Marangi
Add support for Airoha TRNG. The Airoha SoC provide a True RNG module that can output 4 bytes of raw data at times.
The module makes use of various noise source to provide True Random Number Generation.
On probe the module is reset to operate Health Test and verify correct execution of it.
The module can also provide DRBG function but the execution mode is mutually exclusive, running as TRNG doesn't permit to also run it as DRBG.
Signed-off-by Christian Marangi <[email protected]>--- drivers/char/hw_random/Kconfig | 13 ++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/airoha-trng.c | 243 +++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 drivers/char/hw_random/airoha-trng.cdrivers/char/hw_random/Kconfig +0
-0@@ -62,6 +62,19 @@ config HW_RANDOM_AMD If unsure, say Y.
Quoted 7 lines
drivers/char/hw_random/Kconfig config HW_RANDOM_AMD · line 68
Quoted 5 lines
drivers/char/hw_random/Kconfig +4
-0+config HW_RANDOM_AIROHA + tristate "Airoha True HW Random Number Generator support" + depends on ARCH_AIROHA || COMPILE_TEST + default HW_RANDOMThis should not be always enabled when
HW_RANDOMis enabled. Enabling driver should be a opt-in.
Was following the pattern with other HW_RANDOM config. Ok will drop.
Signature · 1 line
Ansuel
Re: [PATCH 2/2] hwrng: add support for Airoha EN7581 TRNG
Quoted 35 lines · Christian Marangi
Quoted 34 lines · Francesco Dolcini
Quoted 32 lines · Christian Marangi
Add support for Airoha TRNG. The Airoha SoC provide a True RNG module that can output 4 bytes of raw data at times.
The module makes use of various noise source to provide True Random Number Generation.
On probe the module is reset to operate Health Test and verify correct execution of it.
The module can also provide DRBG function but the execution mode is mutually exclusive, running as TRNG doesn't permit to also run it as DRBG.
Signed-off-by Christian Marangi <[email protected]>--- drivers/char/hw_random/Kconfig | 13 ++ drivers/char/hw_random/Makefile | 1 + drivers/char/hw_random/airoha-trng.c | 243 +++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 drivers/char/hw_random/airoha-trng.cdrivers/char/hw_random/Kconfig +3
-0@@ -62,6 +62,19 @@ config HW_RANDOM_AMD If unsure, say Y. +config HW_RANDOM_AIROHA + tristate "Airoha True HW Random Number Generator support" + depends on ARCH_AIROHA || COMPILE_TEST
Quoted 5 lines
Quoted 3 lines
drivers/char/hw_random/Kconfig config HW_RANDOM_AMD · line 68
Quoted 1 line
drivers/char/hw_random/Kconfig +1
-0+ default HW_RANDOMThis should not be always enabled when
HW_RANDOMis enabled. Enabling driver should be a opt-in.Was following the pattern with other
HW_RANDOMconfig. Ok will drop.
Whoops. I missed that it depends on ARCH_AIROHA. Given that dependency is fine to me without any change.
Francesco
Quoted 7 lines · Christian Marangi
Add support for Airoha EN7581 True Random Number generator.
This module can generate up to 4bytes of raw data at times and support self health test at startup. The module gets noise for randomness from various source from ADC, AP, dedicated clocks and other devices attached to the SoC producing true random numbers.
Quoted 6 lines
Signed-off-by Christian Marangi <[email protected]>--- .../bindings/rng/airoha,en7581-trng.yaml | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/rng/airoha,en7581-trng.yaml