4 * SPDX-License-Identifier: GPL-2.0+
10 #include <power/pmic.h>
13 int rtc_get(struct rtc_time *rtc)
17 struct pmic *p = pmic_get("FSL_PMIC");
23 ret = pmic_reg_read(p, REG_RTC_DAY, &day1);
27 ret = pmic_reg_read(p, REG_RTC_TIME, &time);
31 ret = pmic_reg_read(p, REG_RTC_DAY, &day2);
35 } while (day1 != day2 && i++ < 3);
37 tim = day1 * 86400 + time;
47 int rtc_set(struct rtc_time *rtc)
50 struct pmic *p = pmic_get("FSL_PMIC");
54 time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday,
55 rtc->tm_hour, rtc->tm_min, rtc->tm_sec);
59 pmic_reg_write(p, REG_RTC_DAY, day);
60 pmic_reg_write(p, REG_RTC_TIME, time);