Skip to contentSkip to conversation

Add FPGA driver, SDRAM driver, generic firmware loader and booting U-Boot.

PATCH Superseded tien.fong.chee at intel.com 3 participants 30 messages Dec 5, 2017 – Dec 8, 2017

Subsystems (5)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add FPGA driver, SDRAM driver, generic firmware loader and booting U-Boot.

From: Tien Fong Chee <[email protected]>

This patchset adding FPGA drivers, SDRAM drivers, and generic firmware loader. The patchset also enable fpga loadfs to program FPGA, SPL loading U-boot and booting to U-boot console. This version mainly resolved comments from Marek in [v4].

Please note that generic firmware loader is an independent driver, which can be used to load whatever into target location, then consumer driver would use it to program whatever, ie. the FPGA.

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

[v4]: https://www.mail-archive.com/u-boot at lists.denx.de/msg268160.html

v4 -> v5 changes:
-----------------
- Created generic firmware loader which is very similar to Linux firmware loader
- Changed the fpga loadfs driver to use generic firmware loader for loading RBF files from flash to memory and then program FPGA.

Patchset history
----------------
[v1]: https://www.mail-archive.com/u-boot at lists.denx.de/msg261831.html [v2]: https://www.mail-archive.com/u-boot at lists.denx.de/msg265192.html [v3]: https://www.mail-archive.com/u-boot at lists.denx.de/msg266981.html

Tien Fong Chee (20):
ARM: socfpga: Description on FPGA RBF properties at Arria 10 FPGA
manager
dts: Add FPGA bitstream properties to Arria 10 DTS
arm: socfpga: Add Arria 10 SoCFPGA programming interface
dts: Enable fpga-mgr node build for Arria 10 SPL
fs: Enable generic filesystems interface support in SPL.
arm: socfpga: Remove static declaration on spl_mmc_find_device
function
common: Generic firmware loader for file system
arm: socfpga: Fix with the correct polling on bit is set
arm: socfpga: Add FPGA drivers for Arria 10 FPGA loadfs
arm: socfpga: Rename the gen5 sdram driver to more specific name
arm: socfpga: Add DRAM bank size initialization function
arm: socfpga: Add DDR driver for Arria 10
configs: Add DDR Kconfig support for Arria 10
arm: socfpga: Enable SPL memory allocation
arm: socfpga: Improve comments for Intel SoCFPGA program header
arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10
arm: socfpga: Adding clock frequency info for U-Boot
arm: socfpga: Adding SoCFPGA info for both SPL and U-Boot
arm: socfpga: Enable DDR working
arm: socfpga: Enable SPL booting U-boot

 arch/arm/dts/socfpga_arria10.dtsi                  |   6 +
 arch/arm/mach-socfpga/Kconfig                      |   1 +
 arch/arm/mach-socfpga/board.c                      |  18 +
 arch/arm/mach-socfpga/include/mach/boot0.h         |  11 +-
 .../include/mach/fpga_manager_arria10.h            |  32 +
 arch/arm/mach-socfpga/include/mach/sdram.h         | 434 +-----------
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h |   2 +
 .../include/mach/{sdram.h => sdram_gen5.h}         |   6 +-
 arch/arm/mach-socfpga/misc_arria10.c               |   5 -
 arch/arm/mach-socfpga/spl.c                        |  49 ++
 cmd/fpga.c                                         |   2 +-
 common/Makefile                                    |   1 +
 common/fs_loader.c                                 | 304 +++++++++
 common/spl/Kconfig                                 |   8 +
 common/spl/spl_mmc.c                               |   2 +-
 configs/socfpga_arria10_defconfig                  |  58 +-
 doc/README.SPL                                     |   1 +
 .../fpga/altera-socfpga-a10-fpga-mgr.txt           |  11 +
 drivers/ddr/altera/Kconfig                         |   2 +-
 drivers/ddr/altera/Makefile                        |   3 +-
 drivers/ddr/altera/sdram_arria10.c                 | 733 +++++++++++++++++++++
 drivers/ddr/altera/{sdram.c => sdram_gen5.c}       |   0
 drivers/fpga/altera.c                              |  40 +-
 drivers/fpga/fpga.c                                |   8 +
 drivers/fpga/socfpga_arria10.c                     | 378 ++++++++++-
 fs/Makefile                                        |   1 +
 include/altera.h                                   |   6 +
 include/configs/socfpga_common.h                   |  23 +-
 include/fpga.h                                     |   2 +
 include/fs_loader.h                                |  30 +
 include/spl.h                                      |   2 +
 31 files changed, 1716 insertions(+), 463 deletions(-)
 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h} (99%)
 create mode 100644 common/fs_loader.c
 create mode 100644 drivers/ddr/altera/sdram_arria10.c
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)
 create mode 100644 include/fs_loader.h
Signature · 1 line
2.2.0
#1 lore raw

PATCH v5 1/20 ARM: socfpga: Description on FPGA RBF properties at Arria 10 FPGA manager

From: Tien Fong Chee <[email protected]>

This patch adds description on properties about location of FPGA RBFs are stored, type and functionality of RBF used to configure FPGA.

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt | 11 +++++++++++
 1 file changed, 11 insertions(+)
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +11 -0
index 2fd8e7a..47c695b 100644
@@ -7,6 +7,14 @@ 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_periph : FPGA peripheral raw binary file which is used to
+                          initialize FPGA IOs, PLL, IO48 and DDR.
+- altr,bitstream_core : FPGA core raw binary file contains FPGA design which is
+			used to program FPGA CRAM and ERAM.
+- altr,bitstream_devpart : Partition of flash device where bitstream files are
+		           stored.
+                           <dev[:part]> - dev is flash device number, part is
+					  flash device partition.
 
 Example:
 
@@ -16,4 +24,7 @@ Example:
 		       0xffcfe400 0x20>;
 		clocks = <&l4_mp_clk>;
 		resets = <&rst FPGAMGR_RESET>;
+		altr,bitstream_periph = "ghrd_10as066n2.periph.rbf.mkimage";
+		altr,bitstream_core = "ghrd_10as066n2.core.rbf.mkimage";
+		altr,bitstream_devpart = "0:1";
 	};
Signature · 1 line
2.2.0
#2 lore raw

PATCH v5 2/20 dts: Add FPGA bitstream properties to Arria 10 DTS

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These FPGA bitstream properties would help bootloader to understand how to configure FPGA and where to look the FPGA RBF files during booting.

---
 arch/arm/dts/socfpga_arria10.dtsi | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/dts/socfpga_arria10.dtsi +5 -0
index 377700d..aeb2be8 100644
@@ -538,6 +538,11 @@
 			clocks = <&l4_mp_clk>;
 			resets = <&rst FPGAMGR_RESET>;
 			reset-names = "fpgamgr";
+			altr,bitstream_periph =
+			 "ghrd_10as066n2.periph.rbf.mkimage";
+			altr,bitstream_core =
+			 "ghrd_10as066n2.core.rbf.mkimage";
+			altr,bitstream_devpart = "0:1";
 		};
 
 		i2c0: i2c at ffc02200 {
Signature · 1 line
2.2.0
#3 lore raw

PATCH v5 3/20 arm: socfpga: Add Arria 10 SoCFPGA programming interface

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add code necessary into the FPGA driver framework in U-Boot so it can be used via the 'fpga' command for programing Arria 10 SoCFPGA.

---
 cmd/fpga.c            |  2 +-
 drivers/fpga/altera.c | 40 ++++++++++++++++++++++++++++++++--------
 drivers/fpga/fpga.c   |  8 ++++++++
 include/fpga.h        |  2 ++
 4 files changed, 43 insertions(+), 9 deletions(-)
cmd/fpga.c +1 -1
index ac6f504..3cb0bcd 100644
@@ -363,7 +363,7 @@ U_BOOT_CMD(fpga, 6, 1, do_fpga,
 	   "(Xilinx only)\n"
 #endif
 #if defined(CONFIG_CMD_FPGA_LOADFS)
-	   "Load device from filesystem (FAT by default) (Xilinx only)\n"
+	   "Load device from filesystem (FAT by default)\n"
 	   "  loadfs [dev] [address] [image size] [blocksize] <interface>\n"
 	   "        [<dev[:part]>] <filename>\n"
 #endif
drivers/fpga/altera.c +32 -8
index 135a357..a03e835 100644
@@ -23,25 +23,31 @@ static const struct altera_fpga {
 	enum altera_family	family;
 	const char		*name;
 	int			(*load)(Altera_desc *, const void *, size_t);
+	int (*loadfs)(Altera_desc *, const void *, size_t, fpga_fs_info *);
 	int			(*dump)(Altera_desc *, const void *, size_t);
 	int			(*info)(Altera_desc *);
 } altera_fpga[] = {
 #if defined(CONFIG_FPGA_ACEX1K)
-	{ Altera_ACEX1K, "ACEX1K", ACEX1K_load, ACEX1K_dump, ACEX1K_info },
-	{ Altera_CYC2,   "ACEX1K", ACEX1K_load, ACEX1K_dump, ACEX1K_info },
+	{ Altera_ACEX1K, "ACEX1K", ACEX1K_load, NULL, ACEX1K_dump,
+	 ACEX1K_info },
+	{ Altera_CYC2,   "ACEX1K", ACEX1K_load, NULL, ACEX1K_dump,
+	 ACEX1K_info },
 #elif defined(CONFIG_FPGA_CYCLON2)
-	{ Altera_ACEX1K, "CycloneII", CYC2_load, CYC2_dump, CYC2_info },
-	{ Altera_CYC2,   "CycloneII", CYC2_load, CYC2_dump, CYC2_info },
+	{ Altera_ACEX1K, "CycloneII", CYC2_load, NULL, CYC2_dump, CYC2_info },
+	{ Altera_CYC2,   "CycloneII", CYC2_load, NULL, CYC2_dump, CYC2_info },
 #endif
 #if defined(CONFIG_FPGA_STRATIX_II)
-	{ Altera_StratixII, "StratixII", StratixII_load,
+	{ Altera_StratixII, "StratixII", StratixII_load, NULL,
 	  StratixII_dump, StratixII_info },
 #endif
 #if defined(CONFIG_FPGA_STRATIX_V)
-	{ Altera_StratixV, "StratixV", stratixv_load, NULL, NULL },
+	{ Altera_StratixV, "StratixV", stratixv_load, NULL, NULL, NULL },
 #endif
-#if defined(CONFIG_FPGA_SOCFPGA)
-	{ Altera_SoCFPGA, "SoC FPGA", socfpga_load, NULL, NULL },
+#if defined(CONFIG_FPGA_SOCFPGA) && defined(CONFIG_CMD_FPGA_LOADFS)
+	{ Altera_SoCFPGA, "SoC FPGA", socfpga_load, socfpga_loadfs, NULL,
+	 NULL },
+#elif defined(CONFIG_FPGA_SOCFPGA)
+	{ Altera_SoCFPGA, "SoC FPGA", socfpga_load, NULL, NULL, NULL },
 #endif
 };
 
@@ -174,3 +180,21 @@ int altera_info(Altera_desc *desc)
 
 	return FPGA_SUCCESS;
 }
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int altera_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo)
+{
+	const struct altera_fpga *fpga = altera_desc_to_fpga(desc, __func__);
+
+	if (!fpga)
+		return FPGA_FAIL;
+
+	debug_cond(FPGA_DEBUG, "%s: Launching the %s FS Loader...\n",
+		   __func__, fpga->name);
+	if (fpga->loadfs)
+		return fpga->loadfs(desc, buf, bsize, fpga_fsinfo);
+
+	return -EINVAL;
+}
+#endif
drivers/fpga/fpga.c +8 -0
index e0fb1b4..42e901e 100644
@@ -198,6 +198,14 @@ int fpga_fsload(int devnum, const void *buf, size_t size,
 			fpga_no_sup((char *)__func__, "Xilinx devices");
 #endif
 			break;
+#if defined(CONFIG_FPGA_ALTERA)
+		case fpga_altera:
+			ret_val = altera_loadfs(desc->devdesc, buf, size,
+						fpga_fsinfo);
+#else
+			fpga_no_sup((char *)__func__, "Altera devices");
+#endif
+			break;
 		default:
 			printf("%s: Invalid or unsupported device type %d\n",
 			       __func__, desc->devtype);
include/fpga.h +2 -0
index d768fb1..8920016 100644
@@ -56,8 +56,10 @@ int fpga_count(void);
 const fpga_desc *const fpga_get_desc(int devnum);
 int fpga_load(int devnum, const void *buf, size_t bsize,
 	      bitstream_type bstype);
+#if defined(CONFIG_CMD_FPGA_LOADFS)
 int fpga_fsload(int devnum, const void *buf, size_t size,
 		fpga_fs_info *fpga_fsinfo);
+#endif
 int fpga_loadbitstream(int devnum, char *fpgadata, size_t size,
 		       bitstream_type bstype);
 int fpga_dump(int devnum, const void *buf, size_t bsize);
Signature · 1 line
2.2.0
#4 lore raw

PATCH v5 4/20 dts: Enable fpga-mgr node build for Arria 10 SPL

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

fpga-mgr node is required in SPL, because SPL needs information from the node to configure FPGA in Arria 10.

---
 arch/arm/dts/socfpga_arria10.dtsi | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/socfpga_arria10.dtsi +1 -0
index aeb2be8..1848710 100644
@@ -532,6 +532,7 @@
 		};
 
 		fpga_mgr: fpga-mgr at ffd03000 {
+			u-boot,dm-pre-reloc;
 			compatible = "altr,socfpga-a10-fpga-mgr";
 			reg = <0xffd03000 0x100
 			       0xffcfe400 0x20>;
Signature · 1 line
2.2.0
#5 lore raw

PATCH v5 5/20 fs: Enable generic filesystems interface support in SPL.

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable generic filesystem interface drivers(fs.c and fat/) build for SPL. This would allow generic filesystem being used in SPL.

---
 common/spl/Kconfig | 8 ++++++++
 doc/README.SPL     | 1 +
 fs/Makefile        | 1 +
 3 files changed, 10 insertions(+)
common/spl/Kconfig +8 -0
index b05ec21..ca25a2d 100644
@@ -304,6 +304,14 @@ config SPL_ETH_SUPPORT
 	  is required since the network stack uses a number of environment
 	  variables. See also SPL_NET_SUPPORT.
 
+config SPL_FS_GENERIC
+	bool "Support Generic filesystems interface driver"
+	help
+	  Enable support for generic filesystems interface with SPL. This
+	  permits U-Boot (or Linux in Falcon mode) to be loaded from a generic
+	  filesystem from within SPL. Support for the underlying block
+	  device (e.g. MMC or USB) must be enabled separately.
+
 config SPL_EXT_SUPPORT
 	bool "Support EXT filesystems"
 	help
doc/README.SPL +1 -0
index 3ba313c..32628a4 100644
@@ -55,6 +55,7 @@ CONFIG_SPL_SPI_FLASH_SUPPORT (drivers/mtd/spi/libspi_flash.o)
 CONFIG_SPL_SPI_SUPPORT (drivers/spi/libspi.o)
 CONFIG_SPL_FAT_SUPPORT (fs/fat/libfat.o)
 CONFIG_SPL_EXT_SUPPORT
+CONFIG_SPL_FS_GENERIC (fs/fs.o fat/)
 CONFIG_SPL_LIBGENERIC_SUPPORT (lib/libgeneric.o)
 CONFIG_SPL_POWER_SUPPORT (drivers/power/libpower.o)
 CONFIG_SPL_NAND_SUPPORT (drivers/mtd/nand/libnand.o)
fs/Makefile +1 -0
index 5770f41..fdacac8 100644
@@ -7,6 +7,7 @@
 #
 
 ifdef CONFIG_SPL_BUILD
+obj-$(CONFIG_SPL_FS_GENERIC) += fs.o fat/
 obj-$(CONFIG_SPL_FAT_SUPPORT) += fat/
 obj-$(CONFIG_SPL_EXT_SUPPORT) += ext4/
 else
Signature · 1 line
2.2.0
#6 lore raw

PATCH v5 6/20 arm: socfpga: Remove static declaration on spl_mmc_find_device function

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This patch removes the static declation on spl_mmc_find_device_function so this function is accessible by the caller from other file. This patch is required for later patch.

---
 common/spl/spl_mmc.c | 2 +-
 include/spl.h        | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
common/spl/spl_mmc.c +1 -1
index b2cccc6..159443f 100644
@@ -113,7 +113,7 @@ static int spl_mmc_get_device_index(u32 boot_device)
 	return -ENODEV;
 }
 
-static int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
+int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device)
 {
 #if CONFIG_IS_ENABLED(DM_MMC)
 	struct udevice *dev;
include/spl.h +2 -0
index ce4cf0a..e24433d 100644
@@ -10,6 +10,7 @@
 /* Platform-specific defines */
 #include <linux/compiler.h>
 #include <asm/spl.h>
+#include <mmc.h>
 
 /* Value in r0 indicates we booted from U-Boot */
 #define UBOOT_NOT_LOADED_FROM_SPL	0x13578642
@@ -68,6 +69,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 void preloader_console_init(void);
 u32 spl_boot_device(void);
 u32 spl_boot_mode(const u32 boot_device);
+int spl_mmc_find_device(struct mmc **mmcp, u32 boot_device);
 
 /**
  * spl_set_header_raw_uboot() - Set up a standard SPL image structure
Signature · 1 line
2.2.0
#7 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever, ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++
 3 files changed, 335 insertions(+)
 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h
common/Makefile +1 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
+obj-y += fs_loader.o
common/fs_loader.c new file +304 -0

304 lines not on this page · raw message

include/fs_loader.h new file +30 -0
new file mode 100644
index 0000000..dacc1f3
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+#ifndef _FS_LOADER_H_
+#define _FS_LOADER_H_
+
+#include <linux/types.h>
+
+struct firmware {
+	size_t size;		/* Size of a file */
+	const u8 *data;		/* Buffer for file */
+	const char *name;	/* Filename */
+	u32 offset;		/* Offset of reading a file */
+	void *priv;		/* Firmware loader private fields */
+};
+
+struct device_location {
+	char *name;	/* Such as mmc, usb,and sata. */
+	char *devpart;  /* Use the load command dev:part conventions */
+	char *mtdpart;	/* MTD partition for ubi part */
+	char *ubivol;	/* UBI volume-name for ubifsmount */
+};
+
+int request_firmware_into_buf(struct firmware **firmware_p,
+			      const char *name,
+			      struct device_location *location,
+			      void *buf, size_t size, u32 offset);
+#endif
Signature · 1 line
2.2.0
#8 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Hi,

