xref: /titanic_52/usr/src/uts/common/sys/pm.h (revision 84441f85b19f6b8080883f30109e58e43c893709)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_SYS_PM_H
27 #define	_SYS_PM_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 
35 /*
36  *	The following ioctls may not exist or may have a different
37  *	interpretation in a future release.
38  */
39 
40 typedef enum {
41 	PM_SCHEDULE,		/* obsolete, not supported */
42 	PM_GET_IDLE_TIME,	/* obsolete, not supported  */
43 	PM_GET_NUM_CMPTS,	/* obsolete, not supported */
44 	PM_GET_THRESHOLD,	/* obsolete, not supported  */
45 	PM_SET_THRESHOLD,	/* obsolete */
46 	PM_GET_NORM_PWR,	/* obsolete */
47 	PM_SET_CUR_PWR,		/* obsolete */
48 	PM_GET_CUR_PWR,		/* obsolete */
49 	PM_GET_NUM_DEPS,	/* obsolete, not supported */
50 	PM_GET_DEP,		/* obsolete, not supported */
51 	PM_ADD_DEP,		/* obsolete */
52 	PM_REM_DEP,		/* obsolete, not supported */
53 	PM_REM_DEVICE,		/* obsolete, not supported */
54 	PM_REM_DEVICES,		/* obsolete */
55 	PM_REPARSE_PM_PROPS,	/* used only by ddivs pm tests */
56 	PM_DISABLE_AUTOPM,	/* obsolete */
57 	PM_REENABLE_AUTOPM,	/* obsolete */
58 	PM_SET_NORM_PWR,	/* obsolete, not supported */
59 	PM_SET_DEVICE_THRESHOLD,
60 	PM_GET_SYSTEM_THRESHOLD,
61 	PM_SET_SYSTEM_THRESHOLD,
62 	PM_START_PM,
63 	PM_STOP_PM,
64 	PM_RESET_PM,
65 	PM_GET_STATS,
66 	PM_GET_DEVICE_THRESHOLD,
67 	PM_GET_POWER_NAME,
68 	PM_GET_POWER_LEVELS,
69 	PM_GET_NUM_COMPONENTS,
70 	PM_GET_COMPONENT_NAME,
71 	PM_GET_NUM_POWER_LEVELS,
72 	PM_GET_STATE_CHANGE,
73 	PM_GET_STATE_CHANGE_WAIT,
74 	PM_DIRECT_PM,
75 	PM_RELEASE_DIRECT_PM,
76 	PM_DIRECT_NOTIFY,
77 	PM_DIRECT_NOTIFY_WAIT,
78 	PM_RESET_DEVICE_THRESHOLD,
79 	PM_GET_PM_STATE,
80 	PM_GET_DEVICE_TYPE,
81 	PM_SET_COMPONENT_THRESHOLDS,
82 	PM_GET_COMPONENT_THRESHOLDS,
83 	PM_IDLE_DOWN,
84 	PM_GET_DEVICE_THRESHOLD_BASIS,
85 	PM_SET_CURRENT_POWER,	/* replaces PM_SET_CUR_PWR */
86 	PM_GET_CURRENT_POWER,	/* replaces PM_GET_CUR_PWR */
87 	PM_GET_FULL_POWER,	/* replaces PM_GET_NORM_PWR */
88 	PM_ADD_DEPENDENT,	/* replaces PM_ADD_DEP */
89 	PM_GET_TIME_IDLE,	/* replaces PM_IDLE_TIME */
90 	PM_GET_DEFAULT_SYSTEM_THRESHOLD,
91 	PM_ADD_DEPENDENT_PROPERTY,
92 	PM_START_CPUPM,
93 	PM_START_CPUPM_EV,
94 	PM_START_CPUPM_POLL,
95 	PM_STOP_CPUPM,
96 	PM_GET_CPU_THRESHOLD,
97 	PM_SET_CPU_THRESHOLD,
98 	PM_GET_CPUPM_STATE,
99 	PM_ENABLE_S3,		/* allow pm to go to S3 state */
100 	PM_DISABLE_S3,		/* do not allow pm to go to S3 state */
101 	PM_ENTER_S3,		/* obsolete, not supported */
102 	PM_START_AUTOS3,
103 	PM_STOP_AUTOS3,
104 	PM_SEARCH_LIST,		/* search S3 enable/disable list */
105 	PM_GET_AUTOS3_STATE,
106 	PM_GET_S3_SUPPORT_STATE,
107 	PM_GET_CMD_NAME,
108 	PM_DISABLE_CPU_DEEP_IDLE,
109 	PM_ENABLE_CPU_DEEP_IDLE,
110 	PM_DEFAULT_CPU_DEEP_IDLE
111 } pm_cmds;
112 
113 /*
114  * Old name for these ioctls.
115  */
116 #define	PM_GET_POWER		PM_GET_NORM_PWR
117 #define	PM_SET_POWER		PM_SET_CUR_PWR
118 
119 /*
120  * This structure is obsolete and will be removed in a later release
121  */
122 typedef struct {
123 	caddr_t	who;		/* Device to configure */
124 	int	select;		/* Selects the component or dependent */
125 				/* of the device */
126 	int	level;		/* Power or threshold level */
127 	caddr_t dependent;	/* Buffer to hold name of dependent */
128 	int	size;		/* Size of dependent buffer */
129 } pm_request;
130 
131 /*
132  * This is the new struct that replaces pm_request
133  */
134 typedef struct pm_req {
135 	char	*physpath;	/* physical path of device to configure */
136 				/* see libdevinfo(3) */
137 	int	component;	/* Selects the component of the device */
138 	int	value;		/* power level, threshold value, or count */
139 	void	*data;		/* command-dependent variable sized data */
140 	size_t	datasize;	/* Size of data buffer */
141 } pm_req_t;
142 
143 /*
144  * PM_SEARCH_LIST requires a list name, manufacturer and product name
145  * Searches the named list for a matching tuple.
146  * NOTE: This structure may be removed in a later release.
147  */
148 typedef struct pm_searchargs {
149 	char	*pms_listname;		/* name of list to search */
150 	char	*pms_manufacturer;	/* 1st elment of tuple */
151 	char	*pms_product;		/* 2nd elment of tuple */
152 } pm_searchargs_t;
153 
154 /*
155  * Use these for PM_ADD_DEPENDENT and PM_ADD_DEPENDENT_PROPERTY
156  */
157 #define	pmreq_keeper	physpath	/* keeper in the physpath field */
158 #define	pmreq_kept	data		/* kept in the data field */
159 
160 /*
161  * Possible values for the event field of pm_state_change below
162  */
163 typedef enum {
164 	PSC_PENDING_CHANGE,	/* device needs to change, is blocked */
165 	PSC_HAS_CHANGED		/* device level has changed */
166 } psc_events;
167 
168 #define	PSC_EVENT_LOST	0x4000	/* buffer overrun */
169 #define	PSC_ALL_LOWEST	0x8000	/* all devices at lowest power */
170 
171 /*
172  * Special value for power level fields in pm_state_change below
173  */
174 #define	PM_LEVEL_UNKNOWN	-1	/* power level is unknown */
175 
176 typedef struct pm_state_change {
177 	caddr_t	physpath;	/* Device which has changed state */
178 	int	component;	/* which component changed state */
179 #if defined(_BIG_ENDIAN)
180 	ushort_t flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
181 	ushort_t event;		/* type of event */
182 #else
183 	ushort_t event;		/* type of event */
184 	ushort_t flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
185 #endif
186 	time_t	timestamp;	/* time of state change */
187 	int	old_level;	/* power level changing from */
188 	int	new_level;	/* power level changing to */
189 	size_t	size;		/* size of buffer physpath points to */
190 } pm_state_change_t;
191 
192 #ifdef _SYSCALL32
193 
194 /* Kernel's view of ILP32 structure version. */
195 
196 /*
197  * This struct is obsolete and will be removed in a later release
198  */
199 typedef struct {
200 	caddr32_t	who;	/* Device to configure */
201 	int		select;	/* Selects the component or dependent */
202 				/* of the device */
203 	int		level;	/* Power or threshold level */
204 	caddr32_t	dependent;	/* Buffer to hold name of */
205 					/* dependent */
206 	size32_t	size;	/* Size of dependent buffer */
207 } pm_request32;
208 
209 typedef struct pm_req32 {
210 	caddr32_t physpath;	/* physical path of device to configure */
211 				/* see libdevinfo(3) */
212 	int	component;	/* selects the component of the device */
213 	int	value;		/* power level, threshold value, or count */
214 	caddr32_t data;		/* command-dependent variable sized data */
215 	size32_t datasize;	/* Size of data buffer */
216 } pm_req32_t;
217 
218 typedef struct pm_state_change32 {
219 	caddr32_t	physpath;	/* Device which has changed state */
220 	int		component;	/* which component changed state */
221 #if defined(_BIG_ENDIAN)
222 	ushort_t	flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
223 	ushort_t	event;		/* type of event */
224 #else
225 	ushort_t	event;		/* type of event */
226 	ushort_t	flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
227 #endif
228 	time32_t	timestamp;	/* time of state change */
229 	int		old_level;	/* power level changing from */
230 	int		new_level;	/* power level changing to */
231 	size32_t	size;		/* size of buffer physpath points to */
232 } pm_state_change32_t;
233 
234 typedef	struct pm_searchargs32_t {
235 	caddr32_t	pms_listname;
236 	caddr32_t	pms_manufacturer;
237 	caddr32_t	pms_product;
238 } pm_searchargs32_t;
239 
240 
241 #endif
242 
243 /*
244  * Return values from ioctl commands that return pm state info.
245  */
246 
247 typedef enum {
248 	PM_SYSTEM_PM_ENABLED,
249 	PM_SYSTEM_PM_DISABLED,
250 	PM_NO_PM_COMPONENTS,
251 	PM_CREATE_COMPONENTS,
252 	PM_AUTOPM,
253 	PM_DEFAULT_THRESHOLD,
254 	PM_DEVICE_THRESHOLD,
255 	PM_COMPONENT_THRESHOLD,
256 	PM_OLD_THRESHOLD,
257 	PM_DIRECTLY_MANAGED,
258 	PM_CPU_THRESHOLD,
259 	PM_CPU_PM_ENABLED,
260 	PM_CPU_PM_DISABLED,
261 	PM_CPU_PM_NOTSET,
262 	PM_AUTOS3_ENABLED,
263 	PM_AUTOS3_DISABLED,
264 	PM_S3_SUPPORT_ENABLED,
265 	PM_S3_SUPPORT_DISABLED
266 } pm_states;
267 
268 #ifdef	__cplusplus
269 }
270 #endif
271 
272 #endif	/* _SYS_PM_H */
273