6715149 T-State support for intel based processors
[illumos-gate.git] / usr / src / uts / sun4u / sys / cpudrv_mach.h
blobcc1536579d742557a8c05df07a8fe74fe42221fb
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _SYS_CPUDRV_MACH_H
27 #define _SYS_CPUDRV_MACH_H
29 #include <sys/cpu_module.h>
30 #include <sys/cpudrv.h>
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
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).
41 #define CPUDRV_PM_XCALL_IS_READY(cpuid) (CPU_XCALL_READY(cpuid))
44 * If a failure occurs during attach(), then CPU power management
45 * is disabled.
47 extern boolean_t cpudrv_enabled;
49 #define CPUDRV_PM_DISABLE() (cpudrv_enabled = B_FALSE)
51 #define CPUDRV_PM_DISABLED() (!cpudrv_enabled)
53 #define CPUDRV_PM_POWER_ENABLED(cpudsp) cpudrv_pm_enabled()
56 * Currently, there is no governor on sun4u,
58 #define CPUDRV_PM_RESET_GOVERNOR_THREAD(cpupm)
61 * Currently, there is no need for a handler on sun4u.
63 #define CPUDRV_PM_INSTALL_MAX_CHANGE_HANDLER(cpudsp, dip)
66 * There is no notion of changing topspeed on sun4u.
68 #define CPUDRV_PM_REDEFINE_TOPSPEED(dip)
71 * There are no PPM callbacks for sun4u.
73 #define CPUDRV_PM_SET_PPM_CALLBACKS()
76 * clock-divisors property tells the supported speeds
77 * as divisors of the normal speed. Divisors are in increasing
78 * order starting with 1 (for normal speed). For example, a
79 * property value of "1, 2, 32" represents full, 1/2 and 1/32
80 * speeds.
82 #define CPUDRV_PM_GET_SPEEDS(cpudsp, speeds, nspeeds) { \
83 if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cpudsp->dip, \
84 DDI_PROP_DONTPASS, "clock-divisors", &speeds, \
85 &nspeeds) != DDI_PROP_SUCCESS) { \
86 DPRINTF(D_PM_INIT, ("cpudrv_pm_init: instance %d: " \
87 "clock-divisors property not defined\n", \
88 ddi_get_instance(cpudsp->dip))); \
89 return (DDI_FAILURE); \
90 } \
92 #define CPUDRV_PM_FREE_SPEEDS(speeds, unused) ddi_prop_free(speeds);
95 * Convert speed to Hz.
97 #define CPUDRV_PM_SPEED_HZ(mhz, divisor) (((uint64_t)mhz * 1000000) / divisor)
100 * Compute the idle cnt percentage for a given speed.
102 #define CPUDRV_PM_IDLE_CNT_PERCENT(hwm, speeds, i) \
103 (100 - ((100 - hwm) * speeds[i]))
106 * Compute the user cnt percentage for a given speed.
108 #define CPUDRV_PM_USER_CNT_PERCENT(hwm, speeds, i) \
109 ((hwm * speeds[i - 1]) / speeds[i])
112 * pm-components property defintions for sun4u.
114 * Fully constructed pm-components property should be an array of
115 * strings that look something like:
117 * pmc[0] = "NAME=CPU Speed"
118 * pmc[1] = "1=1/32 of Normal"
119 * pmc[2] = "2=1/2 of Normal"
120 * pmc[3] = "3=Normal"
122 * The amount of memory needed for each string is:
123 * digits for power level + '=' + '1/' + digits for speed +
124 * description text + '\0'
126 #define CPUDRV_PM_COMP_NORMAL "Normal"
127 #define CPUDRV_PM_COMP_OTHER " of Normal"
128 #define CPUDRV_PM_COMP_SIZE() \
129 (CPUDRV_PM_COMP_MAX_DIG + 1 + 2 + CPUDRV_PM_COMP_MAX_DIG + \
130 sizeof (CPUDRV_PM_COMP_OTHER) + 1);
131 #define CPUDRV_PM_COMP_SPEED(cpupm, cur_spd) \
132 ((cur_spd == cpupm->head_spd) ? cur_spd->pm_level : cur_spd->speed)
133 #define CPUDRV_PM_COMP_SPRINT(pmc, cpupm, cur_spd, comp_spd) { \
134 if (cur_spd == cpupm->head_spd) \
135 (void) sprintf(pmc, "%d=%s", comp_spd, CPUDRV_PM_COMP_NORMAL);\
136 else \
137 (void) sprintf(pmc, "%d=1/%d%s", cur_spd->pm_level, \
138 comp_spd, CPUDRV_PM_COMP_OTHER); \
141 extern boolean_t cpudrv_pm_enabled(void);
143 #ifdef __cplusplus
145 #endif
147 #endif /* _SYS_CPUDRV_MACH_H */