Lines Matching refs:tm
88 static void isl12057_rtc_regs_to_tm(struct rtc_time *tm, u8 *regs) in isl12057_rtc_regs_to_tm() argument
90 tm->tm_sec = bcd2bin(regs[ISL12057_REG_RTC_SC]); in isl12057_rtc_regs_to_tm()
91 tm->tm_min = bcd2bin(regs[ISL12057_REG_RTC_MN]); in isl12057_rtc_regs_to_tm()
94 tm->tm_hour = bcd2bin(regs[ISL12057_REG_RTC_HR] & 0x1f); in isl12057_rtc_regs_to_tm()
96 tm->tm_hour += 12; in isl12057_rtc_regs_to_tm()
98 tm->tm_hour = bcd2bin(regs[ISL12057_REG_RTC_HR] & 0x3f); in isl12057_rtc_regs_to_tm()
101 tm->tm_mday = bcd2bin(regs[ISL12057_REG_RTC_DT]); in isl12057_rtc_regs_to_tm()
102 tm->tm_wday = bcd2bin(regs[ISL12057_REG_RTC_DW]) - 1; /* starts at 1 */ in isl12057_rtc_regs_to_tm()
103 tm->tm_mon = bcd2bin(regs[ISL12057_REG_RTC_MO] & 0x1f) - 1; /* ditto */ in isl12057_rtc_regs_to_tm()
104 tm->tm_year = bcd2bin(regs[ISL12057_REG_RTC_YR]) + 100; in isl12057_rtc_regs_to_tm()
108 tm->tm_year += 100; in isl12057_rtc_regs_to_tm()
111 static int isl12057_rtc_tm_to_regs(u8 *regs, struct rtc_time *tm) in isl12057_rtc_tm_to_regs() argument
123 if (tm->tm_year < 100 || tm->tm_year > 299) in isl12057_rtc_tm_to_regs()
126 century_bit = (tm->tm_year > 199) ? ISL12057_REG_RTC_MO_CEN : 0; in isl12057_rtc_tm_to_regs()
128 regs[ISL12057_REG_RTC_SC] = bin2bcd(tm->tm_sec); in isl12057_rtc_tm_to_regs()
129 regs[ISL12057_REG_RTC_MN] = bin2bcd(tm->tm_min); in isl12057_rtc_tm_to_regs()
130 regs[ISL12057_REG_RTC_HR] = bin2bcd(tm->tm_hour); /* 24-hour format */ in isl12057_rtc_tm_to_regs()
131 regs[ISL12057_REG_RTC_DT] = bin2bcd(tm->tm_mday); in isl12057_rtc_tm_to_regs()
132 regs[ISL12057_REG_RTC_MO] = bin2bcd(tm->tm_mon + 1) | century_bit; in isl12057_rtc_tm_to_regs()
133 regs[ISL12057_REG_RTC_YR] = bin2bcd(tm->tm_year % 100); in isl12057_rtc_tm_to_regs()
134 regs[ISL12057_REG_RTC_DW] = bin2bcd(tm->tm_wday + 1); in isl12057_rtc_tm_to_regs()
199 static int _isl12057_rtc_read_time(struct device *dev, struct rtc_time *tm) in _isl12057_rtc_read_time() argument
228 isl12057_rtc_regs_to_tm(tm, regs); in _isl12057_rtc_read_time()
230 return rtc_valid_tm(tm); in _isl12057_rtc_read_time()
395 static int isl12057_rtc_set_time(struct device *dev, struct rtc_time *tm) in isl12057_rtc_set_time() argument
401 ret = isl12057_rtc_tm_to_regs(regs, tm); in isl12057_rtc_set_time()