Quoted 61 lines · On Tue, 5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever, ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++
 3 files changed, 335 insertions(+)
 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h
common/Makefile +1 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o
 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o
+obj-y += fs_loader.o
common/fs_loader.c new file +29 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",

common/fs_loader.c line 39

Quoted 10 lines
common/fs_loader.c new file +10 -0
+		.devpart = "0:1",
+	},
+};
+
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

common/fs_loader.c line 43

Quoted 4 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 25 lines
common/fs_loader.c new file +24 -0
+		return err;
+
+#ifndef CONFIG_DM_USB
+	err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
+#endif
+
+	return err;
+}
+#else
+static int init_usb(void)
+{
+	printf("Error: Cannot load flash image: no USB support\n");
+	return -ENOSYS;
+}
+#endif
+#endif
+
+#ifdef CONFIG_SATA
+static int init_storage_sata(void)
+{
+	return sata_probe(0);
+}
+#else
+static int init_storage_sata(void)

common/fs_loader.c line 77

Quoted 10 lines
common/fs_loader.c new file +10 -0
+{
+	printf("Error: Cannot load image: no SATA support\n");
+	return -ENOSYS;
+}
+#endif
+
+#ifdef CONFIG_CMD_UBIFS
+static int mount_ubifs(struct device_location *location)
+{
+	int ret = 0;

Useless initialization.

common/fs_loader.c line 84

Quoted 7 lines
common/fs_loader.c new file +7 -0
+	char cmd[32];
+
+	sprintf(cmd, "ubi part %s", location->mtdpart);
+
+	ret = run_command(cmd, 0);
+
+	if (ret)

Unnecessary blank line.

common/fs_loader.c line 91

Quoted 8 lines
common/fs_loader.c new file +7 -0
+		return ret;
+
+	sprintf(cmd, "ubifsmount %s", location->ubivol);
+
+	ret = run_command(cmd, 0);
+
+	return res;

s/res/ret/
You obviously never compiled this code with CONFIG_CMD_UBIFS enabled.

Quoted 7 lines
common/fs_loader.c new file +6 -0
+}
+
+static int umount_ubifs(void)
+{
+	return run_command("ubifsumount", 0);
+}

common/fs_loader.c line 107

Quoted 10 lines
common/fs_loader.c new file +10 -0
+#else
+static int mount_ubifs(struct device_location *location)
+{
+	printf("Error: Cannot load image: no UBIFS support\n");
+	return -ENOSYS;
+}
+
+static int umount_ubifs(void)
+{
+	printf("Error: Cannot unmount UBIFS: no UBIFS support\n");

This error message is useless, since umount_ubifs() would probably never be called when mount_ubifs() failed.

common/fs_loader.c line 117

Quoted 10 lines
common/fs_loader.c new file +9 -0
+}
+#endif
+
+#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD)
+static int init_mmc(void)
+{
+	/* Just for the case MMC is not yet initialized */
+	struct mmc *mmc = NULL;
+	int err = 0;

Useless initialization.

Quoted 14 lines
common/fs_loader.c new file +13 -0
+
+	spl_mmc_find_device(&mmc, spl_boot_device());
+
+	err = mmc_init(mmc);
+
+	if (err) {
+		printf("spl: mmc init failed with error: %d\n", err);
+		return err;
+	}
+
+	return err;
+}
+#else

common/fs_loader.c line 140

