xref: /titanic_51/usr/src/uts/common/sys/sunpm.h (revision cd3e933325e68e23516a196a8fea7f49b1e497c3)
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_SUNPM_H
27 #define	_SYS_SUNPM_H
28 
29 /*
30  * Sun Specific Power Management definitions
31  */
32 
33 #include <sys/isa_defs.h>
34 #include <sys/dditypes.h>
35 #include <sys/ddipropdefs.h>
36 #include <sys/devops.h>
37 #include <sys/time.h>
38 #include <sys/cmn_err.h>
39 #include <sys/ddidevmap.h>
40 #include <sys/ddi_implfuncs.h>
41 #include <sys/ddi_isa.h>
42 #include <sys/model.h>
43 #include <sys/devctl.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 #ifdef	_KERNEL
50 
51 /*
52  * Power cycle transition check is supported for SCSI and SATA devices.
53  */
54 #define	DC_SCSI_FORMAT		0x1		/* SCSI */
55 #define	DC_SMART_FORMAT		0x2		/* SMART */
56 
57 #define	DC_SCSI_MFR_LEN		6		/* YYYYWW */
58 
59 struct pm_scsi_cycles {
60 	int	lifemax;			/* lifetime max power cycles */
61 	int	ncycles;			/* number of cycles so far */
62 	char	svc_date[DC_SCSI_MFR_LEN];	/* service date YYYYWW */
63 	int	flag;				/* reserved for future */
64 };
65 
66 struct pm_smart_count {
67 	int	allowed;	/* normalized max cycles allowed */
68 	int	consumed;	/* normalized consumed cycles */
69 	int	flag;		/* type of cycles */
70 };
71 
72 struct pm_trans_data {
73 	int	format;				/* data format */
74 	union {
75 		struct pm_scsi_cycles scsi_cycles;
76 		struct pm_smart_count smart_count;
77 	} un;
78 };
79 
80 /*
81  * Power levels for devices supporting ACPI based D0, D1, D2, D3 states.
82  *
83  * Note that 0 is off in Solaris PM framework but D0 is full power
84  * for these devices.
85  */
86 #define	PM_LEVEL_D3		0	/* D3 state - off */
87 #define	PM_LEVEL_D2		1	/* D2 state */
88 #define	PM_LEVEL_D1		2	/* D1 state */
89 #define	PM_LEVEL_D0		3	/* D0 state - fully on */
90 
91 /*
92  * Useful strings for creating pm-components property for these devices.
93  * If a device driver wishes to provide more specific description of power
94  * levels (highly recommended), it should NOT use following generic defines.
95  */
96 #define	PM_LEVEL_D3_STR		"0=Device D3 State"
97 #define	PM_LEVEL_D2_STR		"1=Device D2 State"
98 #define	PM_LEVEL_D1_STR		"2=Device D1 State"
99 #define	PM_LEVEL_D0_STR		"3=Device D0 State"
100 
101 /*
102  * If you add or remove a function or data reference, please
103  * remember to duplicate the action below the #else clause for
104  * __STDC__.
105  */
106 
107 #ifdef	__STDC__
108 
109 /*
110  * Generic Sun PM definitions.
111  */
112 
113 /*
114  * These are obsolete power management interfaces, they will be removed from
115  * a subsequent release.
116  */
117 int
118 pm_create_components(dev_info_t *dip, int num_components);
119 
120 void
121 pm_destroy_components(dev_info_t *dip);
122 
123 void
124 pm_set_normal_power(dev_info_t *dip, int component_number, int level);
125 
126 int
127 pm_get_normal_power(dev_info_t *dip, int component_number);
128 
129 /*
130  * These are power management interfaces.
131  */
132 
133 int
134 pm_busy_component(dev_info_t *dip, int component_number);
135 
136 int
137 pm_idle_component(dev_info_t *dip, int component_number);
138 
139 int
140 pm_get_current_power(dev_info_t *dip, int component, int *levelp);
141 
142 int
143 pm_power_has_changed(dev_info_t *, int, int);
144 
145 int
146 pm_trans_check(struct pm_trans_data *datap, time_t *intervalp);
147 
148 int
149 pm_lower_power(dev_info_t *dip, int comp, int level);
150 
151 int
152 pm_raise_power(dev_info_t *dip, int comp, int level);
153 
154 int
155 pm_update_maxpower(dev_info_t *dip, int comp, int level);
156 
157 #else	/* __STDC__ */
158 
159 /*
160  * Obsolete interfaces.
161  */
162 extern int pm_create_components();
163 extern void pm_destroy_components();
164 extern void pm_set_normal_power();
165 extern int pm_get_normal_power();
166 
167 /*
168  * PM interfaces
169  */
170 extern int pm_busy_component();
171 extern int pm_idle_component();
172 extern int pm_get_current_power();
173 extern int pm_power_has_changed();
174 extern int pm_trans_check();
175 extern int pm_lower_power();
176 extern int pm_raise_power();
177 extern int pm_update_maxpower();
178 
179 #endif	/* __STDC__ */
180 
181 #endif	/* _KERNEL */
182 
183 #ifdef	__cplusplus
184 }
185 #endif
186 
187 #endif	/* _SYS_SUNPM_H */
188