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
This commit is contained in:
parent
99187c3a44
commit
55f1ca209d
@ -62,6 +62,11 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/md_var.h>
|
#include <machine/md_var.h>
|
||||||
#endif
|
#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_lock protects low-level access to individual hardware registers.
|
||||||
* atrtc_time_lock protects the entire sequence of accessing multiple 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 */
|
/* Look if we have a RTC present and the time is valid */
|
||||||
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
if (!(rtcin(RTC_STATUSD) & RTCSD_PWR)) {
|
||||||
|
atrtc_power_lost = true;
|
||||||
device_printf(dev, "WARNING: Battery failure indication\n");
|
device_printf(dev, "WARNING: Battery failure indication\n");
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user