Skip to contentSkip to conversation

net: pfe_eth: Use spi_flash_read API to access flash memory

PATCH RESEND New Kuldeep Singh 4 participants 7 messages May 28, 2020 – Jun 22, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v4 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.

---
v4:
-Rebase to top
-Use complete firmware size
-Return -ENODEV if flash probe fails
v3:
-Replace ret with 0 if flash probe fails
v2:
-Add return error code
-Changes in displayed error 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 0493cfe..55e661c 100644
@@ -16,13 +16,14 @@
 #include <linux/bitops.h>
 #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.
@@ -163,6 +164,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 -ENODEV;
+	}
+
+	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.
@@ -187,6 +226,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 3bea9a9..06af8bf 100644
@@ -36,8 +36,11 @@
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 1024 * 1024)
 
-/*SPI device */
+/* PFE */
 #define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH	0x300000
+
+/*SPI device */
 #define CONFIG_SYS_FSL_QSPI_BASE	0x40000000
 
 /* SATA */
Signature · 1 line
2.7.4
#1 lore raw

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

Quoted 6 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.

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being applied too.

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong here.

Quoted 109 lines

---
v4:

(quoted diff) +0 -3
-Rebase to top
-Use complete firmware size
-Return -ENODEV if flash probe fails

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

(quoted diff) +0 -2
-Add return error code
-Changes in displayed error 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 0493cfe..55e661c 100644
@@ -16,13 +16,14 @@
  #include <linux/bitops.h>
  #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.
@@ -163,6 +164,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 -ENODEV;
+	}
+
+	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.
@@ -187,6 +226,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 3bea9a9..06af8bf 100644
@@ -36,8 +36,11 @@
  /* Size of malloc() pool */
  #define CONFIG_SYS_MALLOC_LEN		(CONFIG_ENV_SIZE + 1024 * 1024)
 
-/*SPI device */
+/* PFE */
  #define CONFIG_SYS_FMAN_FW_ADDR		0x400d0000
+#define CONFIG_SYS_QE_FMAN_FW_LENGTH	0x300000
+
+/*SPI device */
  #define CONFIG_SYS_FSL_QSPI_BASE	0x40000000
 
  /* SATA */
#2 lore raw
Quoted 24 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Thursday, May 28, 2020 1:46 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 6 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.

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

Quoted 6 lines

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being applied too.

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong here.

Hi Priyanka,

Could you please help in reviewing this patch. The idea/motivation of these changes are taken from fm driver. The said changes in fm are already accepted in commit 382c53f94631 ("net: fm: add TFABOOT support"). You may take a look at code here[1], line: 380.

Thanks
Kuldeep
[1] https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fm/fm.c

Reviewed-by
#3 lore raw
Quoted 50 lines

-----Original Message-----
From: Kuldeep Singh <[email protected]>
Sent: Friday, June 19, 2020 3:40 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Priyanka Jain <[email protected]>
Cc: Tom Rini <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 24 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Thursday, May 28, 2020 1:46 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 6 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.

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

Quoted 6 lines

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being applied too.

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong here.

Hi Priyanka,

