All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	u-boot@lists.denx.de
Cc: Simon Glass <sjg@chromium.org>, York Sun <york.sun@nxp.com>,
	Priyanka Jain <priyanka.jain@nxp.com>,
	Sean Anderson <sean.anderson@seco.com>
Subject: [PATCH 4/6] net: fm: Add firmware name parameter
Date: Thu, 24 Mar 2022 14:23:03 -0400	[thread overview]
Message-ID: <20220324182306.2037094-5-sean.anderson@seco.com> (raw)
In-Reply-To: <20220324182306.2037094-1-sean.anderson@seco.com>

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@seco.com>
---

 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.25.1


  parent reply	other threads:[~2022-03-24 18:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-24 18:22 [PATCH 0/6] net: fm: Verify Fman microcode Sean Anderson
2022-03-24 18:23 ` [PATCH 1/6] ARMv8/sec_firmware: Remove SEC_FIRMWARE_FIT_CNF_NAME Sean Anderson
2022-03-24 18:23 ` [PATCH 2/6] image: fit: Add some helpers for getting data Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-03-28 15:33     ` Sean Anderson
2022-03-24 18:23 ` [PATCH 3/6] misc: fs_loader: Add function to get the chosen loader Sean Anderson
2022-03-28  6:35   ` Simon Glass
2022-03-24 18:23 ` Sean Anderson [this message]
2022-03-24 18:23 ` [PATCH 5/6] net: fm: Support loading firmware from a filesystem Sean Anderson
2022-03-24 18:23 ` [PATCH 6/6] net: fm: Add support for FIT firmware Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220324182306.2037094-5-sean.anderson@seco.com \
    --to=sean.anderson@seco.com \
    --cc=joe.hershberger@ni.com \
    --cc=priyanka.jain@nxp.com \
    --cc=rfried.dev@gmail.com \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=york.sun@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.