rtc: s35392a: add compatible strings
[oweals/u-boot.git] / drivers / rtc / ds1307.c
index 5df15c7fd6c6846dba9c1a10a567663734ca22fc..a33f47525f787e95c2c7b83f647ff1ea30771b2a 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2001, 2002, 2003
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  * Keith Outwater, keith_outwater@mvis.com`
  * Steven Scholz, steven.scholz@imc-berlin.de
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 /*
@@ -24,6 +23,7 @@ enum ds_type {
        ds_1307,
        ds_1337,
        ds_1340,
+       m41t11,
        mcp794xx,
 };
 
@@ -52,8 +52,6 @@ enum ds_type {
 
 #ifndef CONFIG_DM_RTC
 
-#if defined(CONFIG_CMD_DATE)
-
 /*---------------------------------------------------------------------*/
 #undef DEBUG_RTC
 
@@ -184,25 +182,8 @@ int rtc_set (struct rtc_time *tmp)
  */
 void rtc_reset (void)
 {
-       struct rtc_time tmp;
-
        rtc_write (RTC_SEC_REG_ADDR, 0x00);     /* clearing Clock Halt  */
        rtc_write (RTC_CTL_REG_ADDR, RTC_CTL_BIT_SQWE | RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS0);
-
-       tmp.tm_year = 1970;
-       tmp.tm_mon = 1;
-       tmp.tm_mday= 1;
-       tmp.tm_hour = 0;
-       tmp.tm_min = 0;
-       tmp.tm_sec = 0;
-
-       rtc_set(&tmp);
-
-       printf ( "RTC:   %4d-%02d-%02d %2d:%02d:%02d UTC\n",
-               tmp.tm_year, tmp.tm_mon, tmp.tm_mday,
-               tmp.tm_hour, tmp.tm_min, tmp.tm_sec);
-
-       return;
 }
 
 
@@ -222,8 +203,6 @@ static void rtc_write (uchar reg, uchar val)
        i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val);
 }
 
-#endif /* CONFIG_CMD_DATE*/
-
 #endif /* !CONFIG_DM_RTC */
 
 #ifdef CONFIG_DM_RTC
@@ -282,6 +261,18 @@ read_rtc:
                }
        }
 
+       if (type == m41t11) {
+               /* clock halted?  turn it on, so clock can tick. */
+               if (buf[RTC_SEC_REG_ADDR] & RTC_SEC_BIT_CH) {
+                       buf[RTC_SEC_REG_ADDR] &= ~RTC_SEC_BIT_CH;
+                       dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR,
+                                        MCP7941X_BIT_ST);
+                       dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR,
+                                        buf[RTC_SEC_REG_ADDR]);
+                       goto read_rtc;
+               }
+       }
+
        if (type == mcp794xx) {
                /* make sure that the backup battery is enabled */
                if (!(buf[RTC_DAY_REG_ADDR] & MCP7941X_BIT_VBATEN)) {
@@ -321,14 +312,6 @@ read_rtc:
 static int ds1307_rtc_reset(struct udevice *dev)
 {
        int ret;
-       struct rtc_time tmp = {
-               .tm_year = 1970,
-               .tm_mon = 1,
-               .tm_mday = 1,
-               .tm_hour = 0,
-               .tm_min = 0,
-               .tm_sec = 0,
-       };
 
        /* clear Clock Halt */
        ret = dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, 0x00);
@@ -340,14 +323,6 @@ static int ds1307_rtc_reset(struct udevice *dev)
        if (ret < 0)
                return ret;
 
-       ret = ds1307_rtc_set(dev, &tmp);
-       if (ret < 0)
-               return ret;
-
-       debug("RTC:   %4d-%02d-%02d %2d:%02d:%02d UTC\n",
-             tmp.tm_year, tmp.tm_mon, tmp.tm_mday,
-             tmp.tm_hour, tmp.tm_min, tmp.tm_sec);
-
        return 0;
 }
 
@@ -370,6 +345,7 @@ static const struct udevice_id ds1307_rtc_ids[] = {
        { .compatible = "dallas,ds1337", .data = ds_1337 },
        { .compatible = "dallas,ds1340", .data = ds_1340 },
        { .compatible = "microchip,mcp7941x", .data = mcp794xx },
+       { .compatible = "st,m41t11", .data = m41t11 },
        { }
 };