xref: /titanic_41/usr/src/uts/common/sys/acpi_drv.h (revision 2d6b5ea734bb47d251c82670646fde46af15fd69)
1d2ec54f7Sphitran /*
2d2ec54f7Sphitran  * CDDL HEADER START
3d2ec54f7Sphitran  *
4d2ec54f7Sphitran  * The contents of this file are subject to the terms of the
5d2ec54f7Sphitran  * Common Development and Distribution License (the "License").
6d2ec54f7Sphitran  * You may not use this file except in compliance with the License.
7d2ec54f7Sphitran  *
8d2ec54f7Sphitran  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d2ec54f7Sphitran  * or http://www.opensolaris.org/os/licensing.
10d2ec54f7Sphitran  * See the License for the specific language governing permissions
11d2ec54f7Sphitran  * and limitations under the License.
12d2ec54f7Sphitran  *
13d2ec54f7Sphitran  * When distributing Covered Code, include this CDDL HEADER in each
14d2ec54f7Sphitran  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d2ec54f7Sphitran  * If applicable, add the following below this CDDL HEADER, with the
16d2ec54f7Sphitran  * fields enclosed by brackets "[]" replaced with your own identifying
17d2ec54f7Sphitran  * information: Portions Copyright [yyyy] [name of copyright owner]
18d2ec54f7Sphitran  *
19d2ec54f7Sphitran  * CDDL HEADER END
20d2ec54f7Sphitran  */
21d2ec54f7Sphitran 
22d2ec54f7Sphitran /*
23*2d6b5ea7SGuoli Shu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24d2ec54f7Sphitran  * Use is subject to license terms.
25d2ec54f7Sphitran  */
26d2ec54f7Sphitran 
27d2ec54f7Sphitran #ifndef _ACPI_DRV_H
28d2ec54f7Sphitran #define	_ACPI_DRV_H
29d2ec54f7Sphitran 
30d2ec54f7Sphitran #ifdef	__cplusplus
31d2ec54f7Sphitran extern "C" {
32d2ec54f7Sphitran #endif
33d2ec54f7Sphitran 
34d2ec54f7Sphitran #include <sys/param.h>
35d2ec54f7Sphitran #include <sys/kstat.h>
36d2ec54f7Sphitran 
37d2ec54f7Sphitran enum acpi_drv_ioctl {
38d2ec54f7Sphitran 	ACPI_DRV_IOC_BAY,
39d2ec54f7Sphitran 	ACPI_DRV_IOC_INFO,
40d2ec54f7Sphitran 	ACPI_DRV_IOC_STATUS,
41d2ec54f7Sphitran 	ACPI_DRV_IOC_AC_COUNT,
42d2ec54f7Sphitran 	ACPI_DRV_IOC_POWER_STATUS,
43d2ec54f7Sphitran 	ACPI_DRV_IOC_SET_WARNING,
44d2ec54f7Sphitran 	ACPI_DRV_IOC_GET_WARNING,
45d2ec54f7Sphitran 	ACPI_DRV_IOC_LID_STATUS,
46076d97abSPhi Tran 	ACPI_DRV_IOC_LID_UPDATE,
47d2ec54f7Sphitran 	ACPI_DRV_IOC_LEVELS,
48d2ec54f7Sphitran 	ACPI_DRV_IOC_SET_BRIGHTNESS
49d2ec54f7Sphitran };
50d2ec54f7Sphitran 
51d2ec54f7Sphitran #define	ACPI_DRV_BST_CHARGING		2
52d2ec54f7Sphitran #define	ACPI_DRV_BST_DISCHARGING	1
53d2ec54f7Sphitran 
54d2ec54f7Sphitran typedef struct batt_bay {
55d2ec54f7Sphitran 	/* Total number of bays in the system */
56d2ec54f7Sphitran 	int bay_number;
57d2ec54f7Sphitran 
58d2ec54f7Sphitran 	/*
59d2ec54f7Sphitran 	 * Bitmap for each bay and its battery.
60d2ec54f7Sphitran 	 * battery_map bit i:
61d2ec54f7Sphitran 	 *    1 -- battery inserted to bay i
62d2ec54f7Sphitran 	 *    0 -- bay i empty
63d2ec54f7Sphitran 	 */
64d2ec54f7Sphitran 	uint64_t battery_map;
65d2ec54f7Sphitran } batt_bay_t;
66d2ec54f7Sphitran 
67d2ec54f7Sphitran typedef	struct acpi_bif {
68d2ec54f7Sphitran 	uint32_t	bif_unit;
69d2ec54f7Sphitran 
70d2ec54f7Sphitran 	/*
71d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff
72d2ec54f7Sphitran 	 * 0xffffffff - Unknown design capacity in [mWh] or [mAh]
73d2ec54f7Sphitran 	 */
74d2ec54f7Sphitran 	uint32_t	bif_design_cap;
75d2ec54f7Sphitran 
76d2ec54f7Sphitran 	/*
77d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff
78d2ec54f7Sphitran 	 * 0xffffffff - Unknown last full charge capacity in [mWh] or [mAh]
79d2ec54f7Sphitran 	 */
80d2ec54f7Sphitran 	uint32_t	bif_last_cap;
81d2ec54f7Sphitran 
82d2ec54f7Sphitran 	uint32_t	bif_tech;
83d2ec54f7Sphitran 
84d2ec54f7Sphitran 	/*
85d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff
86d2ec54f7Sphitran 	 * 0xffffffff - Unknown design voltage in [mV]
87d2ec54f7Sphitran 	 */
88d2ec54f7Sphitran 	uint32_t	bif_voltage;
89d2ec54f7Sphitran 
90d2ec54f7Sphitran 	/*
91d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
92d2ec54f7Sphitran 	 */
93d2ec54f7Sphitran 	uint32_t	bif_warn_cap;
94d2ec54f7Sphitran 
95d2ec54f7Sphitran 	/*
96d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
97d2ec54f7Sphitran 	 */
98d2ec54f7Sphitran 	uint32_t	bif_low_cap;
99d2ec54f7Sphitran 
100d2ec54f7Sphitran 	uint32_t	bif_gran1_cap;
101d2ec54f7Sphitran 	uint32_t	bif_gran2_cap;
102d2ec54f7Sphitran 	char		bif_model[MAXNAMELEN];
103d2ec54f7Sphitran 	char		bif_serial[MAXNAMELEN];
104d2ec54f7Sphitran 	char		bif_type[MAXNAMELEN];
105d2ec54f7Sphitran 	char		bif_oem_info[MAXNAMELEN];
106d2ec54f7Sphitran } acpi_bif_t;
107d2ec54f7Sphitran 
108d2ec54f7Sphitran typedef	struct acpi_bst {
109d2ec54f7Sphitran 	uint32_t	bst_state;
110d2ec54f7Sphitran 
111d2ec54f7Sphitran 	/*
112d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff in [mW] or [mA]
113d2ec54f7Sphitran 	 * 0xffffffff - Unknown rate
114d2ec54f7Sphitran 	 */
115d2ec54f7Sphitran 	uint32_t	bst_rate;
116d2ec54f7Sphitran 
117d2ec54f7Sphitran 	/*
118d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
119d2ec54f7Sphitran 	 * 0xffffffff - Unknown capacity
120d2ec54f7Sphitran 	 */
121d2ec54f7Sphitran 	uint32_t	bst_rem_cap;
122d2ec54f7Sphitran 
123d2ec54f7Sphitran 	/*
124d2ec54f7Sphitran 	 * 0x00000000 - 0x7fffffff in [mV]
125d2ec54f7Sphitran 	 * 0xffffffff - Unknown voltage
126d2ec54f7Sphitran 	 */
127d2ec54f7Sphitran 	uint32_t	bst_voltage;
128d2ec54f7Sphitran } acpi_bst_t;
129d2ec54f7Sphitran 
130d2ec54f7Sphitran /* Battery warnning levels in percentage */
131d2ec54f7Sphitran typedef struct acpi_drv_warn {
132d2ec54f7Sphitran 	uint32_t	bw_enabled;	/* Enabled */
133d2ec54f7Sphitran 	uint32_t	bw_charge_warn;	/* charge warn threshold */
134d2ec54f7Sphitran 	uint32_t	bw_charge_low;	/* charge low threshold */
135d2ec54f7Sphitran } acpi_drv_warn_t;
136d2ec54f7Sphitran 
137d2ec54f7Sphitran #define	ACPI_DRV_NAME		"acpi_drv"
138d2ec54f7Sphitran #define	ACPI_DRV_POWER_KSTAT_NAME	"power"
139d2ec54f7Sphitran #define	ACPI_DRV_BTWARN_KSTAT_NAME	"battery warning"
140d2ec54f7Sphitran #define	ACPI_DRV_BIF_KSTAT_NAME		"battery BIF"
141d2ec54f7Sphitran #define	ACPI_DRV_BST_KSTAT_NAME		"battery BST"
142d2ec54f7Sphitran 
143d2ec54f7Sphitran #define	AC			"AC"
144d2ec54f7Sphitran #define	BATTERY			"battery"
145d2ec54f7Sphitran #define	SYSTEM_POWER		"system power"
146d2ec54f7Sphitran #define	SUPPORTED_BATTERY_COUNT	"supported_battery_count"
147d2ec54f7Sphitran 
148d2ec54f7Sphitran #define	BW_ENABLED		"enabled"
149d2ec54f7Sphitran #define	BW_POWEROFF_THRESHOLD	"warn capacity threshold"
150d2ec54f7Sphitran #define	BW_SHUTDOWN_THRESHOLD	"low capacity threshold"
151d2ec54f7Sphitran 
152d2ec54f7Sphitran #define	BIF_UNIT		"bif_unit"
153d2ec54f7Sphitran #define	BIF_DESIGN_CAP		"bif_design_cap"
154d2ec54f7Sphitran #define	BIF_LAST_CAP		"bif_last_cap"
155d2ec54f7Sphitran #define	BIF_TECH		"bif_tech"
156d2ec54f7Sphitran #define	BIF_VOLTAGE		"bif_voltage"
157d2ec54f7Sphitran #define	BIF_WARN_CAP		"bif_warn_cap"
158d2ec54f7Sphitran #define	BIF_LOW_CAP		"bif_low_cap"
159d2ec54f7Sphitran #define	BIF_GRAN1_CAP		"bif_gran1_cap"
160d2ec54f7Sphitran #define	BIF_GRAN2_CAP		"bif_gran2_cap"
161d2ec54f7Sphitran #define	BIF_MODEL		"bif_model"
162d2ec54f7Sphitran #define	BIF_SERIAL		"bif_serial"
163d2ec54f7Sphitran #define	BIF_TYPE		"bif_type"
164d2ec54f7Sphitran #define	BIF_OEM_INFO		"bif_oem_info"
165d2ec54f7Sphitran 
166d2ec54f7Sphitran #define	BST_STATE		"bst_state"
167d2ec54f7Sphitran #define	BST_RATE		"bst_rate"
168d2ec54f7Sphitran #define	BST_REM_CAP		"bst_rem_cap"
169d2ec54f7Sphitran #define	BST_VOLTAGE		"bst_voltage"
170d2ec54f7Sphitran 
171d2ec54f7Sphitran #define	PSR_AC_PRESENT		"psr_ac_present"
172d2ec54f7Sphitran 
173d2ec54f7Sphitran typedef struct acpi_drv_power_kstat_s {
174d2ec54f7Sphitran 	struct kstat_named	acpi_drv_power;
175d2ec54f7Sphitran 	struct kstat_named	acpi_drv_supported_battery_count;
176d2ec54f7Sphitran } acpi_drv_power_kstat_t;
177d2ec54f7Sphitran 
178d2ec54f7Sphitran typedef struct acpi_drv_warn_kstat_s {
179d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bw_enabled;
180d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bw_charge_warn;
181d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bw_charge_low;
182d2ec54f7Sphitran } acpi_drv_warn_kstat_t;
183d2ec54f7Sphitran 
184d2ec54f7Sphitran /* BIF kstat */
185d2ec54f7Sphitran typedef struct acpi_drv_bif_kstat_s {
186d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_unit;
187d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_design_cap;
188d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_last_cap;
189d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_tech;
190d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_voltage;
191d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_warn_cap;
192d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_low_cap;
193d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_gran1_cap;
194d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_gran2_cap;
195d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_model;
196d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_serial;
197d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_type;
198d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bif_oem_info;
199d2ec54f7Sphitran } acpi_drv_bif_kstat_t;
200d2ec54f7Sphitran 
201d2ec54f7Sphitran /* BST kstat */
202d2ec54f7Sphitran typedef struct acpi_drv_bst_kstat_s {
203d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bst_state;
204d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bst_rate;
205d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bst_rem_cap;
206d2ec54f7Sphitran 	struct kstat_named	acpi_drv_bst_voltage;
207d2ec54f7Sphitran } acpi_drv_bst_kstat_t;
208d2ec54f7Sphitran 
209*2d6b5ea7SGuoli Shu /* acpi device types */
210*2d6b5ea7SGuoli Shu enum acpi_drv_type {
211*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_UNKNOWN,
212*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_CBAT,
213*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_AC,
214*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_LID,
215*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_DISPLAY,
216*2d6b5ea7SGuoli Shu 	ACPI_DRV_TYPE_HOTKEY
217d2ec54f7Sphitran };
218d2ec54f7Sphitran 
219d2ec54f7Sphitran struct acpi_drv_output_info {
220d2ec54f7Sphitran 	uint32_t adr; /* unique ID for this output device */
221d2ec54f7Sphitran 	int nlev; /* number of brightness levels */
222d2ec54f7Sphitran };
223d2ec54f7Sphitran 
224d2ec54f7Sphitran struct acpi_drv_output_status {
225d2ec54f7Sphitran 	int state;
226d2ec54f7Sphitran 	int num_levels;
227d2ec54f7Sphitran 	int cur_level;
228d2ec54f7Sphitran 	int cur_level_index;
229d2ec54f7Sphitran };
230d2ec54f7Sphitran 
231*2d6b5ea7SGuoli Shu #define	ACPI_DRV_OK			0
232*2d6b5ea7SGuoli Shu #define	ACPI_DRV_ERR			-1
233*2d6b5ea7SGuoli Shu 
234d2ec54f7Sphitran #ifdef	__cplusplus
235d2ec54f7Sphitran }
236d2ec54f7Sphitran #endif
237d2ec54f7Sphitran 
238d2ec54f7Sphitran #endif /* _ACPI_DRV_H */
239