Skip to contentSkip to conversation

net: pfe_eth: Use spi_flash_read API to access flash memory

PATCH Superseded Kuldeep Singh 2 participants 5 messages Jan 8, 2020 – Jan 13, 2020 Network drivers

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: pfe_eth: Use spi_flash_read API to access flash memory

Current PFE firmware access spi-nor memory directly. New spi-mem framework does not support direct memory access. So, let's use spi_flash_read API to access memory instead of directly using it.

---
v3:
-Replace ret with 0 if flash probe fails
v2:
-Add return error code
-Some changes in displayed log

 drivers/net/pfe_eth/pfe_firmware.c | 45 +++++++++++++++++++++++++++++++++++++-
 include/configs/ls1012a_common.h   |  5 ++++-
 2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/pfe_eth/pfe_firmware.c +44 -1
index e4563f1..6145f4e 100644
@@ -12,13 +12,14 @@
 
 #include <net/pfe_eth/pfe_eth.h>
 #include <net/pfe_eth/pfe_firmware.h>
+#include <spi_flash.h>
 #ifdef CONFIG_CHAIN_OF_TRUST
 #include <fsl_validate.h>
 #endif
 
 #define PFE_FIRMWARE_FIT_CNF_NAME	"config at 1"
 
-static const void *pfe_fit_addr = (void *)CONFIG_SYS_LS_PFE_FW_ADDR;
+static const void *pfe_fit_addr;
 
 /*
  * PFE elf firmware loader.
@@ -159,6 +160,44 @@ static int pfe_fit_check(void)
 	return ret;
 }
 
+int pfe_spi_flash_init(void)
+{
+	struct spi_flash *pfe_flash;
+	int ret = 0;
+	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+
+#ifdef CONFIG_DM_SPI_FLASH
+	struct udevice *new;
+
+	/* speed and mode will be read from DT */
+	ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,
+				     CONFIG_ENV_SPI_CS, 0, 0, &new);
+
+	pfe_flash = dev_get_uclass_priv(new);
+#else
+	pfe_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
+				    CONFIG_ENV_SPI_CS,
+				    CONFIG_ENV_SPI_MAX_HZ,
+				    CONFIG_ENV_SPI_MODE);
+#endif
+	if (!pfe_flash) {
+		printf("SF: probe for pfe failed\n");
+		return 0;
+	}
+
+	ret = spi_flash_read(pfe_flash,
+			     CONFIG_SYS_LS_PFE_FW_ADDR,
+			     CONFIG_SYS_QE_FMAN_FW_LENGTH,
+			     addr);
+	if (ret)
+		printf("SF: read for pfe failed\n");
+
+	pfe_fit_addr = addr;
+	spi_flash_free(pfe_flash);
+
+	return ret;
+}
+
 /*
  * PFE firmware initialization.
  * Loads different firmware files from FIT image.
@@ -183,6 +222,10 @@ int pfe_firmware_init(void)
 	int ret = 0;
 	int fw_count;
 
+	ret = pfe_spi_flash_init();
+	if (ret)
+		goto err;
+
 	ret = pfe_fit_check();
 	if (ret)
 		goto err;
include/configs/ls1012a_common.h +4 -1
index 2579e2f..cbc5bff 100644
@@ -36,9 +36,12 @@
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 128 * 1024)
 
+/* PFE */
+#define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH	0x10000
+
 /*SPI device */
 #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_TFABOOT)
-#define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
 #define CONFIG_SPI_FLASH_SPANSION
 #define CONFIG_FSL_SPI_INTERFACE
 #define CONFIG_SF_DATAFLASH
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 53 lines · Kuldeep Singh

Current PFE firmware access spi-nor memory directly. New spi-mem framework does not support direct memory access. So, let's use spi_flash_read API to access memory instead of directly using it.

---
v3:
-Replace ret with 0 if flash probe fails
v2:

