[PATCH] intel: n5x: ddr: update license

2022-06-10 Thread tien . fong . chee
From: Tien Fong Chee 

All the source code of sdram_n5x.c are from Intel, update the license to
use both GPL2.0 and BSD-3 Clause because this copy of code may used for
open source and internal project.

Signed-off-by: Tien Fong Chee 
---
 drivers/ddr/altera/sdram_n5x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ddr/altera/sdram_n5x.c b/drivers/ddr/altera/sdram_n5x.c
index ac13ac4319..737a4e2ff1 100644
--- a/drivers/ddr/altera/sdram_n5x.c
+++ b/drivers/ddr/altera/sdram_n5x.c
@@ -1,6 +1,6 @@
-// SPDX-License-Identifier: GPL-2.0
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (C) 2020-2021 Intel Corporation 
+ * Copyright (C) 2020-2022 Intel Corporation 
  *
  */
 
-- 
2.19.0



[PATCH] ddr: altera: Stratix10: Use phys_size_t for memory size

2022-04-26 Thread tien . fong . chee
From: Tien Fong Chee 

Replace with phys_size_t for all memory size variables declaration
for the sake of scalability. phys_size_t is defined in
/arch/arm/include/asm/types.h.

Signed-off-by: Tien Fong Chee 
---
 drivers/ddr/altera/sdram_s10.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ddr/altera/sdram_s10.c b/drivers/ddr/altera/sdram_s10.c
index d3a6d21860..4d36fb4533 100644
--- a/drivers/ddr/altera/sdram_s10.c
+++ b/drivers/ddr/altera/sdram_s10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2016-2018 Intel Corporation 
+ * Copyright (C) 2016-2022 Intel Corporation 
  *
  */
 
@@ -277,7 +277,7 @@ int sdram_mmr_init_full(struct udevice *dev)
DDR_SCH_DEVTODEV);
 
/* assigning the SDRAM size */
-   unsigned long long size = sdram_calculate_size(plat);
+   phys_size_t size = sdram_calculate_size(plat);
/* If the size is invalid, use default Config size */
if (size <= 0)
hw_size = PHYS_SDRAM_1_SIZE;
-- 
2.19.0



[PATCH] ddr: altera: Ignore bit[7-4] for both seq2core & core2seq handshake in HPS

2022-04-26 Thread tien . fong . chee
From: Tien Fong Chee 

Bit[7-4] for both register seq2core and core2seq handshake in HPS are not
required for triggering DDR re-calibration or resetting EMIF. So, ignoring
these bits just for playing it safe.

Signed-off-by: Tien Fong Chee 
---
 drivers/ddr/altera/sdram_soc64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ddr/altera/sdram_soc64.h b/drivers/ddr/altera/sdram_soc64.h
index 7460f8c220..07a0f9f2ae 100644
--- a/drivers/ddr/altera/sdram_soc64.h
+++ b/drivers/ddr/altera/sdram_soc64.h
@@ -53,7 +53,7 @@ struct altera_sdram_plat {
 #define DDR_HMC_INTSTAT_DERRPENA_SET_MSK   BIT(1)
 #define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK BIT(16)
 #define DDR_HMC_INTMODE_INTMODE_SET_MSKBIT(0)
-#define DDR_HMC_RSTHANDSHAKE_MASK  0x00ff
+#define DDR_HMC_RSTHANDSHAKE_MASK  0x000f
 #define DDR_HMC_CORE2SEQ_INT_REQ   0xF
 #define DDR_HMC_SEQ2CORE_INT_RESP_MASK BIT(3)
 #define DDR_HMC_HPSINTFCSEL_ENABLE_MASK0x001f1f1f
-- 
2.19.0



[PATCH] mtd: spi-nor-ids: add Macronix flash entry

2022-04-26 Thread tien . fong . chee
From: Tien Fong Chee 

Add Macronix mx25u51245g flash entry, so this can be used on
SoCFPGA devices.

Signed-off-by: Tien Fong Chee 
---
 drivers/mtd/spi/spi-nor-ids.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c
index 763bab04c6..94cf7a3a44 100644
--- a/drivers/mtd/spi/spi-nor-ids.c
+++ b/drivers/mtd/spi/spi-nor-ids.c
@@ -166,6 +166,8 @@ const struct flash_info spi_nor_ids[] = {
{ INFO("mx25u6435f",  0xc22537, 0, 64 * 1024, 128, SECT_4K) },
{ INFO("mx25l12805d", 0xc22018, 0, 64 * 1024, 256, SECT_4K) },
{ INFO("mx25u12835f", 0xc22538, 0, 64 * 1024, 256, SECT_4K) },
+   { INFO("mx25u51245g", 0xc2253a, 0, 64 * 1024, 1024, SECT_4K |
+  SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_4B_OPCODES) },
{ INFO("mx25l12855e", 0xc22618, 0, 64 * 1024, 256, 0) },
{ INFO("mx25l25635e", 0xc22019, 0, 64 * 1024, 512, SPI_NOR_DUAL_READ | 
SPI_NOR_QUAD_READ) },
{ INFO("mx25u25635f", 0xc22539, 0, 64 * 1024, 512, SECT_4K | 
SPI_NOR_4B_OPCODES) },
-- 
2.19.0



[PATCH] ddr: socfpga: Fix integer overflow that caused DDR size mismatched

2020-08-04 Thread tien . fong . chee
From: Tien Fong Chee 

Convert the constant integer to 'phys_size_t' to avoid overflow
when calculating the SDRAM size.

Signed-off-by: Tien Fong Chee 
---
 drivers/ddr/altera/sdram_soc64.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/ddr/altera/sdram_soc64.c b/drivers/ddr/altera/sdram_soc64.c
index 8cb75fe02a..a862ac8092 100644
--- a/drivers/ddr/altera/sdram_soc64.c
+++ b/drivers/ddr/altera/sdram_soc64.c
@@ -218,13 +218,14 @@ phys_size_t sdram_calculate_size(struct 
altera_sdram_platdata *plat)
 {
u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
 
-   phys_size_t size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
-DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
-DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
-DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
-DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
-
-   size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
+   phys_size_t size = (phys_size_t)1 <<
+  (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+   DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
+   DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
+   DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
+   DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
+
+   size *= ((phys_size_t)2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
 
return size;
-- 
2.13.0



[PATCH] ddr: socfpga: stratix10: Use phys_size_t for memory size

2020-08-04 Thread tien . fong . chee
From: Tien Fong Chee 

Replace with phys_size_t for better scalable. phys_size_t is defined in
arch/arm/include/asm/types.h .

Signed-off-by: Tien Fong Chee 
---
 drivers/ddr/altera/sdram_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ddr/altera/sdram_s10.c b/drivers/ddr/altera/sdram_s10.c
index 2945f1e1df..5d24a5800a 100644
--- a/drivers/ddr/altera/sdram_s10.c
+++ b/drivers/ddr/altera/sdram_s10.c
@@ -276,7 +276,7 @@ int sdram_mmr_init_full(struct udevice *dev)
DDR_SCH_DEVTODEV);
 
/* assigning the SDRAM size */
-   unsigned long long size = sdram_calculate_size(plat);
+   phys_size_t size = sdram_calculate_size(plat);
/* If the size is invalid, use default Config size */
if (size <= 0)
hw_size = PHYS_SDRAM_1_SIZE;
-- 
2.13.0



[U-Boot] [PATCH 2/2] drivers: ubi: Adding UBI loader for SPI flash

2019-07-29 Thread tien . fong . chee
From: Tien Fong Chee 

Adding UBI support for SPI flash.

Signed-off-by: Tien Fong Chee 
---
 common/spl/spl_ubi.c| 11 ++-
 drivers/mtd/spi/sf-uclass.c | 30 ++
 include/spi_flash.h | 10 ++
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c
index 0cb5080882..40a449b42b 100644
--- a/common/spl/spl_ubi.c
+++ b/common/spl/spl_ubi.c
@@ -9,6 +9,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 
 int spl_ubi_load_image(struct spl_image_info *spl_image,
@@ -33,6 +35,12 @@ int spl_ubi_load_image(struct spl_image_info *spl_image,
info.peb_size = CONFIG_SYS_ONENAND_BLOCK_SIZE;
break;
 #endif
+#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
+   case BOOT_DEVICE_SPI:
+   info.read = spi_flash_read_block;
+   info.peb_size = CONFIG_SYS_SPI_BLOCK_SIZE;
+   break;
+#endif
default:
goto out;
}
@@ -82,6 +90,7 @@ out:
 #endif
return ret;
 }
-/* Use priorty 0 so that Ubi will override NAND and ONENAND methods */
+/* Use priorty 0 so that Ubi will override SPI, NAND and ONENAND methods */
+SPL_LOAD_IMAGE_METHOD("SPI", 0, BOOT_DEVICE_SPI, spl_ubi_load_image);
 SPL_LOAD_IMAGE_METHOD("NAND", 0, BOOT_DEVICE_NAND, spl_ubi_load_image);
 SPL_LOAD_IMAGE_METHOD("OneNAND", 0, BOOT_DEVICE_ONENAND, spl_ubi_load_image);
diff --git a/drivers/mtd/spi/sf-uclass.c b/drivers/mtd/spi/sf-uclass.c
index 719a2fd23a..45b6dd9e52 100644
--- a/drivers/mtd/spi/sf-uclass.c
+++ b/drivers/mtd/spi/sf-uclass.c
@@ -12,6 +12,36 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/**
+ * spi_flash_read_block - Read data from physical eraseblock into a buffer
+ * @block: Number of the physical eraseblock
+ * @offset:Data offset from the start of @peb
+ * @len:   Data size to read
+ * @buf:   Address of the destination buffer
+ * @return 0 if OK, -ve on error
+ */
+int spi_flash_read_block(int block, int offset, int len, void *buf)
+{
+   struct udevice *dev;
+
+   int ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS,
+CONFIG_SF_DEFAULT_CS,
+CONFIG_SF_DEFAULT_SPEED,
+CONFIG_SF_DEFAULT_MODE, );
+   if (ret) {
+   printf("Failed to initialize SPI flash at ");
+   printf("%u:%u (error %d)\n",CONFIG_SF_DEFAULT_BUS,
+  CONFIG_SF_DEFAULT_CS, ret);
+   return ret;
+   }
+
+   dev_get_uclass_priv(dev);
+
+   return log_ret(sf_get_ops(dev)->read(dev,
+ CONFIG_SYS_SPI_BLOCK_SIZE *
+ block + offset, len, buf));
+}
+
 int spi_flash_read_dm(struct udevice *dev, u32 offset, size_t len, void *buf)
 {
return log_ret(sf_get_ops(dev)->read(dev, offset, len, buf));
diff --git a/include/spi_flash.h b/include/spi_flash.h
index 55b4721813..f6eefdc5c8 100644
--- a/include/spi_flash.h
+++ b/include/spi_flash.h
@@ -102,6 +102,16 @@ int spi_flash_erase_dm(struct udevice *dev, u32 offset, 
size_t len);
  */
 int spl_flash_get_sw_write_prot(struct udevice *dev);
 
+/**
+ * spi_flash_read_block - Read data from physical eraseblock into a buffer
+ * @block: Number of the physical eraseblock
+ * @offset:Data offset from the start of @peb
+ * @len:   Data size to read
+ * @buf:   Address of the destination buffer
+ * @return 0 if OK, -ve on error
+ */
+int spi_flash_read_block(int block, int offset, int len, void *dst);
+
 int spi_flash_probe_bus_cs(unsigned int busnum, unsigned int cs,
   unsigned int max_hz, unsigned int spi_mode,
   struct udevice **devp);
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] mtd: spi: Add SYS_SPI_BLOCK_SIZE to Kconfig

2019-07-29 Thread tien . fong . chee
From: Tien Fong Chee 

Different SPI flash has different block erase size configuration, it can
be configured as block erase size or sub-block erase size, so
SYS_SPI_BLOCK_SIZE is created to provide UBI a consistent block reading.
UBI block reading would be eventually translated to offset
access into SPI regardless how the block erase size is configured on SPI.
This would made the UBI transparent from SPI layer.

Signed-off-by: Tien Fong Chee 
---
 drivers/mtd/spi/Kconfig | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig
index d3b007a731..ea3779c521 100644
--- a/drivers/mtd/spi/Kconfig
+++ b/drivers/mtd/spi/Kconfig
@@ -196,4 +196,11 @@ config SPI_FLASH_MTD
 
  If unsure, say N
 
+config SYS_SPI_BLOCK_SIZE
+   hex "SPI chip eraseblock size for UBI reading"
+   depends on SPL_SPI_FLASH_SUPPORT
+   default 65536
+   help
+ Number of data bytes in a physical eraseblock for UBI reading.
+
 endmenu # menu "SPI Flash Support"
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] Arm: dts: socfpga: Remove invalid property from chose node

2019-05-24 Thread tien . fong . chee
From: Tien Fong Chee 

Finding bitstream from cff-file is no longer valid after bitstream is built
into FIT image and loaded by generic firmware loader. Remove cff-file
as this is legacy implementation from A10 downstream.

Signed-off-by: Tien Fong Chee 
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi
index 39009654d9..1d09361549 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi
@@ -18,10 +18,6 @@
#size-cells = <1>;
model = "SOCFPGA Arria10 Dev Kit";  /* Bootloader setting: 
uboot.model */
 
-   chosen {
-   cff-file = "socfpga.rbf";   /* Bootloader setting: 
uboot.rbf_filename */
-   };
-
/* Clock sources */
clocks {
u-boot,dm-pre-reloc;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] reset: socfpga: release more A10 peripherals out of reset

2019-05-24 Thread tien . fong . chee
From: Tien Fong Chee 

Current implementation almost release all peripherals out of reset for
gen5, but A10 has more peripherals than gen5, hence this patch is required
to release the rest of peripherals to support old kernels.

Signed-off-by: Tien Fong Chee 
---
 drivers/reset/reset-socfpga.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index cb8312619f..d8b8b25fc3 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -127,6 +127,9 @@ static int socfpga_reset_remove(struct udevice *dev)
if (socfpga_reset_keep_enabled()) {
puts("Deasserting all peripheral resets\n");
writel(0, data->modrst_base + 4);
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+   writel(0, data->modrst_base + 8);
+#endif
}
 
return 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 5/9] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

Changes for v13
- Fixed the changes comment in v10

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
-Cleaned up the codes.
-Return -EPERM when programing core on non early IO release mode.
-Using live function to get rid of gd->fdt_blob for FPGA manager.
-Removed @0 for fs-loader node

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 497 -
 include/image.h|   4 +
 4 files changed, 542 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811210..cc761967c7 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6fd3..c5f67714aa 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+const char *get_fpga_filename(void);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9499d1a014..9df2c430d7 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD

[U-Boot] [PATCH v13 7/9] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- Removed the static so the function can be referred by other c file.

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v8
- No changes.

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.
---
 .../include/mach/fpga_manager_arria10.h|  1 +
 arch/arm/mach-socfpga/spl_a10.c| 31 +-
 drivers/fpga/socfpga_arria10.c |  2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index c5f67714aa..62249b3695 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -126,6 +126,7 @@ int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
 const char *get_fpga_filename(void);
+int is_fpgamgr_early_user_mode(void);
 int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
  u32 offset);
 void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c8e73d47c0..b466307f98 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9df2c430d7..285280e507 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -69,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 9/9] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Increasing Malloc pool size up to 0x15000 is required to support FAT in SPL
