Deleted Added
full compact
est.c (177040) est.c (177296)
1/*-
2 * Copyright (c) 2004 Colin Percival
3 * Copyright (c) 2005 Nate Lawson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted providing that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2004 Colin Percival
3 * Copyright (c) 2005 Nate Lawson
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted providing that the following conditions
8 * are met:

--- 12 unchanged lines hidden (view full) ---

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
23 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/i386/cpufreq/est.c 177040 2008-03-10 22:00:35Z jhb $");
29__FBSDID("$FreeBSD: head/sys/i386/cpufreq/est.c 177296 2008-03-17 09:01:43Z phk $");
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/cpu.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/module.h>
37#include <sys/smp.h>

--- 58 unchanged lines hidden (view full) ---

96/* Default bus clock value for Centrino processors. */
97#define INTEL_BUS_CLK 100
98
99/* XXX Update this if new CPUs have more settings. */
100#define EST_MAX_SETTINGS 10
101CTASSERT(EST_MAX_SETTINGS <= MAX_SETTINGS);
102
103/* Estimate in microseconds of latency for performing a transition. */
30
31#include <sys/param.h>
32#include <sys/bus.h>
33#include <sys/cpu.h>
34#include <sys/kernel.h>
35#include <sys/malloc.h>
36#include <sys/module.h>
37#include <sys/smp.h>

--- 58 unchanged lines hidden (view full) ---

96/* Default bus clock value for Centrino processors. */
97#define INTEL_BUS_CLK 100
98
99/* XXX Update this if new CPUs have more settings. */
100#define EST_MAX_SETTINGS 10
101CTASSERT(EST_MAX_SETTINGS <= MAX_SETTINGS);
102
103/* Estimate in microseconds of latency for performing a transition. */
104#define EST_TRANS_LAT 10
104#define EST_TRANS_LAT 1000
105
106/*
107 * Frequency (MHz) and voltage (mV) settings. Data from the
108 * Intel Pentium M Processor Datasheet (Order Number 252612), Table 5.
109 *
110 * Dothan processors have multiple VID#s with different settings for
111 * each VID#. Since we can't uniquely identify this info
112 * without undisclosed methods from Intel, we can't support newer

--- 960 unchanged lines hidden (view full) ---

1073
1074static int
1075est_acpi_info(device_t dev, freq_info **freqs)
1076{
1077 struct est_softc *sc;
1078 struct cf_setting *sets;
1079 freq_info *table;
1080 device_t perf_dev;
105
106/*
107 * Frequency (MHz) and voltage (mV) settings. Data from the
108 * Intel Pentium M Processor Datasheet (Order Number 252612), Table 5.
109 *
110 * Dothan processors have multiple VID#s with different settings for
111 * each VID#. Since we can't uniquely identify this info
112 * without undisclosed methods from Intel, we can't support newer

--- 960 unchanged lines hidden (view full) ---

1073
1074static int
1075est_acpi_info(device_t dev, freq_info **freqs)
1076{
1077 struct est_softc *sc;
1078 struct cf_setting *sets;
1079 freq_info *table;
1080 device_t perf_dev;
1081 int count, error, i, j;
1081 int count, error, i, j, maxi, maxfreq;
1082 uint16_t saved_id16;
1083
1084 perf_dev = device_find_child(device_get_parent(dev), "acpi_perf", -1);
1085 if (perf_dev == NULL || !device_is_attached(perf_dev))
1086 return (ENXIO);
1087
1088 /* Fetch settings from acpi_perf. */
1089 sc = device_get_softc(dev);

--- 7 unchanged lines hidden (view full) ---

1097 goto out;
1098
1099 /* Parse settings into our local table format. */
1100 table = malloc((count + 1) * sizeof(freq_info), M_DEVBUF, M_NOWAIT);
1101 if (table == NULL) {
1102 error = ENOMEM;
1103 goto out;
1104 }
1082 uint16_t saved_id16;
1083
1084 perf_dev = device_find_child(device_get_parent(dev), "acpi_perf", -1);
1085 if (perf_dev == NULL || !device_is_attached(perf_dev))
1086 return (ENXIO);
1087
1088 /* Fetch settings from acpi_perf. */
1089 sc = device_get_softc(dev);

--- 7 unchanged lines hidden (view full) ---

1097 goto out;
1098
1099 /* Parse settings into our local table format. */
1100 table = malloc((count + 1) * sizeof(freq_info), M_DEVBUF, M_NOWAIT);
1101 if (table == NULL) {
1102 error = ENOMEM;
1103 goto out;
1104 }
1105 maxi = maxfreq = 0;
1105 for (i = 0, j = 0; i < count; i++) {
1106 /*
1107 * Confirm id16 value is correct.
1108 */
1109 if (sets[i].freq > 0) {
1110 est_get_id16(&saved_id16);
1111 error = est_set_id16(dev, sets[i].spec[0], 1);
1112 if (error != 0) {
1113 if (bootverbose)
1114 device_printf(dev, "Invalid freq %u, "
1115 "ignored.\n", sets[i].freq);
1116 } else {
1117 table[j].freq = sets[i].freq;
1118 table[j].volts = sets[i].volts;
1119 table[j].id16 = sets[i].spec[0];
1120 table[j].power = sets[i].power;
1121 ++j;
1106 for (i = 0, j = 0; i < count; i++) {
1107 /*
1108 * Confirm id16 value is correct.
1109 */
1110 if (sets[i].freq > 0) {
1111 est_get_id16(&saved_id16);
1112 error = est_set_id16(dev, sets[i].spec[0], 1);
1113 if (error != 0) {
1114 if (bootverbose)
1115 device_printf(dev, "Invalid freq %u, "
1116 "ignored.\n", sets[i].freq);
1117 } else {
1118 table[j].freq = sets[i].freq;
1119 table[j].volts = sets[i].volts;
1120 table[j].id16 = sets[i].spec[0];
1121 table[j].power = sets[i].power;
1122 ++j;
1123 if (sets[i].freq > maxfreq) {
1124 maxi = i;
1125 maxfreq = sets[i].freq;
1126 }
1127
1122 }
1123 /* restore saved setting */
1124 est_set_id16(dev, sets[i].spec[0], 0);
1125 }
1126 }
1128 }
1129 /* restore saved setting */
1130 est_set_id16(dev, sets[i].spec[0], 0);
1131 }
1132 }
1133 /*
1134 * Set the frequency to max, so we get through boot fast, and don't
1135 * handicap systems not running powerd.
1136 */
1137 if (maxfreq != 0) {
1138 device_printf(dev, "Setting %d MHz\n", sets[maxi].freq);
1139 est_set_id16(dev, sets[maxi].spec[0], 0);
1140 }
1127
1128 /* Mark end of table with a terminator. */
1129 bzero(&table[j], sizeof(freq_info));
1130
1131 sc->acpi_settings = TRUE;
1132 *freqs = table;
1133 error = 0;
1134

--- 163 unchanged lines hidden ---
1141
1142 /* Mark end of table with a terminator. */
1143 bzero(&table[j], sizeof(freq_info));
1144
1145 sc->acpi_settings = TRUE;
1146 *freqs = table;
1147 error = 0;
1148

--- 163 unchanged lines hidden ---