]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: pfe_eth: read PFE ESBC header flash with spi_flash_read API
authorBiwen Li <biwen.li@nxp.com>
Thu, 5 Nov 2020 11:28:12 +0000 (19:28 +0800)
committerPriyanka Jain <priyanka.jain@nxp.com>
Thu, 10 Dec 2020 08:26:39 +0000 (13:56 +0530)
Read PFE ESBC header flash with spi_flash_read API
- logs as follows,
  Net:   SF: Detected s25fs512s with page size 256 Bytes, erase size 256
  KiB, total 64 MiB
  "Synchronous Abort" handler, esr 0x96000210
  elr: 000000008206db44 lr : 0000000082004ea0 (reloc)
  elr: 00000000b7ba6b44 lr : 00000000b7b3dea0
  x0 : 00000000b79407e8 x1 : 0000000040640000
  x2 : 0000000000000050 x3 : 0000000000000000
  x4 : 000000000000000a x5 : 0000000000000050
  x6 : 0000000000000366 x7 : 00000000b7942308
  x8 : 00000000b76407c0 x9 : 0000000000000008
  x10: 0000000000000044 x11: 00000000b7634d1c
  x12: 000000000000004f x13: 0000000000000044
  x14: 00000000b7634d98 x15: 00000000b76407c0
  x16: 0000000000000000 x17: 0000000000000000
  x18: 00000000b7636dd8 x19: 0000000000000000
  x20: 00000000b79407d0 x21: 00000000b79407e8
  x22: 0000000040640000 x23: 00000000b7634e58
  x24: 0000000000000000 x25: 0000000003800000
  x26: 00000000b7bdd000 x27: 0000000000000000
  x28: 0000000000000000 x29: 00000000b7634d10

  Code: d2800003 eb03005f 54000101 d65f03c0 (f8636826)
  Resetting CPU ...

Signed-off-by: Biwen Li <biwen.li@nxp.com>
Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
board/freescale/ls1012afrdm/Kconfig
board/freescale/ls1012aqds/Kconfig
board/freescale/ls1012ardb/Kconfig
drivers/net/pfe_eth/pfe_firmware.c

index 55b414e16898ec30d09335068230711948cd1496..4ac69d711748acc21ae1c036d40cefe347cad034 100644 (file)
@@ -16,6 +16,10 @@ config SYS_LS_PFE_FW_ADDR
        hex "Flash address of PFE firmware"
        default 0x40a00000
 
+config SYS_LS_PFE_FW_LENGTH
+       hex "length of PFE firmware"
+       default 0x40000
+
 config SYS_LS_PPA_FW_ADDR
        hex "PPA Firmware Addr"
        default 0x40400000
@@ -65,6 +69,10 @@ config SYS_LS_PFE_FW_ADDR
        hex "Flash address of PFE firmware"
        default 0x40020000
 
+config SYS_LS_PFE_FW_LENGTH
+       hex "length of PFE firmware"
+       default 0x40000
+
 config SYS_LS_PPA_FW_ADDR
        hex "PPA Firmware Addr"
        default 0x40060000
@@ -77,6 +85,9 @@ config SYS_LS_PFE_ESBC_ADDR
        hex "PFE Firmware HDR Addr"
        default 0x401f8000
 
+config SYS_LS_PFE_ESBC_LENGTH
+       hex "length of PFE Firmware HDR"
+       default 0xc00
 endif
 
 if TARGET_LS1012AFRDM || TARGET_LS1012AFRWY
index 8844557aae45a4bb5af1ad4a4b2fc8acf0bdbc2f..59b1a876655f7198face150d7fe14623201a0c36 100644 (file)
@@ -20,6 +20,14 @@ if CHAIN_OF_TRUST
 config SYS_LS_PPA_ESBC_ADDR
        hex "PPA Firmware HDR Addr"
        default 0x40680000
+
+config SYS_LS_PFE_ESBC_ADDR
+       hex "PFE Firmware HDR Addr"
+       default 0x40700000
+
+config SYS_LS_PFE_ESBC_LENGTH
+       hex "length of PFE Firmware HDR"
+       default 0xc00
 endif
 
 if FSL_PFE
@@ -39,9 +47,9 @@ config SYS_LS_PFE_FW_ADDR
        hex "Flash address of PFE firmware"
        default 0x40a00000
 
-config SYS_LS_PFE_ESBC_ADDR
-       hex "PFE Firmware HDR Addr"
-       default 0x40700000
+config SYS_LS_PFE_FW_LENGTH
+       hex "length of PFE firmware"
+       default 0x300000
 
 config DDR_PFE_PHYS_BASEADDR
        hex "PFE DDR physical base address"
index 5a2fa91f6bed909f8f8b421f13cdf0c6edfd89a4..c4acea3ae2db3c7ba93bdf69306b32de42ca8eba 100644 (file)
@@ -20,6 +20,14 @@ if CHAIN_OF_TRUST
 config SYS_LS_PPA_ESBC_ADDR
        hex "PPA Firmware HDR Addr"
        default 0x40680000
