[PATCH 01/13] net: fsl_enetc: Introduce enetc_is_ls1028a()

Marek Vasut marex at denx.de
Thu Jan 16 05:03:18 CET 2025


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 at denx.de>
---
Cc: Alice Guo <alice.guo at nxp.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Cc: Jerome Forissier <jerome.forissier at linaro.org>
Cc: Joe Hershberger <joe.hershberger at ni.com>
Cc: Markus Gothe <markus.gothe at genexis.eu>
Cc: Peng Fan <peng.fan at nxp.com>
Cc: Ramon Fried <rfried.dev at gmail.com>
Cc: Robert Marko <robert.marko at sartura.hr>
Cc: Romain Naour <romain.naour at smile.fr>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tim Harvey <tharvey at gateworks.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: Ye Li <ye.li at nxp.com>
Cc: u-boot at 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



More information about the U-Boot mailing list