. The result of calculation is come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

Previous records of discussion about this patch can be checked from here
https://patchwork.ozlabs.org/cover/1034282/ .

changes for v13
- Fixed commit messages.
- Moved the A10 specific malloc size configuration to A10 SoCDK header.

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 include/configs/socfpga_arria10_socdk.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/configs/socfpga_arria10_socdk.h 
b/include/configs/socfpga_arria10_socdk.h
index 92630c5e6e..645e66e6b0 100644
--- a/include/configs/socfpga_arria10_socdk.h
+++ b/include/configs/socfpga_arria10_socdk.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- *  Copyright (C) 2015-2017 Altera Corporation 
+ *  Copyright (C) 2015-2019 Altera Corporation 
  */
 
 #ifndef __CONFIG_SOCFGPA_ARRIA10_H__
@@ -36,6 +36,9 @@
  */
 #define CONFIG_SYS_MAX_FLASH_BANKS 1
 
+/* SPL memory allocation configuration, this is for FAT implementation */
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
+
 /* The rest of the configuration is shared */
 #include 
 
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 8/9] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 1931a1d153..09a018c97d 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -6,12 +6,15 @@ CONFIG_DISTRO_DEFAULTS=y
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_SPL_TEXT_BASE=0xFFE0
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -20,9 +23,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -30,7 +31,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -41,9 +41,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 4/9] ARM: socfpga: Moving the watchdog reset to the for-loop status polling

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Current watchdog reset is misplaced after for-loop status polling, so
this poses a risk that watchdog can't be reset timely if polling taking
longer than watchdog timeout. This patch moving the watchdog reset
into polling to ensure the watchdog can be reset timely.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- Improved the commit messages.

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- This patch was split out from [PATCH v10 5/9]
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA.
---
 drivers/fpga/socfpga_arria10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index b0abe1955c..9499d1a014 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -360,6 +360,7 @@ static int fpgamgr_program_poll_cd(void)
printf("nstatus == 0 while waiting for condone\n");
return -EPERM;
}
+   WATCHDOG_RESET();
}
 
if (i == FPGA_TIMEOUT_CNT)
@@ -433,7 +434,6 @@ int fpgamgr_program_finish(void)
printf("FPGA: Poll CD failed with error code %d\n", status);
return -EPERM;
}
-   WATCHDOG_RESET();
 
/* Ensure the FPGA entering user mode */
status = fpgamgr_program_poll_usermode();
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 2/9] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- No changes.

changes for v11
- Replaced core image node "-2" with "-1",
  the numeric associates the core and periph images in case where there
  are multiple.

changes for v10
- Replaced both image nodes "@1" and "@2" with "-1" and "-2" respectively.

changes for v9
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.

changes for v7
- No changes.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 00..adae997213
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core-1 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph-1", "fpga-core-1";
+   };
+   };
+};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 6/9] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 47fe1d9690..1931a1d153 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -25,7 +25,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
+CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 3/9] ARM: socfpga: Cleaning up and ensuring consistent format messages in driver

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure all the debug messages are always prefix with "FPGA: " and comment
beginning with uppercase letter.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- This patch was split out from [PATCH v10 5/9]
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA.
---
 drivers/fpga/socfpga_arria10.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd910ab..b0abe1955c 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -94,7 +94,7 @@ int fpgamgr_wait_early_user_mode(void)
i++;
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +172,10 @@ static int fpgamgr_set_cdratio_cdwidth(unsigned int 
cfg_width, u32 *rbf_data,
compress = (rbf_data[COMPRESSION_OFFSET] >> 1) & 1;
compress = !compress;
 
-   debug("header word %d = %08x\n", 69, rbf_data[69]);
-   debug("header word %d = %08x\n", 229, rbf_data[229]);
-   debug("read from rbf header: encrypt=%d compress=%d\n", encrypt, 
compress);
+   debug("FPGA: Header word %d = %08x.\n", 69, rbf_data[69]);
+   debug("FPGA: Header word %d = %08x.\n", 229, rbf_data[229]);
+   debug("FPGA: Read from rbf header: encrypt=%d compress=%d.\n", encrypt,
+compress);
 
/*
 * from the register map description of cdratio in imgcfg_ctrl_02:
@@ -455,10 +456,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, 
size_t rbf_size)
 {
int status;
 
-   /* disable all signals from hps peripheral controller to fpga */
+   /* Disable all signals from hps peripheral controller to fpga */
writel(0, _manager_base->fpgaintf_en_global);
 
-   /* disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
+   /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
socfpga_bridges_reset();
 
/* Initialize the FPGA Manager */
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 1/9] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v13
- No changes.

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a847..da210bfc86 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v13 0/9] Add support for loading FPGA bitstream

2019-05-07 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved comments from Simon in [v12].

This series is working on top of u-boot.git http://git.denx.de/u-boot.git

[v12]: https://patchwork.ozlabs.org/cover/1058282/
[v11]: https://www.mail-archive.com/u-boot@lists.denx.de/msg318174.html
[v10]: https://www.mail-archive.com/u-boot@lists.denx.de/msg318167.html
[v9]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (9):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Cleaning up and ensuring consistent format messages in
driver
  ARM: socfpga: Moving the watchdog reset to the for-loop status polling
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  23 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 514 -
 include/configs/socfpga_arria10_socdk.h|   5 +-
 include/image.h|   4 +
 9 files changed, 668 insertions(+), 30 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 8/9] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 192cf7e05f..759fc771e6 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,11 +10,14 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_BOUNCE_BUFFER=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -23,9 +26,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -33,7 +34,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -44,11 +44,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 5/9] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
-Cleaned up the codes.
-Return -EPERM when programing core on non early IO release mode.
-Using live function to get rid of gd->
-Removed @0 for fs-loader node

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 497 -
 include/image.h|   4 +
 4 files changed, 542 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811210..cc761967c7 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6fd3..c5f67714aa 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+const char *get_fpga_filename(void);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9499d1a014..9df2c430d7 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD_ADDRESS   0x400
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const struct socfp

[U-Boot] [PATCH v12 7/9] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- Removed the static so the function can be referred by other c file.

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v8
- No changes.

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.
---
 .../include/mach/fpga_manager_arria10.h|  1 +
 arch/arm/mach-socfpga/spl_a10.c| 31 +-
 drivers/fpga/socfpga_arria10.c |  2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index c5f67714aa..62249b3695 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -126,6 +126,7 @@ int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
 const char *get_fpga_filename(void);
+int is_fpgamgr_early_user_mode(void);
 int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
  u32 offset);
 void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c8e73d47c0..b466307f98 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9df2c430d7..285280e507 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -69,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 9/9] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Increasing Malloc pool size up to 0x15000 is required to support FAT in SPL
. The result of calculation is come from after applying some few patches
which are required for optimizing vfat and maximizing resusable of the
memory pool, and then followed by the size required come from default max
cluster(0x1) + others(0x2000) + additional memory for headroom(0x3000).
Previous records of describing these few patches can be checked from here
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html .

Signed-off-by: Tien Fong Chee 

---

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 181af9b646..22533036ed 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -254,7 +254,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 6/9] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 9 +
 1 file changed, 9 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index f321a0ac3b..192cf7e05f 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -28,9 +28,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 3/9] ARM: socfpga: Cleaning up and ensuring consistent format messages in driver

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure all the debug messages are always prefix with "FPGA: " and comment
beginning with uppercase letter.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- This patch was split out from [PATCH v10 5/9]
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA.
---
 drivers/fpga/socfpga_arria10.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd910ab..b0abe1955c 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -94,7 +94,7 @@ int fpgamgr_wait_early_user_mode(void)
i++;
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +172,10 @@ static int fpgamgr_set_cdratio_cdwidth(unsigned int 
cfg_width, u32 *rbf_data,
compress = (rbf_data[COMPRESSION_OFFSET] >> 1) & 1;
compress = !compress;
 
-   debug("header word %d = %08x\n", 69, rbf_data[69]);
-   debug("header word %d = %08x\n", 229, rbf_data[229]);
-   debug("read from rbf header: encrypt=%d compress=%d\n", encrypt, 
compress);
+   debug("FPGA: Header word %d = %08x.\n", 69, rbf_data[69]);
+   debug("FPGA: Header word %d = %08x.\n", 229, rbf_data[229]);
+   debug("FPGA: Read from rbf header: encrypt=%d compress=%d.\n", encrypt,
+compress);
 
/*
 * from the register map description of cdratio in imgcfg_ctrl_02:
@@ -455,10 +456,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, 
size_t rbf_size)
 {
int status;
 
-   /* disable all signals from hps peripheral controller to fpga */
+   /* Disable all signals from hps peripheral controller to fpga */
writel(0, _manager_base->fpgaintf_en_global);
 
-   /* disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
+   /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
socfpga_bridges_reset();
 
/* Initialize the FPGA Manager */
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 2/9] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- Replaced core image node "-2" with "-1",
  the numeric associates the core and periph images in case where there
  are multiple.

changes for v10
- Replaced both image nodes "@1" and "@2" with "-1" and "-2" respectively.

changes for v9
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.