+
+config SYS_LS_PFE_ESBC_ADDR
+       hex "PFE Firmware HDR Addr"
+       default 0x40640000
+
+config SYS_LS_PFE_ESBC_LENGTH
+       hex "length of PFE Firmware HDR"
+       default 0xc00
 endif
 
 if FSL_PFE
@@ -33,9 +41,9 @@ config SYS_LS_PFE_FW_ADDR
        hex "Flash address of PFE firmware"
        default 0x40a00000
 
-config SYS_LS_PFE_ESBC_ADDR
-       hex "PFE Firmware HDR Addr"
-       default 0x40640000
+config SYS_LS_PFE_FW_LENGTH
+       hex "length of PFE firmware"
+       default 0x300000
 
 config DDR_PFE_PHYS_BASEADDR
        hex "PFE DDR physical base address"
@@ -89,6 +97,10 @@ config SYS_LS_PFE_FW_ADDR
        hex "Flash address of PFE firmware"
        default 0x40a00000
 
+config SYS_LS_PFE_FW_LENGTH
+       hex "length of PFE firmware"
+       default 0x300000
+
 config DDR_PFE_PHYS_BASEADDR
        hex "PFE DDR physical base address"
        default 0x03800000
index d414c750d42313f331797b459744dbc9423dc84a..41999e176d411a08d3d369e039b7254eff845e38 100644 (file)
@@ -10,6 +10,8 @@
  * files.
  */
 
+#include <dm.h>
+#include <dm/device-internal.h>
 #include <image.h>
 #include <log.h>
 #include <malloc.h>
@@ -24,6 +26,9 @@
 #define PFE_FIRMWARE_FIT_CNF_NAME      "config@1"
 
 static const void *pfe_fit_addr;
+#ifdef CONFIG_CHAIN_OF_TRUST
+static const void *pfe_esbc_hdr_addr;
+#endif
 
 /*
  * PFE elf firmware loader.
@@ -169,7 +174,7 @@ int pfe_spi_flash_init(void)
        struct spi_flash *pfe_flash;
        struct udevice *new;
        int ret = 0;
-       void *addr = malloc(CONFIG_SYS_QE_FMAN_FW_LENGTH);
+       void *addr = malloc(CONFIG_SYS_LS_PFE_FW_LENGTH);
 
        if (!addr)
                return -ENOMEM;
@@ -179,21 +184,56 @@ int pfe_spi_flash_init(void)
                                     CONFIG_ENV_SPI_MAX_HZ,
                                     CONFIG_ENV_SPI_MODE,
                                     &new);
+       if (ret) {
+               printf("SF: failed to probe spi\n");
+               free(addr);
+               device_remove(new, DM_REMOVE_NORMAL);
+               return ret;
+       }
+
 
        pfe_flash = dev_get_uclass_priv(new);
        if (!pfe_flash) {
                printf("SF: probe for pfe failed\n");
                free(addr);
+               device_remove(new, DM_REMOVE_NORMAL);
                return -ENODEV;
        }
 
        ret = spi_flash_read(pfe_flash,
                             CONFIG_SYS_LS_PFE_FW_ADDR,
-                            CONFIG_SYS_QE_FMAN_FW_LENGTH,
+                            CONFIG_SYS_LS_PFE_FW_LENGTH,
                             addr);
-       if (ret)
+       if (ret) {
                printf("SF: read for pfe failed\n");
+               free(addr);
+               spi_flash_free(pfe_flash);
+               return ret;
+       }
 
+#ifdef CONFIG_CHAIN_OF_TRUST
+       void *hdr_addr = malloc(CONFIG_SYS_LS_PFE_ESBC_LENGTH);
+
+       if (!hdr_addr) {
+               free(addr);
+               spi_flash_free(pfe_flash);
+               return -ENOMEM;
+       }
+
+       ret = spi_flash_read(pfe_flash,
+                            CONFIG_SYS_LS_PFE_ESBC_ADDR,
+                            CONFIG_SYS_LS_PFE_ESBC_LENGTH,
+                            hdr_addr);
+       if (ret) {
+               printf("SF: failed to read pfe esbc header\n");
+               free(addr);
+               free(hdr_addr);
+               spi_flash_free(pfe_flash);
+               return ret;
+       }
+
+       pfe_esbc_hdr_addr = hdr_addr;
+#endif
        pfe_fit_addr = addr;
        spi_flash_free(pfe_flash);
 
@@ -233,7 +273,7 @@ int pfe_firmware_init(void)
                goto err;
 
 #ifdef CONFIG_CHAIN_OF_TRUST
-       pfe_esbc_hdr = CONFIG_SYS_LS_PFE_ESBC_ADDR;
+       pfe_esbc_hdr = (uintptr_t)pfe_esbc_hdr_addr;
        pfe_img_addr = (uintptr_t)pfe_fit_addr;
        if (fsl_check_boot_mode_secure() != 0) {
                /*