Skip to contentSkip to conversation

Add FPGA, SDRAM, SPL loads U-boot & booting to console

PATCH Superseded tien.fong.chee at intel.com 5 participants 88 messages Sep 25, 2017 – Dec 10, 2017

Subsystems (6)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add FPGA, SDRAM, SPL loads U-boot & booting to console

From: Tien Fong Chee <[email protected]>

This patchset adding FPGA and SDRAM drivers, enable fpga loadfs to program FPGA , SPL loading U-boot and booting to U-boot console. This version mainly resolved comments from Marek in [v1].
This series is working on top of u-boot.git - http://git.denx.de/u-boot.git .

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

Tien Fong Chee (19):
ARM: socfpga: add bindings doc for arria10 fpga manager
doc: dtbinding: 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
arm: socfpga: Enhance FPGA program write rbf data with size >= 4 bytes
dts: Enable fpga-mgr node build for Arria 10 SPL
fdt: Add compatible strings for Arria 10
fs: Enable generic filesystems interface support in SPL.
arm: socfpga: Add drivers for programing FPGA from flash
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 build for DDR Arria 10
arm: socfpga: Add support to memory allocation in SPL
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 SPL loading U-boot to DDR and booting U-boot

 arch/arm/dts/socfpga_arria10.dtsi                  |   4 +
 arch/arm/mach-socfpga/Kconfig                      |   1 +
 arch/arm/mach-socfpga/board.c                      |  16 +
 arch/arm/mach-socfpga/include/mach/boot0.h         |  11 +-
 .../include/mach/fpga_manager_arria10.h            |  27 +
 arch/arm/mach-socfpga/include/mach/sdram.h         | 436 +-----------
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++-
 .../include/mach/{sdram.h => sdram_gen5.h}         |   6 +-
 arch/arm/mach-socfpga/misc_arria10.c               |   5 -
 arch/arm/mach-socfpga/spl.c                        |  61 ++
 cmd/fpga.c                                         |   2 +-
 common/spl/Kconfig                                 |   8 +
 common/spl/spl_mmc.c                               |   2 +-
 configs/socfpga_arria10_defconfig                  |  57 +-
 doc/README.SPL                                     |   1 +
 .../fpga/altera-socfpga-a10-fpga-mgr.txt           |  30 +
 drivers/ddr/altera/Kconfig                         |   2 +-
 drivers/ddr/altera/Makefile                        |   3 +-
 drivers/ddr/altera/sdram_arria10.c                 | 735 +++++++++++++++++++++
 drivers/ddr/altera/{sdram.c => sdram_gen5.c}       |   0
 drivers/fpga/altera.c                              |  39 +-
 drivers/fpga/fpga.c                                |   8 +
 drivers/fpga/socfpga.c                             |  14 +-
 drivers/fpga/socfpga_arria10.c                     | 391 ++++++++++-
 fs/Makefile                                        |   1 +
 include/altera.h                                   |   6 +
 include/configs/socfpga_common.h                   |  28 +-
 include/fdtdec.h                                   |   2 +
 include/fpga.h                                     |   2 +
 include/spl.h                                      |   2 +
 lib/fdtdec.c                                       |   2 +
 31 files changed, 1535 insertions(+), 470 deletions(-)
 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h} (99%)
 create mode 100644 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
 create mode 100644 drivers/ddr/altera/sdram_arria10.c
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)
Signature · 1 line
2.2.0
#1 lore raw

PATCH v2 1/19 ARM: socfpga: add bindings doc for arria10 fpga manager

From: Tien Fong Chee <[email protected]>

This DT binding doc is porting from Linux DT binding doc. commit 1adcbea4201a6852362aa5ece573f1f169b28113

Add a device tree bindings document for the SoCFPGA Arria10 FPGA Manager driver.

---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt              | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt new file +19 -0
new file mode 100644
index 0000000..2fd8e7a
@@ -0,0 +1,19 @@
+Altera SOCFPGA Arria10 FPGA Manager
+
+Required properties:
+- compatible : should contain "altr,socfpga-a10-fpga-mgr"
+- reg        : base address and size for memory mapped io.
+               - The first index is for FPGA manager register access.
+               - 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.
+
+Example:
+
+	fpga_mgr: fpga-mgr at ffd03000 {
+		compatible = "altr,socfpga-a10-fpga-mgr";
+		reg = <0xffd03000 0x100
+		       0xffcfe400 0x20>;
+		clocks = <&l4_mp_clk>;
+		resets = <&rst FPGAMGR_RESET>;
+	};
Signature · 1 line
2.2.0
Applied
#2 lore raw

PATCH v2 1/19 ARM: socfpga: add bindings doc for arria10 fpga manager

Quoted 5 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This DT binding doc is porting from Linux DT binding doc. commit 1adcbea4201a6852362aa5ece573f1f169b28113

Quoted 8 lines

Add a device tree bindings document for the SoCFPGA Arria10 FPGA Manager driver.

Applied, thanks

Quoted 31 lines
---
 .../fpga/altera-socfpga-a10-fpga-mgr.txt              | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt new file +19 -0
new file mode 100644
index 0000000..2fd8e7a
@@ -0,0 +1,19 @@
+Altera SOCFPGA Arria10 FPGA Manager
+
+Required properties:
+- compatible : should contain "altr,socfpga-a10-fpga-mgr"
+- reg        : base address and size for memory mapped io.
+               - The first index is for FPGA manager register access.
+               - 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.
+
+Example:
+
+	fpga_mgr: fpga-mgr at ffd03000 {
+		compatible = "altr,socfpga-a10-fpga-mgr";
+		reg = <0xffd03000 0x100
+		       0xffcfe400 0x20>;
+		clocks = <&l4_mp_clk>;
+		resets = <&rst FPGAMGR_RESET>;
+	};
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

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

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..7abb746 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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR.
+- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- 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>;
+		bitstream_periph = "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core = "ghrd_10as066n2.core.rbf.mkimage";
+		bitstream_devpart = "0:1";
 	};
Signature · 1 line
2.2.0
#4 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 6 lines · tien.fong.chee at intel.com

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.

Why does this patch have different tags than 1/19 ? Please keep things consistent ...

Quoted 32 lines
---
 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..7abb746 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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR.
+- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- 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>;
+		bitstream_periph = "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core = "ghrd_10as066n2.core.rbf.mkimage";
+		bitstream_devpart = "0:1";
 	};
Signature · 2 lines
Best regards,
Marek Vasut
#5 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 4 lines · Marek Vasut
Quoted 3 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Quoted 9 lines
Quoted 5 lines

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

Why does this patch have different tags than 1/19 ? Please keep things
consistent ...

Not get you. What's you means for tags?

Quoted 44 lines
Quoted 43 lines

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt | 11
+++++++++++

 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt
index 2fd8e7a..7abb746 100644

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR. +- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- bitstream_devpart : Partition of flash device where bitstream files are

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device number,

part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

  };

#6 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 9 lines · Tien Fong
Quoted 8 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

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.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Why does this patch have different tags than 1/19 ? Please keep things
consistent ...

Not get you. What's you means for tags?

ARM: socfpga: , not the random doc: dtbinding: . Heck, the first and second patch change the same file, yet have different tags, why ?

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt | 11
+++++++++++

 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt
index 2fd8e7a..7abb746 100644

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR. +- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- bitstream_devpart : Partition of flash device where bitstream files are

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device number,

part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

  };

Signature · 2 lines
Best regards,
Marek Vasut
#7 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 15 lines · Marek Vasut
Quoted 14 lines · Tien Fong
Quoted 12 lines · Marek Vasut
Quoted 10 lines · tien.fong.chee at intel.com

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.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines

Why does this patch have different tags than 1/19 ? Please keep things
consistent ...

Not get you. What's you means for tags?

ARM: socfpga: , not the random doc: dtbinding: . Heck, the first and second patch change the same file, yet have different tags, why ?

I ported patch 01 from Linux, so i keep everything intact. For patch 02, i put doc:dtbinding because i think that is more descriptive to the file i changed.
I can change to ARM:socfpga .

Quoted 56 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt | 11
+++++++++++

 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

fpga-
mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10- fpga-
mgr.txt
index 2fd8e7a..7abb746 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt

(quoted diff) +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is used
to
+                     initialize FPGA IOs, PLL, IO48 and DDR. +- bitstream_core : FPGA core raw binary file contains FPGA design
which is used
+                   to program FPGA CRAM and ERAM. +- bitstream_devpart : Partition of flash device where bitstream
files are

(quoted diff) +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device

number,
part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

  };

#8 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 21 lines · Tien Fong
Quoted 20 lines · Marek Vasut
Quoted 19 lines · Tien Fong
Quoted 11 lines · Marek Vasut
Quoted 9 lines · tien.fong.chee at intel.com

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.

Quoted 5 lines
Quoted 1 line

Why does this patch have different tags than 1/19 ? Please keep things
consistent ...

Not get you. What's you means for tags?

Quoted 8 lines
Quoted 4 lines

ARM: socfpga: , not the random doc: dtbinding: . Heck, the first and second patch change the same file, yet have different tags, why ?

I ported patch 01 from Linux, so i keep everything intact. For patch 02, i put doc:dtbinding because i think that is more descriptive to the file i changed.
I can change to ARM:socfpga .

The tags are standardized ... inventing new random ones only messes things up.

Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines
Quoted 55 lines

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt | 11
+++++++++++

 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

fpga-
mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10- fpga-
mgr.txt
index 2fd8e7a..7abb746 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt

(quoted diff) +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is used
to
+                     initialize FPGA IOs, PLL, IO48 and DDR. +- bitstream_core : FPGA core raw binary file contains FPGA design
which is used
+                   to program FPGA CRAM and ERAM. +- bitstream_devpart : Partition of flash device where bitstream
files are

(quoted diff) +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device

number,
part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

  };

Signature · 2 lines
Best regards,
Marek Vasut
#9 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 33 lines · Marek Vasut
Quoted 32 lines · Tien Fong
Quoted 30 lines · Marek Vasut
Quoted 17 lines · Tien Fong
Quoted 14 lines · Marek Vasut
Quoted 11 lines · tien.fong.chee at intel.com

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.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Why does this patch have different tags than 1/19 ? Please keep
things
consistent ...

Not get you. What's you means for tags?

ARM: socfpga: , not the random doc: dtbinding: . Heck, the first and second patch change the same file, yet have different tags, why ?

Quoted 9 lines
Quoted 6 lines

I ported patch 01 from Linux, so i keep everything intact. For patch
02, i put doc:dtbinding because i think that is more descriptive to the
file i changed.
I can change to ARM:socfpga .

The tags are standardized ... inventing new random ones only messes things up.

Okay.

Quoted 69 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines
Quoted 68 lines

---
 doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt

Quoted 2 lines

11

+++++++++++

 1 file changed, 11 insertions(+)
(quoted diff) +0 -0

a10-
fpga-
mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10- fpga-
mgr.txt
index 2fd8e7a..7abb746 100644
--- a/doc/device-tree-bindings/fpga/altera-socfpga-a10- fpga-
mgr.txt
+++ b/doc/device-tree-bindings/fpga/altera-socfpga-a10- fpga-
mgr.txt

(quoted diff) +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is
used
to
+                     initialize FPGA IOs, PLL, IO48 and DDR.
+- bitstream_core : FPGA core raw binary file contains FPGA design
which is used
+                   to program FPGA CRAM and ERAM. +- bitstream_devpart : Partition of flash device where bitstream
files are

(quoted diff) +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device

number,
part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

  };

#10 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

In reply to tien.fong.chee at intel.com
Quoted 30 lines · tien.fong.chee at intel.com

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 +8 -0
index 2fd8e7a..7abb746 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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR.
+- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- bitstream_devpart : Partition of flash device where bitstream files are
+		       stored.
+                      <dev[:part]> - dev is flash device number, part is flash
+                                     device partition.
 
 Example:
 

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt Example: · line 29

Quoted 6 lines
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +3 -0
@@ -16,4 +24,7 @@ Example:
 		       0xffcfe400 0x20>;
 		clocks = <&l4_mp_clk>;
 		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph = "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core = "ghrd_10as066n2.core.rbf.mkimage";
+		bitstream_devpart = "0:1";

These should probably be altr,something-something ... they are definitely not generic bindings

Quoted 2 lines
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +0 -0
 	};
Signature · 2 lines
Best regards,
Marek Vasut
#11 lore raw

PATCH v2 2/19 doc: dtbinding: Description on FPGA RBF properties at Arria 10 FPGA manager

Quoted 43 lines · Marek Vasut
Quoted 42 lines · tien.fong.chee at intel.com

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(+)
(quoted diff) +0 -0

mgr.txt b/doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga- mgr.txt
index 2fd8e7a..7abb746 100644

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +0 -0
@@ -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.
+- bitstream_periph : FPGA peripheral raw binary file which is used to
+                     initialize FPGA IOs, PLL, IO48 and DDR. +- bitstream_core : FPGA core raw binary file contains FPGA design which is used
+                   to program FPGA CRAM and ERAM.
+- bitstream_devpart : Partition of flash device where bitstream files are

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
+		       stored.
+                      <dev[:part]> - dev is flash device number,

part is flash
+                                     device partition.
 Example:

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +0 -0
@@ -16,4 +24,7 @@ Example:
  		       0xffcfe400 0x20>;
  		clocks = <&l4_mp_clk>;
Quoted 9 lines

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt Example: · line 29

Quoted 6 lines
doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +2 -0
  		resets = <&rst FPGAMGR_RESET>;
+		bitstream_periph =
 "ghrd_10as066n2.periph.rbf.mkimage";
+		bitstream_core =

"ghrd_10as066n2.core.rbf.mkimage";

doc/device-tree-bindings/fpga/altera-socfpga-a10-fpga-mgr.txt +1 -0
+		bitstream_devpart = "0:1";

These should probably be altr,something-something ... they are definitely not generic bindings

Okay.

Quoted 4 lines
Quoted 3 lines

  };

#12 lore raw

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

PATCH v2 4/19 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 | 39 +++++++++++++++++++++++++++++++--------
 drivers/fpga/fpga.c   |  8 ++++++++
 include/fpga.h        |  2 ++
 4 files changed, 42 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 +31 -8
index 135a357..e2bee99 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,20 @@ 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 0;
+}
+#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
#14 lore raw

PATCH v2 4/19 arm: socfpga: Add Arria 10 SoCFPGA programming interface

Quoted 8 lines · 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.

---

[...]

Quoted 4 lines
drivers/fpga/altera.c +4 -0
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int altera_loadfs(Altera_desc *desc, const void *buf, size_t bsize,
+		   fpga_fs_info *fpga_fsinfo)
+{

drivers/fpga/altera.c int altera_info(Altera_desc *desc) · line 197

Quoted 10 lines
drivers/fpga/altera.c +10 -0
+	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 0;

return -EINVAL , since the loader could not be started ?

Quoted 2 lines
drivers/fpga/altera.c +2 -0
+}
+#endif

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#15 lore raw

PATCH v2 4/19 arm: socfpga: Add Arria 10 SoCFPGA programming interface

Quoted 24 lines · Marek Vasut
Quoted 9 lines · 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.

---

[...]

Quoted 12 lines
(quoted diff) +2 -0
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+int altera_loadfs(Altera_desc *desc, const void *buf, size_t

bsize,

drivers/fpga/altera.c +3 -0
+		   fpga_fs_info *fpga_fsinfo)
+{
+	const struct altera_fpga *fpga = altera_desc_to_fpga(desc,

__func__);

drivers/fpga/altera.c +4 -0
+
+	if (!fpga)
+		return FPGA_FAIL;
+
Quoted 9 lines

drivers/fpga/altera.c int altera_info(Altera_desc *desc) · line 197

Quoted 7 lines
(quoted diff) +1 -0
+	debug_cond(FPGA_DEBUG, "%s: Launching the %s FS

Loader...\n",

drivers/fpga/altera.c +3 -0
+		   __func__, fpga->name);
+	if (fpga->loadfs)
+		return fpga->loadfs(desc, buf, bsize,

fpga_fsinfo);

drivers/fpga/altera.c +1 -0
+	return 0;

return -EINVAL , since the loader could not be started ?

Okay.

Quoted 5 lines
Quoted 3 lines
drivers/fpga/altera.c +2 -0
+}
+#endif

[...]

#16 lore raw

PATCH v2 5/19 arm: socfpga: Enhance FPGA program write rbf data with size >= 4 bytes

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

From: Tien Fong Chee <[email protected]>

Existing FPGA program write is always assume RBF data >= 32 bytes, so any rbf data less than 32 bytes writing to FPGA would be failed. This patch enhances the FPGA program write to support rbf data with size >= 4 bytes.

---
 drivers/fpga/socfpga.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/fpga/socfpga.c +8 -6
index 28fa16b..6e14ebd 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Altera Corporation <www.altera.com>
+ * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
  * All rights reserved.
  *
  * SPDX-License-Identifier:	BSD-3-Clause
@@ -55,18 +55,20 @@ void fpgamgr_program_write(const void *rbf_data, size_t rbf_size)
 	uint32_t loops4 = DIV_ROUND_UP(rbf_size % 32, 4);
 
 	asm volatile(
+		"	cmp	%2,	#0\n"
+		"	beq	2f\n"
 		"1:	ldmia	%0!,	{r0-r7}\n"
 		"	stmia	%1!,	{r0-r7}\n"
 		"	sub	%1,	#32\n"
 		"	subs	%2,	#1\n"
 		"	bne	1b\n"
-		"	cmp	%3,	#0\n"
-		"	beq	3f\n"
-		"2:	ldr	%2,	[%0],	#4\n"
+		"2:	cmp	%3,	#0\n"
+		"	beq	4f\n"
+		"3:	ldr	%2,	[%0],	#4\n"
 		"	str	%2,	[%1]\n"
 		"	subs	%3,	#1\n"
-		"	bne	2b\n"
-		"3:	nop\n"
+		"	bne	3b\n"
+		"4:	nop\n"
 		: "+r"(src), "+r"(dst), "+r"(loops32), "+r"(loops4) :
 		: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "cc");
 }
Signature · 1 line
2.2.0
Applied
#17 lore raw

PATCH v2 5/19 arm: socfpga: Enhance FPGA program write rbf data with size >= 4 bytes

Quoted 8 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Existing FPGA program write is always assume RBF data >= 32 bytes, so any rbf data less than 32 bytes writing to FPGA would be failed. This patch enhances the FPGA program write to support rbf data with size >= 4 bytes.