changes for v7
- No changes.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 00..adae997213
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core-1 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph-1", "fpga-core-1";
+   };
+   };
+};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 4/9] ARM: socfpga: Moving the watchdog reset to the for-loop status polling

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the watchdog is reset timely on each status polling.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- Improved the commit messages.

changes for v11
- No changes.

changes for v10
- This patch was split out from [PATCH v10 5/9]
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA.
---
 drivers/fpga/socfpga_arria10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index b0abe1955c..9499d1a014 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -360,6 +360,7 @@ static int fpgamgr_program_poll_cd(void)
printf("nstatus == 0 while waiting for condone\n");
return -EPERM;
}
+   WATCHDOG_RESET();
}
 
if (i == FPGA_TIMEOUT_CNT)
@@ -433,7 +434,6 @@ int fpgamgr_program_finish(void)
printf("FPGA: Poll CD failed with error code %d\n", status);
return -EPERM;
}
-   WATCHDOG_RESET();
 
/* Ensure the FPGA entering user mode */
status = fpgamgr_program_poll_usermode();
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 1/9] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v12
- No changes.

changes for v11
- No changes.

changes for v10
- No changes.

changes for v9
- No changes.

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a847..da210bfc86 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v12 0/9] Add support for loading FPGA bitstream

2019-03-19 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved comments from Dinh in [v11].

This series is working on top of u-boot.git http://git.denx.de/u-boot.git

These patches are required before applying this series of patches
1. [U-Boot,v4] misc: fs_loader: Add support for initializing block device
https://patchwork.ozlabs.org/project/uboot/list/?series=89282 (done review)

2. [U-Boot] fpga: Replace char * with const char * for filename
https://patchwork.ozlabs.org/patch/1042665/ (done review)

3. [U-Boot] misc: fs_loader: Replace label with DT phandle
https://patchwork.ozlabs.org/patch/1051782/ (under review)

[v11]: https://www.mail-archive.com/u-boot@lists.denx.de/msg318174.html
[v10]: https://www.mail-archive.com/u-boot@lists.denx.de/msg318167.html
[v9]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (9):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Cleaning up and ensuring consistent format messages in
driver
  ARM: socfpga: Moving the watchdog reset to the for-loop status polling
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  22 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 514 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 664 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 5/9] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v10
-Cleaned up the codes.
-Return -EPERM when programing core on non early IO release mode.
-Using live function to get rid of gd->
-Removed @0 for fs-loader node

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 497 -
 include/image.h|   4 +
 4 files changed, 542 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811210..cc761967c7 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6fd3..c5f67714aa 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+const char *get_fpga_filename(void);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9499d1a014..9df2c430d7 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD_ADDRESS   0x400
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const struct socfpga_fpga_manager *fpga_manager_base =
(void

[U-Boot] [PATCH v11 8/9] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index c870543346..bdbf90ed44 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,7 +33,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -43,11 +43,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 9/9] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb29bc..548b458e78 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 7/9] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v10
- Removed the static so the function can be referred by other c file.

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.

# Conflicts:
#   arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
---
 .../include/mach/fpga_manager_arria10.h|  1 +
 arch/arm/mach-socfpga/spl_a10.c| 31 +-
 drivers/fpga/socfpga_arria10.c |  2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index c5f67714aa..62249b3695 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -126,6 +126,7 @@ int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
 const char *get_fpga_filename(void);
+int is_fpgamgr_early_user_mode(void);
 int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
  u32 offset);
 void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb424..4b658c87a3 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9df2c430d7..285280e507 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -69,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 3/9] ARM: socfpga: Cleaning up the messages

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the comment and debug messages are always consistent with the rest.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd910ab..b0abe1955c 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -94,7 +94,7 @@ int fpgamgr_wait_early_user_mode(void)
i++;
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +172,10 @@ static int fpgamgr_set_cdratio_cdwidth(unsigned int 
cfg_width, u32 *rbf_data,
compress = (rbf_data[COMPRESSION_OFFSET] >> 1) & 1;
compress = !compress;
 
-   debug("header word %d = %08x\n", 69, rbf_data[69]);
-   debug("header word %d = %08x\n", 229, rbf_data[229]);
-   debug("read from rbf header: encrypt=%d compress=%d\n", encrypt, 
compress);
+   debug("FPGA: Header word %d = %08x.\n", 69, rbf_data[69]);
+   debug("FPGA: Header word %d = %08x.\n", 229, rbf_data[229]);
+   debug("FPGA: Read from rbf header: encrypt=%d compress=%d.\n", encrypt,
+compress);
 
/*
 * from the register map description of cdratio in imgcfg_ctrl_02:
@@ -455,10 +456,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, 
size_t rbf_size)
 {
int status;
 
-   /* disable all signals from hps peripheral controller to fpga */
+   /* Disable all signals from hps peripheral controller to fpga */
writel(0, _manager_base->fpgaintf_en_global);
 
-   /* disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
+   /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
socfpga_bridges_reset();
 
/* Initialize the FPGA Manager */
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 6/9] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b6ec..c870543346 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,10 +27,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 2/9] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v11
- Replaced core image node "-2" with "-1",
  the numeric associates the core and periph images in case where there
  are multiple.

changes for v10
- Replaced both image nodes "@1" and "@2" with "-1" and "-2" respectively.

changes for v9
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 00..adae997213
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core-1 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph-1", "fpga-core-1";
+   };
+   };
+};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 4/9] ARM: socfpga: Move the watchdog reset to the looping location

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the watchdog is reset timely if the looping is long.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index b0abe1955c..9499d1a014 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -360,6 +360,7 @@ static int fpgamgr_program_poll_cd(void)
printf("nstatus == 0 while waiting for condone\n");
return -EPERM;
}
+   WATCHDOG_RESET();
}
 
if (i == FPGA_TIMEOUT_CNT)
@@ -433,7 +434,6 @@ int fpgamgr_program_finish(void)
printf("FPGA: Poll CD failed with error code %d\n", status);
return -EPERM;
}
-   WATCHDOG_RESET();
 
/* Ensure the FPGA entering user mode */
status = fpgamgr_program_poll_usermode();
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 1/9] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a847..da210bfc86 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v11 0/9] Add support for loading FPGA bitstream

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly assign "-1" to both periph and core images in patch[2/9]
because the numeric associates the core and periph images in cases where there
are multiple.

This series is working on top of u-boot.git http://git.denx.de/u-boot.git

These patches are required before applying this series of patches
1. [U-Boot,v4] misc: fs_loader: Add support for initializing block device
https://patchwork.ozlabs.org/project/uboot/list/?series=89282(done review)

3. [U-Boot] misc: fs_loader: Replace label with DT phandle
https://patchwork.ozlabs.org/project/uboot/list/?series=92167(under review)

[v9]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (9):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Cleaning up the messages
  ARM: socfpga: Move the watchdog reset to the looping location
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 514 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 663 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 5/9] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v10
-Cleaned up the codes.
-Return -EPERM when programing core on non early IO release mode.
-Using live function to get rid of gd->
-Removed @0 for fs-loader node

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 497 -
 include/image.h|   4 +
 4 files changed, 542 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811210..cc761967c7 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6fd3..c5f67714aa 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+const char *get_fpga_filename(void);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9499d1a014..9df2c430d7 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD_ADDRESS   0x400
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const struct socfpga_fpga_manager *fpga_manager_base =
(void

[U-Boot] [PATCH v10 8/9] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index c870543346..bdbf90ed44 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,7 +33,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -43,11 +43,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 7/9] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v10
- Removed the static so the function can be referred by other c file.

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.

# Conflicts:
#   arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
---
 .../include/mach/fpga_manager_arria10.h|  1 +
 arch/arm/mach-socfpga/spl_a10.c| 31 +-
 drivers/fpga/socfpga_arria10.c |  2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index c5f67714aa..62249b3695 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -126,6 +126,7 @@ int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
 const char *get_fpga_filename(void);
+int is_fpgamgr_early_user_mode(void);
 int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
  u32 offset);
 void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb424..4b658c87a3 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9df2c430d7..285280e507 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -69,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 9/9] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb29bc..548b458e78 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 4/9] ARM: socfpga: Move the watchdog reset to the looping location

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the watchdog is reset timely if the looping is long.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index b0abe1955c..9499d1a014 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -360,6 +360,7 @@ static int fpgamgr_program_poll_cd(void)
printf("nstatus == 0 while waiting for condone\n");
return -EPERM;
}
+   WATCHDOG_RESET();
}
 
if (i == FPGA_TIMEOUT_CNT)
@@ -433,7 +434,6 @@ int fpgamgr_program_finish(void)
printf("FPGA: Poll CD failed with error code %d\n", status);
return -EPERM;
}
-   WATCHDOG_RESET();
 
/* Ensure the FPGA entering user mode */
status = fpgamgr_program_poll_usermode();
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 3/9] ARM: socfpga: Cleaning up the messages

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the comment and debug messages are always consistent with the rest.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd910ab..b0abe1955c 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -94,7 +94,7 @@ int fpgamgr_wait_early_user_mode(void)
i++;
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +172,10 @@ static int fpgamgr_set_cdratio_cdwidth(unsigned int 
cfg_width, u32 *rbf_data,
compress = (rbf_data[COMPRESSION_OFFSET] >> 1) & 1;
compress = !compress;
 
-   debug("header word %d = %08x\n", 69, rbf_data[69]);
-   debug("header word %d = %08x\n", 229, rbf_data[229]);
-   debug("read from rbf header: encrypt=%d compress=%d\n", encrypt, 
compress);
+   debug("FPGA: Header word %d = %08x.\n", 69, rbf_data[69]);
+   debug("FPGA: Header word %d = %08x.\n", 229, rbf_data[229]);
+   debug("FPGA: Read from rbf header: encrypt=%d compress=%d.\n", encrypt,
+compress);
 
/*
 * from the register map description of cdratio in imgcfg_ctrl_02:
@@ -455,10 +456,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, 
size_t rbf_size)
 {
int status;
 
-   /* disable all signals from hps peripheral controller to fpga */
+   /* Disable all signals from hps peripheral controller to fpga */
writel(0, _manager_base->fpgaintf_en_global);
 
-   /* disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
+   /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
socfpga_bridges_reset();
 
/* Initialize the FPGA Manager */
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 6/9] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b6ec..c870543346 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,10 +27,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 2/9] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v10
- Replaced both periph anc core image nodes "@1" and "@2" with "-1",
  the numeric associates the core and periph images in case where there
  are multiple.

changes for v9
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 00..adae997213
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core-1 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph-1", "fpga-core-1";
+   };
+   };
+};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 1/9] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a847..da210bfc86 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 0/9] Add support for loading FPGA bitstream

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved some comments from Simek in [v9].

This series is working on top of u-boot.git http://git.denx.de/u-boot.git

These patches are required before applying this series of patches
1. [U-Boot,v4] misc: fs_loader: Add support for initializing block device
https://patchwork.ozlabs.org/project/uboot/list/?series=89282(done review)

3. [U-Boot] misc: fs_loader: Replace label with DT phandle
https://patchwork.ozlabs.org/project/uboot/list/?series=92167(under review)

[v9]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (9):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Cleaning up the messages
  ARM: socfpga: Move the watchdog reset to the looping location
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 514 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 663 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2] misc: fs_loader: Replace label with DT phandle

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

In previously label which will be expanded to the node's full path was
used, and now replacing label with most commonly used DT phandle. The
codes were changed accordingly to the use of DT phandle and supporting
multiple instances.

Signed-off-by: Tien Fong Chee 

---

changes for v2
- Removed the @0 for fs-loader example.
---
 doc/driver-model/fs_firmware_loader.txt | 62 ++---
 drivers/misc/fs_loader.c| 36 ---
 2 files changed, 64 insertions(+), 34 deletions(-)

diff --git a/doc/driver-model/fs_firmware_loader.txt 
b/doc/driver-model/fs_firmware_loader.txt
index b9aee848cc..8be6185371 100644
--- a/doc/driver-model/fs_firmware_loader.txt
+++ b/doc/driver-model/fs_firmware_loader.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Intel Corporation 
+# Copyright (C) 2018-2019 Intel Corporation 
 #
 # SPDX-License-Identifier:GPL-2.0
 
@@ -27,7 +27,7 @@ Firmware storage device described in device tree source
defined in fs-loader node as shown in below:
 
