Home | History | Annotate | Line # | Download | only in dev
battery.c revision 1.2.4.3
      1  1.2.4.3  macallan /*	$NetBSD: battery.c,v 1.2.4.3 2007/06/14 02:25:52 macallan Exp $ */
      2      1.1  macallan 
      3      1.1  macallan /*-
      4      1.1  macallan  * Copyright (c) 2007 Michael Lorenz
      5      1.1  macallan  * All rights reserved.
      6      1.1  macallan  *
      7      1.1  macallan  * Redistribution and use in source and binary forms, with or without
      8      1.1  macallan  * modification, are permitted provided that the following conditions
      9      1.1  macallan  * are met:
     10      1.1  macallan  * 1. Redistributions of source code must retain the above copyright
     11      1.1  macallan  *    notice, this list of conditions and the following disclaimer.
     12      1.1  macallan  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  macallan  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  macallan  *    documentation and/or other materials provided with the distribution.
     15      1.1  macallan  * 3. Neither the name of The NetBSD Foundation nor the names of its
     16      1.1  macallan  *    contributors may be used to endorse or promote products derived
     17      1.1  macallan  *    from this software without specific prior written permission.
     18      1.1  macallan  *
     19      1.1  macallan  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20      1.1  macallan  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21      1.1  macallan  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22      1.1  macallan  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23      1.1  macallan  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24      1.1  macallan  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25      1.1  macallan  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26      1.1  macallan  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27      1.1  macallan  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28      1.1  macallan  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29      1.1  macallan  * POSSIBILITY OF SUCH DAMAGE.
     30      1.1  macallan  */
     31      1.1  macallan 
     32      1.1  macallan #include <sys/cdefs.h>
     33  1.2.4.3  macallan __KERNEL_RCSID(0, "$NetBSD: battery.c,v 1.2.4.3 2007/06/14 02:25:52 macallan Exp $");
     34      1.1  macallan 
     35      1.1  macallan #include <sys/param.h>
     36      1.1  macallan #include <sys/systm.h>
     37      1.1  macallan #include <sys/kernel.h>
     38      1.1  macallan #include <sys/device.h>
     39      1.1  macallan #include <sys/proc.h>
     40      1.1  macallan 
     41      1.1  macallan #include <dev/sysmon/sysmonvar.h>
     42      1.1  macallan #include <dev/sysmon/sysmon_taskq.h>
     43      1.1  macallan 
     44      1.1  macallan #include <macppc/dev/pmuvar.h>
     45      1.1  macallan #include <macppc/dev/batteryvar.h>
     46      1.1  macallan #include <machine/bus.h>
     47  1.2.4.3  macallan #include <machine/pio.h>
     48      1.1  macallan #include "opt_battery.h"
     49      1.1  macallan 
     50      1.1  macallan #ifdef BATTERY_DEBUG
     51      1.1  macallan #define DPRINTF printf
     52      1.1  macallan #else
     53      1.1  macallan #define DPRINTF while (0) printf
     54      1.1  macallan #endif
     55      1.1  macallan 
     56      1.1  macallan #define BTYPE_COMET	1
     57      1.1  macallan #define BTYPE_HOOPER	2
     58      1.1  macallan 
     59      1.1  macallan #define BAT_CPU_TEMPERATURE	0
     60      1.1  macallan #define BAT_AC_PRESENT		1
     61      1.1  macallan #define BAT_PRESENT		2
     62      1.1  macallan #define BAT_VOLTAGE		3
     63      1.1  macallan #define BAT_CURRENT		4
     64      1.1  macallan #define BAT_MAX_CHARGE		5
     65      1.1  macallan #define BAT_CHARGE		6
     66      1.1  macallan #define BAT_CHARGING		7
     67      1.1  macallan #define BAT_DISCHARGING		8
     68      1.1  macallan #define BAT_FULL		9
     69      1.1  macallan #define BAT_TEMPERATURE		10
     70      1.1  macallan #define BAT_NSENSORS		11  /* number of sensors */
     71      1.1  macallan 
     72      1.1  macallan struct battery_softc {
     73      1.1  macallan 	struct device sc_dev;
     74      1.1  macallan 	struct pmu_ops *sc_pmu_ops;
     75      1.1  macallan 	int sc_type;
     76      1.1  macallan 
     77      1.1  macallan 	/* envsys stuff */
     78      1.1  macallan 	struct sysmon_envsys sc_sysmon;
     79      1.1  macallan 	struct envsys_basic_info sc_sinfo[BAT_NSENSORS];
     80      1.1  macallan 	struct envsys_tre_data sc_sdata[BAT_NSENSORS];
     81  1.2.4.1  macallan 	struct sysmon_pswitch sc_sm_acpower;
     82      1.1  macallan 
     83      1.1  macallan 	/* battery status */
     84      1.1  macallan 	int sc_flags;
     85  1.2.4.1  macallan 	int sc_oflags;
     86      1.1  macallan 	int sc_voltage;
     87      1.1  macallan 	int sc_charge;
     88      1.1  macallan 	int sc_current;
     89      1.1  macallan 	int sc_time;
     90      1.1  macallan 	int sc_cpu_temp;
     91      1.1  macallan 	int sc_bat_temp;
     92      1.1  macallan 	int sc_vmax_charged;
     93      1.1  macallan 	int sc_vmax_charging;
     94  1.2.4.1  macallan 	uint32_t sc_timestamp;
     95      1.1  macallan };
     96      1.1  macallan 
     97      1.1  macallan static void battery_attach(struct device *, struct device *, void *);
     98      1.1  macallan static int battery_match(struct device *, struct cfdata *, void *);
     99      1.1  macallan static int battery_update(struct battery_softc *, int);
    100      1.1  macallan static void battery_setup_envsys(struct battery_softc *);
    101      1.1  macallan static int battery_gtredata(struct sysmon_envsys *, struct envsys_tre_data *);
    102      1.1  macallan static int battery_streinfo(struct sysmon_envsys *,
    103      1.1  macallan     struct envsys_basic_info *);
    104  1.2.4.1  macallan static void battery_poll(void *);
    105      1.1  macallan 
    106      1.1  macallan CFATTACH_DECL(battery, sizeof(struct battery_softc),
    107      1.1  macallan     battery_match, battery_attach, NULL, NULL);
    108      1.1  macallan 
    109      1.1  macallan static int
    110      1.1  macallan battery_match(struct device *parent, struct cfdata *cf, void *aux)
    111      1.1  macallan {
    112      1.1  macallan 	struct battery_attach_args *baa = aux;
    113      1.1  macallan 
    114      1.1  macallan 	if (baa->baa_type == BATTERY_TYPE_LEGACY)
    115      1.1  macallan 		return 1;
    116      1.1  macallan 
    117      1.1  macallan 	return 0;
    118      1.1  macallan }
    119      1.1  macallan 
    120      1.1  macallan static void
    121      1.1  macallan battery_attach(struct device *parent, struct device *self, void *aux)
    122      1.1  macallan {
    123      1.1  macallan 	struct battery_attach_args *baa = aux;
    124      1.1  macallan 	struct battery_softc *sc = (struct battery_softc *)self;
    125      1.1  macallan 	uint32_t reg;
    126      1.1  macallan 
    127      1.1  macallan 	sc->sc_pmu_ops = baa->baa_pmu_ops;
    128      1.1  macallan 	printf(": legacy battery ");
    129      1.1  macallan 
    130      1.1  macallan 	reg = in32rb(0xf3000034);
    131      1.1  macallan 	DPRINTF("reg: %08x\n", reg);
    132      1.1  macallan 	if (reg & 0x20000000) {
    133      1.1  macallan 		sc->sc_type = BTYPE_HOOPER;
    134      1.1  macallan 		sc->sc_vmax_charged = 330;
    135      1.1  macallan 		sc->sc_vmax_charging = 365;
    136      1.1  macallan 		printf("[hooper]\n");
    137      1.1  macallan 	} else {
    138      1.1  macallan 		sc->sc_type = BTYPE_COMET;
    139      1.1  macallan 		sc->sc_vmax_charged = 189;
    140      1.1  macallan 		sc->sc_vmax_charging = 213;
    141      1.1  macallan 		printf("[comet]\n");
    142      1.1  macallan 	}
    143      1.1  macallan 	battery_update(sc, 1);
    144  1.2.4.1  macallan 	/* trigger a status update */
    145  1.2.4.1  macallan 	sc->sc_oflags = ~sc->sc_flags;
    146  1.2.4.1  macallan 
    147      1.1  macallan 	battery_setup_envsys(sc);
    148  1.2.4.1  macallan 	sc->sc_pmu_ops->register_callback(sc->sc_pmu_ops->cookie, battery_poll,
    149  1.2.4.1  macallan 	    sc);
    150  1.2.4.1  macallan 
    151  1.2.4.1  macallan 	memset(&sc->sc_sm_acpower, 0, sizeof(struct sysmon_pswitch));
    152  1.2.4.1  macallan 	sc->sc_sm_acpower.smpsw_name = "AC Power";
    153  1.2.4.1  macallan 	sc->sc_sm_acpower.smpsw_type = PSWITCH_TYPE_ACADAPTER;
    154  1.2.4.1  macallan 	if (sysmon_pswitch_register(&sc->sc_sm_acpower) != 0)
    155  1.2.4.1  macallan 		printf("%s: unable to register AC power status with sysmon\n",
    156  1.2.4.1  macallan 		    sc->sc_dev.dv_xname);
    157      1.1  macallan }
    158      1.1  macallan 
    159      1.1  macallan static int
    160      1.1  macallan battery_update(struct battery_softc *sc, int out)
    161      1.1  macallan {
    162      1.1  macallan 	int len, vmax, pcharge, vb;
    163      1.1  macallan 	uint8_t buf[16];
    164      1.1  macallan 
    165  1.2.4.1  macallan 	if (sc->sc_timestamp == time_second)
    166  1.2.4.1  macallan 		return 0;
    167  1.2.4.1  macallan 	sc->sc_timestamp = time_second;
    168  1.2.4.1  macallan 
    169      1.1  macallan 	len = sc->sc_pmu_ops->do_command(sc->sc_pmu_ops->cookie,
    170      1.2  macallan 	    PMU_BATTERY_STATE, 0, NULL, 16, buf);
    171      1.1  macallan 	if (len != 9)
    172      1.1  macallan 		return -1;
    173      1.1  macallan 
    174      1.1  macallan 	sc->sc_flags = buf[1];
    175      1.1  macallan 
    176      1.1  macallan 	if (out) {
    177      1.1  macallan 		if (buf[1] & PMU_PWR_AC_PRESENT)
    178      1.1  macallan 			printf(" AC");
    179      1.1  macallan 		if (buf[1] & PMU_PWR_BATT_CHARGING)
    180      1.1  macallan 			printf(" charging");
    181      1.1  macallan 		if (buf[1] & PMU_PWR_BATT_PRESENT)
    182      1.1  macallan 			printf(" present");
    183      1.1  macallan 		if (buf[1] & PMU_PWR_BATT_FULL)
    184      1.1  macallan 			printf(" full");
    185      1.1  macallan 		printf("\n");
    186      1.1  macallan 	}
    187      1.1  macallan 
    188      1.1  macallan 	sc->sc_cpu_temp = buf[4];
    189      1.1  macallan 
    190      1.1  macallan 	if ((sc->sc_flags & PMU_PWR_BATT_PRESENT) == 0) {
    191      1.1  macallan 		sc->sc_voltage = 0;
    192      1.1  macallan 		sc->sc_current = 0;
    193      1.1  macallan 		sc->sc_bat_temp = 0;
    194      1.1  macallan 		sc->sc_charge = 0;
    195      1.1  macallan 		sc->sc_time = 0;
    196      1.1  macallan 		return 0;
    197      1.1  macallan 	}
    198      1.1  macallan 
    199      1.1  macallan 	vmax = sc->sc_vmax_charged;
    200      1.1  macallan 	vb = (buf[2] << 8) | buf[3];
    201      1.1  macallan 	sc->sc_voltage = (vb * 265 + 72665) / 10;
    202      1.1  macallan 	sc->sc_current = buf[6];
    203      1.1  macallan 	if ((sc->sc_flags & PMU_PWR_AC_PRESENT) == 0) {
    204      1.1  macallan 	    	if (sc->sc_current > 200)
    205      1.1  macallan 			vb += ((sc->sc_current - 200) * 15) / 100;
    206      1.1  macallan 	} else {
    207      1.1  macallan 		vmax = sc->sc_vmax_charging;
    208      1.1  macallan 	}
    209      1.1  macallan 	sc->sc_charge = (100 * vb) / vmax;
    210      1.1  macallan 	if (sc->sc_flags & PMU_PWR_PCHARGE_RESET) {
    211      1.1  macallan 		pcharge = (buf[7] << 8) | buf[8];
    212      1.1  macallan 		if (pcharge > 6500)
    213      1.1  macallan 			pcharge = 6500;
    214      1.1  macallan 		pcharge = 100 - pcharge * 100 / 6500;
    215      1.1  macallan 		if (pcharge < sc->sc_charge)
    216      1.1  macallan 			sc->sc_charge = pcharge;
    217      1.1  macallan 	}
    218      1.1  macallan 	if (sc->sc_current > 0) {
    219      1.1  macallan 		sc->sc_time = (sc->sc_charge * 16440) / sc->sc_current;
    220      1.1  macallan 	} else
    221      1.1  macallan 		sc->sc_time = 0;
    222      1.1  macallan 
    223      1.1  macallan 	sc->sc_bat_temp = buf[5];
    224      1.1  macallan 
    225      1.1  macallan 	if (out) {
    226      1.1  macallan 		printf("voltage: %d.%03d\n", sc->sc_voltage / 1000,
    227      1.1  macallan 		    sc->sc_voltage % 1000);
    228      1.1  macallan 		printf("charge:  %d%%\n", sc->sc_charge);
    229      1.1  macallan 		if (sc->sc_time > 0)
    230      1.1  macallan 			printf("time:    %d:%02d\n", sc->sc_time / 60,
    231      1.1  macallan 			    sc->sc_time % 60);
    232      1.1  macallan 	}
    233      1.1  macallan 
    234      1.1  macallan 	return 0;
    235      1.1  macallan }
    236      1.1  macallan 
    237      1.1  macallan #define INITDATA(index, unit, string) \
    238      1.1  macallan 	sc->sc_sdata[index].sensor = index;				\
    239      1.1  macallan 	sc->sc_sdata[index].units = unit;     				\
    240      1.1  macallan 	sc->sc_sdata[index].validflags = ENVSYS_FVALID;			\
    241      1.1  macallan 	sc->sc_sdata[index].warnflags = 0;				\
    242      1.1  macallan 	sc->sc_sinfo[index].sensor = index;				\
    243      1.1  macallan 	sc->sc_sinfo[index].units = unit;     				\
    244      1.1  macallan 	sc->sc_sinfo[index].rfact = 1;     				\
    245      1.1  macallan 	sc->sc_sinfo[index].validflags = ENVSYS_FVALID;			\
    246      1.1  macallan 	snprintf(sc->sc_sinfo[index].desc, sizeof(sc->sc_sinfo[index].desc),	\
    247      1.1  macallan 	    "%s", string);
    248      1.1  macallan 
    249      1.1  macallan static void
    250      1.1  macallan battery_setup_envsys(struct battery_softc *sc)
    251      1.1  macallan {
    252      1.1  macallan 
    253      1.1  macallan 	INITDATA(BAT_CPU_TEMPERATURE, ENVSYS_STEMP, "CPU temperature");
    254      1.1  macallan 	INITDATA(BAT_AC_PRESENT, ENVSYS_INDICATOR, "AC present");
    255      1.1  macallan 	INITDATA(BAT_PRESENT, ENVSYS_INDICATOR, "Battery present");
    256      1.1  macallan 	INITDATA(BAT_VOLTAGE, ENVSYS_SVOLTS_DC, "Battery voltage");
    257      1.1  macallan 	INITDATA(BAT_CHARGE, ENVSYS_INTEGER, "Battery charge");
    258      1.1  macallan 	INITDATA(BAT_MAX_CHARGE, ENVSYS_INTEGER, "Battery design cap");
    259      1.1  macallan 	INITDATA(BAT_CURRENT, ENVSYS_SAMPS, "Battery current");
    260      1.1  macallan 	INITDATA(BAT_TEMPERATURE, ENVSYS_STEMP, "Battery temperature");
    261      1.1  macallan 	INITDATA(BAT_CHARGING, ENVSYS_INDICATOR, "Battery charging");
    262      1.1  macallan 	INITDATA(BAT_DISCHARGING, ENVSYS_INDICATOR, "Battery discharging");
    263      1.1  macallan 	INITDATA(BAT_FULL, ENVSYS_INDICATOR, "Battery full");
    264      1.1  macallan #undef INITDATA
    265      1.1  macallan 
    266      1.1  macallan 	sc->sc_sysmon.sme_sensor_info = sc->sc_sinfo;
    267      1.1  macallan 	sc->sc_sysmon.sme_sensor_data = sc->sc_sdata;
    268      1.1  macallan 	sc->sc_sysmon.sme_cookie = sc;
    269      1.1  macallan 	sc->sc_sysmon.sme_gtredata = battery_gtredata;
    270      1.1  macallan 	sc->sc_sysmon.sme_streinfo = battery_streinfo;
    271      1.1  macallan 	sc->sc_sysmon.sme_nsensors = BAT_NSENSORS;
    272      1.1  macallan 	sc->sc_sysmon.sme_envsys_version = 1000;
    273      1.1  macallan 
    274      1.1  macallan 	if (sysmon_envsys_register(&sc->sc_sysmon))
    275      1.1  macallan 		printf("%s: unable to register with sysmon\n",
    276      1.1  macallan 		    sc->sc_dev.dv_xname);
    277      1.1  macallan }
    278      1.1  macallan 
    279      1.1  macallan static int
    280      1.1  macallan battery_gtredata(struct sysmon_envsys *sme, struct envsys_tre_data *tred)
    281      1.1  macallan {
    282      1.1  macallan 	struct battery_softc *sc = sme->sme_cookie;
    283      1.1  macallan 	struct envsys_tre_data *cur;
    284      1.1  macallan 	int which = tred->sensor;
    285      1.1  macallan 
    286      1.1  macallan 	battery_update(sc, 0);
    287      1.1  macallan 
    288      1.1  macallan 	cur = &sc->sc_sdata[BAT_CPU_TEMPERATURE];
    289      1.1  macallan 	cur->cur.data_s = sc->sc_cpu_temp * 1000000 + 273150000;
    290      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    291      1.1  macallan 
    292      1.1  macallan 	cur = &sc->sc_sdata[BAT_AC_PRESENT];
    293      1.1  macallan 	cur->cur.data_s = (sc->sc_flags & PMU_PWR_AC_PRESENT);
    294      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    295      1.1  macallan 
    296      1.1  macallan 	cur = &sc->sc_sdata[BAT_PRESENT];
    297      1.1  macallan 	cur->cur.data_s = (sc->sc_flags & PMU_PWR_BATT_PRESENT);
    298      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    299      1.1  macallan 
    300      1.1  macallan 	cur = &sc->sc_sdata[BAT_VOLTAGE];
    301      1.1  macallan 	cur->cur.data_s = sc->sc_voltage * 1000;
    302      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    303      1.1  macallan 
    304      1.1  macallan 	cur = &sc->sc_sdata[BAT_CURRENT];
    305      1.1  macallan 	cur->cur.data_s = sc->sc_current * 1000;
    306      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    307      1.1  macallan 
    308      1.1  macallan 	cur = &sc->sc_sdata[BAT_CHARGE];
    309      1.1  macallan 	cur->cur.data_s = sc->sc_charge;
    310      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    311      1.1  macallan 
    312      1.1  macallan 	cur = &sc->sc_sdata[BAT_MAX_CHARGE];
    313      1.1  macallan 	cur->cur.data_s = 100;
    314      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    315      1.1  macallan 
    316      1.1  macallan 	cur = &sc->sc_sdata[BAT_TEMPERATURE];
    317      1.1  macallan 	cur->cur.data_s = sc->sc_bat_temp * 1000000 + 273150000;
    318      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    319      1.1  macallan 
    320      1.1  macallan 	cur = &sc->sc_sdata[BAT_CHARGING];
    321      1.1  macallan 	cur->cur.data_s = (sc->sc_flags & PMU_PWR_BATT_CHARGING);
    322      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    323      1.1  macallan 
    324      1.1  macallan 	cur = &sc->sc_sdata[BAT_DISCHARGING];
    325      1.1  macallan 	cur->cur.data_s = (!(sc->sc_flags & PMU_PWR_BATT_CHARGING)) &&
    326      1.1  macallan 	    (!(sc->sc_flags & PMU_PWR_AC_PRESENT));
    327      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    328      1.1  macallan 
    329      1.1  macallan 	cur = &sc->sc_sdata[BAT_FULL];
    330      1.1  macallan 	cur->cur.data_s = (sc->sc_flags & PMU_PWR_BATT_FULL);
    331      1.1  macallan 	cur->validflags = ENVSYS_FVALID | ENVSYS_FCURVALID;
    332      1.1  macallan 
    333      1.1  macallan 	memcpy(tred, &sc->sc_sdata[which], sizeof(struct envsys_tre_data));
    334      1.1  macallan 	return 0;
    335      1.1  macallan }
    336      1.1  macallan 
    337      1.1  macallan static int
    338      1.1  macallan battery_streinfo(struct sysmon_envsys *sme, struct envsys_basic_info *binfo)
    339      1.1  macallan {
    340      1.1  macallan 
    341      1.1  macallan 	/* XXX Not implemented */
    342      1.1  macallan 	binfo->validflags = 0;
    343      1.1  macallan 
    344      1.1  macallan 	return 0;
    345      1.1  macallan }
    346  1.2.4.1  macallan 
    347  1.2.4.1  macallan static void
    348  1.2.4.1  macallan battery_poll(void *cookie)
    349  1.2.4.1  macallan {
    350  1.2.4.1  macallan 	struct battery_softc *sc = cookie;
    351  1.2.4.1  macallan 
    352  1.2.4.1  macallan 	battery_update(sc, 0);
    353  1.2.4.1  macallan 	if ((sc->sc_flags & PMU_PWR_AC_PRESENT) == sc->sc_oflags)
    354  1.2.4.1  macallan 		return;
    355  1.2.4.1  macallan 
    356  1.2.4.1  macallan 	sc->sc_oflags = sc->sc_flags & PMU_PWR_AC_PRESENT;
    357  1.2.4.1  macallan 
    358  1.2.4.1  macallan 	sysmon_pswitch_event(&sc->sc_sm_acpower,
    359  1.2.4.1  macallan 	    sc->sc_oflags ? PSWITCH_EVENT_PRESSED :
    360  1.2.4.1  macallan 	    PSWITCH_EVENT_RELEASED);
    361  1.2.4.1  macallan }
    362