pci: Add an option for enumerating PCI devices
This option will be used to disable PCI enumeration (not PCI bus) to gain in code size and execution as long as driver will be properly configured statically. Thus setting this option as set by default. Change-Id: I7da5d154c8ee89e44fc2bad8e85a5a20f498927e Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
3e32b29f57
commit
018bcfe8d4
4 changed files with 55 additions and 32 deletions
|
@ -107,7 +107,7 @@ static int ia32_pci_init(struct device *arg)
|
||||||
ioapic_init(); /* NOP if not needed */
|
ioapic_init(); /* NOP if not needed */
|
||||||
hpet_irq_set(); /* 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 */
|
/* Rescan PCI and display the list of PCI attached devices */
|
||||||
struct pci_dev_info info = {
|
struct pci_dev_info info = {
|
||||||
.function = PCI_FUNCTION_ANY,
|
.function = PCI_FUNCTION_ANY,
|
||||||
|
@ -124,7 +124,7 @@ static int ia32_pci_init(struct device *arg)
|
||||||
info.function = PCI_FUNCTION_ANY;
|
info.function = PCI_FUNCTION_ANY;
|
||||||
info.bar = PCI_BAR_ANY;
|
info.bar = PCI_BAR_ANY;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_PCI_DEBUG */
|
#endif /* CONFIG_PCI_DEBUG && CONFIG_PCI_ENUMERATION */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,19 @@ config PCI
|
||||||
default n
|
default n
|
||||||
depends on X86_32
|
depends on X86_32
|
||||||
help
|
help
|
||||||
This options enables support of PCI bus enumeration for device
|
This options enables support of PCI bus for device drivers.
|
||||||
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
|
config PCI_DEBUG
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -126,6 +126,8 @@ restarting from 0.
|
||||||
#include <pci/pci_mgr.h>
|
#include <pci/pci_mgr.h>
|
||||||
#include <pci/pci.h>
|
#include <pci/pci.h>
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCI_ENUMERATION
|
||||||
|
|
||||||
/* NOTE. These parameters may need to be configurable */
|
/* NOTE. These parameters may need to be configurable */
|
||||||
#define LSPCI_MAX_BUS PCI_BUS_NUMBERS /* maximum number of buses to scan */
|
#define LSPCI_MAX_BUS PCI_BUS_NUMBERS /* maximum number of buses to scan */
|
||||||
#define LSPCI_MAX_DEV 32 /* maximum number of devices 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
|
* @brief Scans PCI bus for devices
|
||||||
|
@ -484,6 +458,35 @@ int pci_bus_scan(struct pci_dev_info *dev_info)
|
||||||
|
|
||||||
return 0;
|
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
|
#ifdef CONFIG_PCI_DEBUG
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -66,8 +66,17 @@ struct pci_dev_info {
|
||||||
uint16_t device_id;
|
uint16_t device_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_PCI_ENUMERATION
|
||||||
extern void pci_bus_scan_init(void);
|
extern void pci_bus_scan_init(void);
|
||||||
extern int pci_bus_scan(struct pci_dev_info *dev_info);
|
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);
|
void pci_enable_regs(struct pci_dev_info *dev_info);
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_DEBUG
|
#ifdef CONFIG_PCI_DEBUG
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue