- rtc_write (RTC_YEAR, bin2bcd(tmp->tm_year % 100));
- rtc_write (RTC_MONTH, bin2bcd(tmp->tm_mon));
-#ifdef CONFIG_AMIGAONEG3SE
- rtc_write (RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday)+1);
-#else
- rtc_write (RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday));
+ mc146818_write8(RTC_YEAR, bin2bcd(tmp->tm_year % 100));
+ mc146818_write8(RTC_MONTH, bin2bcd(tmp->tm_mon));
+ /* Sunday = 1, Saturday = 7 */
+ mc146818_write8(RTC_DAY_OF_WEEK, bin2bcd(tmp->tm_wday + 1));
+ mc146818_write8(RTC_DATE_OF_MONTH, bin2bcd(tmp->tm_mday));
+ mc146818_write8(RTC_HOURS, bin2bcd(tmp->tm_hour));
+ mc146818_write8(RTC_MINUTES, bin2bcd(tmp->tm_min));
+ mc146818_write8(RTC_SECONDS, bin2bcd(tmp->tm_sec));
+
+ /* Enable the RTC to update the regs */
+ mc146818_write8(RTC_CONFIG_B, 0x02);
+
+ return 0;
+}
+
+static void mc146818_reset(void)
+{
+ /* Disable the RTC to update the regs */
+ mc146818_write8(RTC_CONFIG_B, 0x82);
+
+ /* Normal OP */
+ mc146818_write8(RTC_CONFIG_A, 0x20);
+ mc146818_write8(RTC_CONFIG_B, 0x00);
+ mc146818_write8(RTC_CONFIG_B, 0x00);
+
+ /* Enable the RTC to update the regs */
+ mc146818_write8(RTC_CONFIG_B, 0x02);
+}
+
+static void mc146818_init(void)
+{
+#if CLEAR_CMOS
+ int i;
+
+ rtc_write8(RTC_SECONDS_ALARM, 0);
+ rtc_write8(RTC_MINUTES_ALARM, 0);
+ rtc_write8(RTC_HOURS_ALARM, 0);
+ for (i = RTC_CONFIG_A; i < RTC_REG_SIZE; i++)
+ rtc_write8(i, 0);
+ printf("RTC: zeroing CMOS RAM\n");