]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: fsl_enetc: Introduce enetc_is_ls1028a()
authorMarek Vasut <marex@denx.de>
Thu, 16 Jan 2025 04:03:18 +0000 (05:03 +0100)
committerFabio Estevam <festevam@gmail.com>
Mon, 20 Jan 2025 11:40:39 +0000 (08:40 -0300)
Introduce accurate test for LS1028A compatibility based both on
IS_ENABLED(CONFIG_ARCH_LS1028A) and PCI vendor ID. This is done
in preparation for adding ENETCv4 support, which has a different
PCI vendor ID.

Signed-off-by: Marek Vasut <marex@denx.de>
drivers/net/fsl_enetc.c

index a6b0bafc8c60dea8f343ebcf08e93e27db0da083..d1414167723654483f07bd8050f3457511083b70 100644 (file)
 
 static int enetc_remove(struct udevice *dev);
 
+static int enetc_is_ls1028a(struct udevice *dev)
+{
+       struct pci_child_plat *pplat = dev_get_parent_plat(dev);
+
+       /* Test whether this is LS1028A ENETC. This may be optimized out. */
+       return IS_ENABLED(CONFIG_ARCH_LS1028A) &&
+              pplat->vendor == PCI_VENDOR_ID_FREESCALE;
+}
+
 /*
  * sets the MAC address in IERB registers, this setting is persistent and
  * carried over to Linux.
@@ -416,7 +425,7 @@ static int enetc_write_hwaddr(struct udevice *dev)
        struct enetc_priv *priv = dev_get_priv(dev);
        u8 *addr = plat->enetaddr;
 
-       if (IS_ENABLED(CONFIG_ARCH_LS1028A))
+       if (enetc_is_ls1028a(dev))
                return enetc_ls1028a_write_hwaddr(dev);
 
        u16 lower = *(const u16 *)(addr + 4);