Skip to content

Commit 74a22fc

Browse files
elkabloarndb
authored andcommitted
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: ed46f1f ("platform: cznic: turris-omnia-mcu: fix Kconfig dependencies") Signed-off-by: Marek Behún <kabel@kernel.org> Link: https://lore.kernel.org/r/20240719085756.30598-4-kabel@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent c7da0d4 commit 74a22fc

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

drivers/platform/cznic/Kconfig

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ config TURRIS_OMNIA_MCU
1818
depends on I2C
1919
depends on OF
2020
depends on GPIOLIB
21-
depends on RTC_CLASS
2221
select GPIOLIB_IRQCHIP
2322
help
2423
Say Y here to add support for the features implemented by the
2524
microcontroller on the CZ.NIC's Turris Omnia SOHO router.
2625
The features include:
27-
- board poweroff into true low power mode (with voltage regulators
28-
disabled) and the ability to configure wake up from this mode (via
29-
rtcwake)
3026
- GPIO pins
3127
- to get front button press events (the front button can be
3228
configured either to generate press events to the CPU or to change
@@ -45,6 +41,15 @@ config TURRIS_OMNIA_MCU
4541

4642
if TURRIS_OMNIA_MCU
4743

44+
config TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
45+
bool "Turris Omnia MCU system off and RTC wakeup"
46+
default y
47+
depends on RTC_CLASS
48+
help
49+
Say Y here to add support for CZ.NIC's Turris Omnia board poweroff
50+
into true low power mode (with voltage regulators disabled) and the
51+
ability to configure wake up from this mode (via rtcwake).
52+
4853
config TURRIS_OMNIA_MCU_WATCHDOG
4954
bool "Turris Omnia MCU watchdog"
5055
default y

drivers/platform/cznic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o
44
turris-omnia-mcu-y := turris-omnia-mcu-base.o
55
turris-omnia-mcu-y += turris-omnia-mcu-gpio.o
6-
turris-omnia-mcu-y += turris-omnia-mcu-sys-off-wakeup.o
6+
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP) += turris-omnia-mcu-sys-off-wakeup.o
77
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_TRNG) += turris-omnia-mcu-trng.o
88
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG) += turris-omnia-mcu-watchdog.o

drivers/platform/cznic/turris-omnia-mcu-base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ static const struct attribute_group omnia_mcu_base_group = {
198198
static const struct attribute_group *omnia_mcu_groups[] = {
199199
&omnia_mcu_base_group,
200200
&omnia_mcu_gpio_group,
201+
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
201202
&omnia_mcu_poweroff_group,
203+
#endif
202204
NULL
203205
};
204206

drivers/platform/cznic/turris-omnia-mcu.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ struct omnia_mcu {
4242
unsigned long last_status;
4343
bool button_pressed_emul;
4444

45+
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
4546
/* RTC device for configuring wake-up */
4647
struct rtc_device *rtcdev;
4748
u32 rtc_alarm;
4849
bool front_button_poweron;
50+
#endif
4951

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

189191
extern const u8 omnia_int_to_gpio_idx[32];
190192
extern const struct attribute_group omnia_mcu_gpio_group;
191-
extern const struct attribute_group omnia_mcu_poweroff_group;
192-
193193
int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);
194+
195+
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
196+
extern const struct attribute_group omnia_mcu_poweroff_group;
194197
int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu);
198+
#else
199+
static inline int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu)
200+
{
201+
return 0;
202+
}
203+
#endif
195204

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

0 commit comments

Comments
 (0)