Quelle turris-omnia-mcu-sys-off-wakeup.c
Sprache: C
// SPDX-License-Identifier: GPL-2.0 /* * CZ.NIC's Turris Omnia MCU system off and RTC wakeup driver * * This is not a true RTC driver (in the sense that it does not provide a * real-time clock), rather the MCU implements a wakeup from powered off state * at a specified time relative to MCU boot, and we expose this feature via RTC * alarm, so that it can be used via the rtcwake command, which is the standard * Linux command for this. * * 2024 by Marek Behún <kabel@kernel.org>
*/
/* * Although all values from and to MCU are passed in little-endian, the * MCU's CRC unit uses big-endian CRC32 polynomial (0x04c11db7), so we * need to use crc32_be() here.
*/
tmp = cpu_to_be32(get_unaligned_le32(&cmd[1]));
put_unaligned_le32(crc32_be(~0, (void *)&tmp, sizeof(tmp)), &cmd[5]);
err = omnia_cmd_write(mcu->client, cmd, sizeof(cmd)); if (err)
dev_err(&mcu->client->dev, "Unable to send the poweroff command: %d\n", err);
int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu)
{ struct device *dev = &mcu->client->dev; int err;
/* MCU restart is always available */
err = devm_register_sys_off_handler(dev, SYS_OFF_MODE_RESTART,
SYS_OFF_PRIO_FIRMWARE,
omnia_restart, mcu); if (err) return dev_err_probe(dev, err, "Cannot register system restart handler\n");
/* * Poweroff and wakeup are available only if POWEROFF_WAKEUP feature is * present.
*/ if (!(mcu->features & OMNIA_FEAT_POWEROFF_WAKEUP)) return 0;
err = devm_register_sys_off_handler(dev, SYS_OFF_MODE_POWER_OFF,
SYS_OFF_PRIO_FIRMWARE,
omnia_power_off, mcu); if (err) return dev_err_probe(dev, err, "Cannot register system power off handler\n");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.