blob: 32d14017701a8280d16af572658093b38a2b07fd [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Graeme Russ95ffaba2010-04-24 00:05:49 +10002#ifndef _LINUX_APM_H
3#define _LINUX_APM_H
4
5/*
6 * Include file for the interface to an APM BIOS
7 * Copyright 1994-2001 Stephen Rothwell (sfr@canb.auug.org.au)
Graeme Russ95ffaba2010-04-24 00:05:49 +10008 */
9
10#include <linux/types.h>
11
12typedef unsigned short apm_event_t;
13typedef unsigned short apm_eventinfo_t;
14
15struct apm_bios_info {
16 __u16 version;
17 __u16 cseg;
18 __u32 offset;
19 __u16 cseg_16;
20 __u16 dseg;
21 __u16 flags;
22 __u16 cseg_len;
23 __u16 cseg_16_len;
24 __u16 dseg_len;
25};
26
27#ifdef __KERNEL__
28
29#define APM_CS (GDT_ENTRY_APMBIOS_BASE * 8)
30#define APM_CS_16 (APM_CS + 8)
31#define APM_DS (APM_CS_16 + 8)
32
33/* Results of APM Installation Check */
34#define APM_16_BIT_SUPPORT 0x0001
35#define APM_32_BIT_SUPPORT 0x0002
36#define APM_IDLE_SLOWS_CLOCK 0x0004
Wolfgang Denk0cf207e2021-09-27 17:42:39 +020037#define APM_BIOS_DISABLED 0x0008
Graeme Russ95ffaba2010-04-24 00:05:49 +100038#define APM_BIOS_DISENGAGED 0x0010
39
40/*
41 * Data for APM that is persistent across module unload/load
42 */
43struct apm_info {
44 struct apm_bios_info bios;
45 unsigned short connection_version;
46 int get_power_status_broken;
47 int get_power_status_swabinminutes;
48 int allow_ints;
49 int forbid_idle;
50 int realmode_power_off;
51 int disabled;
52};
53
54/*
55 * The APM function codes
56 */
57#define APM_FUNC_INST_CHECK 0x5300
58#define APM_FUNC_REAL_CONN 0x5301
59#define APM_FUNC_16BIT_CONN 0x5302
60#define APM_FUNC_32BIT_CONN 0x5303
61#define APM_FUNC_DISCONN 0x5304
62#define APM_FUNC_IDLE 0x5305
63#define APM_FUNC_BUSY 0x5306
64#define APM_FUNC_SET_STATE 0x5307
65#define APM_FUNC_ENABLE_PM 0x5308
66#define APM_FUNC_RESTORE_BIOS 0x5309
67#define APM_FUNC_GET_STATUS 0x530a
68#define APM_FUNC_GET_EVENT 0x530b
69#define APM_FUNC_GET_STATE 0x530c
70#define APM_FUNC_ENABLE_DEV_PM 0x530d
71#define APM_FUNC_VERSION 0x530e
72#define APM_FUNC_ENGAGE_PM 0x530f
73#define APM_FUNC_GET_CAP 0x5310
74#define APM_FUNC_RESUME_TIMER 0x5311
75#define APM_FUNC_RESUME_ON_RING 0x5312
76#define APM_FUNC_TIMER 0x5313
77
78/*
79 * Function code for APM_FUNC_RESUME_TIMER
80 */
81#define APM_FUNC_DISABLE_TIMER 0
82#define APM_FUNC_GET_TIMER 1
83#define APM_FUNC_SET_TIMER 2
84
85/*
86 * Function code for APM_FUNC_RESUME_ON_RING
87 */
88#define APM_FUNC_DISABLE_RING 0
89#define APM_FUNC_ENABLE_RING 1
90#define APM_FUNC_GET_RING 2
91
92/*
93 * Function code for APM_FUNC_TIMER_STATUS
94 */
95#define APM_FUNC_TIMER_DISABLE 0
96#define APM_FUNC_TIMER_ENABLE 1
97#define APM_FUNC_TIMER_GET 2
98
99/*
100 * in arch/i386/kernel/setup.c
101 */
102extern struct apm_info apm_info;
103
104#endif /* __KERNEL__ */
105
106/*
107 * Power states
108 */
109#define APM_STATE_READY 0x0000
110#define APM_STATE_STANDBY 0x0001
111#define APM_STATE_SUSPEND 0x0002
112#define APM_STATE_OFF 0x0003
113#define APM_STATE_BUSY 0x0004
114#define APM_STATE_REJECT 0x0005
115#define APM_STATE_OEM_SYS 0x0020
116#define APM_STATE_OEM_DEV 0x0040
117
118#define APM_STATE_DISABLE 0x0000
119#define APM_STATE_ENABLE 0x0001
120
121#define APM_STATE_DISENGAGE 0x0000
122#define APM_STATE_ENGAGE 0x0001
123
124/*
125 * Events (results of Get PM Event)
126 */
127#define APM_SYS_STANDBY 0x0001
128#define APM_SYS_SUSPEND 0x0002
129#define APM_NORMAL_RESUME 0x0003
130#define APM_CRITICAL_RESUME 0x0004
131#define APM_LOW_BATTERY 0x0005
132#define APM_POWER_STATUS_CHANGE 0x0006
133#define APM_UPDATE_TIME 0x0007
134#define APM_CRITICAL_SUSPEND 0x0008
135#define APM_USER_STANDBY 0x0009
136#define APM_USER_SUSPEND 0x000a
137#define APM_STANDBY_RESUME 0x000b
138#define APM_CAPABILITY_CHANGE 0x000c
139
140/*
141 * Error codes
142 */
143#define APM_SUCCESS 0x00
144#define APM_DISABLED 0x01
145#define APM_CONNECTED 0x02
146#define APM_NOT_CONNECTED 0x03
147#define APM_16_CONNECTED 0x05
148#define APM_16_UNSUPPORTED 0x06
149#define APM_32_CONNECTED 0x07
150#define APM_32_UNSUPPORTED 0x08
151#define APM_BAD_DEVICE 0x09
152#define APM_BAD_PARAM 0x0a
153#define APM_NOT_ENGAGED 0x0b
154#define APM_BAD_FUNCTION 0x0c
155#define APM_RESUME_DISABLED 0x0d
156#define APM_NO_ERROR 0x53
157#define APM_BAD_STATE 0x60
158#define APM_NO_EVENTS 0x80
159#define APM_NOT_PRESENT 0x86
160
161/*
162 * APM Device IDs
163 */
164#define APM_DEVICE_BIOS 0x0000
165#define APM_DEVICE_ALL 0x0001
166#define APM_DEVICE_DISPLAY 0x0100
167#define APM_DEVICE_STORAGE 0x0200
168#define APM_DEVICE_PARALLEL 0x0300
169#define APM_DEVICE_SERIAL 0x0400
170#define APM_DEVICE_NETWORK 0x0500
171#define APM_DEVICE_PCMCIA 0x0600
172#define APM_DEVICE_BATTERY 0x8000
173#define APM_DEVICE_OEM 0xe000
174#define APM_DEVICE_OLD_ALL 0xffff
175#define APM_DEVICE_CLASS 0x00ff
176#define APM_DEVICE_MASK 0xff00
177
178#ifdef __KERNEL__
179/*
180 * This is the "All Devices" ID communicated to the BIOS
181 */
182#define APM_DEVICE_BALL ((apm_info.connection_version > 0x0100) ? \
183 APM_DEVICE_ALL : APM_DEVICE_OLD_ALL)
184#endif
185
186/*
187 * Battery status
188 */
189#define APM_MAX_BATTERIES 2
190
191/*
192 * APM defined capability bit flags
193 */
194#define APM_CAP_GLOBAL_STANDBY 0x0001
195#define APM_CAP_GLOBAL_SUSPEND 0x0002
196#define APM_CAP_RESUME_STANDBY_TIMER 0x0004 /* Timer resume from standby */
197#define APM_CAP_RESUME_SUSPEND_TIMER 0x0008 /* Timer resume from suspend */
198#define APM_CAP_RESUME_STANDBY_RING 0x0010 /* Resume on Ring fr standby */
199#define APM_CAP_RESUME_SUSPEND_RING 0x0020 /* Resume on Ring fr suspend */
200#define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040 /* Resume on PCMCIA Ring */
201#define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080 /* Resume on PCMCIA Ring */
202
203/*
204 * ioctl operations
205 */
206#include <linux/ioctl.h>
207
208#define APM_IOC_STANDBY _IO('A', 1)
209#define APM_IOC_SUSPEND _IO('A', 2)
210
211#endif /* LINUX_APM_H */