2 * Copyright (C) 2008, Guennadi Liakhovetski <lg@denx.de>
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 = rtc_mktime(rtc);
58 pmic_reg_write(p, REG_RTC_DAY, day);
59 pmic_reg_write(p, REG_RTC_TIME, time);