diff options
author | Marek Behún <kabel@kernel.org> | 2024-07-01 13:30:06 +0200 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2024-07-01 15:46:37 +0200 |
commit | 90e700fd12b618449d2f61e6f933ba5ac435831d (patch) | |
tree | a7236a3375add9fe3ca06db7f7d54549c07a786d /drivers/platform/cznic/turris-omnia-mcu.h | |
parent | dfa556e45ae9ecc199e598222debc8f1883a7cce (diff) | |
download | lwn-90e700fd12b618449d2f61e6f933ba5ac435831d.tar.gz lwn-90e700fd12b618449d2f61e6f933ba5ac435831d.zip |
platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup
Add support for true board poweroff (MCU can disable all unnecessary
voltage regulators) and wakeup at a specified time, implemented via a
RTC driver so that the rtcwake utility can be used to configure it.
Signed-off-by: Marek Behún <kabel@kernel.org>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://lore.kernel.org/r/20240701113010.16447-5-kabel@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'drivers/platform/cznic/turris-omnia-mcu.h')
-rw-r--r-- | drivers/platform/cznic/turris-omnia-mcu.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/platform/cznic/turris-omnia-mcu.h b/drivers/platform/cznic/turris-omnia-mcu.h index 3d2dd0054499..2a1c68ba9b7f 100644 --- a/drivers/platform/cznic/turris-omnia-mcu.h +++ b/drivers/platform/cznic/turris-omnia-mcu.h @@ -15,8 +15,10 @@ #include <linux/types.h> #include <linux/workqueue.h> #include <asm/byteorder.h> +#include <asm/unaligned.h> struct i2c_client; +struct rtc_device; struct omnia_mcu { struct i2c_client *client; @@ -36,6 +38,11 @@ struct omnia_mcu { struct delayed_work button_release_emul_work; unsigned long last_status; bool button_pressed_emul; + + /* RTC device for configuring wake-up */ + struct rtc_device *rtcdev; + u32 rtc_alarm; + bool front_button_poweron; }; int omnia_cmd_write_read(const struct i2c_client *client, @@ -48,6 +55,17 @@ static inline int omnia_cmd_write(const struct i2c_client *client, void *cmd, return omnia_cmd_write_read(client, cmd, len, NULL, 0); } +static inline int omnia_cmd_write_u32(const struct i2c_client *client, u8 cmd, + u32 val) +{ + u8 buf[5]; + + buf[0] = cmd; + put_unaligned_le32(val, &buf[1]); + + return omnia_cmd_write(client, buf, sizeof(buf)); +} + static inline int omnia_cmd_read(const struct i2c_client *client, u8 cmd, void *reply, unsigned int len) { @@ -136,7 +154,9 @@ static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd, } 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); +int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu); #endif /* __TURRIS_OMNIA_MCU_H */ |