Applied, thanks

Quoted 42 lines
---
 drivers/fpga/socfpga.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/fpga/socfpga.c +8 -6
index 28fa16b..6e14ebd 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012 Altera Corporation <www.altera.com>
+ * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
  * All rights reserved.
  *
  * SPDX-License-Identifier:	BSD-3-Clause
@@ -55,18 +55,20 @@ void fpgamgr_program_write(const void *rbf_data, size_t rbf_size)
 	uint32_t loops4 = DIV_ROUND_UP(rbf_size % 32, 4);
 
 	asm volatile(
+		"	cmp	%2,	#0\n"
+		"	beq	2f\n"
 		"1:	ldmia	%0!,	{r0-r7}\n"
 		"	stmia	%1!,	{r0-r7}\n"
 		"	sub	%1,	#32\n"
 		"	subs	%2,	#1\n"
 		"	bne	1b\n"
-		"	cmp	%3,	#0\n"
-		"	beq	3f\n"
-		"2:	ldr	%2,	[%0],	#4\n"
+		"2:	cmp	%3,	#0\n"
+		"	beq	4f\n"
+		"3:	ldr	%2,	[%0],	#4\n"
 		"	str	%2,	[%1]\n"
 		"	subs	%3,	#1\n"
-		"	bne	2b\n"
-		"3:	nop\n"
+		"	bne	3b\n"
+		"4:	nop\n"
 		: "+r"(src), "+r"(dst), "+r"(loops32), "+r"(loops4) :
 		: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "cc");
 }
Signature · 2 lines
Best regards,
Marek Vasut
#18 lore raw

PATCH v2 6/19 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 d4368ce..188a039 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
#19 lore raw

PATCH v2 7/19 fdt: Add compatible strings for Arria 10

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

From: Tien Fong Chee <[email protected]>

Add compatible strings for Intel Arria 10 SoCFPGA device.

---
 include/fdtdec.h | 2 ++
 lib/fdtdec.c     | 2 ++
 2 files changed, 4 insertions(+)
include/fdtdec.h +2 -0
index 4a0947c..095ff36 100644
@@ -157,6 +157,8 @@ enum fdt_compat_id {
 	COMPAT_ALTERA_SOCFPGA_F2SDR0,           /* SoCFPGA fpga2SDRAM0 bridge */
 	COMPAT_ALTERA_SOCFPGA_F2SDR1,           /* SoCFPGA fpga2SDRAM1 bridge */
 	COMPAT_ALTERA_SOCFPGA_F2SDR2,           /* SoCFPGA fpga2SDRAM2 bridge */
+	COMPAT_ALTERA_SOCFPGA_FPGA0,		/* SOCFPGA FPGA manager */
+	COMPAT_ALTERA_SOCFPGA_NOC,		/* SOCFPGA Arria 10 NOC */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +2 -0
index 107a892..03ff75e 100644
@@ -70,6 +70,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(ALTERA_SOCFPGA_F2SDR0, "altr,socfpga-fpga2sdram0-bridge"),
 	COMPAT(ALTERA_SOCFPGA_F2SDR1, "altr,socfpga-fpga2sdram1-bridge"),
 	COMPAT(ALTERA_SOCFPGA_F2SDR2, "altr,socfpga-fpga2sdram2-bridge"),
+	COMPAT(ALTERA_SOCFPGA_FPGA0, "altr,socfpga-a10-fpga-mgr"),
+	COMPAT(ALTERA_SOCFPGA_NOC, "altr,socfpga-a10-noc"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
2.2.0
Applied
#20 lore raw

PATCH v2 7/19 fdt: Add compatible strings for Arria 10

Quoted 5 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add compatible strings for Intel Arria 10 SoCFPGA device.

Applied, thanks

Quoted 32 lines
---
 include/fdtdec.h | 2 ++
 lib/fdtdec.c     | 2 ++
 2 files changed, 4 insertions(+)
include/fdtdec.h +2 -0
index 4a0947c..095ff36 100644
@@ -157,6 +157,8 @@ enum fdt_compat_id {
 	COMPAT_ALTERA_SOCFPGA_F2SDR0,           /* SoCFPGA fpga2SDRAM0 bridge */
 	COMPAT_ALTERA_SOCFPGA_F2SDR1,           /* SoCFPGA fpga2SDRAM1 bridge */
 	COMPAT_ALTERA_SOCFPGA_F2SDR2,           /* SoCFPGA fpga2SDRAM2 bridge */
+	COMPAT_ALTERA_SOCFPGA_FPGA0,		/* SOCFPGA FPGA manager */
+	COMPAT_ALTERA_SOCFPGA_NOC,		/* SOCFPGA Arria 10 NOC */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +2 -0
index 107a892..03ff75e 100644
@@ -70,6 +70,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(ALTERA_SOCFPGA_F2SDR0, "altr,socfpga-fpga2sdram0-bridge"),
 	COMPAT(ALTERA_SOCFPGA_F2SDR1, "altr,socfpga-fpga2sdram1-bridge"),
 	COMPAT(ALTERA_SOCFPGA_F2SDR2, "altr,socfpga-fpga2sdram2-bridge"),
+	COMPAT(ALTERA_SOCFPGA_FPGA0, "altr,socfpga-a10-fpga-mgr"),
+	COMPAT(ALTERA_SOCFPGA_NOC, "altr,socfpga-a10-noc"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 2 lines
Best regards,
Marek Vasut
#21 lore raw

PATCH v2 7/19 fdt: Add compatible strings for Arria 10

Hi,

Quoted 14 lines · Marek Vasut
Quoted 5 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add compatible strings for Intel Arria 10 SoCFPGA device.

Applied, thanks

Quoted 5 lines
---
 include/fdtdec.h | 2 ++
 lib/fdtdec.c     | 2 ++
 2 files changed, 4 insertions(+)
Quoted 10 lines

include/fdtdec.h enum fdt_compat_id { · line 161

Quoted 10 lines
include/fdtdec.h +2 -0
index 4a0947c..095ff36 100644
@@ -157,6 +157,8 @@ enum fdt_compat_id {
      COMPAT_ALTERA_SOCFPGA_F2SDR0,           /* SoCFPGA fpga2SDRAM0 bridge */
      COMPAT_ALTERA_SOCFPGA_F2SDR1,           /* SoCFPGA fpga2SDRAM1 bridge */
      COMPAT_ALTERA_SOCFPGA_F2SDR2,           /* SoCFPGA fpga2SDRAM2 bridge */
+     COMPAT_ALTERA_SOCFPGA_FPGA0,            /* SOCFPGA FPGA manager */
+     COMPAT_ALTERA_SOCFPGA_NOC,              /* SOCFPGA Arria 10 NOC */

We should not be adding new things here. There is a clear message at the top:

* NOTE: This list is basically a TODO list for things that need to be
* converted to driver model. So don't add new things here unless there is a
* good reason why driver-model conversion is infeasible. Examples include
* things which are used before driver model is available.

Can this be converted to driver model please? I'll see if I can remove this array.

Quoted 15 lines
Quoted 15 lines
include/fdtdec.h +0 -0
      COMPAT_COUNT,
 };
lib/fdtdec.c +2 -0
index 107a892..03ff75e 100644
@@ -70,6 +70,8 @@ static const char * const compat_names[COMPAT_COUNT] = {
      COMPAT(ALTERA_SOCFPGA_F2SDR0, "altr,socfpga-fpga2sdram0-bridge"),
      COMPAT(ALTERA_SOCFPGA_F2SDR1, "altr,socfpga-fpga2sdram1-bridge"),
      COMPAT(ALTERA_SOCFPGA_F2SDR2, "altr,socfpga-fpga2sdram2-bridge"),
+     COMPAT(ALTERA_SOCFPGA_FPGA0, "altr,socfpga-a10-fpga-mgr"),
+     COMPAT(ALTERA_SOCFPGA_NOC, "altr,socfpga-a10-noc"),
 };
 
Quoted 7 lines

lib/fdtdec.c static const char * const compat_names[COMPAT_COUNT] = { · line 77

Quoted 2 lines
lib/fdtdec.c +0 -0
 const char *fdtdec_get_compatible(enum fdt_compat_id id)

--
Best regards,
Marek Vasut

Regards,
Simon

#22 lore raw

PATCH v2 8/19 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 9446cd9..5f4bd92 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
#23 lore raw

PATCH v2 8/19 fs: Enable generic filesystems interface support in SPL.

Quoted 6 lines · 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.

+CC Simon, I'd like a RB on this one.

Quoted 50 lines
---
 common/spl/Kconfig | 8 ++++++++
 doc/README.SPL     | 1 +
 fs/Makefile        | 1 +
 3 files changed, 10 insertions(+)
common/spl/Kconfig +8 -0
index 9446cd9..5f4bd92 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 · 2 lines
Best regards,
Marek Vasut
#24 lore raw

PATCH v2 8/19 fs: Enable generic filesystems interface support in SPL.

In reply to tien.fong.chee at intel.com
Quoted 11 lines · On 25 September 2017 at 02:40, <[email protected]> wrote:

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(+)
#25 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

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

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++
 drivers/fpga/socfpga_arria10.c                     | 391 ++++++++++++++++++++-
 include/altera.h                                   |   6 +
 include/configs/socfpga_common.h                   |   4 +
 4 files changed, 425 insertions(+), 3 deletions(-)
arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +27 -0
index 9cbf696..93a9122 100644
@@ -8,6 +8,8 @@
 #ifndef _FPGA_MANAGER_ARRIA10_H_
 #define _FPGA_MANAGER_ARRIA10_H_
 
+#include <asm/cache.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 +91,36 @@ 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 {
+	char *interface;
+	char *dev_part;
+	char *filename;
+	int fstype;
+	u32 remaining;
+	u32 flash_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);
+#endif
 
 #endif /* __ASSEMBLY__ */
 
drivers/fpga/socfpga_arria10.c +388 -3

422 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
include/configs/socfpga_common.h +4 -0
index 9897e11..eadce2d 100644
@@ -27,7 +27,11 @@
  */
 #define CONFIG_NR_DRAM_BANKS		1
 #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 * 1024)
+#endif
 #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
 #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
Signature · 1 line
2.2.0
#26 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Did you run checkpatch on this before submitting ? I presume no ...

Quoted 6 lines
---
 .../include/mach/fpga_manager_arria10.h            |  27 ++
 drivers/fpga/socfpga_arria10.c                     | 391 ++++++++++++++++++++-
 include/altera.h                                   |   6 +
 include/configs/socfpga_common.h                   |   4 +
 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +0 -2
@@ -112,13 +122,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

drivers/fpga/socfpga_arria10.c static int wait_for_nconfig_pin_and_nstatus_pin(void) · line 133

Quoted 10 lines
drivers/fpga/socfpga_arria10.c +4 -1
+	/*
+	 * 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);
 }

Seems more like a fix, split this out.

Quoted 45 lines
drivers/fpga/socfpga_arria10.c +33 -0
 static int wait_for_f2s_nstatus_pin(unsigned long value)
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 
 	/* Initialize the FPGA Manager */
 	status = fpgamgr_program_init((u32 *)rbf_data, rbf_size);
+
 	if (status)
 		return status;
 
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 
 	return fpgamgr_program_finish();
 }
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core)
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset, "bitstream_periph",
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 10 lines
drivers/fpga/socfpga_arria10.c +10 -0
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset, "bitstream_devpart", len);
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic firmware loader , which you could then use here.

[...]

include/configs/socfpga_common.h line 34

Quoted 13 lines
include/configs/socfpga_common.h +4 -0
index 9897e11..eadce2d 100644
@@ -27,7 +27,11 @@
  */
 #define CONFIG_NR_DRAM_BANKS		1
 #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 * 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Quoted 4 lines
include/configs/socfpga_common.h +0 -0
 #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
 #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
Signature · 2 lines
Best regards,
Marek Vasut
#27 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 10 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Did you run checkpatch on this before submitting ? I presume no ...

Yeah, i run checkpatch for all patches. What's the issue here?

Quoted 25 lines
Quoted 8 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++ drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 15 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_NSTATU S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms
Quoted 9 lines
Quoted 7 lines

   */
  return wait_for_bit(__func__, &fpga_manager_base->imgcfg_stat, mask,

drivers/fpga/socfpga_arria10.c +1 -1
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);

 }

Seems more like a fix, split this out.

Okay.

Quoted 67 lines
Quoted 54 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const void
 *rbf_data, size_t rbf_size)


  /* Initialize the FPGA Manager */
  status = fpgamgr_program_init((u32 *)rbf_data, rbf_size); +
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const
 void *rbf_data, size_t rbf_size)


  return fpgamgr_program_finish();
 }

drivers/fpga/socfpga_arria10.c +18 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core)
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset,

"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset, "bitstream_devpart",

len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

[...]

Quoted 1 line
Quoted 16 lines
Quoted 6 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644

include/configs/socfpga_common.h line 34

Quoted 8 lines
include/configs/socfpga_common.h +4 -0
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 * 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Okay, i will try out with smaller size.

Quoted 6 lines
Quoted 5 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
  #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
  #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
#28 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 5 lines · Tien Fong
Quoted 4 lines · Marek Vasut
Quoted 3 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Quoted 7 lines
Quoted 6 lines
Quoted 4 lines

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Did you run checkpatch on this before submitting ? I presume no ...

Yeah, i run checkpatch for all patches. What's the issue here?

It should definitely indicate problem with ie. yoda-notation +if (0 == flashinfo->remaining) {
and indent ...

Quoted 34 lines
Quoted 25 lines
Quoted 8 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++ drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 15 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_NSTATU S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms
Quoted 9 lines
Quoted 7 lines

   */
  return wait_for_bit(__func__, &fpga_manager_base->imgcfg_stat, mask,

drivers/fpga/socfpga_arria10.c +1 -1
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);

 }

Seems more like a fix, split this out.

Quoted 64 lines

Okay.

Quoted 63 lines
Quoted 54 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const void
 *rbf_data, size_t rbf_size)


  /* Initialize the FPGA Manager */
  status = fpgamgr_program_init((u32 *)rbf_data, rbf_size); +
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const
 void *rbf_data, size_t rbf_size)


  return fpgamgr_program_finish();
 }

drivers/fpga/socfpga_arria10.c +18 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core)
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset,

"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset, "bitstream_devpart",

len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

This is important here, I don't want yet another ad-hoc loader ...

Quoted 19 lines
Quoted 19 lines

[...]

Quoted 7 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644

include/configs/socfpga_common.h line 34

Quoted 8 lines
include/configs/socfpga_common.h +4 -0
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 * 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Quoted 1 line

Okay, i will try out with smaller size.

Why do you need such massive area ? It's not a matter of "try out", you should know why this change was needed for your use-case.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
  #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
  #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
Signature · 2 lines
Best regards,
Marek Vasut
#29 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 12 lines · Marek Vasut
Quoted 11 lines · Tien Fong
Quoted 9 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Did you run checkpatch on this before submitting ? I presume no
...

Yeah, i run checkpatch for all patches. What's the issue here?

It should definitely indicate problem with ie. yoda-notation +if (0 == flashinfo->remaining) {
and indent ...

No complaint from checkpath. I know someone saying bad for readbility, but yoda-notation at this simple implementation doesn't impact the readbility, and having benefit to leverage detection of compiler on missing "=". Overall, this can help to improve coding quality. I can remove it if this doesn't favored in U-boot.

Quoted 111 lines
Quoted 41 lines
Quoted 32 lines
Quoted 11 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++ drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 19 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_NS TATU
S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms
Quoted 9 lines
Quoted 7 lines

   */
  return wait_for_bit(__func__, &fpga_manager_base->imgcfg_stat, mask,

drivers/fpga/socfpga_arria10.c +1 -1
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);

 }

Seems more like a fix, split this out.

Quoted 70 lines

Okay.

Quoted 69 lines
Quoted 60 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const

void
*rbf_data, size_t rbf_size)

  /* Initialize the FPGA Manager */ status = fpgamgr_program_init((u32 *)rbf_data, rbf_size);
+
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const
 void *rbf_data, size_t rbf_size)


  return fpgamgr_program_finish();
 }

arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +3 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32

core)

drivers/fpga/socfpga_arria10.c +15 -0
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset,

"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

Quoted 2 lines

This is important here, I don't want yet another ad-hoc loader ...

Disucss in another email reply separately. I need time to think.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

[...]

Quoted 8 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644

include/configs/socfpga_common.h line 36

Quoted 10 lines
include/configs/socfpga_common.h +4 -0
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 *
 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 *
 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Quoted 5 lines
Quoted 1 line

Okay, i will try out with smaller size.

Why do you need such massive area ? It's not a matter of "try out", you
should know why this change was needed for your use-case.

I forgot what reason i put this value. I need to find out.

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1

 #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1_SIZ
E
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)

#30 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 22 lines · Tien Fong
Quoted 12 lines · Marek Vasut
Quoted 11 lines · Tien Fong
Quoted 9 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Quoted 9 lines
Quoted 5 lines
Quoted 4 lines
Quoted 1 line

Did you run checkpatch on this before submitting ? I presume no
...

Yeah, i run checkpatch for all patches. What's the issue here?

It should definitely indicate problem with ie. yoda-notation +if (0 == flashinfo->remaining) {
and indent ...

Quoted 5 lines

No complaint from checkpath. I know someone saying bad for readbility, but yoda-notation at this simple implementation doesn't impact the readbility, and having benefit to leverage detection of compiler on missing "=". Overall, this can help to improve coding quality. I can remove it if this doesn't favored in U-boot.

It is not welcome and modern gcc warns you about such things .

Quoted 138 lines
Quoted 111 lines
Quoted 41 lines
Quoted 32 lines
Quoted 11 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++ drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 19 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_NS TATU
S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms
Quoted 9 lines
Quoted 7 lines

   */
  return wait_for_bit(__func__, &fpga_manager_base->imgcfg_stat, mask,

drivers/fpga/socfpga_arria10.c +1 -1
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);

 }

Seems more like a fix, split this out.

Quoted 70 lines

Okay.

Quoted 69 lines
Quoted 60 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const

void
*rbf_data, size_t rbf_size)

  /* Initialize the FPGA Manager */ status = fpgamgr_program_init((u32 *)rbf_data, rbf_size);
+
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const
 void *rbf_data, size_t rbf_size)


  return fpgamgr_program_finish();
 }

arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +3 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32

core)

drivers/fpga/socfpga_arria10.c +15 -0
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset,

"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

Quoted 2 lines

This is important here, I don't want yet another ad-hoc loader ...

Disucss in another email reply separately. I need time to think.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

[...]

Quoted 8 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644

include/configs/socfpga_common.h line 36

Quoted 10 lines
include/configs/socfpga_common.h +4 -0
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 *
 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 *
 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Okay, i will try out with smaller size.

Why do you need such massive area ? It's not a matter of "try out", you
should know why this change was needed for your use-case.

I forgot what reason i put this value. I need to find out.

If this was properly documented in the commit message, you would not have to ...

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1

 #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1_SIZ
E
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)

Signature · 2 lines
Best regards,
Marek Vasut
#31 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 30 lines · Marek Vasut
Quoted 29 lines · Tien Fong
Quoted 27 lines · Marek Vasut
Quoted 15 lines · Tien Fong
Quoted 12 lines · Marek Vasut
Quoted 9 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading
RBF to memory and then to program FPGA.

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Did you run checkpatch on this before submitting ? I presume no
...

Yeah, i run checkpatch for all patches. What's the issue here?

It should definitely indicate problem with ie. yoda-notation +if (0 == flashinfo->remaining) {
and indent ...

Quoted 9 lines
Quoted 7 lines

No complaint from checkpath. I know someone saying bad for readbility,
but yoda-notation at this simple implementation doesn't impact the readbility, and having benefit to leverage detection of compiler on missing "=". Overall, this can help to improve coding quality. I can
remove it if this doesn't favored in U-boot.

It is not welcome and modern gcc warns you about such things .

Okay.

Quoted 162 lines
Quoted 162 lines
Quoted 129 lines
Quoted 52 lines
Quoted 43 lines
Quoted 17 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++
 drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 24 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_F2 S_NS
TATU
S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin;

loop
until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms

   */
  return wait_for_bit(__func__,
      &fpga_manager_base-

Quoted 9 lines
Quoted 7 lines
Quoted 1 line

imgcfg_stat,

      mask,

(quoted diff) +0 -1
-			    false, FPGA_TIMEOUT_MSEC,

false);

(quoted diff) +1 -0
+			    true, FPGA_TIMEOUT_MSEC,

false);
 }

Seems more like a fix, split this out.

Quoted 77 lines

Okay.

Quoted 76 lines
Quoted 66 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc,

const
void
*rbf_data, size_t rbf_size)

  /* Initialize the FPGA Manager */ status = fpgamgr_program_init((u32 *)rbf_data, rbf_size);
+
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc,

const
void *rbf_data, size_t rbf_size)

  return fpgamgr_program_finish();
 }

arch/arm/mach-socfpga/include/mach/fpga_manager_arria10.h +3 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len,

u32
core)

drivers/fpga/socfpga_arria10.c +15 -0
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt,

nodeoffset,
"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into
generic
firmware loader , which you could then use here.

Quoted 3 lines

This is important here, I don't want yet another ad-hoc loader
...

Disucss in another email reply separately. I need time to think.

Quoted 29 lines
Quoted 29 lines
Quoted 19 lines

[...]

Quoted 12 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
Quoted 9 lines

include/configs/socfpga_common.h line 36

Quoted 7 lines
include/configs/socfpga_common.h +4 -0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 *
 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 *
 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Okay, i will try out with smaller size.

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

Why do you need such massive area ? It's not a matter of "try out",
you
should know why this change was needed for your use-case.

I forgot what reason i put this value. I need to find out.

If this was properly documented in the commit message, you would not have to ...

Okay.

Quoted 16 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1

 #define CONFIG_SYS_MEMTEST_END PHYS_SDRAM_1
_SIZ
E
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)

#32 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

In reply to Marek Vasut
Quoted 99 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Did you run checkpatch on this before submitting ? I presume no ...

Quoted 8 lines

---
 .../include/mach/fpga_manager_arria10.h            |  27 ++ drivers/fpga/socfpga_arria10.c                     | 391
++++++++++++++++++++-
 include/altera.h                                   |   6 + include/configs/socfpga_common.h                   |   4 +

 4 files changed, 425 insertions(+), 3 deletions(-)

[...]

Quoted 21 lines
(quoted diff) +0 -0
@@ -112,13 +122,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_NSTATU S_PIN_SET_MSK;

(quoted diff) +0 -1
-	/* Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until de-asserted,

drivers/fpga/socfpga_arria10.c +2 -1
-	 * timeout at 1000ms
+	/*
+	 * Poll until f2s_nconfig_pin and f2s_nstatus_pin; loop

until

drivers/fpga/socfpga_arria10.c +1 -0
+	 * de-asserted, timeout at 1000ms

   */
  return wait_for_bit(__func__, &fpga_manager_base->imgcfg_stat, mask,

drivers/fpga/socfpga_arria10.c +1 -1
-			    false, FPGA_TIMEOUT_MSEC, false);
+			    true, FPGA_TIMEOUT_MSEC, false);
Quoted 1 line

 }

Seems more like a fix, split this out.

Quoted 55 lines

 static int wait_for_f2s_nstatus_pin(unsigned long value)

(quoted diff) +0 -0
@@ -469,6 +480,7 @@ int socfpga_load(Altera_desc *desc, const void
 *rbf_data, size_t rbf_size)


  /* Initialize the FPGA Manager */
  status = fpgamgr_program_init((u32 *)rbf_data, rbf_size); +
  if (status)
  return status;

(quoted diff) +0 -0
@@ -477,3 +489,376 @@ int socfpga_load(Altera_desc *desc, const
 void *rbf_data, size_t rbf_size)


  return fpgamgr_program_finish();
 }

drivers/fpga/socfpga_arria10.c +18 -0
+
+#if defined(CONFIG_CMD_FPGA_LOADFS)
+const char *get_cff_filename(const void *fdt, int *len, u32 core)
+{
+	const char *cff_filename = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	if (nodeoffset >= 0) {
+		if (core)
+			cell = fdt_getprop(fdt,
+					nodeoffset,
+					"bitstream_core",
+					len);
+		else
+			cell = fdt_getprop(fdt, nodeoffset,

"bitstream_periph",

drivers/fpga/socfpga_arria10.c +18 -0
+					 len);
+
+		if (cell)
+			cff_filename = cell;
+	}
+
+	return cff_filename;
+}
+
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset, "bitstream_devpart",

len);
+

Quoted 9 lines

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 5 lines
drivers/fpga/socfpga_arria10.c +5 -0
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

the devpart is hard coded in splash*.c. The function here is getting devpart info from DTS. So, is there any similar function in splash*.c? May be you can share more about your idea.

Quoted 25 lines

[...]

Quoted 7 lines
include/configs/socfpga_common.h +0 -0
index 9897e11..eadce2d 100644

include/configs/socfpga_common.h line 34

Quoted 8 lines
include/configs/socfpga_common.h +4 -0
@@ -27,7 +27,11 @@
   */
  #define CONFIG_NR_DRAM_BANKS		1
  #define PHYS_SDRAM_1			0x0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
  #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_MALLOC_LEN		(128 * 1024 * 1024)
+#endif

You definitely don't need 128 MiB of malloc area.

Quoted 5 lines
include/configs/socfpga_common.h +0 -0
  #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
  #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
  #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
#33 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 9 lines · Tien Fong
Quoted 8 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

[...]

Quoted 20 lines
Quoted 11 lines
Quoted 11 lines
drivers/fpga/socfpga_arria10.c +9 -0
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset, "bitstream_devpart",

len);
+

Quoted 9 lines

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 5 lines
drivers/fpga/socfpga_arria10.c +5 -0
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

Quoted 3 lines

the devpart is hard coded in splash*.c. The function here is getting devpart info from DTS. So, is there any similar function in splash*.c? May be you can share more about your idea.

The generic loader could use some work of course ...

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#34 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 39 lines · Marek Vasut
Quoted 12 lines · Tien Fong
Quoted 10 lines · Marek Vasut
Quoted 8 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

[...]

Quoted 24 lines
Quoted 24 lines
Quoted 14 lines
drivers/fpga/socfpga_arria10.c +9 -0
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 6 lines
drivers/fpga/socfpga_arria10.c +6 -0
+
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

Quoted 7 lines
Quoted 5 lines

the devpart is hard coded in splash*.c. The function here is getting
devpart info from DTS. So, is there any similar function in splash*.c?
May be you can share more about your idea.

The generic loader could use some work of course ...

Sorry, i am still confusing. Allow me to ask you more:
1. Is the generic firmware loader already exists in splash*.c?
2. Are you talking about get_cff_devpart or whole fpga laodfs?
3. You want me integrate get_cff_devpart function into splash*.c?
4. Are you means to hard code the devpart instead providing dynamic devpart described in DTS?

Current implementation are located in spl_board_init func (arcg/arm/mach-socfpga/spl.c). Based on boot device such as mmc, nand and QSPI, then reading some info from DTS, setting dev and partition with generic fs functions, and reading with generic fs function before programming RBF into FPGA. All these are in patch 19.

Thanks.

Quoted 2 lines

[...]

#35 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 45 lines · Tien Fong
Quoted 44 lines · Marek Vasut
Quoted 12 lines · Tien Fong
Quoted 10 lines · Marek Vasut
Quoted 8 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

[...]

Quoted 29 lines
Quoted 15 lines
Quoted 15 lines
drivers/fpga/socfpga_arria10.c +9 -0
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);
+

Quoted 9 lines

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 5 lines
drivers/fpga/socfpga_arria10.c +5 -0
+	if (cell)
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into generic
firmware loader , which you could then use here.

the devpart is hard coded in splash*.c. The function here is getting
devpart info from DTS. So, is there any similar function in splash*.c?
May be you can share more about your idea.

Quoted 4 lines
Quoted 2 lines

The generic loader could use some work of course ...

Sorry, i am still confusing. Allow me to ask you more:
1. Is the generic firmware loader already exists in splash*.c?

No

Quoted 4 lines

2. Are you talking about get_cff_devpart or whole fpga laodfs?
3. You want me integrate get_cff_devpart function into splash*.c?
4. Are you means to hard code the devpart instead providing dynamic devpart described in DTS?

I am talking about factoring out generic firmware loader from splash*c , since it already contains most of the parts for such a thing.

Quoted 5 lines

Current implementation are located in spl_board_init func (arcg/arm/mach-socfpga/spl.c). Based on boot device such as mmc, nand and QSPI, then reading some info from DTS, setting dev and partition with generic fs functions, and reading with generic fs function before programming RBF into FPGA. All these are in patch 19.

That's what splash*c also does, so adding separate parallel implementation of the same functionality is a no-no.

Quoted 2 lines

Thanks.

Quoted 1 line

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#36 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 80 lines · Marek Vasut
Quoted 55 lines · Tien Fong
Quoted 53 lines · Marek Vasut
Quoted 16 lines · Tien Fong
Quoted 13 lines · Marek Vasut
Quoted 10 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading
RBF to memory and then to program FPGA.

[...]

Quoted 33 lines
Quoted 19 lines
Quoted 19 lines
drivers/fpga/socfpga_arria10.c +9 -0
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

(quoted diff) +2 -0
+
+	if (cell)
Quoted 9 lines

drivers/fpga/socfpga_arria10.c int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size) · line 533

Quoted 4 lines
drivers/fpga/socfpga_arria10.c +4 -0
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into
generic
firmware loader , which you could then use here.

the devpart is hard coded in splash*.c. The function here is getting
devpart info from DTS. So, is there any similar function in splash*.c?
May be you can share more about your idea.

Quoted 4 lines
Quoted 2 lines

The generic loader could use some work of course ...

Sorry, i am still confusing. Allow me to ask you more:
1. Is the generic firmware loader already exists in splash*.c?

No

Quoted 5 lines

2. Are you talking about get_cff_devpart or whole fpga laodfs?
3. You want me integrate get_cff_devpart function into splash*.c?
4. Are you means to hard code the devpart instead providing dynamic devpart described in DTS?

I am talking about factoring out generic firmware loader from splash*c ,
since it already contains most of the parts for such a thing.

Quoted 9 lines

Current implementation are located in spl_board_init func (arcg/arm/mach-socfpga/spl.c). Based on boot device such as mmc, nand
and QSPI, then reading some info from DTS, setting dev and partition
with generic fs functions, and reading with generic fs function before
programming RBF into FPGA. All these are in patch 19.

Quoted 3 lines

That's what splash*c also does, so adding separate parallel implementation of the same functionality is a no-no.

After reading through splash*c, i found there are two functions bear a close similarity to.
1st function -->
In /common/splash.c :

static struct splash_location default_splash_locations[] = {
	{
		.name = "sf",
		.storage = SPLASH_STORAGE_SF,
		.flags = SPLASH_STORAGE_RAW,
		.offset = 0x0,
	},
	{
		.name = "mmc_fs",
		.storage = SPLASH_STORAGE_MMC,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
	{
		.name = "usb_fs",
		.storage = SPLASH_STORAGE_USB,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
	{
		.name = "sata_fs",
		.storage = SPLASH_STORAGE_SATA,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
};

In my /arch/arm/mach-socfpga/spl.c (spl_board_init(void)) bootdev.boot_device = spl_boot_device();

	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
		struct mmc *mmc = NULL;
		int err = 0;

		spl_mmc_find_device(&mmc, bootdev.boot_device);

		err = mmc_init(mmc);

		if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
			printf("spl: mmc init failed with error: %d\n",
err);
#endif
		}

		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd-
Quoted 1 line

fdt_blob,

								 &len);

		fpga_fsinfo.filename = (char *)get_cff_filename(gd-
Quoted 1 line

fdt_blob,

								 &len,
								PERIPH_

RBF);

		fpga_fsinfo.interface = "mmc";

		fpga_fsinfo.fstype = FS_TYPE_FAT;
	} else {
		printf("Invalid boot device!\n");
		return;
	}

	/* Program peripheral RBF */
	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len > 0))
		rval = fpga_fsload(0, buffer, BSIZE, &fpga_fsinfo);

In /common/splash.c, dev_Part and flash type everything are hard coded in struct splash_location. In my spl.c, flash type are determined on run time and dev_part are retrived from DTS, and then assigned to struct fpga_fsinfo. Please note that this is in SPL, mmc need to be initialized 1st before loading raw file into memory. In SPL, raw file are coppied to OCRAM chunk by chunk, but In u-boot it would normally done in one big chunk to DRAM. This would be handled by fpga loadfs.

So, you want me hard code everthing like in splash.c?

2nd function -->
In /common/splash_source.c
static int splash_select_fs_dev(struct splash_location *location)

{
	int res;

	switch (location->storage) {
	case SPLASH_STORAGE_MMC:
		res = fs_set_blk_dev("mmc", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_USB:
		res = fs_set_blk_dev("usb", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_SATA:
		res = fs_set_blk_dev("sata", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_NAND:
		if (location->ubivol != NULL)
			res = fs_set_blk_dev("ubi", NULL,
FS_TYPE_UBIFS);
		else
			res = -ENODEV;
		break;
	default:
		printf("Error: unsupported location storage.\n");
		return -ENODEV;
	}

	if (res)
		printf("Error: could not access storage.\n");

	return res;
}

In my /drivers/fpga/socfpga_arria10.c static int flash_read(struct flash_info *flashinfo,

	u32 size_read,
	u32 *buffer_ptr)
{
	size_t ret = EEXIST;
	loff_t actread = 0;

	if (fs_set_blk_dev(flashinfo->interface, flashinfo->dev_part,
				flashinfo->fstype))
		return FPGA_FAIL;

	ret = fs_read(flashinfo->filename,
			(u32) buffer_ptr, flashinfo->flash_offset,
			size_read, &actread);

	if (ret || actread != size_read) {
		printf("Failed to read %s from flash %d ",
			flashinfo->filename,
			 ret);
		printf("!= %d.\n", size_read);
		return -EPERM;
		} else
			ret = actread;

	return ret;
}

Some attributes like flash type is determined on run time and and dev_part is retrieved from DTS, so every infos driver need to know are assinged into struct flashinfo and passed to fs_set_blk_dev as arguments. I found that function in splash_source.c some like flash type are getting from env variable, but we are still in SPL phase, those env variable is not set up yet. So, i think that is very ineffcient to factor out them as common.

If you want me create a generic firmware loader which is generic enough loading content for all components like flashes, FPGA, splash ....etc, i don't think that is effient enough, as fpga loadfs has different handling in both SPL and U-boot like copying raw into memory.

It would be good you can direct point me out which functions have similirity and how to factor them out as common.

Thanks a lot.

Quoted 5 lines
Quoted 4 lines

Thanks.

Quoted 2 lines

[...]

#37 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

Quoted 163 lines · Tien Fong
Quoted 80 lines · Marek Vasut
Quoted 55 lines · Tien Fong
Quoted 53 lines · Marek Vasut
Quoted 16 lines · Tien Fong
Quoted 13 lines · Marek Vasut
Quoted 10 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading
RBF to memory and then to program FPGA.

[...]

Quoted 33 lines
Quoted 19 lines
Quoted 19 lines
(quoted diff) +9 -0
+const char *get_cff_devpart(const void *fdt, int *len)
+{
+	const char *cff_devpart = NULL;
+	const char *cell;
+	int nodeoffset;
+	nodeoffset = fdtdec_next_compatible(fdt, 0,
+			 COMPAT_ALTERA_SOCFPGA_FPGA0);
+
+	cell = fdt_getprop(fdt, nodeoffset,

"bitstream_devpart",
len);

(quoted diff) +2 -0
+
+	if (cell)
Quoted 9 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+		cff_devpart = cell;
+
+	return cff_devpart;
+}

Take a look at splash*.c , I believe that can be reworked into
generic
firmware loader , which you could then use here.

the devpart is hard coded in splash*.c. The function here is getting
devpart info from DTS. So, is there any similar function in splash*.c?
May be you can share more about your idea.

Quoted 4 lines
Quoted 2 lines

The generic loader could use some work of course ...

Sorry, i am still confusing. Allow me to ask you more:
1. Is the generic firmware loader already exists in splash*.c?

No

Quoted 5 lines

2. Are you talking about get_cff_devpart or whole fpga laodfs?
3. You want me integrate get_cff_devpart function into splash*.c?
4. Are you means to hard code the devpart instead providing dynamic devpart described in DTS?

I am talking about factoring out generic firmware loader from splash*c ,
since it already contains most of the parts for such a thing.

Quoted 9 lines

Current implementation are located in spl_board_init func (arcg/arm/mach-socfpga/spl.c). Based on boot device such as mmc, nand
and QSPI, then reading some info from DTS, setting dev and partition
with generic fs functions, and reading with generic fs function before
programming RBF into FPGA. All these are in patch 19.

Quoted 3 lines

That's what splash*c also does, so adding separate parallel implementation of the same functionality is a no-no.

After reading through splash*c, i found there are two functions bear a close similarity to.
1st function -->
In /common/splash.c :

static struct splash_location default_splash_locations[] = {
	{
		.name = "sf",
		.storage = SPLASH_STORAGE_SF,
		.flags = SPLASH_STORAGE_RAW,
		.offset = 0x0,
	},
	{
		.name = "mmc_fs",
		.storage = SPLASH_STORAGE_MMC,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
	{
		.name = "usb_fs",
		.storage = SPLASH_STORAGE_USB,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
	{
		.name = "sata_fs",
		.storage = SPLASH_STORAGE_SATA,
		.flags = SPLASH_STORAGE_FS,
		.devpart = "0:1",
	},
};

In my /arch/arm/mach-socfpga/spl.c (spl_board_init(void)) bootdev.boot_device = spl_boot_device();

	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
		struct mmc *mmc = NULL;
		int err = 0;

		spl_mmc_find_device(&mmc, bootdev.boot_device);

		err = mmc_init(mmc);

		if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
			printf("spl: mmc init failed with error: %d\n",
err);
#endif
		}

		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd-
Quoted 1 line

fdt_blob,

								 &len);

		fpga_fsinfo.filename = (char *)get_cff_filename(gd-
Quoted 1 line

fdt_blob,

								 &len,
								PERIPH_

RBF);

		fpga_fsinfo.interface = "mmc";

		fpga_fsinfo.fstype = FS_TYPE_FAT;
	} else {
		printf("Invalid boot device!\n");
		return;
	}

	/* Program peripheral RBF */
	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len > 0))
		rval = fpga_fsload(0, buffer, BSIZE, &fpga_fsinfo);

