xref: /titanic_41/usr/src/uts/sun4u/io/cpudrv_mach.c (revision d5688513c1985c22c27675da44b5b691f123818e)
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 /*
27  * CPU power management driver support for sun4u.
28  */
29 #include <sys/ddi.h>
30 #include <sys/sunddi.h>
31 #include <sys/cpupm.h>
32 #include <sys/cpudrv_mach.h>
33 #include <sys/machsystm.h>
34 
35 /*
36  * Change CPU speed.
37  */
38 int
cpudrv_change_speed(cpudrv_devstate_t * cpudsp,cpudrv_pm_spd_t * new_spd)39 cpudrv_change_speed(cpudrv_devstate_t *cpudsp, cpudrv_pm_spd_t *new_spd)
40 {
41 	xc_one(cpudsp->cpu_id, (xcfunc_t *)cpu_change_speed, \
42 	    (uint64_t)new_spd->speed, 0);
43 	return (DDI_SUCCESS);
44 }
45 
46 /*
47  * Determine the cpu_id for the CPU device.
48  */
49 boolean_t
cpudrv_get_cpu_id(dev_info_t * dip,processorid_t * cpu_id)50 cpudrv_get_cpu_id(dev_info_t *dip,  processorid_t *cpu_id)
51 {
52 	return (dip_to_cpu_id(dip, cpu_id) == DDI_SUCCESS);
53 }
54 
55 /*
56  * A noop for this machine type.
57  */
58 /* ARGSUSED */
59 boolean_t
cpudrv_power_ready(cpu_t * cp)60 cpudrv_power_ready(cpu_t *cp)
61 {
62 	return (B_TRUE);
63 }
64 
65 /*
66  * A noop for this machine type.
67  */
68 /* ARGSUSED */
69 boolean_t
cpudrv_is_governor_thread(cpudrv_pm_t * cpupm)70 cpudrv_is_governor_thread(cpudrv_pm_t *cpupm)
71 {
72 	return (B_FALSE);
73 }
74 
75 /*
76  * A noop for this machine type.
77  */
78 /*ARGSUSED*/
79 boolean_t
cpudrv_mach_init(cpudrv_devstate_t * cpudsp)80 cpudrv_mach_init(cpudrv_devstate_t *cpudsp)
81 {
82 	return (B_TRUE);
83 }
84 
85 /*
86  * On SPARC all instances support power management unless attach fails.
87  * In the case of attach failure, cpudrv_enabled will be false.
88  */
89 /*ARGSUSED*/
90 boolean_t
cpudrv_is_enabled(cpudrv_devstate_t * cpudsp)91 cpudrv_is_enabled(cpudrv_devstate_t *cpudsp)
92 {
93 	return (cpudrv_enabled);
94 }
95 
96 void
cpudrv_set_supp_freqs(cpudrv_devstate_t * cpudsp)97 cpudrv_set_supp_freqs(cpudrv_devstate_t *cpudsp)
98 {
99 	int		*speeds;
100 	uint_t		nspeeds;
101 
102 	CPUDRV_GET_SPEEDS(cpudsp, speeds, nspeeds);
103 	if (nspeeds == 0)
104 		return;
105 	cpupm_set_supp_freqs(cpudsp->cp, speeds, nspeeds);
106 	CPUDRV_FREE_SPEEDS(speeds, nspeeds);
107 }
108