diff options
author | Matthew Wilcox <matthew@wil.cx> | 2009-12-13 08:11:34 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-02-22 19:15:19 -0500 |
commit | 45b4cdd57ef0e57555b2ab61b584784819b39365 (patch) | |
tree | 1e08008e0cdc57252022b5ad1a0e3029c7e96f99 | |
parent | 9be60ca0497a2563662fde4c9007841c3b79a742 (diff) |
PCI: Add support for AGP in cur/max bus speed
Take advantage of some gaps in the table to fit in support for AGP speeds.
Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r-- | drivers/pci/probe.c | 45 | ||||
-rw-r--r-- | drivers/pci/slot.c | 10 | ||||
-rw-r--r-- | include/linux/pci.h | 5 |
3 files changed, 55 insertions, 5 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 188ee9cf0605..2803ab96a98c 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -437,11 +437,56 @@ void pcie_update_link_speed(struct pci_bus *bus, u16 linksta) | |||
437 | } | 437 | } |
438 | EXPORT_SYMBOL_GPL(pcie_update_link_speed); | 438 | EXPORT_SYMBOL_GPL(pcie_update_link_speed); |
439 | 439 | ||
440 | static unsigned char agp_speeds[] = { | ||
441 | AGP_UNKNOWN, | ||
442 | AGP_1X, | ||
443 | AGP_2X, | ||
444 | AGP_4X, | ||
445 | AGP_8X | ||
446 | }; | ||
447 | |||
448 | static enum pci_bus_speed agp_speed(int agp3, int agpstat) | ||
449 | { | ||
450 | int index = 0; | ||
451 | |||
452 | if (agpstat & 4) | ||
453 | index = 3; | ||
454 | else if (agpstat & 2) | ||
455 | index = 2; | ||
456 | else if (agpstat & 1) | ||
457 | index = 1; | ||
458 | else | ||
459 | goto out; | ||
460 | |||
461 | if (agp3) { | ||
462 | index += 2; | ||
463 | if (index == 5) | ||
464 | index = 0; | ||
465 | } | ||
466 | |||
467 | out: | ||
468 | return agp_speeds[index]; | ||
469 | } | ||
470 | |||
471 | |||
440 | static void pci_set_bus_speed(struct pci_bus *bus) | 472 | static void pci_set_bus_speed(struct pci_bus *bus) |
441 | { | 473 | { |
442 | struct pci_dev *bridge = bus->self; | 474 | struct pci_dev *bridge = bus->self; |
443 | int pos; | 475 | int pos; |
444 | 476 | ||
477 | pos = pci_find_capability(bridge, PCI_CAP_ID_AGP); | ||
478 | if (!pos) | ||
479 | pos = pci_find_capability(bridge, PCI_CAP_ID_AGP3); | ||
480 | if (pos) { | ||
481 | u32 agpstat, agpcmd; | ||
482 | |||
483 | pci_read_config_dword(bridge, pos + PCI_AGP_STATUS, &agpstat); | ||
484 | bus->max_bus_speed = agp_speed(agpstat & 8, agpstat & 7); | ||
485 | |||
486 | pci_read_config_dword(bridge, pos + PCI_AGP_COMMAND, &agpcmd); | ||
487 | bus->cur_bus_speed = agp_speed(agpstat & 8, agpcmd & 7); | ||
488 | } | ||
489 | |||
445 | pos = pci_find_capability(bridge, PCI_CAP_ID_PCIX); | 490 | pos = pci_find_capability(bridge, PCI_CAP_ID_PCIX); |
446 | if (pos) { | 491 | if (pos) { |
447 | u16 status; | 492 | u16 status; |
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 6f6b8d24786a..c7260d4e339b 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c | |||
@@ -61,11 +61,11 @@ static char *pci_bus_speed_strings[] = { | |||
61 | "66 MHz PCI-X 266", /* 0x09 */ | 61 | "66 MHz PCI-X 266", /* 0x09 */ |
62 | "100 MHz PCI-X 266", /* 0x0a */ | 62 | "100 MHz PCI-X 266", /* 0x0a */ |
63 | "133 MHz PCI-X 266", /* 0x0b */ | 63 | "133 MHz PCI-X 266", /* 0x0b */ |
64 | NULL, /* 0x0c */ | 64 | "Unknown AGP", /* 0x0c */ |
65 | NULL, /* 0x0d */ | 65 | "1x AGP", /* 0x0d */ |
66 | NULL, /* 0x0e */ | 66 | "2x AGP", /* 0x0e */ |
67 | NULL, /* 0x0f */ | 67 | "4x AGP", /* 0x0f */ |
68 | NULL, /* 0x10 */ | 68 | "8x AGP", /* 0x10 */ |
69 | "66 MHz PCI-X 533", /* 0x11 */ | 69 | "66 MHz PCI-X 533", /* 0x11 */ |
70 | "100 MHz PCI-X 533", /* 0x12 */ | 70 | "100 MHz PCI-X 533", /* 0x12 */ |
71 | "133 MHz PCI-X 533", /* 0x13 */ | 71 | "133 MHz PCI-X 533", /* 0x13 */ |
diff --git a/include/linux/pci.h b/include/linux/pci.h index a446097a9f68..842adaad312e 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -200,6 +200,11 @@ enum pci_bus_speed { | |||
200 | PCI_SPEED_66MHz_PCIX_266 = 0x09, | 200 | PCI_SPEED_66MHz_PCIX_266 = 0x09, |
201 | PCI_SPEED_100MHz_PCIX_266 = 0x0a, | 201 | PCI_SPEED_100MHz_PCIX_266 = 0x0a, |
202 | PCI_SPEED_133MHz_PCIX_266 = 0x0b, | 202 | PCI_SPEED_133MHz_PCIX_266 = 0x0b, |
203 | AGP_UNKNOWN = 0x0c, | ||
204 | AGP_1X = 0x0d, | ||
205 | AGP_2X = 0x0e, | ||
206 | AGP_4X = 0x0f, | ||
207 | AGP_8X = 0x10, | ||
203 | PCI_SPEED_66MHz_PCIX_533 = 0x11, | 208 | PCI_SPEED_66MHz_PCIX_533 = 0x11, |
204 | PCI_SPEED_100MHz_PCIX_533 = 0x12, | 209 | PCI_SPEED_100MHz_PCIX_533 = 0x12, |
205 | PCI_SPEED_133MHz_PCIX_533 = 0x13, | 210 | PCI_SPEED_133MHz_PCIX_533 = 0x13, |