Commit 74a22fce authored by Marek Behún's avatar Marek Behún Committed by Arnd Bergmann
Browse files

platform: cznic: turris-omnia-mcu: Make poweroff and wakeup code optional



Make the system poweroff and RTC wakeup part of the driver optional,
under a boolean config option. Move the dependency to RTC_CLASS to this
new option.

This makes the turris-omnia-mcu driver available for compilation even if
RTC_CLASS 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-4-kabel@kernel.org


Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent c7da0d4e
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -18,15 +18,11 @@ config TURRIS_OMNIA_MCU
	depends on I2C
	depends on OF
	depends on GPIOLIB
	depends on RTC_CLASS
	select GPIOLIB_IRQCHIP
	help
	  Say Y here to add support for the features implemented by the
	  microcontroller on the CZ.NIC's Turris Omnia SOHO router.
	  The features include:
	  - board poweroff into true low power mode (with voltage regulators
	    disabled) and the ability to configure wake up from this mode (via
	    rtcwake)
	  - GPIO pins
	    - to get front button press events (the front button can be
	      configured either to generate press events to the CPU or to change
@@ -45,6 +41,15 @@ config TURRIS_OMNIA_MCU

if TURRIS_OMNIA_MCU

config TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
	bool "Turris Omnia MCU system off and RTC wakeup"
	default y
	depends on RTC_CLASS
	help
	  Say Y here to add support for CZ.NIC's Turris Omnia board poweroff
	  into true low power mode (with voltage regulators disabled) and the
	  ability to configure wake up from this mode (via rtcwake).

config TURRIS_OMNIA_MCU_WATCHDOG
	bool "Turris Omnia MCU watchdog"
	default y
+1 −1
Original line number Diff line number Diff line
@@ -3,6 +3,6 @@
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-gpio.o
turris-omnia-mcu-y		+= turris-omnia-mcu-sys-off-wakeup.o
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP)	+= turris-omnia-mcu-sys-off-wakeup.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
+2 −0
Original line number Diff line number Diff line
@@ -198,7 +198,9 @@ static const struct attribute_group omnia_mcu_base_group = {
static const struct attribute_group *omnia_mcu_groups[] = {
	&omnia_mcu_base_group,
	&omnia_mcu_gpio_group,
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
	&omnia_mcu_poweroff_group,
#endif
	NULL
};

+11 −2
Original line number Diff line number Diff line
@@ -42,10 +42,12 @@ struct omnia_mcu {
	unsigned long last_status;
	bool button_pressed_emul;

#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
	/* RTC device for configuring wake-up */
	struct rtc_device *rtcdev;
	u32 rtc_alarm;
	bool front_button_poweron;
#endif

#ifdef CONFIG_TURRIS_OMNIA_MCU_WATCHDOG
	/* MCU watchdog */
@@ -188,10 +190,17 @@ static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd,

extern const u8 omnia_int_to_gpio_idx[32];
extern const struct attribute_group omnia_mcu_gpio_group;
extern const struct attribute_group omnia_mcu_poweroff_group;

int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);

#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
extern const struct attribute_group omnia_mcu_poweroff_group;
int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu);
#else
static inline int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu)
{
	return 0;
}
#endif

#ifdef CONFIG_TURRIS_OMNIA_MCU_TRNG
int omnia_mcu_register_trng(struct omnia_mcu *mcu);