[Midnightbsd-cvs] src [8231] trunk/sys/dev/iicbus/pcf8563.c: It turns out that as documented, PCF8563_R_SECOND_VL (i.e.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Sep 17 16:34:06 EDT 2016


Revision: 8231
          http://svnweb.midnightbsd.org/src/?rev=8231
Author:   laffer1
Date:     2016-09-17 16:34:06 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
It turns out that as documented, PCF8563_R_SECOND_VL (i.e. battery low)
doesn't automatically clear when VDD rises above Vlow again and needs to be
cleared manually. However, apparently this needs all of the time registers
to be set, i.e. pcf8563_settime(), and not just PCF8563_R_SECOND in order
for PCF8563_R_SECOND_VL to stick. Thus, we just issue a warning during
pcf8563_attach() rather than failing with ENXIO in case it is set.

Obtained from: FreeBSD

Modified Paths:
--------------
    trunk/sys/dev/iicbus/pcf8563.c

Modified: trunk/sys/dev/iicbus/pcf8563.c
===================================================================
--- trunk/sys/dev/iicbus/pcf8563.c	2016-09-17 20:33:34 UTC (rev 8230)
+++ trunk/sys/dev/iicbus/pcf8563.c	2016-09-17 20:34:06 UTC (rev 8231)
@@ -83,6 +83,16 @@
 	if (sc->sc_addr == 0)
 		sc->sc_addr = PCF8563_ADDR;
 
+	/*
+	 * NB: PCF8563_R_SECOND_VL doesn't automatically clear when VDD
+	 * rises above Vlow again and needs to be cleared manually.
+	 * However, apparently this needs all of the time registers to be
+	 * set, i.e. pcf8563_settime(), and not just PCF8563_R_SECOND in
+	 * order for PCF8563_R_SECOND_VL to stick.  Thus, we just issue a
+	 * warning here rather than failing with ENXIO in case it is set.
+	 * Note that pcf8563_settime() will also clear PCF8563_R_SECOND_VL
+	 * as a side-effect.
+	 */
 	msgs[0].slave = msgs[1].slave = sc->sc_addr;
 	error = iicbus_transfer(device_get_parent(dev), msgs, sizeof(msgs) /
 	    sizeof(*msgs));
@@ -90,10 +100,8 @@
 		device_printf(dev, "%s: cannot read RTC\n", __func__);
 		return (error);
 	}
-	if ((val & PCF8563_R_SECOND_VL) != 0) {
+	if ((val & PCF8563_R_SECOND_VL) != 0)
 		device_printf(dev, "%s: battery low\n", __func__);
-		return (ENXIO);
-	}
 
 	sc->sc_year0 = 1900;
 	clock_register(dev, 1000000);   /* 1 second resolution */



More information about the Midnightbsd-cvs mailing list