Example for block device:
-   fs_loader0: fs-loader@0 {
+   fs_loader0: fs-loader {
u-boot,dm-pre-reloc;
compatible = "u-boot,fs-loader";
phandlepart = < 1>;
@@ -39,22 +39,55 @@ Firmware storage device described in device tree source
device, it can be described in FDT as shown in below:
 
Example for ubi:
-   fs_loader1: fs-loader@1 {
+   fs_loader1: fs-loader {
u-boot,dm-pre-reloc;
compatible = "u-boot,fs-loader";
mtdpart = "UBI",
ubivol = "ubi0";
};
 
-   Then, firmware_loader property would be set with the path of fs_loader
-   node under /chosen node such as:
+   Then, firmware-loader property can be added with any device node, which
+   driver would use the firmware loader for loading.
+
+   The value of the firmware-loader property should be set with phandle
+   of the fs-loader node.
+   For example:
+   firmware-loader = <_loader0>;
+
+   If there are majority of devices using the same fs-loader node, then
+   firmware-loader property can be added under /chosen node instead of
+   adding to each of device node.
+
+   For example:
/{
chosen {
-   firmware_loader = _loader0;
+   firmware-loader = <_loader0>;
};
};
 
-   However, this driver is also designed to support U-boot environment
+   In each respective driver of devices using firmware loader, the firmware
+   loaded instance should be created by DT phandle.
+
+   For example of getting DT phandle from /chosen and creating instance:
+   chosen_node = ofnode_path("/chosen");
+   if (!ofnode_valid(chosen_node)) {
+   debug("/chosen node was not found.\n");
+   return -ENOENT;
+   }
+
+   phandle_p = ofnode_get_property(chosen_node, "firmware-loader", );
+   if (!phandle_p) {
+   debug("firmware-loader property was not found.\n");
+   return -ENOENT;
+   }
+
+   phandle = fdt32_to_cpu(*phandle_p);
+   ret = uclass_get_device_by_phandle_id(UCLASS_FS_FIRMWARE_LOADER,
+phandle, );
+   if (ret)
+   return ret;
+
+   Firmware loader driver is also designed to support U-boot environment
variables, so all these data from FDT can be overwritten
through the U-boot environment variable during run time.
For examples:
@@ -104,9 +137,12 @@ return:
 Description:
The firmware is loaded directly into the buffer pointed to by buf
 
-Example of creating firmware loader instance and calling
-request_firmware_into_buf API:
-   if (uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
-   request_firmware_into_buf(dev, filename, buffer_location,
-buffer_size, offset_ofreading);
-   }
+Example of calling request_firmware_into_buf API after creating firmware loader
+instance:
+   ret = uclass_get_device_by_phandle_id(UCLASS_FS_FIRMWARE_LOADER,
+phandle, );
+   if (ret)
+   return ret;
+
+   request_firmware_into_buf(dev, filename, buffer_location, buffer_size,
+offset_ofreading);
diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index a2e3763c19..f42eeff8f6 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
  /*
- * Copyright (C) 2018 Intel Corporation 
+ * Copyright (C) 2018-2019 Intel Corporation 
  *
  */
 #include 
@@ -219,32 +219,26 @@ int request_firmware_into_buf(struct udevice *dev,
 
 static int fs

[U-Boot] [PATCH v10 9/9] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb29bc..548b458e78 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 7/9] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v10
- Removed the static so the function can be referred by other c file.

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.

# Conflicts:
#   arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
---
 .../include/mach/fpga_manager_arria10.h|  1 +
 arch/arm/mach-socfpga/spl_a10.c| 31 +-
 drivers/fpga/socfpga_arria10.c |  2 +-
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index c5f67714aa..62249b3695 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -126,6 +126,7 @@ int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
 const char *get_fpga_filename(void);
+int is_fpgamgr_early_user_mode(void);
 int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
  u32 offset);
 void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb424..4b658c87a3 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9df2c430d7..285280e507 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -69,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 5/9] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v10
-Cleaned up the codes.
-Return -EPERM when programing core on non early IO release mode.
-Using live function to get rid of gd->
-Removed @0 for fs-loader node

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 497 -
 include/image.h|   4 +
 4 files changed, 542 insertions(+), 15 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811210..cc761967c7 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6fd3..c5f67714aa 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+const char *get_fpga_filename(void);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 9499d1a014..9df2c430d7 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD_ADDRESS   0x400
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const struct socfpga_fpga_manager *fpga_manager_base =
(void

[U-Boot] [PATCH v10 2/9] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v10
- Replaced both image nodes "@1" and "@2" with "-1" and "-2" respectively.

changes for v9
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 00..368de88085
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core-2 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph-1", "fpga-core-2";
+   };
+   };
+};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 8/9] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index c870543346..bdbf90ed44 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,7 +33,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -43,11 +43,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 6/9] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b6ec..c870543346 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,10 +27,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 4/9] ARM: socfpga: Move the watchdog reset to the looping location

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the watchdog is reset timely if the looping is long.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index b0abe1955c..9499d1a014 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -360,6 +360,7 @@ static int fpgamgr_program_poll_cd(void)
printf("nstatus == 0 while waiting for condone\n");
return -EPERM;
}
+   WATCHDOG_RESET();
}
 
if (i == FPGA_TIMEOUT_CNT)
@@ -433,7 +434,6 @@ int fpgamgr_program_finish(void)
printf("FPGA: Poll CD failed with error code %d\n", status);
return -EPERM;
}
-   WATCHDOG_RESET();
 
/* Ensure the FPGA entering user mode */
status = fpgamgr_program_poll_usermode();
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 1/9] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a847..da210bfc86 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 3/9] ARM: socfpga: Cleaning up the messages

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the comment and debug messages are always consistent with the rest.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/socfpga_arria10.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd910ab..b0abe1955c 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -94,7 +94,7 @@ int fpgamgr_wait_early_user_mode(void)
i++;
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +172,10 @@ static int fpgamgr_set_cdratio_cdwidth(unsigned int 
cfg_width, u32 *rbf_data,
compress = (rbf_data[COMPRESSION_OFFSET] >> 1) & 1;
compress = !compress;
 
-   debug("header word %d = %08x\n", 69, rbf_data[69]);
-   debug("header word %d = %08x\n", 229, rbf_data[229]);
-   debug("read from rbf header: encrypt=%d compress=%d\n", encrypt, 
compress);
+   debug("FPGA: Header word %d = %08x.\n", 69, rbf_data[69]);
+   debug("FPGA: Header word %d = %08x.\n", 229, rbf_data[229]);
+   debug("FPGA: Read from rbf header: encrypt=%d compress=%d.\n", encrypt,
+compress);
 
/*
 * from the register map description of cdratio in imgcfg_ctrl_02:
@@ -455,10 +456,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, 
size_t rbf_size)
 {
int status;
 
-   /* disable all signals from hps peripheral controller to fpga */
+   /* Disable all signals from hps peripheral controller to fpga */
writel(0, _manager_base->fpgaintf_en_global);
 
-   /* disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
+   /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
socfpga_bridges_reset();
 
/* Initialize the FPGA Manager */
-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v10 0/9] Add support for loading FPGA bitstream

2019-03-05 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved some comments from Simek in [v9].

This series is working on top of u-boot.git http://git.denx.de/u-boot.git

These patches are required before applying this series of patches
1. [U-Boot,v4] misc: fs_loader: Add support for initializing block device
https://patchwork.ozlabs.org/project/uboot/list/?series=89282(done review)

3. [U-Boot] misc: fs_loader: Replace label with DT phandle
https://patchwork.ozlabs.org/project/uboot/list/?series=92167(under review)

[v9]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (9):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Cleaning up the messages
  ARM: socfpga: Move the watchdog reset to the looping location
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 514 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 663 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.13.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 6/7] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index c870543..bdbf90e 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,7 +33,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -43,11 +43,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 5/7] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v9
- Used ALLOC_CACHE_ALIGN_BUFFER
- De-duplicated the same chunks of codes

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.
---
 arch/arm/mach-socfpga/spl_a10.c | 31 ++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb..4b658c8 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,11 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+
+#define FPGA_BUFSIZ16 * 1024
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +73,35 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   ALLOC_CACHE_ALIGN_BUFFER(char, buf, FPGA_BUFSIZ);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode())
+   fpgamgr_program(buf, FPGA_BUFSIZ, 0);
 }
 
 void board_init_f(ulong dummy)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 7/7] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb2..548b458 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 3/7] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v9
- Support data offset
- Added default DDR load address
- Squashed the image.h
- Changed to phandle
- Ensure the DDR is fully up running by checking the gd->ram

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 drivers/fpga/socfpga_arria10.c | 533 -
 include/image.h|   4 +
 4 files changed, 571 insertions(+), 23 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811..9d43111 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = <_loader0>;
+   };
+
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6..7a4f723 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,40 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+int is_fpgamgr_early_user_mode(void);
+const char *get_fpga_filename(const void *fdt, int *len);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
+void fpgamgr_program(const void *buf, size_t bsize, u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd91..9936b69 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -21,6 +23,9 @@
 #define COMPRESSION_OFFSET 229
 #define FPGA_TIMEOUT_MSEC  1000  /* timeout in ms */
 #define FPGA_TIMEOUT_CNT   0x100
+#define DEFAULT_DDR_LOAD_ADDRESS   0x400
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static const struct socfpga_fpga_manager *fpga_manager_base =
(void *)SOCFPGA_FPGAMGRREGS_ADDRESS;
@@ -64,7 +69,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);

[U-Boot] [PATCH v9 4/7] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b..c870543 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,10 +27,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 2/7] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Reordered the images and fpga configurations.
- Removed the load property at core image.

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 38 +
 1 file changed, 38 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 000..df84562
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-periph@1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+
+   fpga-core@2 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph@1", "fpga-core@2";
+   };
+   };
+};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 1/7] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a..da210bf 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v9 0/7] Add support for loading FPGA bitstream

2019-02-18 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved comments from Marek in [v8].

This series is working on top of u-boot.git -  http://git.denx.de/u-boot.git .

These patches are required before applying this series of patches
1. [U-Boot,v4] misc: fs_loader: Add support for initializing block device
https://patchwork.ozlabs.org/project/uboot/list/?series=89282 (done review)

2 a. [U-Boot,v3,1/2] fs: fat: dynamically allocate memory for temporary buffer
  b. [U-Boot,v3,2/2] fs: fat: Reduce default max clustersize 64KiB from malloc
 pool
https://patchwork.ozlabs.org/project/uboot/list/?series=91135 (under review)

3. [U-Boot] misc: fs_loader: Replace label with DT phandle
https://patchwork.ozlabs.org/project/uboot/list/?series=92167 (under review)

[v8]: https://www.mail-archive.com/u-boot@lists.denx.de/msg316086.html
[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html


Tien Fong Chee (7):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  40 +-
 arch/arm/mach-socfpga/spl_a10.c|  31 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  38 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 533 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 682 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] fpga: Replace char * with const char * for filename

2019-02-14 Thread tien . fong . chee
From: Tien Fong Chee 

Ensure the string for filename is always constant, otherwise it can be
corrupted by the writing.

Signed-off-by: Tien Fong Chee 
---
 drivers/fpga/zynqpl.c |3 ++-
 include/fpga.h|2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/fpga/zynqpl.c b/drivers/fpga/zynqpl.c
index 499310d..683cf14 100644
--- a/drivers/fpga/zynqpl.c
+++ b/drivers/fpga/zynqpl.c
@@ -421,7 +421,8 @@ static int zynq_loadfs(xilinx_desc *desc, const void *buf, 
size_t bsize,
loff_t blocksize, actread;
loff_t pos = 0;
int fstype;
-   char *interface, *dev_part, *filename;
+   char *interface, *dev_part;
+   const char *filename;
 
blocksize = fsinfo->blocksize;
interface = fsinfo->interface;
diff --git a/include/fpga.h b/include/fpga.h
index 195f0bd..51de5c5 100644
--- a/include/fpga.h
+++ b/include/fpga.h
@@ -41,7 +41,7 @@ typedef struct {/* typedef fpga_desc */
unsigned int blocksize;
char *interface;
char *dev_part;
-   char *filename;
+   const char *filename;
int fstype;
 } fpga_fs_info;
 
-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] misc: fs_loader: Replace label with DT phandle

2019-02-14 Thread tien . fong . chee
From: Tien Fong Chee 

