Lines Matching +full:turris +full:- +full:omnia +full:- +full:mcu
1 // SPDX-License-Identifier: GPL-2.0
3 * CZ.NIC's Turris Omnia MCU system off and RTC wakeup driver
6 * real-time clock), rather the MCU implements a wakeup from powered off state
7 * at a specified time relative to MCU boot, and we expose this feature via RTC
25 #include <linux/turris-omnia-mcu-interface.h>
26 #include "turris-omnia-mcu.h"
65 struct omnia_mcu *mcu = i2c_get_clientdata(client); in omnia_read_alarm() local
73 alrm->enabled = !!wakeup; in omnia_read_alarm()
74 rtc_time64_to_tm(wakeup ?: mcu->rtc_alarm, &alrm->time); in omnia_read_alarm()
82 struct omnia_mcu *mcu = i2c_get_clientdata(client); in omnia_set_alarm() local
84 mcu->rtc_alarm = rtc_tm_to_time64(&alrm->time); in omnia_set_alarm()
86 if (alrm->enabled) in omnia_set_alarm()
88 mcu->rtc_alarm); in omnia_set_alarm()
96 struct omnia_mcu *mcu = i2c_get_clientdata(client); in omnia_alarm_irq_enable() local
99 enabled ? mcu->rtc_alarm : 0); in omnia_alarm_irq_enable()
111 struct omnia_mcu *mcu = data->cb_data; in omnia_power_off() local
117 if (mcu->front_button_poweron) in omnia_power_off()
127 * Although all values from and to MCU are passed in little-endian, the in omnia_power_off()
128 * MCU's CRC unit uses big-endian CRC32 polynomial (0x04c11db7), so we in omnia_power_off()
134 err = omnia_cmd_write(mcu->client, cmd, sizeof(cmd)); in omnia_power_off()
136 dev_err(&mcu->client->dev, in omnia_power_off()
144 struct omnia_mcu *mcu = data->cb_data; in omnia_restart() local
155 err = omnia_cmd_write(mcu->client, cmd, sizeof(cmd)); in omnia_restart()
157 dev_err(&mcu->client->dev, in omnia_restart()
161 * MCU needs a little bit to process the I2C command, otherwise it will in omnia_restart()
172 struct omnia_mcu *mcu = dev_get_drvdata(dev); in front_button_poweron_show() local
174 return sysfs_emit(buf, "%d\n", mcu->front_button_poweron); in front_button_poweron_show()
181 struct omnia_mcu *mcu = dev_get_drvdata(dev); in front_button_poweron_store() local
189 mcu->front_button_poweron = val; in front_button_poweron_store()
204 struct omnia_mcu *mcu = dev_get_drvdata(dev); in poweroff_attrs_visible() local
206 if (mcu->features & OMNIA_FEAT_POWEROFF_WAKEUP) in poweroff_attrs_visible()
207 return a->mode; in poweroff_attrs_visible()
217 int omnia_mcu_register_sys_off_and_wakeup(struct omnia_mcu *mcu) in omnia_mcu_register_sys_off_and_wakeup() argument
219 struct device *dev = &mcu->client->dev; in omnia_mcu_register_sys_off_and_wakeup()
222 /* MCU restart is always available */ in omnia_mcu_register_sys_off_and_wakeup()
225 omnia_restart, mcu); in omnia_mcu_register_sys_off_and_wakeup()
234 if (!(mcu->features & OMNIA_FEAT_POWEROFF_WAKEUP)) in omnia_mcu_register_sys_off_and_wakeup()
239 omnia_power_off, mcu); in omnia_mcu_register_sys_off_and_wakeup()
244 mcu->rtcdev = devm_rtc_allocate_device(dev); in omnia_mcu_register_sys_off_and_wakeup()
245 if (IS_ERR(mcu->rtcdev)) in omnia_mcu_register_sys_off_and_wakeup()
246 return dev_err_probe(dev, PTR_ERR(mcu->rtcdev), in omnia_mcu_register_sys_off_and_wakeup()
249 mcu->rtcdev->ops = &omnia_rtc_ops; in omnia_mcu_register_sys_off_and_wakeup()
250 mcu->rtcdev->range_max = U32_MAX; in omnia_mcu_register_sys_off_and_wakeup()
251 set_bit(RTC_FEATURE_ALARM_WAKEUP_ONLY, mcu->rtcdev->features); in omnia_mcu_register_sys_off_and_wakeup()
253 err = devm_rtc_register_device(mcu->rtcdev); in omnia_mcu_register_sys_off_and_wakeup()
257 mcu->front_button_poweron = true; in omnia_mcu_register_sys_off_and_wakeup()