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