Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Feb 2023 07:25:47 GMT
From:      =?utf-8?Q?Corvin=20K=C3=B6hne?= <corvink@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 55f1ca209d37 - main - atrtc: expose power loss as sysctl
Message-ID:  <202302020725.3127PlLK046633@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by corvink:

URL: https://cgit.FreeBSD.org/src/commit/?id=55f1ca209d37d7b5a6faf57b23c7341cb7f84ee6

commit 55f1ca209d37d7b5a6faf57b23c7341cb7f84ee6
Author:     Corvin Köhne <corvink@FreeBSD.org>
AuthorDate: 2022-12-08 07:28:42 +0000
Commit:     Corvin Köhne <corvink@FreeBSD.org>
CommitDate: 2023-02-02 07:25:08 +0000

    atrtc: expose power loss as sysctl
    
    Exposing the a power loss of the rtc as an sysctl makes it easier to
    detect an empty cmos battery.
    
    Reviewed by:            manu
    MFC after:              1 week
    Sponsored by:           Beckhoff Automation GmbH & Co. KG
    Differential Revision:  https://reviews.freebsd.org/D38325
---
 sys/x86/isa/atrtc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/x86/isa/atrtc.c b/sys/x86/isa/atrtc.c
index 33eb9a4bbdf0..81ba400619cc 100644
--- a/sys/x86/isa/atrtc.c
+++ b/sys/x86/isa/atrtc.c
@@ -62,6 +62,11 @@ __FBSDID("$FreeBSD$");
 #include <machine/md_var.h>
 #endif
 
+/* tunable to detect a power loss of the rtc */
+static bool atrtc_power_lost = false;
+SYSCTL_BOOL(_machdep, OID_AUTO, atrtc_power_lost, CTLFLAG_RD, &atrtc_power_lost,
+    false, "RTC lost power on last power cycle (probably caused by an emtpy cmos battery)");
+
 /*
  * atrtc_lock protects low-level access to individual hardware registers.
  * atrtc_time_lock protects the entire sequence of accessing multiple registers
@@ -600,6 +605,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
 
 	/* Look if we have a RTC present and the time is valid */
 	if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
+		atrtc_power_lost = true;
 		device_printf(dev, "WARNING: Battery failure indication\n");
 		return (EINVAL);
 	}



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