[RESEND PATCH v2 2/3] net: fm: Add firmware name parameter

Sean Anderson sean.anderson at seco.com
Fri Apr 22 19:30:31 CEST 2022


In order to read the firmware from the filesystem, we need a file name.
Read the firmware name from the device tree, using the firmware-name
property. This property is commonly used in Linux to determine the
correct name to use (and can be seen in several device trees in U-Boot).

Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---

(no changes since v1)

 drivers/net/fm/fm.c   | 15 ++++++++++++---
 drivers/net/fm/fm.h   |  2 +-
 drivers/net/fm/init.c |  4 ++--
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c
index f825612640..aa0cc69232 100644
--- a/drivers/net/fm/fm.c
+++ b/drivers/net/fm/fm.c
@@ -7,6 +7,7 @@
 #include <env.h>
 #include <malloc.h>
 #include <asm/io.h>
+#include <dm/device_compat.h>
 #include <linux/errno.h>
 #include <u-boot/crc.h>
 #ifdef CONFIG_DM_ETH
@@ -354,7 +355,7 @@ static void fm_init_qmi(struct fm_qmi_common *qmi)
 
 /* Init common part of FM, index is fm num# like fm as above */
 #ifdef CONFIG_TFABOOT
-int fm_init_common(int index, struct ccsr_fman *reg)
+int fm_init_common(int index, struct ccsr_fman *reg, const char *firmware_name)
 {
 	int rc;
 	void *addr = NULL;
@@ -449,7 +450,7 @@ int fm_init_common(int index, struct ccsr_fman *reg)
 	return fm_init_bmi(index, &reg->fm_bmi_common);
 }
 #else
-int fm_init_common(int index, struct ccsr_fman *reg)
+int fm_init_common(int index, struct ccsr_fman *reg, const char *firmware_name)
 {
 	int rc;
 #if defined(CONFIG_SYS_QE_FMAN_FW_IN_NOR)
@@ -546,6 +547,8 @@ static const struct udevice_id fman_ids[] = {
 
 static int fman_probe(struct udevice *dev)
 {
+	const char *firmware_name = NULL;
+	int ret;
 	struct fman_priv *priv = dev_get_priv(dev);
 
 	priv->reg = (struct ccsr_fman *)(uintptr_t)dev_read_addr(dev);
@@ -555,7 +558,13 @@ static int fman_probe(struct udevice *dev)
 		return -EINVAL;
 	}
 
-	return fm_init_common(priv->fman_id, priv->reg);
+	ret = dev_read_string_index(dev, "firmware-name", 0, &firmware_name);
+	if (ret && ret != -EINVAL) {
+		dev_dbg(dev, "Could not read firmware-name\n");
+		return ret;
+	}
+
+	return fm_init_common(priv->fman_id, priv->reg, firmware_name);
 }
 
 static int fman_remove(struct udevice *dev)
diff --git a/drivers/net/fm/fm.h b/drivers/net/fm/fm.h
index 2379b3a11c..32de5cf2b6 100644
--- a/drivers/net/fm/fm.h
+++ b/drivers/net/fm/fm.h
@@ -108,7 +108,7 @@ struct fm_port_global_pram {
 
 void *fm_muram_alloc(int fm_idx, size_t size, ulong align);
 void *fm_muram_base(int fm_idx);
-int fm_init_common(int index, struct ccsr_fman *reg);
+int fm_init_common(int index, struct ccsr_fman *reg, const char *firmware_name);
 int fm_eth_initialize(struct ccsr_fman *reg, struct fm_eth_info *info);
 phy_interface_t fman_port_enet_if(enum fm_port port);
 void fman_disable_port(enum fm_port port);
diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c
index 2fed64205c..a9a20931a1 100644
--- a/drivers/net/fm/init.c
+++ b/drivers/net/fm/init.c
@@ -93,7 +93,7 @@ int fm_standard_init(struct bd_info *bis)
 	struct ccsr_fman *reg;
 
 	reg = (void *)CONFIG_SYS_FSL_FM1_ADDR;
-	if (fm_init_common(0, reg))
+	if (fm_init_common(0, reg, NULL))
 		return 0;
 
 	for (i = 0; i < ARRAY_SIZE(fm_info); i++) {
@@ -103,7 +103,7 @@ int fm_standard_init(struct bd_info *bis)
 
 #if (CONFIG_SYS_NUM_FMAN == 2)
 	reg = (void *)CONFIG_SYS_FSL_FM2_ADDR;
-	if (fm_init_common(1, reg))
+	if (fm_init_common(1, reg, NULL))
 		return 0;
 
 	for (i = 0; i < ARRAY_SIZE(fm_info); i++) {
-- 
2.35.1.1320.gc452695387.dirty



More information about the U-Boot mailing list