In previously label which will be expanded to the node's full path was
used, and now replacing label with most commonly used DT phandle. The
codes were changed accordingly to the use of DT phandle and supporting
multiple instances.

Signed-off-by: Tien Fong Chee 
---
 doc/driver-model/fs_firmware_loader.txt |   58 +--
 drivers/misc/fs_loader.c|   36 ---
 2 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/doc/driver-model/fs_firmware_loader.txt 
b/doc/driver-model/fs_firmware_loader.txt
index b9aee84..d9f966e 100644
--- a/doc/driver-model/fs_firmware_loader.txt
+++ b/doc/driver-model/fs_firmware_loader.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2018 Intel Corporation 
+# Copyright (C) 2018-2019 Intel Corporation 
 #
 # SPDX-License-Identifier:GPL-2.0
 
@@ -46,15 +46,48 @@ Firmware storage device described in device tree source
ubivol = "ubi0";
};
 
-   Then, firmware_loader property would be set with the path of fs_loader
-   node under /chosen node such as:
+   Then, firmware-loader property can be added with any device node, which
+   driver would use the firmware loader for loading.
+
+   The value of the firmware-loader property should be set with phandle
+   of the fs-loader node.
+   For example:
+   firmware-loader = <_loader0>;
+
+   If there are majority of devices using the same fs-loader node, then
+   firmware-loader property can be added under /chosen node instead of
+   adding to each of device node.
+
+   For example:
/{
chosen {
-   firmware_loader = _loader0;
+   firmware-loader = <_loader0>;
};
};
 
-   However, this driver is also designed to support U-boot environment
+   In each respective driver of devices using firmware loader, the firmware
+   loaded instance should be created by DT phandle.
+
+   For example of getting DT phandle from /chosen and creating instance:
+   chosen_node = ofnode_path("/chosen");
+   if (!ofnode_valid(chosen_node)) {
+   debug("/chosen node was not found.\n");
+   return -ENOENT;
+   }
+
+   phandle_p = ofnode_get_property(chosen_node, "firmware-loader", );
+   if (!phandle_p) {
+   debug("firmware-loader property was not found.\n");
+   return -ENOENT;
+   }
+
+   phandle = fdt32_to_cpu(*phandle_p);
+   ret = uclass_get_device_by_phandle_id(UCLASS_FS_FIRMWARE_LOADER,
+phandle, );
+   if (ret)
+   return ret;
+
+   Firmware loader driver is also designed to support U-boot environment
variables, so all these data from FDT can be overwritten
through the U-boot environment variable during run time.
For examples:
@@ -104,9 +137,12 @@ return:
 Description:
The firmware is loaded directly into the buffer pointed to by buf
 
-Example of creating firmware loader instance and calling
-request_firmware_into_buf API:
-   if (uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
-   request_firmware_into_buf(dev, filename, buffer_location,
-buffer_size, offset_ofreading);
-   }
+Example of calling request_firmware_into_buf API after creating firmware loader
+instance:
+   ret = uclass_get_device_by_phandle_id(UCLASS_FS_FIRMWARE_LOADER,
+phandle, );
+   if (ret)
+   return ret;
+
+   request_firmware_into_buf(dev, filename, buffer_location, buffer_size,
+offset_ofreading);
diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index a2e3763..f42eeff 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
  /*
- * Copyright (C) 2018 Intel Corporation 
+ * Copyright (C) 2018-2019 Intel Corporation 
  *
  */
 #include 
@@ -219,32 +219,26 @@ int request_firmware_into_buf(struct udevice *dev,
 
 static int fs_loader_ofdata_to_platdata(struct udevice *dev)
 {
-   const char *fs_loader_path;
u32 phandlepart[2];
 
-   fs_loader_path = ofnode_get_chosen_prop("firmware-loader");
+   ofnode fs_loader_node = dev_ofnode(dev);
 
-   if (fs_loader_path) {
-   ofnode fs_loader_node;
+   if (ofnode_valid(fs_loader_node)) {
+   struct device_platdata *plat;
 
-   fs_loader_node = ofnode_path(fs_loader_path);
-   if (ofnode_valid(fs_loader_node)) {
-   struct device_platdata *plat;
-   plat = dev->platdata;
-
-   if (!ofnode_read_u32_array(fs_

[U-Boot] [PATCH v8 5/8] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added FIT related configs

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 8 
 1 file changed, 8 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b..c870543 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,10 +27,18 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 8/8] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x1) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb2..548b458 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 6/8] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.
---
 arch/arm/mach-socfpga/spl_a10.c | 41 -
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb..36003b1 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +70,48 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   char buf[16 * 1024] __aligned(ARCH_DMA_MINALIGN);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpga_fs_info fpga_fsinfo;
+   int len;
+
+   fpga_fsinfo.filename = get_fpga_filename(gd->fdt_blob, );
+
+   if (fpga_fsinfo.filename)
+   socfpga_loadfs(_fsinfo, buf, sizeof(buf), 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode()) {
+   fpga_fs_info fpga_fsinfo;
+   int len;
+
+   fpga_fsinfo.filename = get_fpga_filename(gd->fdt_blob, );
+
+   if (fpga_fsinfo.filename)
+   socfpga_loadfs(_fsinfo, buf, sizeof(buf), 0);
+   }
 }
 
 void board_init_f(ulong dummy)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 7/8] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Moved the FIT related configs to the patch of configuration for FPGA
  SoCFPGA A10 SoCDK.

changes for v7
- Keep minimal configs.
---
 configs/socfpga_arria10_defconfig | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index c870543..bdbf90e 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,7 +33,6 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
@@ -43,11 +43,14 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 4/8] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Added codes to discern bitstream type based on fpga node name.

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 467 -
 3 files changed, 500 insertions(+), 23 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811..14f1967 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,23 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6..5ef15bb 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+int is_fpgamgr_early_user_mode(void);
+char *get_fpga_filename(const void *fdt, int *len);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd91..630d5a3 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,8 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
-
 #include 
 #include 
 #include 
@@ -10,8 +9,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -64,7 +66,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
@@ -92,9 +94,10 @@ int fpgamgr_wait_early_user_mode(void)
sizeof(sync_data));
udelay(FPGA_TIMEOUT_MSEC);
i++;
+   WATCHDOG_RESET();
}
 
-   debug("Additional %i sync word needed\n", i);
+   debug("FPGA: Additional %i sync word needed\n", i);
 
/* restoring original CDRATIO */
fpgamgr_set_cd_ratio(cd_ratio);
@@ -172,9 +175,

[U-Boot] [PATCH v8 3/8] fit: Add function declarations to the header file

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Adding some function declarations to the header file, so these
functions can be referred by other C files.

Signed-off-by: Tien Fong Chee 
---
 include/image.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/include/image.h b/include/image.h
index 83a2d41..f839443 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1041,6 +1041,10 @@ int fit_check_format(const void *fit);
 
 int fit_conf_find_compat(const void *fit, const void *fdt);
 int fit_conf_get_node(const void *fit, const char *conf_uname);
+int fit_conf_get_prop_node_count(const void *fit, int noffset,
+   const char *prop_name);
+int fit_conf_get_prop_node_index(const void *fit, int noffset,
+   const char *prop_name, int index);
 
 /**
  * fit_conf_get_prop_node() - Get node refered to by a configuration
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 1/8] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Removed explanation about support for altr,bitstream-core

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a..da210bf 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,31 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : Fit image file name for both FPGA peripheral bitstream,
+  FPGA core bitstream and full bitstream.
 
-Example:
+  Full bitstream, consist of peripheral bitstream and core
+  bitstream.
+
+  FPGA peripheral bitstream is used to initialize FPGA IOs,
+  PLL, IO48 and DDR. This bitstream is required to get DDR up
+  running.
+
+  FPGA core bitstream contains FPGA design which is used to
+  program FPGA CRAM and ERAM.
+
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with full release or booting with early IO release, then
+  follow by entering early user mode:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +39,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 2/8] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 

---

changes for v8
- Changed the FPGA node name to fpga-core and fpga-periph for both core and
  periph bitstreams respectively.
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 39 +
 1 file changed, 39 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 000..8ce175b
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-core@1 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   load = <0x400>;
+   };
+
+   fpga-periph@2 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+
+   configurations {
+   default = "config-1";
+   config-1 {
+   description = "Boot with FPGA early IO release config";
+   fpga = "fpga-periph@2", "fpga-core@1";
+   };
+   };
+};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v8 0/8] Add support for loading FPGA bitstream

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

This version mainly resolved comments from Marek and Dalon L Westergreen in
[v7].

Additonal note:
---
There are a few solutions at this moment for solving the performance issue
1. Using absolute data position to allign the core bistream in fitImage.
2. SPL program periph bitstream, then using fpga loadmk for loading the core
   bitstream from DDR. This is work because there is no allignment performance
   issue when reading whole fitImage instead of offset to the fitImage.

This series is working on top of u-boot.git -
 http://git.denx.de/u-boot.git .

[v7]: https://www.mail-archive.com/u-boot@lists.denx.de/msg314511.html

Tien Fong Chee (8):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  fit: Add function declarations to the header file
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  17 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 arch/arm/mach-socfpga/spl_a10.c|  41 +-
 board/altera/arria10-socdk/fit_spl_fpga.its|  39 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  26 +-
 drivers/fpga/socfpga_arria10.c | 467 -
 include/configs/socfpga_common.h   |   4 +-
 include/image.h|   4 +
 9 files changed, 626 insertions(+), 32 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] fit: Add support for printing more than one FPGA node name

2019-02-13 Thread tien . fong . chee
From: Tien Fong Chee 

This would print out all the FPGA node names setting to fpga property.

Signed-off-by: Tien Fong Chee 
---
 common/image-fit.c |   14 +++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index ac901e1..816e17d 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -263,6 +263,7 @@ static void fit_conf_print(const void *fit, int noffset, 
const char *p)
int ret;
int fdt_index, loadables_index;
int ndepth;
+   ulong count;
 
/* Mandatory properties */
ret = fit_get_desc(fit, noffset, );
@@ -299,9 +300,16 @@ static void fit_conf_print(const void *fit, int noffset, 
const char *p)
printf("%s\n", uname);
}
 
-   uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL);
-   if (uname)
-   printf("%s  FPGA: %s\n", p, uname);
+   count = fit_conf_get_prop_node_count(fit, noffset, FIT_FPGA_PROP);
+
+   for (ndepth = 0; ndepth < count; ndepth++) {
+   int images_noffset = fit_conf_get_prop_node_index(fit, noffset,
+   FIT_FPGA_PROP, ndepth);
+   uname = fit_get_name(fit, images_noffset, NULL);
+
+   if (uname)
+   printf("%s  FPGA: %s\n", p, uname);
+   }
 
/* Print out all of the specified loadables */
for (loadables_index = 0;
-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] cmd: ximg.c: Add support for getting external data address and length

2019-02-12 Thread tien . fong . chee
From: Tien Fong Chee 

This function supports getting both data address and length for
existing FIT subimage and FIT external data.

Signed-off-by: Tien Fong Chee 
---
 cmd/ximg.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/ximg.c b/cmd/ximg.c
index 6880c74..0ca37b3 100644
--- a/cmd/ximg.c
+++ b/cmd/ximg.c
@@ -159,9 +159,9 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char * 
const argv[])
}
}
 
-   /* get subimage data address and length */
-   if (fit_image_get_data(fit_hdr, noffset,
-   _data, _len)) {
+   /* get subimage/external data address and length */
+   if (fit_image_get_data_and_size(fit_hdr, noffset,
+  _data, _len)) {
puts("Could not find script subimage data\n");
return 1;
}
-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] fpga: Add support for getting external data address and length

2019-02-12 Thread tien . fong . chee
From: Tien Fong Chee 

This function supports getting both data address and length for
existing FPGA subimage and FPGA external data.

Signed-off-by: Tien Fong Chee 
---
 cmd/fpga.c |6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/fpga.c b/cmd/fpga.c
index 88a8e3f..b1f224b 100644
--- a/cmd/fpga.c
+++ b/cmd/fpga.c
@@ -343,9 +343,9 @@ static int do_fpga_loadmk(cmd_tbl_t *cmdtp, int flag, int 
argc,
return CMD_RET_FAILURE;
}
 