In /common/splash.c, dev_Part and flash type everything are hard coded in struct splash_location. In my spl.c, flash type are determined on run time and dev_part are retrived from DTS, and then assigned to struct fpga_fsinfo. Please note that this is in SPL, mmc need to be initialized 1st before loading raw file into memory. In SPL, raw file are coppied to OCRAM chunk by chunk, but In u-boot it would normally done in one big chunk to DRAM. This would be handled by fpga loadfs.

Quoted 1 line

So, you want me hard code everthing like in splash.c?

No, I need you to play around with this and come up with generic firmware loader that's flexible enough.

Quoted 73 lines

2nd function -->
In /common/splash_source.c
static int splash_select_fs_dev(struct splash_location *location)

{
	int res;

	switch (location->storage) {
	case SPLASH_STORAGE_MMC:
		res = fs_set_blk_dev("mmc", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_USB:
		res = fs_set_blk_dev("usb", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_SATA:
		res = fs_set_blk_dev("sata", location->devpart,
FS_TYPE_ANY);
		break;
	case SPLASH_STORAGE_NAND:
		if (location->ubivol != NULL)
			res = fs_set_blk_dev("ubi", NULL,
FS_TYPE_UBIFS);
		else
			res = -ENODEV;
		break;
	default:
		printf("Error: unsupported location storage.\n");
		return -ENODEV;
	}

	if (res)
		printf("Error: could not access storage.\n");

	return res;
}

In my /drivers/fpga/socfpga_arria10.c static int flash_read(struct flash_info *flashinfo,

	u32 size_read,
	u32 *buffer_ptr)
{
	size_t ret = EEXIST;
	loff_t actread = 0;

	if (fs_set_blk_dev(flashinfo->interface, flashinfo->dev_part,
				flashinfo->fstype))
		return FPGA_FAIL;

	ret = fs_read(flashinfo->filename,
			(u32) buffer_ptr, flashinfo->flash_offset,
			size_read, &actread);

	if (ret || actread != size_read) {
		printf("Failed to read %s from flash %d ",
			flashinfo->filename,
			 ret);
		printf("!= %d.\n", size_read);
		return -EPERM;
		} else
			ret = actread;

	return ret;
}

Some attributes like flash type is determined on run time and and dev_part is retrieved from DTS, so every infos driver need to know are assinged into struct flashinfo and passed to fs_set_blk_dev as arguments. I found that function in splash_source.c some like flash type are getting from env variable, but we are still in SPL phase, those env variable is not set up yet. So, i think that is very ineffcient to factor out them as common.

Quoted 4 lines

If you want me create a generic firmware loader which is generic enough loading content for all components like flashes, FPGA, splash ....etc, i don't think that is effient enough, as fpga loadfs has different handling in both SPL and U-boot like copying raw into memory.

Duplicating code is nonsense and I believe generic firmware loader would be the way to go here.

Quoted 8 lines

It would be good you can direct point me out which functions have similirity and how to factor them out as common.

Thanks a lot.

Quoted 4 lines
Quoted 4 lines

Thanks.

Quoted 2 lines

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#38 lore raw

PATCH v2 9/19 arm: socfpga: Add drivers for programing FPGA from flash

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

Hi,

Quoted 5 lines · On 25 September 2017 at 02:40, <[email protected]> wrote:

From: Tien Fong Chee <[email protected]>

These drivers handle FPGA program operation from flash loading RBF to memory and then to program FPGA.

Quoted 7 lines
---
 .../include/mach/fpga_manager_arria10.h            |  27 ++
 drivers/fpga/socfpga_arria10.c                     | 391 ++++++++++++++++++++-
 include/altera.h                                   |   6 +
 include/configs/socfpga_common.h                   |   4 +
 4 files changed, 425 insertions(+), 3 deletions(-)

Agreed on the generic loader, but also, can you please use driver model? Am I missing something?

Regards,
Simon

#39 lore raw

PATCH v2 10/19 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         | 434 +--------------------
 .../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, 8 insertions(+), 434 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 +4 -430
index b11228f..4a9754e 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright Altera Corporation (C) 2014-2015
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -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
#40 lore raw

PATCH v2 10/19 arm: socfpga: Rename the gen5 sdram driver to more specific name

Quoted 21 lines · 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         | 434 +--------------------
 .../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, 8 insertions(+), 434 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 +0 -0
index b11228f..4a9754e 100644

arch/arm/mach-socfpga/include/mach/sdram.h line 2

Quoted 3 lines
arch/arm/mach-socfpga/include/mach/sdram.h +1 -1
@@ -1,5 +1,5 @@
 /*
- * Copyright Altera Corporation (C) 2014-2015
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>

Retain the old copyright ?

arch/arm/mach-socfpga/include/mach/sdram.h line 9

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -8,435 +8,9 @@
 
 #ifndef __ASSEMBLY__

What's with this massive deletion here ?

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -9
-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);

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#41 lore raw

PATCH v2 10/19 arm: socfpga: Rename the gen5 sdram driver to more specific name

Quoted 22 lines · Marek Vasut
Quoted 21 lines · 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         | 434 +------
--------------
 .../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, 8 insertions(+), 434 deletions(-)

 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h} (99%)
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)

Quoted 11 lines

arch/arm/mach-socfpga/include/mach/sdram.h line 2

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram.h +1 -1
index b11228f..4a9754e 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright Altera Corporation (C) 2014-2015
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>

Retain the old copyright ?

Okay.

Quoted 9 lines
Quoted 7 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
   *
   * SPDX-License-Identifier:	GPL-2.0+
   */
@@ -8,435 +8,9 @@


 #ifndef __ASSEMBLY__

What's with this massive deletion here ?

Move to sdram_gen5.h . This header should contain common stuff.

Quoted 15 lines
Quoted 13 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -7
-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);

[...]

#42 lore raw

PATCH v2 10/19 arm: socfpga: Rename the gen5 sdram driver to more specific name

Quoted 44 lines · Tien Fong
Quoted 22 lines · Marek Vasut
Quoted 21 lines · 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         | 434 +------
--------------
 .../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, 8 insertions(+), 434 deletions(-)

 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h} (99%)
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)

Quoted 11 lines

arch/arm/mach-socfpga/include/mach/sdram.h line 2

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram.h +1 -1
index b11228f..4a9754e 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright Altera Corporation (C) 2014-2015
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>

Retain the old copyright ?

Okay.

Quoted 9 lines
Quoted 7 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
   *
   * SPDX-License-Identifier:	GPL-2.0+
   */
@@ -8,435 +8,9 @@


 #ifndef __ASSEMBLY__

What's with this massive deletion here ?

Quoted 1 line

Move to sdram_gen5.h . This header should contain common stuff.

Then where did the + part go ?

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -7
-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);

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#43 lore raw

PATCH v2 10/19 arm: socfpga: Rename the gen5 sdram driver to more specific name

Quoted 54 lines · Marek Vasut
Quoted 53 lines · Tien Fong
Quoted 28 lines · Marek Vasut
Quoted 26 lines · 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         | 434 +--
----
--------------
 .../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, 8 insertions(+), 434 deletions(-)

 copy arch/arm/mach-socfpga/include/mach/{sdram.h => sdram_gen5.h}
(99%)
 rename drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)

Quoted 11 lines

arch/arm/mach-socfpga/include/mach/sdram.h line 2

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram.h +1 -1
index b11228f..4a9754e 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright Altera Corporation (C) 2014-2015
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>

Retain the old copyright ?

Okay.

Quoted 11 lines
Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
   *
   * SPDX-License-Identifier:	GPL-2.0+
   */
@@ -8,435 +8,9 @@


 #ifndef __ASSEMBLY__

What's with this massive deletion here ?

Quoted 3 lines
Quoted 1 line

Move to sdram_gen5.h . This header should contain common stuff.

Then where did the + part go ?

I'm not sure why the patch didn't showing "+" portion, i suspect the patch use below instead of "+".
 copy arch/arm/mach-socfpga/include/mach/{sdram.h =>

Quoted 1 line

 > > > sdram_gen5.h}> > > > (99%)> > > >  rename

drivers/ddr/altera/{sdram.c => sdram_gen5.c} (100%)

Quoted 19 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
arch/arm/mach-socfpga/include/mach/sdram.h +0 -5
-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);

arch/arm/mach-socfpga/include/mach/sdram.h +0 -2
-
-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);

[...]

#44 lore raw

PATCH v2 11/19 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 eadce2d..7549ee8 100644
@@ -47,6 +47,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
#45 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 7 lines · 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.

I'd like TB on Gen5.

Quoted 36 lines
---
 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 eadce2d..7549ee8 100644
@@ -47,6 +47,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 · 2 lines
Best regards,
Marek Vasut
#46 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 4 lines · Marek Vasut
Quoted 3 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Quoted 8 lines
Quoted 6 lines

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

I'd like TB on Gen5.

What is TB?

Quoted 40 lines
Quoted 39 lines

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +

 2 files changed, 8 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index a41d089..965f9dc 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -29,6 +29,13 @@ int board_init(void)
  	return 0;
  }

arch/arm/mach-socfpga/board.c +7 -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 +0 -0
index eadce2d..7549ee8 100644
@@ -47,6 +47,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

#47 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 10 lines · Tien Fong
Quoted 9 lines · Marek Vasut
Quoted 8 lines · 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.

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

I'd like TB on Gen5.

What is TB?

Tested-by

Quoted 39 lines
Quoted 39 lines
Quoted 39 lines

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +

 2 files changed, 8 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index a41d089..965f9dc 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -29,6 +29,13 @@ int board_init(void)
  	return 0;
  }

arch/arm/mach-socfpga/board.c +7 -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 +0 -0
index eadce2d..7549ee8 100644
@@ -47,6 +47,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 · 2 lines
Best regards,
Marek Vasut
#48 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 16 lines · Marek Vasut
Quoted 15 lines · Tien Fong
Quoted 13 lines · Marek Vasut
Quoted 11 lines · 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.

Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

I'd like TB on Gen5.

What is TB?

Tested-by

You want me resend the patch with Tested-by?

Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +

 2 files changed, 8 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index a41d089..965f9dc 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -29,6 +29,13 @@ int board_init(void)
  	return 0;
  }

arch/arm/mach-socfpga/board.c +7 -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 +0 -0
index eadce2d..7549ee8 100644
@@ -47,6 +47,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

#49 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 17 lines · Tien Fong
Quoted 16 lines · Marek Vasut
Quoted 15 lines · Tien Fong
Quoted 13 lines · Marek Vasut
Quoted 11 lines · 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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

I'd like TB on Gen5.

What is TB?

Tested-by

You want me resend the patch with Tested-by?

Uh no, that's not how TB works. You should get TB on your patches from someone else , not yourself .

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +

 2 files changed, 8 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index a41d089..965f9dc 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -29,6 +29,13 @@ int board_init(void)
  	return 0;
  }

arch/arm/mach-socfpga/board.c +7 -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 +0 -0
index eadce2d..7549ee8 100644
@@ -47,6 +47,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 · 2 lines
Best regards,
Marek Vasut
#50 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 27 lines · Marek Vasut
Quoted 26 lines · Tien Fong
Quoted 24 lines · Marek Vasut
Quoted 22 lines · Tien Fong
Quoted 19 lines · Marek Vasut
Quoted 13 lines · 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.

Quoted 1 line

I'd like TB on Gen5.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

What is TB?

Tested-by

You want me resend the patch with Tested-by?

Uh no, that's not how TB works. You should get TB on your patches from
someone else , not yourself .

oo...okay, i will ask ley foon help to verify.

Quoted 50 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines
Quoted 49 lines

---
 arch/arm/mach-socfpga/board.c    | 7 +++++++
 include/configs/socfpga_common.h | 1 +

 2 files changed, 8 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index a41d089..965f9dc 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -29,6 +29,13 @@ int board_init(void)
  	return 0;
  }

arch/arm/mach-socfpga/board.c +7 -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 +0 -0
index eadce2d..7549ee8 100644
@@ -47,6 +47,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

#51 lore raw

PATCH v2 11/19 arm: socfpga: Add DRAM bank size initialization function

Quoted 29 lines · Tien Fong
Quoted 28 lines · Marek Vasut
Quoted 27 lines · Tien Fong
Quoted 25 lines · Marek Vasut
Quoted 23 lines · Tien Fong
Quoted 16 lines · Marek Vasut
Quoted 13 lines · 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.

Quoted 3 lines
Quoted 1 line

I'd like TB on Gen5.

What is TB?

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

Tested-by

You want me resend the patch with Tested-by?

Uh no, that's not how TB works. You should get TB on your patches from
someone else , not yourself .

oo...okay, i will ask ley foon help to verify.

Quoted 1 line
Quoted 1 line
#52 lore raw

PATCH v2 12/19 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 suppport for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 +
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++-
 drivers/ddr/altera/sdram_arria10.c                 | 735 +++++++++++++++++++++
 3 files changed, 839 insertions(+), 1 deletion(-)
 create mode 100644 drivers/ddr/altera/sdram_arria10.c
arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
index 4a9754e..b833fc2 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 +102 -1

119 lines not on this page · raw message

drivers/ddr/altera/sdram_arria10.c new file +735 -0

735 lines not on this page · raw message

Signature · 1 line
2.2.0
#53 lore raw

PATCH v2 12/19 arm: socfpga: Add DDR driver for Arria 10

Quoted 48 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add DDR driver suppport for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 +
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++-
 drivers/ddr/altera/sdram_arria10.c                 | 735 +++++++++++++++++++++
 3 files changed, 839 insertions(+), 1 deletion(-)
 create mode 100644 drivers/ddr/altera/sdram_arria10.c
arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
index 4a9754e..b833fc2 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 -1
index 1d7b7c1..7af9431 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
  *
  * SPDX-License-Identifier:	GPL-2.0
  */
@@ -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,106 @@ struct socfpga_io48_mmr {
 	u32 niosreserve1;
 	u32 niosreserve2;
 };

