xref: /titanic_50/usr/src/uts/common/sys/sunpm.h (revision 3d729aecc03ea6ebb9bd5d56b8dccd24f57daa41)
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 2014 Garrett D'Amore <garrett@damore.org>
23  *
24  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #ifndef	_SYS_SUNPM_H
29 #define	_SYS_SUNPM_H
30 
31 /*
32  * Sun Specific Power Management definitions
33  */
34 
35 #include <sys/isa_defs.h>
36 #include <sys/dditypes.h>
37 #include <sys/ddipropdefs.h>
38 #include <sys/devops.h>
39 #include <sys/time.h>
40 #include <sys/cmn_err.h>
41 #include <sys/ddidevmap.h>
42 #include <sys/ddi_implfuncs.h>
43 #include <sys/ddi_isa.h>
44 #include <sys/model.h>
45 #include <sys/devctl.h>
46 
47 #ifdef	__cplusplus
48 extern "C" {
49 #endif
50 
51 #ifdef	_KERNEL
52 
53 /*
54  * Power cycle transition check is supported for SCSI and SATA devices.
55  */
56 #define	DC_SCSI_FORMAT		0x1		/* SCSI */
57 #define	DC_SMART_FORMAT		0x2		/* SMART */
58 
59 #define	DC_SCSI_MFR_LEN		6		/* YYYYWW */
60 
61 struct pm_scsi_cycles {
62 	int	lifemax;			/* lifetime max power cycles */
63 	int	ncycles;			/* number of cycles so far */
64 	char	svc_date[DC_SCSI_MFR_LEN];	/* service date YYYYWW */
65 	int	flag;				/* reserved for future */
66 };
67 
68 struct pm_smart_count {
69 	int	allowed;	/* normalized max cycles allowed */
70 	int	consumed;	/* normalized consumed cycles */
71 	int	flag;		/* type of cycles */
72 };
73 
74 struct pm_trans_data {
75 	int	format;				/* data format */
76 	union {
77 		struct pm_scsi_cycles scsi_cycles;
78 		struct pm_smart_count smart_count;
79 	} un;
80 };
81 
82 /*
83  * Power levels for devices supporting ACPI based D0, D1, D2, D3 states.
84  *
85  * Note that 0 is off in Solaris PM framework but D0 is full power
86  * for these devices.
87  */
88 #define	PM_LEVEL_D3		0	/* D3 state - off */
89 #define	PM_LEVEL_D2		1	/* D2 state */
90 #define	PM_LEVEL_D1		2	/* D1 state */
91 #define	PM_LEVEL_D0		3	/* D0 state - fully on */
92 
93 /*
94  * Useful strings for creating pm-components property for these devices.
95  * If a device driver wishes to provide more specific description of power
96  * levels (highly recommended), it should NOT use following generic defines.
97  */
98 #define	PM_LEVEL_D3_STR		"0=Device D3 State"
99 #define	PM_LEVEL_D2_STR		"1=Device D2 State"
100 #define	PM_LEVEL_D1_STR		"2=Device D1 State"
101 #define	PM_LEVEL_D0_STR		"3=Device D0 State"
102 
103 /*
104  * Generic Sun PM definitions.
105  */
106 
107 /*
108  * These are obsolete power management interfaces, they will be removed from
109  * a subsequent release.
110  */
111 int pm_create_components(dev_info_t *dip, int num_components);
112 
113 void pm_destroy_components(dev_info_t *dip);
114 
115 void pm_set_normal_power(dev_info_t *dip, int component_number, int level);
116 
117 int pm_get_normal_power(dev_info_t *dip, int component_number);
118 
119 /*
120  * These are power management interfaces.
121  */
122 
123 int pm_busy_component(dev_info_t *dip, int component_number);
124 
125 int pm_idle_component(dev_info_t *dip, int component_number);
126 
127 int pm_get_current_power(dev_info_t *dip, int component, int *levelp);
128 
129 int pm_power_has_changed(dev_info_t *, int, int);
130 
131 int pm_trans_check(struct pm_trans_data *datap, time_t *intervalp);
132 
133 int pm_lower_power(dev_info_t *dip, int comp, int level);
134 
135 int pm_raise_power(dev_info_t *dip, int comp, int level);
136 
137 int pm_update_maxpower(dev_info_t *dip, int comp, int level);
138 
139 #endif	/* _KERNEL */
140 
141 #ifdef	__cplusplus
142 }
143 #endif
144 
145 #endif	/* _SYS_SUNPM_H */
146