/* All current Au1xxx SoCs have 2 counters fed by an external 32.768 kHz *crystal.Counter0,whichkeepscountingduringsleep/powerdown,is *usedtocountsecondssincethebeginningoftheunixepoch. * *Thecountersmustbeconfiguredandenabledbybootloader/boardcode; *nochecksastowhethertheyreallygetaproper32.768kHzclockare *madeasthiswouldtakefartoolong.
*/
/* wait for the pending register write to succeed. This can *takeupto6seconds...
*/ while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
msleep(1);
t = alchemy_rdsys(AU1000_SYS_CNTRCTRL); if (!(t & CNTR_OK)) {
dev_err(&pdev->dev, "counters not working; aborting.\n"); return -ENODEV;
}
/* set counter0 tickrate to 1Hz if necessary */ if (alchemy_rdsys(AU1000_SYS_TOYTRIM) != 32767) { /* wait until hardware gives access to TRIM register */
t = 0x00100000; while ((alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_T0S) && --t)
msleep(1);
if (!t) { /* timed out waiting for register access; assume *countersareunusable.
*/
dev_err(&pdev->dev, "timeout waiting for access\n"); return -ETIMEDOUT;
}
/* set 1Hz TOY tick rate */
alchemy_wrsys(32767, AU1000_SYS_TOYTRIM);
}
/* wait until the hardware allows writes to the counter reg */ while (alchemy_rdsys(AU1000_SYS_CNTRCTRL) & SYS_CNTRL_C0S)
msleep(1);
rtcdev = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtcdev)) return PTR_ERR(rtcdev);
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.