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 <ma...@denx.de>
---
Cc: Alice Guo <alice....@nxp.com>
Cc: Ilias Apalodimas <ilias.apalodi...@linaro.org>
Cc: Jerome Forissier <jerome.foriss...@linaro.org>
Cc: Joe Hershberger <joe.hershber...@ni.com>
Cc: Markus Gothe <markus.go...@genexis.eu>
Cc: Peng Fan <peng....@nxp.com>
Cc: Ramon Fried <rfried....@gmail.com>
Cc: Robert Marko <robert.ma...@sartura.hr>
Cc: Romain Naour <romain.na...@smile.fr>
Cc: Simon Glass <s...@chromium.org>
Cc: Tim Harvey <thar...@gateworks.com>
Cc: Tom Rini <tr...@konsulko.com>
Cc: Ye Li <ye...@nxp.com>
Cc: u-boot@lists.denx.de
---
 drivers/net/fsl_enetc.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index a6b0bafc8c6..d1414167723 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -23,6 +23,15 @@
 
 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);
-- 
2.45.2

Reply via email to