diff options
author | Stefano Babic <sbabic@denx.de> | 2011-10-02 18:38:43 +0200 |
---|---|---|
committer | Albert ARIBAUD <albert.u.boot@aribaud.net> | 2011-10-27 21:56:31 +0200 |
commit | 4380075e41237a4ec03954c1f827eea70fc25c93 (patch) | |
tree | c1c3ba2e0c64c3a4fc870b2d2b3a712d33154f18 | |
parent | bac395ee42d6770c3e71f5e06bc1825a04cff224 (diff) | |
download | u-boot-imx-4380075e41237a4ec03954c1f827eea70fc25c93.zip u-boot-imx-4380075e41237a4ec03954c1f827eea70fc25c93.tar.gz u-boot-imx-4380075e41237a4ec03954c1f827eea70fc25c93.tar.bz2 |
RTC: Switch mc13783 to generic pmic code
Signed-off-by: Stefano Babic <sbabic@denx.de>
-rw-r--r-- | drivers/rtc/mc13783-rtc.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/rtc/mc13783-rtc.c b/drivers/rtc/mc13783-rtc.c index 4e18f80..70ea8a1 100644 --- a/drivers/rtc/mc13783-rtc.c +++ b/drivers/rtc/mc13783-rtc.c @@ -23,24 +23,27 @@ #include <common.h> #include <rtc.h> #include <spi.h> +#include <pmic.h> #include <fsl_pmic.h> int rtc_get(struct rtc_time *rtc) { u32 day1, day2, time; int tim, i = 0; + struct pmic *p = get_pmic(); + int ret; do { - day1 = pmic_reg_read(REG_RTC_DAY); - if (day1 < 0) + ret = pmic_reg_read(p, REG_RTC_DAY, &day1); + if (ret < 0) return -1; - time = pmic_reg_read(REG_RTC_TIME); - if (time < 0) + ret = pmic_reg_read(p, REG_RTC_TIME, &time); + if (ret < 0) return -1; - day2 = pmic_reg_read(REG_RTC_DAY); - if (day2 < 0) + ret = pmic_reg_read(p, REG_RTC_DAY, &day2); + if (ret < 0) return -1; } while (day1 != day2 && i++ < 3); @@ -58,14 +61,15 @@ int rtc_get(struct rtc_time *rtc) int rtc_set(struct rtc_time *rtc) { u32 time, day; + struct pmic *p = get_pmic(); time = mktime(rtc->tm_year, rtc->tm_mon, rtc->tm_mday, rtc->tm_hour, rtc->tm_min, rtc->tm_sec); day = time / 86400; time %= 86400; - pmic_reg_write(REG_RTC_DAY, day); - pmic_reg_write(REG_RTC_TIME, time); + pmic_reg_write(p, REG_RTC_DAY, day); + pmic_reg_write(p, REG_RTC_TIME, time); return 0; } |