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