Commit graph

274 commits

Author SHA1 Message Date
Ioannis Karachalios 97bd924f59 drivers: entropy: smartbond: Bug fix
This commit should fix few wrong expressions

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2024-05-16 18:55:18 -04:00
Ioannis Karachalios 6771e79729 drivers: entropy: smartbond: Add support for PM
This commit should add all the functionality needed for the entropy
driver to work when PM is enabled.

Signed-off-by: Ioannis Karachalios <ioannis.karachalios.px@renesas.com>
2024-05-15 16:09:32 +02:00
Tomi Fontanilles 43651979fc drivers: entropy: fix TF-M enabled build with MbedTLS 3.6.0
This fixes the compilation of entropy_psa_crypto.c that failed
when trying to include the MbedTLS configuration.

Inherit the needed include folders and definitions from tfm_api.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-02 09:42:34 -07:00
David Leach 00b46686b1 drivers: lpc55s36: Remove deprecated CSS driver
CSS was deprecated from the mcu-sdk. Removing driver from lpc55s36
to clear build error.

This is a temporary patch to remove the build error.

Fixes #69961

Signed-off-by: David Leach <david.leach@nxp.com>
2024-04-10 14:11:34 -04:00
Lucas Tamborrino fe57a12cf2 drivers: esp32: update to hal_espressif v5.1
Modify necessary drivers to meet updated hal.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-04-05 13:39:53 +02:00
Jun Lin 6057a83060 drivers: entropy: npcx: add rng driver support
This commit add the rng driver support by using the npcx drgb API.

Signed-off-by: Jun Lin <CHLin56@nuvoton.com>
2024-03-14 18:14:04 +00:00
John Johnson c13930791d drivers: entropy: stm32: fix missing rng in function call
Replace rng to dev_data->rng in call to LL_RNG_SetHealthConfig.

Signed-off-by: John Johnson <john.filip.johnson@gmail.com>
2024-02-28 07:44:41 -06:00
Henrik Brix Andersen ded0d48779 drivers: entropy: neorv32: add missing soc.h include
Add missing soc.h include for NEORV32_SYSINFO_FEATURES.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-13 10:42:04 +01:00
Alberto Escolar Piedras 404db20877 drivers/entropy/native: Define required SOURCE macro
The srandom function is not available
unless _XOPEN_SOURCE is set > 500 or an equivalent
declaration is done.
Let's set it.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-26 07:48:55 -05:00
Alberto Escolar Piedras c6ed39e3ad drivers entropy fake_native: Add option to seed generator randomly
Add a command line option which will seed the random generator
from /dev/urandom.
This can be usefull for some particular tests in which we are
interested in having different random numbers in each run,
but we cannot provide a different random seed from command line.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-01-25 12:28:51 +01:00
Guillaume Gautier 5aff88ab93 drivers: entropy: stm32: reinit rng when exiting suspend to ram
With PM, when resuming from low power mode, reenable the RNG register
clocks and check the health register. If it is not set to the desired
value, it means we exit Suspend to RAM mode, and that the RNG needs to be
reinitialized.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-01-25 08:55:02 +01:00
Guillaume Gautier b8fdcbb59e drivers: entropy: stm32: prevent suspend to ram when operation in progress
Prevent the system to enter Suspend to RAM state while RNG operation is
in progress.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-01-25 08:55:02 +01:00
Markus Swarowsky 11175c3ad3 tf-m: Change NS include path for TF-M 2.0.0
The place where TF-M places its non-secure api header files has changed
Therefore changing it for for all applications that use it.

Signed-off-by: Markus Swarowsky <markus.swarowsky@nordicsemi.no>
2024-01-17 16:52:52 +01:00
Erwan Gouriou 2908458554 soc: stm32wba: hci_if: Implement HW_RNG_EnableClock API
STM32WBA controller uses a PKA driver to perform cyphering operations
on keys. Since PKA hardware block requires RNG clock to be enabled, a
synchronization with zephyr RNG driver is needed.

Use RNG enable status to check if RNG could be switched off or needs to
be switched on.
Similarly in entropy driver, don't cut RNG clock if PKA is enabled.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-12-21 09:18:53 +01:00
Dawid Niedzwiecki b0753d9c10 entropy: stm32: enable interrupt when RNG is resumed
Enable the RNG module interrupt every time it is resumed.

