xref: /titanic_52/usr/src/uts/common/sys/acpi_drv.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
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 2008 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/param.h>
37 #include <sys/kstat.h>
38 
39 enum acpi_drv_ioctl {
40 	ACPI_DRV_IOC_BAY,
41 	ACPI_DRV_IOC_INFO,
42 	ACPI_DRV_IOC_STATUS,
43 	ACPI_DRV_IOC_AC_COUNT,
44 	ACPI_DRV_IOC_POWER_STATUS,
45 	ACPI_DRV_IOC_SET_WARNING,
46 	ACPI_DRV_IOC_GET_WARNING,
47 	ACPI_DRV_IOC_LID_STATUS,
48 	ACPI_DRV_IOC_LEVELS,
49 	ACPI_DRV_IOC_SET_BRIGHTNESS
50 };
51 
52 #define	ACPI_DRV_BST_CHARGING		2
53 #define	ACPI_DRV_BST_DISCHARGING	1
54 
55 typedef struct batt_bay {
56 	/* Total number of bays in the system */
57 	int bay_number;
58 
59 	/*
60 	 * Bitmap for each bay and its battery.
61 	 * battery_map bit i:
62 	 *    1 -- battery inserted to bay i
63 	 *    0 -- bay i empty
64 	 */
65 	uint64_t battery_map;
66 } batt_bay_t;
67 
68 typedef	struct acpi_bif {
69 	uint32_t	bif_unit;
70 
71 	/*
72 	 * 0x00000000 - 0x7fffffff
73 	 * 0xffffffff - Unknown design capacity in [mWh] or [mAh]
74 	 */
75 	uint32_t	bif_design_cap;
76 
77 	/*
78 	 * 0x00000000 - 0x7fffffff
79 	 * 0xffffffff - Unknown last full charge capacity in [mWh] or [mAh]
80 	 */
81 	uint32_t	bif_last_cap;
82 
83 	uint32_t	bif_tech;
84 
85 	/*
86 	 * 0x00000000 - 0x7fffffff
87 	 * 0xffffffff - Unknown design voltage in [mV]
88 	 */
89 	uint32_t	bif_voltage;
90 
91 	/*
92 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
93 	 */
94 	uint32_t	bif_warn_cap;
95 
96 	/*
97 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
98 	 */
99 	uint32_t	bif_low_cap;
100 
101 	uint32_t	bif_gran1_cap;
102 	uint32_t	bif_gran2_cap;
103 	char		bif_model[MAXNAMELEN];
104 	char		bif_serial[MAXNAMELEN];
105 	char		bif_type[MAXNAMELEN];
106 	char		bif_oem_info[MAXNAMELEN];
107 } acpi_bif_t;
108 
109 typedef	struct acpi_bst {
110 	uint32_t	bst_state;
111 
112 	/*
113 	 * 0x00000000 - 0x7fffffff in [mW] or [mA]
114 	 * 0xffffffff - Unknown rate
115 	 */
116 	uint32_t	bst_rate;
117 
118 	/*
119 	 * 0x00000000 - 0x7fffffff in [mWh] or [mAh]
120 	 * 0xffffffff - Unknown capacity
121 	 */
122 	uint32_t	bst_rem_cap;
123 
124 	/*
125 	 * 0x00000000 - 0x7fffffff in [mV]
126 	 * 0xffffffff - Unknown voltage
127 	 */
128 	uint32_t	bst_voltage;
129 } acpi_bst_t;
130 
131 /* Battery warnning levels in percentage */
132 typedef struct acpi_drv_warn {
133 	uint32_t	bw_enabled;	/* Enabled */
134 	uint32_t	bw_charge_warn;	/* charge warn threshold */
135 	uint32_t	bw_charge_low;	/* charge low threshold */
136 } acpi_drv_warn_t;
137 
138 #define	ACPI_DRV_NAME		"acpi_drv"
139 #define	ACPI_DRV_POWER_KSTAT_NAME	"power"
140 #define	ACPI_DRV_BTWARN_KSTAT_NAME	"battery warning"
141 #define	ACPI_DRV_BIF_KSTAT_NAME		"battery BIF"
142 #define	ACPI_DRV_BST_KSTAT_NAME		"battery BST"
143 
144 #define	AC			"AC"
145 #define	BATTERY			"battery"
146 #define	SYSTEM_POWER		"system power"
147 #define	SUPPORTED_BATTERY_COUNT	"supported_battery_count"
148 
149 #define	BW_ENABLED		"enabled"
150 #define	BW_POWEROFF_THRESHOLD	"warn capacity threshold"
151 #define	BW_SHUTDOWN_THRESHOLD	"low capacity threshold"
152 
153 #define	BIF_UNIT		"bif_unit"
154 #define	BIF_DESIGN_CAP		"bif_design_cap"
155 #define	BIF_LAST_CAP		"bif_last_cap"
156 #define	BIF_TECH		"bif_tech"
157 #define	BIF_VOLTAGE		"bif_voltage"
158 #define	BIF_WARN_CAP		"bif_warn_cap"
159 #define	BIF_LOW_CAP		"bif_low_cap"
160 #define	BIF_GRAN1_CAP		"bif_gran1_cap"
161 #define	BIF_GRAN2_CAP		"bif_gran2_cap"
162 #define	BIF_MODEL		"bif_model"
163 #define	BIF_SERIAL		"bif_serial"
164 #define	BIF_TYPE		"bif_type"
165 #define	BIF_OEM_INFO		"bif_oem_info"
166 
167 #define	BST_STATE		"bst_state"
168 #define	BST_RATE		"bst_rate"
169 #define	BST_REM_CAP		"bst_rem_cap"
170 #define	BST_VOLTAGE		"bst_voltage"
171 
172 #define	PSR_AC_PRESENT		"psr_ac_present"
173 
174 typedef struct acpi_drv_power_kstat_s {
175 	struct kstat_named	acpi_drv_power;
176 	struct kstat_named	acpi_drv_supported_battery_count;
177 } acpi_drv_power_kstat_t;
178 
179 typedef struct acpi_drv_warn_kstat_s {
180 	struct kstat_named	acpi_drv_bw_enabled;
181 	struct kstat_named	acpi_drv_bw_charge_warn;
182 	struct kstat_named	acpi_drv_bw_charge_low;
183 } acpi_drv_warn_kstat_t;
184 
185 /* BIF kstat */
186 typedef struct acpi_drv_bif_kstat_s {
187 	struct kstat_named	acpi_drv_bif_unit;
188 	struct kstat_named	acpi_drv_bif_design_cap;
189 	struct kstat_named	acpi_drv_bif_last_cap;
190 	struct kstat_named	acpi_drv_bif_tech;
191 	struct kstat_named	acpi_drv_bif_voltage;
192 	struct kstat_named	acpi_drv_bif_warn_cap;
193 	struct kstat_named	acpi_drv_bif_low_cap;
194 	struct kstat_named	acpi_drv_bif_gran1_cap;
195 	struct kstat_named	acpi_drv_bif_gran2_cap;
196 	struct kstat_named	acpi_drv_bif_model;
197 	struct kstat_named	acpi_drv_bif_serial;
198 	struct kstat_named	acpi_drv_bif_type;
199 	struct kstat_named	acpi_drv_bif_oem_info;
200 } acpi_drv_bif_kstat_t;
201 
202 /* BST kstat */
203 typedef struct acpi_drv_bst_kstat_s {
204 	struct kstat_named	acpi_drv_bst_state;
205 	struct kstat_named	acpi_drv_bst_rate;
206 	struct kstat_named	acpi_drv_bst_rem_cap;
207 	struct kstat_named	acpi_drv_bst_voltage;
208 } acpi_drv_bst_kstat_t;
209 
210 struct acpi_drv_display_info {
211 	int noutput; /* number of output devices */
212 	int sw_on;
213 	int bright_on;
214 };
215 
216 struct acpi_drv_output_info {
217 	uint32_t adr; /* unique ID for this output device */
218 	int nlev; /* number of brightness levels */
219 };
220 
221 struct acpi_drv_output_status {
222 	int state;
223 	int num_levels;
224 	int cur_level;
225 	int cur_level_index;
226 };
227 
228 #ifdef	__cplusplus
229 }
230 #endif
231 
232 #endif /* _ACPI_DRV_H */
233