Initial APM support (enough to get battery level)
This commit is contained in:
parent
eee61c81f0
commit
e77de5cb68
@ -1,4 +1,4 @@
|
||||
# $NetBSD: majors.arm32,v 1.2 2002/09/06 13:18:43 gehenna Exp $
|
||||
# $NetBSD: majors.arm32,v 1.3 2002/09/16 19:52:53 manu Exp $
|
||||
#
|
||||
# Device majors for arm32
|
||||
#
|
||||
@ -98,3 +98,4 @@ device-major kttcp char 99 kttcp
|
||||
device-major ixpcom char 100 ixpcom
|
||||
device-major sysmon char 101 sysmon
|
||||
device-major dmoverio char 102 dmoverio
|
||||
device-major apm char 103 apm
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: files.hpcarm,v 1.46 2002/09/06 13:18:43 gehenna Exp $
|
||||
# $NetBSD: files.hpcarm,v 1.47 2002/09/16 19:52:52 manu Exp $
|
||||
#
|
||||
# First try for arm-specific configuration info
|
||||
#
|
||||
@ -65,13 +65,18 @@ device sed: hpcfbif
|
||||
attach sed at saip
|
||||
file arch/hpcarm/dev/sed_saip.c sed
|
||||
|
||||
device j720ssp: wskbddev, wsmousedev, tpcalib
|
||||
device j720ssp {}: wskbddev, wsmousedev, tpcalib
|
||||
attach j720ssp at saip
|
||||
file arch/hpcarm/dev/j720ssp.c j720ssp
|
||||
file arch/hpcarm/dev/j720kbdmap.c j720ssp
|
||||
|
||||
file dev/cninit.c
|
||||
|
||||
# APM
|
||||
device apm
|
||||
attach apm at j720ssp
|
||||
file arch/hpcarm/dev/apm.c apm needs-count
|
||||
|
||||
# Atmel microcontroller
|
||||
device atmelgpioif {}
|
||||
device atmelgpio: atmelgpioif
|
||||
|
158
sys/arch/hpcarm/dev/apm.c
Normal file
158
sys/arch/hpcarm/dev/apm.c
Normal file
@ -0,0 +1,158 @@
|
||||
/* $NetBSD: apm.c,v 1.1 2002/09/16 19:52:54 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Emmanuel Dreyfus
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "apm.h"
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.1 2002/09/16 19:52:54 manu Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/poll.h>
|
||||
#include <sys/conf.h>
|
||||
|
||||
#include <machine/apmvar.h>
|
||||
|
||||
extern struct cfdriver apm_cd;
|
||||
extern int hpcarm_apm_getpower(struct apm_power_info *, void *);
|
||||
|
||||
int apmmatch(struct device *, struct cfdata *, void *);
|
||||
void apmattach(struct device *, struct device *, void *);
|
||||
dev_type_open(apmopen);
|
||||
dev_type_close(apmclose);
|
||||
dev_type_ioctl(apmioctl);
|
||||
dev_type_poll(apmpoll);
|
||||
|
||||
|
||||
struct apm_softc {
|
||||
struct device sc_dev;
|
||||
void *sc_parent;
|
||||
};
|
||||
|
||||
struct cfattach apm_ca = {
|
||||
sizeof(struct apm_softc), apmmatch, apmattach, NULL, NULL
|
||||
};
|
||||
|
||||
const struct cdevsw apm_cdevsw = {
|
||||
apmopen, apmclose, noread, nowrite, apmioctl,
|
||||
nostop, notty, apmpoll, nommap,
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
apmmatch(parent, match, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *match;
|
||||
void *aux;
|
||||
{
|
||||
struct apm_attach_args *apm_args = (struct apm_attach_args *)aux;
|
||||
return (apm_args->aaa_magic == APM_ATTACH_ARGS_MAGIC);
|
||||
}
|
||||
|
||||
void
|
||||
apmattach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct apm_softc *sc = (struct apm_softc *)self;
|
||||
|
||||
sc->sc_parent = (void *)parent;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
apmopen(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
apmclose(dev, flag, mode, p)
|
||||
dev_t dev;
|
||||
int flag, mode;
|
||||
struct proc *p;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
apmioctl(dev, cmd, data, flag, p)
|
||||
dev_t dev;
|
||||
u_long cmd;
|
||||
caddr_t data;
|
||||
int flag;
|
||||
struct proc *p;
|
||||
{
|
||||
struct apm_softc *sc;;
|
||||
|
||||
if ((apm_cd.cd_ndevs == 0) || (minor(dev) & 0xf0) ||
|
||||
((sc = apm_cd.cd_devs[minor(dev) & 0xf0]) == NULL))
|
||||
return ENXIO;
|
||||
|
||||
switch (cmd) {
|
||||
case APM_IOC_GETPOWER:
|
||||
return hpcarm_apm_getpower((struct apm_power_info *)data,
|
||||
sc->sc_parent);
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
apmpoll(dev, events, p)
|
||||
dev_t dev;
|
||||
int events;
|
||||
struct proc *p;
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
# $NetBSD: Makefile,v 1.17 2002/08/07 05:15:21 briggs Exp $
|
||||
# $NetBSD: Makefile,v 1.18 2002/09/16 19:52:55 manu Exp $
|
||||
|
||||
KDIR= /sys/arch/hpcarm/include
|
||||
INCSDIR= /usr/include/hpcarm
|
||||
|
||||
INCS= ansi.h aout_machdep.h asm.h \
|
||||
INCS= ansi.h apmvar.h aout_machdep.h asm.h \
|
||||
bswap.h bus.h \
|
||||
cdefs.h cpu.h \
|
||||
db_machdep.h disklabel.h \
|
||||
|
76
sys/arch/hpcarm/include/apmvar.h
Normal file
76
sys/arch/hpcarm/include/apmvar.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: apmvar.h,v 1.1 2002/09/16 19:52:55 manu Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Emmanuel Dreyfus
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
struct apm_attach_args {
|
||||
int aaa_magic;
|
||||
};
|
||||
#define APM_ATTACH_ARGS_MAGIC 0x0061706d
|
||||
|
||||
/*
|
||||
* All definitions from here are duplicated in i386 and macppc
|
||||
* versions. The definitions are the same, it is probably worth
|
||||
* moving them in a MI place.
|
||||
*/
|
||||
|
||||
#define APM_AC_OFF 0x00
|
||||
#define APM_AC_ON 0x01
|
||||
#define APM_AC_BACKUP 0x02
|
||||
#define APM_AC_UNKNOWN 0xff
|
||||
#define APM_BATT_HIGH 0x00
|
||||
#define APM_BATT_LOW 0x01
|
||||
#define APM_BATT_CRITICAL 0x02
|
||||
#define APM_BATT_CHARGING 0x03
|
||||
#define APM_BATT_ABSENT 0x04
|
||||
#define APM_BATT_UNKNOWN 0xff
|
||||
#define APM_BATT_LIFE_UNKNOWN 0xff
|
||||
|
||||
struct apm_power_info {
|
||||
u_char battery_state;
|
||||
u_char ac_state;
|
||||
u_char battery_life;
|
||||
u_char spare1;
|
||||
u_int minutes_left; /* estimate */
|
||||
u_int nbattery;
|
||||
u_int batteryid;
|
||||
u_int spare2[4];
|
||||
};
|
||||
|
||||
/* ioctl definitions */
|
||||
#define APM_IOC_STANDBY _IO('A', 1)
|
||||
#define APM_IOC_SUSPEND _IO('A', 2)
|
||||
#define APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info)
|
Loading…
Reference in New Issue
Block a user