It is done to make sure the interrupt is always enabled. The CR register
may not persist when the device clock is disabled on some chips.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-12-14 19:07:19 +00:00
Dawid Niedzwiecki 87f2486e1c entropy: stm32: enable rng module if needed
Move enabling/disabling the RNG module to acquire/release functions.
It causes enabling the RNG module for the get_entropy_isr function.

It fixes hanging in the get_entropy_isr function.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-12-14 19:07:19 +00:00
Florian La Roche fdcfec0328 drivers: entropy: entropy_esp32.c: remove not necessary cast
This cast already has the correct type on both sides, so it
can be removed.

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
2023-12-13 20:12:54 +01:00
Dawid Niedzwiecki 78af1c1e38 entropy: stm32: suspend when pool is full
Suspend the RNG module when the pool is full to save power. The
generated numbers aren't used anyway.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-12-05 16:27:53 -06:00
Erwan Gouriou 321c5e8656 drivers: entropy: stm32: Move irq_lock at init
Perform clock check inside irq_lock in order to exit cleanly
if failing.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-11-15 10:00:50 +01:00
Sebastian Bøe 1f0b4c62a2 drivers: entropy: psa: Don't have PSA_CRYPTO_RNG depend on TF-M
Remove the depenency on TF-M so that this driver can be used when PSA
is provided by something else than TF-M.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2023-11-09 11:22:26 +01:00
Anas Nashif a08bfeb49c syscall: rename Z_OOPS -> K_OOPS
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 1a9de05767 syscall: rename Z_SYSCALL_DRIVER_ -> K_SYSCALL_DRIVER_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 9c4d881183 syscall: rename Z_SYSCALL_ to K_SYSCALL_
Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Anas Nashif 4e396174ce kernel: move syscall_handler.h to internal include directory
Move the syscall_handler.h header, used internally only to a dedicated
internal folder that should not be used outside of Zephyr.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-11-03 11:46:52 +01:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Flavio Ceolin 39068456c4 entropy: sam: Remove unused parameter
Do not propagate unused parameter. ISR callback is already handling
the given flags, there is not need to propagate it through internal
calls.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Flavio Ceolin 78af988546 entropy: sam: Fix get_entropy() behavior
entropy_get_entropy blocks if required to generate the necessary
random data.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Flavio Ceolin 1dcaf4637e entropy: fake_entropy: Fix return value in isr callback
get_entropy_isr() has to return the number of bytes copied or
a negative value in case of error.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Flavio Ceolin 58b0c8f4b7 entropy: neorv32: Return ENODATA on error
Return -ENODATA in neorv32_trng_get_entropy_isr when
there is no data available. This is consistent with other
drivers.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Flavio Ceolin 5133ac8af4 entropy: b91_trng: Fix callback return
get_entropy_isr() has to return the number of bytes copied or a negative
value for error. Since this driver is assuming that it will always
(????) get the number of requested bytes, change the function to return it
instead of 0.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Flavio Ceolin ff074551b0 entropy: gecko_se: Remove unnecessary callback
get_entropy_isr is not implemented, just remove it and let the
driver interface handle it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-09 10:16:19 +02:00
Carles Cufi a5e7ba3564 Bluetooth: Controller: Remove legacy BT_CTLR_FAST_ENC option
When the legacy LLCP implementation was removed this Kconfig option was
mistakenly left over. Remove it now with all its users.

Fixes #63212.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 13:32:33 +03:00
Erwan Gouriou 9f52fac1ea driver: entropy: stm32: Enable PM
Enable PM on STM32 entropy driver.
Only supports PM_DEVICE for now, runtime support will be added later.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-09-13 11:50:04 +02:00
Alberto Escolar Piedras 8252e99608 drivers: entropy native: Refactor to support embedded libCs
Refactor the host libC accesses to use the native simulator
host trampolines.

In this way we support building this driver with embedded libCs.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-07 14:32:41 +02:00
Alberto Escolar Piedras abf6da6318 drivers for POSIX arch: Add external libc dependencies
Quite a few of the drivers meant for the POSIX arch
interacted with the host directly, and will not
work when we use an embedded libC.

Until we fix them, let's add the appropriate
kconfig dependencies to avoid users trying to build them.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-07-05 07:01:19 -04:00
Filip Kokosinski d644bebd93 drivers/entropy/gecko_trng: select the correct RNGOUT_FIFO_MEM_BASE
This commit introduces a preprocessor checking mechanism for selecting the
correct RNGOUT FIFO memory base address depending on whether SL_TRUSTZONE
is used.

