xref: /openbmc/linux/include/linux/apm-emulation.h (revision f0aa4fa4)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /* -*- linux-c -*-
3  *
4  * (C) 2003 zecke@handhelds.org
5  *
6  * based on arch/arm/kernel/apm.c
7  * factor out the information needed by architectures to provide
8  * apm status
9  */
10 #ifndef __LINUX_APM_EMULATION_H
11 #define __LINUX_APM_EMULATION_H
12 
13 #include <linux/apm_bios.h>
14 
15 /*
16  * This structure gets filled in by the machine specific 'get_power_status'
17  * implementation.  Any fields which are not set default to a safe value.
18  */
19 struct apm_power_info {
20 	unsigned char	ac_line_status;
21 #define APM_AC_OFFLINE			0
22 #define APM_AC_ONLINE			1
23 #define APM_AC_BACKUP			2
24 #define APM_AC_UNKNOWN			0xff
25 
26 	unsigned char	battery_status;
27 #define APM_BATTERY_STATUS_HIGH		0
28 #define APM_BATTERY_STATUS_LOW		1
29 #define APM_BATTERY_STATUS_CRITICAL	2
30 #define APM_BATTERY_STATUS_CHARGING	3
31 #define APM_BATTERY_STATUS_NOT_PRESENT	4
32 #define APM_BATTERY_STATUS_UNKNOWN	0xff
33 
34 	unsigned char	battery_flag;
35 #define APM_BATTERY_FLAG_HIGH		(1 << 0)
36 #define APM_BATTERY_FLAG_LOW		(1 << 1)
37 #define APM_BATTERY_FLAG_CRITICAL	(1 << 2)
38 #define APM_BATTERY_FLAG_CHARGING	(1 << 3)
39 #define APM_BATTERY_FLAG_NOT_PRESENT	(1 << 7)
40 #define APM_BATTERY_FLAG_UNKNOWN	0xff
41 
42 	int		battery_life;
43 	int		time;
44 	int		units;
45 #define APM_UNITS_MINS			0
46 #define APM_UNITS_SECS			1
47 #define APM_UNITS_UNKNOWN		-1
48 
49 };
50 
51 /*
52  * This allows machines to provide their own "apm get power status" function.
53  */
54 extern void (*apm_get_power_status)(struct apm_power_info *);
55 
56 /*
57  * Queue an event (APM_SYS_SUSPEND or APM_CRITICAL_SUSPEND)
58  */
59 void apm_queue_event(apm_event_t event);
60 
61 #endif /* __LINUX_APM_EMULATION_H */
62