Could you please help in reviewing this patch. The idea/motivation of these changes are taken from fm driver.
The said changes in fm are already accepted in commit 382c53f94631 ("net:
fm: add TFABOOT support").
You may take a look at code here[1], line: 380.

Quoted 3 lines

Thanks
Kuldeep
[1] https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fm/fm.c

Joe,

Kindly help to pick this patch.

Regards
Priyanka

#4 lore raw
Quoted 54 lines · Priyanka Jain
Quoted 50 lines

-----Original Message-----
From: Kuldeep Singh <[email protected]>
Sent: Friday, June 19, 2020 3:40 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Priyanka Jain <[email protected]>
Cc: Tom Rini <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 24 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Thursday, May 28, 2020 1:46 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 6 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.

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

Quoted 6 lines

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being applied too.

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong here.

Hi Priyanka,

Could you please help in reviewing this patch. The idea/motivation of these changes are taken from fm driver.
The said changes in fm are already accepted in commit 382c53f94631 ("net:
fm: add TFABOOT support").
You may take a look at code here[1], line: 380.

Quoted 3 lines

Thanks
Kuldeep
[1] https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fm/fm.c

Quoted 5 lines

Joe,

Kindly help to pick this patch.

This is something that should go via the NXP trees, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200619/5b0824a2/attachment.sig>
#5 lore raw
Quoted 70 lines

-----Original Message-----
From: Tom Rini <[email protected]>
Sent: Friday, June 19, 2020 8:07 PM
To: Priyanka Jain <[email protected]>
Cc: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Schrempf Frieder <[email protected]>
Subject: Re: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 31 lines · Priyanka Jain
Quoted 31 lines

-----Original Message-----
From: Kuldeep Singh <[email protected]>
Sent: Friday, June 19, 2020 3:40 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Priyanka Jain <[email protected]>
Cc: Tom Rini <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 20 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Thursday, May 28, 2020 1:46 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 6 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.

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being

applied too.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong here.

Hi Priyanka,

Could you please help in reviewing this patch. The idea/motivation of these changes are taken from fm driver.
The said changes in fm are already accepted in commit 382c53f94631

("net:

Quoted 9 lines
Quoted 8 lines

fm: add TFABOOT support").
You may take a look at code here[1], line: 380.

Thanks
Kuldeep
[1]
https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fm/fm.
c

Quoted 7 lines
Quoted 5 lines

Joe,

Kindly help to pick this patch.

This is something that should go via the NXP trees, thanks!

Thanks Tom for mentioning. If this is so Priyanka, could you please pick this up in next PR.

#6 lore raw
Quoted 87 lines

-----Original Message-----
From: Kuldeep Singh <[email protected]>
Sent: Monday, June 22, 2020 11:00 AM
To: Priyanka Jain <[email protected]>
Cc: Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Schrempf Frieder <[email protected]>; Tom Rini <[email protected]>
Subject: RE: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 10 lines

-----Original Message-----
From: Tom Rini <[email protected]>
Sent: Friday, June 19, 2020 8:07 PM
To: Priyanka Jain <[email protected]>
Cc: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Schrempf Frieder <[email protected]>
Subject: Re: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 28 lines
Quoted 27 lines · Priyanka Jain
Quoted 27 lines

-----Original Message-----
From: Kuldeep Singh <[email protected]>
Sent: Friday, June 19, 2020 3:40 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de; Priyanka Jain <[email protected]>
Cc: Tom Rini <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Quoted 16 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Thursday, May 28, 2020 1:46 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Tom Rini <[email protected]>
Subject: [EXT] Re: [RESEND][Patch v4] net: pfe_eth: Use spi_flash_read API to access flash memory

Caution: EXT Email

Quoted 3 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.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines

So this patch has been floating around for about half a year now with almost no attention from the maintainers! Several pings have been sent by the author without response.

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

In fact this patch was blocking 91afd36f3802 ("spi: Transform the FSL QuadSPI driver to use the SPI MEM API") that has finally been merged, ignoring the fact that it will break ls1012a without this being

applied too.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

I don't want to blame anyone, but I want to voice my disappointment and raise attention that something is obviously wrong

here.

Quoted 18 lines
Quoted 6 lines
Quoted 6 lines

Hi Priyanka,

Could you please help in reviewing this patch. The idea/motivation of these changes are taken from fm driver.
The said changes in fm are already accepted in commit 382c53f94631

("net:

Quoted 11 lines
Quoted 8 lines

fm: add TFABOOT support").
You may take a look at code here[1], line: 380.

Thanks
Kuldeep
[1]
https://gitlab.denx.de/u-boot/u-boot/-/blob/master/drivers/net/fm/fm.
c

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Joe,

Kindly help to pick this patch.

This is something that should go via the NXP trees, thanks!

Thanks Tom for mentioning. If this is so Priyanka, could you please pick this up in next PR.

I will take care of this.

Thanks
Priyanka