summaryrefslogtreecommitdiff
path: root/usr/src/uts/common/sys/sunpm.h
blob: 7ce11e0bda16f617bf233d9d51bf8acb9c28aa35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
 *
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_SYS_SUNPM_H
#define	_SYS_SUNPM_H

/*
 * Sun Specific Power Management definitions
 */

#include <sys/isa_defs.h>
#include <sys/dditypes.h>
#include <sys/ddipropdefs.h>
#include <sys/devops.h>
#include <sys/time.h>
#include <sys/cmn_err.h>
#include <sys/ddidevmap.h>
#include <sys/ddi_implfuncs.h>
#include <sys/ddi_isa.h>
#include <sys/model.h>
#include <sys/devctl.h>

#ifdef	__cplusplus
extern "C" {
#endif

#ifdef	_KERNEL

/*
 * Power cycle transition check is supported for SCSI and SATA devices.
 */
#define	DC_SCSI_FORMAT		0x1		/* SCSI */
#define	DC_SMART_FORMAT		0x2		/* SMART */

#define	DC_SCSI_MFR_LEN		6		/* YYYYWW */

struct pm_scsi_cycles {
	int	lifemax;			/* lifetime max power cycles */
	int	ncycles;			/* number of cycles so far */
	char	svc_date[DC_SCSI_MFR_LEN];	/* service date YYYYWW */
	int	flag;				/* reserved for future */
};

struct pm_smart_count {
	int	allowed;	/* normalized max cycles allowed */
	int	consumed;	/* normalized consumed cycles */
	int	flag;		/* type of cycles */
};

struct pm_trans_data {
	int	format;				/* data format */
	union {
		struct pm_scsi_cycles scsi_cycles;
		struct pm_smart_count smart_count;
	} un;
};

/*
 * Power levels for devices supporting ACPI based D0, D1, D2, D3 states.
 *
 * Note that 0 is off in Solaris PM framework but D0 is full power
 * for these devices.
 */
#define	PM_LEVEL_D3		0	/* D3 state - off */
#define	PM_LEVEL_D2		1	/* D2 state */
#define	PM_LEVEL_D1		2	/* D1 state */
#define	PM_LEVEL_D0		3	/* D0 state - fully on */

/*
 * Useful strings for creating pm-components property for these devices.
 * If a device driver wishes to provide more specific description of power
 * levels (highly recommended), it should NOT use following generic defines.
 */
#define	PM_LEVEL_D3_STR		"0=Device D3 State"
#define	PM_LEVEL_D2_STR		"1=Device D2 State"
#define	PM_LEVEL_D1_STR		"2=Device D1 State"
#define	PM_LEVEL_D0_STR		"3=Device D0 State"

/*
 * Generic Sun PM definitions.
 */

/*
 * These are obsolete power management interfaces, they will be removed from
 * a subsequent release.
 */
int pm_create_components(dev_info_t *dip, int num_components);

void pm_destroy_components(dev_info_t *dip);

void pm_set_normal_power(dev_info_t *dip, int component_number, int level);

int pm_get_normal_power(dev_info_t *dip, int component_number);

/*
 * These are power management interfaces.
 */

int pm_busy_component(dev_info_t *dip, int component_number);

int pm_idle_component(dev_info_t *dip, int component_number);

int pm_get_current_power(dev_info_t *dip, int component, int *levelp);

int pm_power_has_changed(dev_info_t *, int, int);

int pm_trans_check(struct pm_trans_data *datap, time_t *intervalp);

int pm_lower_power(dev_info_t *dip, int comp, int level);

int pm_raise_power(dev_info_t *dip, int comp, int level);

int pm_update_maxpower(dev_info_t *dip, int comp, int level);

#endif	/* _KERNEL */

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_SUNPM_H */