Quoted 10 lines
common/fs_loader.c new file +10 -0
+static int init_mmc(void)
+{
+	/* Expect somewhere already initialize MMC */
+	return 0;
+}
+#endif
+
+static int select_fs_dev(struct device_location *location)
+{
+	int ret = 0;

Useless initialization. Omitting the initialization here makes sure, that 'ret' is properly set in each of the below if/else clauses. Otherwise the compiler will complain about an unitialized use of 'ret'.

Quoted 6 lines
common/fs_loader.c new file +6 -0
+	if (!strcmp("mmc", location->name))
+		ret = fs_set_blk_dev("mmc", location->devpart, FS_TYPE_ANY);
+	else if (!strcmp("usb", location->name))
+		ret = fs_set_blk_dev("usb", location->devpart, FS_TYPE_ANY);
+	else if (!strcmp("sata", location->name))
+		ret = fs_set_blk_dev("sata", location->devpart, FS_TYPE_ANY);

common/fs_loader.c line 157

Quoted 10 lines
common/fs_loader.c new file +10 -0
+	else if (!strcmp("ubi", location->name))
+		if (location->ubivol != NULL)
+			ret = fs_set_blk_dev("ubi", NULL, FS_TYPE_UBIFS);
+		else
+			ret = -ENODEV;
+	else {
+		printf("Error: unsupported location storage.\n");
+		return -ENODEV;
+	}
+

All if/else clauses should be enclosed in {}.
Refer to Documentation/CodingStyle in the Linux source which also applies to U-Boot.

Quoted 26 lines
common/fs_loader.c new file +25 -0
+	if (ret)
+		printf("Error: could not access storage.\n");
+
+	return ret;
+}
+
+static int init_storage_device(struct device_location *location)
+{
+	int ret = 0;
+#ifndef CONFIG_SPL_BUILD
+	/* USB build is not supported yet in SPL */
+	if (!strcmp("usb", location->name))
+		ret = init_usb();
+#endif
+
+	if (!strcmp("mmc", location->name))
+		ret = init_mmc();
+
+	if (!strcmp("sata", location->name))
+		ret = init_storage_sata();
+
+	if (location->ubivol != NULL)
+		ret = mount_ubifs(location);
+
+	return ret;

common/fs_loader.c line 192

Quoted 10 lines
common/fs_loader.c new file +10 -0
+}
+
+static void set_storage_devpart(char *name, char *devpart)
+{
+	int i;
+	u32 size;
+
+	size = ARRAY_SIZE(default_locations);
+
+	for (i = 0; i < size; i++) {

The compiler should complain about a comparison of signed and unsigned integers.
I would do:

	size_t i;

	for (i = 0; i < ARRAY_SIZE(default_locations); i++) {

[...]

Quoted 11 lines
common/fs_loader.c new file +11 -0
+		if (!strcmp(default_locations[i].name, name))
+			default_locations[i].devpart = devpart;
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */

common/fs_loader.c line 213

Quoted 10 lines
common/fs_loader.c new file +10 -0
+static int _request_firmware_prepare(struct firmware **firmware_p,
+				     const char *name, void *dbuf,
+				     size_t size, u32 offset)
+{
+	struct firmware *firmware = NULL;
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware' struct and returning an error at the end?

Quoted 20 lines
common/fs_loader.c new file +20 -0
+	*firmware_p = firmware = calloc(1, sizeof(*firmware));
+
+	if (!firmware) {
+		printf("%s: calloc(struct firmware) failed\n", __func__);
+		return -ENOMEM;
+	}
+
+	firmware->name = name;
+	firmware->data = dbuf;
+	firmware->size = size;
+	firmware->offset = offset;
+
+	return ret;
+}
+
+/*
+ * fw_get_filesystem_firmware - load firmware into a allocated buffer
+ * @firmware_p: pointer to firmware image
+ * @location: An array of supported firmware location
+ *

common/fs_loader.c line 243

Quoted 10 lines
common/fs_loader.c new file +10 -0
+ * @return: size of total read
+ *	    -ve when error
+ */
+static int fw_get_filesystem_firmware(struct device_location *location,
+				      struct firmware *firmware_p)
+{
+	loff_t actread;
+	char *dev_part;
+	int ret = 0;
+

Useless initialization.

common/fs_loader.c line 246

Quoted 4 lines
common/fs_loader.c new file +3 -0
+	dev_part = env_get("FW_DEV_PART");
+
+	if (dev_part)

Unnecessary blank line.

common/fs_loader.c line 251

Quoted 5 lines
common/fs_loader.c new file +5 -0
+		set_storage_devpart(location->name, dev_part);
+
+	ret = init_storage_device(location);
+
+	if (ret)

Unnecessary blank line.

common/fs_loader.c line 256

Quoted 6 lines
common/fs_loader.c new file +5 -0
+		goto out;
+
+	select_fs_dev(location);
+
+	ret = fs_read(firmware_p->name, (u32)firmware_p->data,

The second parameter of fs_read is of type 'ulong' NOT 'u32'! This will blow up when compiling for 64bit machines.

common/fs_loader.c line 268

Quoted 12 lines
common/fs_loader.c new file +12 -0
+		      firmware_p->offset, firmware_p->size, &actread);
+
+	if (ret || (actread != firmware_p->size)) {
+		printf("Error: %d Failed to read %s from flash %lld ",
+		      ret,
+		      firmware_p->name,
+		      actread);
+		printf("!= %d.\n", firmware_p->size);
+		return -EPERM;
+		} else
+			ret = actread;
+

broken indentation.
All clauses of the if/else statement should be enclosed in {}.

Quoted 17 lines
common/fs_loader.c new file +16 -0
+out:
+	if (location->ubivol != NULL)
+		umount_ubifs();
+
+	return ret;
+}
+/*
+ * request_firmware_into_buf - load firmware into a previously allocated buffer
+ * @firmware_p: pointer to firmware image
+ * @name: name of firmware file
+ * @buf: address of buffer to load firmware into
+ * @size: size of buffer
+ * @offset: offset of a file for start reading
+ *
+ * This firmware is loaded directly into the buffer pointed to by @buf and
+ * the @firmware_p data member is pointed at @buf.

common/fs_loader.c line 294

Quoted 10 lines
common/fs_loader.c new file +10 -0
+ *
+ * @return: size of total read
+ *	    -ve when error
+ */
+int request_firmware_into_buf(struct firmware **firmware_p,
+			      const char *name,
+			      struct device_location *location,
+			      void *buf, size_t size, u32 offset)
+{
+	int ret = 0;

Useless initialization.

common/fs_loader.c line 298

Quoted 4 lines
common/fs_loader.c new file +3 -0
+	ret = _request_firmware_prepare(firmware_p, name, buf, size, offset);
+
+	if (ret < 0) /* error */

Unnecessary blank line.

Quoted 16 lines
common/fs_loader.c new file +6 -0
+		return ret;
+
+	ret = fw_get_filesystem_firmware(location, *firmware_p);
+
+	return ret;
+}
include/fs_loader.h new file +3 -0
new file mode 100644
index 0000000..dacc1f3
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *

include/fs_loader.h line 13

Quoted 10 lines
include/fs_loader.h new file +10 -0
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+#ifndef _FS_LOADER_H_
+#define _FS_LOADER_H_
+
+#include <linux/types.h>
+
+struct firmware {
+	size_t size;		/* Size of a file */
+	const u8 *data;		/* Buffer for file */

const void *data?

Quoted 7 lines
include/fs_loader.h new file +7 -0
+	const char *name;	/* Filename */
+	u32 offset;		/* Offset of reading a file */
+	void *priv;		/* Firmware loader private fields */
+};
+
+struct device_location {
+	char *name;	/* Such as mmc, usb,and sata. */

include/fs_loader.h line 30

Quoted 10 lines
include/fs_loader.h new file +10 -0
+	char *devpart;  /* Use the load command dev:part conventions */
+	char *mtdpart;	/* MTD partition for ubi part */
+	char *ubivol;	/* UBI volume-name for ubifsmount */
+};
+
+int request_firmware_into_buf(struct firmware **firmware_p,
+			      const char *name,
+			      struct device_location *location,
+			      void *buf, size_t size, u32 offset);
+#endif

Lothar Waßmann

#9 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Quoted 69 lines · Lothar Waßmann

Hi,

Quoted 66 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever, ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 7 lines

common/fs_loader.c line 43

Quoted 5 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Sorry, i'm not catching you because there is no blank line between "if" and "return"

Quoted 30 lines
Quoted 30 lines
common/fs_loader.c new file +12 -0
+		return err;
+
+#ifndef CONFIG_DM_USB
+	err = usb_stor_scan(1) < 0 ? -ENODEV : 0;
+#endif
+
+	return err;
+}
+#else
+static int init_usb(void)
+{
+	printf("Error: Cannot load flash image: no USB

support\n");

common/fs_loader.c new file +16 -0
+	return -ENOSYS;
+}
+#endif
+#endif
+
+#ifdef CONFIG_SATA
+static int init_storage_sata(void)
+{
+	return sata_probe(0);
+}
+#else
+static int init_storage_sata(void)
+{
+	printf("Error: Cannot load image: no SATA support\n");
+	return -ENOSYS;
+}
Quoted 9 lines

common/fs_loader.c line 77

Quoted 7 lines
common/fs_loader.c new file +6 -0
+#endif
+
+#ifdef CONFIG_CMD_UBIFS
+static int mount_ubifs(struct device_location *location)
+{
+	int ret = 0;

Useless initialization.

noted.

Quoted 11 lines

common/fs_loader.c line 84

Quoted 8 lines
common/fs_loader.c new file +7 -0
+	char cmd[32];
+
+	sprintf(cmd, "ubi part %s", location->mtdpart);
+
+	ret = run_command(cmd, 0);
+
+	if (ret)

Unnecessary blank line.

Quoted 1 line
Quoted 11 lines

common/fs_loader.c line 91

Quoted 8 lines
common/fs_loader.c new file +7 -0
+		return ret;
+
+	sprintf(cmd, "ubifsmount %s", location->ubivol);
+
+	ret = run_command(cmd, 0);
+
+	return res;

s/res/ret/
You obviously never compiled this code with CONFIG_CMD_UBIFS enabled.

Good catch!! I will rectify.

Quoted 12 lines
Quoted 12 lines
common/fs_loader.c new file +11 -0
+}
+
+static int umount_ubifs(void)
+{
+	return run_command("ubifsumount", 0);
+}
+#else
+static int mount_ubifs(struct device_location *location)
+{
+	printf("Error: Cannot load image: no UBIFS support\n");
+	return -ENOSYS;
Quoted 9 lines

common/fs_loader.c line 107

Quoted 6 lines
common/fs_loader.c new file +5 -0
+}
+
+static int umount_ubifs(void)
+{
+	printf("Error: Cannot unmount UBIFS: no UBIFS support\n");

This error message is useless, since umount_ubifs() would probably never be called when mount_ubifs() failed.

Yeah, you are right, i will remove it.

Quoted 13 lines

common/fs_loader.c line 117

Quoted 11 lines
common/fs_loader.c new file +9 -0
+}
+#endif
+
+#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD)
+static int init_mmc(void)
+{
+	/* Just for the case MMC is not yet initialized */
+	struct mmc *mmc = NULL;
+	int err = 0;

Useless initialization.

noted.

Quoted 22 lines
Quoted 22 lines
common/fs_loader.c new file +7 -0
+
+	spl_mmc_find_device(&mmc, spl_boot_device());
+
+	err = mmc_init(mmc);
+
+	if (err) {
+		printf("spl: mmc init failed with error: %d\n",

err);

common/fs_loader.c new file +13 -0
+		return err;
+	}
+
+	return err;
+}
+#else
+static int init_mmc(void)
+{
+	/* Expect somewhere already initialize MMC */
+	return 0;
+}
+#endif
+
Quoted 9 lines

common/fs_loader.c line 140

Quoted 4 lines
common/fs_loader.c new file +3 -0
+static int select_fs_dev(struct device_location *location)
+{
+	int ret = 0;

Useless initialization. Omitting the initialization here makes sure, that 'ret' is properly set in each of the below if/else clauses. Otherwise the compiler will complain about an unitialized use of 'ret'.

Okay. sure.

Quoted 16 lines
Quoted 16 lines
common/fs_loader.c new file +2 -0
+	if (!strcmp("mmc", location->name))
+		ret = fs_set_blk_dev("mmc", location->devpart,

FS_TYPE_ANY);

common/fs_loader.c new file +2 -0
+	else if (!strcmp("usb", location->name))
+		ret = fs_set_blk_dev("usb", location->devpart,

FS_TYPE_ANY);

common/fs_loader.c new file +2 -0
+	else if (!strcmp("sata", location->name))
+		ret = fs_set_blk_dev("sata", location->devpart,

FS_TYPE_ANY);

common/fs_loader.c new file +3 -0
+	else if (!strcmp("ubi", location->name))
+		if (location->ubivol != NULL)
+			ret = fs_set_blk_dev("ubi", NULL,

FS_TYPE_UBIFS);

common/fs_loader.c new file +2 -0
+		else
+			ret = -ENODEV;
Quoted 9 lines

common/fs_loader.c line 157

Quoted 5 lines
common/fs_loader.c new file +5 -0
+	else {
+		printf("Error: unsupported location storage.\n");
+		return -ENODEV;
+	}
+

All if/else clauses should be enclosed in {}.
Refer to Documentation/CodingStyle in the Linux source which also applies to U-Boot.

Okay.

Quoted 41 lines
Quoted 27 lines
common/fs_loader.c new file +25 -0
+	if (ret)
+		printf("Error: could not access storage.\n");
+
+	return ret;
+}
+
+static int init_storage_device(struct device_location *location)
+{
+	int ret = 0;
+#ifndef CONFIG_SPL_BUILD
+	/* USB build is not supported yet in SPL */
+	if (!strcmp("usb", location->name))
+		ret = init_usb();
+#endif
+
+	if (!strcmp("mmc", location->name))
+		ret = init_mmc();
+
+	if (!strcmp("sata", location->name))
+		ret = init_storage_sata();
+
+	if (location->ubivol != NULL)
+		ret = mount_ubifs(location);
+
+	return ret;

common/fs_loader.c line 192

Quoted 10 lines
common/fs_loader.c new file +10 -0
+}
+
+static void set_storage_devpart(char *name, char *devpart)
+{
+	int i;
+	u32 size;
+
+	size = ARRAY_SIZE(default_locations);
+
+	for (i = 0; i < size; i++) {

The compiler should complain about a comparison of signed and unsigned
integers.
I would do:

Quoted 5 lines
	size_t i;

	for (i = 0; i < ARRAY_SIZE(default_locations); i++) {

[...]

Okay. noted.

Quoted 16 lines
Quoted 16 lines
common/fs_loader.c new file +15 -0
+		if (!strcmp(default_locations[i].name, name))
+			default_locations[i].devpart = devpart;
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware **firmware_p,
+				     const char *name, void *dbuf,
+				     size_t size, u32 offset)
+{
Quoted 9 lines

common/fs_loader.c line 213

Quoted 6 lines
common/fs_loader.c new file +6 -0
+	struct firmware *firmware = NULL;
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware' struct and returning an error at the end?

I try to keep it very close to Linux firmware loader. When more API ported in from Linux in future, this can be helper function. Anyway, i have no strong opinion, i can move to caller if you guys think that is better.

Quoted 27 lines
Quoted 27 lines
common/fs_loader.c new file +4 -0
+	*firmware_p = firmware = calloc(1, sizeof(*firmware));
+
+	if (!firmware) {
+		printf("%s: calloc(struct firmware) failed\n",

__func__);

common/fs_loader.c new file +13 -0
+		return -ENOMEM;
+	}
+
+	firmware->name = name;
+	firmware->data = dbuf;
+	firmware->size = size;
+	firmware->offset = offset;
+
+	return ret;
+}
+
+/*
+ * fw_get_filesystem_firmware - load firmware into a allocated

buffer
+ * @firmware_p: pointer to firmware image
+ * @location: An array of supported firmware location
+ *
+ * @return: size of total read
+ *     -ve when error
+ */
+static int fw_get_filesystem_firmware(struct device_location

Quoted 9 lines

common/fs_loader.c line 243

Quoted 7 lines

*location,

common/fs_loader.c new file +6 -0
+				      struct firmware *firmware_p)
+{
+	loff_t actread;
+	char *dev_part;
+	int ret = 0;
+

Useless initialization.

noted.

Quoted 16 lines

common/fs_loader.c line 246

Quoted 5 lines
common/fs_loader.c new file +3 -0
+	dev_part = env_get("FW_DEV_PART");
+
+	if (dev_part)

Unnecessary blank line.

common/fs_loader.c line 251

Quoted 6 lines
common/fs_loader.c new file +5 -0
+		set_storage_devpart(location->name, dev_part);
+
+	ret = init_storage_device(location);
+
+	if (ret)

Unnecessary blank line.

Quoted 1 line
Quoted 9 lines

common/fs_loader.c line 256

Quoted 6 lines
common/fs_loader.c new file +5 -0
+		goto out;
+
+	select_fs_dev(location);
+
+	ret = fs_read(firmware_p->name, (u32)firmware_p->data,

The second parameter of fs_read is of type 'ulong' NOT 'u32'! This will blow up when compiling for 64bit machines.

Okay.

Quoted 18 lines
Quoted 7 lines
common/fs_loader.c new file +1 -0
+		      firmware_p->offset, firmware_p->size,

&actread);

common/fs_loader.c new file +3 -0
+
+	if (ret || (actread != firmware_p->size)) {
+		printf("Error: %d Failed to read %s from flash

%lld ",

common/fs_loader.c line 268

Quoted 8 lines
common/fs_loader.c new file +8 -0
+		      ret,
+		      firmware_p->name,
+		      actread);
+		printf("!= %d.\n", firmware_p->size);
+		return -EPERM;
+		} else
+			ret = actread;
+

broken indentation.
All clauses of the if/else statement should be enclosed in {}.

Okay.

Quoted 23 lines
Quoted 23 lines
common/fs_loader.c new file +8 -0
+out:
+	if (location->ubivol != NULL)
+		umount_ubifs();
+
+	return ret;
+}
+/*
+ * request_firmware_into_buf - load firmware into a previously

allocated buffer
+ * @firmware_p: pointer to firmware image
+ * @name: name of firmware file
+ * @buf: address of buffer to load firmware into
+ * @size: size of buffer
+ * @offset: offset of a file for start reading
+ *
+ * This firmware is loaded directly into the buffer pointed to by @buf and
+ * the @firmware_p data member is pointed at @buf.
+ *
+ * @return: size of total read
+ *     -ve when error
+ */

Quoted 9 lines

common/fs_loader.c line 294

Quoted 7 lines
common/fs_loader.c new file +6 -0
+int request_firmware_into_buf(struct firmware **firmware_p,
+			      const char *name,
+			      struct device_location *location,
+			      void *buf, size_t size, u32 offset)
+{
+	int ret = 0;

Useless initialization.

noted.

Quoted 28 lines

common/fs_loader.c line 298

Quoted 6 lines
common/fs_loader.c new file +1 -0
+	ret = _request_firmware_prepare(firmware_p, name, buf,

size, offset);

common/fs_loader.c new file +2 -0
+
+	if (ret < 0) /* error */

Unnecessary blank line.

Quoted 20 lines
common/fs_loader.c new file +6 -0
+		return ret;
+
+	ret = fw_get_filesystem_firmware(location, *firmware_p);
+
+	return ret;
+}
include/fs_loader.h new file +7 -0
new file mode 100644
index 0000000..dacc1f3
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+#ifndef _FS_LOADER_H_
+#define _FS_LOADER_H_
Quoted 9 lines

include/fs_loader.h line 13

Quoted 7 lines
include/fs_loader.h new file +6 -0
+
+#include <linux/types.h>
+
+struct firmware {
+	size_t size;		/* Size of a file */
+	const u8 *data;		/* Buffer for file */

const void *data?

okay.

Quoted 22 lines
Quoted 11 lines
include/fs_loader.h new file +3 -0
+	const char *name;	/* Filename */
+	u32 offset;		/* Offset of reading a file */
+	void *priv;		/* Firmware loader private

fields */

include/fs_loader.h new file +5 -0
+};
+
+struct device_location {
+	char *name;	/* Such as mmc, usb,and sata. */
+	char *devpart;  /* Use the load command dev:part

conventions */

include/fs_loader.h line 30

Quoted 9 lines
include/fs_loader.h new file +9 -0
+	char *mtdpart;	/* MTD partition for ubi part */
+	char *ubivol;	/* UBI volume-name for ubifsmount */
+};
+
+int request_firmware_into_buf(struct firmware **firmware_p,
+			      const char *name,
+			      struct device_location *location,
+			      void *buf, size_t size, u32 offset);
+#endif

Lothar Waßmann

#10 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Hi,

Quoted 81 lines · Tien Fong
Quoted 69 lines · Lothar Waßmann

Hi,

Quoted 66 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever, ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 1 line
Quoted 1 line
Quoted 9 lines
Quoted 6 lines

common/fs_loader.c line 43

Quoted 4 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Sorry, i'm not catching you because there is no blank line between "if" and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Quoted 25 lines
Quoted 16 lines
Quoted 16 lines
common/fs_loader.c new file +15 -0
+		if (!strcmp(default_locations[i].name, name))
+			default_locations[i].devpart = devpart;
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware **firmware_p,
+				     const char *name, void *dbuf,
+				     size_t size, u32 offset)
+{
Quoted 9 lines

common/fs_loader.c line 213

Quoted 6 lines
common/fs_loader.c new file +6 -0
+	struct firmware *firmware = NULL;
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware' struct and returning an error at the end?

Quoted 4 lines

I try to keep it very close to Linux firmware loader. When more API ported in from Linux in future, this can be helper function. Anyway, i have no strong opinion, i can move to caller if you guys think that is better.

The Linux firmware loader has this:

|	if (!name || name[0] == '\0') {
|		ret = -EINVAL;
|		goto out;
|	}

Note the 'goto out' which is missing in your code.
If following the Linux code closely, you would have to set *firmware_p to NULL and exit in this case.

Lothar Waßmann

#11 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Quoted 97 lines · Lothar Waßmann

Hi,

Quoted 94 lines · Tien Fong
Quoted 73 lines · Lothar Waßmann

Hi,

Quoted 68 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever,
ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 9 lines

common/fs_loader.c line 43

Quoted 7 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 6 lines
Quoted 4 lines

Sorry, i'm not catching you because there is no blank line between "if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 39 lines
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
common/fs_loader.c new file +2 -0
+		if (!strcmp(default_locations[i].name, name))
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name, void

*dbuf,

common/fs_loader.c new file +2 -0
+				     size_t size, u32 offset)
+{
Quoted 9 lines

common/fs_loader.c line 213

Quoted 6 lines
common/fs_loader.c new file +6 -0
+	struct firmware *firmware = NULL;
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware' struct and returning an error at the end?

Quoted 6 lines

I try to keep it very close to Linux firmware loader. When more API ported in from Linux in future, this can be helper function. Anyway, i
have no strong opinion, i can move to caller if you guys think that is
better.

The Linux firmware loader has this:

Quoted 1 line
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

I can set the *firmware_p to NUll in failing case. But, i checked the static int _request_firmware_prepare in Linux, there is no goto out error handling method in the function. Fyi, there is no allocated memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers/base/fi
rmware_class.c#L1191

Quoted 2 lines

Lothar Waßmann

#12 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Hi,

Quoted 153 lines · Tien Fong
Quoted 97 lines · Lothar Waßmann

Hi,

Quoted 94 lines · Tien Fong
Quoted 73 lines · Lothar Waßmann

Hi,

Quoted 68 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever,
ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 9 lines

common/fs_loader.c line 43

Quoted 7 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 6 lines
Quoted 4 lines

Sorry, i'm not catching you because there is no blank line between "if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 39 lines
Quoted 31 lines
Quoted 22 lines
Quoted 22 lines
common/fs_loader.c new file +2 -0
+		if (!strcmp(default_locations[i].name, name))
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name, void

*dbuf,

common/fs_loader.c new file +2 -0
+				     size_t size, u32 offset)
+{
Quoted 9 lines

common/fs_loader.c line 213

Quoted 6 lines
common/fs_loader.c new file +6 -0
+	struct firmware *firmware = NULL;
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware' struct and returning an error at the end?

Quoted 6 lines

I try to keep it very close to Linux firmware loader. When more API ported in from Linux in future, this can be helper function. Anyway, i
have no strong opinion, i can move to caller if you guys think that is
better.

The Linux firmware loader has this:

Quoted 1 line
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

Quoted 7 lines

I can set the *firmware_p to NUll in failing case. But, i checked the static int _request_firmware_prepare in Linux, there is no goto out error handling method in the function. Fyi, there is no allocated memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers/base/fi
rmware_class.c#L1191

Quoted 1 line

I was referring to _request_firmware() which calls request_firmware_prepare() and does the checking of 'name' as your code does.

Lothar Waßmann

#13 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Quoted 186 lines · Lothar Waßmann

Hi,

Quoted 173 lines · Tien Fong
Quoted 104 lines · Lothar Waßmann

Hi,

Quoted 100 lines · Tien Fong
Quoted 76 lines · Lothar Waßmann

Hi,

Quoted 70 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load
the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever,
ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 11 lines

common/fs_loader.c line 43

Quoted 9 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 7 lines
Quoted 5 lines

Sorry, i'm not catching you because there is no blank line between
"if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 50 lines
Quoted 39 lines
Quoted 30 lines
Quoted 30 lines
common/fs_loader.c new file +1 -0
+		if (!strcmp(default_locations[i].name,

name))

common/fs_loader.c new file +1 -0
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name,

void
*dbuf,

common/fs_loader.c new file +1 -0
+				     size_t size, u32

offset)

common/fs_loader.c new file +2 -0
+{
+	struct firmware *firmware = NULL;
Quoted 9 lines

common/fs_loader.c line 213

Quoted 5 lines
common/fs_loader.c new file +5 -0
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware'
struct and returning an error at the end?

Quoted 8 lines

I try to keep it very close to Linux firmware loader. When more API
ported in from Linux in future, this can be helper function. Anyway, i
have no strong opinion, i can move to caller if you guys think that
is
better.

The Linux firmware loader has this:

Quoted 2 lines
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

Quoted 10 lines

I can set the *firmware_p to NUll in failing case. But, i checked the
static int _request_firmware_prepare in Linux, there is no goto out error handling method in the function. Fyi, there is no allocated memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers/bas
e/fi
rmware_class.c#L1191

Quoted 2 lines
Quoted 4 lines

I was referring to _request_firmware() which calls request_firmware_prepare() and does the checking of 'name' as your code does.

Ohh.....i skipped _request_firmware() because there is no error handling required in U-Boot such as memory release. For the checking at both firmware_p and name, i would rather to merge them into request_firware_prepare() because they are related to each other instead of creating one function just for checking purpose. What do you think?

Quoted 2 lines

Lothar Waßmann

#14 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Hi,

Quoted 191 lines · Tien Fong
Quoted 186 lines · Lothar Waßmann

Hi,

Quoted 173 lines · Tien Fong
Quoted 104 lines · Lothar Waßmann

Hi,

Quoted 100 lines · Tien Fong
Quoted 76 lines · Lothar Waßmann

Hi,

Quoted 70 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.com wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load
the file image from the storage into target such as memory. The consumer driver would then use this loader to program whatever,
ie. the FPGA device.

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +33 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c line 39

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 11 lines

common/fs_loader.c line 42

Quoted 9 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 7 lines
Quoted 5 lines

Sorry, i'm not catching you because there is no blank line between
"if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 50 lines
Quoted 39 lines
Quoted 30 lines
Quoted 30 lines
common/fs_loader.c new file +1 -0
+		if (!strcmp(default_locations[i].name,

name))

common/fs_loader.c new file +1 -0
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name,

void
*dbuf,

common/fs_loader.c new file +1 -0
+				     size_t size, u32

offset)

common/fs_loader.c new file +2 -0
+{
+	struct firmware *firmware = NULL;
Quoted 9 lines

common/fs_loader.c

Quoted 5 lines
common/fs_loader.c new file +5 -0
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware'
struct and returning an error at the end?

Quoted 8 lines

I try to keep it very close to Linux firmware loader. When more API
ported in from Linux in future, this can be helper function. Anyway, i
have no strong opinion, i can move to caller if you guys think that
is
better.

The Linux firmware loader has this:

Quoted 2 lines
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

Quoted 10 lines

I can set the *firmware_p to NUll in failing case. But, i checked the
static int _request_firmware_prepare in Linux, there is no goto out error handling method in the function. Fyi, there is no allocated memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers/bas
e/fi
rmware_class.c#L1191

Quoted 2 lines
Quoted 4 lines

I was referring to _request_firmware() which calls request_firmware_prepare() and does the checking of 'name' as your code does.

Quoted 7 lines

Ohh.....i skipped _request_firmware() because there is no error handling required in U-Boot such as memory release. For the checking at both firmware_p and name, i would rather to merge them into request_firware_prepare() because they are related to each other instead of creating one function just for checking purpose. What do you think?

I don't mind whether you combine those functions or not as long as you reproduce the same functionality which your patch currently does not do.

Lothar Waßmann

#15 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Quoted 231 lines · Lothar Waßmann

Hi,

Quoted 219 lines · Tien Fong
Quoted 212 lines · Lothar Waßmann

Hi,

Quoted 193 lines · Tien Fong
Quoted 115 lines · Lothar Waßmann

Hi,

Quoted 110 lines · Tien Fong
Quoted 83 lines · Lothar Waßmann

Hi,

Quoted 75 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.c om wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load
the file image from the storage into target such as memory.
The consumer driver would then use this loader to program
whatever,
ie. the FPGA device.

Quoted 1 line

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +2 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com
Quoted 1 line

+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */

common/fs_loader.c new file +28 -0
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 13 lines

common/fs_loader.c

Quoted 11 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 7 lines
Quoted 5 lines

Sorry, i'm not catching you because there is no blank line between
"if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 58 lines
Quoted 43 lines
Quoted 34 lines
Quoted 34 lines
common/fs_loader.c new file +1 -0
+		if (!strcmp(default_locations[i].name,

name))

common/fs_loader.c new file +1 -0
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name,

void
*dbuf,

common/fs_loader.c new file +1 -0
+				     size_t size, u32

offset)

common/fs_loader.c new file +2 -0
+{
+	struct firmware *firmware = NULL;
Quoted 9 lines

common/fs_loader.c

Quoted 5 lines
common/fs_loader.c new file +5 -0
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware'
struct and returning an error at the end?

Quoted 11 lines

I try to keep it very close to Linux firmware loader. When more
API
ported in from Linux in future, this can be helper function.
Anyway, i
have no strong opinion, i can move to caller if you guys think
that
is
better.

The Linux firmware loader has this:

Quoted 3 lines
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

Quoted 15 lines

I can set the *firmware_p to NUll in failing case. But, i checked
the
static int _request_firmware_prepare in Linux, there is no goto out
error handling method in the function. Fyi, there is no allocated
memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers
/bas
e/fi
rmware_class.c#L1191

Quoted 3 lines
Quoted 5 lines

I was referring to _request_firmware() which calls request_firmware_prepare() and does the checking of 'name' as your
code does.

Quoted 9 lines

Ohh.....i skipped _request_firmware() because there is no error handling required in U-Boot such as memory release. For the checking at
both firmware_p and name, i would rather to merge them into request_firware_prepare() because they are related to each other instead of creating one function just for checking purpose. What do you
think?

Quoted 5 lines

I don't mind whether you combine those functions or not as long as you
reproduce the same functionality which your patch currently does not do.

Okay. SO i will add the checking on firmware_p whether is NULL, and assign NULL to *firmware_P if calloc is failed. There is no goout since there is no error handling required.

Quoted 2 lines


Lothar Waßmann

#16 lore raw

PATCH v5 7/20 common: Generic firmware loader for file system

Hi,

Quoted 232 lines · Tien Fong
Quoted 231 lines · Lothar Waßmann

Hi,

Quoted 228 lines · Tien Fong
Quoted 212 lines · Lothar Waßmann

Hi,

Quoted 193 lines · Tien Fong
Quoted 115 lines · Lothar Waßmann

Hi,

Quoted 110 lines · Tien Fong
Quoted 83 lines · Lothar Waßmann

Hi,

Quoted 75 lines · On Tue,  5 Dec 2017 15:57:57 +0800 tien.fong.chee at intel.c om wrote:

From: Tien Fong Chee <[email protected]>

This is file system generic loader which can be used to load
the file image from the storage into target such as memory.
The consumer driver would then use this loader to program
whatever,
ie. the FPGA device.

Quoted 1 line

---
 common/Makefile     |   1 +
 common/fs_loader.c  | 304
++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/fs_loader.h |  30 ++++++

 3 files changed, 335 insertions(+)

 create mode 100644 common/fs_loader.c
 create mode 100644 include/fs_loader.h

common/Makefile +0 -0
index 801ea31..419e915 100644
@@ -130,3 +130,4 @@ obj-$(CONFIG_CMD_DFU) += dfu.o

 obj-y += command.o
 obj-y += s_record.o
 obj-y += xyzModem.o

common/Makefile +1 -0
+obj-y += fs_loader.o
common/fs_loader.c new file +2 -0
new file mode 100644
index 0000000..04f682b
@@ -0,0 +1,304 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com
Quoted 1 line

+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */

common/fs_loader.c new file +28 -0
+
+#include <common.h>
+#include <errno.h>
+#include <fs.h>
+#include <fs_loader.h>
+#include <nand.h>
+#include <sata.h>
+#include <spi.h>
+#include <spi_flash.h>
+#include <spl.h>
+#include <linux/string.h>
+#include <usb.h>
+
+static struct device_location default_locations[] = {
+	{
+		.name = "mmc",
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb",
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata",
+		.devpart = "0:1",
+	},
+};
+
Quoted 9 lines

common/fs_loader.c

Quoted 7 lines
common/fs_loader.c new file +6 -0
+/* USB build is not supported yet in SPL */
+#ifndef CONFIG_SPL_BUILD
+#ifdef CONFIG_USB_STORAGE
+static int init_usb(void)
+{
+	int err = 0;

Useless initialization.

noted.

Quoted 13 lines

common/fs_loader.c

Quoted 11 lines
common/fs_loader.c new file +3 -0
+	err = usb_init();
+
+	if (err)

Unnecessary blank line.

Quoted 7 lines
Quoted 5 lines

Sorry, i'm not catching you because there is no blank line between
"if"
and "return"

I meant the blank line between 'err = ...' and 'if (err)'

Okay, i can change that.

Quoted 58 lines
Quoted 43 lines
Quoted 34 lines
Quoted 34 lines
common/fs_loader.c new file +1 -0
+		if (!strcmp(default_locations[i].name,

name))

common/fs_loader.c new file +1 -0
+			default_locations[i].devpart =

devpart;

common/fs_loader.c new file +10 -0
+	}
+
+	return;
+}
+
+/*
+ * Prepare firmware struct;
+ * return -ve if fail.
+ */
+static int _request_firmware_prepare(struct firmware

**firmware_p,

common/fs_loader.c new file +1 -0
+				     const char *name,

void
*dbuf,

common/fs_loader.c new file +1 -0
+				     size_t size, u32

offset)

common/fs_loader.c new file +2 -0
+{
+	struct firmware *firmware = NULL;
Quoted 9 lines

common/fs_loader.c

Quoted 5 lines
common/fs_loader.c new file +5 -0
+	int ret = 0;
+
+	if (!name || name[0] == '\0')
+		ret = -EINVAL;
+

Is it really useful to continue here initializing the 'firmware'
struct and returning an error at the end?

Quoted 11 lines

I try to keep it very close to Linux firmware loader. When more
API
ported in from Linux in future, this can be helper function.
Anyway, i
have no strong opinion, i can move to caller if you guys think
that
is
better.

The Linux firmware loader has this:

Quoted 3 lines
Quoted 9 lines
Quoted 4 lines
	if (!name || name[0] == '\0') {
		ret = -EINVAL;
		goto out;
	}

Note the 'goto out' which is missing in your code. If following the Linux code closely, you would have to set *firmware_p
to NULL and exit in this case.

Quoted 15 lines

I can set the *firmware_p to NUll in failing case. But, i checked
the
static int _request_firmware_prepare in Linux, there is no goto out
error handling method in the function. Fyi, there is no allocated
memory release in U-Boot.
https://elixir.free-electrons.com/linux/v4.13.15/source/drivers
/bas
e/fi
rmware_class.c#L1191

Quoted 3 lines
Quoted 5 lines

I was referring to _request_firmware() which calls request_firmware_prepare() and does the checking of 'name' as your
code does.

Ohh.....i skipped _request_firmware() because there is no error handling required in U-Boot such as memory release. For the checking at
both firmware_p and name, i would rather to merge them into request_firware_prepare() because they are related to each other instead of creating one function just for checking purpose. What do you
think?

Quoted 9 lines
Quoted 5 lines

I don't mind whether you combine those functions or not as long as you
reproduce the same functionality which your patch currently does not do.

Okay. SO i will add the checking on firmware_p whether is NULL, and assign NULL to *firmware_P if calloc is failed. There is no goout since there is no error handling required.

Quoted 1 line

You should also exit early setting *firmware_p to NULL when the 'name' check fails, like the Linux code does!
I.e.:
+ struct firmware *firmware = NULL;
+
+ *firmware_p = NULL;
+ if (!name || name[0] == '\0')
+ return -EINVAL;
+
+ *firmware_p = firmware = calloc(1, sizeof(*firmware));
+ if (!firmware) {
+ printf("%s: calloc(struct firmware) failed\n", __func__);
+ return -ENOMEM;
+ }
+
+ firmware->name = name;
+ firmware->data = dbuf;
+ firmware->size = size;
+ firmware->offset = offset;
+
+ return 0;

Lothar Waßmann

#17 lore raw

PATCH v5 8/20 arm: socfpga: Fix with the correct polling on bit is set

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Commit 2baa997240d ("arm: socfpga: Add FPGA driver support for Arria 10") Polling on wrong cleared bit. Fix with correct polling on bit is set.

Fixes 2baa997240d ("arm: socfpga: Add FPGA driver support for Arria 10")
---
 drivers/fpga/socfpga_arria10.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/fpga/socfpga_arria10.c +4 -3
index 5c1a68a..e076bda 100644
@@ -112,13 +112,14 @@ static int wait_for_nconfig_pin_and_nstatus_pin(void)
 	unsigned long mask = ALT_FPGAMGR_IMGCFG_STAT_F2S_NCONFIG_PIN_SET_MSK |
 				ALT_FPGAMGR_IMGCFG_STAT_F2S_NSTATUS_PIN_SET_MSK;
 
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop until de-asserted,
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop until
+	 * de-asserted, timeout at 1000ms
 	 */
 	return wait_for_bit(__func__,
 			    &fpga_manager_base->imgcfg_stat,
 			    mask,
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);
 }
 
 static int wait_for_f2s_nstatus_pin(unsigned long value)
Signature · 1 line
2.2.0
#18 lore raw

PATCH v5 9/20 arm: socfpga: Add FPGA drivers for Arria 10 FPGA loadfs

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add FPGA drivers to support FPGA loadfs to program FPGA.
The drivers are designed based on generic firmware loader framework, specific firmware loader handling is defined in fpga_manager_arria10.c. These drivers can handle FPGA program operation from
loading RBF image in flash to memory and then to program FPGA.

---
 .../include/mach/fpga_manager_arria10.h            |  32 ++
 drivers/fpga/socfpga_arria10.c                     | 371 +++++++++++++++++++++
 include/altera.h                                   |   6 +
 3 files changed, 409 insertions(+)
arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +32 -0
index 9cbf696..afcf7d8 100644
@@ -8,6 +8,9 @@
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
+#include <asm/cache.h>
+#include <fs_loader.h>
+
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_CRC_ERROR_SET_MSK		BIT(0)
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_EARLY_USERMODE_SET_MSK	BIT(1)
 #define ALT_FPGAMGR_IMGCFG_STAT_F2S_USERMODE_SET_MSK 		BIT(2)
@@ -89,11 +92,40 @@ struct socfpga_fpga_manager {
 	u32  imgcfg_fifo_status;
 };
 
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+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 flash_info {
+	struct device_location dev;
+	char *filename;
+	int fstype;
+	u32 remaining;
+	u32 offset;
+	struct rbf_info rbfinfo;
+	struct image_header header;
+};
+#endif
+
 /* 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);
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core);
+const char *get_cff_devpart(const void *fdt, int *len);
+int fs_flash_preinit(struct flash_info *flashinfo, u32 *buffer,
+		     u32 *buffer_sizebytes);
+int fs_flash_read(struct flash_info *flashinfo, u32 *buffer,
+		  u32 *buffer_sizebytes);
+#endif
+void set_flash_devpart(char *name, char *devpart);
 
 #endif /* __ASSEMBLY__ */
 
drivers/fpga/socfpga_arria10.c +371 -0

386 lines not on this page · raw message

include/altera.h +6 -0
index 48d3eb7..0597e8a 100644
@@ -84,6 +84,10 @@ typedef struct {
 extern int altera_load(Altera_desc *desc, const void *image, size_t size);
 extern int altera_dump(Altera_desc *desc, const void *buf, size_t bsize);
 extern int altera_info(Altera_desc *desc);
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int altera_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo);
+#endif
 
 /* Board specific implementation specific function types
  *********************************************************************/
@@ -111,6 +115,8 @@ typedef struct {
 
 #ifdef CONFIG_FPGA_SOCFPGA
 int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size);
+int socfpga_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo);
 #endif
 
 #ifdef CONFIG_FPGA_STRATIX_V
Signature · 1 line
2.2.0
#19 lore raw

PATCH v5 10/20 arm: socfpga: Rename the gen5 sdram driver to more specific name

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Current sdram driver is only applied to gen5 device, hence it is better to rename sdram driver to more specific name which is related to gen5 device.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         | 432 +--------------------
 .../include/mach/{sdram.h => sdram_gen5.h}         |   6 +-
 drivers/ddr/altera/Makefile                        |   2 +-
 drivers/ddr/altera/{sdram.c => sdram_gen5.c}       |   0
 4 files changed, 7 insertions(+), 433 deletions(-)
 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h} (99%)
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)
arch/arm/mach-socfpga/include/mach/sdram.h +3 -429
index b11228f..137e073 100644
@@ -8,435 +8,9 @@
 
 #ifndef __ASSEMBLY__
 
-unsigned long sdram_calculate_size(void);
-int sdram_mmr_init_full(unsigned int sdr_phy_reg);
-int sdram_calibration_full(void);
-
-const struct socfpga_sdram_config *socfpga_get_sdram_config(void);
-
-void socfpga_get_seq_ac_init(const u32 **init, unsigned int *nelem);
-void socfpga_get_seq_inst_init(const u32 **init, unsigned int *nelem);
-const struct socfpga_sdram_rw_mgr_config *socfpga_get_sdram_rwmgr_config(void);
-const struct socfpga_sdram_io_config *socfpga_get_sdram_io_config(void);
-const struct socfpga_sdram_misc_config *socfpga_get_sdram_misc_config(void);
-
-#define SDR_CTRLGRP_ADDRESS	(SOCFPGA_SDR_ADDRESS | 0x5000)
-
-struct socfpga_sdr_ctrl {
-	u32	ctrl_cfg;
-	u32	dram_timing1;
-	u32	dram_timing2;
-	u32	dram_timing3;
-	u32	dram_timing4;	/* 0x10 */
-	u32	lowpwr_timing;
-	u32	dram_odt;
-	u32	extratime1;
-	u32	__padding0[3];
-	u32	dram_addrw;	/* 0x2c */
-	u32	dram_if_width;	/* 0x30 */
-	u32	dram_dev_width;
-	u32	dram_sts;
-	u32	dram_intr;
-	u32	sbe_count;	/* 0x40 */
-	u32	dbe_count;
-	u32	err_addr;
-	u32	drop_count;
-	u32	drop_addr;	/* 0x50 */
-	u32	lowpwr_eq;
-	u32	lowpwr_ack;
-	u32	static_cfg;
-	u32	ctrl_width;	/* 0x60 */
-	u32	cport_width;
-	u32	cport_wmap;
-	u32	cport_rmap;
-	u32	rfifo_cmap;	/* 0x70 */
-	u32	wfifo_cmap;
-	u32	cport_rdwr;
-	u32	port_cfg;
-	u32	fpgaport_rst;	/* 0x80 */
-	u32	__padding1;
-	u32	fifo_cfg;
-	u32	protport_default;
-	u32	prot_rule_addr;	/* 0x90 */
-	u32	prot_rule_id;
-	u32	prot_rule_data;
-	u32	prot_rule_rdwr;
-	u32	__padding2[3];
-	u32	mp_priority;	/* 0xac */
-	u32	mp_weight0;	/* 0xb0 */
-	u32	mp_weight1;
-	u32	mp_weight2;
-	u32	mp_weight3;
-	u32	mp_pacing0;	/* 0xc0 */
-	u32	mp_pacing1;
-	u32	mp_pacing2;
-	u32	mp_pacing3;
-	u32	mp_threshold0;	/* 0xd0 */
-	u32	mp_threshold1;
-	u32	mp_threshold2;
-	u32	__padding3[29];
-	u32	phy_ctrl0;	/* 0x150 */
-	u32	phy_ctrl1;
-	u32	phy_ctrl2;
-};
-
-/* SDRAM configuration structure for the SPL. */
-struct socfpga_sdram_config {
-	u32	ctrl_cfg;
-	u32	dram_timing1;
-	u32	dram_timing2;
-	u32	dram_timing3;
-	u32	dram_timing4;
-	u32	lowpwr_timing;
-	u32	dram_odt;
-	u32	extratime1;
-	u32	dram_addrw;
-	u32	dram_if_width;
-	u32	dram_dev_width;
-	u32	dram_intr;
-	u32	lowpwr_eq;
-	u32	static_cfg;
-	u32	ctrl_width;
-	u32	cport_width;
-	u32	cport_wmap;
-	u32	cport_rmap;
-	u32	rfifo_cmap;
-	u32	wfifo_cmap;
-	u32	cport_rdwr;
-	u32	port_cfg;
-	u32	fpgaport_rst;
-	u32	fifo_cfg;
-	u32	mp_priority;
-	u32	mp_weight0;
-	u32	mp_weight1;
-	u32	mp_weight2;
-	u32	mp_weight3;
-	u32	mp_pacing0;
-	u32	mp_pacing1;
-	u32	mp_pacing2;
-	u32	mp_pacing3;
-	u32	mp_threshold0;
-	u32	mp_threshold1;
-	u32	mp_threshold2;
-	u32	phy_ctrl0;
-};
-
-struct socfpga_sdram_rw_mgr_config {
-	u8	activate_0_and_1;
-	u8	activate_0_and_1_wait1;
-	u8	activate_0_and_1_wait2;
-	u8	activate_1;
-	u8	clear_dqs_enable;
-	u8	guaranteed_read;
-	u8	guaranteed_read_cont;
-	u8	guaranteed_write;
-	u8	guaranteed_write_wait0;
-	u8	guaranteed_write_wait1;
-	u8	guaranteed_write_wait2;
-	u8	guaranteed_write_wait3;
-	u8	idle;
-	u8	idle_loop1;
-	u8	idle_loop2;
-	u8	init_reset_0_cke_0;
-	u8	init_reset_1_cke_0;
-	u8	lfsr_wr_rd_bank_0;
-	u8	lfsr_wr_rd_bank_0_data;
-	u8	lfsr_wr_rd_bank_0_dqs;
-	u8	lfsr_wr_rd_bank_0_nop;
-	u8	lfsr_wr_rd_bank_0_wait;
-	u8	lfsr_wr_rd_bank_0_wl_1;
-	u8	lfsr_wr_rd_dm_bank_0;
-	u8	lfsr_wr_rd_dm_bank_0_data;
-	u8	lfsr_wr_rd_dm_bank_0_dqs;
-	u8	lfsr_wr_rd_dm_bank_0_nop;
-	u8	lfsr_wr_rd_dm_bank_0_wait;
-	u8	lfsr_wr_rd_dm_bank_0_wl_1;
-	u8	mrs0_dll_reset;
-	u8	mrs0_dll_reset_mirr;
-	u8	mrs0_user;
-	u8	mrs0_user_mirr;
-	u8	mrs1;
-	u8	mrs1_mirr;
-	u8	mrs2;
-	u8	mrs2_mirr;
-	u8	mrs3;
-	u8	mrs3_mirr;
-	u8	precharge_all;
-	u8	read_b2b;
-	u8	read_b2b_wait1;
-	u8	read_b2b_wait2;
-	u8	refresh_all;
-	u8	rreturn;
-	u8	sgle_read;
-	u8	zqcl;
-
-	u8	true_mem_data_mask_width;
-	u8	mem_address_mirroring;
-	u8	mem_data_mask_width;
-	u8	mem_data_width;
-	u8	mem_dq_per_read_dqs;
-	u8	mem_dq_per_write_dqs;
-	u8	mem_if_read_dqs_width;
-	u8	mem_if_write_dqs_width;
-	u8	mem_number_of_cs_per_dimm;
-	u8	mem_number_of_ranks;
-	u8	mem_virtual_groups_per_read_dqs;
-	u8	mem_virtual_groups_per_write_dqs;
-};
-
-struct socfpga_sdram_io_config {
-	u16	delay_per_opa_tap;
-	u8	delay_per_dchain_tap;
-	u8	delay_per_dqs_en_dchain_tap;
-	u8	dll_chain_length;
-	u8	dqdqs_out_phase_max;
-	u8	dqs_en_delay_max;
-	u8	dqs_en_delay_offset;
-	u8	dqs_en_phase_max;
-	u8	dqs_in_delay_max;
-	u8	dqs_in_reserve;
-	u8	dqs_out_reserve;
-	u8	io_in_delay_max;
-	u8	io_out1_delay_max;
-	u8	io_out2_delay_max;
-	u8	shift_dqs_en_when_shift_dqs;
-};
-
-struct socfpga_sdram_misc_config {
-	u32	reg_file_init_seq_signature;
-	u8	afi_rate_ratio;
-	u8	calib_lfifo_offset;
-	u8	calib_vfifo_offset;
-	u8	enable_super_quick_calibration;
-	u8	max_latency_count_width;
-	u8	read_valid_fifo_size;
-	u8	tinit_cntr0_val;
-	u8	tinit_cntr1_val;
-	u8	tinit_cntr2_val;
-	u8	treset_cntr0_val;
-	u8	treset_cntr1_val;
-	u8	treset_cntr2_val;
-};
-
-#define SDR_CTRLGRP_CTRLCFG_NODMPINS_LSB 23
-#define SDR_CTRLGRP_CTRLCFG_NODMPINS_MASK 0x00800000
-#define SDR_CTRLGRP_CTRLCFG_DQSTRKEN_LSB 22
-#define SDR_CTRLGRP_CTRLCFG_DQSTRKEN_MASK 0x00400000
-#define SDR_CTRLGRP_CTRLCFG_STARVELIMIT_LSB 16
-#define SDR_CTRLGRP_CTRLCFG_STARVELIMIT_MASK 0x003f0000
-#define SDR_CTRLGRP_CTRLCFG_REORDEREN_LSB 15
-#define SDR_CTRLGRP_CTRLCFG_REORDEREN_MASK 0x00008000
-#define SDR_CTRLGRP_CTRLCFG_ECCCORREN_LSB 11
-#define SDR_CTRLGRP_CTRLCFG_ECCCORREN_MASK 0x00000800
-#define SDR_CTRLGRP_CTRLCFG_ECCEN_LSB 10
-#define SDR_CTRLGRP_CTRLCFG_ECCEN_MASK 0x00000400
-#define SDR_CTRLGRP_CTRLCFG_ADDRORDER_LSB 8
-#define SDR_CTRLGRP_CTRLCFG_ADDRORDER_MASK 0x00000300
-#define SDR_CTRLGRP_CTRLCFG_MEMBL_LSB 3
-#define SDR_CTRLGRP_CTRLCFG_MEMBL_MASK 0x000000f8
-#define SDR_CTRLGRP_CTRLCFG_MEMTYPE_LSB 0
-#define SDR_CTRLGRP_CTRLCFG_MEMTYPE_MASK 0x00000007
-/* Register template: sdr::ctrlgrp::dramtiming1                            */
-#define SDR_CTRLGRP_DRAMTIMING1_TRFC_LSB 24
-#define SDR_CTRLGRP_DRAMTIMING1_TRFC_MASK 0xff000000
-#define SDR_CTRLGRP_DRAMTIMING1_TFAW_LSB 18
-#define SDR_CTRLGRP_DRAMTIMING1_TFAW_MASK 0x00fc0000
-#define SDR_CTRLGRP_DRAMTIMING1_TRRD_LSB 14
-#define SDR_CTRLGRP_DRAMTIMING1_TRRD_MASK 0x0003c000
-#define SDR_CTRLGRP_DRAMTIMING1_TCL_LSB 9
-#define SDR_CTRLGRP_DRAMTIMING1_TCL_MASK 0x00003e00
-#define SDR_CTRLGRP_DRAMTIMING1_TAL_LSB 4
-#define SDR_CTRLGRP_DRAMTIMING1_TAL_MASK 0x000001f0
-#define SDR_CTRLGRP_DRAMTIMING1_TCWL_LSB 0
-#define SDR_CTRLGRP_DRAMTIMING1_TCWL_MASK 0x0000000f
-/* Register template: sdr::ctrlgrp::dramtiming2                            */
-#define SDR_CTRLGRP_DRAMTIMING2_TWTR_LSB 25
-#define SDR_CTRLGRP_DRAMTIMING2_TWTR_MASK 0x1e000000
-#define SDR_CTRLGRP_DRAMTIMING2_TWR_LSB 21
-#define SDR_CTRLGRP_DRAMTIMING2_TWR_MASK 0x01e00000
-#define SDR_CTRLGRP_DRAMTIMING2_TRP_LSB 17
-#define SDR_CTRLGRP_DRAMTIMING2_TRP_MASK 0x001e0000
-#define SDR_CTRLGRP_DRAMTIMING2_TRCD_LSB 13
-#define SDR_CTRLGRP_DRAMTIMING2_TRCD_MASK 0x0001e000
-#define SDR_CTRLGRP_DRAMTIMING2_TREFI_LSB 0
-#define SDR_CTRLGRP_DRAMTIMING2_TREFI_MASK 0x00001fff
-/* Register template: sdr::ctrlgrp::dramtiming3                            */
-#define SDR_CTRLGRP_DRAMTIMING3_TCCD_LSB 19
-#define SDR_CTRLGRP_DRAMTIMING3_TCCD_MASK 0x00780000
-#define SDR_CTRLGRP_DRAMTIMING3_TMRD_LSB 15
-#define SDR_CTRLGRP_DRAMTIMING3_TMRD_MASK 0x00078000
-#define SDR_CTRLGRP_DRAMTIMING3_TRC_LSB 9
-#define SDR_CTRLGRP_DRAMTIMING3_TRC_MASK 0x00007e00
-#define SDR_CTRLGRP_DRAMTIMING3_TRAS_LSB 4
-#define SDR_CTRLGRP_DRAMTIMING3_TRAS_MASK 0x000001f0
-#define SDR_CTRLGRP_DRAMTIMING3_TRTP_LSB 0
-#define SDR_CTRLGRP_DRAMTIMING3_TRTP_MASK 0x0000000f
-/* Register template: sdr::ctrlgrp::dramtiming4                            */
-#define SDR_CTRLGRP_DRAMTIMING4_MINPWRSAVECYCLES_LSB 20
-#define SDR_CTRLGRP_DRAMTIMING4_MINPWRSAVECYCLES_MASK 0x00f00000
-#define SDR_CTRLGRP_DRAMTIMING4_PWRDOWNEXIT_LSB 10
-#define SDR_CTRLGRP_DRAMTIMING4_PWRDOWNEXIT_MASK 0x000ffc00
-#define SDR_CTRLGRP_DRAMTIMING4_SELFRFSHEXIT_LSB 0
-#define SDR_CTRLGRP_DRAMTIMING4_SELFRFSHEXIT_MASK 0x000003ff
-/* Register template: sdr::ctrlgrp::lowpwrtiming                           */
-#define SDR_CTRLGRP_LOWPWRTIMING_CLKDISABLECYCLES_LSB 16
-#define SDR_CTRLGRP_LOWPWRTIMING_CLKDISABLECYCLES_MASK 0x000f0000
-#define SDR_CTRLGRP_LOWPWRTIMING_AUTOPDCYCLES_LSB 0
-#define SDR_CTRLGRP_LOWPWRTIMING_AUTOPDCYCLES_MASK 0x0000ffff
-/* Register template: sdr::ctrlgrp::dramaddrw                              */
-#define SDR_CTRLGRP_DRAMADDRW_CSBITS_LSB 13
-#define SDR_CTRLGRP_DRAMADDRW_CSBITS_MASK 0x0000e000
-#define SDR_CTRLGRP_DRAMADDRW_BANKBITS_LSB 10
-#define SDR_CTRLGRP_DRAMADDRW_BANKBITS_MASK 0x00001c00
-#define SDR_CTRLGRP_DRAMADDRW_ROWBITS_LSB 5
-#define SDR_CTRLGRP_DRAMADDRW_ROWBITS_MASK 0x000003e0
-#define SDR_CTRLGRP_DRAMADDRW_COLBITS_LSB 0
-#define SDR_CTRLGRP_DRAMADDRW_COLBITS_MASK 0x0000001f
-/* Register template: sdr::ctrlgrp::dramifwidth                            */
-#define SDR_CTRLGRP_DRAMIFWIDTH_IFWIDTH_LSB 0
-#define SDR_CTRLGRP_DRAMIFWIDTH_IFWIDTH_MASK 0x000000ff
-/* Register template: sdr::ctrlgrp::dramdevwidth                           */
-#define SDR_CTRLGRP_DRAMDEVWIDTH_DEVWIDTH_LSB 0
-#define SDR_CTRLGRP_DRAMDEVWIDTH_DEVWIDTH_MASK 0x0000000f
-/* Register template: sdr::ctrlgrp::dramintr                               */
-#define SDR_CTRLGRP_DRAMINTR_INTREN_LSB 0
-#define SDR_CTRLGRP_DRAMINTR_INTREN_MASK 0x00000001
-#define SDR_CTRLGRP_LOWPWREQ_SELFRFSHMASK_LSB 4
-#define SDR_CTRLGRP_LOWPWREQ_SELFRFSHMASK_MASK 0x00000030
-/* Register template: sdr::ctrlgrp::staticcfg                              */
-#define SDR_CTRLGRP_STATICCFG_APPLYCFG_LSB 3
-#define SDR_CTRLGRP_STATICCFG_APPLYCFG_MASK 0x00000008
-#define SDR_CTRLGRP_STATICCFG_USEECCASDATA_LSB 2
-#define SDR_CTRLGRP_STATICCFG_USEECCASDATA_MASK 0x00000004
-#define SDR_CTRLGRP_STATICCFG_MEMBL_LSB 0
-#define SDR_CTRLGRP_STATICCFG_MEMBL_MASK 0x00000003
-/* Register template: sdr::ctrlgrp::ctrlwidth                              */
-#define SDR_CTRLGRP_CTRLWIDTH_CTRLWIDTH_LSB 0
-#define SDR_CTRLGRP_CTRLWIDTH_CTRLWIDTH_MASK 0x00000003
-/* Register template: sdr::ctrlgrp::cportwidth                             */
-#define SDR_CTRLGRP_CPORTWIDTH_CMDPORTWIDTH_LSB 0
-#define SDR_CTRLGRP_CPORTWIDTH_CMDPORTWIDTH_MASK 0x000fffff
-/* Register template: sdr::ctrlgrp::cportwmap                              */
-#define SDR_CTRLGRP_CPORTWMAP_CPORTWFIFOMAP_LSB 0
-#define SDR_CTRLGRP_CPORTWMAP_CPORTWFIFOMAP_MASK 0x3fffffff
-/* Register template: sdr::ctrlgrp::cportrmap                              */
-#define SDR_CTRLGRP_CPORTRMAP_CPORTRFIFOMAP_LSB 0
-#define SDR_CTRLGRP_CPORTRMAP_CPORTRFIFOMAP_MASK 0x3fffffff
-/* Register template: sdr::ctrlgrp::rfifocmap                              */
-#define SDR_CTRLGRP_RFIFOCMAP_RFIFOCPORTMAP_LSB 0
-#define SDR_CTRLGRP_RFIFOCMAP_RFIFOCPORTMAP_MASK 0x00ffffff
-/* Register template: sdr::ctrlgrp::wfifocmap                              */
-#define SDR_CTRLGRP_WFIFOCMAP_WFIFOCPORTMAP_LSB 0
-#define SDR_CTRLGRP_WFIFOCMAP_WFIFOCPORTMAP_MASK 0x00ffffff
-/* Register template: sdr::ctrlgrp::cportrdwr                              */
-#define SDR_CTRLGRP_CPORTRDWR_CPORTRDWR_LSB 0
-#define SDR_CTRLGRP_CPORTRDWR_CPORTRDWR_MASK 0x000fffff
-/* Register template: sdr::ctrlgrp::portcfg                                */
-#define SDR_CTRLGRP_PORTCFG_AUTOPCHEN_LSB 10
-#define SDR_CTRLGRP_PORTCFG_AUTOPCHEN_MASK 0x000ffc00
-#define SDR_CTRLGRP_PORTCFG_PORTPROTOCOL_LSB 0
-#define SDR_CTRLGRP_PORTCFG_PORTPROTOCOL_MASK 0x000003ff
-/* Register template: sdr::ctrlgrp::fifocfg                                */
-#define SDR_CTRLGRP_FIFOCFG_INCSYNC_LSB 10
-#define SDR_CTRLGRP_FIFOCFG_INCSYNC_MASK 0x00000400
-#define SDR_CTRLGRP_FIFOCFG_SYNCMODE_LSB 0
-#define SDR_CTRLGRP_FIFOCFG_SYNCMODE_MASK 0x000003ff
-/* Register template: sdr::ctrlgrp::mppriority                             */
-#define SDR_CTRLGRP_MPPRIORITY_USERPRIORITY_LSB 0
-#define SDR_CTRLGRP_MPPRIORITY_USERPRIORITY_MASK 0x3fffffff
-/* Register template: sdr::ctrlgrp::mpweight::mpweight_0                   */
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_0_STATICWEIGHT_31_0_LSB 0
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_0_STATICWEIGHT_31_0_MASK 0xffffffff
-/* Register template: sdr::ctrlgrp::mpweight::mpweight_1                   */
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_SUMOFWEIGHTS_13_0_LSB 18
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_SUMOFWEIGHTS_13_0_MASK 0xfffc0000
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_STATICWEIGHT_49_32_LSB 0
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_1_STATICWEIGHT_49_32_MASK 0x0003ffff
-/* Register template: sdr::ctrlgrp::mpweight::mpweight_2                   */
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_2_SUMOFWEIGHTS_45_14_LSB 0
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_2_SUMOFWEIGHTS_45_14_MASK 0xffffffff
-/* Register template: sdr::ctrlgrp::mpweight::mpweight_3                   */
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_3_SUMOFWEIGHTS_63_46_LSB 0
-#define SDR_CTRLGRP_MPWEIGHT_MPWEIGHT_3_SUMOFWEIGHTS_63_46_MASK 0x0003ffff
-/* Register template: sdr::ctrlgrp::mppacing::mppacing_0                   */
-#define SDR_CTRLGRP_MPPACING_MPPACING_0_THRESHOLD1_31_0_LSB 0
-#define SDR_CTRLGRP_MPPACING_MPPACING_0_THRESHOLD1_31_0_MASK 0xffffffff
-/* Register template: sdr::ctrlgrp::mppacing::mppacing_1                   */
-#define SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD2_3_0_LSB 28
-#define SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD2_3_0_MASK 0xf0000000
-#define SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD1_59_32_LSB 0
-#define SDR_CTRLGRP_MPPACING_MPPACING_1_THRESHOLD1_59_32_MASK 0x0fffffff
-/* Register template: sdr::ctrlgrp::mppacing::mppacing_2                   */
-#define SDR_CTRLGRP_MPPACING_MPPACING_2_THRESHOLD2_35_4_LSB 0
-#define SDR_CTRLGRP_MPPACING_MPPACING_2_THRESHOLD2_35_4_MASK 0xffffffff
-/* Register template: sdr::ctrlgrp::mppacing::mppacing_3                   */
-#define SDR_CTRLGRP_MPPACING_MPPACING_3_THRESHOLD2_59_36_LSB 0
-#define SDR_CTRLGRP_MPPACING_MPPACING_3_THRESHOLD2_59_36_MASK 0x00ffffff
-/* Register template: sdr::ctrlgrp::mpthresholdrst::mpthresholdrst_0       */
-#define \
-SDR_CTRLGRP_MPTHRESHOLDRST_0_THRESHOLDRSTCYCLES_31_0_LSB 0
-#define  \
-SDR_CTRLGRP_MPTHRESHOLDRST_0_THRESHOLDRSTCYCLES_31_0_MASK \
-0xffffffff
-/* Register template: sdr::ctrlgrp::mpthresholdrst::mpthresholdrst_1       */
-#define \
-SDR_CTRLGRP_MPTHRESHOLDRST_1_THRESHOLDRSTCYCLES_63_32_LSB 0
-#define \
-SDR_CTRLGRP_MPTHRESHOLDRST_1_THRESHOLDRSTCYCLES_63_32_MASK \
-0xffffffff
-/* Register template: sdr::ctrlgrp::mpthresholdrst::mpthresholdrst_2       */
-#define \
-SDR_CTRLGRP_MPTHRESHOLDRST_2_THRESHOLDRSTCYCLES_79_64_LSB 0
-#define \
-SDR_CTRLGRP_MPTHRESHOLDRST_2_THRESHOLDRSTCYCLES_79_64_MASK \
-0x0000ffff
-/* Register template: sdr::ctrlgrp::remappriority                          */
-#define SDR_CTRLGRP_REMAPPRIORITY_PRIORITYREMAP_LSB 0
-#define SDR_CTRLGRP_REMAPPRIORITY_PRIORITYREMAP_MASK 0x000000ff
-/* Register template: sdr::ctrlgrp::phyctrl::phyctrl_0                     */
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_SAMPLECOUNT_19_0_LSB 12
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_SAMPLECOUNT_19_0_WIDTH 20
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_SAMPLECOUNT_19_0_SET(x) \
- (((x) << 12) & 0xfffff000)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_ADDLATSEL_SET(x) \
- (((x) << 10) & 0x00000c00)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_DQSLOGICDELAYEN_SET(x) \
- (((x) << 6) & 0x000000c0)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_RESETDELAYEN_SET(x) \
- (((x) << 8) & 0x00000100)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_LPDDRDIS_SET(x) \
- (((x) << 9) & 0x00000200)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_DQSDELAYEN_SET(x) \
- (((x) << 4) & 0x00000030)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_DQDELAYEN_SET(x) \
- (((x) << 2) & 0x0000000c)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_0_ACDELAYEN_SET(x) \
- (((x) << 0) & 0x00000003)
-/* Register template: sdr::ctrlgrp::phyctrl::phyctrl_1                     */
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_1_LONGIDLESAMPLECOUNT_19_0_WIDTH 20
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_1_LONGIDLESAMPLECOUNT_19_0_SET(x) \
- (((x) << 12) & 0xfffff000)
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_1_SAMPLECOUNT_31_20_SET(x) \
- (((x) << 0) & 0x00000fff)
-/* Register template: sdr::ctrlgrp::phyctrl::phyctrl_2                     */
-#define SDR_CTRLGRP_PHYCTRL_PHYCTRL_2_LONGIDLESAMPLECOUNT_31_20_SET(x) \
- (((x) << 0) & 0x00000fff)
-/* Register template: sdr::ctrlgrp::dramodt                                */
-#define SDR_CTRLGRP_DRAMODT_READ_LSB 4
-#define SDR_CTRLGRP_DRAMODT_READ_MASK 0x000000f0
-#define SDR_CTRLGRP_DRAMODT_WRITE_LSB 0
-#define SDR_CTRLGRP_DRAMODT_WRITE_MASK 0x0000000f
-/* Field instance: sdr::ctrlgrp::dramsts                                   */
-#define SDR_CTRLGRP_DRAMSTS_DBEERR_MASK 0x00000008
-#define SDR_CTRLGRP_DRAMSTS_SBEERR_MASK 0x00000004
-/* Register template: sdr::ctrlgrp::extratime1                             */
-#define SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_LSB 20
-#define SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_BC_LSB 24
-#define SDR_CTRLGRP_EXTRATIME1_RD_TO_WR_DIFF_LSB 28
-
-/* SDRAM width macro for configuration with ECC */
-#define SDRAM_WIDTH_32BIT_WITH_ECC	40
-#define SDRAM_WIDTH_16BIT_WITH_ECC	24
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
+#include <asm/arch/sdram_gen5.h>
+#endif
 
 #endif
 #endif /* _SDRAM_H_ */
arch/arm/mach-socfpga/include/mach/sdram_gen5.h renamed from arch/arm/mach-socfpga/include/mach/sdram.h +3 -3
similarity index 99%
copy from arch/arm/mach-socfpga/include/mach/sdram.h
copy to arch/arm/mach-socfpga/include/mach/sdram_gen5.h
index b11228f..b16d776 100644
@@ -3,8 +3,8 @@
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
-#ifndef	_SDRAM_H_
-#define	_SDRAM_H_
+#ifndef	_SOCFPGA_SDRAM_GEN5_H_
+#define	_SOCFPGA_SDRAM_GEN5_H_
 
 #ifndef __ASSEMBLY__
 
@@ -439,4 +439,4 @@ SDR_CTRLGRP_MPTHRESHOLDRST_2_THRESHOLDRSTCYCLES_79_64_MASK \
 #define SDRAM_WIDTH_16BIT_WITH_ECC	24
 
 #endif
-#endif /* _SDRAM_H_ */
+#endif /* _SOCFPGA_SDRAM_GEN5_H_ */
drivers/ddr/altera/Makefile +1 -1
index bdd2872..ac4ab85 100644
@@ -9,5 +9,5 @@
 #
 
 ifdef CONFIG_ALTERA_SDRAM
-obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram.o sequencer.o
+obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
 endif
drivers/ddr/altera/sdram_gen5.c renamed from drivers/ddr/altera/sdram.c +0 -0
similarity index 100%
rename from drivers/ddr/altera/sdram.c
rename to drivers/ddr/altera/sdram_gen5.c
Signature · 1 line
2.2.0
#20 lore raw

PATCH v5 11/20 arm: socfpga: Add DRAM bank size initialization function

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add function for both multiple DRAM bank and single DRAM bank size initialization. This common functionality could be used by every single SOCFPGA board.

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +
 2 files changed, 8 insertions(+)
arch/arm/mach-socfpga/board.c +7 -0
index a41d089..965f9dc 100644
@@ -29,6 +29,13 @@ int board_init(void)
 	return 0;
 }
 
