aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7d55039ffa05..bd993351db45 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -2520,6 +2520,50 @@ int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type)
2520 return 0; 2520 return 0;
2521} 2521}
2522 2522
2523/**
2524 * pci_set_vga_state - set VGA decode state on device and parents if requested
2525 * @dev the PCI device
2526 * @decode - true = enable decoding, false = disable decoding
2527 * @command_bits PCI_COMMAND_IO and/or PCI_COMMAND_MEMORY
2528 * @change_bridge - traverse ancestors and change bridges
2529 */
2530int pci_set_vga_state(struct pci_dev *dev, bool decode,
2531 unsigned int command_bits, bool change_bridge)
2532{
2533 struct pci_bus *bus;
2534 struct pci_dev *bridge;
2535 u16 cmd;
2536
2537 WARN_ON(command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY));
2538
2539 pci_read_config_word(dev, PCI_COMMAND, &cmd);
2540 if (decode == true)
2541 cmd |= command_bits;
2542 else
2543 cmd &= ~command_bits;
2544 pci_write_config_word(dev, PCI_COMMAND, cmd);
2545
2546 if (change_bridge == false)
2547 return 0;
2548
2549 bus = dev->bus;
2550 while (bus) {
2551 bridge = bus->self;
2552 if (bridge) {
2553 pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
2554 &cmd);
2555 if (decode == true)
2556 cmd |= PCI_BRIDGE_CTL_VGA;
2557 else
2558 cmd &= ~PCI_BRIDGE_CTL_VGA;
2559 pci_write_config_word(bridge, PCI_BRIDGE_CONTROL,
2560 cmd);
2561 }
2562 bus = bus->parent;
2563 }
2564 return 0;
2565}
2566
2523#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE 2567#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
2524static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; 2568static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
2525spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED; 2569spinlock_t resource_alignment_lock = SPIN_LOCK_UNLOCKED;