-   /* get fpga subimage data address and length */
-   if (fit_image_get_data(fit_hdr, noffset, _data,
-  _size)) {
+   /* get fpga subimage/external data address and length */
+   if (fit_image_get_data_and_size(fit_hdr, noffset,
+  _data, _size)) {
puts("Fpga subimage data not found\n");
return CMD_RET_FAILURE;
}
-- 
1.7.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

2019-02-10 Thread tien . fong . chee
From: Tien Fong Chee 

Release cluster block immediately when no longer use would help to reduce
64KiB memory allocated to the memory pool.

Signed-off-by: Tien Fong Chee 

---

changes for v3
- Dropped the if conditional because free(NULL) is valid.
---
 fs/fat/fat.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index ea11250..26ae101 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1151,7 +1151,15 @@ int file_fat_read_at(const char *filename, loff_t pos, 
void *buffer,
goto out_free_both;
 
debug("reading %s at pos %llu\n", filename, pos);
-   ret = get_contents(, itr->dent, pos, buffer, maxsize, actread);
+
+   /* For saving default max clustersize memory allocated to malloc pool */
+   dir_entry *dentptr = itr->dent;
+
+   free(itr);
+
+   itr = NULL;
+
+   ret = get_contents(, dentptr, pos, buffer, maxsize, actread);
 
 out_free_both:
free(fsdata.fatbuf);
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 1/2] fs: fat: dynamically allocate memory for temporary buffer

2019-02-10 Thread tien . fong . chee
From: Tien Fong Chee 

Drop the statically allocated get_contents_vfatname_block and
dynamically allocate a buffer only if required. This saves
64KiB of memory.

Signed-off-by: Stefan Agner 
Signed-off-by: Tien Fong Chee 

---

changes for v3
- Removed the cast on actsize
---
 fs/fat/fat.c | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index ecfa255..ea11250 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -306,9 +306,6 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, 
unsigned long size)
  * into 'buffer'.
  * Update the number of bytes read in *gotsize or return -1 on fatal errors.
  */
-__u8 get_contents_vfatname_block[MAX_CLUSTSIZE]
-   __aligned(ARCH_DMA_MINALIGN);
-
 static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos,
__u8 *buffer, loff_t maxsize, loff_t *gotsize)
 {
@@ -351,15 +348,24 @@ static int get_contents(fsdata *mydata, dir_entry 
*dentptr, loff_t pos,
 
/* align to beginning of next cluster if any */
if (pos) {
+   __u8 *tmp_buffer;
+
actsize = min(filesize, (loff_t)bytesperclust);
-   if (get_cluster(mydata, curclust, get_contents_vfatname_block,
-   (int)actsize) != 0) {
+   tmp_buffer = malloc_cache_aligned(actsize);
+   if (!tmp_buffer) {
+   debug("Error: allocating buffer\n");
+   return -ENOMEM;
+   }
+
+   if (get_cluster(mydata, curclust, tmp_buffer, actsize) != 0) {
printf("Error reading cluster\n");
+   free(tmp_buffer);
return -1;
}
filesize -= actsize;
actsize -= pos;
-   memcpy(buffer, get_contents_vfatname_block + pos, actsize);
+   memcpy(buffer, tmp_buffer + pos, actsize);
+   free(tmp_buffer);
*gotsize += actsize;
if (!filesize)
return 0;
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 5/7] spl : socfpga: Implement fpga bitstream loading with socfpga loadfs

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Add support for loading FPGA bitstream to get DDR up running before
U-Boot is loaded into DDR. Boot device initialization, generic firmware
loader and SPL FAT support are required for this whole mechanism to work.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Removed casting for get_fpga_filename
- Removed hard coding DDR address for loading core bistream, using loadable
  property from FIT.
- Added checking for config_pins, return if error.
---
 arch/arm/mach-socfpga/spl_a10.c | 46 -
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index c97eacb..dae3b8c 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
- *  Copyright (C) 2012 Altera Corporation 
+ *  Copyright (C) 2012-2019 Altera Corporation 
  */
 
 #include 
@@ -23,6 +23,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -68,11 +70,53 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
+   char buf[16 * 1024] __aligned(ARCH_DMA_MINALIGN);
+
/* enable console uart printing */
preloader_console_init();
WATCHDOG_RESET();
 
arch_early_init_r();
+
+   /* If the full FPGA is already loaded, ie.from EPCQ, config fpga pins */
+   if (is_fpgamgr_user_mode()) {
+   int ret = config_pins(gd->fdt_blob, "shared");
+   if (ret)
+   return;
+
+   ret = config_pins(gd->fdt_blob, "fpga");
+   if (ret)
+   return;
+   } else if (!is_fpgamgr_early_user_mode()) {
+   /* Program IOSSM(early IO release) or full FPGA */
+   fpga_fs_info fpga_fsinfo;
+   int len;
+
+   fpga_fsinfo.filename = get_fpga_filename(
+   gd->fdt_blob,
+   ,
+   FPGA_SOCFPGA_A10_RBF_PERIPH);
+
+   if (fpga_fsinfo.filename)
+   socfpga_loadfs(_fsinfo, buf, sizeof(buf), 0);
+   }
+
+   /* If the IOSSM/full FPGA is already loaded, start DDR */
+   if (is_fpgamgr_early_user_mode() || is_fpgamgr_user_mode())
+   ddr_calibration_sequence();
+
+   if (!is_fpgamgr_user_mode()) {
+   fpga_fs_info fpga_fsinfo;
+   int len;
+
+   fpga_fsinfo.filename = get_fpga_filename(
+   gd->fdt_blob,
+   ,
+   FPGA_SOCFPGA_A10_RBF_CORE);
+
+   if (fpga_fsinfo.filename)
+   socfpga_loadfs(_fsinfo, buf, sizeof(buf), 0);
+   }
 }
 
 void board_init_f(ulong dummy)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 3/7] ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Add FPGA driver to support program FPGA with FPGA bitstream loading from
filesystem. The driver are designed based on generic firmware loader
framework. The driver can handle FPGA program operation from loading FPGA
bitstream in flash to memory and then to program FPGA.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Restructure the FPGA driver to support both peripheral bitstream and core
  bitstream bundled into FIT image.
- Support loadable property for core bitstream. User can set loadable
  in DDR for better performance. This loading would be done in one large
  chunk instead of chunk by chunk loading with small memory buffer.
---
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  18 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 drivers/fpga/socfpga_arria10.c | 417 -
 3 files changed, 457 insertions(+), 17 deletions(-)

diff --git a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts 
b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
index 998d811..dc55618 100644
--- a/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
+++ b/arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
@@ -18,6 +18,24 @@
 /dts-v1/;
 #include "socfpga_arria10_socdk.dtsi"
 
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs-loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+};
+
+_mgr {
+   u-boot,dm-pre-reloc;
+   altr,bitstream = "fit_spl_fpga.itb";
+   altr,bitstream-core = "fit_spl_fpga.itb";
+};
+
  {
u-boot,dm-pre-reloc;
status = "okay";
diff --git a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h 
b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
index 09d13f6..683c84c 100644
--- a/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
+++ b/arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h
@@ -1,9 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  * All rights reserved.
  */
 
+#include 
+#include 
+#include 
+
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
@@ -51,6 +55,10 @@
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CFGWIDTH_SET_MSK BIT(24)
 #define ALT_FPGAMGR_IMGCFG_CTL_02_CDRATIO_LSB  16
 
+#define FPGA_SOCFPGA_A10_RBF_UNENCRYPTED   0xa65c
+#define FPGA_SOCFPGA_A10_RBF_ENCRYPTED 0xa65d
+#define FPGA_SOCFPGA_A10_RBF_PERIPH0x0001
+#define FPGA_SOCFPGA_A10_RBF_CORE  0x8001
 #ifndef __ASSEMBLY__
 
 struct socfpga_fpga_manager {
@@ -88,12 +96,39 @@ struct socfpga_fpga_manager {
u32  imgcfg_fifo_status;
 };
 
+enum rbf_type {
+   unknown,
+   periph_section,
+   core_section
+};
+
+enum rbf_security {
+   invalid,
+   unencrypted,
+   encrypted
+};
+
+struct rbf_info {
+   enum rbf_type section;
+   enum rbf_security security;
+};
+
+struct fpga_loadfs_info {
+   fpga_fs_info *fpga_fsinfo;
+   u32 remaining;
+   u32 offset;
+   struct rbf_info rbfinfo;
+};
+
 /* Functions */
 int fpgamgr_program_init(u32 * rbf_data, size_t rbf_size);
 int fpgamgr_program_finish(void);
 int is_fpgamgr_user_mode(void);
 int fpgamgr_wait_early_user_mode(void);
-
+int is_fpgamgr_early_user_mode(void);
+char *get_fpga_filename(const void *fdt, int *len, u32 rbf_type);
+int socfpga_loadfs(fpga_fs_info *fpga_fsinfo, const void *buf, size_t bsize,
+ u32 offset);
 #endif /* __ASSEMBLY__ */
 
 #endif /* _FPGA_MANAGER_ARRIA10_H_ */
diff --git a/drivers/fpga/socfpga_arria10.c b/drivers/fpga/socfpga_arria10.c
index 114dd91..019dbd3 100644
--- a/drivers/fpga/socfpga_arria10.c
+++ b/drivers/fpga/socfpga_arria10.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2017 Intel Corporation 
+ * Copyright (C) 2017-2019 Intel Corporation 
  */
 
 #include 
@@ -10,8 +10,11 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
@@ -64,7 +67,7 @@ static int wait_for_user_mode(void)
1, FPGA_TIMEOUT_MSEC, false);
 }
 
-static int is_fpgamgr_early_user_mode(void)
+int is_fpgamgr_early_user_mode(void)
 {
return (readl(_manager_base->imgcfg_stat) &
ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK) != 0;
@@ -447,27 +450,411 @@ int fpgamgr_program_finish(void)
return 0;
 }
 
-/*
- * FPGA Manager to program the FPGA. This is the interface used by FPGA driver.
- * Return 0 for sucess, non-zero for error.
- */
+char *get_fpga_filename(const void *fdt, int *len, u32 rbf_type)
+{
+   char *fpga_filename = NULL;
+   int node_offset;
+
+   fdtdec_find_aliases_for_id(gd->fdt_blob, "fpga_mgr",
+   COMPAT_ALTERA_SOCFPGA_FPGA0

[U-Boot] [PATCH v7 4/7] ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
to get the SoCFPGA loadfs driver support. This would enable the
implementation of programming bitstream into FPGA from MMC.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Removed limit set for CONFIG_FS_FAT_MAX_CLUSTSIZE
---
 configs/socfpga_arria10_defconfig | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index 0554f1b..fc0dfa4 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -27,9 +27,15 @@ CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
 # CONFIG_EFI_PARTITION is not set
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
+CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 7/7] ARM: socfpga: Increase Malloc pool size to support FAT filesystem in SPL

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

After some series of patches to maximise reusable of memory pool, here come
to result of reasonable size required for whole SDMMC boot working on A10
SoCDK. Size required come from default max cluster(0x10) +
others(0x2000) + additional memory for headroom(0x3000).

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Added 0x3000 for memory headroom.
---
 include/configs/socfpga_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 4551cb2..548b458 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Copyright (C) 2012 Altera Corporation 
+ * Copyright (C) 2012-2019 Altera Corporation 
  */
 #ifndef __CONFIG_SOCFPGA_COMMON_H__
 #define __CONFIG_SOCFPGA_COMMON_H__
@@ -258,7 +258,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 /* SPL memory allocation configuration, this is for FAT implementation */
 #ifndef CONFIG_SYS_SPL_MALLOC_START
-#define CONFIG_SYS_SPL_MALLOC_SIZE 0x0001
+#define CONFIG_SYS_SPL_MALLOC_SIZE 0x00015000
 #define CONFIG_SYS_SPL_MALLOC_START(CONFIG_SYS_INIT_RAM_SIZE - \
 CONFIG_SYS_SPL_MALLOC_SIZE + \
 CONFIG_SYS_INIT_RAM_ADDR)
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 1/7] ARM: socfpga: Description on FPGA bitstream type and file name for Arria 10

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

This patch adds description on properties about file name used for both
peripheral bitstream and core bitstream.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Provided example of setting FPGA FIT image for both early IO release
  and full release FPGA configuration.
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   | 34 +-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt 
b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
index 2fd8e7a..5f81a32 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
@@ -7,8 +7,39 @@ Required properties:
- The second index is for writing FPGA configuration data.
 - resets : Phandle and reset specifier for the device's reset.
 - clocks : Clocks used by the device.
