net: pfe_eth: Use spi_flash_read API to access flash memory
PATCH 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:
-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
@@ -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 -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.
@@ -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
@@ -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
PATCH v4 1/1 net: pfe_eth: Use spi_flash_read API to access flash memory
Quoted 5 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_readAPI to access memory instead of directly using it.Signed-off-by Kuldeep Singh <[email protected]>
Quoted 108 lines
---
v4:
-Return-ENODEVif 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@@ -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 -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. @@ -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@@ -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
Hi Joe,
Quoted 12 lines
-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, January 13, 2020 3:11 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]>; Priyanka Jain <[email protected]>
Subject: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryCaution: EXT Email
Quoted 9 lines
Quoted 5 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_readAPI to access memory instead of directly using it.Signed-off-by Kuldeep Singh <[email protected]>Reviewed-by Frieder Schrempf <[email protected]>
ping. this already has reviewed-by tag.
Please let me know if there's any dependency on my side.
Thanks
Kuldeep
Quoted 110 lines
Review
Quoted 10 lines
---
v4:
-Return-ENODEVif 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+++++++++++++++++++++++++++++++++++++-
Quoted 84 lines
include/configs/ls1012a_common.h | 5 ++++- 2 files changed, 48 insertions(+), 2 deletions(-)drivers/net/pfe_eth/pfe_firmware.c +42
-1@@ -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 -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. @@ -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
-0include/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
Ping.
Quoted 39 lines
-----Original Message-----
From: Kuldeep Singh
Sent: Thursday, January 23, 2020 12:43 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Priyanka Jain <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryHi Joe,
Quoted 12 lines
-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, January 13, 2020 3:11 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]>; Priyanka Jain <[email protected]>
Subject: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryCaution: EXT Email
Quoted 9 lines
Quoted 5 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_readAPI to access memory instead of directly using it.Signed-off-by Kuldeep Singh <[email protected]>Reviewed-by Frieder Schrempf <[email protected]>ping. this already has reviewed-by tag.
Please let me know if there's any dependency on my side.Thanks
Kuldeep
Quoted 11 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Kuldeep Singh
Sent: Tuesday, March 17, 2020 4:52 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Priyanka Jain <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memory
Quoted 41 lines
Ping.
Quoted 39 lines
-----Original Message-----
From: Kuldeep Singh
Sent: Thursday, January 23, 2020 12:43 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Priyanka Jain <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryHi Joe,
Quoted 12 lines
-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, January 13, 2020 3:11 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]>; Priyanka Jain <[email protected]>
Subject: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryCaution: EXT Email
Quoted 9 lines
Quoted 5 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_readAPI to access memory instead of directly using it.Signed-off-by Kuldeep Singh <[email protected]>Reviewed-by Frieder Schrempf <[email protected]>ping. this already has reviewed-by tag.
Please let me know if there's any dependency on my side.Thanks
Kuldeep
Joe,
Can you please pick this patch or provide Acked-by so that I can apply this in.
Thanks
Priyanka
Quoted 38 lines
-----Original Message-----
From: Priyanka Jain (OSS) <[email protected]>
Sent: Tuesday, May 12, 2020 12:11 PM
To: Kuldeep Singh <[email protected]>; Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryQuoted 24 lines
-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Kuldeep Singh
Sent: Tuesday, March 17, 2020 4:52 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Priyanka Jain <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryPing.
Quoted 12 lines
-----Original Message-----
From: Kuldeep Singh
Sent: Thursday, January 23, 2020 12:43 PM
To: Joe Hershberger <[email protected]>; u-boot at lists.denx.de
Cc: Thomas Hebb <[email protected]>; Patrick Delaunay <[email protected]>; Priyanka Jain <[email protected]>; Schrempf Frieder <[email protected]>
Subject: RE: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryHi Joe,
Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, January 13, 2020 3:11 PM
To: Kuldeep Singh <[email protected]>; u-boot at lists.denx.de
Cc: Joe Hershberger <[email protected]>; Thomas Hebb <[email protected]>; Patrick DelaunayQuoted 14 lines
Quoted 14 lines
Quoted 14 lines
Priyanka Jain <[email protected]>
Subject: [EXT] Re: [Patch v4] net:pfe_eth: Usespi_flash_readAPI to access flash memoryCaution: EXT Email
Quoted 5 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_readAPI to access memory instead of directly using it.Signed-off-by Kuldeep Singh <[email protected]>Reviewed-by Frieder Schrempf <[email protected]>
This patch requires rebasing to top. Will respin this version.
Thanks
Kuldeep