27 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/types.h>
31 #include <linux/pci.h>
35 #include <linux/slab.h>
37 #define MY_NAME "acpi_pcihp"
39 #define dbg(fmt, arg...) do { if (debug_acpi) printk(KERN_DEBUG "%s: %s: " fmt , MY_NAME , __func__ , ## arg); } while (0)
40 #define err(format, arg...) printk(KERN_ERR "%s: " format , MY_NAME , ## arg)
41 #define info(format, arg...) printk(KERN_INFO "%s: " format , MY_NAME , ## arg)
42 #define warn(format, arg...) printk(KERN_WARNING "%s: " format , MY_NAME , ## arg)
44 #define METHOD_NAME__SUN "_SUN"
45 #define METHOD_NAME_OSHP "OSHP"
47 static bool debug_acpi;
60 for (i = 2; i < 6; i++)
65 hpx->
t0->cache_line_size = fields[2].
integer.value;
66 hpx->
t0->latency_timer = fields[3].
integer.value;
67 hpx->
t0->enable_serr = fields[4].
integer.value;
68 hpx->
t0->enable_perr = fields[5].
integer.value;
72 "%s: Type 0 Revision %d record not supported\n",
90 for (i = 2; i < 5; i++)
95 hpx->
t1->max_mem_read = fields[2].
integer.value;
96 hpx->
t1->avg_max_split = fields[3].
integer.value;
97 hpx->
t1->tot_max_split = fields[4].
integer.value;
101 "%s: Type 1 Revision %d record not supported\n",
117 if (record->
package.count != 18)
119 for (i = 2; i < 18; i++)
124 hpx->
t2->unc_err_mask_and = fields[2].
integer.value;
125 hpx->
t2->unc_err_mask_or = fields[3].
integer.value;
126 hpx->
t2->unc_err_sever_and = fields[4].
integer.value;
127 hpx->
t2->unc_err_sever_or = fields[5].
integer.value;
128 hpx->
t2->cor_err_mask_and = fields[6].
integer.value;
129 hpx->
t2->cor_err_mask_or = fields[7].
integer.value;
130 hpx->
t2->adv_err_cap_and = fields[8].
integer.value;
131 hpx->
t2->adv_err_cap_or = fields[9].
integer.value;
132 hpx->
t2->pci_exp_devctl_and = fields[10].
integer.value;
133 hpx->
t2->pci_exp_devctl_or = fields[11].
integer.value;
134 hpx->
t2->pci_exp_lnkctl_and = fields[12].
integer.value;
135 hpx->
t2->pci_exp_lnkctl_or = fields[13].
integer.value;
136 hpx->
t2->sec_unc_err_sever_and = fields[14].
integer.value;
137 hpx->
t2->sec_unc_err_sever_or = fields[15].
integer.value;
138 hpx->
t2->sec_unc_err_mask_and = fields[16].
integer.value;
139 hpx->
t2->sec_unc_err_mask_or = fields[17].
integer.value;
143 "%s: Type 2 Revision %d record not supported\n",
166 package = (union acpi_object *)buffer.pointer;
172 for (i = 0; i < package->
package.count; i++) {
173 record = &package->
package.elements[
i];
179 fields = record->
package.elements;
186 type = fields[0].
integer.value;
189 status = decode_type0_hpx_record(record, hpx);
194 status = decode_type1_hpx_record(record, hpx);
199 status = decode_type2_hpx_record(record, hpx);
229 package = (union acpi_object *) buffer.pointer;
236 fields = package->
package.elements;
237 for (i = 0; i < 4; i++) {
245 hpp->
t0->revision = 1;
246 hpp->
t0->cache_line_size = fields[0].
integer.value;
247 hpp->
t0->latency_timer = fields[1].
integer.value;
248 hpp->
t0->enable_serr = fields[2].
integer.value;
249 hpp->
t0->enable_perr = fields[3].
integer.value;
274 __func__, (
char *)
string.
pointer, status);
276 dbg(
"%s:%s OSHP not found\n",
277 __func__, (
char *)
string.
pointer);
279 pr_debug(
"%s:%s OSHP passes\n", __func__,
298 for (pbus = dev->
bus; pbus; pbus = pbus->
parent) {
299 handle = acpi_pci_get_bridge_handle(pbus);
311 status = acpi_run_hpx(handle, hpp);
314 status = acpi_run_hpp(handle, hpp);
341 flags &= OSC_SHPC_NATIVE_HP_CONTROL;
343 err(
"Invalid flags %u specified!\n", flags);
356 handle = acpi_find_root_bridge_handle(pdev);
359 dbg(
"Trying to get hotplug control for %s\n",
366 kfree(
string.pointer);
370 handle = DEVICE_ACPI_HANDLE(&pdev->
dev);
377 for (pbus = pdev->
bus; pbus; pbus = pbus->
parent) {
378 handle = acpi_pci_get_bridge_handle(pbus);
386 dbg(
"Trying to get hotplug control for %s \n",
388 status = acpi_run_oshp(handle);
399 dbg(
"Cannot get control of hotplug hardware for pci %s\n",
404 dbg(
"Gained control for hotplug HW for pci %s (%s)\n",
405 pci_name(pdev), (
char *)
string.pointer);
406 kfree(
string.pointer);
439 if (!(bridge_handle = acpi_pci_get_bridge_handle(pbus)))
443 if (bridge_handle != parent_handle)
445 return pcihp_is_ejectable(handle);
452 int *found = (
int *)context;
453 if (pcihp_is_ejectable(handle)) {
474 check_hotplug,
NULL, (
void *)&found,
NULL);