Merge branch '2019-07-17-master-imports'
[oweals/u-boot.git] / drivers / rtc / mxsrtc.c
index 5beb1a0440d04caf41553a20134270b71b974ec3..be899a925408c3f6ccfba9c9fab399fb89296926 100644 (file)
@@ -1,23 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale i.MX28 RTC Driver
  *
  * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
  * on behalf of DENX Software Engineering GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
- *
  */
 
 #include <common.h>
@@ -31,7 +17,7 @@
 /* Set time in seconds since 1970-01-01 */
 int mxs_rtc_set_time(uint32_t secs)
 {
-       struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
+       struct mxs_rtc_regs *rtc_regs = (struct mxs_rtc_regs *)MXS_RTC_BASE;
        int ret;
 
        writel(secs, &rtc_regs->hw_rtc_seconds);
@@ -41,7 +27,7 @@ int mxs_rtc_set_time(uint32_t secs)
         * is taken from the linux kernel driver for the STMP37xx RTC since
         * documentation doesn't mention it.
         */
-       ret = mx28_wait_mask_clr(&rtc_regs->hw_rtc_stat_reg,
+       ret = mxs_wait_mask_clr(&rtc_regs->hw_rtc_stat_reg,
                0x80 << RTC_STAT_STALE_REGS_OFFSET, MXS_RTC_MAX_TIMEOUT);
 
        if (ret)
@@ -52,11 +38,11 @@ int mxs_rtc_set_time(uint32_t secs)
 
 int rtc_get(struct rtc_time *time)
 {
-       struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
+       struct mxs_rtc_regs *rtc_regs = (struct mxs_rtc_regs *)MXS_RTC_BASE;
        uint32_t secs;
 
        secs = readl(&rtc_regs->hw_rtc_seconds);
-       to_tm(secs, time);
+       rtc_to_tm(secs, time);
 
        return 0;
 }
@@ -65,22 +51,21 @@ int rtc_set(struct rtc_time *time)
 {
        uint32_t secs;
 
-       secs = mktime(time->tm_year, time->tm_mon, time->tm_mday,
-               time->tm_hour, time->tm_min, time->tm_sec);
+       secs = rtc_mktime(time);
 
        return mxs_rtc_set_time(secs);
 }
 
 void rtc_reset(void)
 {
-       struct mx28_rtc_regs *rtc_regs = (struct mx28_rtc_regs *)MXS_RTC_BASE;
+       struct mxs_rtc_regs *rtc_regs = (struct mxs_rtc_regs *)MXS_RTC_BASE;
        int ret;
 
        /* Set time to 1970-01-01 */
        mxs_rtc_set_time(0);
 
        /* Reset the RTC block */
-       ret = mx28_reset_block(&rtc_regs->hw_rtc_ctrl_reg);
+       ret = mxs_reset_block(&rtc_regs->hw_rtc_ctrl_reg);
        if (ret)
                printf("MXS RTC: Block reset timeout\n");
 }