+int dram_init_banksize(void)
+{
+	fdtdec_setup_memory_banksize();
+
+	return 0;
+}
+
 #ifdef CONFIG_USB_GADGET
 struct dwc2_plat_otg_data socfpga_otg_data = {
 	.usb_gusbcfg	= 0x1417,
include/configs/socfpga_common.h +1 -0
index 7b5417a..0d1cde6 100644
@@ -43,6 +43,7 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 #define CONFIG_SYS_SDRAM_BASE		PHYS_SDRAM_1
+#define CONFIG_SYS_SDRAM_SIZE		PHYS_SDRAM_1_SIZE
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_TEXT_BASE		0x08000040
 #else
Signature · 1 line
2.2.0
#21 lore raw

PATCH v5 12/20 arm: socfpga: Add DDR driver for Arria 10

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add DDR driver support for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 +
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h |   2 +
 drivers/ddr/altera/Makefile                        |   1 +
 drivers/ddr/altera/sdram_arria10.c                 | 733 +++++++++++++++++++++
 4 files changed, 738 insertions(+)
 create mode 100644 drivers/ddr/altera/sdram_arria10.c
arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
index 137e073..33f830b 100644
@@ -10,6 +10,8 @@
 
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/sdram_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/sdram_arria10.h>
 #endif
 
 #endif
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +2 -0
index 1d7b7c1..e7a2503 100644
@@ -8,6 +8,7 @@
 #define _SOCFPGA_SDRAM_ARRIA10_H_
 
 #ifndef __ASSEMBLY__
+int ddr_calibration_sequence(void);
 
 struct socfpga_ecc_hmc {
 	u32 ip_rev_id;
@@ -204,6 +205,7 @@ struct socfpga_io48_mmr {
 	u32 niosreserve1;
 	u32 niosreserve2;
 };
+
 #endif /*__ASSEMBLY__*/
 
 #define IO48_MMR_CTRLCFG0_DB2_BURST_LENGTH_MASK		0x1F000000
drivers/ddr/altera/Makefile +1 -0
index ac4ab85..02f8b7c 100644
@@ -10,4 +10,5 @@
 
 ifdef CONFIG_ALTERA_SDRAM
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
 endif
drivers/ddr/altera/sdram_arria10.c new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
2.2.0
#22 lore raw

PATCH v5 13/20 configs: Add DDR Kconfig support for Arria 10

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This patch enables DDR Kconfig support for Arria 10.

---
 arch/arm/mach-socfpga/Kconfig | 1 +
 drivers/ddr/altera/Kconfig    | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/Kconfig +1 -0
index 45e5379..3e7a68a 100644
@@ -40,6 +40,7 @@ config TARGET_SOCFPGA_ARRIA5
 config TARGET_SOCFPGA_ARRIA10
 	bool
 	select SPL_BOARD_INIT if SPL
+	select ALTERA_SDRAM
 
 config TARGET_SOCFPGA_CYCLONE5
 	bool
drivers/ddr/altera/Kconfig +1 -1
index 021ec1d..2b28a97 100644
@@ -1,5 +1,5 @@
 config ALTERA_SDRAM
 	bool "SoCFPGA DDR SDRAM driver"
-	depends on TARGET_SOCFPGA_GEN5
+	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	help
 	  Enable DDR SDRAM controller for the SoCFPGA devices.
Signature · 1 line
2.2.0
#23 lore raw

PATCH v5 14/20 arm: socfpga: Enable SPL memory allocation

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable memory allocation in SPL for preparation to enable FAT in SPL. Memory allocation is needed by FAT to work properly.

---
 include/configs/socfpga_common.h | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +21 -1
index 0d1cde6..218eb05 100644
@@ -274,17 +274,33 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 /*
  * SPL
  *
- * SRAM Memory layout:
+ * SRAM Memory layout for gen 5:
  *
  * 0xFFFF_0000 ...... Start of SRAM
  * 0xFFFF_xxxx ...... Top of stack (grows down)
  * 0xFFFF_yyyy ...... Malloc area
  * 0xFFFF_zzzz ...... Global Data
  * 0xFFFF_FF00 ...... End of SRAM
+ *
+ * SRAM Memory layout for Arria 10:
+ * 0xFFE0_0000 ...... Start of SRAM (bottom)
+ * 0xFFEx_xxxx ...... Top of stack (grows down to bottom)
+ * 0xFFEy_yyyy ...... Global Data
+ * 0xFFEz_zzzz ...... Malloc area (grows up to top)
+ * 0xFFE3_FFFF ...... End of SRAM (top)
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
 #define CONFIG_SPL_MAX_SIZE		CONFIG_SYS_INIT_RAM_SIZE
+#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	0x00010000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RAM_SIZE - \
+					 CONFIG_SYS_SPL_MALLOC_SIZE + \
+					 CONFIG_SYS_INIT_RAM_ADDR)
+#endif
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -314,7 +330,11 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 /*
  * Stack setup
  */
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_STACK		CONFIG_SYS_SPL_MALLOC_START
+#endif
 
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.2.0
#24 lore raw

PATCH v5 15/20 arm: socfpga: Improve comments for Intel SoCFPGA program header

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Adding some details about size in bytes to each section.

---
 arch/arm/mach-socfpga/include/mach/boot0.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +2 -2
index 22d9e7f..e06b548 100644
@@ -11,8 +11,8 @@
 	.balignl 64,0xf33db33f;
 
 	.word	0x1337c0d3;	/* SoCFPGA preloader validation word */
-	.word	0xc01df00d;	/* Version, flags, length */
-	.word	0xcafec0d3;	/* Checksum, zero-pad */
+	.word	0xc01df00d;	/* Header length(2B),flags(1B),version(1B) */
+	.word	0xcafec0d3;	/* Simple checksum(2B),spare offset(2B) */
 	nop;
 
 	b reset;		/* SoCFPGA jumps here */
Signature · 1 line
2.2.0
#25 lore raw

PATCH v5 16/20 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enhance preloader header with both additional program length and program entry offset attributes, which offset is relative to the start of program header.

---
 arch/arm/mach-socfpga/include/mach/boot0.h | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-socfpga/include/mach/boot0.h +7 -0
index e06b548..b21b871 100644
@@ -12,6 +12,13 @@
 
 	.word	0x1337c0d3;	/* SoCFPGA preloader validation word */
 	.word	0xc01df00d;	/* Header length(2B),flags(1B),version(1B) */
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface;	/* Program length(4B) */
+	.word	0xf00dcafe;	/*
+				 * Program entry offset(4B),relative to
+				 * the start of program header
+				 */
+#endif
 	.word	0xcafec0d3;	/* Simple checksum(2B),spare offset(2B) */
 	nop;
 
Signature · 1 line
2.2.0
#26 lore raw

PATCH v5 17/20 arm: socfpga: Adding clock frequency info for U-Boot

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-Boot because info would be erased when transition from SPL to U-Boot.

---
 arch/arm/mach-socfpga/board.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-socfpga/board.c +7 -0
index 965f9dc..8d3b515 100644
@@ -8,7 +8,9 @@
 
 #include <common.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <asm/arch/reset_manager.h>
+#include <asm/arch/clock_manager.h>
 #include <asm/io.h>
 
 #include <usb.h>
@@ -26,6 +28,11 @@ int board_init(void)
 	/* Address of boot parameters for ATAG (if ATAG is used) */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+#endif
+
 	return 0;
 }
 
Signature · 1 line
2.2.0
#27 lore raw

PATCH v5 18/20 arm: socfpga: Adding SoCFPGA info for both SPL and U-Boot

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

SoC FPGA info is required in both SPL and U-Boot.

---
 arch/arm/mach-socfpga/board.c        | 4 ++++
 arch/arm/mach-socfpga/misc_arria10.c | 5 -----
 arch/arm/mach-socfpga/spl.c          | 6 ++++++
 3 files changed, 10 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/board.c +4 -0
index 8d3b515..7beb347 100644
@@ -11,6 +11,7 @@
 #include <fdtdec.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/arch/clock_manager.h>
+#include <asm/arch/misc.h>
 #include <asm/io.h>
 
 #include <usb.h>
@@ -31,6 +32,9 @@ int board_init(void)
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 	/* configuring the clock based on handoff */
 	cm_basic_init(gd->fdt_blob);
+
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
 #endif
 
 	return 0;
arch/arm/mach-socfpga/misc_arria10.c +0 -5
index 9d751f6..8760ac9 100644
@@ -94,11 +94,6 @@ int arch_early_init_r(void)
 	/* assert reset to all except L4WD0 and L4TIMER0 */
 	socfpga_per_reset_all();
 
-	/* configuring the clock based on handoff */
-	/* TODO: Add call to cm_basic_init() */
-
-	/* Add device descriptor to FPGA device table */
-	socfpga_fpga_add();
 	return 0;
 }
 #else
