- Stephen Rothwell: APM updates
[davej-history.git] / include / linux / apm_bios.h
blob9dba26eebfa40f432c35caacb352bd37141ed7c3
1 #ifndef _LINUX_APM_H
2 #define _LINUX_APM_H
4 /*
5 * Include file for the interface to an APM BIOS
6 * Copyright 1994-2000 Stephen Rothwell (sfr@linuxcare.com)
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
19 typedef unsigned short apm_event_t;
20 typedef unsigned short apm_eventinfo_t;
22 #ifdef __KERNEL__
24 #define APM_40 0x40
25 #define APM_CS (APM_40 + 8)
26 #define APM_CS_16 (APM_CS + 8)
27 #define APM_DS (APM_CS_16 + 8)
29 struct apm_bios_info {
30 unsigned short version;
31 unsigned short cseg;
32 unsigned long offset;
33 unsigned short cseg_16;
34 unsigned short dseg;
35 unsigned short flags;
36 unsigned short cseg_len;
37 unsigned short cseg_16_len;
38 unsigned short dseg_len;
41 /* Results of APM Installation Check */
42 #define APM_16_BIT_SUPPORT 0x0001
43 #define APM_32_BIT_SUPPORT 0x0002
44 #define APM_IDLE_SLOWS_CLOCK 0x0004
45 #define APM_BIOS_DISABLED 0x0008
46 #define APM_BIOS_DISENGAGED 0x0010
49 * Data for APM that is persistant across module unload/load
51 struct apm_info {
52 struct apm_bios_info bios;
53 unsigned short connection_version;
54 int get_power_status_broken;
58 * The APM function codes
60 #define APM_FUNC_INST_CHECK 0x5300
61 #define APM_FUNC_REAL_CONN 0x5301
62 #define APM_FUNC_16BIT_CONN 0x5302
63 #define APM_FUNC_32BIT_CONN 0x5303
64 #define APM_FUNC_DISCONN 0x5304
65 #define APM_FUNC_IDLE 0x5305
66 #define APM_FUNC_BUSY 0x5306
67 #define APM_FUNC_SET_STATE 0x5307
68 #define APM_FUNC_ENABLE_PM 0x5308
69 #define APM_FUNC_RESTORE_BIOS 0x5309
70 #define APM_FUNC_GET_STATUS 0x530a
71 #define APM_FUNC_GET_EVENT 0x530b
72 #define APM_FUNC_GET_STATE 0x530c
73 #define APM_FUNC_ENABLE_DEV_PM 0x530d
74 #define APM_FUNC_VERSION 0x530e
75 #define APM_FUNC_ENGAGE_PM 0x530f
76 #define APM_FUNC_GET_CAP 0x5310
77 #define APM_FUNC_RESUME_TIMER 0x5311
78 #define APM_FUNC_RESUME_ON_RING 0x5312
79 #define APM_FUNC_TIMER 0x5313
82 * Function code for APM_FUNC_RESUME_TIMER
84 #define APM_FUNC_DISABLE_TIMER 0
85 #define APM_FUNC_GET_TIMER 1
86 #define APM_FUNC_SET_TIMER 2
89 * Function code for APM_FUNC_RESUME_ON_RING
91 #define APM_FUNC_DISABLE_RING 0
92 #define APM_FUNC_ENABLE_RING 1
93 #define APM_FUNC_GET_RING 2
96 * Function code for APM_FUNC_TIMER_STATUS
98 #define APM_FUNC_TIMER_DISABLE 0
99 #define APM_FUNC_TIMER_ENABLE 1
100 #define APM_FUNC_TIMER_GET 2
103 * in arch/i386/kernel/setup.c
105 extern struct apm_info apm_info;
107 #endif /* __KERNEL__ */
110 * Power states
112 #define APM_STATE_READY 0x0000
113 #define APM_STATE_STANDBY 0x0001
114 #define APM_STATE_SUSPEND 0x0002
115 #define APM_STATE_OFF 0x0003
116 #define APM_STATE_BUSY 0x0004
117 #define APM_STATE_REJECT 0x0005
118 #define APM_STATE_OEM_SYS 0x0020
119 #define APM_STATE_OEM_DEV 0x0040
121 #define APM_STATE_DISABLE 0x0000
122 #define APM_STATE_ENABLE 0x0001
124 #define APM_STATE_DISENGAGE 0x0000
125 #define APM_STATE_ENGAGE 0x0001
128 * Events (results of Get PM Event)
130 #define APM_SYS_STANDBY 0x0001
131 #define APM_SYS_SUSPEND 0x0002
132 #define APM_NORMAL_RESUME 0x0003
133 #define APM_CRITICAL_RESUME 0x0004
134 #define APM_LOW_BATTERY 0x0005
135 #define APM_POWER_STATUS_CHANGE 0x0006
136 #define APM_UPDATE_TIME 0x0007
137 #define APM_CRITICAL_SUSPEND 0x0008
138 #define APM_USER_STANDBY 0x0009
139 #define APM_USER_SUSPEND 0x000a
140 #define APM_STANDBY_RESUME 0x000b
141 #define APM_CAPABILITY_CHANGE 0x000c
144 * Error codes
146 #define APM_SUCCESS 0x00
147 #define APM_DISABLED 0x01
148 #define APM_CONNECTED 0x02
149 #define APM_NOT_CONNECTED 0x03
150 #define APM_16_CONNECTED 0x05
151 #define APM_16_UNSUPPORTED 0x06
152 #define APM_32_CONNECTED 0x07
153 #define APM_32_UNSUPPORTED 0x08
154 #define APM_BAD_DEVICE 0x09
155 #define APM_BAD_PARAM 0x0a
156 #define APM_NOT_ENGAGED 0x0b
157 #define APM_BAD_FUNCTION 0x0c
158 #define APM_RESUME_DISABLED 0x0d
159 #define APM_NO_ERROR 0x53
160 #define APM_BAD_STATE 0x60
161 #define APM_NO_EVENTS 0x80
162 #define APM_NOT_PRESENT 0x86
165 * APM Device IDs
167 #define APM_DEVICE_BIOS 0x0000
168 #define APM_DEVICE_ALL 0x0001
169 #define APM_DEVICE_DISPLAY 0x0100
170 #define APM_DEVICE_STORAGE 0x0200
171 #define APM_DEVICE_PARALLEL 0x0300
172 #define APM_DEVICE_SERIAL 0x0400
173 #define APM_DEVICE_NETWORK 0x0500
174 #define APM_DEVICE_PCMCIA 0x0600
175 #define APM_DEVICE_BATTERY 0x8000
176 #define APM_DEVICE_OEM 0xe000
177 #define APM_DEVICE_OLD_ALL 0xffff
178 #define APM_DEVICE_CLASS 0x00ff
179 #define APM_DEVICE_MASK 0xff00
181 #ifdef __KERNEL__
183 * This is the "All Devices" ID communicated to the BIOS
185 #define APM_DEVICE_BALL ((apm_info.connection_version > 0x0100) ? \
186 APM_DEVICE_ALL : APM_DEVICE_OLD_ALL)
187 #endif
190 * Battery status
192 #define APM_MAX_BATTERIES 2
195 * APM defined capability bit flags
197 #define APM_CAP_GLOBAL_STANDBY 0x0001
198 #define APM_CAP_GLOBAL_SUSPEND 0x0002
199 #define APM_CAP_RESUME_STANDBY_TIMER 0x0004 /* Timer resume from standby */
200 #define APM_CAP_RESUME_SUSPEND_TIMER 0x0008 /* Timer resume from suspend */
201 #define APM_CAP_RESUME_STANDBY_RING 0x0010 /* Resume on Ring fr standby */
202 #define APM_CAP_RESUME_SUSPEND_RING 0x0020 /* Resume on Ring fr suspend */
203 #define APM_CAP_RESUME_STANDBY_PCMCIA 0x0040 /* Resume on PCMCIA Ring */
204 #define APM_CAP_RESUME_SUSPEND_PCMCIA 0x0080 /* Resume on PCMCIA Ring */
207 * ioctl operations
209 #include <linux/ioctl.h>
211 #define APM_IOC_STANDBY _IO('A', 1)
212 #define APM_IOC_SUSPEND _IO('A', 2)
214 #endif /* LINUX_APM_H */