1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_CPUDRV_MACH_H 27 #define _SYS_CPUDRV_MACH_H 28 29 #include <sys/cpu_module.h> 30 #include <sys/cpudrv.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * We currently refuse to power manage if the CPU in not ready to 38 * take cross calls (cross calls fail silently if CPU is not ready 39 * for it). 40 */ 41 #define CPUDRV_XCALL_IS_READY(cpuid) (CPU_XCALL_READY(cpuid)) 42 43 /* 44 * Currently, there is no governor on sun4u, 45 */ 46 #define CPUDRV_RESET_GOVERNOR_THREAD(cpupm) 47 48 /* 49 * Currently, there is no need for a handler on sun4u. 50 */ 51 #define CPUDRV_INSTALL_MAX_CHANGE_HANDLER(cpuid) 52 53 /* 54 * Topspeed is always the head speed. 55 */ 56 #define CPUDRV_TOPSPEED(cpupm) (cpupm)->head_spd 57 58 /* 59 * There is no notion of changing topspeed on sun4u. 60 */ 61 #define CPUDRV_REDEFINE_TOPSPEED(dip) 62 63 /* 64 * There are no PPM callbacks for sun4u. 65 */ 66 #define CPUDRV_SET_PPM_CALLBACKS() 67 68 /* 69 * clock-divisors property tells the supported speeds 70 * as divisors of the normal speed. Divisors are in increasing 71 * order starting with 1 (for normal speed). For example, a 72 * property value of "1, 2, 32" represents full, 1/2 and 1/32 73 * speeds. 74 */ 75 #define CPUDRV_GET_SPEEDS(cpudsp, speeds, nspeeds) { \ 76 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cpudsp->dip, \ 77 DDI_PROP_DONTPASS, "clock-divisors", &speeds, \ 78 &nspeeds) != DDI_PROP_SUCCESS) { \ 79 nspeeds = 0; \ 80 DPRINTF(D_PM_INIT, ("cpudrv_init: instance %d: " \ 81 "clock-divisors property not defined\n", \ 82 ddi_get_instance(cpudsp->dip))); \ 83 } \ 84 } 85 #define CPUDRV_FREE_SPEEDS(speeds, nspeeds) { \ 86 if (nspeeds > 0) \ 87 ddi_prop_free(speeds); \ 88 } 89 90 /* 91 * Convert speed to Hz. 92 */ 93 #define CPUDRV_SPEED_HZ(mhz, divisor) (((uint64_t)mhz * 1000000) / divisor) 94 95 /* 96 * Compute the idle cnt percentage for a given speed. 97 */ 98 #define CPUDRV_IDLE_CNT_PERCENT(hwm, speeds, i) \ 99 (100 - ((100 - hwm) * speeds[i])) 100 101 /* 102 * Compute the user cnt percentage for a given speed. 103 */ 104 #define CPUDRV_USER_CNT_PERCENT(hwm, speeds, i) \ 105 ((hwm * speeds[i - 1]) / speeds[i]) 106 107 /* 108 * pm-components property defintions for sun4u. 109 * 110 * Fully constructed pm-components property should be an array of 111 * strings that look something like: 112 * 113 * pmc[0] = "NAME=CPU Speed" 114 * pmc[1] = "1=1/32 of Normal" 115 * pmc[2] = "2=1/2 of Normal" 116 * pmc[3] = "3=Normal" 117 * 118 * The amount of memory needed for each string is: 119 * digits for power level + '=' + '1/' + digits for speed + 120 * description text + '\0' 121 */ 122 #define CPUDRV_COMP_NORMAL "Normal" 123 #define CPUDRV_COMP_OTHER " of Normal" 124 #define CPUDRV_COMP_SIZE() \ 125 (CPUDRV_COMP_MAX_DIG + 1 + 2 + CPUDRV_COMP_MAX_DIG + \ 126 sizeof (CPUDRV_COMP_OTHER) + 1); 127 #define CPUDRV_COMP_SPEED(cpupm, cur_spd) \ 128 ((cur_spd == cpupm->head_spd) ? cur_spd->pm_level : cur_spd->speed) 129 #define CPUDRV_COMP_SPRINT(pmc, cpupm, cur_spd, comp_spd) { \ 130 if (cur_spd == cpupm->head_spd) \ 131 (void) sprintf(pmc, "%d=%s", comp_spd, CPUDRV_COMP_NORMAL);\ 132 else \ 133 (void) sprintf(pmc, "%d=1/%d%s", cur_spd->pm_level, \ 134 comp_spd, CPUDRV_COMP_OTHER); \ 135 } 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* _SYS_CPUDRV_MACH_H */ 142