/* * S32G2 and S32G3 SoCs have RTC clock source1 reserved and * should not be used.
*/ #define RTC_CLK_SRC1_RESERVED BIT(1)
/* * S32G RTC module has a 512 value and a 32 value hardware frequency * divisors (DIV512 and DIV32) which could be used to achieve higher * counter ranges by lowering the RTC frequency.
*/ enum {
DIV1 = 1,
DIV32 = 32,
DIV512 = 512,
DIV512_32 = 16384
};
/* * The function is not really getting time from the RTC since the S32G RTC * has several limitations. Thus, to setup alarm use system time.
*/ staticint s32g_rtc_read_time(struct device *dev, struct rtc_time *tm)
{ struct rtc_priv *priv = dev_get_drvdata(dev);
time64_t sec;
if (check_add_overflow(ktime_get_real_seconds(),
priv->sleep_sec, &sec)) return -ERANGE;
/* RTC API functionality is used both for triggering interrupts * and as a wakeup event. Hence it should always be enabled.
*/
rtcc = readl(priv->rtc_base + RTCC_OFFSET);
rtcc |= RTCC_APIEN | RTCC_APIIE;
writel(rtcc, priv->rtc_base + RTCC_OFFSET);
/* APIVAL could have been reset from the IRQ handler. * Hence, we wait in case there is a synchronization process.
*/
ret = read_poll_timeout(readl, rtcs, !(rtcs & RTCS_INV_API),
0, RTC_SYNCH_TIMEOUT, false, priv->rtc_base + RTCS_OFFSET); if (ret) return ret;
switch (priv->rtc_data->clk_div) { case DIV512_32:
rtcc |= RTCC_DIV512EN;
rtcc |= RTCC_DIV32EN; break; case DIV512:
rtcc |= RTCC_DIV512EN; break; case DIV32:
rtcc |= RTCC_DIV32EN; break; case DIV1: break; default: return -EINVAL;
}
rtcc |= RTCC_APIEN | RTCC_APIIE; /* * Make sure the CNTEN is 0 before we configure * the clock source and dividers.
*/
s32g_rtc_disable(priv);
writel(rtcc, priv->rtc_base + RTCC_OFFSET);
s32g_rtc_enable(priv);
/* The transition from resume to run is a reset event. * This leads to the RTC registers being reset after resume from * suspend. It is uncommon, but this behaviour has been observed * on S32G RTC after issuing a Suspend to RAM operation. * Thus, reconfigure RTC registers on the resume path.
*/ return rtc_clk_src_setup(priv);
}
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.