(quoted diff) +0 -2
-Add return error code
-Some changes in displayed log
 
  drivers/net/pfe_eth/pfe_firmware.c | 45 +++++++++++++++++++++++++++++++++++++-
  include/configs/ls1012a_common.h   |  5 ++++-
  2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/pfe_eth/pfe_firmware.c +15 -1
index e4563f1..6145f4e 100644
@@ -12,13 +12,14 @@
 
  #include <net/pfe_eth/pfe_eth.h>
  #include <net/pfe_eth/pfe_firmware.h>
+#include <spi_flash.h>
  #ifdef CONFIG_CHAIN_OF_TRUST
  #include <fsl_validate.h>
  #endif
 
  #define PFE_FIRMWARE_FIT_CNF_NAME	"config at 1"
 
-static const void *pfe_fit_addr = (void *)CONFIG_SYS_LS_PFE_FW_ADDR;
+static const void *pfe_fit_addr;
 
  /*
   * PFE elf firmware loader.
@@ -159,6 +160,44 @@ static int pfe_fit_check(void)
  	return ret;
  }
 
+int pfe_spi_flash_init(void)
+{
+	struct spi_flash *pfe_flash;
+	int ret = 0;
+	void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+
+#ifdef CONFIG_DM_SPI_FLASH
+	struct udevice *new;
+
+	/* speed and mode will be read from DT */
+	ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,
+				     CONFIG_ENV_SPI_CS, 0, 0, &new);
+

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 185

Quoted 10 lines
drivers/net/pfe_eth/pfe_firmware.c +10 -0
+	pfe_flash = dev_get_uclass_priv(new);
+#else
+	pfe_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
+				    CONFIG_ENV_SPI_CS,
+				    CONFIG_ENV_SPI_MAX_HZ,
+				    CONFIG_ENV_SPI_MODE);
+#endif
+	if (!pfe_flash) {
+		printf("SF: probe for pfe failed\n");
+		return 0;

No again. It seems like you're not getting what I'm trying to tell you, so it would be better to just ask back instead of posting new versions.

pfe_spi_flash_init() should return an error code in case the probe of the SPI flash failed. An error code is a negative value like for example -ENODEV to report that the device is not available to the calling function.

Quoted 48 lines
drivers/net/pfe_eth/pfe_firmware.c +19 -0
+	}
+
+	ret = spi_flash_read(pfe_flash,
+			     CONFIG_SYS_LS_PFE_FW_ADDR,
+			     CONFIG_SYS_QE_FMAN_FW_LENGTH,
+			     addr);
+	if (ret)
+		printf("SF: read for pfe failed\n");
+
+	pfe_fit_addr = addr;
+	spi_flash_free(pfe_flash);
+
+	return ret;
+}
+
  /*
   * PFE firmware initialization.
   * Loads different firmware files from FIT image.
@@ -183,6 +222,10 @@ int pfe_firmware_init(void)
  	int ret = 0;
  	int fw_count;
 
+	ret = pfe_spi_flash_init();
+	if (ret)
+		goto err;
+
  	ret = pfe_fit_check();
  	if (ret)
  		goto err;
include/configs/ls1012a_common.h +4 -1
index 2579e2f..cbc5bff 100644
@@ -36,9 +36,12 @@
  /* Size of malloc() pool */
  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 128 * 1024)
 
+/* PFE */
+#define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH	0x10000
+
  /*SPI device */
  #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_TFABOOT)
-#define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
  #define CONFIG_SPI_FLASH_SPANSION
  #define CONFIG_FSL_SPI_INTERFACE
  #define CONFIG_SF_DATAFLASH
#2 lore raw

Hi Frieder,

Quoted 79 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Wednesday, January 8, 2020 2:52 PM
To: Kuldeep Singh <[email protected]>; u-boot at lists.denx.de
Cc: Joe Hershberger <[email protected]>; Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>
Subject: [EXT] Re: [Patch v3] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Review

Quoted 13 lines · Kuldeep Singh

