device: Use pcidev_on_root()
Change-Id: Icf34b39d80f6e46d32a39b68f38fb2752c0bcebc
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Signed-off-by: Elyes HAOUAS <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/26484
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Piotr Król <piotr.krol@3mdeb.com>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/src/soc/intel/baytrail/pmutil.c b/src/soc/intel/baytrail/pmutil.c
index 06751f1..be870fc 100644
--- a/src/soc/intel/baytrail/pmutil.c
+++ b/src/soc/intel/baytrail/pmutil.c
@@ -43,7 +43,7 @@
static struct device *get_pcu_dev(void)
{
if (pcu_dev == NULL)
- pcu_dev = dev_find_slot(0, PCI_DEVFN(PCU_DEV, 0));
+ pcu_dev = pcidev_on_root(PCU_DEV, 0);
return pcu_dev;
}
#endif
diff --git a/src/soc/intel/baytrail/ramstage.c b/src/soc/intel/baytrail/ramstage.c
index e9925a2..1715198 100644
--- a/src/soc/intel/baytrail/ramstage.c
+++ b/src/soc/intel/baytrail/ramstage.c
@@ -80,7 +80,7 @@
struct pattrs *attrs = (struct pattrs *)pattrs_get();
attrs->cpuid = cpuid_eax(1);
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
attrs->revid = pci_read_config8(dev, REVID);
/* The revision to stepping IDs have two values per metal stepping. */
if (attrs->revid >= RID_D_STEPPING_START) {
diff --git a/src/soc/intel/baytrail/romstage/pmc.c b/src/soc/intel/baytrail/romstage/pmc.c
index b47f7df..e77d00d 100644
--- a/src/soc/intel/baytrail/romstage/pmc.c
+++ b/src/soc/intel/baytrail/romstage/pmc.c
@@ -44,7 +44,7 @@
const struct soc_intel_baytrail_config *cfg = NULL;
rid = pci_read_config8(IOSF_PCI_DEV, REVID);
- dev = dev_find_slot(0, PCI_DEVFN(SOC_DEV, SOC_FUNC));
+ dev = pcidev_on_root(SOC_DEV, SOC_FUNC);
if (dev)
cfg = dev->chip_info;
diff --git a/src/soc/intel/baytrail/spi.c b/src/soc/intel/baytrail/spi.c
index d893816..81e118c 100644
--- a/src/soc/intel/baytrail/spi.c
+++ b/src/soc/intel/baytrail/spi.c
@@ -267,7 +267,7 @@
#ifdef __SMM__
pci_devfn_t dev = PCI_DEV(0, LPC_DEV, LPC_FUNC);
#else
- struct device *dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
#endif
pci_read_config_dword(dev, SBASE, &sbase);
sbase &= ~0x1ff;
diff --git a/src/soc/intel/braswell/chip.c b/src/soc/intel/braswell/chip.c
index ccd6c9f..7a63b5b 100644
--- a/src/soc/intel/braswell/chip.c
+++ b/src/soc/intel/braswell/chip.c
@@ -86,7 +86,7 @@
void soc_silicon_init_params(SILICON_INIT_UPD *params)
{
- struct device *dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
struct soc_intel_braswell_config *config;
if (!dev) {
@@ -406,7 +406,7 @@
**/
int SocStepping(void)
{
- struct device *dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
u8 revid = pci_read_config8(dev, 0x8);
switch (revid & B_PCH_LPC_RID_STEPPING_MASK) {
diff --git a/src/soc/intel/braswell/pmutil.c b/src/soc/intel/braswell/pmutil.c
index 85384a61..8dbb4992 100644
--- a/src/soc/intel/braswell/pmutil.c
+++ b/src/soc/intel/braswell/pmutil.c
@@ -44,7 +44,7 @@
static struct device *get_pcu_dev(void)
{
if (pcu_dev == NULL)
- pcu_dev = dev_find_slot(0, PCI_DEVFN(PCU_DEV, 0));
+ pcu_dev = pcidev_on_root(PCU_DEV, 0);
return pcu_dev;
}
#endif /* ENV_SMM */
diff --git a/src/soc/intel/braswell/ramstage.c b/src/soc/intel/braswell/ramstage.c
index a12db80..b8362cd 100644
--- a/src/soc/intel/braswell/ramstage.c
+++ b/src/soc/intel/braswell/ramstage.c
@@ -84,7 +84,7 @@
struct pattrs *attrs = (struct pattrs *)pattrs_get();
attrs->cpuid = cpuid_eax(1);
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
attrs->revid = pci_read_config8(dev, REVID);
/* The revision to stepping IDs have two values per metal stepping. */
if (attrs->revid >= RID_D_STEPPING_START) {
diff --git a/src/soc/intel/braswell/romstage/romstage.c b/src/soc/intel/braswell/romstage/romstage.c
index 14eaa6b..9b9a0eb 100644
--- a/src/soc/intel/braswell/romstage/romstage.c
+++ b/src/soc/intel/braswell/romstage/romstage.c
@@ -216,7 +216,7 @@
const struct soc_intel_braswell_config *config;
/* Set the parameters for MemoryInit */
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
if (!dev) {
printk(BIOS_ERR,
diff --git a/src/soc/intel/braswell/spi.c b/src/soc/intel/braswell/spi.c
index a5f835d5..988832d 100644
--- a/src/soc/intel/braswell/spi.c
+++ b/src/soc/intel/braswell/spi.c
@@ -236,7 +236,7 @@
#if ENV_SMM
pci_devfn_t dev = PCI_DEV(0, LPC_DEV, LPC_FUNC);
#else
- struct device *dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
#endif
if (!dev) {
printk(BIOS_ERR, "%s: PCI device not found", __func__);
diff --git a/src/soc/intel/common/block/lpc/lpc_lib.c b/src/soc/intel/common/block/lpc/lpc_lib.c
index 2fe5b39..fb50b74 100644
--- a/src/soc/intel/common/block/lpc/lpc_lib.c
+++ b/src/soc/intel/common/block/lpc/lpc_lib.c
@@ -265,7 +265,7 @@
{
const struct device *dev;
- dev = dev_find_slot(0, PCI_DEVFN(PCH_DEV_SLOT_LPC, 0));
+ dev = pcidev_on_root(PCH_DEV_SLOT_LPC, 0);
if (!dev || !dev->chip_info)
return;
@@ -278,7 +278,7 @@
const struct device *dev;
uint32_t gen_io_dec[LPC_NUM_GENERIC_IO_RANGES];
- dev = dev_find_slot(0, PCI_DEVFN(PCH_DEV_SLOT_LPC, 0));
+ dev = pcidev_on_root(PCH_DEV_SLOT_LPC, 0);
if (!dev || !dev->chip_info)
return;
diff --git a/src/soc/intel/fsp_baytrail/i2c.c b/src/soc/intel/fsp_baytrail/i2c.c
index 95761f3..22e565f 100644
--- a/src/soc/intel/fsp_baytrail/i2c.c
+++ b/src/soc/intel/fsp_baytrail/i2c.c
@@ -114,7 +114,7 @@
base_ptr = (char*)base_adr[bus];
/* Set the I2C-device the user wants to use */
- dev = dev_find_slot(0, PCI_DEVFN(I2C1_DEV, bus + 1));
+ dev = pcidev_on_root(I2C1_DEV, bus + 1);
/* Ensure we have the right PCI device */
if ((pci_read_config16(dev, 0x0) != I2C_PCI_VENDOR_ID) ||
@@ -171,7 +171,7 @@
int stat;
/* Get base address of desired I2C-controller */
- dev = dev_find_slot(0, PCI_DEVFN(I2C1_DEV, bus + 1));
+ dev = pcidev_on_root(I2C1_DEV, bus + 1);
base_ptr = (char *)pci_read_config32(dev, PCI_BASE_ADDRESS_0);
if (base_ptr == NULL) {
printk(BIOS_INFO, "I2C: Invalid Base address\n");
@@ -230,7 +230,7 @@
int stat;
/* Get base address of desired I2C-controller */
- dev = dev_find_slot(0, PCI_DEVFN(I2C1_DEV, bus + 1));
+ dev = pcidev_on_root(I2C1_DEV, bus + 1);
base_ptr = (char *)pci_read_config32(dev, PCI_BASE_ADDRESS_0);
if (base_ptr == NULL) {
return I2C_ERR_INVALID_ADR;
diff --git a/src/soc/intel/fsp_baytrail/northcluster.c b/src/soc/intel/fsp_baytrail/northcluster.c
index 93cd2f2..416746d 100644
--- a/src/soc/intel/fsp_baytrail/northcluster.c
+++ b/src/soc/intel/fsp_baytrail/northcluster.c
@@ -92,7 +92,7 @@
*base = 0;
- dev = dev_find_slot(0, PCI_DEVFN(0, 0));
+ dev = pcidev_on_root(0, 0);
if (!dev)
return 0;
diff --git a/src/soc/intel/fsp_baytrail/pmutil.c b/src/soc/intel/fsp_baytrail/pmutil.c
index 402842e..6e4a7c8 100644
--- a/src/soc/intel/fsp_baytrail/pmutil.c
+++ b/src/soc/intel/fsp_baytrail/pmutil.c
@@ -41,7 +41,7 @@
static struct device *get_pcu_dev(void)
{
if (pcu_dev == NULL)
- pcu_dev = dev_find_slot(0, PCI_DEVFN(PCU_DEV, 0));
+ pcu_dev = pcidev_on_root(PCU_DEV, 0);
return pcu_dev;
}
#endif
diff --git a/src/soc/intel/fsp_baytrail/ramstage.c b/src/soc/intel/fsp_baytrail/ramstage.c
index f4cdaa8..754c5f5 100644
--- a/src/soc/intel/fsp_baytrail/ramstage.c
+++ b/src/soc/intel/fsp_baytrail/ramstage.c
@@ -78,7 +78,7 @@
struct pattrs *attrs = (struct pattrs *)pattrs_get();
attrs->cpuid = cpuid_eax(1);
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
attrs->revid = pci_read_config8(dev, REVID);
/* The revision to stepping IDs have two values per metal stepping. */
if (attrs->revid >= RID_D_STEPPING_START) {
diff --git a/src/soc/intel/fsp_baytrail/spi.c b/src/soc/intel/fsp_baytrail/spi.c
index 4537bcc..41d5150 100644
--- a/src/soc/intel/fsp_baytrail/spi.c
+++ b/src/soc/intel/fsp_baytrail/spi.c
@@ -254,11 +254,9 @@
uint32_t sbase;
#ifdef __SMM__
- pci_devfn_t dev;
- dev = PCI_DEV(0, LPC_DEV, LPC_FUNC);
+ pci_devfn_t dev = PCI_DEV(0, LPC_DEV, LPC_FUNC);
#else
- struct device *dev;
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
#endif
pci_read_config_dword(dev, SBASE, &sbase);
sbase &= ~0x1ff;
diff --git a/src/soc/intel/fsp_broadwell_de/acpi.c b/src/soc/intel/fsp_broadwell_de/acpi.c
index ad88313..0b07ea8 100644
--- a/src/soc/intel/fsp_broadwell_de/acpi.c
+++ b/src/soc/intel/fsp_broadwell_de/acpi.c
@@ -81,7 +81,7 @@
{
uint8_t actl = 0;
static uint8_t sci_irq = 0;
- struct device *dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ struct device *dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
/* If this function was already called, just return the stored value. */
if (sci_irq)
diff --git a/src/soc/intel/fsp_broadwell_de/ramstage.c b/src/soc/intel/fsp_broadwell_de/ramstage.c
index 7b94268..492378e 100644
--- a/src/soc/intel/fsp_broadwell_de/ramstage.c
+++ b/src/soc/intel/fsp_broadwell_de/ramstage.c
@@ -62,7 +62,7 @@
attrs->cpuid = cpuid_eax(1);
attrs->stepping = (attrs->cpuid & 0x0F) - 1;
- dev = dev_find_slot(0, PCI_DEVFN(LPC_DEV, LPC_FUNC));
+ dev = pcidev_on_root(LPC_DEV, LPC_FUNC);
attrs->revid = pci_read_config8(dev, REVID);
attrs->microcode_patch = intel_microcode_find();
attrs->address_bits = cpuid_eax(0x80000008) & 0xff;
diff --git a/src/soc/intel/quark/acpi.c b/src/soc/intel/quark/acpi.c
index 960b53f..83bed34 100644
--- a/src/soc/intel/quark/acpi.c
+++ b/src/soc/intel/quark/acpi.c
@@ -31,9 +31,8 @@
void acpi_fill_in_fadt(acpi_fadt_t *fadt)
{
- struct device *dev = dev_find_slot(0,
- PCI_DEVFN(PCI_DEVICE_NUMBER_QNC_LPC,
- PCI_FUNCTION_NUMBER_QNC_LPC));
+ struct device *dev = pcidev_on_root(PCI_DEVICE_NUMBER_QNC_LPC,
+ PCI_FUNCTION_NUMBER_QNC_LPC);
uint32_t gpe0_base = pci_read_config32(dev, R_QNC_LPC_GPE0BLK)
& B_QNC_LPC_GPE0BLK_MASK;
uint32_t pmbase = pci_read_config32(dev, R_QNC_LPC_PM1BLK)