diff --git a/arch/x86/platforms/ia32_pci/system.c b/arch/x86/platforms/ia32_pci/system.c index 70c18dd8e5c..a546704aa3b 100644 --- a/arch/x86/platforms/ia32_pci/system.c +++ b/arch/x86/platforms/ia32_pci/system.c @@ -107,7 +107,7 @@ static int ia32_pci_init(struct device *arg) ioapic_init(); /* NOP if not needed */ hpet_irq_set(); /* NOP if not needed */ -#ifdef CONFIG_PCI_DEBUG +#if defined(CONFIG_PCI_DEBUG) && defined(CONFIG_PCI_ENUMERATION) /* Rescan PCI and display the list of PCI attached devices */ struct pci_dev_info info = { .function = PCI_FUNCTION_ANY, @@ -124,7 +124,7 @@ static int ia32_pci_init(struct device *arg) info.function = PCI_FUNCTION_ANY; info.bar = PCI_BAR_ANY; } -#endif /* CONFIG_PCI_DEBUG */ +#endif /* CONFIG_PCI_DEBUG && CONFIG_PCI_ENUMERATION */ return 0; } diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 8ce2ba77a87..38ed1e1f87c 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -6,8 +6,19 @@ config PCI default n depends on X86_32 help - This options enables support of PCI bus enumeration for device - drivers. + This options enables support of PCI bus for device drivers. + +config PCI_ENUMERATION + bool + prompt "Enable PCI device enumeration" + depends on PCI + default y + help + This option enables the PCI enumeration for device drivers. + This might be useful along with PCI_DEBUG to find out which + are the PCI settings of the devices. Once those are known and + statically set in every relevant driver's configuration, it + might be wise to disable this option to remove useless code. config PCI_DEBUG bool diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a19b9880999..0677abb072b 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -126,6 +126,8 @@ restarting from 0. #include #include +#ifdef CONFIG_PCI_ENUMERATION + /* NOTE. These parameters may need to be configurable */ #define LSPCI_MAX_BUS PCI_BUS_NUMBERS /* maximum number of buses to scan */ #define LSPCI_MAX_DEV 32 /* maximum number of devices to scan */ @@ -391,34 +393,6 @@ void pci_bus_scan_init(void) } -void pci_enable_regs(struct pci_dev_info *dev_info) -{ - union pci_addr_reg pci_ctrl_addr; - uint32_t pci_data; - - pci_ctrl_addr.value = 0; - pci_ctrl_addr.field.func = dev_info->function; - pci_ctrl_addr.field.bus = dev_info->bus; - pci_ctrl_addr.field.device = dev_info->dev; - pci_ctrl_addr.field.reg = 1; - -#ifdef CONFIG_PCI_DEBUG - printk("pci_enable_regs 0x%x\n", pci_ctrl_addr); -#endif - - pci_read(DEFAULT_PCI_CONTROLLER, - pci_ctrl_addr, - sizeof(uint16_t), - &pci_data); - - pci_data = pci_data | PCI_CMD_MEM_ENABLE; - - pci_write(DEFAULT_PCI_CONTROLLER, - pci_ctrl_addr, - sizeof(uint16_t), - pci_data); -} - /** * * @brief Scans PCI bus for devices @@ -484,6 +458,35 @@ int pci_bus_scan(struct pci_dev_info *dev_info) return 0; } +#endif /* CONFIG_PCI_ENUMERATION */ + +void pci_enable_regs(struct pci_dev_info *dev_info) +{ + union pci_addr_reg pci_ctrl_addr; + uint32_t pci_data; + + pci_ctrl_addr.value = 0; + pci_ctrl_addr.field.func = dev_info->function; + pci_ctrl_addr.field.bus = dev_info->bus; + pci_ctrl_addr.field.device = dev_info->dev; + pci_ctrl_addr.field.reg = 1; + +#ifdef CONFIG_PCI_DEBUG + printk("pci_enable_regs 0x%x\n", pci_ctrl_addr); +#endif + + pci_read(DEFAULT_PCI_CONTROLLER, + pci_ctrl_addr, + sizeof(uint16_t), + &pci_data); + + pci_data = pci_data | PCI_CMD_MEM_ENABLE; + + pci_write(DEFAULT_PCI_CONTROLLER, + pci_ctrl_addr, + sizeof(uint16_t), + pci_data); +} #ifdef CONFIG_PCI_DEBUG /** diff --git a/include/drivers/pci/pci.h b/include/drivers/pci/pci.h index 58a3bae25c0..8f032c8a30c 100644 --- a/include/drivers/pci/pci.h +++ b/include/drivers/pci/pci.h @@ -66,8 +66,17 @@ struct pci_dev_info { uint16_t device_id; }; +#ifdef CONFIG_PCI_ENUMERATION extern void pci_bus_scan_init(void); extern int pci_bus_scan(struct pci_dev_info *dev_info); +#else +#define pci_bus_scan_init(void) {;} +static inline int pci_bus_scan(struct pci_dev_info *dev_info) +{ + return 1; +} +#endif /* CONFIG_PCI_ENUMERATION */ + void pci_enable_regs(struct pci_dev_info *dev_info); #ifdef CONFIG_PCI_DEBUG