Current PFE firmware access spi-nor memory directly. New spi-mem framework does not support direct memory access. So, let's use spi_flash_read API to access memory instead of directly using it.

---
v3:
-Replace ret with 0 if flash probe fails
v2:

(quoted diff) +0 -2
-Add return error code
-Some changes in displayed log
 
  drivers/net/pfe_eth/pfe_firmware.c | 45

+++++++++++++++++++++++++++++++++++++-

Quoted 39 lines
  include/configs/ls1012a_common.h   |  5 ++++-
  2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/pfe_eth/pfe_firmware.c +13 -1
index e4563f1..6145f4e 100644
@@ -12,13 +12,14 @@
 
  #include <net/pfe_eth/pfe_eth.h>
  #include <net/pfe_eth/pfe_firmware.h>
+#include <spi_flash.h>
  #ifdef CONFIG_CHAIN_OF_TRUST
  #include <fsl_validate.h>
  #endif
 
  #define PFE_FIRMWARE_FIT_CNF_NAME   "config at 1"
 
-static const void *pfe_fit_addr = (void *)CONFIG_SYS_LS_PFE_FW_ADDR;
+static const void *pfe_fit_addr;
 
  /*
   * PFE elf firmware loader.
@@ -159,6 +160,44 @@ static int pfe_fit_check(void)
      return ret;
  }
 
+int pfe_spi_flash_init(void)
+{
+     struct spi_flash *pfe_flash;
+     int ret = 0;
+     void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+
+#ifdef CONFIG_DM_SPI_FLASH
+     struct udevice *new;
+
+     /* speed and mode will be read from DT */
+     ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 183

Quoted 10 lines
drivers/net/pfe_eth/pfe_firmware.c +10 -0
+                                  CONFIG_ENV_SPI_CS, 0, 0, &new);
+
+     pfe_flash = dev_get_uclass_priv(new); #else
+     pfe_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
+                                 CONFIG_ENV_SPI_CS,
+                                 CONFIG_ENV_SPI_MAX_HZ,
+                                 CONFIG_ENV_SPI_MODE); #endif
+     if (!pfe_flash) {
+             printf("SF: probe for pfe failed\n");
+             return 0;

No again. It seems like you're not getting what I'm trying to tell you, so it would be better to just ask back instead of posting new versions.

Quoted 3 lines

pfe_spi_flash_init() should return an error code in case the probe of the SPI flash failed. An error code is a negative value like for example -ENODEV to report that the device is not available to the calling function.

Thanks Frieder for providing the info.
I will return -ENODEV here instead of 0.

Quoted 9 lines

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 193

Quoted 9 lines
drivers/net/pfe_eth/pfe_firmware.c +8 -0
+     }
+
+     ret = spi_flash_read(pfe_flash,
+                          CONFIG_SYS_LS_PFE_FW_ADDR,
+                          CONFIG_SYS_QE_FMAN_FW_LENGTH,
+                          addr);
+     if (ret)
+             printf("SF: read for pfe failed\n");

I think -EIO should also be returned here as pfe functionality will fail if data is not read. Please confirm the same if error code is correct/required. I will update this in next version.

Thanks
Kuldeep

Quoted 42 lines
Quoted 27 lines
drivers/net/pfe_eth/pfe_firmware.c +11 -0
+
+     pfe_fit_addr = addr;
+     spi_flash_free(pfe_flash);
+
+     return ret;
+}
+
  /*
   * PFE firmware initialization.
   * Loads different firmware files from FIT image.
@@ -183,6 +222,10 @@ int pfe_firmware_init(void)
      int ret = 0;
      int fw_count;
 
+     ret = pfe_spi_flash_init();
+     if (ret)
+             goto err;
+
      ret = pfe_fit_check();
      if (ret)
              goto err;
include/configs/ls1012a_common.h +0 -0
index 2579e2f..cbc5bff 100644

include/configs/ls1012a_common.h line 37

Quoted 2 lines
include/configs/ls1012a_common.h +0 -0
@@ -36,9 +36,12 @@
  /* Size of malloc() pool */
  #define CONFIG_SYS_MALLOC_LEN               (CONFIG_ENV_SIZE + 128 *

