diff options
author | Kristen Accardi <kristen.c.accardi@intel.com> | 2006-03-03 13:16:05 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-03-23 17:35:17 -0500 |
commit | 783c49fc506d9afe4784390b556fa25ede5d6d1f (patch) | |
tree | 8090c2251193211129816254f16f10cbb33ed20c /drivers/pci/hotplug/acpiphp_glue.c | |
parent | f5afe8064f3087bead8fea7e32547c2a3ada5fd0 (diff) |
[PATCH] PCI Hotplug: add common acpi functions to core
shpchprm_acpi.c and pciehprm_acpi.c are nearly identical. In addition,
there are functions in both these files that are also in acpiphp_glue.c.
This patch will remove duplicate functions from shpchp, pciehp, and
acpiphp and move this functionality to pci_hotplug, as it is not
hardware specific. Get rid of shpchprm* and pciehprm* files since they
are no longer needed. shpchprm_nonacpi.c and pciehprm_nonacpi.c are
identical, as well as shpchprm_legacy.c and can be replaced with a
macro.
This patch also changes acpiphp to use the common hpp code.
Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/hotplug/acpiphp_glue.c')
-rw-r--r-- | drivers/pci/hotplug/acpiphp_glue.c | 91 |
1 files changed, 13 insertions, 78 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index c7e6387983df..053ee843863c 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
@@ -285,57 +285,19 @@ static int detect_ejectable_slots(acpi_handle *bridge_handle) | |||
285 | static void decode_hpp(struct acpiphp_bridge *bridge) | 285 | static void decode_hpp(struct acpiphp_bridge *bridge) |
286 | { | 286 | { |
287 | acpi_status status; | 287 | acpi_status status; |
288 | struct acpi_buffer buffer = { .length = ACPI_ALLOCATE_BUFFER, | ||
289 | .pointer = NULL}; | ||
290 | union acpi_object *package; | ||
291 | int i; | ||
292 | |||
293 | /* default numbers */ | ||
294 | bridge->hpp.cache_line_size = 0x10; | ||
295 | bridge->hpp.latency_timer = 0x40; | ||
296 | bridge->hpp.enable_SERR = 0; | ||
297 | bridge->hpp.enable_PERR = 0; | ||
298 | |||
299 | status = acpi_evaluate_object(bridge->handle, "_HPP", NULL, &buffer); | ||
300 | 288 | ||
289 | status = acpi_get_hp_params_from_firmware(bridge->pci_dev, &bridge->hpp); | ||
301 | if (ACPI_FAILURE(status)) { | 290 | if (ACPI_FAILURE(status)) { |
302 | dbg("_HPP evaluation failed\n"); | 291 | /* use default numbers */ |
303 | return; | 292 | bridge->hpp.cache_line_size = 0x10; |
304 | } | 293 | bridge->hpp.latency_timer = 0x40; |
305 | 294 | bridge->hpp.enable_serr = 0; | |
306 | package = (union acpi_object *) buffer.pointer; | 295 | bridge->hpp.enable_perr = 0; |
307 | |||
308 | if (!package || package->type != ACPI_TYPE_PACKAGE || | ||
309 | package->package.count != 4 || !package->package.elements) { | ||
310 | err("invalid _HPP object; ignoring\n"); | ||
311 | goto err_exit; | ||
312 | } | 296 | } |
313 | |||
314 | for (i = 0; i < 4; i++) { | ||
315 | if (package->package.elements[i].type != ACPI_TYPE_INTEGER) { | ||
316 | err("invalid _HPP parameter type; ignoring\n"); | ||
317 | goto err_exit; | ||
318 | } | ||
319 | } | ||
320 | |||
321 | bridge->hpp.cache_line_size = package->package.elements[0].integer.value; | ||
322 | bridge->hpp.latency_timer = package->package.elements[1].integer.value; | ||
323 | bridge->hpp.enable_SERR = package->package.elements[2].integer.value; | ||
324 | bridge->hpp.enable_PERR = package->package.elements[3].integer.value; | ||
325 | |||
326 | dbg("_HPP parameter = (%02x, %02x, %02x, %02x)\n", | ||
327 | bridge->hpp.cache_line_size, | ||
328 | bridge->hpp.latency_timer, | ||
329 | bridge->hpp.enable_SERR, | ||
330 | bridge->hpp.enable_PERR); | ||
331 | |||
332 | bridge->flags |= BRIDGE_HAS_HPP; | ||
333 | |||
334 | err_exit: | ||
335 | kfree(buffer.pointer); | ||
336 | } | 297 | } |
337 | 298 | ||
338 | 299 | ||
300 | |||
339 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ | 301 | /* initialize miscellaneous stuff for both root and PCI-to-PCI bridge */ |
340 | static void init_bridge_misc(struct acpiphp_bridge *bridge) | 302 | static void init_bridge_misc(struct acpiphp_bridge *bridge) |
341 | { | 303 | { |
@@ -1154,11 +1116,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
1154 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, | 1116 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, |
1155 | bridge->hpp.latency_timer); | 1117 | bridge->hpp.latency_timer); |
1156 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); | 1118 | pci_read_config_word(dev, PCI_COMMAND, &pci_cmd); |
1157 | if (bridge->hpp.enable_SERR) | 1119 | if (bridge->hpp.enable_serr) |
1158 | pci_cmd |= PCI_COMMAND_SERR; | 1120 | pci_cmd |= PCI_COMMAND_SERR; |
1159 | else | 1121 | else |
1160 | pci_cmd &= ~PCI_COMMAND_SERR; | 1122 | pci_cmd &= ~PCI_COMMAND_SERR; |
1161 | if (bridge->hpp.enable_PERR) | 1123 | if (bridge->hpp.enable_perr) |
1162 | pci_cmd |= PCI_COMMAND_PARITY; | 1124 | pci_cmd |= PCI_COMMAND_PARITY; |
1163 | else | 1125 | else |
1164 | pci_cmd &= ~PCI_COMMAND_PARITY; | 1126 | pci_cmd &= ~PCI_COMMAND_PARITY; |
@@ -1169,11 +1131,11 @@ static void program_hpp(struct pci_dev *dev, struct acpiphp_bridge *bridge) | |||
1169 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, | 1131 | pci_write_config_byte(dev, PCI_SEC_LATENCY_TIMER, |
1170 | bridge->hpp.latency_timer); | 1132 | bridge->hpp.latency_timer); |
1171 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); | 1133 | pci_read_config_word(dev, PCI_BRIDGE_CONTROL, &pci_bctl); |
1172 | if (bridge->hpp.enable_SERR) | 1134 | if (bridge->hpp.enable_serr) |
1173 | pci_bctl |= PCI_BRIDGE_CTL_SERR; | 1135 | pci_bctl |= PCI_BRIDGE_CTL_SERR; |
1174 | else | 1136 | else |
1175 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; | 1137 | pci_bctl &= ~PCI_BRIDGE_CTL_SERR; |
1176 | if (bridge->hpp.enable_PERR) | 1138 | if (bridge->hpp.enable_perr) |
1177 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; | 1139 | pci_bctl |= PCI_BRIDGE_CTL_PARITY; |
1178 | else | 1140 | else |
1179 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; | 1141 | pci_bctl &= ~PCI_BRIDGE_CTL_PARITY; |
@@ -1193,6 +1155,7 @@ static void acpiphp_set_hpp_values(acpi_handle handle, struct pci_bus *bus) | |||
1193 | 1155 | ||
1194 | memset(&bridge, 0, sizeof(bridge)); | 1156 | memset(&bridge, 0, sizeof(bridge)); |
1195 | bridge.handle = handle; | 1157 | bridge.handle = handle; |
1158 | bridge.pci_dev = bus->self; | ||
1196 | decode_hpp(&bridge); | 1159 | decode_hpp(&bridge); |
1197 | list_for_each_entry(dev, &bus->devices, bus_list) | 1160 | list_for_each_entry(dev, &bus->devices, bus_list) |
1198 | program_hpp(dev, &bridge); | 1161 | program_hpp(dev, &bridge); |
@@ -1409,41 +1372,13 @@ void handle_hotplug_event_func(acpi_handle handle, u32 type, void *context) | |||
1409 | } | 1372 | } |
1410 | } | 1373 | } |
1411 | 1374 | ||
1412 | static int is_root_bridge(acpi_handle handle) | ||
1413 | { | ||
1414 | acpi_status status; | ||
1415 | struct acpi_device_info *info; | ||
1416 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
1417 | int i; | ||
1418 | |||
1419 | status = acpi_get_object_info(handle, &buffer); | ||
1420 | if (ACPI_SUCCESS(status)) { | ||
1421 | info = buffer.pointer; | ||
1422 | if ((info->valid & ACPI_VALID_HID) && | ||
1423 | !strcmp(PCI_ROOT_HID_STRING, | ||
1424 | info->hardware_id.value)) { | ||
1425 | acpi_os_free(buffer.pointer); | ||
1426 | return 1; | ||
1427 | } | ||
1428 | if (info->valid & ACPI_VALID_CID) { | ||
1429 | for (i=0; i < info->compatibility_id.count; i++) { | ||
1430 | if (!strcmp(PCI_ROOT_HID_STRING, | ||
1431 | info->compatibility_id.id[i].value)) { | ||
1432 | acpi_os_free(buffer.pointer); | ||
1433 | return 1; | ||
1434 | } | ||
1435 | } | ||
1436 | } | ||
1437 | } | ||
1438 | return 0; | ||
1439 | } | ||
1440 | 1375 | ||
1441 | static acpi_status | 1376 | static acpi_status |
1442 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) | 1377 | find_root_bridges(acpi_handle handle, u32 lvl, void *context, void **rv) |
1443 | { | 1378 | { |
1444 | int *count = (int *)context; | 1379 | int *count = (int *)context; |
1445 | 1380 | ||
1446 | if (is_root_bridge(handle)) { | 1381 | if (acpi_root_bridge(handle)) { |
1447 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, | 1382 | acpi_install_notify_handler(handle, ACPI_SYSTEM_NOTIFY, |
1448 | handle_hotplug_event_bridge, NULL); | 1383 | handle_hotplug_event_bridge, NULL); |
1449 | (*count)++; | 1384 | (*count)++; |