xref: /titanic_41/usr/src/uts/sun4u/sys/cpudrv_mach.h (revision 0e7515250c8395f368aa45fb9acae7c4f8f8b786)
17f606aceSMark Haywood /*
27f606aceSMark Haywood  * CDDL HEADER START
37f606aceSMark Haywood  *
47f606aceSMark Haywood  * The contents of this file are subject to the terms of the
57f606aceSMark Haywood  * Common Development and Distribution License (the "License").
67f606aceSMark Haywood  * You may not use this file except in compliance with the License.
77f606aceSMark Haywood  *
87f606aceSMark Haywood  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97f606aceSMark Haywood  * or http://www.opensolaris.org/os/licensing.
107f606aceSMark Haywood  * See the License for the specific language governing permissions
117f606aceSMark Haywood  * and limitations under the License.
127f606aceSMark Haywood  *
137f606aceSMark Haywood  * When distributing Covered Code, include this CDDL HEADER in each
147f606aceSMark Haywood  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157f606aceSMark Haywood  * If applicable, add the following below this CDDL HEADER, with the
167f606aceSMark Haywood  * fields enclosed by brackets "[]" replaced with your own identifying
177f606aceSMark Haywood  * information: Portions Copyright [yyyy] [name of copyright owner]
187f606aceSMark Haywood  *
197f606aceSMark Haywood  * CDDL HEADER END
207f606aceSMark Haywood  */
217f606aceSMark Haywood /*
22*0e751525SEric Saxe  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237f606aceSMark Haywood  * Use is subject to license terms.
247f606aceSMark Haywood  */
257f606aceSMark Haywood 
267f606aceSMark Haywood #ifndef _SYS_CPUDRV_MACH_H
277f606aceSMark Haywood #define	_SYS_CPUDRV_MACH_H
287f606aceSMark Haywood 
297f606aceSMark Haywood #include <sys/cpu_module.h>
307f606aceSMark Haywood #include <sys/cpudrv.h>
317f606aceSMark Haywood 
327f606aceSMark Haywood #ifdef  __cplusplus
337f606aceSMark Haywood extern "C" {
347f606aceSMark Haywood #endif
357f606aceSMark Haywood 
367f606aceSMark Haywood /*
377f606aceSMark Haywood  * We currently refuse to power manage if the CPU in not ready to
387f606aceSMark Haywood  * take cross calls (cross calls fail silently if CPU is not ready
397f606aceSMark Haywood  * for it).
407f606aceSMark Haywood  */
41*0e751525SEric Saxe #define	CPUDRV_XCALL_IS_READY(cpuid) (CPU_XCALL_READY(cpuid))
427f606aceSMark Haywood 
437f606aceSMark Haywood /*
447f606aceSMark Haywood  * Currently, there is no governor on sun4u,
457f606aceSMark Haywood  */
46*0e751525SEric Saxe #define	CPUDRV_RESET_GOVERNOR_THREAD(cpupm)
477f606aceSMark Haywood 
487f606aceSMark Haywood /*
497f606aceSMark Haywood  * Currently, there is no need for a handler on sun4u.
507f606aceSMark Haywood  */
51*0e751525SEric Saxe #define	CPUDRV_INSTALL_MAX_CHANGE_HANDLER(cpuid)
527f606aceSMark Haywood 
537f606aceSMark Haywood /*
5417353130SMark Haywood  * Topspeed is always the head speed.
5517353130SMark Haywood  */
56*0e751525SEric Saxe #define	CPUDRV_TOPSPEED(cpupm)	(cpupm)->head_spd
5717353130SMark Haywood 
5817353130SMark Haywood /*
597f606aceSMark Haywood  * There is no notion of changing topspeed on sun4u.
607f606aceSMark Haywood  */
61*0e751525SEric Saxe #define	CPUDRV_REDEFINE_TOPSPEED(dip)
627f606aceSMark Haywood 
637f606aceSMark Haywood /*
647f606aceSMark Haywood  * There are no PPM callbacks for sun4u.
657f606aceSMark Haywood  */
66*0e751525SEric Saxe #define	CPUDRV_SET_PPM_CALLBACKS()
677f606aceSMark Haywood 
687f606aceSMark Haywood /*
697f606aceSMark Haywood  * clock-divisors property tells the supported speeds
707f606aceSMark Haywood  * as divisors of the normal speed. Divisors are in increasing
717f606aceSMark Haywood  * order starting with 1 (for normal speed). For example, a
727f606aceSMark Haywood  * property value of "1, 2, 32" represents full, 1/2 and 1/32
737f606aceSMark Haywood  * speeds.
747f606aceSMark Haywood  */
75*0e751525SEric Saxe #define	CPUDRV_GET_SPEEDS(cpudsp, speeds, nspeeds) { \
767f606aceSMark Haywood 	if (ddi_prop_lookup_int_array(DDI_DEV_T_ANY, cpudsp->dip, \
777f606aceSMark Haywood 	    DDI_PROP_DONTPASS, "clock-divisors", &speeds, \
787f606aceSMark Haywood 	    &nspeeds) != DDI_PROP_SUCCESS) { \
79*0e751525SEric Saxe 		nspeeds = 0; \
80*0e751525SEric Saxe 		DPRINTF(D_PM_INIT, ("cpudrv_init: instance %d: " \
817f606aceSMark Haywood 		    "clock-divisors property not defined\n", \
827f606aceSMark Haywood 		    ddi_get_instance(cpudsp->dip))); \
837f606aceSMark Haywood 	} \
847f606aceSMark Haywood }
85*0e751525SEric Saxe #define	CPUDRV_FREE_SPEEDS(speeds, nspeeds) { \
86*0e751525SEric Saxe 	if (nspeeds > 0) \
87*0e751525SEric Saxe 		ddi_prop_free(speeds); \
88*0e751525SEric Saxe }
897f606aceSMark Haywood 
907f606aceSMark Haywood /*
917f606aceSMark Haywood  * Convert speed to Hz.
927f606aceSMark Haywood  */
93*0e751525SEric Saxe #define	CPUDRV_SPEED_HZ(mhz, divisor) (((uint64_t)mhz * 1000000) / divisor)
947f606aceSMark Haywood 
957f606aceSMark Haywood /*
967f606aceSMark Haywood  * Compute the idle cnt percentage for a given speed.
977f606aceSMark Haywood  */
98*0e751525SEric Saxe #define	CPUDRV_IDLE_CNT_PERCENT(hwm, speeds, i) \
997f606aceSMark Haywood 	(100 - ((100 - hwm) * speeds[i]))
1007f606aceSMark Haywood 
1017f606aceSMark Haywood /*
1027f606aceSMark Haywood  * Compute the user cnt percentage for a given speed.
1037f606aceSMark Haywood  */
104*0e751525SEric Saxe #define	CPUDRV_USER_CNT_PERCENT(hwm, speeds, i) \
1057f606aceSMark Haywood 	((hwm * speeds[i - 1]) / speeds[i])
1067f606aceSMark Haywood 
1077f606aceSMark Haywood /*
1087f606aceSMark Haywood  * pm-components property defintions for sun4u.
1097f606aceSMark Haywood  *
1107f606aceSMark Haywood  * Fully constructed pm-components property should be an array of
1117f606aceSMark Haywood  * strings that look something like:
1127f606aceSMark Haywood  *
1137f606aceSMark Haywood  * pmc[0] = "NAME=CPU Speed"
1147f606aceSMark Haywood  * pmc[1] = "1=1/32 of Normal"
1157f606aceSMark Haywood  * pmc[2] = "2=1/2 of Normal"
1167f606aceSMark Haywood  * pmc[3] = "3=Normal"
1177f606aceSMark Haywood  *
1187f606aceSMark Haywood  * The amount of memory needed for each string is:
1197f606aceSMark Haywood  *      digits for power level + '=' + '1/' + digits for speed +
1207f606aceSMark Haywood  *      description text + '\0'
1217f606aceSMark Haywood  */
122*0e751525SEric Saxe #define	CPUDRV_COMP_NORMAL "Normal"
123*0e751525SEric Saxe #define	CPUDRV_COMP_OTHER " of Normal"
124*0e751525SEric Saxe #define	CPUDRV_COMP_SIZE() \
125*0e751525SEric Saxe 	(CPUDRV_COMP_MAX_DIG + 1 + 2 + CPUDRV_COMP_MAX_DIG + \
126*0e751525SEric Saxe 	    sizeof (CPUDRV_COMP_OTHER) + 1);
127*0e751525SEric Saxe #define	CPUDRV_COMP_SPEED(cpupm, cur_spd) \
1287f606aceSMark Haywood 	((cur_spd == cpupm->head_spd) ? cur_spd->pm_level : cur_spd->speed)
129*0e751525SEric Saxe #define	CPUDRV_COMP_SPRINT(pmc, cpupm, cur_spd, comp_spd) { \
1307f606aceSMark Haywood 	if (cur_spd == cpupm->head_spd) \
131*0e751525SEric Saxe 		(void) sprintf(pmc, "%d=%s", comp_spd, CPUDRV_COMP_NORMAL);\
1327f606aceSMark Haywood 	else \
1337f606aceSMark Haywood 		(void) sprintf(pmc, "%d=1/%d%s", cur_spd->pm_level, \
134*0e751525SEric Saxe 		    comp_spd, CPUDRV_COMP_OTHER); \
1357f606aceSMark Haywood }
1367f606aceSMark Haywood 
1377f606aceSMark Haywood #ifdef  __cplusplus
1387f606aceSMark Haywood }
1397f606aceSMark Haywood #endif
1407f606aceSMark Haywood 
1417f606aceSMark Haywood #endif /* _SYS_CPUDRV_MACH_H */
142