xref: /illumos-gate/usr/src/uts/sun4u/io/cpudrv_mach.c (revision d5688513)
15cff7825Smh /*
25cff7825Smh  * CDDL HEADER START
35cff7825Smh  *
45cff7825Smh  * The contents of this file are subject to the terms of the
55cff7825Smh  * Common Development and Distribution License (the "License").
65cff7825Smh  * You may not use this file except in compliance with the License.
75cff7825Smh  *
85cff7825Smh  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95cff7825Smh  * or http://www.opensolaris.org/os/licensing.
105cff7825Smh  * See the License for the specific language governing permissions
115cff7825Smh  * and limitations under the License.
125cff7825Smh  *
135cff7825Smh  * When distributing Covered Code, include this CDDL HEADER in each
145cff7825Smh  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155cff7825Smh  * If applicable, add the following below this CDDL HEADER, with the
165cff7825Smh  * fields enclosed by brackets "[]" replaced with your own identifying
175cff7825Smh  * information: Portions Copyright [yyyy] [name of copyright owner]
185cff7825Smh  *
195cff7825Smh  * CDDL HEADER END
205cff7825Smh  */
215cff7825Smh /*
220e751525SEric Saxe  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
235cff7825Smh  * Use is subject to license terms.
245cff7825Smh  */
255cff7825Smh 
265cff7825Smh /*
277f606aceSMark Haywood  * CPU power management driver support for sun4u.
285cff7825Smh  */
295cff7825Smh #include <sys/ddi.h>
305cff7825Smh #include <sys/sunddi.h>
310e751525SEric Saxe #include <sys/cpupm.h>
327f606aceSMark Haywood #include <sys/cpudrv_mach.h>
335cff7825Smh #include <sys/machsystm.h>
345cff7825Smh 
355cff7825Smh /*
365cff7825Smh  * Change CPU speed.
375cff7825Smh  */
385cff7825Smh int
cpudrv_change_speed(cpudrv_devstate_t * cpudsp,cpudrv_pm_spd_t * new_spd)390e751525SEric Saxe cpudrv_change_speed(cpudrv_devstate_t *cpudsp, cpudrv_pm_spd_t *new_spd)
405cff7825Smh {
415cff7825Smh 	xc_one(cpudsp->cpu_id, (xcfunc_t *)cpu_change_speed, \
425cff7825Smh 	    (uint64_t)new_spd->speed, 0);
435cff7825Smh 	return (DDI_SUCCESS);
445cff7825Smh }
455cff7825Smh 
465cff7825Smh /*
475cff7825Smh  * Determine the cpu_id for the CPU device.
485cff7825Smh  */
495cff7825Smh boolean_t
cpudrv_get_cpu_id(dev_info_t * dip,processorid_t * cpu_id)500e751525SEric Saxe cpudrv_get_cpu_id(dev_info_t *dip,  processorid_t *cpu_id)
515cff7825Smh {
525cff7825Smh 	return (dip_to_cpu_id(dip, cpu_id) == DDI_SUCCESS);
535cff7825Smh }
545cff7825Smh 
555cff7825Smh /*
567f606aceSMark Haywood  * A noop for this machine type.
575cff7825Smh  */
58*d5688513SMark Haywood /* ARGSUSED */
595cff7825Smh boolean_t
cpudrv_power_ready(cpu_t * cp)60444f66e7SMark Haywood cpudrv_power_ready(cpu_t *cp)
615cff7825Smh {
625cff7825Smh 	return (B_TRUE);
635cff7825Smh }
645cff7825Smh 
655cff7825Smh /*
667f606aceSMark Haywood  * A noop for this machine type.
675cff7825Smh  */
685cff7825Smh /* ARGSUSED */
695cff7825Smh boolean_t
cpudrv_is_governor_thread(cpudrv_pm_t * cpupm)700e751525SEric Saxe cpudrv_is_governor_thread(cpudrv_pm_t *cpupm)
715cff7825Smh {
725cff7825Smh 	return (B_FALSE);
735cff7825Smh }
745cff7825Smh 
755cff7825Smh /*
767f606aceSMark Haywood  * A noop for this machine type.
775cff7825Smh  */
785cff7825Smh /*ARGSUSED*/
795cff7825Smh boolean_t
cpudrv_mach_init(cpudrv_devstate_t * cpudsp)800e751525SEric Saxe cpudrv_mach_init(cpudrv_devstate_t *cpudsp)
815cff7825Smh {
825cff7825Smh 	return (B_TRUE);
835cff7825Smh }
845cff7825Smh 
855cff7825Smh /*
860e751525SEric Saxe  * On SPARC all instances support power management unless attach fails.
870e751525SEric Saxe  * In the case of attach failure, cpudrv_enabled will be false.
885cff7825Smh  */
895cff7825Smh /*ARGSUSED*/
900e751525SEric Saxe boolean_t
cpudrv_is_enabled(cpudrv_devstate_t * cpudsp)910e751525SEric Saxe cpudrv_is_enabled(cpudrv_devstate_t *cpudsp)
925cff7825Smh {
930e751525SEric Saxe 	return (cpudrv_enabled);
945cff7825Smh }
957f606aceSMark Haywood 
960e751525SEric Saxe void
cpudrv_set_supp_freqs(cpudrv_devstate_t * cpudsp)970e751525SEric Saxe cpudrv_set_supp_freqs(cpudrv_devstate_t *cpudsp)
987f606aceSMark Haywood {
990e751525SEric Saxe 	int		*speeds;
1000e751525SEric Saxe 	uint_t		nspeeds;
1010e751525SEric Saxe 
1020e751525SEric Saxe 	CPUDRV_GET_SPEEDS(cpudsp, speeds, nspeeds);
1030e751525SEric Saxe 	if (nspeeds == 0)
1040e751525SEric Saxe 		return;
1050e751525SEric Saxe 	cpupm_set_supp_freqs(cpudsp->cp, speeds, nspeeds);
1060e751525SEric Saxe 	CPUDRV_FREE_SPEEDS(speeds, nspeeds);
1077f606aceSMark Haywood }
108