aboutsummaryrefslogtreecommitdiff
path: root/drivers/net/pfe_eth
diff options
context:
space:
mode:
authorKuldeep Singh2020-05-28 11:42:53 +0530
committerPriyanka Jain2020-07-27 14:16:27 +0530
commite0152dbed683ed02af9294551fd4f03823ef7a5a (patch)
treea53ab855c1f6487abf8eaa806aca9811b90b4c3e /drivers/net/pfe_eth
parent02decd4e0ccf1a1f6395f24dfa14e2578f3e6e29 (diff)
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. Signed-off-by: Kuldeep Singh <kuldeep.singh@nxp.com> Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
Diffstat (limited to 'drivers/net/pfe_eth')
-rw-r--r--drivers/net/pfe_eth/pfe_firmware.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/drivers/net/pfe_eth/pfe_firmware.c b/drivers/net/pfe_eth/pfe_firmware.c
index 0493cfe8724..55e661c0e1d 100644
--- a/drivers/net/pfe_eth/pfe_firmware.c
+++ b/drivers/net/pfe_eth/pfe_firmware.c
@@ -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@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;