arch/arm/mach-socfpga/include/mach/sdram_arria10.h struct socfpga_io48_mmr { · line 217

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +10 -0
+
+union dramaddrw_reg {
+	struct {
+		u32 cfg_col_addr_width:5;
+		u32 cfg_row_addr_width:5;
+		u32 cfg_bank_addr_width:4;
+		u32 cfg_bank_group_addr_width:2;
+		u32 cfg_cs_addr_width:3;
+		u32 reserved:13;
+	};

Use regular macros for bitfields, not this crap.

Quoted 13 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +13 -0
+	u32 word;
+};
+
+union ctrlcfg0_reg {
+	struct {
+		u32 cfg_mem_type:4;
+		u32 cfg_dimm_type:3;
+		u32 cfg_ac_pos:2;
+		u32 cfg_ctrl_burst_len:5;
+		u32 reserved:18;  /* Other fields unused */
+	};
+	u32 word;
+};

[...]

Quoted 9 lines
drivers/ddr/altera/sdram_arria10.c new file +3 -0
new file mode 100644
index 0000000..f22a726
@@ -0,0 +1,735 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *

drivers/ddr/altera/sdram_arria10.c line 13

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <malloc.h>
+#include <mmc.h>
+#include <nand.h>
+#include <watchdog.h>
+#include <ns16550.h>

Why does an SDRAM init driver need access to ns16550 UART , MMC and NAND ?

Quoted 5 lines
drivers/ddr/altera/sdram_arria10.c new file +5 -0
+#include <asm/io.h>
+#include <asm/arch/fpga_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/sdram.h>

drivers/ddr/altera/sdram_arria10.c line 28

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void sdram_mmr_init(void);
+static unsigned long long sdram_size_calc(void);
+
+/* FAWBANK - Number of Bank of a given device involved in the FAW period. */
+#define ARRIA10_SDR_ACTIVATE_FAWBANK	(0x1)
+
+#define ARRIA_DDR_CONFIG(A, B, C, R)	((A<<24)|(B<<16)|(C<<8)|R)

Missing parenthesis around (A), (B) etc. ...

drivers/ddr/altera/sdram_arria10.c line 29

Quoted 1 line
drivers/ddr/altera/sdram_arria10.c new file +1 -0
+#define DDR_CONFIG_ELEMENTS	(sizeof(ddr_config)/sizeof(u32))

So this is ARRAY_SIZE() ?

Quoted 77 lines
drivers/ddr/altera/sdram_arria10.c new file +77 -0
+#define DDR_REG_SEQ2CORE        0xFFD0507C
+#define DDR_REG_CORE2SEQ        0xFFD05078
+#define DDR_READ_LATENCY_DELAY	40
+#define DDR_SIZE_2GB_HEX	0x80000000
+#define DDR_MAX_TRIES		0x00100000
+
+#define IO48_MMR_DRAMSTS	0xFFCFA0EC
+#define IO48_MMR_NIOS2_RESERVE0	0xFFCFA110
+#define IO48_MMR_NIOS2_RESERVE1	0xFFCFA114
+#define IO48_MMR_NIOS2_RESERVE2	0xFFCFA118
+
+#define SEQ2CORE_MASK		0xF
+#define CORE2SEQ_INT_REQ	0xF
+#define SEQ2CORE_INT_RESP_BIT	3
+
+static const struct socfpga_ecc_hmc *socfpga_ecc_hmc_base =
+		(void *)SOCFPGA_SDR_ADDRESS;
+static const struct socfpga_noc_ddr_scheduler *socfpga_noc_ddr_scheduler_base =
+		(void *)SOCFPGA_SDR_SCHEDULER_ADDRESS;
+static const struct socfpga_noc_fw_ddr_mpu_fpga2sdram
+		*socfpga_noc_fw_ddr_mpu_fpga2sdram_base =
+		(void *)SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS;
+static const struct socfpga_noc_fw_ddr_l3 *socfpga_noc_fw_ddr_l3_base =
+		(void *)SOCFPGA_SDR_FIREWALL_L3_ADDRESS;
+static const struct socfpga_io48_mmr *socfpga_io48_mmr_base =
+		(void *)SOCFPGA_HMC_MMR_IO48_ADDRESS;
+
+/* The followring are the supported configurations */
+static u32 ddr_config[] = {
+	/* Chip - Row - Bank - Column Style */
+	/* All Types */
+	ARRIA_DDR_CONFIG(0, 3, 10, 12),
+	ARRIA_DDR_CONFIG(0, 3, 10, 13),
+	ARRIA_DDR_CONFIG(0, 3, 10, 14),
+	ARRIA_DDR_CONFIG(0, 3, 10, 15),
+	ARRIA_DDR_CONFIG(0, 3, 10, 16),
+	ARRIA_DDR_CONFIG(0, 3, 10, 17),
+	/* LPDDR x16 */
+	ARRIA_DDR_CONFIG(0, 3, 11, 14),
+	ARRIA_DDR_CONFIG(0, 3, 11, 15),
+	ARRIA_DDR_CONFIG(0, 3, 11, 16),
+	ARRIA_DDR_CONFIG(0, 3, 12, 15),
+	/* DDR4 Only */
+	ARRIA_DDR_CONFIG(0, 4, 10, 14),
+	ARRIA_DDR_CONFIG(0, 4, 10, 15),
+	ARRIA_DDR_CONFIG(0, 4, 10, 16),
+	ARRIA_DDR_CONFIG(0, 4, 10, 17),	/* 14 */
+	/* Chip - Bank - Row - Column Style */
+	ARRIA_DDR_CONFIG(1, 3, 10, 12),
+	ARRIA_DDR_CONFIG(1, 3, 10, 13),
+	ARRIA_DDR_CONFIG(1, 3, 10, 14),
+	ARRIA_DDR_CONFIG(1, 3, 10, 15),
+	ARRIA_DDR_CONFIG(1, 3, 10, 16),
+	ARRIA_DDR_CONFIG(1, 3, 10, 17),
+	ARRIA_DDR_CONFIG(1, 3, 11, 14),
+	ARRIA_DDR_CONFIG(1, 3, 11, 15),
+	ARRIA_DDR_CONFIG(1, 3, 11, 16),
+	ARRIA_DDR_CONFIG(1, 3, 12, 15),
+	/* DDR4 Only */
+	ARRIA_DDR_CONFIG(1, 4, 10, 14),
+	ARRIA_DDR_CONFIG(1, 4, 10, 15),
+	ARRIA_DDR_CONFIG(1, 4, 10, 16),
+	ARRIA_DDR_CONFIG(1, 4, 10, 17),
+};
+
+static int match_ddr_conf(u32 ddr_conf)
+{
+	int i;
+
+	for (i = 0; i < DDR_CONFIG_ELEMENTS; i++) {
+		if (ddr_conf == ddr_config[i])
+			return i;
+	}
+	return 0;
+}
+
+/* Check whether SDRAM is successfully Calibrated */

drivers/ddr/altera/sdram_arria10.c line 116

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+static int is_sdram_cal_success(void)
+{
+	return readl(&socfpga_ecc_hmc_base->ddrcalstat);
+}
+
+static unsigned char ddr_get_bit(u32 ereg, unsigned char bit)
+{
+	u32 reg = readl(ereg);
+
+	return (reg & (1 << bit)) ? 1 : 0;

Urgh, BIT() and just use it inline and drop this

Quoted 14 lines
drivers/ddr/altera/sdram_arria10.c new file +14 -0
+}
+
+static unsigned char ddr_wait_bit(u32 ereg, u32 bit,
+			   u32 expected, u32 timeout_usec)
+{
+	u32 tmr;
+
+	for (tmr = 0; tmr < timeout_usec; tmr += 100) {
+		udelay(100);
+		WATCHDOG_RESET();
+		if (ddr_get_bit(ereg, bit) == expected)
+			return 0;
+	}
+

drivers/ddr/altera/sdram_arria10.c line 140

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+	return 1;
+}
+
+static void ddr_delay(u32 delay)
+{
+	int tmr;
+
+	for (tmr = 0; tmr < delay; tmr++) {
+		udelay(1000);
+		WATCHDOG_RESET();

So this is mdelay(delay) ?

drivers/ddr/altera/sdram_arria10.c line 153

Quoted 13 lines
drivers/ddr/altera/sdram_arria10.c new file +13 -0
+	}
+}
+
+static int emif_clear(void)
+{
+	u32 s2c;
+	u32 i = DDR_MAX_TRIES;
+
+	writel(0, DDR_REG_CORE2SEQ);
+	do {
+		ddr_delay(50);
+		s2c = readl(DDR_REG_SEQ2CORE);
+	} while ((s2c & SEQ2CORE_MASK) && (--i > 0));

wait_for_bit() or something ?

Quoted 16 lines
drivers/ddr/altera/sdram_arria10.c new file +16 -0
+	return !i;
+}
+
+static int emif_reset(void)
+{
+	u32 c2s, s2c;
+
+	c2s = readl(DDR_REG_CORE2SEQ);
+	s2c = readl(DDR_REG_SEQ2CORE);
+
+	debug("c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
+		c2s, s2c, readl(IO48_MMR_NIOS2_RESERVE0),
+		readl(IO48_MMR_NIOS2_RESERVE1),
+		readl(IO48_MMR_NIOS2_RESERVE2),
+		readl(IO48_MMR_DRAMSTS));
+

drivers/ddr/altera/sdram_arria10.c line 180

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+	if ((s2c & SEQ2CORE_MASK) && emif_clear()) {
+		printf("failed emif_clear()\n");
+		return -1;
+	}
+
+	writel(CORE2SEQ_INT_REQ, DDR_REG_CORE2SEQ);
+
+	if (ddr_wait_bit(DDR_REG_SEQ2CORE, SEQ2CORE_INT_RESP_BIT, 0, 1000000)) {
+		printf("emif_reset failed to see interrupt acknowledge\n");
+		return -2;

Use proper errno.h codes

Quoted 17 lines
drivers/ddr/altera/sdram_arria10.c new file +17 -0
+	} else {
+		printf("emif_reset interrupt acknowledged\n");
+	}
+
+	if (emif_clear()) {
+		printf("emif_clear() failed\n");
+		return -3;
+	}
+	debug("emif_reset interrupt cleared\n");
+
+	debug("nr0=%08x nr1=%08x nr2=%08x\n",
+		readl(IO48_MMR_NIOS2_RESERVE0),
+		readl(IO48_MMR_NIOS2_RESERVE1),
+		readl(IO48_MMR_NIOS2_RESERVE2));
+
+	return 0;
+}

[...]

drivers/ddr/altera/sdram_arria10.c line 415

Quoted 11 lines
drivers/ddr/altera/sdram_arria10.c new file +11 -0
+struct firewall_entry {
+	const char *prop_name;
+	const u32 cfg_addr;
+	const u32 en_addr;
+	const u32 en_bit;
+};
+#define FW_MPU_FPGA_ADDRESS \
+	((const struct socfpga_noc_fw_ddr_mpu_fpga2sdram *)\
+	SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS)
+const struct firewall_entry firewall_table[] = {
+	{

This seems to be mostly copy-paste of the same stuff ... fix with macro.

Quoted 19 lines
drivers/ddr/altera/sdram_arria10.c new file +19 -0
+		"altr,mpu0",
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 mpuregion0addr),
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 enable),
+		ALT_NOC_FW_DDR_SCR_EN_MPUREG0EN_SET_MSK
+	},
+	{
+		"altr,mpu1",
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 mpuregion1addr),
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 enable),
+		ALT_NOC_FW_DDR_SCR_EN_MPUREG1EN_SET_MSK
+	},

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#54 lore raw

PATCH v2 12/19 arm: socfpga: Add DDR driver for Arria 10

Quoted 56 lines · Marek Vasut
Quoted 55 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add DDR driver suppport for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 + arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++- drivers/ddr/altera/sdram_arria10.c                 | 735
+++++++++++++++++++++

 3 files changed, 839 insertions(+), 1 deletion(-)

 create mode 100644 drivers/ddr/altera/sdram_arria10.c

arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
index 4a9754e..b833fc2 100644
@@ -10,6 +10,8 @@


 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/sdram_gen5.h>

arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/sdram_arria10.h>

 #endif

 #endif

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +1 -1
index 1d7b7c1..7af9431 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright (C) 2015-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
   *
   * SPDX-License-Identifier:	GPL-2.0
   */
@@ -8,6 +8,7 @@
  #define _SOCFPGA_SDRAM_ARRIA10_H_


 #ifndef __ASSEMBLY__
+int ddr_calibration_sequence(void);

 struct socfpga_ecc_hmc {
  u32 ip_rev_id;

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +3 -0
@@ -204,6 +205,106 @@ struct socfpga_io48_mmr {
  	u32 niosreserve1;
  	u32 niosreserve2;
  };
+
+union dramaddrw_reg {
+	struct {
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/sdram_arria10.h struct socfpga_io48_mmr { · line 217

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +7 -0
+		u32 cfg_col_addr_width:5;
+		u32 cfg_row_addr_width:5;
+		u32 cfg_bank_addr_width:4;
+		u32 cfg_bank_group_addr_width:2;
+		u32 cfg_cs_addr_width:3;
+		u32 reserved:13;
+	};

Use regular macros for bitfields, not this crap.

Why regular macros is prefered? Above implementation improve readability, simplify the implementation and saving memory.

Quoted 31 lines
Quoted 14 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +13 -0
+	u32 word;
+};
+
+union ctrlcfg0_reg {
+	struct {
+		u32 cfg_mem_type:4;
+		u32 cfg_dimm_type:3;
+		u32 cfg_ac_pos:2;
+		u32 cfg_ctrl_burst_len:5;
+		u32 reserved:18;  /* Other fields unused */
+	};
+	u32 word;
+};

[...]

Quoted 15 lines
drivers/ddr/altera/sdram_arria10.c new file +7 -0
new file mode 100644
index 0000000..f22a726
@@ -0,0 +1,735 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
Quoted 9 lines

drivers/ddr/altera/sdram_arria10.c line 13

Quoted 6 lines
drivers/ddr/altera/sdram_arria10.c new file +6 -0
+#include <fdtdec.h>
+#include <malloc.h>
+#include <mmc.h>
+#include <nand.h>
+#include <watchdog.h>
+#include <ns16550.h>

Why does an SDRAM init driver need access to ns16550 UART , MMC and NAND ?

I will remove them.

Quoted 11 lines
Quoted 11 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+#include <asm/io.h>
+#include <asm/arch/fpga_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/sdram.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void sdram_mmr_init(void);
+static unsigned long long sdram_size_calc(void);
Quoted 9 lines
Quoted 7 lines
drivers/ddr/altera/sdram_arria10.c new file +2 -0
+
+/* FAWBANK - Number of Bank of a given device involved in the FAW

period. */

drivers/ddr/altera/sdram_arria10.c new file +3 -0
+#define ARRIA10_SDR_ACTIVATE_FAWBANK	(0x1)
+
+#define ARRIA_DDR_CONFIG(A, B, C, R)	((A<<24)|(B<<16)|(C<<8

)|R)

Missing parenthesis around (A), (B) etc. ...

Okay.

Quoted 5 lines
Quoted 3 lines

+#define DDR_CONFIG_ELEMENTS (sizeof(ddr_config)/sizeof(u32)
)

So this is ARRAY_SIZE() ?

Yes. i will use ARRAY_SIZE().

Quoted 83 lines
Quoted 83 lines
drivers/ddr/altera/sdram_arria10.c new file +18 -0
+#define DDR_REG_SEQ2CORE        0xFFD0507C
+#define DDR_REG_CORE2SEQ        0xFFD05078
+#define DDR_READ_LATENCY_DELAY	40
+#define DDR_SIZE_2GB_HEX	0x80000000
+#define DDR_MAX_TRIES		0x00100000
+
+#define IO48_MMR_DRAMSTS	0xFFCFA0EC
+#define IO48_MMR_NIOS2_RESERVE0	0xFFCFA110
+#define IO48_MMR_NIOS2_RESERVE1	0xFFCFA114
+#define IO48_MMR_NIOS2_RESERVE2	0xFFCFA118
+
+#define SEQ2CORE_MASK		0xF
+#define CORE2SEQ_INT_REQ	0xF
+#define SEQ2CORE_INT_RESP_BIT	3
+
+static const struct socfpga_ecc_hmc *socfpga_ecc_hmc_base =
+		(void *)SOCFPGA_SDR_ADDRESS;
+static const struct socfpga_noc_ddr_scheduler

*socfpga_noc_ddr_scheduler_base =

drivers/ddr/altera/sdram_arria10.c new file +5 -0
+		(void *)SOCFPGA_SDR_SCHEDULER_ADDRESS;
+static const struct socfpga_noc_fw_ddr_mpu_fpga2sdram
+		*socfpga_noc_fw_ddr_mpu_fpga2sdram_base =
+		(void *)SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS;
+static const struct socfpga_noc_fw_ddr_l3

*socfpga_noc_fw_ddr_l3_base =

drivers/ddr/altera/sdram_arria10.c new file +57 -0
+		(void *)SOCFPGA_SDR_FIREWALL_L3_ADDRESS;
+static const struct socfpga_io48_mmr *socfpga_io48_mmr_base =
+		(void *)SOCFPGA_HMC_MMR_IO48_ADDRESS;
+
+/* The followring are the supported configurations */
+static u32 ddr_config[] = {
+	/* Chip - Row - Bank - Column Style */
+	/* All Types */
+	ARRIA_DDR_CONFIG(0, 3, 10, 12),
+	ARRIA_DDR_CONFIG(0, 3, 10, 13),
+	ARRIA_DDR_CONFIG(0, 3, 10, 14),
+	ARRIA_DDR_CONFIG(0, 3, 10, 15),
+	ARRIA_DDR_CONFIG(0, 3, 10, 16),
+	ARRIA_DDR_CONFIG(0, 3, 10, 17),
+	/* LPDDR x16 */
+	ARRIA_DDR_CONFIG(0, 3, 11, 14),
+	ARRIA_DDR_CONFIG(0, 3, 11, 15),
+	ARRIA_DDR_CONFIG(0, 3, 11, 16),
+	ARRIA_DDR_CONFIG(0, 3, 12, 15),
+	/* DDR4 Only */
+	ARRIA_DDR_CONFIG(0, 4, 10, 14),
+	ARRIA_DDR_CONFIG(0, 4, 10, 15),
+	ARRIA_DDR_CONFIG(0, 4, 10, 16),
+	ARRIA_DDR_CONFIG(0, 4, 10, 17),	/* 14 */
+	/* Chip - Bank - Row - Column Style */
+	ARRIA_DDR_CONFIG(1, 3, 10, 12),
+	ARRIA_DDR_CONFIG(1, 3, 10, 13),
+	ARRIA_DDR_CONFIG(1, 3, 10, 14),
+	ARRIA_DDR_CONFIG(1, 3, 10, 15),
+	ARRIA_DDR_CONFIG(1, 3, 10, 16),
+	ARRIA_DDR_CONFIG(1, 3, 10, 17),
+	ARRIA_DDR_CONFIG(1, 3, 11, 14),
+	ARRIA_DDR_CONFIG(1, 3, 11, 15),
+	ARRIA_DDR_CONFIG(1, 3, 11, 16),
+	ARRIA_DDR_CONFIG(1, 3, 12, 15),
+	/* DDR4 Only */
+	ARRIA_DDR_CONFIG(1, 4, 10, 14),
+	ARRIA_DDR_CONFIG(1, 4, 10, 15),
+	ARRIA_DDR_CONFIG(1, 4, 10, 16),
+	ARRIA_DDR_CONFIG(1, 4, 10, 17),
+};
+
+static int match_ddr_conf(u32 ddr_conf)
+{
+	int i;
+
+	for (i = 0; i < DDR_CONFIG_ELEMENTS; i++) {
+		if (ddr_conf == ddr_config[i])
+			return i;
+	}
+	return 0;
+}
+
+/* Check whether SDRAM is successfully Calibrated */
+static int is_sdram_cal_success(void)
+{
+	return readl(&socfpga_ecc_hmc_base->ddrcalstat);
Quoted 9 lines

drivers/ddr/altera/sdram_arria10.c line 116

Quoted 7 lines
drivers/ddr/altera/sdram_arria10.c new file +7 -0
+}
+
+static unsigned char ddr_get_bit(u32 ereg, unsigned char bit)
+{
+	u32 reg = readl(ereg);
+
+	return (reg & (1 << bit)) ? 1 : 0;

Urgh, BIT() and just use it inline and drop this

Okay.

Quoted 18 lines
Quoted 18 lines
drivers/ddr/altera/sdram_arria10.c new file +17 -0
+}
+
+static unsigned char ddr_wait_bit(u32 ereg, u32 bit,
+			   u32 expected, u32 timeout_usec)
+{
+	u32 tmr;
+
+	for (tmr = 0; tmr < timeout_usec; tmr += 100) {
+		udelay(100);
+		WATCHDOG_RESET();
+		if (ddr_get_bit(ereg, bit) == expected)
+			return 0;
+	}
+
+	return 1;
+}
+
Quoted 9 lines