1024)

Quoted 12 lines
include/configs/ls1012a_common.h +4 -1
+/* PFE */
+#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH 0x10000
+
  /*SPI device */
  #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_TFABOOT)
-#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
  #define CONFIG_SPI_FLASH_SPANSION
  #define CONFIG_FSL_SPI_INTERFACE
  #define CONFIG_SF_DATAFLASH
 
#3 lore raw
Quoted 98 lines · Kuldeep Singh

Hi Frieder,

Quoted 79 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Wednesday, January 8, 2020 2:52 PM
To: Kuldeep Singh <[email protected]>; u-boot at lists.denx.de
Cc: Joe Hershberger <[email protected]>; Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>
Subject: [EXT] Re: [Patch v3] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Review

Quoted 13 lines · Kuldeep Singh

Current PFE firmware access spi-nor memory directly. New spi-mem framework does not support direct memory access. So, let's use spi_flash_read API to access memory instead of directly using it.

---
v3:
-Replace ret with 0 if flash probe fails
v2:

(quoted diff) +0 -2
-Add return error code
-Some changes in displayed log
 
   drivers/net/pfe_eth/pfe_firmware.c | 45

+++++++++++++++++++++++++++++++++++++-

Quoted 39 lines
   include/configs/ls1012a_common.h   |  5 ++++-
   2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/pfe_eth/pfe_firmware.c +13 -1
index e4563f1..6145f4e 100644
@@ -12,13 +12,14 @@
 
   #include <net/pfe_eth/pfe_eth.h>
   #include <net/pfe_eth/pfe_firmware.h>
+#include <spi_flash.h>
   #ifdef CONFIG_CHAIN_OF_TRUST
   #include <fsl_validate.h>
   #endif
 
   #define PFE_FIRMWARE_FIT_CNF_NAME   "config at 1"
 
-static const void *pfe_fit_addr = (void *)CONFIG_SYS_LS_PFE_FW_ADDR;
+static const void *pfe_fit_addr;
 
   /*
    * PFE elf firmware loader.
@@ -159,6 +160,44 @@ static int pfe_fit_check(void)
       return ret;
   }
 
+int pfe_spi_flash_init(void)
+{
+     struct spi_flash *pfe_flash;
+     int ret = 0;
+     void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+
+#ifdef CONFIG_DM_SPI_FLASH
+     struct udevice *new;
+
+     /* speed and mode will be read from DT */
+     ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 183

Quoted 10 lines
drivers/net/pfe_eth/pfe_firmware.c +10 -0
+                                  CONFIG_ENV_SPI_CS, 0, 0, &new);
+
+     pfe_flash = dev_get_uclass_priv(new); #else
+     pfe_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
+                                 CONFIG_ENV_SPI_CS,
+                                 CONFIG_ENV_SPI_MAX_HZ,
+                                 CONFIG_ENV_SPI_MODE); #endif
+     if (!pfe_flash) {
+             printf("SF: probe for pfe failed\n");
+             return 0;

No again. It seems like you're not getting what I'm trying to tell you, so it would be better to just ask back instead of posting new versions.

Quoted 3 lines

pfe_spi_flash_init() should return an error code in case the probe of the SPI flash failed. An error code is a negative value like for example -ENODEV to report that the device is not available to the calling function.

Thanks Frieder for providing the info.
I will return -ENODEV here instead of 0.

Quoted 9 lines

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 193

Quoted 9 lines
drivers/net/pfe_eth/pfe_firmware.c +8 -0
+     }
+
+     ret = spi_flash_read(pfe_flash,
+                          CONFIG_SYS_LS_PFE_FW_ADDR,
+                          CONFIG_SYS_QE_FMAN_FW_LENGTH,
+                          addr);
+     if (ret)
+             printf("SF: read for pfe failed\n");
Quoted 2 lines

