18906SEric.Saxe@Sun.COM /* 28906SEric.Saxe@Sun.COM * CDDL HEADER START 38906SEric.Saxe@Sun.COM * 48906SEric.Saxe@Sun.COM * The contents of this file are subject to the terms of the 58906SEric.Saxe@Sun.COM * Common Development and Distribution License (the "License"). 68906SEric.Saxe@Sun.COM * You may not use this file except in compliance with the License. 78906SEric.Saxe@Sun.COM * 88906SEric.Saxe@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 98906SEric.Saxe@Sun.COM * or http://www.opensolaris.org/os/licensing. 108906SEric.Saxe@Sun.COM * See the License for the specific language governing permissions 118906SEric.Saxe@Sun.COM * and limitations under the License. 128906SEric.Saxe@Sun.COM * 138906SEric.Saxe@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 148906SEric.Saxe@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 158906SEric.Saxe@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 168906SEric.Saxe@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 178906SEric.Saxe@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 188906SEric.Saxe@Sun.COM * 198906SEric.Saxe@Sun.COM * CDDL HEADER END 208906SEric.Saxe@Sun.COM */ 218906SEric.Saxe@Sun.COM /* 228906SEric.Saxe@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 238906SEric.Saxe@Sun.COM * Use is subject to license terms. 248906SEric.Saxe@Sun.COM */ 258906SEric.Saxe@Sun.COM 268906SEric.Saxe@Sun.COM #ifndef _CPU_PM_H 278906SEric.Saxe@Sun.COM #define _CPU_PM_H 288906SEric.Saxe@Sun.COM 298906SEric.Saxe@Sun.COM #ifdef __cplusplus 308906SEric.Saxe@Sun.COM extern "C" { 318906SEric.Saxe@Sun.COM #endif 328906SEric.Saxe@Sun.COM 338906SEric.Saxe@Sun.COM #if (defined(_KERNEL) || defined(_KMEMUSER)) 348906SEric.Saxe@Sun.COM #include <sys/cpuvar.h> 358906SEric.Saxe@Sun.COM #include <sys/processor.h> 368906SEric.Saxe@Sun.COM #include <sys/types.h> 378906SEric.Saxe@Sun.COM #include <sys/kstat.h> 388906SEric.Saxe@Sun.COM #include <sys/cmt.h> 398906SEric.Saxe@Sun.COM 408906SEric.Saxe@Sun.COM /* 418906SEric.Saxe@Sun.COM * CPU Power Manager Policies 428906SEric.Saxe@Sun.COM */ 438906SEric.Saxe@Sun.COM typedef enum cpupm_policy { 448906SEric.Saxe@Sun.COM CPUPM_POLICY_ELASTIC, 458906SEric.Saxe@Sun.COM CPUPM_POLICY_DISABLED, 468906SEric.Saxe@Sun.COM CPUPM_NUM_POLICIES 478906SEric.Saxe@Sun.COM } cpupm_policy_t; 488906SEric.Saxe@Sun.COM 498906SEric.Saxe@Sun.COM /* 508906SEric.Saxe@Sun.COM * Power Managable CPU Domain Types 518906SEric.Saxe@Sun.COM */ 528906SEric.Saxe@Sun.COM typedef enum cpupm_dtype { 538906SEric.Saxe@Sun.COM CPUPM_DTYPE_ACTIVE, /* Active Power Domain */ 548906SEric.Saxe@Sun.COM CPUPM_DTYPE_IDLE /* Idle Power Domain */ 558906SEric.Saxe@Sun.COM } cpupm_dtype_t; 568906SEric.Saxe@Sun.COM 578906SEric.Saxe@Sun.COM /* 588906SEric.Saxe@Sun.COM * CPUPM state names for policy implementation. 598906SEric.Saxe@Sun.COM * The last element is used to size the enumeration. 608906SEric.Saxe@Sun.COM */ 618906SEric.Saxe@Sun.COM typedef enum cpupm_state_name { 628906SEric.Saxe@Sun.COM CPUPM_STATE_LOW_POWER, 638906SEric.Saxe@Sun.COM CPUPM_STATE_MAX_PERF, 648906SEric.Saxe@Sun.COM CPUPM_STATE_NAMES 658906SEric.Saxe@Sun.COM } cpupm_state_name_t; 668906SEric.Saxe@Sun.COM 678906SEric.Saxe@Sun.COM /* 68*10797SEric.Saxe@Sun.COM * Possible states for the domain's transience governor 69*10797SEric.Saxe@Sun.COM */ 70*10797SEric.Saxe@Sun.COM typedef enum cpupm_gov_state_t { 71*10797SEric.Saxe@Sun.COM CPUPM_GOV_DISENGAGED, 72*10797SEric.Saxe@Sun.COM CPUPM_GOV_TRANS_IDLE, /* Transient idleness, lowerings disabled */ 73*10797SEric.Saxe@Sun.COM CPUPM_GOV_TRANS_WORK /* Transient work, raises disabled */ 74*10797SEric.Saxe@Sun.COM } cpupm_gov_state_t; 75*10797SEric.Saxe@Sun.COM 76*10797SEric.Saxe@Sun.COM /* 778906SEric.Saxe@Sun.COM * Utilization events delivered by the dispatcher. 788906SEric.Saxe@Sun.COM */ 798906SEric.Saxe@Sun.COM typedef enum cpupm_util_event { 808906SEric.Saxe@Sun.COM CPUPM_DOM_BUSY_FROM_IDLE, 818906SEric.Saxe@Sun.COM CPUPM_DOM_IDLE_FROM_BUSY, 828906SEric.Saxe@Sun.COM CPUPM_DOM_REMAIN_BUSY 838906SEric.Saxe@Sun.COM } cpupm_util_event_t; 848906SEric.Saxe@Sun.COM 858906SEric.Saxe@Sun.COM typedef uintptr_t cpupm_handle_t; /* Platform handle */ 868906SEric.Saxe@Sun.COM 878906SEric.Saxe@Sun.COM /* 888906SEric.Saxe@Sun.COM * CPU Power Domain State 898906SEric.Saxe@Sun.COM */ 908906SEric.Saxe@Sun.COM typedef struct cpupm_state { 918906SEric.Saxe@Sun.COM uint32_t cps_speed; 928906SEric.Saxe@Sun.COM cpupm_handle_t cps_handle; 938906SEric.Saxe@Sun.COM } cpupm_state_t; 948906SEric.Saxe@Sun.COM 958906SEric.Saxe@Sun.COM /* 968906SEric.Saxe@Sun.COM * CPU Power Domain 978906SEric.Saxe@Sun.COM */ 988906SEric.Saxe@Sun.COM typedef struct cpupm_domain { 998906SEric.Saxe@Sun.COM id_t cpd_id; /* Domain ID */ 1008906SEric.Saxe@Sun.COM cpupm_dtype_t cpd_type; /* Active or Idle */ 1018906SEric.Saxe@Sun.COM cpupm_state_t *cpd_states; /* Available Power States */ 1028906SEric.Saxe@Sun.COM cpupm_state_t *cpd_state; /* Current State */ 1038906SEric.Saxe@Sun.COM uint_t cpd_nstates; /* Number of States */ 1048906SEric.Saxe@Sun.COM cpupm_state_t *cpd_named_states[CPUPM_STATE_NAMES]; 1058906SEric.Saxe@Sun.COM hrtime_t cpd_last_raise; /* Last raise request time */ 1068906SEric.Saxe@Sun.COM hrtime_t cpd_last_lower; /* last lower request time */ 107*10797SEric.Saxe@Sun.COM int cpd_ti; /* transient idle history */ 1088906SEric.Saxe@Sun.COM int cpd_tw; /* transient work history */ 109*10797SEric.Saxe@Sun.COM cpupm_gov_state_t cpd_governor; /* transience governor */ 1108906SEric.Saxe@Sun.COM struct cpupm_domain *cpd_next; 1118906SEric.Saxe@Sun.COM } cpupm_domain_t; 1128906SEric.Saxe@Sun.COM 1138906SEric.Saxe@Sun.COM #define CPUPM_NO_DOMAIN ((id_t)-1) 1148906SEric.Saxe@Sun.COM 1158906SEric.Saxe@Sun.COM /* 1168906SEric.Saxe@Sun.COM * CPU power manager domain management interfaces 1178906SEric.Saxe@Sun.COM */ 1188906SEric.Saxe@Sun.COM cpupm_domain_t *cpupm_domain_init(struct cpu *, cpupm_dtype_t); 1198906SEric.Saxe@Sun.COM id_t cpupm_domain_id(struct cpu *, cpupm_dtype_t); 1208906SEric.Saxe@Sun.COM int cpupm_change_state(struct cpu *, cpupm_domain_t *, 1218906SEric.Saxe@Sun.COM cpupm_state_t *); 1228906SEric.Saxe@Sun.COM extern void cpupm_redefine_max_activepwr_state(struct cpu *, int); 1238906SEric.Saxe@Sun.COM 1248906SEric.Saxe@Sun.COM /* 1258906SEric.Saxe@Sun.COM * CPU power manager policy engine interfaces 1268906SEric.Saxe@Sun.COM */ 1278906SEric.Saxe@Sun.COM int cpupm_set_policy(cpupm_policy_t); 1288906SEric.Saxe@Sun.COM cpupm_policy_t cpupm_get_policy(void); 1298906SEric.Saxe@Sun.COM void cpupm_utilization_event(struct cpu *, hrtime_t, 1308906SEric.Saxe@Sun.COM cpupm_domain_t *, cpupm_util_event_t); 1318906SEric.Saxe@Sun.COM 1328906SEric.Saxe@Sun.COM /* 1338906SEric.Saxe@Sun.COM * CPU power platform driver interfaces 1348906SEric.Saxe@Sun.COM */ 1358906SEric.Saxe@Sun.COM id_t cpupm_plat_domain_id(struct cpu *, cpupm_dtype_t); 1368906SEric.Saxe@Sun.COM uint_t cpupm_plat_state_enumerate(struct cpu *, cpupm_dtype_t, 1378906SEric.Saxe@Sun.COM cpupm_state_t *); 1388906SEric.Saxe@Sun.COM int cpupm_plat_change_state(struct cpu *, cpupm_state_t *); 1398906SEric.Saxe@Sun.COM 1408906SEric.Saxe@Sun.COM 1418906SEric.Saxe@Sun.COM #endif /* !_KERNEL && !_KMEMUSER */ 1428906SEric.Saxe@Sun.COM 1438906SEric.Saxe@Sun.COM #ifdef __cplusplus 1448906SEric.Saxe@Sun.COM } 1458906SEric.Saxe@Sun.COM #endif 1468906SEric.Saxe@Sun.COM 1478906SEric.Saxe@Sun.COM #endif /* _CPU_PM_H */ 148