]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
x86: apl: Avoid accessing the PCI bus before it is probed
authorSimon Glass <sjg@chromium.org>
Mon, 30 Dec 2019 04:19:13 +0000 (21:19 -0700)
committerSimon Glass <sjg@chromium.org>
Tue, 7 Jan 2020 23:02:38 +0000 (16:02 -0700)
The PCI bus is not actually probed by the time the ofdata_to_platdata()
method is called since that happens in the uclass's post_probe() method.
Update the PMC and P2SB drivers to access the bus in its probe() method.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/x86/cpu/apollolake/p2sb.c
arch/x86/cpu/apollolake/pmc.c

index eb27861b7a467f887c3b1227ff72abe5599fea35..b72f50a6274dc17ff9e1df4ebc3ba49d2a191dcf 100644 (file)
@@ -106,11 +106,6 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev)
                if (plat->bdf < 0)
                        return log_msg_ret("Cannot get p2sb PCI address",
                                           plat->bdf);
-       } else {
-               plat->mmio_base = dev_read_addr_pci(dev);
-               /* Don't set BDF since it should not be used */
-               if (!plat->mmio_base || plat->mmio_base == FDT_ADDR_T_NONE)
-                       return -EINVAL;
        }
 #else
        plat->mmio_base = plat->dtplat.early_regs[0];
@@ -124,10 +119,19 @@ int apl_p2sb_ofdata_to_platdata(struct udevice *dev)
 
 static int apl_p2sb_probe(struct udevice *dev)
 {
-       if (spl_phase() == PHASE_TPL)
+       if (spl_phase() == PHASE_TPL) {
                return apl_p2sb_early_init(dev);
-       else if (spl_phase() == PHASE_SPL)
-               return apl_p2sb_spl_init(dev);
+       } else {
+               struct p2sb_platdata *plat = dev_get_platdata(dev);
+
+               plat->mmio_base = dev_read_addr_pci(dev);
+               /* Don't set BDF since it should not be used */
+               if (!plat->mmio_base || plat->mmio_base == FDT_ADDR_T_NONE)
+                       return -EINVAL;
+
+               if (spl_phase() == PHASE_SPL)
+                       return apl_p2sb_spl_init(dev);
+       }
 
        return 0;
 }
index 683c6082f2c3b9129019adf23b60686c35a8988a..aec0c8394c2e5b708e1fdcd6d09b9d4ef2d4d486 100644 (file)
@@ -119,8 +119,16 @@ int apl_pmc_ofdata_to_uc_platdata(struct udevice *dev)
        ret = dev_read_u32_array(dev, "early-regs", base, ARRAY_SIZE(base));
        if (ret)
                return log_msg_ret("Missing/short early-regs", ret);
-       upriv->pmc_bar0 = (void *)base[0];
-       upriv->pmc_bar2 = (void *)base[2];
+       if (spl_phase() == PHASE_TPL) {
+               upriv->pmc_bar0 = (void *)base[0];
+               upriv->pmc_bar2 = (void *)base[2];
+
+               /* Since PCI is not enabled, we must get the BDF manually */
+               plat->bdf = pci_get_devfn(dev);
+               if (plat->bdf < 0)
+                       return log_msg_ret("Cannot get PMC PCI address",
+                                          plat->bdf);
+       }
        upriv->acpi_base = base[4];
 
        /* Since PCI is not enabled, we must get the BDF manually */
@@ -187,8 +195,14 @@ static int enable_pmcbar(struct udevice *dev)
 
 static int apl_pmc_probe(struct udevice *dev)
 {
-       if (spl_phase() == PHASE_TPL)
+       if (spl_phase() == PHASE_TPL) {
                return enable_pmcbar(dev);
+       } else {
+               struct acpi_pmc_upriv *upriv = dev_get_uclass_priv(dev);
+
+               upriv->pmc_bar0 = (void *)dm_pci_read_bar32(dev, 0);
+               upriv->pmc_bar2 = (void *)dm_pci_read_bar32(dev, 2);
+       }
 
        return 0;
 }