drivers/ddr/altera/sdram_arria10.c line 140

Quoted 7 lines
drivers/ddr/altera/sdram_arria10.c new file +7 -0
+static void ddr_delay(u32 delay)
+{
+	int tmr;
+
+	for (tmr = 0; tmr < delay; tmr++) {
+		udelay(1000);
+		WATCHDOG_RESET();

So this is mdelay(delay) ?

Yes, i can use mdelay.

Quoted 16 lines
Quoted 4 lines
drivers/ddr/altera/sdram_arria10.c new file +3 -0
+	}
+}
+

drivers/ddr/altera/sdram_arria10.c line 153

Quoted 10 lines
drivers/ddr/altera/sdram_arria10.c new file +10 -0
+static int emif_clear(void)
+{
+	u32 s2c;
+	u32 i = DDR_MAX_TRIES;
+
+	writel(0, DDR_REG_CORE2SEQ);
+	do {
+		ddr_delay(50);
+		s2c = readl(DDR_REG_SEQ2CORE);
+	} while ((s2c & SEQ2CORE_MASK) && (--i > 0));

wait_for_bit() or something ?

Okay.

Quoted 23 lines
Quoted 23 lines
drivers/ddr/altera/sdram_arria10.c new file +11 -0
+	return !i;
+}
+
+static int emif_reset(void)
+{
+	u32 c2s, s2c;
+
+	c2s = readl(DDR_REG_CORE2SEQ);
+	s2c = readl(DDR_REG_SEQ2CORE);
+
+	debug("c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x

dst=%08x\n",

drivers/ddr/altera/sdram_arria10.c new file +10 -0
+		c2s, s2c, readl(IO48_MMR_NIOS2_RESERVE0),
+		readl(IO48_MMR_NIOS2_RESERVE1),
+		readl(IO48_MMR_NIOS2_RESERVE2),
+		readl(IO48_MMR_DRAMSTS));
+
+	if ((s2c & SEQ2CORE_MASK) && emif_clear()) {
+		printf("failed emif_clear()\n");
+		return -1;
+	}
+
Quoted 9 lines

drivers/ddr/altera/sdram_arria10.c line 180

Quoted 7 lines
drivers/ddr/altera/sdram_arria10.c new file +3 -0
+	writel(CORE2SEQ_INT_REQ, DDR_REG_CORE2SEQ);
+
+	if (ddr_wait_bit(DDR_REG_SEQ2CORE, SEQ2CORE_INT_RESP_BIT,

0, 1000000)) {

drivers/ddr/altera/sdram_arria10.c new file +1 -0
+		printf("emif_reset failed to see interrupt

acknowledge\n");

drivers/ddr/altera/sdram_arria10.c new file +1 -0
+		return -2;

Use proper errno.h codes

Okay.

Quoted 21 lines
Quoted 18 lines
drivers/ddr/altera/sdram_arria10.c new file +17 -0
+	} else {
+		printf("emif_reset interrupt acknowledged\n");
+	}
+
+	if (emif_clear()) {
+		printf("emif_clear() failed\n");
+		return -3;
+	}
+	debug("emif_reset interrupt cleared\n");
+
+	debug("nr0=%08x nr1=%08x nr2=%08x\n",
+		readl(IO48_MMR_NIOS2_RESERVE0),
+		readl(IO48_MMR_NIOS2_RESERVE1),
+		readl(IO48_MMR_NIOS2_RESERVE2));
+
+	return 0;
+}

[...]

Quoted 1 line
Quoted 14 lines

drivers/ddr/altera/sdram_arria10.c line 415

Quoted 11 lines
drivers/ddr/altera/sdram_arria10.c new file +11 -0
+struct firewall_entry {
+	const char *prop_name;
+	const u32 cfg_addr;
+	const u32 en_addr;
+	const u32 en_bit;
+};
+#define FW_MPU_FPGA_ADDRESS \
+	((const struct socfpga_noc_fw_ddr_mpu_fpga2sdram *)\
+	SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS)
+const struct firewall_entry firewall_table[] = {
+	{

This seems to be mostly copy-paste of the same stuff ... fix with macro.

Okay.

Quoted 23 lines
Quoted 20 lines
drivers/ddr/altera/sdram_arria10.c new file +19 -0
+		"altr,mpu0",
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 mpuregion0addr),
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 enable),
+		ALT_NOC_FW_DDR_SCR_EN_MPUREG0EN_SET_MSK
+	},
+	{
+		"altr,mpu1",
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 mpuregion1addr),
+		SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS +
+		offsetof(struct socfpga_noc_fw_ddr_mpu_fpga2sdram,
+			 enable),
+		ALT_NOC_FW_DDR_SCR_EN_MPUREG1EN_SET_MSK
+	},

[...]

#55 lore raw

PATCH v2 12/19 arm: socfpga: Add DDR driver for Arria 10

Quoted 66 lines · Tien Fong
Quoted 56 lines · Marek Vasut
Quoted 55 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add DDR driver suppport for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 + arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++- drivers/ddr/altera/sdram_arria10.c                 | 735
+++++++++++++++++++++

 3 files changed, 839 insertions(+), 1 deletion(-)

 create mode 100644 drivers/ddr/altera/sdram_arria10.c

arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
index 4a9754e..b833fc2 100644
@@ -10,6 +10,8 @@


 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/sdram_gen5.h>

arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/sdram_arria10.h>

 #endif

 #endif

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +1 -1
index 1d7b7c1..7af9431 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright (C) 2015-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
   *
   * SPDX-License-Identifier:	GPL-2.0
   */
@@ -8,6 +8,7 @@
  #define _SOCFPGA_SDRAM_ARRIA10_H_


 #ifndef __ASSEMBLY__
+int ddr_calibration_sequence(void);

 struct socfpga_ecc_hmc {
  u32 ip_rev_id;

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +3 -0
@@ -204,6 +205,106 @@ struct socfpga_io48_mmr {
  	u32 niosreserve1;
  	u32 niosreserve2;
  };
+
+union dramaddrw_reg {
+	struct {
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/sdram_arria10.h struct socfpga_io48_mmr { · line 217

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +7 -0
+		u32 cfg_col_addr_width:5;
+		u32 cfg_row_addr_width:5;
+		u32 cfg_bank_addr_width:4;
+		u32 cfg_bank_group_addr_width:2;
+		u32 cfg_cs_addr_width:3;
+		u32 reserved:13;
+	};

Use regular macros for bitfields, not this crap.

Quoted 2 lines

Why regular macros is prefered? Above implementation improve readability, simplify the implementation and saving memory.

Because that's how U-Boot does it (and the above afair breaks on different endianness).

Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +13 -0
+	u32 word;
+};
+
+union ctrlcfg0_reg {
+	struct {
+		u32 cfg_mem_type:4;
+		u32 cfg_dimm_type:3;
+		u32 cfg_ac_pos:2;
+		u32 cfg_ctrl_burst_len:5;
+		u32 reserved:18;  /* Other fields unused */
+	};
+	u32 word;
+};

[...]

[...]

Signature · 2 lines
Best regards,
Marek Vasut
#56 lore raw

PATCH v2 12/19 arm: socfpga: Add DDR driver for Arria 10

Quoted 70 lines · Marek Vasut
Quoted 69 lines · Tien Fong
Quoted 67 lines · Marek Vasut
Quoted 53 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Add DDR driver suppport for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram.h         |   2 + arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 103 ++- drivers/ddr/altera/sdram_arria10.c                 | 735
+++++++++++++++++++++

 3 files changed, 839 insertions(+), 1 deletion(-)

 create mode 100644 drivers/ddr/altera/sdram_arria10.c

arch/arm/mach-socfpga/include/mach/sdram.h +0 -0
index 4a9754e..b833fc2 100644
@@ -10,6 +10,8 @@


 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/sdram_gen5.h>

arch/arm/mach-socfpga/include/mach/sdram.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/sdram_arria10.h>

 #endif

 #endif

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +1 -1
index 1d7b7c1..7af9431 100644
@@ -1,5 +1,5 @@
  /*
- * Copyright (C) 2015-2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
   *
   * SPDX-License-Identifier:	GPL-2.0
   */
@@ -8,6 +8,7 @@
  #define _SOCFPGA_SDRAM_ARRIA10_H_


 #ifndef __ASSEMBLY__
+int ddr_calibration_sequence(void);

 struct socfpga_ecc_hmc {
  u32 ip_rev_id;

arch/arm/mach-socfpga/include/mach/sdram_arria10.h +0 -0
@@ -204,6 +205,106 @@ struct socfpga_io48_mmr {
  	u32 niosreserve1;
  	u32 niosreserve2;
  };

arch/arm/mach-socfpga/include/mach/sdram_arria10.h struct socfpga_io48_mmr { · line 217

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +10 -0
+
+union dramaddrw_reg {
+	struct {
+		u32 cfg_col_addr_width:5;
+		u32 cfg_row_addr_width:5;
+		u32 cfg_bank_addr_width:4;
+		u32 cfg_bank_group_addr_width:2;
+		u32 cfg_cs_addr_width:3;
+		u32 reserved:13;
+	};

Use regular macros for bitfields, not this crap.

Quoted 5 lines
Quoted 2 lines

Why regular macros is prefered? Above implementation improve readability, simplify the implementation and saving memory.

Because that's how U-Boot does it (and the above afair breaks on different endianness).

Okay.

Quoted 20 lines
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
arch/arm/mach-socfpga/include/mach/sdram_arria10.h +13 -0
+	u32 word;
+};
+
+union ctrlcfg0_reg {
+	struct {
+		u32 cfg_mem_type:4;
+		u32 cfg_dimm_type:3;
+		u32 cfg_ac_pos:2;
+		u32 cfg_ctrl_burst_len:5;
+		u32 reserved:18;  /* Other fields unused */
+	};
+	u32 word;
+};

[...]

[...]

#57 lore raw

PATCH v2 13/19 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
#58 lore raw

PATCH v2 14/19 arm: socfpga: Enable build for DDR Arria 10

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

From: Tien Fong Chee <[email protected]>

This patch is for enabling the DDR support on Arria 10.

---
 drivers/ddr/altera/Makefile | 1 +
 1 file changed, 1 insertion(+)
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
Signature · 1 line
2.2.0
#59 lore raw

PATCH v2 14/19 arm: socfpga: Enable build for DDR Arria 10

Quoted 15 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This patch is for enabling the DDR support on Arria 10.

---
 drivers/ddr/altera/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/ddr/altera/Makefile +0 -0
index ac4ab85..02f8b7c 100644

drivers/ddr/altera/Makefile line 14

Quoted 5 lines
drivers/ddr/altera/Makefile +1 -0
@@ -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

This should be part of the patch which added the sdram_arria10.c

Signature · 2 lines
Best regards,
Marek Vasut
#60 lore raw

PATCH v2 14/19 arm: socfpga: Enable build for DDR Arria 10

Quoted 11 lines · Marek Vasut
Quoted 10 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

This patch is for enabling the DDR support on Arria 10.

---
 drivers/ddr/altera/Makefile | 1 +

 1 file changed, 1 insertion(+)
Quoted 14 lines
Quoted 6 lines
drivers/ddr/altera/Makefile +0 -0
index ac4ab85..02f8b7c 100644
@@ -10,4 +10,5 @@
Quoted 6 lines


 ifdef CONFIG_ALTERA_SDRAM obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o +obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o endif

This should be part of the patch which added the sdram_arria10.c

Okay.

#61 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

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

From: Tien Fong Chee <[email protected]>

Add support to 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 | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +22 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 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, it is required by FAT feature */
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RAM_SIZE - \
+					 GENERATED_GBL_DATA_SIZE - \
+					 CONFIG_SYS_SPL_MALLOC_SIZE + \
+					 CONFIG_SYS_INIT_RAM_ADDR)
+#endif
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -320,7 +337,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 - 1)
+#endif
 
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
Signature · 1 line
2.2.0
#62 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Gen 5 does have malloc support in SPL, so what's the deal here ?

Quoted 57 lines
---
 include/configs/socfpga_common.h | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +22 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 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, it is required by FAT feature */
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RAM_SIZE - \
+					 GENERATED_GBL_DATA_SIZE - \
+					 CONFIG_SYS_SPL_MALLOC_SIZE + \
+					 CONFIG_SYS_INIT_RAM_ADDR)
+#endif
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -320,7 +337,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 - 1)
+#endif
 
 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD
Signature · 2 lines
Best regards,
Marek Vasut
#63 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 11 lines · Marek Vasut
Quoted 8 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Gen 5 does have malloc support in SPL, so what's the deal here ?

For FAT to work properly in Arria 10 SPL, SPL malloc need to be enabled, and the min of SPL malloc size is 0x2000. FAT needed in Arria 10 SPL, because u-boot.img is stored in FAT partition.

Quoted 69 lines
Quoted 68 lines

---
 include/configs/socfpga_common.h | 23 ++++++++++++++++++++++-

 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +8 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 0xFFE3_FFFF ...... End of SRAM (top)
   */
  #define CONFIG_SPL_FRAMEWORK
  #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_AD

DR
 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT_RAM_SIZ
E

include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+/* SPL memory allocation configuration, it is required by FAT

feature */

include/configs/socfpga_common.h +3 -0
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RAM_SI

ZE - \

include/configs/socfpga_common.h +1 -0
+					 GENERATED_GBL_DATA_SIZE -

\

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_SPL_MALLOC_SIZ

E + \

include/configs/socfpga_common.h +3 -0
+					 CONFIG_SYS_INIT_RAM_ADDR)
+#endif
+#endif


 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT

include/configs/socfpga_common.h +4 -0
@@ -320,7 +337,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_STA
 RT - 1)
+#endif


 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD

#64 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 9 lines · Tien Fong
Quoted 8 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Gen 5 does have malloc support in SPL, so what's the deal here ?

For FAT to work properly in Arria 10 SPL, SPL malloc need to be enabled,

It is already enabled on Gen 5

Quoted 1 line

and the min of SPL malloc size is 0x2000.

Where did you find about this minimum ? That can be configured ...

Quoted 2 lines

FAT needed in Arria
10 SPL, because u-boot.img is stored in FAT partition.

It can also be stored on ext partition (which is preferred, patent-wise)

Quoted 68 lines
Quoted 68 lines
Quoted 68 lines

---
 include/configs/socfpga_common.h | 23 ++++++++++++++++++++++-

 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +8 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 0xFFE3_FFFF ...... End of SRAM (top)
   */
  #define CONFIG_SPL_FRAMEWORK
  #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_AD

DR
 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT_RAM_SIZ
E

include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+/* SPL memory allocation configuration, it is required by FAT

feature */

include/configs/socfpga_common.h +3 -0
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RAM_SI

ZE - \

include/configs/socfpga_common.h +1 -0
+					 GENERATED_GBL_DATA_SIZE -

\

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_SPL_MALLOC_SIZ

E + \

include/configs/socfpga_common.h +3 -0
+					 CONFIG_SYS_INIT_RAM_ADDR)
+#endif
+#endif


 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT

include/configs/socfpga_common.h +4 -0
@@ -320,7 +337,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_STA
 RT - 1)
+#endif


 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD

Signature · 2 lines
Best regards,
Marek Vasut
#65 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 14 lines · Marek Vasut
Quoted 13 lines · Tien Fong
Quoted 11 lines · Marek Vasut
Quoted 9 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Gen 5 does have malloc support in SPL, so what's the deal here ?

For FAT to work properly in Arria 10 SPL, SPL malloc need to be enabled,

It is already enabled on Gen 5

I think i have confused you, this patch is for getting the malloc area mapping to Arria 10 SRAM memory correctly. I will improve the commit message.

Quoted 4 lines
Quoted 2 lines

and the min of SPL malloc size is 0x2000.

Where did you find about this minimum ? That can be configured ...

I having issue to boot u-boot successful(Hung or reset), after debuging through debugger, just found that 0x2000 is min required.

Quoted 86 lines
Quoted 3 lines

FAT needed in Arria
10 SPL, because u-boot.img is stored in FAT partition.

It can also be stored on ext partition (which is preferred, patent- wise)

Quoted 79 lines
Quoted 79 lines
Quoted 79 lines

---
 include/configs/socfpga_common.h | 23 ++++++++++++++++++++++-

 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +8 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 0xFFE3_FFFF ...... End of SRAM (top)
   */
  #define CONFIG_SPL_FRAMEWORK
  #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RA

M_AD
DR
 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT_RAM
_SIZ
E

include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+/* SPL memory allocation configuration, it is required by FAT

feature */

include/configs/socfpga_common.h +3 -0
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RA

M_SI
ZE - \

include/configs/socfpga_common.h +1 -0
+					 GENERATED_GBL_DATA_SI

ZE -
\

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_SPL_MALLOC

_SIZ
E + \

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_INIT_RAM_A

DDR)

include/configs/socfpga_common.h +2 -0
+#endif
+#endif


 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT

include/configs/socfpga_common.h +1 -0
@@ -320,7 +337,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_ADD

R

include/configs/socfpga_common.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_STACK		(CONFIG_SYS_SPL_MALLOC

_STA
RT - 1)
+#endif

 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD

#66 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 26 lines · Tien Fong
Quoted 14 lines · Marek Vasut
Quoted 13 lines · Tien Fong
Quoted 11 lines · Marek Vasut
Quoted 9 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Gen 5 does have malloc support in SPL, so what's the deal here ?

For FAT to work properly in Arria 10 SPL, SPL malloc need to be enabled,

It is already enabled on Gen 5

I think i have confused you, this patch is for getting the malloc area mapping to Arria 10 SRAM memory correctly. I will improve the commit message.

Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

and the min of SPL malloc size is 0x2000.

Where did you find about this minimum ? That can be configured ...

I having issue to boot u-boot successful(Hung or reset), after debuging through debugger, just found that 0x2000 is min required.

You can set the value much lower and depending on the requirements, it will work, so the problem must be elsewhere ...

Quoted 85 lines
Quoted 85 lines
Quoted 3 lines

FAT needed in Arria
10 SPL, because u-boot.img is stored in FAT partition.

It can also be stored on ext partition (which is preferred, patent- wise)