Fixes #59197.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2023-06-20 09:25:45 +02:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Patryk Duda 5cb40310f4 drivers: entropy: Make entropy_stm32.c clang compatible
Clang doesn't support push_options, pop_options and optimize pragmas.
Since "Ofast" is only applied to rng_pool_get() we can use function
attributes instead of pragmas.

Please note that clang doesn't support applying optimizations to
functions.

This change was verified by comparing assembler output.

Signed-off-by: Patryk Duda <pdk@semihalf.com>
2023-05-31 14:41:25 -04:00
Carlo Caione cb11b2e84b barriers: Move __DSB() to the new API
Remove the arch-specific ARM-centric __DSB() macro and use the new
barrier API instead.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-05-24 13:13:57 -04:00
Declan Snyder f4c2dc54b4 drivers: entropy_mcux_caam: Add semaphore
Add a semaphore to the entropy mcux caam driver
to make the driver thread safe, since some static
variables in the HAL can be the source of
some race conditions.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-05-09 13:24:00 -05:00
Roman Dobrodii f9e2d064c4 drivers/entropy/entropy_gecko_trng: support BG27
Add TRNG support for BG27, which has slightly different register
definitions in HAL, compared to BG22.

Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
2023-04-24 13:35:46 +02:00
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Erwan Gouriou 8e5a2cd45c drivers: entropy: stm32: Move clock check to post kernel operations
Don't check clock configuration before kernel was started since it
will prevent message to be displayed.
After kernel initialization, message is still valid and then ASSERT
more valuable to the user.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-04-14 14:04:26 +02:00
Pieter De Gendt 6b532ff43e treewide: Update clock control API usage
Replace all (clock_control_subsys_t *) casts with (clock_control_subsys_t)

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2023-04-05 10:55:46 +02:00
Henrik Brix Andersen c41dd36de2 drivers: kconfig: unify menuconfig title strings
Unify the drivers/*/Kconfig menuconfig title strings to the format
"<class> [(acronym)] [bus] drivers".

Including both the full name of the driver class and an acronym makes
menuconfig more user friendly as some of the acronyms are less well-known
than others. It also improves Kconfig search, both via menuconfig and via
the generated Kconfig documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-28 15:06:06 +02:00
Gerson Fernando Budke 91e219c644 drivers: entropy: sam/sam0: Update to use clock control
This update Atmel SAM trng driver to use clock control driver.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2023-03-21 14:12:25 -07:00
Ben Lauret 36ac1ee2a2 drivers: entropy: add Renesas SmartBond entropy generator driver
This adds driver for SmartBond TRNG peripheral that with separate
ISR an thread data pools.

Co-authored-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>

Signed-off-by: Ben Lauret <ben.lauret.wm@renesas.com>
2023-03-03 11:01:36 +01:00
Andrzej Głąbek 68bd036947 drivers: entropy_nrf5: Eliminate direct use of WFE instructions
Use the appropriate kernel function, i.e. `k_cpu_atomic_idle()`,
instead of directly executing the WFE instruction.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2023-02-21 15:02:54 +01:00
David Leach cde1573619 drivers: entropy: use non-cache intermediate buffer for RNG
The CAAM hardware needs to read RNG values into a non-cache
buffer. Since the contract to Zephyr RNG functions do not
require non-cache buffers, we use an intermediate non-cache
buffer to retrieve results.

Added a Kconfig to control the size of the intermediate buffer.

Fixes #53035

Signed-off-by: David Leach <david.leach@nxp.com>
2023-01-26 09:46:20 -06:00
Erwan Gouriou 8725edc134 drivers: entropy: stm32: Check clock config at runtime
RNG clock configuration constraints differ between each series.
Rather than providing complex build time code to verify RNG clock
configuration is correct, take advantage of CECS bit (Clock error
current status) to assess clock configuration.

This check is implemented under a specific ENTROPY_STM32_CLK_CHECK
Kconfig option. This allows user to disable this feature in specific
conditions:
- CED bit disabled in application (in which case CECS status is not valid)
- Clock configuration is deemed as correct by user. Note that RNG number
  are always generated, whatever the clock status.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-18 09:56:03 +01:00