+- altr,bitstream : File name for FPGA peripheral bitstream which is used
+  to initialize FPGA IOs, PLL, IO48 and DDR. This bitstream is
+  required to get DDR up running.
+  or
+  File name for full bitstream, consist of peripheral bitstream
+  and core bitstream.
+- altr,bitstream-core(optional) : File name for core bitstream which contains
+ FPGA design which is used to program FPGA CRAM
+ and ERAM.
 
-Example:
+Example: Bundles both peripheral bitstream and core bitstream into FIT image
+called fit_spl_fpga.itb. This FIT image can be created through running
+this command: tools/mkimage
+  -E -p 400
+  -f board/altera/arria10-socdk/fit_spl_fpga.its
+  fit_spl_fpga.itb
+
+For details of describing structure and contents of the FIT image,
+please refer board/altera/arria10-socdk/fit_spl_fpga.its
+
+- Examples for booting with early IO release, and enter early user mode:
+
+   fpga_mgr: fpga-mgr@ffd03000 {
+   compatible = "altr,socfpga-a10-fpga-mgr";
+   reg = <0xffd03000 0x100
+  0xffcfe400 0x20>;
+   clocks = <_mp_clk>;
+   resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
+   altr,bitstream-core = "fit_spl_fpga.itb";
+   };
+
+- Examples for booting with full release, enter user mode with full bitstream:
 
fpga_mgr: fpga-mgr@ffd03000 {
compatible = "altr,socfpga-a10-fpga-mgr";
@@ -16,4 +47,5 @@ Example:
   0xffcfe400 0x20>;
clocks = <_mp_clk>;
resets = < FPGAMGR_RESET>;
+   altr,bitstream = "fit_spl_fpga.itb";
};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 0/7] Add support for loading FPGA bitstream

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

These series of patches enable peripheral bitstream being programmed into FPGA
to get the DDR up running. This's also called early IO release, because the
peripheral bitstream is only initializing FPGA IOs, PLL, IO48 and DDR.

Once DDR is up running, core bitstream from MMC which contains user FPGA
design would be loaded into DDR location. socfpga loadfs would be called to
program core bitstream into FPGA and entering user mode.

Lastly, u-boot-dtb.img from MMC FAT partition would be loaded to DDR, and up
running from there.

For this whole mechanism to work, the SDMMC flash layout would be designed as
shown in below:

RAW partition:
1. spl_w_dtb-mkpimage.bin
mkpimage -hv 1 -o spl/spl_w_dtb-mkpimage.bin spl/u-boot-spl-dtb.bin
 spl/u-boot-spl-dtb.bin spl/u-boot-spl-dtb.bin spl/u-boot-spl-dtb.bin

FAT partition contains:
FPGA FIT image(fit_spl_fpga.itb)

Early IO release method is recommended for the sake of performance, improve
up to 86% compare to full bitstream.

To generate FPGA FIT image for Early IO release, runs this command:
tools/mkimage -E -p 400
 -f board/altera/arria10-socdk/fit_spl_fpga.its fit_spl_fpga.itb

Before running above command, ensure U-Boot source directory contains both
peripheral bitstream(ghrd_10as066n2.periph.rbf) and
core bitstream(ghrd_10as066n2.core.rbf_.

For details of describing structure and contents of the FIT image,
please refer board/altera/arria10-socdk/fit_spl_fpga.its

Additonal note:
---
There is performance penalty if the memory used for loading
the bitstream is unalligned to ARCH_DMA_MINALIGN inside function
"static int
get_cluster()" in fs/fat/fat.c. Sometimes child functions would alter the
memory location and causing unalligned to ARCH_DMA_MINALIGN. This only happend
when reading a FAT file by offset.

To avoid performance penalty, core bitstream(fpga-2) contains large size should
be at 1st then following by peripheral bitstream(fpga-1) as shown in
fit_spl_fpga.its.

After that, enable the DEBUG in fs/fat/fat.c and ensure no
print out "FAT: Misaligned buffer address (%p)" when loading core bitstream on
SPL console. Print out when loading peripheral bitstream can be ignored because
the size is too small.

If there is print out, please set an allign data position by running mkimage
with optional -p xxx when generating FIT image. 

U-Boot image

3. u-boot-dtb.img

For the testing purpose, these 3 series of patches are required to apply 1st
before applying this series of patches.
1. [U-Boot] [PATCH v4] misc: fs_loader: Add support for initializing block
   device
   https://www.mail-archive.com/u-boot@lists.denx.de/msg314453.html
   Version 4 under review

2. [U-Boot] [PATCH v2 1/4] spl: Kconfig: Replace CONFIG_SPL_FAT_SUPPORT with
   CONFIG_SPL_FS_FAT
   https://www.mail-archive.com/u-boot@lists.denx.de/msg313259.html
   All series Reviewed-by: Tom Rini 
   Some patches of the series Reviewed-by: Simon Goldschmidt

3. [U-Boot] [PATCH v2 1/2] fs: fat: dynamically allocate memory for temporary
   buffer
   https://www.mail-archive.com/u-boot@lists.denx.de/msg314470.html
   Version 2 under review

This series is working on top of u-boot.git -
 http://git.denx.de/u-boot.git .

Tien Fong Chee (7):
  ARM: socfpga: Description on FPGA bitstream type and file name for
Arria 10
  ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK
  ARM: socfpga: Add FPGA drivers for Arria 10 FPGA bitstream loading
  ARM: socfpga: Add the configuration for FPGA SoCFPGA A10 SoCDK
  spl : socfpga: Implement fpga bitstream loading with socfpga loadfs
  ARM: socfpga: Synchronize the configuration for A10 SoCDK
  ARM: socfpga: Increase Malloc pool size to support FAT filesystem in
SPL

 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts   |  18 +
 .../include/mach/fpga_manager_arria10.h|  39 +-
 arch/arm/mach-socfpga/spl_a10.c|  46 ++-
 board/altera/arria10-socdk/fit_spl_fpga.its|  31 ++
 configs/socfpga_arria10_defconfig  |  21 +-
 .../fpga/altera-socfpga-a10-fpga-mgr.txt   |  34 +-
 drivers/fpga/socfpga_arria10.c | 417 -
 include/configs/socfpga_common.h   |   4 +-
 8 files changed, 584 insertions(+), 26 deletions(-)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 6/7] ARM: socfpga: Synchronize the configuration for A10 SoCDK

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Update the default configuration file to enable the necessary functionality
the get the kit working.

Signed-off-by: Tien Fong Chee 

---

changes for v7
- Keep minimal configs
---
 configs/socfpga_arria10_defconfig | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index fc0dfa4..bdbf90e 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -10,10 +10,13 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 # CONFIG_USE_BOOTCOMMAND is not set
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_VERSION_VARIABLE=y
 CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_SPL_FPGA_SUPPORT=y
-CONFIG_SPL_SPI_LOAD=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
@@ -22,9 +25,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_MTDIDS_DEFAULT="nor0=ff705000.spi.0"
-# CONFIG_SPL_DOS_PARTITION is not set
-# CONFIG_ISO_PARTITION is not set
-# CONFIG_EFI_PARTITION is not set
+CONFIG_OF_SPL_REMOVE_PROPS="interrupts interrupt-parent dmas dma-names"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_ENV_SUPPORT=y
@@ -32,20 +33,24 @@ CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_SPL_DM_MMC=y
 CONFIG_SPL_MMC_SUPPORT=y
-CONFIG_SPL_EXT_SUPPORT=y
 CONFIG_SPL_FS_FAT=y
 CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
 CONFIG_FS_LOADER=y
 CONFIG_FPGA_SOCFPGA=y
+CONFIG_SPL_FIT=y
+CONFIG_FIT=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MTD_DEVICE=y
+CONFIG_MMC_DW=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_MII=y
+CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_DESIGNWARE_APB_TIMER=y
-CONFIG_USE_TINY_PRINTF=y
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 2/7] ARM: socfpga: Add default FPGA bitstream fitImage for Arria10 SoCDK

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Add default fitImage file bundling FPGA bitstreams for Arria10.

Signed-off-by: Tien Fong Chee 
---
 board/altera/arria10-socdk/fit_spl_fpga.its | 31 +
 1 file changed, 31 insertions(+)
 create mode 100644 board/altera/arria10-socdk/fit_spl_fpga.its

diff --git a/board/altera/arria10-socdk/fit_spl_fpga.its 
b/board/altera/arria10-socdk/fit_spl_fpga.its
new file mode 100644
index 000..46b125c
--- /dev/null
+++ b/board/altera/arria10-socdk/fit_spl_fpga.its
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0
+ /*
+ * Copyright (C) 2019 Intel Corporation 
+ *
+ */
+
+/dts-v1/;
+
+/ {
+   description = "FIT image with FPGA bistream";
+   #address-cells = <1>;
+
+   images {
+   fpga-2 {
+   description = "FPGA core bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.core.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   load = <0x400>;
+   };
+
+   fpga-1 {
+   description = "FPGA peripheral bitstream";
+   data = /incbin/("../../../ghrd_10as066n2.periph.rbf");
+   type = "fpga";
+   arch = "arm";
+   compression = "none";
+   };
+   };
+};
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 1/2] fs: fat: dynamically allocate memory for temporary buffer

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Drop the statically allocated get_contents_vfatname_block and
dynamically allocate a buffer only if required. This saves
64KiB of memory.

Signed-off-by: Stefan Agner 
Signed-off-by: Tien Fong Chee 

---

changes for v2
- Removed the change for debug message.
- Set allocation based on actual required size instead of default max
  cluster size
---
 fs/fat/fat.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index ecfa255..347787e 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -306,9 +306,6 @@ get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, 
unsigned long size)
  * into 'buffer'.
  * Update the number of bytes read in *gotsize or return -1 on fatal errors.
  */
-__u8 get_contents_vfatname_block[MAX_CLUSTSIZE]
-   __aligned(ARCH_DMA_MINALIGN);
-
 static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos,