Quoted 79 lines
Quoted 79 lines
Quoted 79 lines

---
 include/configs/socfpga_common.h | 23 ++++++++++++++++++++++-

 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +8 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 0xFFE3_FFFF ...... End of SRAM (top)
   */
  #define CONFIG_SPL_FRAMEWORK
  #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RA

M_AD
DR
 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT_RAM
_SIZ
E

include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+/* SPL memory allocation configuration, it is required by FAT

feature */

include/configs/socfpga_common.h +3 -0
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INIT_RA

M_SI
ZE - \

include/configs/socfpga_common.h +1 -0
+					 GENERATED_GBL_DATA_SI

ZE -
\

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_SPL_MALLOC

_SIZ
E + \

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_INIT_RAM_A

DDR)

include/configs/socfpga_common.h +2 -0
+#endif
+#endif


 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT

include/configs/socfpga_common.h +1 -0
@@ -320,7 +337,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_ADD

R

include/configs/socfpga_common.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_STACK		(CONFIG_SYS_SPL_MALLOC

_STA
RT - 1)
+#endif

 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD

Signature · 2 lines
Best regards,
Marek Vasut
#67 lore raw

PATCH v2 15/19 arm: socfpga: Add support to memory allocation in SPL

Quoted 42 lines · Marek Vasut
Quoted 41 lines · Tien Fong
Quoted 19 lines · Marek Vasut
Quoted 17 lines · Tien Fong
Quoted 14 lines · Marek Vasut
Quoted 11 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

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

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Gen 5 does have malloc support in SPL, so what's the deal here ?

For FAT to work properly in Arria 10 SPL, SPL malloc need to be enabled,

It is already enabled on Gen 5

I think i have confused you, this patch is for getting the malloc area
mapping to Arria 10 SRAM memory correctly. I will improve the commit
message.

Quoted 7 lines
Quoted 4 lines

and the min of SPL malloc size is 0x2000.

Where did you find about this minimum ? That can be configured
...

Quoted 7 lines
Quoted 3 lines

I having issue to boot u-boot successful(Hung or reset), after debuging
through debugger, just found that 0x2000 is min required.

You can set the value much lower and depending on the requirements, it
will work, so the problem must be elsewhere ...

Okay, i will test it out.

Quoted 103 lines
Quoted 102 lines
Quoted 102 lines
Quoted 6 lines

FAT needed in Arria
10 SPL, because u-boot.img is stored in FAT partition.

It can also be stored on ext partition (which is preferred, patent-
wise)

Quoted 92 lines
Quoted 92 lines
Quoted 92 lines

---
 include/configs/socfpga_common.h | 23
++++++++++++++++++++++-

 1 file changed, 22 insertions(+), 1 deletion(-)
include/configs/socfpga_common.h +8 -1
index 7549ee8..9b6719e 100644
@@ -280,17 +280,34 @@ 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 ...... Malloc area (grows up to top)
+ * 0xFFEz_zzzz ...... Global Data
+ * 0xFFE3_FFFF ...... End of SRAM (top)
   */
  #define CONFIG_SPL_FRAMEWORK
  #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INI

T_RA
M_AD
DR
 #define CONFIG_SPL_MAX_SIZE CONFIG_SYS_INIT
_RAM
_SIZ
E

include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+/* SPL memory allocation configuration, it is required by

FAT
feature */

include/configs/socfpga_common.h +3 -0
+#ifndef CONFIG_SYS_SPL_MALLOC_START
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x00002000
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SYS_INI

T_RA
M_SI
ZE - \

include/configs/socfpga_common.h +1 -0
+					 GENERATED_GBL_DAT

A_SI
ZE -
\

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_SPL_MA

LLOC
_SIZ
E + \

include/configs/socfpga_common.h +1 -0
+					 CONFIG_SYS_INIT_R

AM_A
DDR)

include/configs/socfpga_common.h +2 -0
+#endif
+#endif


 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT

include/configs/socfpga_common.h +1 -0
@@ -320,7 +337,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

_ADD
R

include/configs/socfpga_common.h +2 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_STACK		(CONFIG_SYS_SPL_MA

LLOC
_STA
RT - 1)
+#endif

 /* Extra Environment */
 #ifndef CONFIG_SPL_BUILD

#68 lore raw

PATCH v2 16/19 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 | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +9 -2
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
 	.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) */
+#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;
 
 	b reset;		/* SoCFPGA jumps here */
Signature · 1 line
2.2.0
#69 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 16 lines · 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 | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/boot0.h +3 -2
@@ -11,8 +11,15 @@
 	.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) */
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy - entries.

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/boot0.h +6 -0
+	.word	0xf00dcafe; /*
+			     * Program entry offset(4B),relative to
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple checksum(2B),spare offset(2B) */
 	nop;
 
 	b reset;		/* SoCFPGA jumps here */
Signature · 2 lines
Best regards,
Marek Vasut
#70 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 26 lines · Marek Vasut
Quoted 25 lines · 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 | 11 +++++++++--

 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
  	.balignl 64,0xf33db33f;


  .word 0x1337c0d3; /* SoCFPGA preloader
validation word */

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xc01df00d;	/* Version, flags, length
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 6 lines

*/

arch/arm/mach-socfpga/include/mach/boot0.h +1 -1
-	.word	0xcafec0d3;	/* Checksum, zero-pad */
+	.word	0xc01df00d; /* Header

length(2B),flags(1B),version(1B) */

arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy - entries.

Are you saying to keep the comment indent intact, and allign with 1st comment  /* SoCFPGA preloader validation word */ ?

Quoted 14 lines
Quoted 13 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+	.word	0xf00dcafe; /*
+			     * Program entry offset(4B),relative

to

arch/arm/mach-socfpga/include/mach/boot0.h +4 -0
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple

checksum(2B),spare offset(2B) */
  nop;

  b reset; /* SoCFPGA jumps here */

#71 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 36 lines · Tien Fong
Quoted 26 lines · Marek Vasut
Quoted 25 lines · 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 | 11 +++++++++--

 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
  	.balignl 64,0xf33db33f;


  .word 0x1337c0d3; /* SoCFPGA preloader
validation word */

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xc01df00d;	/* Version, flags, length
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 6 lines

*/

arch/arm/mach-socfpga/include/mach/boot0.h +1 -1
-	.word	0xcafec0d3;	/* Checksum, zero-pad */
+	.word	0xc01df00d; /* Header

length(2B),flags(1B),version(1B) */

arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy - entries.

Quoted 2 lines

Are you saying to keep the comment indent intact, and allign with 1st comment  /* SoCFPGA preloader validation word */ ?

Just look at the diff and make sure that it only changes the relevant parts, not extras due to indent changes.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+	.word	0xf00dcafe; /*
+			     * Program entry offset(4B),relative

to

arch/arm/mach-socfpga/include/mach/boot0.h +4 -0
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple

checksum(2B),spare offset(2B) */
  nop;

  b reset; /* SoCFPGA jumps here */

Signature · 2 lines
Best regards,
Marek Vasut
#72 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 44 lines · Marek Vasut
Quoted 43 lines · Tien Fong
Quoted 41 lines · Marek Vasut
Quoted 34 lines · 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 | 11 +++++++++--

 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
  	.balignl 64,0xf33db33f;


  .word 0x1337c0d3; /* SoCFPGA preloader
validation word */

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xc01df00d;	/* Version, flags,

length
*/

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xcafec0d3;	/* Checksum, zero-pad

*/

arch/arm/mach-socfpga/include/mach/boot0.h +1 -0
+	.word	0xc01df00d; /* Header

length(2B),flags(1B),version(1B) */

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 2 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy - entries.

Quoted 6 lines
Quoted 3 lines

Are you saying to keep the comment indent intact, and allign with 1st
comment  /* SoCFPGA preloader validation word */ ?

Just look at the diff and make sure that it only changes the relevant parts, not extras due to indent changes.

Not get you, which particular change is due to indent changes only? Some changes are for re-writing more descriptive comment. And some new adding header attributes to support Arria 10.

Quoted 18 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+	.word	0xf00dcafe; /*
+			     * Program entry

offset(4B),relative
to

arch/arm/mach-socfpga/include/mach/boot0.h +4 -0
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple

checksum(2B),spare offset(2B) */
  nop;

  b reset; /* SoCFPGA jumps here */

#73 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 48 lines · Tien Fong
Quoted 47 lines · Marek Vasut
Quoted 46 lines · Tien Fong
Quoted 32 lines · Marek Vasut
Quoted 30 lines · 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 | 11 +++++++++--

 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
  	.balignl 64,0xf33db33f;


  .word 0x1337c0d3; /* SoCFPGA preloader
validation word */

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xc01df00d;	/* Version, flags,

length
*/

Quoted 9 lines

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xcafec0d3;	/* Checksum, zero-pad

*/

arch/arm/mach-socfpga/include/mach/boot0.h +1 -0
+	.word	0xc01df00d; /* Header

length(2B),flags(1B),version(1B) */

arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy - entries.

Are you saying to keep the comment indent intact, and allign with 1st
comment  /* SoCFPGA preloader validation word */ ?

Quoted 6 lines
Quoted 3 lines

Just look at the diff and make sure that it only changes the relevant parts, not extras due to indent changes.

Not get you, which particular change is due to indent changes only? Some changes are for re-writing more descriptive comment. And some new adding header attributes to support Arria 10.

Aaargh, then don't do two things in one patch.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+	.word	0xf00dcafe; /*
+			     * Program entry

offset(4B),relative
to

arch/arm/mach-socfpga/include/mach/boot0.h +4 -0
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple

checksum(2B),spare offset(2B) */
  nop;

  b reset; /* SoCFPGA jumps here */

Signature · 2 lines
Best regards,
Marek Vasut
#74 lore raw

PATCH v2 16/19 arm: socfpga: Enhance Intel SoCFPGA program header to support Arria 10

Quoted 65 lines · Marek Vasut
Quoted 64 lines · Tien Fong
Quoted 62 lines · Marek Vasut
Quoted 52 lines · Tien Fong
Quoted 40 lines · Marek Vasut
Quoted 37 lines · 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 | 11 +++++++++- -

 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/boot0.h +0 -0
index 22d9e7f..33c9368 100644
@@ -11,8 +11,15 @@
  	.balignl 64,0xf33db33f;


  .word 0x1337c0d3; /* SoCFPGA
preloader
validation word */

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xc01df00d;	/* Version, flags,

length
*/

arch/arm/mach-socfpga/include/mach/boot0.h +0 -1
-	.word	0xcafec0d3;	/* Checksum, zero-

pad

Quoted 9 lines

arch/arm/mach-socfpga/include/mach/boot0.h line 16

Quoted 5 lines

*/

arch/arm/mach-socfpga/include/mach/boot0.h +1 -0
+	.word	0xc01df00d; /* Header

length(2B),flags(1B),version(1B) */

arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+#ifndef CONFIG_TARGET_SOCFPGA_GEN5
+	.word	0xfeedface; /* Program length(4B) */

Keep this indent intact, then it won't generate these crappy -
entries.

Quoted 4 lines

Are you saying to keep the comment indent intact, and allign with
1st
comment  /* SoCFPGA preloader validation word */ ?

Just look at the diff and make sure that it only changes the relevant
parts, not extras due to indent changes.

Quoted 6 lines
Quoted 4 lines

Not get you, which particular change is due to indent changes only? Some changes are for re-writing more descriptive comment. And some new
adding header attributes to support Arria 10.

Aaargh, then don't do two things in one patch.

I can split them.

Quoted 23 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
arch/arm/mach-socfpga/include/mach/boot0.h +2 -0
+	.word	0xf00dcafe; /*
+			     * Program entry

offset(4B),relative
to

arch/arm/mach-socfpga/include/mach/boot0.h +4 -0
+			     * the start of program header
+			     */
+#endif
+	.word	0xcafec0d3;	/* Simple

checksum(2B),spare offset(2B) */
  nop;

  b reset; /* SoCFPGA jumps here */

#75 lore raw

PATCH v2 17/19 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.

---
 arch/arm/mach-socfpga/board.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-socfpga/board.c +6 -0
index 965f9dc..a00f63b 100644
@@ -8,7 +8,10 @@
 
 #include <common.h>
 #include <errno.h>
+#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>
@@ -26,6 +29,9 @@ int board_init(void)
 	/* Address of boot parameters for ATAG (if ATAG is used) */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+
 	return 0;
 }
 
Signature · 1 line
2.2.0
#76 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

Quoted 5 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-boot.

I want a TB on Gen 5

Quoted 30 lines
---
 arch/arm/mach-socfpga/board.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-socfpga/board.c +6 -0
index 965f9dc..a00f63b 100644
@@ -8,7 +8,10 @@
 
 #include <common.h>
 #include <errno.h>
+#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>
@@ -26,6 +29,9 @@ int board_init(void)
 	/* Address of boot parameters for ATAG (if ATAG is used) */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+
 	return 0;
 }
 
Signature · 2 lines
Best regards,
Marek Vasut
#77 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

Quoted 9 lines · Marek Vasut
Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-boot.

I want a TB on Gen 5

What is TB?

Quoted 34 lines
Quoted 33 lines

---
 arch/arm/mach-socfpga/board.c | 6 ++++++

 1 file changed, 6 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index 965f9dc..a00f63b 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -8,7 +8,10 @@


 #include <common.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <asm/arch/reset_manager.h>

arch/arm/mach-socfpga/board.c +2 -0
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/misc.h>

 #include <asm/io.h>

 #include <usb.h>

arch/arm/mach-socfpga/board.c +0 -0
@@ -26,6 +29,9 @@ int board_init(void)
  	/* Address of boot parameters for ATAG (if ATAG is used)
 */
  	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

arch/arm/mach-socfpga/board.c +3 -0
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+

  return 0;
 }

#78 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut
Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-boot.

I want a TB on Gen 5

Okay.

Quoted 34 lines
Quoted 33 lines

---
 arch/arm/mach-socfpga/board.c | 6 ++++++

 1 file changed, 6 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index 965f9dc..a00f63b 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -8,7 +8,10 @@


 #include <common.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <asm/arch/reset_manager.h>

arch/arm/mach-socfpga/board.c +2 -0
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/misc.h>

 #include <asm/io.h>

 #include <usb.h>

arch/arm/mach-socfpga/board.c +0 -0
@@ -26,6 +29,9 @@ int board_init(void)
  	/* Address of boot parameters for ATAG (if ATAG is used)
 */
  	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

arch/arm/mach-socfpga/board.c +3 -0
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+

  return 0;
 }

#79 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

In reply to Marek Vasut
Quoted 9 lines · Marek Vasut
Quoted 6 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-boot.

I want a TB on Gen 5

This patch break the gen5, because cm_basic_init is exclusive for Arria
10. #ifdef is required.

Quoted 34 lines
Quoted 33 lines

---
 arch/arm/mach-socfpga/board.c | 6 ++++++

 1 file changed, 6 insertions(+)
arch/arm/mach- renamed from arch/arm/mach-socfpga/board.c +0 -0

socfpga/board.c
index 965f9dc..a00f63b 100644

arch/arm/mach-socfpga/board.c +0 -0
@@ -8,7 +8,10 @@


 #include <common.h>
 #include <errno.h>
+#include <fdtdec.h>
 #include <asm/arch/reset_manager.h>

arch/arm/mach-socfpga/board.c +2 -0
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/misc.h>

 #include <asm/io.h>

 #include <usb.h>

arch/arm/mach-socfpga/board.c +0 -0
@@ -26,6 +29,9 @@ int board_init(void)
  	/* Address of boot parameters for ATAG (if ATAG is used)
 */
  	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;

arch/arm/mach-socfpga/board.c +3 -0
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+

  return 0;
 }

#80 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

Quoted 5 lines · Tien Fong
Quoted 4 lines · Marek Vasut
Quoted 3 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Clock frequency info is required in U-boot.

I want a TB on Gen 5

This patch break the gen5, because cm_basic_init is exclusive for Arria
10. #ifdef is required.

Can you at least build-test your patches before submitting ? Heck, you can also set up the travisci [1] to do all that stuff for you.

[1] https://travis-ci.org/marex/u-boot-socfpga/branches

Signature · 2 lines
Best regards,
Marek Vasut
#81 lore raw

PATCH v2 17/19 arm: socfpga: Adding clock frequency info for U-boot

Quoted 14 lines · Marek Vasut
Quoted 13 lines · Tien Fong
Quoted 11 lines · Marek Vasut
Quoted 7 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Clock frequency info is required in U-boot.

I want a TB on Gen 5

Quoted 9 lines
Quoted 3 lines

This patch break the gen5, because cm_basic_init is exclusive for Arria
10. #ifdef is required.

Can you at least build-test your patches before submitting ? Heck, you can also set up the travisci [1] to do all that stuff for you.

[1] https://travis-ci.org/marex/u-boot-socfpga/branches

Okay.

#82 lore raw

PATCH v2 18/19 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        | 3 +++
 arch/arm/mach-socfpga/misc_arria10.c | 5 -----
 arch/arm/mach-socfpga/spl.c          | 6 ++++++
 3 files changed, 9 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/board.c +3 -0
index a00f63b..0fbad67 100644
@@ -32,6 +32,9 @@ int board_init(void)
 	/* configuring the clock based on handoff */
 	cm_basic_init(gd->fdt_blob);
 
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
+
 	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
#83 lore raw

PATCH v2 19/19 arm: socfpga: Enable SPL loading U-boot to DDR and booting U-boot

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

From: Tien Fong Chee <[email protected]>

Enable SPL loading U-boot from SDMMC to DDR and booting U-boot.

---
 arch/arm/mach-socfpga/spl.c       | 55 +++++++++++++++++++++++++++++++++++++
 common/spl/spl_mmc.c              |  2 +-
 configs/socfpga_arria10_defconfig | 57 ++++++++++++++++++++++++++++++++++-----
 include/spl.h                     |  2 ++
 4 files changed, 108 insertions(+), 8 deletions(-)
arch/arm/mach-socfpga/spl.c +55 -0
index aba116d..9b381bb 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/fpga_manager.h>
 #include <asm/arch/misc.h>
 #include <asm/arch/scan_manager.h>
 #include <asm/arch/sdram.h>