I think -EIO should also be returned here as pfe functionality will fail if data is not read. Please confirm the same if error code is correct/required. I will update this in next version.

No, I don't think it's a good idea to return an error code here. You already get an error code back from spi_flash_read() if it fails and you pass this error to the caller at the end of the function, which should be sufficient.

Also returning here would require to add a call to spi_flash_free() first.

Quoted 46 lines

Thanks
Kuldeep

Quoted 42 lines
Quoted 27 lines
drivers/net/pfe_eth/pfe_firmware.c +11 -0
+
+     pfe_fit_addr = addr;
+     spi_flash_free(pfe_flash);
+
+     return ret;
+}
+
   /*
    * PFE firmware initialization.
    * Loads different firmware files from FIT image.
@@ -183,6 +222,10 @@ int pfe_firmware_init(void)
       int ret = 0;
       int fw_count;
 
+     ret = pfe_spi_flash_init();
+     if (ret)
+             goto err;
+
       ret = pfe_fit_check();
       if (ret)
               goto err;
include/configs/ls1012a_common.h +0 -0
index 2579e2f..cbc5bff 100644

include/configs/ls1012a_common.h line 37

Quoted 2 lines
include/configs/ls1012a_common.h +0 -0
@@ -36,9 +36,12 @@
   /* Size of malloc() pool */
   #define CONFIG_SYS_MALLOC_LEN               (CONFIG_ENV_SIZE + 128 *

1024)

Quoted 12 lines
include/configs/ls1012a_common.h +4 -1
+/* PFE */
+#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH 0x10000
+
   /*SPI device */
   #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_TFABOOT)
-#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
   #define CONFIG_SPI_FLASH_SPANSION
   #define CONFIG_FSL_SPI_INTERFACE
   #define CONFIG_SF_DATAFLASH
 
#4 lore raw
Quoted 114 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, January 13, 2020 2:07 PM
To: Kuldeep Singh <[email protected]>; u-boot at lists.denx.de
Cc: Joe Hershberger <[email protected]>; Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>
Subject: Re: [EXT] Re: [Patch v3] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 85 lines · Kuldeep Singh

Hi Frieder,

Quoted 83 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Wednesday, January 8, 2020 2:52 PM
To: Kuldeep Singh <[email protected]>; u-boot at lists.denx.de
Cc: Joe Hershberger <[email protected]>; Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>
Subject: [EXT] Re: [Patch v3] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Review

Quoted 13 lines · Kuldeep Singh

Current PFE firmware access spi-nor memory directly. New spi-mem framework does not support direct memory access. So, let's use spi_flash_read API to access memory instead of directly using it.

---
v3:
-Replace ret with 0 if flash probe fails
v2:

(quoted diff) +0 -2
-Add return error code
-Some changes in displayed log
 
   drivers/net/pfe_eth/pfe_firmware.c | 45

+++++++++++++++++++++++++++++++++++++-

Quoted 40 lines
   include/configs/ls1012a_common.h   |  5 ++++-
   2 files changed, 48 insertions(+), 2 deletions(-)
drivers/net/pfe_eth/pfe_firmware.c +2 -1
index e4563f1..6145f4e 100644
@@ -12,13 +12,14 @@
 
   #include <net/pfe_eth/pfe_eth.h>
   #include <net/pfe_eth/pfe_firmware.h>
+#include <spi_flash.h>
   #ifdef CONFIG_CHAIN_OF_TRUST
   #include <fsl_validate.h>
   #endif
 
   #define PFE_FIRMWARE_FIT_CNF_NAME   "config at 1"
 
-static const void *pfe_fit_addr = (void
 *)CONFIG_SYS_LS_PFE_FW_ADDR;
