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*2ee4dfc7SJane Chu * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 235cff7825Smh27603 * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_SUNPM_H 277c478bd9Sstevel@tonic-gate #define _SYS_SUNPM_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Sun Specific Power Management definitions 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 347c478bd9Sstevel@tonic-gate #include <sys/dditypes.h> 357c478bd9Sstevel@tonic-gate #include <sys/ddipropdefs.h> 367c478bd9Sstevel@tonic-gate #include <sys/devops.h> 377c478bd9Sstevel@tonic-gate #include <sys/time.h> 387c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 397c478bd9Sstevel@tonic-gate #include <sys/ddidevmap.h> 407c478bd9Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 417c478bd9Sstevel@tonic-gate #include <sys/ddi_isa.h> 427c478bd9Sstevel@tonic-gate #include <sys/model.h> 437c478bd9Sstevel@tonic-gate #include <sys/devctl.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #ifdef __cplusplus 467c478bd9Sstevel@tonic-gate extern "C" { 477c478bd9Sstevel@tonic-gate #endif 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #ifdef _KERNEL 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 52*2ee4dfc7SJane Chu * Power cycle transition check is supported for SCSI and SATA devices. 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate #define DC_SCSI_FORMAT 0x1 /* SCSI */ 55*2ee4dfc7SJane Chu #define DC_SMART_FORMAT 0x2 /* SMART */ 567c478bd9Sstevel@tonic-gate 577c478bd9Sstevel@tonic-gate #define DC_SCSI_MFR_LEN 6 /* YYYYWW */ 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate struct pm_scsi_cycles { 607c478bd9Sstevel@tonic-gate int lifemax; /* lifetime max power cycles */ 617c478bd9Sstevel@tonic-gate int ncycles; /* number of cycles so far */ 627c478bd9Sstevel@tonic-gate char svc_date[DC_SCSI_MFR_LEN]; /* service date YYYYWW */ 637c478bd9Sstevel@tonic-gate int flag; /* reserved for future */ 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate 66*2ee4dfc7SJane Chu struct pm_smart_count { 67*2ee4dfc7SJane Chu int allowed; /* normalized max cycles allowed */ 68*2ee4dfc7SJane Chu int consumed; /* normalized consumed cycles */ 69*2ee4dfc7SJane Chu int flag; /* type of cycles */ 70*2ee4dfc7SJane Chu }; 71*2ee4dfc7SJane Chu 727c478bd9Sstevel@tonic-gate struct pm_trans_data { 737c478bd9Sstevel@tonic-gate int format; /* data format */ 747c478bd9Sstevel@tonic-gate union { 757c478bd9Sstevel@tonic-gate struct pm_scsi_cycles scsi_cycles; 76*2ee4dfc7SJane Chu struct pm_smart_count smart_count; 777c478bd9Sstevel@tonic-gate } un; 787c478bd9Sstevel@tonic-gate }; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * Power levels for devices supporting ACPI based D0, D1, D2, D3 states. 827c478bd9Sstevel@tonic-gate * 837c478bd9Sstevel@tonic-gate * Note that 0 is off in Solaris PM framework but D0 is full power 847c478bd9Sstevel@tonic-gate * for these devices. 857c478bd9Sstevel@tonic-gate */ 867c478bd9Sstevel@tonic-gate #define PM_LEVEL_D3 0 /* D3 state - off */ 877c478bd9Sstevel@tonic-gate #define PM_LEVEL_D2 1 /* D2 state */ 887c478bd9Sstevel@tonic-gate #define PM_LEVEL_D1 2 /* D1 state */ 897c478bd9Sstevel@tonic-gate #define PM_LEVEL_D0 3 /* D0 state - fully on */ 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* 927c478bd9Sstevel@tonic-gate * Useful strings for creating pm-components property for these devices. 937c478bd9Sstevel@tonic-gate * If a device driver wishes to provide more specific description of power 947c478bd9Sstevel@tonic-gate * levels (highly recommended), it should NOT use following generic defines. 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate #define PM_LEVEL_D3_STR "0=Device D3 State" 977c478bd9Sstevel@tonic-gate #define PM_LEVEL_D2_STR "1=Device D2 State" 987c478bd9Sstevel@tonic-gate #define PM_LEVEL_D1_STR "2=Device D1 State" 997c478bd9Sstevel@tonic-gate #define PM_LEVEL_D0_STR "3=Device D0 State" 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate /* 1027c478bd9Sstevel@tonic-gate * If you add or remove a function or data reference, please 1037c478bd9Sstevel@tonic-gate * remember to duplicate the action below the #else clause for 1047c478bd9Sstevel@tonic-gate * __STDC__. 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate #ifdef __STDC__ 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * Generic Sun PM definitions. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * These are obsolete power management interfaces, they will be removed from 1157c478bd9Sstevel@tonic-gate * a subsequent release. 1167c478bd9Sstevel@tonic-gate */ 1177c478bd9Sstevel@tonic-gate int 1187c478bd9Sstevel@tonic-gate pm_create_components(dev_info_t *dip, int num_components); 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate void 1217c478bd9Sstevel@tonic-gate pm_destroy_components(dev_info_t *dip); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate void 1247c478bd9Sstevel@tonic-gate pm_set_normal_power(dev_info_t *dip, int component_number, int level); 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate int 1277c478bd9Sstevel@tonic-gate pm_get_normal_power(dev_info_t *dip, int component_number); 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * These are power management interfaces. 1317c478bd9Sstevel@tonic-gate */ 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate int 1347c478bd9Sstevel@tonic-gate pm_busy_component(dev_info_t *dip, int component_number); 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate int 1377c478bd9Sstevel@tonic-gate pm_idle_component(dev_info_t *dip, int component_number); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate int 1407c478bd9Sstevel@tonic-gate pm_get_current_power(dev_info_t *dip, int component, int *levelp); 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate int 1437c478bd9Sstevel@tonic-gate pm_power_has_changed(dev_info_t *, int, int); 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate int 1467c478bd9Sstevel@tonic-gate pm_trans_check(struct pm_trans_data *datap, time_t *intervalp); 1477c478bd9Sstevel@tonic-gate 1487c478bd9Sstevel@tonic-gate int 1497c478bd9Sstevel@tonic-gate pm_lower_power(dev_info_t *dip, int comp, int level); 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate int 1527c478bd9Sstevel@tonic-gate pm_raise_power(dev_info_t *dip, int comp, int level); 1537c478bd9Sstevel@tonic-gate 1545cff7825Smh27603 int 1555cff7825Smh27603 pm_update_maxpower(dev_info_t *dip, int comp, int level); 1565cff7825Smh27603 1577c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* 1607c478bd9Sstevel@tonic-gate * Obsolete interfaces. 1617c478bd9Sstevel@tonic-gate */ 1627c478bd9Sstevel@tonic-gate extern int pm_create_components(); 1637c478bd9Sstevel@tonic-gate extern void pm_destroy_components(); 1647c478bd9Sstevel@tonic-gate extern void pm_set_normal_power(); 1657c478bd9Sstevel@tonic-gate extern int pm_get_normal_power(); 1667c478bd9Sstevel@tonic-gate 1677c478bd9Sstevel@tonic-gate /* 1687c478bd9Sstevel@tonic-gate * PM interfaces 1697c478bd9Sstevel@tonic-gate */ 1707c478bd9Sstevel@tonic-gate extern int pm_busy_component(); 1717c478bd9Sstevel@tonic-gate extern int pm_idle_component(); 1727c478bd9Sstevel@tonic-gate extern int pm_get_current_power(); 1737c478bd9Sstevel@tonic-gate extern int pm_power_has_changed(); 1747c478bd9Sstevel@tonic-gate extern int pm_trans_check(); 1757c478bd9Sstevel@tonic-gate extern int pm_lower_power(); 1767c478bd9Sstevel@tonic-gate extern int pm_raise_power(); 1775cff7825Smh27603 extern int pm_update_maxpower(); 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 1827c478bd9Sstevel@tonic-gate 1837c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1847c478bd9Sstevel@tonic-gate } 1857c478bd9Sstevel@tonic-gate #endif 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate #endif /* _SYS_SUNPM_H */ 188