Merge tag 'u-boot-imx-20191209' of https://gitlab.denx.de/u-boot/custodians/u-boot-imx
[oweals/u-boot.git] / drivers / rtc / ds3231.c
index 79b026af4b9f434a31f5f8f48ce251aafc40d3bf..eb5ce73a7613f0b22f5a13699a21b77fcc92a4cf 100644 (file)
@@ -148,11 +148,13 @@ void rtc_reset (void)
 /*
  * Enable 32KHz output
  */
+#ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT
 void rtc_enable_32khz_output(void)
 {
        rtc_write(RTC_STAT_REG_ADDR,
                  RTC_STAT_BIT_BB32KHZ | RTC_STAT_BIT_EN32KHZ);
 }
+#endif
 
 /*
  * Helper functions
@@ -251,6 +253,22 @@ static int ds3231_probe(struct udevice *dev)
        return 0;
 }
 
+#ifdef CONFIG_RTC_ENABLE_32KHZ_OUTPUT
+int rtc_enable_32khz_output(int busnum, int chip_addr)
+{
+       int ret;
+       struct udevice *dev;
+
+       ret = i2c_get_chip_for_busnum(busnum, chip_addr, 1, &dev);
+       if (!ret) {
+               ret = dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR,
+                                      RTC_STAT_BIT_BB32KHZ |
+                                      RTC_STAT_BIT_EN32KHZ);
+       }
+       return ret;
+}
+#endif
+
 static const struct rtc_ops ds3231_rtc_ops = {
        .get = ds3231_rtc_get,
        .set = ds3231_rtc_set,