Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Oct 2012 11:43:43 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r241803 - stable/9/sys/dev/iicbus
Message-ID:  <201210211143.q9LBhhDn064871@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Sun Oct 21 11:43:43 2012
New Revision: 241803
URL: http://svn.freebsd.org/changeset/base/241803

Log:
  MFC: r241679
  
  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.

Modified:
  stable/9/sys/dev/iicbus/pcf8563.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sys/dev/iicbus/pcf8563.c
==============================================================================
--- stable/9/sys/dev/iicbus/pcf8563.c	Sun Oct 21 11:16:16 2012	(r241802)
+++ stable/9/sys/dev/iicbus/pcf8563.c	Sun Oct 21 11:43:43 2012	(r241803)
@@ -83,6 +83,16 @@ pcf8563_attach(device_t dev)
 	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 @@ pcf8563_attach(device_t dev)
 		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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210211143.q9LBhhDn064871>