arch/arm/mach-socfpga/spl.c +6 -0
index 71bae82..aba116d 100644
@@ -15,6 +15,7 @@
 #include <asm/arch/system_manager.h>
 #include <asm/arch/freeze_controller.h>
 #include <asm/arch/clock_manager.h>
+#include <asm/arch/misc.h>
 #include <asm/arch/scan_manager.h>
 #include <asm/arch/sdram.h>
 #include <asm/arch/scu.h>
@@ -208,6 +209,11 @@ void spl_board_init(void)
 
 	/* enable console uart printing */
 	preloader_console_init();
+
+	WATCHDOG_RESET();
+
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
 }
 
 void board_init_f(ulong dummy)
Signature · 1 line
2.2.0
#28 lore raw

PATCH v5 19/20 arm: socfpga: Enable DDR working

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

SPL configures DDR by programming peripheral raw binary file and calibrating DDR.

---
 arch/arm/mach-socfpga/spl.c       | 43 +++++++++++++++++++++++++++++++++++++++
 configs/socfpga_arria10_defconfig | 17 +++++++++++++---
 2 files changed, 57 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/spl.c +43 -0
index aba116d..60159b2 100644
@@ -15,13 +15,19 @@
 #include <asm/arch/system_manager.h>
 #include <asm/arch/freeze_controller.h>
 #include <asm/arch/clock_manager.h>
