3 #include <linux/time.h>
5 #include <asm/ds1216.h>
7 volatile unsigned char *ds1216_base;
10 * Read the 64 bit we'd like to have - It a series
11 * of 64 bits showing up in the LSB of the base register.
14 static unsigned char *ds1216_read(void)
16 static unsigned char rdbuf[8];
20 for (i = 0; i < 8; i++) {
22 for (j = 0; j < 8; j++) {
23 c |= (*ds1216_base & 0x1) << j;
31 static void ds1216_switch_ds_to_clock(void)
33 unsigned char magic[] = {
34 0xc5, 0x3a, 0xa3, 0x5c, 0xc5, 0x3a, 0xa3, 0x5c
38 /* Reset magic pointer */
41 /* Write 64 bit magic to DS1216 */
42 for (i = 0; i < 8; i++) {
44 for (j = 0; j < 8; j++) {
51 unsigned long ds1216_get_cmos_time(void)
54 unsigned int year, month, date, hour, min, sec;
56 ds1216_switch_ds_to_clock();
57 rdbuf = ds1216_read();
59 sec = BCD2BIN(DS1216_SEC(rdbuf));
60 min = BCD2BIN(DS1216_MIN(rdbuf));
61 hour = BCD2BIN(DS1216_HOUR(rdbuf));
62 date = BCD2BIN(DS1216_DATE(rdbuf));
63 month = BCD2BIN(DS1216_MONTH(rdbuf));
64 year = BCD2BIN(DS1216_YEAR(rdbuf));
66 if (DS1216_1224(rdbuf) && DS1216_AMPM(rdbuf))
74 return mktime(year, month, date, hour, min, sec);
77 int ds1216_set_rtc_mmss(unsigned long nowtime)
79 printk("ds1216_set_rtc_mmss called but not implemented\n");