1*8906SEric.Saxe@Sun.COM /* 2*8906SEric.Saxe@Sun.COM * CDDL HEADER START 3*8906SEric.Saxe@Sun.COM * 4*8906SEric.Saxe@Sun.COM * The contents of this file are subject to the terms of the 5*8906SEric.Saxe@Sun.COM * Common Development and Distribution License (the "License"). 6*8906SEric.Saxe@Sun.COM * You may not use this file except in compliance with the License. 7*8906SEric.Saxe@Sun.COM * 8*8906SEric.Saxe@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*8906SEric.Saxe@Sun.COM * or http://www.opensolaris.org/os/licensing. 10*8906SEric.Saxe@Sun.COM * See the License for the specific language governing permissions 11*8906SEric.Saxe@Sun.COM * and limitations under the License. 12*8906SEric.Saxe@Sun.COM * 13*8906SEric.Saxe@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 14*8906SEric.Saxe@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*8906SEric.Saxe@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 16*8906SEric.Saxe@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 17*8906SEric.Saxe@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 18*8906SEric.Saxe@Sun.COM * 19*8906SEric.Saxe@Sun.COM * CDDL HEADER END 20*8906SEric.Saxe@Sun.COM */ 21*8906SEric.Saxe@Sun.COM /* 22*8906SEric.Saxe@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23*8906SEric.Saxe@Sun.COM * Use is subject to license terms. 24*8906SEric.Saxe@Sun.COM */ 25*8906SEric.Saxe@Sun.COM 26*8906SEric.Saxe@Sun.COM #ifndef _CPU_PM_H 27*8906SEric.Saxe@Sun.COM #define _CPU_PM_H 28*8906SEric.Saxe@Sun.COM 29*8906SEric.Saxe@Sun.COM #ifdef __cplusplus 30*8906SEric.Saxe@Sun.COM extern "C" { 31*8906SEric.Saxe@Sun.COM #endif 32*8906SEric.Saxe@Sun.COM 33*8906SEric.Saxe@Sun.COM #if (defined(_KERNEL) || defined(_KMEMUSER)) 34*8906SEric.Saxe@Sun.COM #include <sys/cpuvar.h> 35*8906SEric.Saxe@Sun.COM #include <sys/processor.h> 36*8906SEric.Saxe@Sun.COM #include <sys/types.h> 37*8906SEric.Saxe@Sun.COM #include <sys/kstat.h> 38*8906SEric.Saxe@Sun.COM #include <sys/cmt.h> 39*8906SEric.Saxe@Sun.COM 40*8906SEric.Saxe@Sun.COM /* 41*8906SEric.Saxe@Sun.COM * CPU Power Manager Policies 42*8906SEric.Saxe@Sun.COM */ 43*8906SEric.Saxe@Sun.COM typedef enum cpupm_policy { 44*8906SEric.Saxe@Sun.COM CPUPM_POLICY_ELASTIC, 45*8906SEric.Saxe@Sun.COM CPUPM_POLICY_DISABLED, 46*8906SEric.Saxe@Sun.COM CPUPM_NUM_POLICIES 47*8906SEric.Saxe@Sun.COM } cpupm_policy_t; 48*8906SEric.Saxe@Sun.COM 49*8906SEric.Saxe@Sun.COM /* 50*8906SEric.Saxe@Sun.COM * Power Managable CPU Domain Types 51*8906SEric.Saxe@Sun.COM */ 52*8906SEric.Saxe@Sun.COM typedef enum cpupm_dtype { 53*8906SEric.Saxe@Sun.COM CPUPM_DTYPE_ACTIVE, /* Active Power Domain */ 54*8906SEric.Saxe@Sun.COM CPUPM_DTYPE_IDLE /* Idle Power Domain */ 55*8906SEric.Saxe@Sun.COM } cpupm_dtype_t; 56*8906SEric.Saxe@Sun.COM 57*8906SEric.Saxe@Sun.COM /* 58*8906SEric.Saxe@Sun.COM * CPUPM state names for policy implementation. 59*8906SEric.Saxe@Sun.COM * The last element is used to size the enumeration. 60*8906SEric.Saxe@Sun.COM */ 61*8906SEric.Saxe@Sun.COM typedef enum cpupm_state_name { 62*8906SEric.Saxe@Sun.COM CPUPM_STATE_LOW_POWER, 63*8906SEric.Saxe@Sun.COM CPUPM_STATE_MAX_PERF, 64*8906SEric.Saxe@Sun.COM CPUPM_STATE_NAMES 65*8906SEric.Saxe@Sun.COM } cpupm_state_name_t; 66*8906SEric.Saxe@Sun.COM 67*8906SEric.Saxe@Sun.COM /* 68*8906SEric.Saxe@Sun.COM * Utilization events delivered by the dispatcher. 69*8906SEric.Saxe@Sun.COM */ 70*8906SEric.Saxe@Sun.COM typedef enum cpupm_util_event { 71*8906SEric.Saxe@Sun.COM CPUPM_DOM_BUSY_FROM_IDLE, 72*8906SEric.Saxe@Sun.COM CPUPM_DOM_IDLE_FROM_BUSY, 73*8906SEric.Saxe@Sun.COM CPUPM_DOM_REMAIN_BUSY 74*8906SEric.Saxe@Sun.COM } cpupm_util_event_t; 75*8906SEric.Saxe@Sun.COM 76*8906SEric.Saxe@Sun.COM typedef uintptr_t cpupm_handle_t; /* Platform handle */ 77*8906SEric.Saxe@Sun.COM 78*8906SEric.Saxe@Sun.COM /* 79*8906SEric.Saxe@Sun.COM * CPU Power Domain State 80*8906SEric.Saxe@Sun.COM */ 81*8906SEric.Saxe@Sun.COM typedef struct cpupm_state { 82*8906SEric.Saxe@Sun.COM uint32_t cps_speed; 83*8906SEric.Saxe@Sun.COM cpupm_handle_t cps_handle; 84*8906SEric.Saxe@Sun.COM } cpupm_state_t; 85*8906SEric.Saxe@Sun.COM 86*8906SEric.Saxe@Sun.COM /* 87*8906SEric.Saxe@Sun.COM * CPU Power Domain 88*8906SEric.Saxe@Sun.COM */ 89*8906SEric.Saxe@Sun.COM typedef struct cpupm_domain { 90*8906SEric.Saxe@Sun.COM id_t cpd_id; /* Domain ID */ 91*8906SEric.Saxe@Sun.COM cpupm_dtype_t cpd_type; /* Active or Idle */ 92*8906SEric.Saxe@Sun.COM cpupm_state_t *cpd_states; /* Available Power States */ 93*8906SEric.Saxe@Sun.COM cpupm_state_t *cpd_state; /* Current State */ 94*8906SEric.Saxe@Sun.COM uint_t cpd_nstates; /* Number of States */ 95*8906SEric.Saxe@Sun.COM cpupm_state_t *cpd_named_states[CPUPM_STATE_NAMES]; 96*8906SEric.Saxe@Sun.COM hrtime_t cpd_last_raise; /* Last raise request time */ 97*8906SEric.Saxe@Sun.COM hrtime_t cpd_last_lower; /* last lower request time */ 98*8906SEric.Saxe@Sun.COM int cpd_tw; /* transient work history */ 99*8906SEric.Saxe@Sun.COM int cpd_ti; /* transient idle history */ 100*8906SEric.Saxe@Sun.COM boolean_t cpd_ti_governed; /* transient idle governor */ 101*8906SEric.Saxe@Sun.COM boolean_t cpd_tw_governed; /* transient work governor */ 102*8906SEric.Saxe@Sun.COM struct cpupm_domain *cpd_next; 103*8906SEric.Saxe@Sun.COM } cpupm_domain_t; 104*8906SEric.Saxe@Sun.COM 105*8906SEric.Saxe@Sun.COM #define CPUPM_NO_DOMAIN ((id_t)-1) 106*8906SEric.Saxe@Sun.COM 107*8906SEric.Saxe@Sun.COM /* 108*8906SEric.Saxe@Sun.COM * CPU power manager domain management interfaces 109*8906SEric.Saxe@Sun.COM */ 110*8906SEric.Saxe@Sun.COM cpupm_domain_t *cpupm_domain_init(struct cpu *, cpupm_dtype_t); 111*8906SEric.Saxe@Sun.COM id_t cpupm_domain_id(struct cpu *, cpupm_dtype_t); 112*8906SEric.Saxe@Sun.COM int cpupm_change_state(struct cpu *, cpupm_domain_t *, 113*8906SEric.Saxe@Sun.COM cpupm_state_t *); 114*8906SEric.Saxe@Sun.COM extern void cpupm_redefine_max_activepwr_state(struct cpu *, int); 115*8906SEric.Saxe@Sun.COM 116*8906SEric.Saxe@Sun.COM /* 117*8906SEric.Saxe@Sun.COM * CPU power manager policy engine interfaces 118*8906SEric.Saxe@Sun.COM */ 119*8906SEric.Saxe@Sun.COM int cpupm_set_policy(cpupm_policy_t); 120*8906SEric.Saxe@Sun.COM cpupm_policy_t cpupm_get_policy(void); 121*8906SEric.Saxe@Sun.COM void cpupm_utilization_event(struct cpu *, hrtime_t, 122*8906SEric.Saxe@Sun.COM cpupm_domain_t *, cpupm_util_event_t); 123*8906SEric.Saxe@Sun.COM 124*8906SEric.Saxe@Sun.COM /* 125*8906SEric.Saxe@Sun.COM * CPU power platform driver interfaces 126*8906SEric.Saxe@Sun.COM */ 127*8906SEric.Saxe@Sun.COM id_t cpupm_plat_domain_id(struct cpu *, cpupm_dtype_t); 128*8906SEric.Saxe@Sun.COM uint_t cpupm_plat_state_enumerate(struct cpu *, cpupm_dtype_t, 129*8906SEric.Saxe@Sun.COM cpupm_state_t *); 130*8906SEric.Saxe@Sun.COM int cpupm_plat_change_state(struct cpu *, cpupm_state_t *); 131*8906SEric.Saxe@Sun.COM 132*8906SEric.Saxe@Sun.COM 133*8906SEric.Saxe@Sun.COM #endif /* !_KERNEL && !_KMEMUSER */ 134*8906SEric.Saxe@Sun.COM 135*8906SEric.Saxe@Sun.COM #ifdef __cplusplus 136*8906SEric.Saxe@Sun.COM } 137*8906SEric.Saxe@Sun.COM #endif 138*8906SEric.Saxe@Sun.COM 139*8906SEric.Saxe@Sun.COM #endif /* _CPU_PM_H */ 140