xref: /titanic_52/usr/src/uts/sun4u/io/cpudrv_mach.c (revision 753a6d457b330b1b29b2d3eefcd0831116ce950d)
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
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
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 boolean_t
59 cpudrv_power_ready(void)
60 {
61 	return (B_TRUE);
62 }
63 
64 /*
65  * A noop for this machine type.
66  */
67 /* ARGSUSED */
68 boolean_t
69 cpudrv_is_governor_thread(cpudrv_pm_t *cpupm)
70 {
71 	return (B_FALSE);
72 }
73 
74 /*
75  * A noop for this machine type.
76  */
77 /*ARGSUSED*/
78 boolean_t
79 cpudrv_mach_init(cpudrv_devstate_t *cpudsp)
80 {
81 	return (B_TRUE);
82 }
83 
84 /*
85  * On SPARC all instances support power management unless attach fails.
86  * In the case of attach failure, cpudrv_enabled will be false.
87  */
88 /*ARGSUSED*/
89 boolean_t
90 cpudrv_is_enabled(cpudrv_devstate_t *cpudsp)
91 {
92 	return (cpudrv_enabled);
93 }
94 
95 void
96 cpudrv_set_supp_freqs(cpudrv_devstate_t *cpudsp)
97 {
98 	int		*speeds;
99 	uint_t		nspeeds;
100 
101 	CPUDRV_GET_SPEEDS(cpudsp, speeds, nspeeds);
102 	if (nspeeds == 0)
103 		return;
104 	cpupm_set_supp_freqs(cpudsp->cp, speeds, nspeeds);
105 	CPUDRV_FREE_SPEEDS(speeds, nspeeds);
106 }
107