2 * Copyright (C) 2005 Intel Corporation
3 * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
5 * Alex Chiang <achiang@hp.com>
6 * - Unified x86/ia64 implementations
7 * Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
8 * - Added _PDC for platforms with Intel CPUs
10 #include <linux/dmi.h>
12 #include <acpi/acpi_drivers.h>
13 #include <acpi/processor.h>
17 #define PREFIX "ACPI: "
18 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
19 ACPI_MODULE_NAME("processor_pdc");
21 static int set_no_mwait(const struct dmi_system_id *id)
23 printk(KERN_NOTICE PREFIX "%s detected - "
24 "disabling mwait for CPU C-states\n", id->ident);
29 static struct dmi_system_id __cpuinitdata processor_idle_dmi_table[] = {
31 set_no_mwait, "IFL91 board", {
32 DMI_MATCH(DMI_BIOS_VENDOR, "COMPAL"),
33 DMI_MATCH(DMI_SYS_VENDOR, "ZEPTO"),
34 DMI_MATCH(DMI_PRODUCT_VERSION, "3215W"),
35 DMI_MATCH(DMI_BOARD_NAME, "IFL91") }, NULL},
37 set_no_mwait, "Extensa 5220", {
38 DMI_MATCH(DMI_BIOS_VENDOR, "Phoenix Technologies LTD"),
39 DMI_MATCH(DMI_SYS_VENDOR, "Acer"),
40 DMI_MATCH(DMI_PRODUCT_VERSION, "0100"),
41 DMI_MATCH(DMI_BOARD_NAME, "Columbia") }, NULL},
45 static void acpi_set_pdc_bits(u32 *buf)
47 buf[0] = ACPI_PDC_REVISION_ID;
50 /* Enable coordination with firmware's _TSD info */
51 buf[2] = ACPI_PDC_SMP_T_SWCOORD;
53 /* Twiddle arch-specific bits needed for _PDC */
54 arch_acpi_set_pdc_bits(buf);
57 static struct acpi_object_list *acpi_processor_alloc_pdc(void)
59 struct acpi_object_list *obj_list;
60 union acpi_object *obj;
63 /* allocate and initialize pdc. It will be used later. */
64 obj_list = kmalloc(sizeof(struct acpi_object_list), GFP_KERNEL);
66 printk(KERN_ERR "Memory allocation error\n");
70 obj = kmalloc(sizeof(union acpi_object), GFP_KERNEL);
72 printk(KERN_ERR "Memory allocation error\n");
77 buf = kmalloc(12, GFP_KERNEL);
79 printk(KERN_ERR "Memory allocation error\n");
85 acpi_set_pdc_bits(buf);
87 obj->type = ACPI_TYPE_BUFFER;
88 obj->buffer.length = 12;
89 obj->buffer.pointer = (u8 *) buf;
91 obj_list->pointer = obj;
97 * _PDC is required for a BIOS-OS handshake for most of the newer
98 * ACPI processor features.
101 acpi_processor_eval_pdc(acpi_handle handle, struct acpi_object_list *pdc_in)
103 acpi_status status = AE_OK;
107 * If mwait is disabled for CPU C-states, the C2C3_FFH access
108 * mode will be disabled in the parameter of _PDC object.
109 * Of course C1_FFH access mode will also be disabled.
111 union acpi_object *obj;
114 obj = pdc_in->pointer;
115 buffer = (u32 *)(obj->buffer.pointer);
116 buffer[2] &= ~(ACPI_PDC_C_C2C3_FFH | ACPI_PDC_C_C1_FFH);
119 status = acpi_evaluate_object(handle, "_PDC", pdc_in, NULL);
121 if (ACPI_FAILURE(status))
122 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
123 "Could not evaluate _PDC, using legacy perf. control.\n"));
128 void acpi_processor_set_pdc(acpi_handle handle)
130 struct acpi_object_list *obj_list;
132 if (arch_has_acpi_pdc() == false)
135 obj_list = acpi_processor_alloc_pdc();
139 acpi_processor_eval_pdc(handle, obj_list);
141 kfree(obj_list->pointer->buffer.pointer);
142 kfree(obj_list->pointer);
145 EXPORT_SYMBOL_GPL(acpi_processor_set_pdc);
147 static int early_pdc_optin;
148 static int set_early_pdc_optin(const struct dmi_system_id *id)
154 static struct dmi_system_id __cpuinitdata early_pdc_optin_table[] = {
156 set_early_pdc_optin, "HP Envy", {
157 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
158 DMI_MATCH(DMI_PRODUCT_NAME, "HP Envy") }, NULL},
160 set_early_pdc_optin, "HP Pavilion dv6", {
161 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
162 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv6") }, NULL},
164 set_early_pdc_optin, "HP Pavilion dv7", {
165 DMI_MATCH(DMI_BIOS_VENDOR, "Hewlett-Packard"),
166 DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv7") }, NULL},
171 early_init_pdc(acpi_handle handle, u32 lvl, void *context, void **rv)
173 acpi_processor_set_pdc(handle);
177 void __init acpi_early_processor_set_pdc(void)
180 * Check whether the system is DMI table. If yes, OSPM
181 * should not use mwait for CPU-states.
183 dmi_check_system(processor_idle_dmi_table);
186 * Allow systems to opt-in to early _PDC evaluation.
188 dmi_check_system(early_pdc_optin_table);
189 if (!early_pdc_optin)
192 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
194 early_init_pdc, NULL, NULL, NULL);