1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2008, Guennadi Liakhovetski <lg@denx.de>
9 #include <power/pmic.h>
12 int rtc_get(struct rtc_time *rtc)
16 struct pmic *p = pmic_get("FSL_PMIC");
22 ret = pmic_reg_read(p, REG_RTC_DAY, &day1);
26 ret = pmic_reg_read(p, REG_RTC_TIME, &time);
30 ret = pmic_reg_read(p, REG_RTC_DAY, &day2);
34 } while (day1 != day2 && i++ < 3);
36 tim = day1 * 86400 + time;
46 int rtc_set(struct rtc_time *rtc)
49 struct pmic *p = pmic_get("FSL_PMIC");
53 time = rtc_mktime(rtc);
57 pmic_reg_write(p, REG_RTC_DAY, day);
58 pmic_reg_write(p, REG_RTC_TIME, time);