xref: /titanic_44/usr/src/uts/common/sys/sunpm.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55cff7825Smh27603  * Common Development and Distribution License (the "License").
65cff7825Smh27603  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*ba3594baSGarrett D'Amore  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
23*ba3594baSGarrett D'Amore  *
242ee4dfc7SJane Chu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
255cff7825Smh27603  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_SYS_SUNPM_H
297c478bd9Sstevel@tonic-gate #define	_SYS_SUNPM_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Sun Specific Power Management definitions
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
367c478bd9Sstevel@tonic-gate #include <sys/dditypes.h>
377c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h>
387c478bd9Sstevel@tonic-gate #include <sys/devops.h>
397c478bd9Sstevel@tonic-gate #include <sys/time.h>
407c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h>
417c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h>
427c478bd9Sstevel@tonic-gate #include <sys/ddi_implfuncs.h>
437c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h>
447c478bd9Sstevel@tonic-gate #include <sys/model.h>
457c478bd9Sstevel@tonic-gate #include <sys/devctl.h>
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
487c478bd9Sstevel@tonic-gate extern "C" {
497c478bd9Sstevel@tonic-gate #endif
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate /*
542ee4dfc7SJane Chu  * Power cycle transition check is supported for SCSI and SATA devices.
557c478bd9Sstevel@tonic-gate  */
567c478bd9Sstevel@tonic-gate #define	DC_SCSI_FORMAT		0x1		/* SCSI */
572ee4dfc7SJane Chu #define	DC_SMART_FORMAT		0x2		/* SMART */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate #define	DC_SCSI_MFR_LEN		6		/* YYYYWW */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate struct pm_scsi_cycles {
627c478bd9Sstevel@tonic-gate 	int	lifemax;			/* lifetime max power cycles */
637c478bd9Sstevel@tonic-gate 	int	ncycles;			/* number of cycles so far */
647c478bd9Sstevel@tonic-gate 	char	svc_date[DC_SCSI_MFR_LEN];	/* service date YYYYWW */
657c478bd9Sstevel@tonic-gate 	int	flag;				/* reserved for future */
667c478bd9Sstevel@tonic-gate };
677c478bd9Sstevel@tonic-gate 
682ee4dfc7SJane Chu struct pm_smart_count {
692ee4dfc7SJane Chu 	int	allowed;	/* normalized max cycles allowed */
702ee4dfc7SJane Chu 	int	consumed;	/* normalized consumed cycles */
712ee4dfc7SJane Chu 	int	flag;		/* type of cycles */
722ee4dfc7SJane Chu };
732ee4dfc7SJane Chu 
747c478bd9Sstevel@tonic-gate struct pm_trans_data {
757c478bd9Sstevel@tonic-gate 	int	format;				/* data format */
767c478bd9Sstevel@tonic-gate 	union {
777c478bd9Sstevel@tonic-gate 		struct pm_scsi_cycles scsi_cycles;
782ee4dfc7SJane Chu 		struct pm_smart_count smart_count;
797c478bd9Sstevel@tonic-gate 	} un;
807c478bd9Sstevel@tonic-gate };
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * Power levels for devices supporting ACPI based D0, D1, D2, D3 states.
847c478bd9Sstevel@tonic-gate  *
857c478bd9Sstevel@tonic-gate  * Note that 0 is off in Solaris PM framework but D0 is full power
867c478bd9Sstevel@tonic-gate  * for these devices.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D3		0	/* D3 state - off */
897c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D2		1	/* D2 state */
907c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D1		2	/* D1 state */
917c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D0		3	/* D0 state - fully on */
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Useful strings for creating pm-components property for these devices.
957c478bd9Sstevel@tonic-gate  * If a device driver wishes to provide more specific description of power
967c478bd9Sstevel@tonic-gate  * levels (highly recommended), it should NOT use following generic defines.
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D3_STR		"0=Device D3 State"
997c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D2_STR		"1=Device D2 State"
1007c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D1_STR		"2=Device D1 State"
1017c478bd9Sstevel@tonic-gate #define	PM_LEVEL_D0_STR		"3=Device D0 State"
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate  * Generic Sun PM definitions.
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate /*
1087c478bd9Sstevel@tonic-gate  * These are obsolete power management interfaces, they will be removed from
1097c478bd9Sstevel@tonic-gate  * a subsequent release.
1107c478bd9Sstevel@tonic-gate  */
111*ba3594baSGarrett D'Amore int pm_create_components(dev_info_t *dip, int num_components);
1127c478bd9Sstevel@tonic-gate 
113*ba3594baSGarrett D'Amore void pm_destroy_components(dev_info_t *dip);
1147c478bd9Sstevel@tonic-gate 
115*ba3594baSGarrett D'Amore void pm_set_normal_power(dev_info_t *dip, int component_number, int level);
1167c478bd9Sstevel@tonic-gate 
117*ba3594baSGarrett D'Amore int pm_get_normal_power(dev_info_t *dip, int component_number);
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate /*
1207c478bd9Sstevel@tonic-gate  * These are power management interfaces.
1217c478bd9Sstevel@tonic-gate  */
1227c478bd9Sstevel@tonic-gate 
123*ba3594baSGarrett D'Amore int pm_busy_component(dev_info_t *dip, int component_number);
1247c478bd9Sstevel@tonic-gate 
125*ba3594baSGarrett D'Amore int pm_idle_component(dev_info_t *dip, int component_number);
1267c478bd9Sstevel@tonic-gate 
127*ba3594baSGarrett D'Amore int pm_get_current_power(dev_info_t *dip, int component, int *levelp);
1287c478bd9Sstevel@tonic-gate 
129*ba3594baSGarrett D'Amore int pm_power_has_changed(dev_info_t *, int, int);
1307c478bd9Sstevel@tonic-gate 
131*ba3594baSGarrett D'Amore int pm_trans_check(struct pm_trans_data *datap, time_t *intervalp);
1327c478bd9Sstevel@tonic-gate 
133*ba3594baSGarrett D'Amore int pm_lower_power(dev_info_t *dip, int comp, int level);
1347c478bd9Sstevel@tonic-gate 
135*ba3594baSGarrett D'Amore int pm_raise_power(dev_info_t *dip, int comp, int level);
1367c478bd9Sstevel@tonic-gate 
137*ba3594baSGarrett D'Amore int pm_update_maxpower(dev_info_t *dip, int comp, int level);
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1427c478bd9Sstevel@tonic-gate }
1437c478bd9Sstevel@tonic-gate #endif
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate #endif	/* _SYS_SUNPM_H */
146