+#include <asm/arch/fpga_manager.h>
 #include <asm/arch/misc.h>
 #include <asm/arch/scan_manager.h>
 #include <asm/arch/sdram.h>
 #include <asm/arch/scu.h>
 #include <asm/arch/nic301.h>
 #include <asm/sections.h>
+#include <environment.h>
 #include <fdtdec.h>
+#include <fat.h>
+#include <fs.h>
+#include <linux/ctype.h>
+#include <mmc.h>
 #include <watchdog.h>
 #if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 #include <asm/arch/pinmux.h>
@@ -29,6 +35,9 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define BSIZE	4096
+#define PERIPH_RBF	0
+
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct pl310_regs *const pl310 =
 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
@@ -197,6 +206,12 @@ void board_init_f(ulong dummy)
 #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 void spl_board_init(void)
 {
+	int rval = 0;
+	int len = 0;
+	u32 buffer[BSIZE] __aligned(ARCH_DMA_MINALIGN);
+	struct spl_boot_device bootdev;
+	fpga_fs_info fpga_fsinfo;
+
 	/* configuring the clock based on handoff */
 	cm_basic_init(gd->fdt_blob);
 	WATCHDOG_RESET();
@@ -214,6 +229,34 @@ void spl_board_init(void)
 
 	/* Add device descriptor to FPGA device table */
 	socfpga_fpga_add();
+
+	set_default_env(NULL);
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		fpga_fsinfo.interface = "mmc";
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	}
+
+	fpga_fsinfo.filename = (char *)get_cff_filename(gd->fdt_blob,
+							&len,
+							PERIPH_RBF);
+
+	fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd->fdt_blob,
+						       &len);
+
+	if (fpga_fsinfo.dev_part)
+		env_set("FW_DEV_PART", fpga_fsinfo.dev_part);
+
+	/* Program peripheral RBF */
+	rval = fpga_fsload(0, buffer, BSIZE, &fpga_fsinfo);
+
+	if (!rval) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}
 }
 
 void board_init_f(ulong dummy)
