8354 sync regcomp(3C) with upstream (fix make catalog)
[unleashed/tickless.git] / usr / src / uts / sun4u / sys / cpudrv_mach.h
blobf1714fc695f519c4cdd05c1f3def644f585e9fab
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 2009 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_XCALL_IS_READY(cpuid) (CPU_XCALL_READY(cpuid))
44 * Currently, there is no governor on sun4u,
46 #define CPUDRV_RESET_GOVERNOR_THREAD(cpupm)
49 * Currently, there is no need for a handler on sun4u.
51 #define CPUDRV_INSTALL_MAX_CHANGE_HANDLER(cpuid)
54 * Topspeed is always the head speed.
56 #define CPUDRV_TOPSPEED(cpupm) (cpupm)->head_spd
59 * There is no notion of changing topspeed on sun4u.
61 #define CPUDRV_REDEFINE_TOPSPEED(dip)
64 * There are no PPM callbacks for sun4u.
66 #define CPUDRV_SET_PPM_CALLBACKS()
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.
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 } \
85 #define CPUDRV_FREE_SPEEDS(speeds, nspeeds) { \
86 if (nspeeds > 0) \
87 ddi_prop_free(speeds); \
91 * Convert speed to Hz.
93 #define CPUDRV_SPEED_HZ(mhz, divisor) (((uint64_t)mhz * 1000000) / divisor)
96 * Compute the idle cnt percentage for a given speed.
98 #define CPUDRV_IDLE_CNT_PERCENT(hwm, speeds, i) \
99 (100 - ((100 - hwm) * speeds[i]))
102 * Compute the user cnt percentage for a given speed.
104 #define CPUDRV_USER_CNT_PERCENT(hwm, speeds, i) \
105 ((hwm * speeds[i - 1]) / speeds[i])
108 * pm-components property defintions for sun4u.
110 * Fully constructed pm-components property should be an array of
111 * strings that look something like:
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"
118 * The amount of memory needed for each string is:
119 * digits for power level + '=' + '1/' + digits for speed +
120 * description text + '\0'
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); \
137 #ifdef __cplusplus
139 #endif
141 #endif /* _SYS_CPUDRV_MACH_H */