xref: /openbsd-src/sys/arch/arm/include/apmvar.h (revision cd56ea097150e82cade6656d44978184e018e288)
1*cd56ea09Sphessler /*	$OpenBSD: apmvar.h,v 1.6 2019/01/22 02:36:30 phessler Exp $	*/
26b1405b6Suwe 
36b1405b6Suwe /*
46b1405b6Suwe  *  Copyright (c) 2001 Alexander Guy
56b1405b6Suwe  *  Copyright (c) 1995 John T. Kohl
66b1405b6Suwe  *  All rights reserved.
76b1405b6Suwe  *
86b1405b6Suwe  *  Redistribution and use in source and binary forms, with or without
96b1405b6Suwe  *  modification, are permitted provided that the following conditions
106b1405b6Suwe  *  are met:
116b1405b6Suwe  *  1. Redistributions of source code must retain the above copyright
126b1405b6Suwe  *     notice, this list of conditions and the following disclaimer.
136b1405b6Suwe  *  2. Redistributions in binary form must reproduce the above copyright
146b1405b6Suwe  *     notice, this list of conditions and the following disclaimer in the
156b1405b6Suwe  *     documentation and/or other materials provided with the distribution.
166b1405b6Suwe  *  3. The name of the author may not be used to endorse or promote products
176b1405b6Suwe  *     derived from this software without specific prior written permission.
186b1405b6Suwe  *
196b1405b6Suwe  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
206b1405b6Suwe  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
216b1405b6Suwe  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
226b1405b6Suwe  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
236b1405b6Suwe  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
246b1405b6Suwe  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
256b1405b6Suwe  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
266b1405b6Suwe  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
276b1405b6Suwe  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
286b1405b6Suwe  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
296b1405b6Suwe  * POSSIBILITY OF SUCH DAMAGE.
306b1405b6Suwe  *
316b1405b6Suwe  */
326b1405b6Suwe #ifndef _ARM_APMVAR_H_
336b1405b6Suwe #define _ARM_APMVAR_H_
346b1405b6Suwe 
356b1405b6Suwe #include <sys/ioccom.h>
366b1405b6Suwe 
376b1405b6Suwe /* Advanced Power Management (v1.0 and v1.1 specification)
386b1405b6Suwe  * functions/defines/etc.
396b1405b6Suwe  */
406b1405b6Suwe 
416b1405b6Suwe /* These definitions make up the heart of the user-land interface
426b1405b6Suwe  * to the APM devices.
436b1405b6Suwe  */
446b1405b6Suwe 
456b1405b6Suwe #define		APM_AC_OFF		0x00
466b1405b6Suwe #define		APM_AC_ON		0x01
476b1405b6Suwe #define		APM_AC_BACKUP		0x02
486b1405b6Suwe #define		APM_AC_UNKNOWN		0xff
496b1405b6Suwe #define		APM_BATT_HIGH		0x00
506b1405b6Suwe #define		APM_BATT_LOW		0x01
516b1405b6Suwe #define		APM_BATT_CRITICAL	0x02
526b1405b6Suwe #define		APM_BATT_CHARGING	0x03
536b1405b6Suwe #define		APM_BATT_UNKNOWN	0xff
546b1405b6Suwe #define		APM_BATT_LIFE_UNKNOWN	0xff
556b1405b6Suwe 
566b1405b6Suwe #define		APM_NOEVENT		0x0000
576b1405b6Suwe #define		APM_STANDBY_REQ		0x0001
586b1405b6Suwe #define		APM_SUSPEND_REQ		0x0002
596b1405b6Suwe #define		APM_NORMAL_RESUME	0x0003
606b1405b6Suwe #define		APM_CRIT_RESUME		0x0004 /* suspend/resume happened
616b1405b6Suwe 						  without us */
626b1405b6Suwe #define		APM_BATTERY_LOW		0x0005
636b1405b6Suwe #define		APM_POWER_CHANGE	0x0006
646b1405b6Suwe #define		APM_UPDATE_TIME		0x0007
656b1405b6Suwe #define		APM_CRIT_SUSPEND_REQ	0x0008
666b1405b6Suwe #define		APM_USER_STANDBY_REQ	0x0009
676b1405b6Suwe #define		APM_USER_SUSPEND_REQ	0x000A
686b1405b6Suwe #define		APM_SYS_STANDBY_RESUME	0x000B
696b1405b6Suwe #define		APM_CAPABILITY_CHANGE	0x000C	/* apm v1.2 */
70a802036bSmiod #define		APM_USER_HIBERNATE_REQ	0x000D
716b1405b6Suwe #define		APM_EVENT_MASK		0xffff
726b1405b6Suwe 
736b1405b6Suwe #define	APM_EVENT_COMPOSE(t,i)	((((i) & 0x7fff) << 16)|((t) & APM_EVENT_MASK))
746b1405b6Suwe #define	APM_EVENT_TYPE(e)	((e) & APM_EVENT_MASK)
756b1405b6Suwe #define	APM_EVENT_INDEX(e)	((e) >> 16)
766b1405b6Suwe 
776b1405b6Suwe /*
786b1405b6Suwe  * LP (Laptop Package)
796b1405b6Suwe  *
806b1405b6Suwe  * Copyright (C) 1994 by HOSOKAWA Tatsumi <hosokawa@mt.cs.keio.ac.jp>
816b1405b6Suwe  *
826b1405b6Suwe  * This software may be used, modified, copied, and distributed, in
836b1405b6Suwe  * both source and binary form provided that the above copyright and
846b1405b6Suwe  * these terms are retained. Under no circumstances is the author
856b1405b6Suwe  * responsible for the proper functioning of this software, nor does
866b1405b6Suwe  * the author assume any responsibility for damages incurred with its
876b1405b6Suwe  * use.
886b1405b6Suwe  *
896b1405b6Suwe  * Sep., 1994	Implemented on FreeBSD 1.1.5.1R (Toshiba AVS001WD)
906b1405b6Suwe  */
916b1405b6Suwe 
926b1405b6Suwe #define APM_BATTERY_ABSENT 4
936b1405b6Suwe 
946b1405b6Suwe struct apm_power_info {
956b1405b6Suwe 	u_char battery_state;
966b1405b6Suwe 	u_char ac_state;
976b1405b6Suwe 	u_char battery_life;
986b1405b6Suwe 	u_char spare1;
996b1405b6Suwe 	u_int minutes_left;		/* estimate */
1006b1405b6Suwe 	u_int spare2[6];
1016b1405b6Suwe };
1026b1405b6Suwe 
1036b1405b6Suwe struct apm_ctl {
1046b1405b6Suwe 	u_int dev;
1056b1405b6Suwe 	u_int mode;
1066b1405b6Suwe };
1076b1405b6Suwe 
1086b1405b6Suwe #define	APM_IOC_REJECT	_IOW('A', 0, struct apm_event_info) /* reject request # */
1096b1405b6Suwe #define	APM_IOC_STANDBY	_IO('A', 1)	/* put system into standby */
1106b1405b6Suwe #define	APM_IOC_SUSPEND	_IO('A', 2)	/* put system into suspend */
1116b1405b6Suwe #define	APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
1126b1405b6Suwe #define	APM_IOC_DEV_CTL	_IOW('A', 5, struct apm_ctl) /* put device into mode */
1136b1405b6Suwe #define APM_IOC_PRN_CTL _IOW('A', 6, int ) /* driver power status msg */
1146b1405b6Suwe #define		APM_PRINT_ON	0	/* driver power status displayed */
1156b1405b6Suwe #define		APM_PRINT_OFF	1	/* driver power status not displayed */
1166b1405b6Suwe #define		APM_PRINT_PCT	2	/* driver power status only displayed
1176b1405b6Suwe 					   if the percentage changes */
1187939ba9cSoga #define	APM_IOC_STANDBY_REQ	_IO('A', 7)	/* request standby */
1197939ba9cSoga #define	APM_IOC_SUSPEND_REQ	_IO('A', 8)	/* request suspend */
1203d908d29Sderaadt #define	APM_IOC_HIBERNATE	_IO('A', 9)	/* put system into hibernate */
1216b1405b6Suwe 
1226b1405b6Suwe #endif /* _ARM_APMVAR_H_ */
123