configs/socfpga_arria10_defconfig +14 -3
index 4c73d73..14adbd8 100644
@@ -7,28 +7,39 @@ CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200"
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_FIT=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_SPL_FIT=y
 CONFIG_SPL=y
 CONFIG_SPL_FPGA_SUPPORT=y
+CONFIG_SPL_FAT_SUPPORT=y
+CONFIG_FS_FAT_MAX_CLUSTSIZE=32768
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_GPIO=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y
 CONFIG_DOS_PARTITION=y
-# CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SPL_DOS_PARTITION=y
+CONFIG_SPL_FS_GENERIC=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DFU_MMC=y
 CONFIG_FPGA_SOCFPGA=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
 CONFIG_SYS_NS16550=y
 CONFIG_USE_TINY_PRINTF=y
+CONFIG_CMD_FPGA_LOADFS=y
+CONFIG_SPL_MMC_SUPPORT=y
Signature · 1 line
2.2.0
#29 lore raw

PATCH v5 20/20 arm: socfpga: Enable SPL booting U-boot

In reply to tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable SPL successfully boot to U-boot.

---
 configs/socfpga_arria10_defconfig | 41 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)
configs/socfpga_arria10_defconfig +36 -5
index 14adbd8..5211b99 100644
@@ -1,16 +1,18 @@
 CONFIG_ARM=y
 CONFIG_ARCH_SOCFPGA=y
-CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y
 CONFIG_IDENT_STRING="socfpga_arria10"
 CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
-CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyS0,115200"
 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
 CONFIG_FIT=y
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_FIT=y
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL=y
+CONFIG_HUSH_PARSER=y
 CONFIG_SPL_FPGA_SUPPORT=y
 CONFIG_SPL_FAT_SUPPORT=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=32768
@@ -19,14 +21,22 @@ CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_ASKENV=y
 CONFIG_CMD_GREPENV=y
 # CONFIG_CMD_FLASH is not set
-CONFIG_CMD_GPIO=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_CMD_PART=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DFU=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_MII=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_CACHE=y
 CONFIG_DOS_PARTITION=y
-CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SPL_DOS_PARTITION=y
 CONFIG_SPL_FS_GENERIC=y
 CONFIG_CMD_FAT=y
@@ -39,7 +49,28 @@ CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
 CONFIG_SYS_NS16550=y
 CONFIG_USE_TINY_PRINTF=y
 CONFIG_CMD_FPGA_LOADFS=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DWC2_OTG=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_G_DNL_MANUFACTURER="altera"
+CONFIG_G_DNL_VENDOR_NUM=0x0525
+CONFIG_G_DNL_PRODUCT_NUM=0xa4a5
+CONFIG_USE_TINY_PRINTF=y
 CONFIG_SPL_MMC_SUPPORT=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x800
+CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
Signature · 1 line
2.2.0