/* Time Of Year(TOY) counters registers */ #define TOY_TRIM_REG 0x20 /* Must be initialized to 0 */ #define TOY_WRITE0_REG 0x24 /* TOY low 32-bits value (write-only) */ #define TOY_WRITE1_REG 0x28 /* TOY high 32-bits value (write-only) */ #define TOY_READ0_REG 0x2c /* TOY low 32-bits value (read-only) */ #define TOY_READ1_REG 0x30 /* TOY high 32-bits value (read-only) */ #define TOY_MATCH0_REG 0x34 /* TOY timing interrupt 0 */ #define TOY_MATCH1_REG 0x38 /* TOY timing interrupt 1 */ #define TOY_MATCH2_REG 0x3c /* TOY timing interrupt 2 */
/* RTC counters registers */ #define RTC_CTRL_REG 0x40 /* TOY and RTC control register */ #define RTC_TRIM_REG 0x60 /* Must be initialized to 0 */ #define RTC_WRITE0_REG 0x64 /* RTC counters value (write-only) */ #define RTC_READ0_REG 0x68 /* RTC counters value (read-only) */ #define RTC_MATCH0_REG 0x6c /* RTC timing interrupt 0 */ #define RTC_MATCH1_REG 0x70 /* RTC timing interrupt 1 */ #define RTC_MATCH2_REG 0x74 /* RTC timing interrupt 2 */
/* PM domain registers */ #define PM1_STS_REG 0x0c /* Power management 1 status register */ #define RTC_STS BIT(10) /* RTC status */ #define PM1_EN_REG 0x10 /* Power management 1 enable register */ #define RTC_EN BIT(10) /* RTC event enable */
/* * According to the LS1C manual, RTC_CTRL and alarm-related registers are not defined. * Accessing the relevant registers will cause the system to hang.
*/ #define LS1C_RTC_CTRL_WORKAROUND BIT(0)
ret = regmap_read(priv->regmap, TOY_MATCH0_REG, &alarm_data); if (ret < 0) return ret;
alrm->time.tm_sec = FIELD_GET(TOY_MATCH_SEC, alarm_data);
alrm->time.tm_min = FIELD_GET(TOY_MATCH_MIN, alarm_data);
alrm->time.tm_hour = FIELD_GET(TOY_MATCH_HOUR, alarm_data);
alrm->time.tm_mday = FIELD_GET(TOY_MATCH_DAY, alarm_data);
alrm->time.tm_mon = FIELD_GET(TOY_MATCH_MON, alarm_data) - 1; /* * This is a hardware bug: the year field of SYS_TOYMATCH is only 6 bits, * making it impossible to save year values larger than 64. * * SYS_TOYMATCH is used to match the alarm time value and determine if * an alarm is triggered, so we must keep the lower 6 bits of the year * value constant during the value conversion. * * In summary, we need to manually add 64(or a multiple of 64) to the * year value to avoid the invalid alarm prompt at startup.
*/
alrm->time.tm_year = FIELD_GET(TOY_MATCH_YEAR, alarm_data) + priv->fix_year;
if (has_acpi_companion(dev))
acpi_install_fixed_event_handler(ACPI_EVENT_RTC,
loongson_rtc_handler, priv);
} else { /* Loongson-1C RTC does not support alarm */
clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features);
}
/* Loongson RTC does not support UIE */
clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features);
priv->rtcdev->ops = &loongson_rtc_ops;
priv->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000;
priv->rtcdev->range_max = RTC_TIMESTAMP_END_2099;
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.