acpidev.h revision 1.4
1/* $OpenBSD: acpidev.h,v 1.4 2006/02/16 22:14:32 marco Exp $ */
2/*
3 * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org>
4 * Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19#ifndef __DEV_ACPI_ACPIDEV_H__
20#define __DEV_ACPI_ACPIDEV_H__
21
22#define DEVNAME(s)  ((s)->sc_dev.dv_xname)
23
24/*
25 * _BIF (Battery InFormation)
26 * Arguments: none
27 * Results  : package _BIF (Battery InFormation)
28 * Package {
29 * 	// ASCIIZ is ASCII character string terminated with a 0x00.
30 * 	Power Unit			//DWORD
31 * 	Design Capacity			//DWORD
32 * 	Last Full Charge Capacity	//DWORD
33 * 	Battery Technology		//DWORD
34 * 	Design Voltage			//DWORD
35 * 	Design Capacity of Warning	//DWORD
36 * 	Design Capacity of Low		//DWORD
37 * 	Battery Capacity Granularity 1	//DWORD
38 * 	Battery Capacity Granularity 2	//DWORD
39 * 	Model Number			//ASCIIZ
40 * 	Serial Number			//ASCIIZ
41 * 	Battery Type			//ASCIIZ
42 * 	OEM Information			//ASCIIZ
43 * }
44 */
45struct acpibat_bif {
46	u_int32_t	bif_power_unit;
47#define BIF_POWER_MW		0x00
48#define BIF_POWER_MA		0x01
49	u_int32_t	bif_capacity;
50#define BIF_UNKNOWN		0xffffffff
51	u_int32_t	bif_last_capacity;
52	u_int32_t	bif_technology;
53#define BIF_TECH_PRIMARY	0x00
54#define BIF_TECH_SECONDARY	0x01
55	u_int32_t	bif_voltage;
56	u_int32_t	bif_warning;
57	u_int32_t	bif_low;
58	u_int32_t	bif_cap_granu1;
59	u_int32_t	bif_cap_granu2;
60	const char	*bif_model;
61	const char	*bif_serial;
62	const char	*bif_type;
63	const char	*bif_oem;
64};
65
66/*
67 * _OSC Definition for Control Method Battery
68 * Arguments: none
69 * Results  : DWORD flags
70 */
71#define CMB_OSC_UUID		"f18fc78b-0f15-4978-b793-53f833a1d35b"
72#define   CMB_OSC_GRANULARITY	0x01
73#define   CMB_OSC_WAKE_ON_LOW	0x02
74
75/*
76 * _BST (Battery STatus)
77 * Arguments: none
78 * Results  : package _BST (Battery STatus)
79 * Package {
80 * 	Battery State			//DWORD
81 * 	Battery Present Rate		//DWORD
82 * 	Battery Remaining Capacity	//DWORD
83 * 	Battery Present Voltage		//DWORD
84 * }
85 *
86 * Per the spec section 10.2.2.3
87 * Remaining Battery Percentage[%] = (Battery Remaining Capacity [=0 ~ 100] /
88 *     Last Full Charged Capacity[=100]) * 100
89 *
90 * Remaining Battery Life [h] = Battery Remaining Capacity [mAh/mWh] /
91 *     Battery Present Rate [=0xFFFFFFFF] = unknown
92 */
93struct acpibat_bst {
94	u_int32_t	bst_state;
95#define BST_DISCHARGE		0x01
96#define BST_CHARGE		0x02
97#define BST_CRITICAL		0x04
98	u_int32_t	bst_rate;
99#define BST_UNKNOWN		0xffffffff
100	u_int32_t	bst_capacity;
101	u_int32_t	bst_voltage;
102};
103
104/*
105 * _BTP (Battery Trip Point)
106 * Arguments: DWORD level
107 * Results  : none
108 */
109#define BTP_CLEAR_TRIP_POINT	0x00
110
111/*
112 * _BTM (Battery TiMe)
113 * Arguments: DWORD rate of discharge
114 * Results  : DWORD time in seconds or error/unknown
115 */
116#define BTM_CURRENT_RATE	0x00
117
118#define BTM_RATE_TOO_LARGE	0x00
119#define BTM_CRITICAL		0x00
120#define BTM_UNKNOWN		0xffffffff
121
122/*
123 * _BMD (Battery Maintenance Data)
124 * Arguments: none
125 * Results  : package _BMD (Battery Maintenance Data)
126 * Package {
127 * 	Status Flags		//DWORD
128 * 	Capability Flags	//DWORD
129 * 	Recalibrate Count	//DWORD
130 * 	Quick Recalibrate Time	//DWORD
131 * 	Slow Recalibrate Time	//DWORD
132 * }
133 */
134struct acpibat_bmd {
135	u_int32_t	bmd_status;
136#define BMD_AML_CALIBRATE_CYCLE	0x01
137#define BMD_CHARGING_DISABLED	0x02
138#define BMD_DISCHARGE_WHILE_AC	0x04
139#define BMD_RECALIBRATE_BAT	0x08
140#define BMD_GOTO_STANDBY_SPEED	0x10
141	u_int32_t	bmd_capability;
142#define BMD_CB_AML_CALIBRATION	0x01
143#define BMD_CB_DISABLE_CHARGER	0x02
144#define BMD_CB_DISCH_WHILE_AC	0x04
145#define BMD_CB_AFFECT_ALL_BATT	0x08
146#define BMD_CB_FULL_CHRG_FIRST	0x10
147	u_int32_t	bmd_recalibrate_count;
148#define BMD_ONLY_CALIB_IF_ST3	0x00	/* only recal when status bit 3 set */
149	u_int32_t	bmd_quick_recalibrate_time;
150#define BMD_UNKNOWN		0xffffffff
151	u_int32_t	bmd_slow_recalibrate_time;
152};
153
154/*
155 * _BMC (Battery Maintenance Control)
156 * Arguments: DWORD flags
157 * Results  : none
158 */
159#define BMC_AML_CALIBRATE	0x01
160#define BMC_DISABLE_CHARGING	0x02
161#define BMC_ALLOW_AC_DISCHARGE	0x04
162
163/* AC device */
164/*
165 * _PSR (Power Source)
166 * Arguments: none
167 * Results  : DWORD status
168 */
169#define PSR_OFFLINE		0x00
170#define PSR_ONLINE		0x01
171
172/*
173 * _PCL (Power Consumer List)
174 * Arguments: none
175 * Results  : LIST of Power Class pointers
176 */
177
178/* hpet device */
179#define	HPET_REG_SIZE		1024
180
181#define	HPET_CAPABILITIES	0x000
182#define	HPET_CONFIGURATION	0x010
183#define	HPET_INTERRUPT_STATUS	0x020
184#define	HPET_MAIN_COUNTER	0x0F0
185#define	HPET_TIMER0_CONFIG	0x100
186#define	HPET_TIMER0_COMPARE	0x108
187#define	HPET_TIMER0_INTERRUPT	0x110
188#define	HPET_TIMER1_CONFIG	0x200
189#define	HPET_TIMER1_COMPARE	0x208
190#define	HPET_TIMER1_INTERRUPT	0x310
191#define	HPET_TIMER2_CONFIG	0x400
192#define	HPET_TIMER2_COMPARE	0x408
193#define	HPET_TIMER2_INTERRUPT	0x510
194
195#endif /* __DEV_ACPI_ACPIDEV_H__ */
196