Deleted Added
full compact
pmu.c (185782) pmu.c (193159)
1/*-
2 * Copyright (c) 2006 Michael Lorenz
3 * Copyright 2008 by Nathan Whitehorn
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2006 Michael Lorenz
3 * Copyright 2008 by Nathan Whitehorn
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 13 unchanged lines hidden (view full) ---

22 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/powerpc/powermac/pmu.c 185782 2008-12-09 01:01:02Z nwhitehorn $");
30__FBSDID("$FreeBSD: head/sys/powerpc/powermac/pmu.c 193159 2009-05-31 10:02:20Z nwhitehorn $");
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/module.h>
35#include <sys/bus.h>
36#include <sys/conf.h>
37#include <sys/kernel.h>
38#include <sys/sysctl.h>

--- 28 unchanged lines hidden (view full) ---

67
68static u_int pmu_adb_send(device_t dev, u_char command_byte, int len,
69 u_char *data, u_char poll);
70static u_int pmu_adb_autopoll(device_t dev, uint16_t mask);
71static void pmu_poll(device_t dev);
72
73static void pmu_set_sleepled(void *xsc, int onoff);
74static int pmu_server_mode(SYSCTL_HANDLER_ARGS);
31
32#include <sys/param.h>
33#include <sys/systm.h>
34#include <sys/module.h>
35#include <sys/bus.h>
36#include <sys/conf.h>
37#include <sys/kernel.h>
38#include <sys/sysctl.h>

--- 28 unchanged lines hidden (view full) ---

67
68static u_int pmu_adb_send(device_t dev, u_char command_byte, int len,
69 u_char *data, u_char poll);
70static u_int pmu_adb_autopoll(device_t dev, uint16_t mask);
71static void pmu_poll(device_t dev);
72
73static void pmu_set_sleepled(void *xsc, int onoff);
74static int pmu_server_mode(SYSCTL_HANDLER_ARGS);
75static int pmu_acline_state(SYSCTL_HANDLER_ARGS);
75static int pmu_query_battery(struct pmu_softc *sc, int batt,
76 struct pmu_battstate *info);
77static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS);
78
79/*
80 * List of battery-related sysctls we might ask for
81 */
82

--- 305 unchanged lines hidden (view full) ---

388 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
389 "server_mode", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
390 pmu_server_mode, "I", "Enable reboot after power failure");
391
392 if (sc->sc_batteries > 0) {
393 struct sysctl_oid *oid, *battroot;
394 char battnum[2];
395
76static int pmu_query_battery(struct pmu_softc *sc, int batt,
77 struct pmu_battstate *info);
78static int pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS);
79
80/*
81 * List of battery-related sysctls we might ask for
82 */
83

--- 305 unchanged lines hidden (view full) ---

389 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
390 "server_mode", CTLTYPE_INT | CTLFLAG_RW, sc, 0,
391 pmu_server_mode, "I", "Enable reboot after power failure");
392
393 if (sc->sc_batteries > 0) {
394 struct sysctl_oid *oid, *battroot;
395 char battnum[2];
396
397 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
398 "acline", CTLTYPE_INT | CTLFLAG_RD, sc, 0,
399 pmu_acline_state, "I", "AC Line Status");
400
396 battroot = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
397 "batteries", CTLFLAG_RD, 0, "Battery Information");
398
399 for (i = 0; i < sc->sc_batteries; i++) {
400 battnum[0] = i + '0';
401 battnum[1] = '\0';
402
403 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(battroot),

--- 434 unchanged lines hidden (view full) ---

838 resp[1]);
839 return (-1);
840 }
841
842 return (0);
843}
844
845static int
401 battroot = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
402 "batteries", CTLFLAG_RD, 0, "Battery Information");
403
404 for (i = 0; i < sc->sc_batteries; i++) {
405 battnum[0] = i + '0';
406 battnum[1] = '\0';
407
408 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(battroot),

--- 434 unchanged lines hidden (view full) ---

843 resp[1]);
844 return (-1);
845 }
846
847 return (0);
848}
849
850static int
851pmu_acline_state(SYSCTL_HANDLER_ARGS)
852{
853 struct pmu_softc *sc;
854 struct pmu_battstate batt;
855 int error, result;
856
857 sc = arg1;
858
859 /* The PMU treats the AC line status as a property of the battery */
860 error = pmu_query_battery(sc, 0, &batt);
861
862 if (error != 0)
863 return (error);
864
865 result = (batt.state & PMU_PWR_AC_PRESENT) ? 1 : 0;
866 error = sysctl_handle_int(oidp, &result, 0, req);
867
868 return (error);
869}
870
871static int
846pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS)
847{
848 struct pmu_softc *sc;
849 struct pmu_battstate batt;
850 int error, result;
851
852 sc = arg1;
853

--- 48 unchanged lines hidden ---
872pmu_battquery_sysctl(SYSCTL_HANDLER_ARGS)
873{
874 struct pmu_softc *sc;
875 struct pmu_battstate batt;
876 int error, result;
877
878 sc = arg1;
879

--- 48 unchanged lines hidden ---