summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/powermac
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2009-05-31 10:02:20 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2009-05-31 10:02:20 +0000
commit3eefad2beb7d0186398ce72993f4abc3bfca886d (patch)
tree55295df662383770e7a807de9d656303771299c1 /sys/powerpc/powermac
parent378ab0baa10e2b2cf06631fcda2118e46376beaf (diff)
downloadFreeBSD-src-3eefad2beb7d0186398ce72993f4abc3bfca886d.zip
FreeBSD-src-3eefad2beb7d0186398ce72993f4abc3bfca886d.tar.gz
Provide an analogous sysctl to hw.acpi.acline (dev.pmu.0.acline) to
determine whether the computer is plugged in to mains power.
Diffstat (limited to 'sys/powerpc/powermac')
-rw-r--r--sys/powerpc/powermac/pmu.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/powerpc/powermac/pmu.c b/sys/powerpc/powermac/pmu.c
index 593c2c4..5aef180 100644
--- a/sys/powerpc/powermac/pmu.c
+++ b/sys/powerpc/powermac/pmu.c
@@ -72,6 +72,7 @@ static void pmu_poll(device_t dev);
static void pmu_set_sleepled(void *xsc, int onoff);
static int pmu_server_mode(SYSCTL_HANDLER_ARGS);
+static int pmu_acline_state(SYSCTL_HANDLER_ARGS);
static int pmu_query_battery(struct pmu_softc *sc, int batt,
struct pmu_battstate *info);
static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS);
@@ -393,6 +394,10 @@ pmu_attach(device_t dev)
struct sysctl_oid *oid, *battroot;
char battnum[2];
+ SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
+ "acline", CTLTYPE_INT | CTLFLAG_RD, sc, 0,
+ pmu_acline_state, "I", "AC Line Status");
+
battroot = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
"batteries", CTLFLAG_RD, 0, "Battery Information");
@@ -843,6 +848,27 @@ pmu_query_battery(struct pmu_softc *sc, int batt, struct pmu_battstate *info)
}
static int
+pmu_acline_state(SYSCTL_HANDLER_ARGS)
+{
+ struct pmu_softc *sc;
+ struct pmu_battstate batt;
+ int error, result;
+
+ sc = arg1;
+
+ /* The PMU treats the AC line status as a property of the battery */
+ error = pmu_query_battery(sc, 0, &batt);
+
+ if (error != 0)
+ return (error);
+
+ result = (batt.state & PMU_PWR_AC_PRESENT) ? 1 : 0;
+ error = sysctl_handle_int(oidp, &result, 0, req);
+
+ return (error);
+}
+
+static int
pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS)
{
struct pmu_softc *sc;
OpenPOWER on IntegriCloud