__u8 *buffer, loff_t maxsize, loff_t *gotsize)
 {
@@ -351,15 +348,25 @@ static int get_contents(fsdata *mydata, dir_entry 
*dentptr, loff_t pos,
 
/* align to beginning of next cluster if any */
if (pos) {
+   __u8 *tmp_buffer;
+
actsize = min(filesize, (loff_t)bytesperclust);
-   if (get_cluster(mydata, curclust, get_contents_vfatname_block,
+   tmp_buffer = malloc_cache_aligned(actsize);
+   if (!tmp_buffer) {
+   debug("Error: allocating buffer\n");
+   return -ENOMEM;
+   }
+
+   if (get_cluster(mydata, curclust, tmp_buffer,
(int)actsize) != 0) {
printf("Error reading cluster\n");
+   free(tmp_buffer);
return -1;
}
filesize -= actsize;
actsize -= pos;
-   memcpy(buffer, get_contents_vfatname_block + pos, actsize);
+   memcpy(buffer, tmp_buffer + pos, actsize);
+   free(tmp_buffer);
*gotsize += actsize;
if (!filesize)
return 0;
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 2/2] fs: fat: Reduce default max clustersize 64KiB from malloc pool

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Release cluster block immediately when no longer use would help to reduce
64KiB memory allocated to the memory pool.

Signed-off-by: Tien Fong Chee 

---

changes for v2
- Assigned NULL to itr after free.
- Added NULL checking to itr, avoid freeing twice.
---
 fs/fat/fat.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 347787e..fa846ff 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -1152,12 +1152,21 @@ int file_fat_read_at(const char *filename, loff_t pos, 
void *buffer,
goto out_free_both;
 
debug("reading %s at pos %llu\n", filename, pos);
-   ret = get_contents(, itr->dent, pos, buffer, maxsize, actread);
+
+   /* For saving default max clustersize memory allocated to malloc pool */
+   dir_entry *dentptr = itr->dent;
+
+   free(itr);
+
+   itr = NULL;
+
+   ret = get_contents(, dentptr, pos, buffer, maxsize, actread);
 
 out_free_both:
free(fsdata.fatbuf);
 out_free_itr:
-   free(itr);
+   if (itr)
+   free(itr);
return ret;
 }
 
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4] misc: fs_loader: Add support for initializing block device

2019-01-31 Thread tien . fong . chee
From: Tien Fong Chee 

Firmware loader would encounter problem if the block device is accessed
before initializing it. This patch would adding the support of probing
block device and initializing block before the block device is accessed by
firmware loader.

Signed-off-by: Tien Fong Chee 

---

changes in v4
- Removed header mmc.h
- Dropped extra blank line

changes in v3:
- Initializing block device through probing the blk device

changes in v2:
- Initializing MMC through probing the blk device
---
 drivers/misc/fs_loader.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index 57a14a3..a2e3763 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -252,6 +252,29 @@ static int fs_loader_ofdata_to_platdata(struct udevice 
*dev)
 
 static int fs_loader_probe(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(BLK)
+   int ret;
+   struct device_platdata *plat = dev->platdata;
+
+   if (plat->phandlepart.phandle) {
+   ofnode node = ofnode_get_by_phandle(plat->phandlepart.phandle);
+   struct udevice *parent_dev = NULL;
+
+   ret = device_get_global_by_ofnode(node, _dev);
+   if (!ret) {
+   struct udevice *dev;
+
+   ret = blk_get_from_parent(parent_dev, );
+   if (ret) {
+   debug("fs_loader: No block device: %d\n",
+   ret);
+
+   return ret;
+   }
+   }
+   }
+#endif
+
return 0;
 };
 
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] misc: fs_loader: Add support for initializing block device

2019-01-24 Thread tien . fong . chee
From: Tien Fong Chee 

Firmware loader would encounter problem if the block device is accessed
before initializing it. This patch would adding the support of probing
block device and initializing block before the block device is accessed by
firmware loader.

Signed-off-by: Tien Fong Chee 

---

Changes in v3:
- Initializing block device through probing the blk device

Changes in v2:
- Initializing MMC through probing the blk device
---
 drivers/misc/fs_loader.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/misc/fs_loader.c b/drivers/misc/fs_loader.c
index 57a14a3..df35ec6 100644
--- a/drivers/misc/fs_loader.c
+++ b/drivers/misc/fs_loader.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -252,6 +253,31 @@ static int fs_loader_ofdata_to_platdata(struct udevice 
*dev)
 
 static int fs_loader_probe(struct udevice *dev)
 {
+#if CONFIG_IS_ENABLED(DM) && CONFIG_IS_ENABLED(BLK)
+   int ret;
+   struct device_platdata *plat = dev->platdata;
+
+   if (plat->phandlepart.phandle) {
+   ofnode node = ofnode_get_by_phandle(plat->phandlepart.phandle);
+
+   struct udevice *parent_dev = NULL;
+
+   ret = device_get_global_by_ofnode(node, _dev);
+
+   if (!ret) {
+   struct udevice *dev;
+
+   ret = blk_get_from_parent(parent_dev, );
+   if (ret) {
+   debug("fs_loader: No block device: %d\n",
+   ret);
+
+   return ret;
+   }
+   }
+   }
+#endif
+
return 0;
 };
 
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 4/4] spl: fat/fs: Add control to build FS EXT4 in SPL

2019-01-22 Thread tien . fong . chee
From: Tien Fong Chee 

CONFIG_SPL_FS_EXT4 can be used to include/exclude the FS EXT4 from
SPL build. Excluding the FS EXT4 from SPL build can help to save 20KiB
memory.

Signed-off-by: Tien Fong Chee 

---

changes in v2:
- Changed both config checking SPL_BUILD and FS_EXT4 to
  CONFIG_IS_ENABLED(FS_EXT4).
---
 fs/fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/fs.c b/fs/fs.c
index 48b8e9a..21adbde 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -183,7 +183,8 @@ static struct fstype_info fstypes[] = {
.closedir = fat_closedir,
},
 #endif
-#ifdef CONFIG_FS_EXT4
+
+#if CONFIG_IS_ENABLED(FS_EXT4)
{
.fstype = FS_TYPE_EXT,
.name = "ext4",
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 3/4] spl: Kconfig: Replace CONFIG_SPL_EXT_SUPPORT to CONFIG_SPL_FS_EXT4

2019-01-22 Thread tien . fong . chee
From: Tien Fong Chee 

Replace CONFIG_SPL_EXT_SUPPORT to CONFIG_SPLY_FS_EXT4 so both
obj-$(CONFIG_$(SPL_)FS_EXT4) and CONFIG_IS_ENABLED(FS_EXT4) can be
used to control the build in both SPL and U-Boot.

Signed-off-by: Tien Fong Chee 
---
 arch/arm/mach-k3/am6_init.c| 2 +-
 arch/arm/mach-omap2/Kconfig| 6 +++---
 arch/arm/mach-omap2/am33xx/Kconfig | 4 ++--
 arch/arm/mach-socfpga/spl_a10.c| 2 +-
 arch/arm/mach-socfpga/spl_gen5.c   | 2 +-
 arch/arm/mach-socfpga/spl_s10.c| 2 +-
 common/spl/Kconfig | 2 +-
 common/spl/Makefile| 2 +-
 common/spl/spl_mmc.c   | 6 +++---
 configs/am335x_baltos_defconfig| 2 +-
 configs/am335x_hs_evm_defconfig| 2 +-
 configs/am335x_hs_evm_uart_defconfig   | 2 +-
 configs/am335x_igep003x_defconfig  | 2 +-
 configs/am335x_shc_defconfig   | 2 +-
 configs/am335x_shc_ict_defconfig   | 2 +-
 configs/am335x_shc_netboot_defconfig   | 2 +-
 configs/am335x_shc_prompt_defconfig| 2 +-
 configs/am335x_shc_sdboot_defconfig| 2 +-
 configs/am335x_shc_sdboot_prompt_defconfig | 2 +-
 configs/am335x_sl50_defconfig  | 2 +-
 configs/am3517_crane_defconfig | 2 +-
 configs/am3517_evm_defconfig   | 2 +-
 configs/birdland_bav335a_defconfig | 2 +-
 configs/birdland_bav335b_defconfig | 2 +-
 configs/cgtqmx6eval_defconfig  | 2 +-
 configs/cl-som-am57x_defconfig | 2 +-
 configs/cm_t335_defconfig  | 2 +-
 configs/cm_t35_defconfig   | 2 +-
 configs/cm_t43_defconfig   | 2 +-
 configs/eco5pk_defconfig   | 2 +-
 configs/igep0032_defconfig | 2 +-
 configs/igep00x0_defconfig | 2 +-
 configs/mcx_defconfig  | 2 +-
 configs/mt_ventoux_defconfig   | 2 +-
 configs/mx6cuboxi_defconfig| 2 +-
 configs/mx6sabreauto_defconfig | 2 +-
 configs/mx6sabresd_defconfig   | 2 +-
 configs/mx6slevk_spl_defconfig | 2 +-
 configs/mx6sxsabresd_spl_defconfig | 2 +-
 configs/mx6ul_14x14_evk_defconfig  | 2 +-
 configs/mx6ul_9x9_evk_defconfig| 2 +-
 configs/novena_defconfig   | 2 +-
 configs/omap3_beagle_defconfig | 2 +-
 configs/omap3_evm_defconfig| 2 +-
 configs/omap3_ha_defconfig | 2 +-
 configs/omap4_panda_defconfig  | 2 +-
 configs/pcm051_rev1_defconfig  | 2 +-
 configs/pcm051_rev3_defconfig  | 2 +-
 configs/pcm058_defconfig   | 2 +-
 configs/pengwyn_defconfig  | 2 +-
 configs/pepper_defconfig   | 2 +-
 configs/pfla02_defconfig   | 2 +-
 configs/platinum_picon_defconfig   | 2 +-
 configs/platinum_titanium_defconfig| 2 +-
 configs/sksimx6_defconfig  | 2 +-
 configs/sniper_defconfig   | 2 +-
 configs/tao3530_defconfig  | 2 +-
 configs/twister_defconfig  | 2 +-
 configs/udoo_defconfig | 2 +-
 configs/udoo_neo_defconfig | 2 +-
 configs/wandboard_defconfig| 2 +-
 configs/xpress_spl_defconfig   | 2 +-
 configs/zc5202_defconfig   | 2 +-
 configs/zc5601_defconfig   | 2 +-
 doc/README.SPL | 2 +-
 fs/Makefile| 2 +-
 include/configs/imx6_spl.h | 2 +-
 include/configs/imx7_spl.h | 2 +-
 include/configs/socfpga_common.h   | 2 +-
 include/part.h | 2 +-
 70 files changed, 75 insertions(+), 75 deletions(-)

diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 4aef3cd..a555319 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -106,7 +106,7 @@ u32 spl_boot_mode(const u32 boot_device)
 #endif
 
/* Everything else use filesystem if available */
-#if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_EXT_SUPPORT)
+#if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
return MMCSD_MODE_FS;
 #else
return MMCSD_MODE_RAW;
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index 7293362..d29f1ca 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -13,7 +13,7 @@ config OMAP34XX
select ARM_ERRATA_725233
select USE_TINY_PRINTF
imply NAND_OMAP_GPMC
-   imply SPL_EXT_SUPPORT
+   imply SPL_FS_EXT4
imply SPL_FS_FAT
imply SPL_GPIO_SUPPORT
imply SPL_I2C_SUPPORT
@@ -35,7 +35,7 @@ config OMAP44XX
imply NAND_OMAP_ELM
imply NAND_OMAP_GPMC
imply SPL_DISPLAY_PRINT
-   imply SPL_EXT_SUPPORT
+   imply SPL_FS_EXT4
imply

[U-Boot] [PATCH v2 2/4] spl: fat/fs: Add option to include/exclude FAT write build in SPL

2019-01-22 Thread tien . fong . chee
From: Tien Fong Chee 

Most of the time SPL only needs very simple FAT reading, so having
CONFIG_IS_ENABLED(FAT_WRITE) to exclude it from SPL build would help
to save 64KiB default max clustersize from memory.

Signed-off-by: Tien Fong Chee 

---

Changes in v2:
- Changed to CONFIG_IS_ENABLED(FAT_WRITE) to control build for FAT write
int both SPL and U-Boot
- Changed to CONFIG_IS_ENABLED for config FS_FAT too.
---
 common/spl/Kconfig | 7 +++
 fs/fat/Makefile| 4 ++--
 fs/fat/fat.c   | 3 ++-
 fs/fs.c| 2 +-
 4 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 93e7fe9..9042117 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -403,6 +403,13 @@ config SPL_FS_FAT
  filesystem from within SPL. Support for the underlying block
  device (e.g. MMC or USB) must be enabled separately.
 
+config SPL_FAT_WRITE
+   bool "Support write for FAT filesystems"
+   help
+ Enable write support for FAT and VFAT filesystems with SPL.
+ Support for the underlying block device (e.g. MMC or USB) must be
+ enabled separately.
+
 config SPL_FPGA_SUPPORT
bool "Support FPGAs"
help
diff --git a/fs/fat/Makefile b/fs/fat/Makefile
index e64b61a..f84efac 100644
--- a/fs/fat/Makefile
+++ b/fs/fat/Makefile
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 
-obj-$(CONFIG_FS_FAT)   := fat.o
-obj-$(CONFIG_FAT_WRITE):= fat_write.o
+obj-$(CONFIG_$(SPL_)FS_FAT) = fat.o
+obj-$(CONFIG_$(SPL_)FAT_WRITE) = fat_write.o
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index ac8913e..ecfa255 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -145,7 +145,8 @@ static void get_name(dir_entry *dirent, char *s_name)
 }
 
 static int flush_dirty_fat_buffer(fsdata *mydata);
-#if !defined(CONFIG_FAT_WRITE)
+
+#if !CONFIG_IS_ENABLED(FAT_WRITE)
 /* Stub for read only operation */
 int flush_dirty_fat_buffer(fsdata *mydata)
 {
diff --git a/fs/fs.c b/fs/fs.c
index cb26517..48b8e9a 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -168,7 +168,7 @@ static struct fstype_info fstypes[] = {
.exists = fat_exists,
.size = fat_size,
.read = fat_read_file,
-#ifdef CONFIG_FAT_WRITE
+#if CONFIG_IS_ENABLED(FAT_WRITE)
.write = file_fat_write,
.unlink = fat_unlink,
.mkdir = fat_mkdir,
-- 
2.2.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


  1   2   3   4   5   >