+static const void *pfe_fit_addr;
 
   /*

* PFE elf firmware loader.

drivers/net/pfe_eth/pfe_firmware.c +11 -0
@@ -159,6 +160,44 @@ static int pfe_fit_check(void)
       return ret;
   }
 
+int pfe_spi_flash_init(void)
+{
+     struct spi_flash *pfe_flash;
+     int ret = 0;
+     void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+
+#ifdef CONFIG_DM_SPI_FLASH
+     struct udevice *new;
+
+     /* speed and mode will be read from DT */
+     ret = spi_flash_probe_bus_cs(CONFIG_ENV_SPI_BUS,

drivers/net/pfe_eth/pfe_firmware.c static int pfe_fit_check(void) · line 183

Quoted 10 lines
drivers/net/pfe_eth/pfe_firmware.c +10 -0
+                                  CONFIG_ENV_SPI_CS, 0, 0, &new);
+
+     pfe_flash = dev_get_uclass_priv(new); #else
+     pfe_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS,
+                                 CONFIG_ENV_SPI_CS,
+                                 CONFIG_ENV_SPI_MAX_HZ,
+                                 CONFIG_ENV_SPI_MODE); #endif
+     if (!pfe_flash) {
+             printf("SF: probe for pfe failed\n");
+             return 0;

No again. It seems like you're not getting what I'm trying to tell you, so it would be better to just ask back instead of posting new versions.

pfe_spi_flash_init() should return an error code in case the probe of the SPI flash failed. An error code is a negative value like for example -ENODEV to report that the device is not available to the calling

function.

Quoted 14 lines

Thanks Frieder for providing the info.
I will return -ENODEV here instead of 0.

Quoted 9 lines
Quoted 9 lines
drivers/net/pfe_eth/pfe_firmware.c +8 -0
+     }
+
+     ret = spi_flash_read(pfe_flash,
+                          CONFIG_SYS_LS_PFE_FW_ADDR,
+                          CONFIG_SYS_QE_FMAN_FW_LENGTH,
+                          addr);
+     if (ret)
+             printf("SF: read for pfe failed\n");
Quoted 8 lines
Quoted 1 line

I think -EIO should also be returned here as pfe functionality will fail if data

is not read.

Quoted 1 line

Please confirm the same if error code is correct/required. I will update this

in next version.

No, I don't think it's a good idea to return an error code here. You already get an error code back from spi_flash_read() if it fails and you pass this error to the caller at the end of the function, which should be sufficient.

Okay. I will not return error code here.

Thanks
Kuldeep

Quoted 49 lines

Also returning here would require to add a call to spi_flash_free() first.

Quoted 46 lines

Thanks
Kuldeep

Quoted 42 lines
Quoted 27 lines
drivers/net/pfe_eth/pfe_firmware.c +11 -0
+
+     pfe_fit_addr = addr;
+     spi_flash_free(pfe_flash);
+
+     return ret;
+}
+
   /*
    * PFE firmware initialization.
    * Loads different firmware files from FIT image.
@@ -183,6 +222,10 @@ int pfe_firmware_init(void)
       int ret = 0;
       int fw_count;
 
+     ret = pfe_spi_flash_init();
+     if (ret)
+             goto err;
+
       ret = pfe_fit_check();
       if (ret)
               goto err;
include/configs/ls1012a_common.h +0 -0
index 2579e2f..cbc5bff 100644

include/configs/ls1012a_common.h line 37

Quoted 2 lines
include/configs/ls1012a_common.h +0 -0
@@ -36,9 +36,12 @@
   /* Size of malloc() pool */
   #define CONFIG_SYS_MALLOC_LEN               (CONFIG_ENV_SIZE + 128 *

1024)

Quoted 12 lines
include/configs/ls1012a_common.h +4 -1
+/* PFE */
+#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH 0x10000
+
   /*SPI device */
   #if defined(CONFIG_QSPI_BOOT) || defined(CONFIG_TFABOOT)
-#define CONFIG_SYS_FMAN_FW_ADDR              0x400d0000
   #define CONFIG_SPI_FLASH_SPANSION
   #define CONFIG_FSL_SPI_INTERFACE
   #define CONFIG_SF_DATAFLASH