@@ -22,6 +23,10 @@
 #include <asm/arch/nic301.h>
 #include <asm/sections.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 +34,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 +205,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 +228,47 @@ void spl_board_init(void)
 
 	/* Add device descriptor to FPGA device table */
 	socfpga_fpga_add();
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		struct mmc *mmc = NULL;
+		int err = 0;
+
+		spl_mmc_find_device(&mmc, bootdev.boot_device);
+
+		err = mmc_init(mmc);
+
+		if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+			printf("spl: mmc init failed with error: %d\n", err);
+#endif
+		}
+
+		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd->fdt_blob,
+								 &len);
+
+		fpga_fsinfo.filename = (char *)get_cff_filename(gd->fdt_blob,
+								 &len,
+								PERIPH_RBF);
+
+		fpga_fsinfo.interface = "mmc";
+
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	} else {
+		printf("Invalid boot device!\n");
+		return;
+	}
+
+	/* Program peripheral RBF */
+	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len > 0))
+		rval = fpga_fsload(0, buffer, BSIZE, &fpga_fsinfo);
+
+	if (rval > 0) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}
 }
 
 void board_init_f(ulong dummy)
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;
configs/socfpga_arria10_defconfig +50 -7

83 lines not on this page · raw message

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
#84 lore raw

PATCH v2 19/19 arm: socfpga: Enable SPL loading U-boot to DDR and booting U-boot

Quoted 3 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable SPL loading U-boot from SDMMC to DDR and booting U-boot.

This patch seems to be doing more than just one thing ...

Quoted 224 lines
---
 arch/arm/mach-socfpga/spl.c       | 55 +++++++++++++++++++++++++++++++++++++
 common/spl/spl_mmc.c              |  2 +-
 configs/socfpga_arria10_defconfig | 57 ++++++++++++++++++++++++++++++++++-----
 include/spl.h                     |  2 ++
 4 files changed, 108 insertions(+), 8 deletions(-)
arch/arm/mach-socfpga/spl.c +55 -0
index aba116d..9b381bb 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/fpga_manager.h>
 #include <asm/arch/misc.h>
 #include <asm/arch/scan_manager.h>
 #include <asm/arch/sdram.h>
@@ -22,6 +23,10 @@
 #include <asm/arch/nic301.h>
 #include <asm/sections.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 +34,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 +205,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 +228,47 @@ void spl_board_init(void)
 
 	/* Add device descriptor to FPGA device table */
 	socfpga_fpga_add();
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		struct mmc *mmc = NULL;
+		int err = 0;
+
+		spl_mmc_find_device(&mmc, bootdev.boot_device);
+
+		err = mmc_init(mmc);
+
+		if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+			printf("spl: mmc init failed with error: %d\n", err);
+#endif
+		}
+
+		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd->fdt_blob,
+								 &len);
+
+		fpga_fsinfo.filename = (char *)get_cff_filename(gd->fdt_blob,
+								 &len,
+								PERIPH_RBF);
+
+		fpga_fsinfo.interface = "mmc";
+
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	} else {
+		printf("Invalid boot device!\n");
+		return;
+	}
+
+	/* Program peripheral RBF */
+	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len > 0))
+		rval = fpga_fsload(0, buffer, BSIZE, &fpga_fsinfo);
+
+	if (rval > 0) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}
 }
 
 void board_init_f(ulong dummy)
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;
configs/socfpga_arria10_defconfig +50 -7
index 4c73d73..2ff9801 100644
@@ -2,33 +2,76 @@ CONFIG_ARM=y
 CONFIG_ARCH_SOCFPGA=y
 CONFIG_SYS_MALLOC_F_LEN=0x2000
 CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y
+CONFIG_SPL_STACK_R_ADDR=0x00800000
 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_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_SPL_ENV_SUPPORT=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
 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_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_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_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
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 · 2 lines
Best regards,
Marek Vasut
#85 lore raw

PATCH v2 19/19 arm: socfpga: Enable SPL loading U-boot to DDR and booting U-boot

Quoted 7 lines · Marek Vasut
Quoted 4 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable SPL loading U-boot from SDMMC to DDR and booting U-boot.

This patch seems to be doing more than just one thing ...

I can split into two patches:
1) Enable DDR up by configuring FPGA so SPL able loading U-boot to DDR
2) Setting up configs so SPL can boot U-boot from FAT.

Quoted 241 lines
Quoted 240 lines

---
 arch/arm/mach-socfpga/spl.c       | 55
+++++++++++++++++++++++++++++++++++++
 common/spl/spl_mmc.c              |  2 +-
 configs/socfpga_arria10_defconfig | 57
++++++++++++++++++++++++++++++++++-----
 include/spl.h                     |  2 ++

 4 files changed, 108 insertions(+), 8 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/spl.c +0 -0

socfpga/spl.c
index aba116d..9b381bb 100644

arch/arm/mach-socfpga/spl.c +5 -0
@@ -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/fpga_manager.h>
  #include <asm/arch/misc.h>
  #include <asm/arch/scan_manager.h>
  #include <asm/arch/sdram.h>
@@ -22,6 +23,10 @@
  #include <asm/arch/nic301.h>
  #include <asm/sections.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 +34,9 @@


 DECLARE_GLOBAL_DATA_PTR;

arch/arm/mach-socfpga/spl.c +3 -0
+#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;

arch/arm/mach-socfpga/spl.c +6 -0
@@ -197,6 +205,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 +228,47 @@ void spl_board_init(void)


  /* Add device descriptor to FPGA device table */ socfpga_fpga_add();

arch/arm/mach-socfpga/spl.c +14 -0
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		struct mmc *mmc = NULL;
+		int err = 0;
+
+		spl_mmc_find_device(&mmc, bootdev.boot_device);
+
+		err = mmc_init(mmc);
+
+		if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+			printf("spl: mmc init failed with error:

%d\n", err);

arch/arm/mach-socfpga/spl.c +4 -0
+#endif
+		}
+
+		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd-
Quoted 1 line

fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								 &

len);

arch/arm/mach-socfpga/spl.c +2 -0
+
+		fpga_fsinfo.filename = (char

*)get_cff_filename(gd->fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								 &

len,

arch/arm/mach-socfpga/spl.c +1 -0
+								PE

RIPH_RBF);

arch/arm/mach-socfpga/spl.c +11 -0
+
+		fpga_fsinfo.interface = "mmc";
+
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	} else {
+		printf("Invalid boot device!\n");
+		return;
+	}
+
+	/* Program peripheral RBF */
+	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len >

0))

arch/arm/mach-socfpga/spl.c +1 -0
+		rval = fpga_fsload(0, buffer, BSIZE,

&fpga_fsinfo);

arch/arm/mach-socfpga/spl.c +6 -0
+
+	if (rval > 0) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}

 }

 void board_init_f(ulong dummy)

common/spl/spl_mmc.c +0 -0
index b2cccc6..159443f 100644
@@ -113,7 +113,7 @@ static int spl_mmc_get_device_index(u32
 boot_device)
  	return -ENODEV;
  }

common/spl/spl_mmc.c +1 -1
-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;

configs/socfpga_arria10_defconfig +0 -0
index 4c73d73..2ff9801 100644
@@ -2,33 +2,76 @@ CONFIG_ARM=y

 CONFIG_ARCH_SOCFPGA=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y +CONFIG_SPL_STACK_R_ADDR=0x00800000 CONFIG_IDENT_STRING="socfpga_arria10" CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyS0,115200"

 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"

configs/socfpga_arria10_defconfig +6 -0
+CONFIG_FIT=y
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_VERSION_VARIABLE=y

 CONFIG_SPL=y
+CONFIG_HUSH_PARSER=y
 CONFIG_SPL_FPGA_SUPPORT=y

configs/socfpga_arria10_defconfig +2 -0
+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

configs/socfpga_arria10_defconfig +2 -1
-CONFIG_CMD_GPIO=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_CMD_PART=y

 CONFIG_CMD_MMC=y

configs/socfpga_arria10_defconfig +9 -0
+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

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y

 CONFIG_DOS_PARTITION=y

configs/socfpga_arria10_defconfig +4 -2
-# 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

configs/socfpga_arria10_defconfig +7 -0
+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

configs/socfpga_arria10_defconfig +17 -0
+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
include/spl.h +1 -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

include/spl.h +1 -0
@@ -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

#86 lore raw

PATCH v2 19/19 arm: socfpga: Enable SPL loading U-boot to DDR and booting U-boot

Quoted 11 lines · Tien Fong
Quoted 7 lines · Marek Vasut
Quoted 4 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Enable SPL loading U-boot from SDMMC to DDR and booting U-boot.

This patch seems to be doing more than just one thing ...

I can split into two patches:
1) Enable DDR up by configuring FPGA so SPL able loading U-boot to DDR
2) Setting up configs so SPL can boot U-boot from FAT.

Split it so that one patch does one thing.

Quoted 240 lines
Quoted 240 lines
Quoted 240 lines

---
 arch/arm/mach-socfpga/spl.c       | 55
+++++++++++++++++++++++++++++++++++++
 common/spl/spl_mmc.c              |  2 +-
 configs/socfpga_arria10_defconfig | 57
++++++++++++++++++++++++++++++++++-----
 include/spl.h                     |  2 ++

 4 files changed, 108 insertions(+), 8 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/spl.c +0 -0

socfpga/spl.c
index aba116d..9b381bb 100644

arch/arm/mach-socfpga/spl.c +5 -0
@@ -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/fpga_manager.h>
  #include <asm/arch/misc.h>
  #include <asm/arch/scan_manager.h>
  #include <asm/arch/sdram.h>
@@ -22,6 +23,10 @@
  #include <asm/arch/nic301.h>
  #include <asm/sections.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 +34,9 @@


 DECLARE_GLOBAL_DATA_PTR;

arch/arm/mach-socfpga/spl.c +3 -0
+#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;

arch/arm/mach-socfpga/spl.c +6 -0
@@ -197,6 +205,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 +228,47 @@ void spl_board_init(void)


  /* Add device descriptor to FPGA device table */ socfpga_fpga_add();

arch/arm/mach-socfpga/spl.c +14 -0
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		struct mmc *mmc = NULL;
+		int err = 0;
+
+		spl_mmc_find_device(&mmc, bootdev.boot_device);
+
+		err = mmc_init(mmc);
+
+		if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+			printf("spl: mmc init failed with error:

%d\n", err);

arch/arm/mach-socfpga/spl.c +4 -0
+#endif
+		}
+
+		fpga_fsinfo.dev_part = (char *)get_cff_devpart(gd-
Quoted 1 line

fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								 &

len);

arch/arm/mach-socfpga/spl.c +2 -0
+
+		fpga_fsinfo.filename = (char

*)get_cff_filename(gd->fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								 &

len,

arch/arm/mach-socfpga/spl.c +1 -0
+								PE

RIPH_RBF);

arch/arm/mach-socfpga/spl.c +11 -0
+
+		fpga_fsinfo.interface = "mmc";
+
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	} else {
+		printf("Invalid boot device!\n");
+		return;
+	}
+
+	/* Program peripheral RBF */
+	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part && (len >

0))

arch/arm/mach-socfpga/spl.c +1 -0
+		rval = fpga_fsload(0, buffer, BSIZE,

&fpga_fsinfo);

arch/arm/mach-socfpga/spl.c +6 -0
+
+	if (rval > 0) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}

 }

 void board_init_f(ulong dummy)

common/spl/spl_mmc.c +0 -0
index b2cccc6..159443f 100644
@@ -113,7 +113,7 @@ static int spl_mmc_get_device_index(u32
 boot_device)
  	return -ENODEV;
  }

common/spl/spl_mmc.c +1 -1
-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;

configs/socfpga_arria10_defconfig +0 -0
index 4c73d73..2ff9801 100644
@@ -2,33 +2,76 @@ CONFIG_ARM=y

 CONFIG_ARCH_SOCFPGA=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y +CONFIG_SPL_STACK_R_ADDR=0x00800000 CONFIG_IDENT_STRING="socfpga_arria10" CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyS0,115200"

 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"

configs/socfpga_arria10_defconfig +6 -0
+CONFIG_FIT=y
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_VERSION_VARIABLE=y

 CONFIG_SPL=y
+CONFIG_HUSH_PARSER=y
 CONFIG_SPL_FPGA_SUPPORT=y

configs/socfpga_arria10_defconfig +2 -0
+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

configs/socfpga_arria10_defconfig +2 -1
-CONFIG_CMD_GPIO=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_CMD_PART=y

 CONFIG_CMD_MMC=y

configs/socfpga_arria10_defconfig +9 -0
+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

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y

 CONFIG_DOS_PARTITION=y

configs/socfpga_arria10_defconfig +4 -2
-# 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

configs/socfpga_arria10_defconfig +7 -0
+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

configs/socfpga_arria10_defconfig +17 -0
+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
include/spl.h +1 -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

include/spl.h +1 -0
@@ -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 · 2 lines
Best regards,
Marek Vasut
#87 lore raw

PATCH v2 19/19 arm: socfpga: Enable SPL loading U-boot to DDR and booting U-boot

Quoted 9 lines · Marek Vasut
Quoted 8 lines · Tien Fong
Quoted 6 lines · Marek Vasut
Quoted 4 lines · tien.fong.chee at intel.com

From: Tien Fong Chee <[email protected]>

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Enable SPL loading U-boot from SDMMC to DDR and booting U-boot.

This patch seems to be doing more than just one thing ...

I can split into two patches:
1) Enable DDR up by configuring FPGA so SPL able loading U-boot to DDR
2) Setting up configs so SPL can boot U-boot from FAT.

Split it so that one patch does one thing.

Okay.

Quoted 253 lines
Quoted 252 lines
Quoted 252 lines
Quoted 252 lines

---
 arch/arm/mach-socfpga/spl.c       | 55
+++++++++++++++++++++++++++++++++++++
 common/spl/spl_mmc.c              |  2 +-
 configs/socfpga_arria10_defconfig | 57
++++++++++++++++++++++++++++++++++-----
 include/spl.h                     |  2 ++

 4 files changed, 108 insertions(+), 8 deletions(-)
arch/arm/mach- renamed from arch/arm/mach-socfpga/spl.c +0 -0

socfpga/spl.c
index aba116d..9b381bb 100644

arch/arm/mach-socfpga/spl.c +5 -0
@@ -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/fpga_manager.h>
  #include <asm/arch/misc.h>
  #include <asm/arch/scan_manager.h>
  #include <asm/arch/sdram.h>
@@ -22,6 +23,10 @@
  #include <asm/arch/nic301.h>
  #include <asm/sections.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 +34,9 @@


 DECLARE_GLOBAL_DATA_PTR;

arch/arm/mach-socfpga/spl.c +3 -0
+#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;

arch/arm/mach-socfpga/spl.c +6 -0
@@ -197,6 +205,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 +228,47 @@ void spl_board_init(void)


  /* Add device descriptor to FPGA device table */ socfpga_fpga_add();

arch/arm/mach-socfpga/spl.c +8 -0
+
+	bootdev.boot_device = spl_boot_device();
+
+	if (BOOT_DEVICE_MMC1 == bootdev.boot_device) {
+		struct mmc *mmc = NULL;
+		int err = 0;
+
+		spl_mmc_find_device(&mmc,

bootdev.boot_device);

arch/arm/mach-socfpga/spl.c +6 -0
+
+		err = mmc_init(mmc);
+
+		if (err) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+			printf("spl: mmc init failed with

error:
%d\n", err);

arch/arm/mach-socfpga/spl.c +4 -0
+#endif
+		}
+
+		fpga_fsinfo.dev_part = (char

*)get_cff_devpart(gd-

Quoted 2 lines

fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								

 &
len);

arch/arm/mach-socfpga/spl.c +2 -0
+
+		fpga_fsinfo.filename = (char

*)get_cff_filename(gd->fdt_blob,

arch/arm/mach-socfpga/spl.c +1 -0
+								

 &
len,

arch/arm/mach-socfpga/spl.c +1 -0
+								

PE
RIPH_RBF);

arch/arm/mach-socfpga/spl.c +11 -0
+
+		fpga_fsinfo.interface = "mmc";
+
+		fpga_fsinfo.fstype = FS_TYPE_FAT;
+	} else {
+		printf("Invalid boot device!\n");
+		return;
+	}
+
+	/* Program peripheral RBF */
+	if (fpga_fsinfo.filename && fpga_fsinfo.dev_part &&

(len >
0))

arch/arm/mach-socfpga/spl.c +1 -0
+		rval = fpga_fsload(0, buffer, BSIZE,

&fpga_fsinfo);

arch/arm/mach-socfpga/spl.c +6 -0
+
+	if (rval > 0) {
+		config_pins(gd->fdt_blob, "shared");
+
+		ddr_calibration_sequence();
+	}

 }

 void board_init_f(ulong dummy)

common/spl/spl_mmc.c +0 -0
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;

configs/socfpga_arria10_defconfig +0 -0
index 4c73d73..2ff9801 100644
@@ -2,33 +2,76 @@ CONFIG_ARM=y

 CONFIG_ARCH_SOCFPGA=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y +CONFIG_SPL_STACK_R_ADDR=0x00800000 CONFIG_IDENT_STRING="socfpga_arria10" CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_USE_BOOTARGS=y
-CONFIG_BOOTARGS="console=ttyS0,115200"

 CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"

configs/socfpga_arria10_defconfig +6 -0
+CONFIG_FIT=y
+CONFIG_SYS_CONSOLE_IS_IN_ENV=y
+CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE=y
+CONFIG_SYS_CONSOLE_ENV_OVERWRITE=y
+CONFIG_SPL_ENV_SUPPORT=y
+CONFIG_VERSION_VARIABLE=y

 CONFIG_SPL=y
+CONFIG_HUSH_PARSER=y
 CONFIG_SPL_FPGA_SUPPORT=y

configs/socfpga_arria10_defconfig +2 -0
+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

configs/socfpga_arria10_defconfig +2 -1
-CONFIG_CMD_GPIO=y
+CONFIG_SPL_LIBDISK_SUPPORT=y
+CONFIG_CMD_PART=y

 CONFIG_CMD_MMC=y

configs/socfpga_arria10_defconfig +9 -0
+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

configs/socfpga_arria10_defconfig +0 -2
-CONFIG_CMD_EXT4=y
-CONFIG_CMD_EXT4_WRITE=y

 CONFIG_DOS_PARTITION=y

configs/socfpga_arria10_defconfig +4 -2
-# 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

configs/socfpga_arria10_defconfig +7 -0
+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

configs/socfpga_arria10_defconfig +17 -0
+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
include/spl.h +1 -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

include/spl.h +1 -0
@@ -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