est.c (143902) | est.c (144630) |
---|---|
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 143902 2005-03-21 06:43:25Z njl $"); | 29__FBSDID("$FreeBSD: head/sys/i386/cpufreq/est.c 144630 2005-04-04 15:51:13Z njl $"); |
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> 38#include <sys/systm.h> 39 40#include "cpufreq_if.h" 41#include <machine/md_var.h> 42 | 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> 38#include <sys/systm.h> 39 40#include "cpufreq_if.h" 41#include <machine/md_var.h> 42 |
43#include <contrib/dev/acpica/acpi.h> 44#include <dev/acpica/acpivar.h> 45#include "acpi_if.h" 46 |
|
43/* Status/control registers (from the IA-32 System Programming Guide). */ 44#define MSR_PERF_STATUS 0x198 45#define MSR_PERF_CTL 0x199 46 47/* Register and bit for enabling SpeedStep. */ 48#define MSR_MISC_ENABLE 0x1a0 49#define MSR_SS_ENABLE (1<<16) 50 --- 476 unchanged lines hidden (view full) --- 527 INTEL(PM_715D_90, 1500, 1276, 600, 988, INTEL_BUS_CLK), 528 INTEL(PM_738_90, 1400, 1116, 600, 988, INTEL_BUS_CLK), 529 INTEL(PM_733_90, 1100, 940, 600, 812, INTEL_BUS_CLK), 530 INTEL(PM_723_90, 1000, 940, 600, 812, INTEL_BUS_CLK), 531 { NULL, 0, 0, NULL }, 532}; 533 534static void est_identify(driver_t *driver, device_t parent); | 47/* Status/control registers (from the IA-32 System Programming Guide). */ 48#define MSR_PERF_STATUS 0x198 49#define MSR_PERF_CTL 0x199 50 51/* Register and bit for enabling SpeedStep. */ 52#define MSR_MISC_ENABLE 0x1a0 53#define MSR_SS_ENABLE (1<<16) 54 --- 476 unchanged lines hidden (view full) --- 531 INTEL(PM_715D_90, 1500, 1276, 600, 988, INTEL_BUS_CLK), 532 INTEL(PM_738_90, 1400, 1116, 600, 988, INTEL_BUS_CLK), 533 INTEL(PM_733_90, 1100, 940, 600, 812, INTEL_BUS_CLK), 534 INTEL(PM_723_90, 1000, 940, 600, 812, INTEL_BUS_CLK), 535 { NULL, 0, 0, NULL }, 536}; 537 538static void est_identify(driver_t *driver, device_t parent); |
539static int est_features(driver_t *driver, u_int *features); |
|
535static int est_probe(device_t parent); 536static int est_attach(device_t parent); 537static int est_detach(device_t parent); 538static int est_get_info(device_t dev); 539static int est_acpi_info(device_t dev, freq_info **freqs); 540static int est_table_info(device_t dev, uint64_t msr, uint32_t bus_clk, 541 freq_info **freqs); 542static freq_info *est_get_current(freq_info *freq_list); --- 9 unchanged lines hidden (view full) --- 552 DEVMETHOD(device_attach, est_attach), 553 DEVMETHOD(device_detach, est_detach), 554 555 /* cpufreq interface */ 556 DEVMETHOD(cpufreq_drv_set, est_set), 557 DEVMETHOD(cpufreq_drv_get, est_get), 558 DEVMETHOD(cpufreq_drv_type, est_type), 559 DEVMETHOD(cpufreq_drv_settings, est_settings), | 540static int est_probe(device_t parent); 541static int est_attach(device_t parent); 542static int est_detach(device_t parent); 543static int est_get_info(device_t dev); 544static int est_acpi_info(device_t dev, freq_info **freqs); 545static int est_table_info(device_t dev, uint64_t msr, uint32_t bus_clk, 546 freq_info **freqs); 547static freq_info *est_get_current(freq_info *freq_list); --- 9 unchanged lines hidden (view full) --- 557 DEVMETHOD(device_attach, est_attach), 558 DEVMETHOD(device_detach, est_detach), 559 560 /* cpufreq interface */ 561 DEVMETHOD(cpufreq_drv_set, est_set), 562 DEVMETHOD(cpufreq_drv_get, est_get), 563 DEVMETHOD(cpufreq_drv_type, est_type), 564 DEVMETHOD(cpufreq_drv_settings, est_settings), |
565 566 /* ACPI interface */ 567 DEVMETHOD(acpi_get_features, est_features), 568 |
|
560 {0, 0} 561}; 562 563static driver_t est_driver = { 564 "est", 565 est_methods, 566 sizeof(struct est_softc), 567}; 568 569static devclass_t est_devclass; 570DRIVER_MODULE(est, cpu, est_driver, est_devclass, 0, 0); 571 | 569 {0, 0} 570}; 571 572static driver_t est_driver = { 573 "est", 574 est_methods, 575 sizeof(struct est_softc), 576}; 577 578static devclass_t est_devclass; 579DRIVER_MODULE(est, cpu, est_driver, est_devclass, 0, 0); 580 |
581static int 582est_features(driver_t *driver, u_int *features) 583{ 584 585 /* Notify the ACPI CPU that we support direct access to MSRs */ 586 *features = ACPI_CAP_PERF_MSRS; 587 return (0); 588} 589 |
|
572static void 573est_identify(driver_t *driver, device_t parent) 574{ | 590static void 591est_identify(driver_t *driver, device_t parent) 592{ |
593 device_t child; |
|
575 u_int p[4]; 576 577 /* Make sure we're not being doubly invoked. */ 578 if (device_find_child(parent, "est", -1) != NULL) 579 return; 580 581 /* Check that CPUID is supported and the vendor is Intel.*/ 582 if (cpu_high == 0 || strcmp(cpu_vendor, GenuineIntel) != 0) 583 return; 584 585 /* Read capability bits and check if the CPU supports EST. */ 586 do_cpuid(1, p); 587 if ((p[2] & 0x80) == 0) 588 return; 589 590 /* 591 * We add a child for each CPU since settings must be performed 592 * on each CPU in the SMP case. 593 */ | 594 u_int p[4]; 595 596 /* Make sure we're not being doubly invoked. */ 597 if (device_find_child(parent, "est", -1) != NULL) 598 return; 599 600 /* Check that CPUID is supported and the vendor is Intel.*/ 601 if (cpu_high == 0 || strcmp(cpu_vendor, GenuineIntel) != 0) 602 return; 603 604 /* Read capability bits and check if the CPU supports EST. */ 605 do_cpuid(1, p); 606 if ((p[2] & 0x80) == 0) 607 return; 608 609 /* 610 * We add a child for each CPU since settings must be performed 611 * on each CPU in the SMP case. 612 */ |
594 if (BUS_ADD_CHILD(parent, 0, "est", -1) == NULL) | 613 child = BUS_ADD_CHILD(parent, 0, "est", -1); 614 if (child == NULL) |
595 device_printf(parent, "add est child failed\n"); 596} 597 598static int 599est_probe(device_t dev) 600{ 601 device_t perf_dev; 602 uint64_t msr; --- 278 unchanged lines hidden --- | 615 device_printf(parent, "add est child failed\n"); 616} 617 618static int 619est_probe(device_t dev) 620{ 621 device_t perf_dev; 622 uint64_t msr; --- 278 unchanged lines hidden --- |