/* Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.  */
static int aica_rtc_settimeofday(const time_t secs)
/* Adjusts the given @tv to the AICA Epoch and sets the RTC seconds counter.  */
static int aica_rtc_settimeofday(const time_t secs)
{
	unsigned long val1, val2;
	unsigned long adj = secs + TWENTY_YEARS;
	do {
		ctrl_outl((adj & 0xffff0000) >> 16, AICA_RTC_SECS_H);
		ctrl_outl((adj & 0xffff), AICA_RTC_SECS_L);
		val1 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
		val2 = ((ctrl_inl(AICA_RTC_SECS_H) & 0xffff) << 16) |
			(ctrl_inl(AICA_RTC_SECS_L) & 0xffff);
	} while (val1 != val2);
	return 0;
}