Commit c7da0d4e authored by Marek Behún's avatar Marek Behún Committed by Arnd Bergmann

platform: cznic: turris-omnia-mcu: Make TRNG code optional

Make the TRNG part of the driver optional, under a boolean config
option.

This makes the driver turris-omnia-mcu available for compilation even if
HW_RANDOM is disabled.

Fixes: ed46f1f7 ("platform: cznic: turris-omnia-mcu: fix Kconfig dependencies")
Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
Link: https://lore.kernel.org/r/20240719085756.30598-3-kabel@kernel.orgSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 019f87f1
...@@ -18,7 +18,6 @@ config TURRIS_OMNIA_MCU ...@@ -18,7 +18,6 @@ config TURRIS_OMNIA_MCU
depends on I2C depends on I2C
depends on OF depends on OF
depends on GPIOLIB depends on GPIOLIB
depends on HW_RANDOM
depends on RTC_CLASS depends on RTC_CLASS
select GPIOLIB_IRQCHIP select GPIOLIB_IRQCHIP
help help
...@@ -28,7 +27,6 @@ config TURRIS_OMNIA_MCU ...@@ -28,7 +27,6 @@ config TURRIS_OMNIA_MCU
- board poweroff into true low power mode (with voltage regulators - board poweroff into true low power mode (with voltage regulators
disabled) and the ability to configure wake up from this mode (via disabled) and the ability to configure wake up from this mode (via
rtcwake) rtcwake)
- true random number generator (if available on the MCU)
- GPIO pins - GPIO pins
- to get front button press events (the front button can be - to get front button press events (the front button can be
configured either to generate press events to the CPU or to change configured either to generate press events to the CPU or to change
...@@ -56,6 +54,14 @@ config TURRIS_OMNIA_MCU_WATCHDOG ...@@ -56,6 +54,14 @@ config TURRIS_OMNIA_MCU_WATCHDOG
Say Y here to add support for watchdog provided by CZ.NIC's Turris Say Y here to add support for watchdog provided by CZ.NIC's Turris
Omnia MCU. Omnia MCU.
config TURRIS_OMNIA_MCU_TRNG
bool "Turris Omnia MCU true random number generator"
default y
depends on HW_RANDOM
help
Say Y here to add support for the true random number generator
provided by CZ.NIC's Turris Omnia MCU.
endif # TURRIS_OMNIA_MCU endif # TURRIS_OMNIA_MCU
endif # CZNIC_PLATFORMS endif # CZNIC_PLATFORMS
...@@ -4,5 +4,5 @@ obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o ...@@ -4,5 +4,5 @@ obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o
turris-omnia-mcu-y := turris-omnia-mcu-base.o turris-omnia-mcu-y := turris-omnia-mcu-base.o
turris-omnia-mcu-y += turris-omnia-mcu-gpio.o turris-omnia-mcu-y += turris-omnia-mcu-gpio.o
turris-omnia-mcu-y += turris-omnia-mcu-sys-off-wakeup.o turris-omnia-mcu-y += turris-omnia-mcu-sys-off-wakeup.o
turris-omnia-mcu-y += turris-omnia-mcu-trng.o turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_TRNG) += turris-omnia-mcu-trng.o
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG) += turris-omnia-mcu-watchdog.o turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG) += turris-omnia-mcu-watchdog.o
...@@ -52,9 +52,11 @@ struct omnia_mcu { ...@@ -52,9 +52,11 @@ struct omnia_mcu {
struct watchdog_device wdt; struct watchdog_device wdt;
#endif #endif
#ifdef CONFIG_TURRIS_OMNIA_MCU_TRNG
/* true random number generator */ /* true random number generator */
struct hwrng trng; struct hwrng trng;
struct completion trng_entropy_ready; struct completion trng_entropy_ready;
#endif
}; };
int omnia_cmd_write_read(const struct i2c_client *client, int omnia_cmd_write_read(const struct i2c_client *client,
...@@ -190,7 +192,15 @@ extern const struct attribute_group omnia_mcu_poweroff_group; ...@@ -190,7 +192,15 @@ extern const struct attribute_group omnia_mcu_poweroff_group;
int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu); int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);
int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu); int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu);
#ifdef CONFIG_TURRIS_OMNIA_MCU_TRNG
int omnia_mcu_register_trng(struct omnia_mcu *mcu); int omnia_mcu_register_trng(struct omnia_mcu *mcu);
#else
static inline int omnia_mcu_register_trng(struct omnia_mcu *mcu)
{
return 0;
}
#endif
#ifdef CONFIG_TURRIS_OMNIA_MCU_WATCHDOG #ifdef CONFIG_TURRIS_OMNIA_MCU_WATCHDOG
int omnia_mcu_register_watchdog(struct omnia_mcu *mcu); int omnia_mcu_register_watchdog(struct omnia_mcu *mcu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment