2 * Copyright (c) 2014 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Sepherosa Ziehau <sepherosa@gmail.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/systm.h>
38 #include <sys/globaldata.h>
40 #include <machine/md_var.h>
41 #include <machine/cpufunc.h>
42 #include <machine/cpufreq.h>
43 #include <machine/cputypes.h>
44 #include <machine/specialreg.h>
47 #include "acpi_cpu_cstate.h"
50 acpi_cst_md_cx_setup(struct acpi_cst_cx *cx)
52 if (cpu_vendor_id != CPU_VENDOR_INTEL) {
54 * No optimization for non-Intel CPUs so far.
56 * Hardware fixed resouce is not supported for
59 if (cx->type == ACPI_STATE_C1 &&
60 cx->gas.SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE)
62 if (cx->gas.SpaceId != ACPI_ADR_SPACE_SYSTEM_IO &&
63 cx->gas.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
64 kprintf("C%d: invalid SpaceId %d\n", cx->type,
71 if (cx->type == ACPI_STATE_C1 &&
72 cx->gas.SpaceId == ACPI_ADR_SPACE_FIXED_HARDWARE) {
73 /* TODO: filter C1 I/O then halt */
77 /* TODO: We don't support fixed hardware yet */
78 if (cx->gas.SpaceId != ACPI_ADR_SPACE_SYSTEM_IO &&
79 cx->gas.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
80 if (cx->gas.SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE) {
81 kprintf("C%d: invalid SpaceId %d\n", cx->type,
87 if (cx->type >= ACPI_STATE_C3) {
88 if (CPUID_TO_FAMILY(cpu_id) > 0xf ||
89 (CPUID_TO_FAMILY(cpu_id) == 0x6 &&
90 CPUID_TO_MODEL(cpu_id) >= 0xf)) {
92 * Pentium dual-core, Core 2 and beyond do not
93 * need any additional activities to enter C3(+).
95 cx->preamble = ACPI_CST_CX_PREAMBLE_NONE;
96 } else if ((acpi_cst_quirks & ACPI_CST_QUIRK_NO_BM) == 0) {
98 * Intel CPUs support bus master operation for
99 * entering C3(+) even on MP system.
101 cx->preamble = ACPI_CST_CX_PREAMBLE_BM_ARB;