Skip to contentSkip to conversation

Add Intel Agilex SoC support

PATCH Superseded Ley Foon Tan 3 participants 36 messages Oct 11, 2019 – Oct 25, 2019

Subsystems (6)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add Intel Agilex SoC support

This is 5th version of patchset to add Intel Agilex SoC[1] support. Most of changes are related to move CCU driver to DM, remove *_manager_s10.h and include *_manager_soc64.h directly. Detail changelog can find in commit message.

This patchset needs to apply after patchset in [2] for manager driver struct to defines conversion.

Patch status:
No change: Patch 1, 2, 9, 10, 13, 14, 15, 16
Have changes: Patch 3, 4, 5, 6, 7, 11, 17, 18, 19
New: Patch 8, 12

Intel Agilex SoC is with a 64-bit quad core ARM Cortex-A53 MPCore hard processor system (HPS). New IPs in Agilex are CCU, clock manager and SDRAM, other IPs have minor changes compared to Stratix 10.

Intel Agilex HPS TRM:
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/agilex/mnl-1100.pdf

v4->v5:
-------
- Move CCU driver to DM
- Remove system_manager_s10.h and use system_manager_soc64.h directly.
- Remove reset_manager_s10.h and use reset_manager_soc64.h directly.
- Separate patch to fix INTOSC clock to 400MHz. [Patch 8]

History:
---------
[v1]: https://patchwork.ozlabs.org/cover/1097830/
[v2]: https://patchwork.ozlabs.org/cover/1127440/
[v3]: https://patchwork.ozlabs.org/cover/1149863/
[v4]: https://patchwork.ozlabs.org/cover/1161483/

[1]: https://www.intel.com/content/www/us/en/products/programmable/fpga/agilex.html
[2]: https://patchwork.ozlabs.org/cover/1174347/

Ley Foon Tan (19):
arm: socfpga: agilex: Add base address for Intel Agilex SoC
arm: socfpga: Move firewall code to firewall file
arm: socfpga: Move Stratix10 and Agilex reset manager common code
arm: socfpga: agilex: Add reset manager support
arm: socfpga: Move Stratix10 and Agilex system manager common code
arm: socfpga: agilex: Add system manager support
arm: socfpga: Move Stratix10 and Agilex clock manager common code
arm: socfpga: Fix CLKMGR_INTOSC_HZ to 400MHz
clk: agilex: Add clock driver for Agilex
arm: socfpga: agilex: Add clock wrapper functions
cache: Add Arteris Ncore cache coherent unit driver
drivers: Enable cache driver build in SPL
arm: agilex: Add clock handoff offset for Agilex
ddr: altera: Restructure Stratix 10 SDRAM driver
ddr: altera: agilex: Add SDRAM driver for Agilex
board: intel: agilex: Add socdk board support for Intel Agilex SoC
arm: socfpga: agilex: Add SPL for Agilex SoC
arm: dts: agilex: Add base dtsi and devkit dts
arm: socfpga: agilex: Enable Agilex SoC build

 arch/arm/Kconfig                              |   4 +-
 arch/arm/dts/Makefile                         |   1 +
 arch/arm/dts/socfpga_agilex.dtsi              | 500 +++++++++++++++
 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi |  79 +++
 arch/arm/dts/socfpga_agilex_socdk.dts         | 136 ++++
 arch/arm/mach-socfpga/Kconfig                 |  16 +
 arch/arm/mach-socfpga/Makefile                |  17 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |  84 +++
 arch/arm/mach-socfpga/clock_manager_s10.c     |   2 +-
 .../mach-socfpga/{spl_s10.c => firewall.c}    | 122 +---
 .../mach-socfpga/include/mach/base_addr_s10.h |   4 +
 .../mach-socfpga/include/mach/clock_manager.h |   2 +
 .../include/mach/clock_manager_agilex.h       |  14 +
 .../include/mach/clock_manager_s10.h          |  16 +-
 .../include/mach/clock_manager_soc64.h        |  23 +
 .../mach/{firewall_s10.h => firewall.h}       |  10 +-
 .../mach-socfpga/include/mach/handoff_s10.h   |   9 +-
 .../mach-socfpga/include/mach/reset_manager.h |   5 +-
 .../include/mach/reset_manager_s10.h          |  95 ---
 .../include/mach/reset_manager_soc64.h        |  38 ++
 .../include/mach/system_manager.h             |   5 +-
 .../include/mach/system_manager_s10.h         | 124 ----
 .../include/mach/system_manager_soc64.h       | 123 ++++
 arch/arm/mach-socfpga/mailbox_s10.c           |   2 +-
 arch/arm/mach-socfpga/misc.c                  |   4 +
 arch/arm/mach-socfpga/misc_s10.c              |   4 +-
 arch/arm/mach-socfpga/reset_manager_s10.c     |  34 +-
 arch/arm/mach-socfpga/spl_agilex.c            |  98 +++
 arch/arm/mach-socfpga/spl_s10.c               |  95 +--
 arch/arm/mach-socfpga/system_manager_s10.c    |  26 +-
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |  13 +-
 board/intel/agilex-socdk/MAINTAINERS          |   7 +
 board/intel/agilex-socdk/Makefile             |   7 +
 board/intel/agilex-socdk/socfpga.c            |   7 +
 configs/socfpga_agilex_defconfig              |  59 ++
 drivers/Makefile                              |   1 +
 drivers/cache/Kconfig                         |   8 +
 drivers/cache/Makefile                        |   1 +
 drivers/cache/cache-ncore.c                   | 164 +++++
 drivers/clk/altera/Makefile                   |   1 +
 drivers/clk/altera/clk-agilex.c               | 579 ++++++++++++++++++
 drivers/clk/altera/clk-agilex.h               | 237 +++++++
 drivers/ddr/altera/Kconfig                    |   6 +-
 drivers/ddr/altera/Makefile                   |   3 +-
 drivers/ddr/altera/sdram_agilex.c             | 168 +++++
 drivers/ddr/altera/sdram_s10.c                | 298 +--------
 drivers/ddr/altera/sdram_s10.h                | 148 +----
 drivers/ddr/altera/sdram_soc64.c              | 304 +++++++++
 .../ddr/altera/{sdram_s10.h => sdram_soc64.h} |  71 ++-
 include/configs/socfpga_agilex_socdk.h        | 207 +++++++
 .../dt-bindings/clock/socfpga-soc64-clock.h   |  84 +++
 51 files changed, 3101 insertions(+), 964 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_agilex.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk.dts
 create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex.c
 copy arch/arm/mach-socfpga/{spl_s10.c => firewall.c} (54%)
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h
 rename arch/arm/mach-socfpga/include/mach/{firewall_s10.h => firewall.h} (94%)
 delete mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_soc64.h
 delete mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
 create mode 100644 arch/arm/mach-socfpga/spl_agilex.c
 create mode 100644 board/intel/agilex-socdk/MAINTAINERS
 create mode 100644 board/intel/agilex-socdk/Makefile
 create mode 100644 board/intel/agilex-socdk/socfpga.c
 create mode 100644 configs/socfpga_agilex_defconfig
 create mode 100644 drivers/cache/cache-ncore.c
 create mode 100644 drivers/clk/altera/clk-agilex.c
 create mode 100644 drivers/clk/altera/clk-agilex.h
 create mode 100644 drivers/ddr/altera/sdram_agilex.c
 create mode 100644 drivers/ddr/altera/sdram_soc64.c
 copy drivers/ddr/altera/{sdram_s10.h => sdram_soc64.h} (79%)
 create mode 100644 include/configs/socfpga_agilex_socdk.h
 create mode 100644 include/dt-bindings/clock/socfpga-soc64-clock.h
Signature · 1 line
2.19.0
#1 lore raw

PATCH v5 1/19 arm: socfpga: agilex: Add base address for Intel Agilex SoC

Add base address for Intel Agilex SoC.

Reuse base_addr_s10.h for Agilex, only one base address is different from S10.

---
v2:
- Reuse base_addr_s10.h and add #ifdef Agilex for SOCFPGA_FW_MPU_DDR_SCR_ADDRESS

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-socfpga/include/mach/base_addr_s10.h +4 -0
index 1f549d7e70..d3eca65e97 100644
@@ -10,7 +10,11 @@
 #define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xf8000400
 #define SOCFPGA_HMC_MMR_IO48_ADDRESS		0xf8010000
 #define SOCFPGA_SDR_ADDRESS			0xf8011000
+#ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+#define SOCFPGA_FW_MPU_DDR_SCR_ADDRESS		0xf8020200
+#else
 #define SOCFPGA_FW_MPU_DDR_SCR_ADDRESS		0xf8020100
+#endif
 #define SOCFPGA_SMMU_ADDRESS			0xfa000000
 #define SOCFPGA_MAILBOX_ADDRESS			0xffa30000
 #define SOCFPGA_UART0_ADDRESS			0xffc02000
Signature · 1 line
2.19.0
#2 lore raw

PATCH v5 2/19 arm: socfpga: Move firewall code to firewall file

In reply to Ley Foon Tan

Move firewall related code to new firewall.c, to share code in Stratix 10 and Agilex.

SDMMC will transfer data to OCRAM in SPL. So, enable privilege for SDMMC to allow DMA transfer to OCRAM.

---
v4:
- Move SYSMGR_DMA* to firewall.c

v3:
- Move SOCFPGA_FIREWALL_TCU to firewall.c

---
 arch/arm/mach-socfpga/Makefile                |   1 +
 .../mach-socfpga/{spl_s10.c => firewall.c}    | 120 +++---------------
 .../mach/{firewall_s10.h => firewall.h}       |  10 +-
 arch/arm/mach-socfpga/spl_s10.c               |  93 +-------------
 drivers/ddr/altera/sdram_s10.c                |   2 +-
 5 files changed, 26 insertions(+), 200 deletions(-)
 copy arch/arm/mach-socfpga/{spl_s10.c => firewall.c} (56%)
 rename arch/arm/mach-socfpga/include/mach/{firewall_s10.h => firewall.h} (94%)
arch/arm/mach-socfpga/Makefile +1 -0
index fc1181cb27..dab34d0ef2 100644
@@ -51,6 +51,7 @@ ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
 obj-y	+= spl_a10.o
 endif
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y	+= firewall.o
 obj-y	+= spl_s10.o
 endif
 endif
arch/arm/mach-socfpga/firewall.c renamed from arch/arm/mach-socfpga/spl_s10.c +16 -104

151 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/firewall.h renamed from arch/arm/mach-socfpga/include/mach/firewall_s10.h +6 -4
similarity index 94%
rename from arch/arm/mach-socfpga/include/mach/firewall_s10.h
rename to arch/arm/mach-socfpga/include/mach/firewall.h
index b96f779f14..516bd1c0e1 100644
@@ -1,11 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0
  *
- * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2017-2019 Intel Corporation <www.intel.com>
  *
  */
 
-#ifndef	_FIREWALL_S10_
-#define	_FIREWALL_S10_
+#ifndef	_FIREWALL_H_
+#define	_FIREWALL_H_
 
 struct socfpga_firwall_l4_per {
 	u32	nand;		/* 0x00 */
@@ -117,4 +117,6 @@ struct socfpga_firwall_l4_sys {
 #define FW_MPU_DDR_SCR_WRITEL(data, reg)		\
 	writel(data, SOCFPGA_FW_MPU_DDR_SCR_ADDRESS + (reg))
 
-#endif /* _FIREWALL_S10_ */
+void firewall_setup(void);
+
+#endif /* _FIREWALL_H_ */
arch/arm/mach-socfpga/spl_s10.c +2 -91

111 lines not on this page · raw message

drivers/ddr/altera/sdram_s10.c +1 -1
index d5812f2fd7..8948c31f45 100644
@@ -13,7 +13,7 @@
 #include <reset.h>
 #include "sdram_s10.h"
 #include <wait_bit.h>
-#include <asm/arch/firewall_s10.h>
+#include <asm/arch/firewall.h>
 #include <asm/arch/system_manager.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/io.h>
Signature · 1 line
2.19.0
#3 lore raw

PATCH v5 3/19 arm: socfpga: Move Stratix10 and Agilex reset manager common code

In reply to Ley Foon Tan

Move Stratix10 and Agilex reset manager common code to reset_manager_soc64.h. Changed macros to RSTMGR_SOC64_*.

Remove unused RSTMGR_XXX defines.

---
v5:
- Remove reset_manager_s10.h and use reset_manager_soc64.h directly.

v4:
- Change prefix from RSTMGR_S10* to RSTMGR_SOC64*.

v3:
- Add new reset_manager_soc64.h
- Convert to use defines instead of struct.

---
 .../mach-socfpga/include/mach/reset_manager.h |  2 +-
 .../include/mach/reset_manager_s10.h          | 95 -------------------
 .../include/mach/reset_manager_soc64.h        | 38 ++++++++
 arch/arm/mach-socfpga/reset_manager_s10.c     | 20 ++--
 4 files changed, 49 insertions(+), 106 deletions(-)
 delete mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_soc64.h
arch/arm/mach-socfpga/include/mach/reset_manager.h +1 -1
index a5b6931350..b077b077f8 100644
@@ -44,7 +44,7 @@ void socfpga_per_reset_all(void);
 #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 #include <asm/arch/reset_manager_arria10.h>
 #elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-#include <asm/arch/reset_manager_s10.h>
+#include <asm/arch/reset_manager_soc64.h>
 #endif
 
 #endif /* _RESET_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_s10.h deleted +0 -95

95 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/reset_manager_soc64.h new file +38 -0
new file mode 100644
index 0000000000..3b739a0202
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ *  Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ */
+
+#ifndef _RESET_MANAGER_SOC64_H_
+#define _RESET_MANAGER_SOC64_H_
+
+void reset_deassert_peripherals_handoff(void);
+int cpu_has_been_warmreset(void);
+void socfpga_bridges_reset(int enable);
+
+#define RSTMGR_SOC64_STATUS		0
+#define RSTMGR_SOC64_MPUMODRST	0x20
+#define RSTMGR_SOC64_PER0MODRST	0x24
+#define RSTMGR_SOC64_PER1MODRST	0x28
+#define RSTMGR_SOC64_BRGMODRST	0x2c
+
+#define RSTMGR_MPUMODRST_CORE0		0
+#define RSTMGR_PER0MODRST_OCP_MASK	0x0020bf00
+#define RSTMGR_BRGMODRST_DDRSCH_MASK	0X00000040
+#define RSTMGR_BRGMODRST_FPGA2SOC_MASK	0x00000004
+
+/* Watchdogs and MPU warm reset mask */
+#define RSTMGR_L4WD_MPU_WARMRESET_MASK	0x000F0F00
+
+/*
+ * SocFPGA Stratix10 reset IDs, bank mapping is as follows:
+ * 0 ... mpumodrst
+ * 1 ... per0modrst
+ * 2 ... per1modrst
+ * 3 ... brgmodrst
+ */
+#define RSTMGR_L4WD0		RSTMGR_DEFINE(2, 0)
+#define RSTMGR_OSC1TIMER0	RSTMGR_DEFINE(2, 4)
+#define RSTMGR_UART0		RSTMGR_DEFINE(2, 16)
+
+#endif /* _RESET_MANAGER_SOC64_H_ */
arch/arm/mach-socfpga/reset_manager_s10.c +10 -10
index 50a2d80930..bdc0f3ee6e 100644
@@ -18,13 +18,13 @@ void socfpga_per_reset(u32 reset, int set)
 	unsigned long reg;
 
 	if (RSTMGR_BANK(reset) == 0)
-		reg = RSTMGR_S10_MPUMODRST;
+		reg = RSTMGR_SOC64_MPUMODRST;
 	else if (RSTMGR_BANK(reset) == 1)
-		reg = RSTMGR_S10_PER0MODRST;
+		reg = RSTMGR_SOC64_PER0MODRST;
 	else if (RSTMGR_BANK(reset) == 2)
-		reg = RSTMGR_S10_PER1MODRST;
+		reg = RSTMGR_SOC64_PER1MODRST;
 	else if (RSTMGR_BANK(reset) == 3)
-		reg = RSTMGR_S10_BRGMODRST;
+		reg = RSTMGR_SOC64_BRGMODRST;
 	else	/* Invalid reset register, do nothing */
 		return;
 
@@ -47,9 +47,9 @@ void socfpga_per_reset_all(void)
 
 	/* disable all except OCP and l4wd0. OCP disable later */
 	writel(~(l4wd0 | RSTMGR_PER0MODRST_OCP_MASK),
-		      socfpga_rstmgr_base + RSTMGR_S10_PER0MODRST);
-	writel(~l4wd0, socfpga_rstmgr_base + RSTMGR_S10_PER0MODRST);
-	writel(0xffffffff, socfpga_rstmgr_base + RSTMGR_S10_PER1MODRST);
+		      socfpga_rstmgr_base + RSTMGR_SOC64_PER0MODRST);
+	writel(~l4wd0, socfpga_rstmgr_base + RSTMGR_SOC64_PER0MODRST);
+	writel(0xffffffff, socfpga_rstmgr_base + RSTMGR_SOC64_PER1MODRST);
 }
 
 void socfpga_bridges_reset(int enable)
@@ -60,7 +60,7 @@ void socfpga_bridges_reset(int enable)
 			     ~0);
 
 		/* Release all bridges from reset state */
-		clrbits_le32(socfpga_rstmgr_base + RSTMGR_S10_BRGMODRST, ~0);
+		clrbits_le32(socfpga_rstmgr_base + RSTMGR_SOC64_BRGMODRST, ~0);
 
 		/* Poll until all idleack to 0 */
 		while (readl(socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLEACK))
@@ -83,7 +83,7 @@ void socfpga_bridges_reset(int enable)
 			;
 
 		/* Reset all bridges (except NOR DDR scheduler & F2S) */
-		setbits_le32(socfpga_rstmgr_base + RSTMGR_S10_BRGMODRST,
+		setbits_le32(socfpga_rstmgr_base + RSTMGR_SOC64_BRGMODRST,
 			     ~(RSTMGR_BRGMODRST_DDRSCH_MASK |
 			       RSTMGR_BRGMODRST_FPGA2SOC_MASK));
 
@@ -97,6 +97,6 @@ void socfpga_bridges_reset(int enable)
  */
 int cpu_has_been_warmreset(void)
 {
-	return readl(socfpga_rstmgr_base + RSTMGR_S10_STATUS) &
+	return readl(socfpga_rstmgr_base + RSTMGR_SOC64_STATUS) &
 			RSTMGR_L4WD_MPU_WARMRESET_MASK;
 }
Signature · 1 line
2.19.0
#4 lore raw

PATCH v5 4/19 arm: socfpga: agilex: Add reset manager support

In reply to Ley Foon Tan

Add reset manager support for Agilex.

---
v5:
- Remove reset_reset_manager_agilex.h and use reset_manager_soc64.h.

v3:
- Add reset_manager_soc64.h
- Convert to use defines instead of struct.

---
 arch/arm/mach-socfpga/include/mach/reset_manager.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -1
index b077b077f8..2c83563d5e 100644
@@ -43,7 +43,8 @@ void socfpga_per_reset_all(void);
 #include <asm/arch/reset_manager_gen5.h>
 #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 #include <asm/arch/reset_manager_arria10.h>
-#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
+	defined(CONFIG_TARGET_SOCFPGA_AGILEX)
 #include <asm/arch/reset_manager_soc64.h>
 #endif
 
Signature · 1 line
2.19.0
#5 lore raw

PATCH v5 4/19 arm: socfpga: agilex: Add reset manager support

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 3 lines

Add reset manager support for Agilex.

Quoted 27 lines

---
v5:
- Remove reset_reset_manager_agilex.h and use reset_manager_soc64.h.

v3:
- Add reset_manager_soc64.h
- Convert to use defines instead of struct.

---
  arch/arm/mach-socfpga/include/mach/reset_manager.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -1
index b077b077f8..2c83563d5e 100644
@@ -43,7 +43,8 @@ void socfpga_per_reset_all(void);
  #include <asm/arch/reset_manager_gen5.h>
  #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
  #include <asm/arch/reset_manager_arria10.h>
-#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
+	defined(CONFIG_TARGET_SOCFPGA_AGILEX)
  #include <asm/arch/reset_manager_soc64.h>
  #endif
 
#6 lore raw

PATCH v5 5/19 arm: socfpga: Move Stratix10 and Agilex system manager common code

In reply to Ley Foon Tan

Move Stratix10 and Agilex system manager common code to system_manager_soc64.h. Changed macros to use SYSMGR_SOC64_*.

---
v5:
- Remove system_manager_s10.h and use system_manager_soc64.h.

v4:
- Change prefix from SYSMGR_S10* to SYSMGR_SOC64*.

v3:
- Change filename to system_manager_soc64.h
- Move to use defines instead of struct.

v2:
- Move common defines for Stratix 10 and Agilex to system_manager_s10_agilex_common.h

---
 arch/arm/mach-socfpga/clock_manager_s10.c     |   2 +-
 arch/arm/mach-socfpga/firewall.c              |   4 +-
 .../include/mach/system_manager.h             |   2 +-
 .../include/mach/system_manager_s10.h         | 124 ------------------
 .../include/mach/system_manager_soc64.h       | 123 +++++++++++++++++
 arch/arm/mach-socfpga/mailbox_s10.c           |   2 +-
 arch/arm/mach-socfpga/misc_s10.c              |   4 +-
 arch/arm/mach-socfpga/reset_manager_s10.c     |  14 +-
 arch/arm/mach-socfpga/spl_s10.c               |   2 +-
 arch/arm/mach-socfpga/system_manager_s10.c    |  26 ++--
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |   8 +-
 drivers/ddr/altera/sdram_s10.c                |   2 +-
 12 files changed, 156 insertions(+), 157 deletions(-)
 delete mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
arch/arm/mach-socfpga/clock_manager_s10.c +1 -1
index c6269701f0..bae07e02b6 100644
@@ -382,7 +382,7 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 
 unsigned int cm_get_qspi_controller_clk_hz(void)
 {
-	return readl(socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD0);
+	return readl(socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
 }
 
 unsigned int cm_get_spi_controller_clk_hz(void)
arch/arm/mach-socfpga/firewall.c +2 -2
index 7c9d317896..c32a7c84b5 100644
@@ -101,7 +101,7 @@ void firewall_setup(void)
 
 	/* enable non-secure interface to DMA330 DMA and peripherals */
 	writel(SYSMGR_DMA_IRQ_NS | SYSMGR_DMA_MGR_NS,
-	       socfpga_sysmgr_base + SYSMGR_S10_DMA);
+	       socfpga_sysmgr_base + SYSMGR_SOC64_DMA);
 	writel(SYSMGR_DMAPERIPH_ALL_NS,
-	       socfpga_sysmgr_base + SYSMGR_S10_DMA_PERIPH);
+	       socfpga_sysmgr_base + SYSMGR_SOC64_DMA_PERIPH);
 }
arch/arm/mach-socfpga/include/mach/system_manager.h +1 -1
index 803305eb35..7ab66e7fc9 100644
@@ -9,7 +9,7 @@
 extern phys_addr_t socfpga_sysmgr_base;
 
 #if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
-#include <asm/arch/system_manager_s10.h>
+#include <asm/arch/system_manager_soc64.h>
 #else
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	BIT(1)
arch/arm/mach-socfpga/include/mach/system_manager_s10.h deleted +0 -124

124 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_soc64.h new file +123 -0

123 lines not on this page · raw message

arch/arm/mach-socfpga/mailbox_s10.c +1 -1
index 11b57361c7..ba81461f90 100644
@@ -316,7 +316,7 @@ int mbox_qspi_open(void)
 	/* We are getting QSPI ref clock and set into sysmgr boot register */
 	printf("QSPI: Reference clock at %d Hz\n", resp_buf[0]);
 	writel(resp_buf[0],
-	       socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD0);
+	       socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD0);
 
 	return 0;
 
arch/arm/mach-socfpga/misc_s10.c +2 -2
index 16fbf71599..ba95ab566b 100644
@@ -65,8 +65,8 @@ static u32 socfpga_phymode_setup(u32 gmac_index, const char *phymode)
 	else
 		return -EINVAL;
 
-	clrsetbits_le32((unsigned long)(socfpga_sysmgr_base + SYSMGR_S10_EMAC0 +
-			gmac_index),
+	clrsetbits_le32((unsigned long)(socfpga_sysmgr_base +
+			SYSMGR_SOC64_EMAC0 + gmac_index),
 			SYSMGR_EMACGRP_CTRL_PHYSEL_MASK, modereg);
 
 	return 0;
arch/arm/mach-socfpga/reset_manager_s10.c +7 -7
index bdc0f3ee6e..938999043e 100644
@@ -56,29 +56,29 @@ void socfpga_bridges_reset(int enable)
 {
 	if (enable) {
 		/* clear idle request to all bridges */
-		setbits_le32(socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLEREQ_CLR,
+		setbits_le32(socfpga_sysmgr_base + SYSMGR_SOC64_NOC_IDLEREQ_CLR,
 			     ~0);
 
 		/* Release all bridges from reset state */
 		clrbits_le32(socfpga_rstmgr_base + RSTMGR_SOC64_BRGMODRST, ~0);
 
 		/* Poll until all idleack to 0 */
-		while (readl(socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLEACK))
+		while (readl(socfpga_sysmgr_base + SYSMGR_SOC64_NOC_IDLEACK))
 			;
 	} else {
 		/* set idle request to all bridges */
-		writel(~0, socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLEREQ_SET);
+		writel(~0, socfpga_sysmgr_base + SYSMGR_SOC64_NOC_IDLEREQ_SET);
 
 		/* Enable the NOC timeout */
-		writel(1, socfpga_sysmgr_base + SYSMGR_S10_NOC_TIMEOUT);
+		writel(1, socfpga_sysmgr_base + SYSMGR_SOC64_NOC_TIMEOUT);
 
 		/* Poll until all idleack to 1 */
-		while ((readl(socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLEACK) ^
+		while ((readl(socfpga_sysmgr_base + SYSMGR_SOC64_NOC_IDLEACK) ^
 			(SYSMGR_NOC_H2F_MSK | SYSMGR_NOC_LWH2F_MSK)))
 			;
 
 		/* Poll until all idlestatus to 1 */
-		while ((readl(socfpga_sysmgr_base + SYSMGR_S10_NOC_IDLESTATUS) ^
+		while ((readl(socfpga_sysmgr_base + SYSMGR_SOC64_NOC_IDLESTATUS) ^
 			(SYSMGR_NOC_H2F_MSK | SYSMGR_NOC_LWH2F_MSK)))
 			;
 
@@ -88,7 +88,7 @@ void socfpga_bridges_reset(int enable)
 			       RSTMGR_BRGMODRST_FPGA2SOC_MASK));
 
 		/* Disable NOC timeout */
-		writel(0, socfpga_sysmgr_base + SYSMGR_S10_NOC_TIMEOUT);
+		writel(0, socfpga_sysmgr_base + SYSMGR_SOC64_NOC_TIMEOUT);
 	}
 }
 
arch/arm/mach-socfpga/spl_s10.c +1 -1
index cdfbd06327..fabedba6d1 100644
@@ -53,7 +53,7 @@ void board_init_f(ulong dummy)
 #ifdef CONFIG_HW_WATCHDOG
 	/* Ensure watchdog is paused when debugging is happening */
 	writel(SYSMGR_WDDBG_PAUSE_ALL_CPU,
-	       socfpga_sysmgr_base + SYSMGR_S10_WDDBG);
+	       socfpga_sysmgr_base + SYSMGR_SOC64_WDDBG);
 
 	/* Enable watchdog before initializing the HW */
 	socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
arch/arm/mach-socfpga/system_manager_s10.c +13 -13
index c046bb17c9..0da9431517 100644
@@ -29,31 +29,31 @@ void populate_sysmgr_fpgaintf_module(void)
 	u32 handoff_val = 0;
 
 	/* Enable the signal for those HPS peripherals that use FPGA. */
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_NAND_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_NAND_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_NAND;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_SDMMC_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_SDMMC_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SDMMC;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_SPIM0_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_SPIM0_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SPIM0;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_SPIM1_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_SPIM1_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_SPIM1;
-	writel(handoff_val, socfpga_sysmgr_base + SYSMGR_S10_FPGAINTF_EN2);
+	writel(handoff_val, socfpga_sysmgr_base + SYSMGR_SOC64_FPGAINTF_EN2);
 
 	handoff_val = 0;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_EMAC0_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_EMAC0_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC0;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_EMAC1_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_EMAC1_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC1;
-	if (readl(socfpga_sysmgr_base + SYSMGR_S10_EMAC2_USEFPGA) ==
+	if (readl(socfpga_sysmgr_base + SYSMGR_SOC64_EMAC2_USEFPGA) ==
 	    SYSMGR_FPGAINTF_USEFPGA)
 		handoff_val |= SYSMGR_FPGAINTF_EMAC2;
-	writel(handoff_val, socfpga_sysmgr_base + SYSMGR_S10_FPGAINTF_EN3);
+	writel(handoff_val, socfpga_sysmgr_base + SYSMGR_SOC64_FPGAINTF_EN3);
 }
 
 /*
@@ -69,7 +69,7 @@ void populate_sysmgr_pinmux(void)
 	for (i = 0; i < len; i = i + 2) {
 		writel(sys_mgr_table_u32[i + 1],
 		       sys_mgr_table_u32[i] +
-		       (u8 *)socfpga_sysmgr_base + SYSMGR_S10_PINSEL0);
+		       (u8 *)socfpga_sysmgr_base + SYSMGR_SOC64_PINSEL0);
 	}
 
 	/* setup the pin ctrl */
@@ -77,7 +77,7 @@ void populate_sysmgr_pinmux(void)
 	for (i = 0; i < len; i = i + 2) {
 		writel(sys_mgr_table_u32[i + 1],
 		       sys_mgr_table_u32[i] +
-		       (u8 *)socfpga_sysmgr_base + SYSMGR_S10_IOCTRL0);
+		       (u8 *)socfpga_sysmgr_base + SYSMGR_SOC64_IOCTRL0);
 	}
 
 	/* setup the fpga use */
@@ -85,7 +85,7 @@ void populate_sysmgr_pinmux(void)
 	for (i = 0; i < len; i = i + 2) {
 		writel(sys_mgr_table_u32[i + 1],
 		       sys_mgr_table_u32[i] +
-		       (u8 *)socfpga_sysmgr_base + SYSMGR_S10_EMAC0_USEFPGA);
+		       (u8 *)socfpga_sysmgr_base + SYSMGR_SOC64_EMAC0_USEFPGA);
 	}
 
 	/* setup the IO delay */
@@ -93,6 +93,6 @@ void populate_sysmgr_pinmux(void)
 	for (i = 0; i < len; i = i + 2) {
 		writel(sys_mgr_table_u32[i + 1],
 		       sys_mgr_table_u32[i] +
-		       (u8 *)socfpga_sysmgr_base + SYSMGR_S10_IODELAY0);
+		       (u8 *)socfpga_sysmgr_base + SYSMGR_SOC64_IODELAY0);
 	}
 }
arch/arm/mach-socfpga/wrap_pll_config_s10.c +4 -4
index c9570fea38..b002f38215 100644
@@ -35,9 +35,9 @@ const unsigned int cm_get_osc_clk_hz(void)
 #ifdef CONFIG_SPL_BUILD
 	u32 clock = readl(S10_HANDOFF_CLOCK_OSC);
 
-	writel(clock, socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD1);
+	writel(clock, socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD1);
 #endif
-	return readl(socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD1);
+	return readl(socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD1);
 }
 
 const unsigned int cm_get_intosc_clk_hz(void)
@@ -50,7 +50,7 @@ const unsigned int cm_get_fpga_clk_hz(void)
 #ifdef CONFIG_SPL_BUILD
 	u32 clock = readl(S10_HANDOFF_CLOCK_FPGA);
 
-	writel(clock, socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD2);
+	writel(clock, socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD2);
 #endif
-	return readl(socfpga_sysmgr_base + SYSMGR_S10_BOOT_SCRATCH_COLD2);
+	return readl(socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD2);
 }
drivers/ddr/altera/sdram_s10.c +1 -1
index 8948c31f45..9578aa743d 100644
@@ -148,7 +148,7 @@ static int emif_reset(struct altera_sdram_platdata *plat)
 static int poll_hmc_clock_status(void)
 {
 	return wait_for_bit_le32((const void *)(socfpga_sysmgr_base +
-				 SYSMGR_S10_HMC_CLK),
+				 SYSMGR_SOC64_HMC_CLK),
 				 SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
 }
 
Signature · 1 line
2.19.0
#7 lore raw

PATCH v5 6/19 arm: socfpga: agilex: Add system manager support

In reply to Ley Foon Tan

Add system manager support for Agilex.

---
v5:
- Remove system_manager_agilex.h and use system_manager_soc64.h directly.

v3:
- Change include filename to system_manager_soc64.h.
- Move to use defines instead of struct.

v2:
- Include system_manager_s10_agilex_common.h in system_manager_agilex.h

---
 arch/arm/mach-socfpga/include/mach/system_manager.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/system_manager.h +2 -1
index 7ab66e7fc9..a201dec274 100644
@@ -8,7 +8,8 @@
 
 extern phys_addr_t socfpga_sysmgr_base;
 
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
+	defined(CONFIG_TARGET_SOCFPGA_AGILEX)
 #include <asm/arch/system_manager_soc64.h>
 #else
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
Signature · 1 line
2.19.0
#8 lore raw

PATCH v5 6/19 arm: socfpga: agilex: Add system manager support

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 3 lines

Add system manager support for Agilex.

Quoted 30 lines

---
v5:
- Remove system_manager_agilex.h and use system_manager_soc64.h directly.

v3:
- Change include filename to system_manager_soc64.h.
- Move to use defines instead of struct.

v2:
- Include system_manager_s10_agilex_common.h in system_manager_agilex.h

---
  arch/arm/mach-socfpga/include/mach/system_manager.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/system_manager.h +2 -1
index 7ab66e7fc9..a201dec274 100644
@@ -8,7 +8,8 @@
 
  extern phys_addr_t socfpga_sysmgr_base;
 
-#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
+	defined(CONFIG_TARGET_SOCFPGA_AGILEX)
  #include <asm/arch/system_manager_soc64.h>
  #else
  #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
#9 lore raw

PATCH v5 7/19 arm: socfpga: Move Stratix10 and Agilex clock manager common code

In reply to Ley Foon Tan

Move Stratix10 and Agilex clock manager common code to new header file.

---
v5:
- Revert CLKMGR_INTOSC_HZ to 460MHz.

---
 .../include/mach/clock_manager_s10.h          | 16 +++----------
 .../include/mach/clock_manager_soc64.h        | 23 +++++++++++++++++++
 2 files changed, 26 insertions(+), 13 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +3 -13
index fa0ba26f09..223940ba0c 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0
  *
- * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
  *
  */
 
@@ -14,18 +14,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
 unsigned int cm_get_mmc_controller_clk_hz(void);
 unsigned int cm_get_qspi_controller_clk_hz(void);
 unsigned int cm_get_spi_controller_clk_hz(void);
-const unsigned int cm_get_osc_clk_hz(void);
-const unsigned int cm_get_f2s_per_ref_clk_hz(void);
-const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
-const unsigned int cm_get_intosc_clk_hz(void);
-const unsigned int cm_get_fpga_clk_hz(void);
-
-#define CLKMGR_EOSC1_HZ		25000000
-#define CLKMGR_INTOSC_HZ	460000000
-#define CLKMGR_FPGA_CLK_HZ	50000000
-
-/* Clock configuration accessors */
-const struct cm_config * const cm_get_default_config(void);
 
 struct cm_config {
 	/* main group */
@@ -186,4 +174,6 @@ void cm_basic_init(const struct cm_config * const cfg);
 
 #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK		0x00000020
 
+#include <asm/arch/clock_manager_soc64.h>
+
 #endif /* _CLOCK_MANAGER_S10_ */
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h new file +23 -0
new file mode 100644
index 0000000000..3b4bb62ca5
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _CLOCK_MANAGER_SOC64_
+#define _CLOCK_MANAGER_SOC64_
+
+const unsigned int cm_get_osc_clk_hz(void);
+const unsigned int cm_get_f2s_per_ref_clk_hz(void);
+const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
+const unsigned int cm_get_intosc_clk_hz(void);
+const unsigned int cm_get_fpga_clk_hz(void);
+
+#define CLKMGR_EOSC1_HZ		25000000
+#define CLKMGR_INTOSC_HZ	460000000
+#define CLKMGR_FPGA_CLK_HZ	50000000
+
+/* Clock configuration accessors */
+const struct cm_config * const cm_get_default_config(void);
+
+#endif /* _CLOCK_MANAGER_SOC64_ */
Signature · 1 line
2.19.0
#10 lore raw

PATCH v5 7/19 arm: socfpga: Move Stratix10 and Agilex clock manager common code

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 45 lines

Move Stratix10 and Agilex clock manager common code to new header file.

---
v5:
- Revert CLKMGR_INTOSC_HZ to 460MHz.

---
  .../include/mach/clock_manager_s10.h          | 16 +++----------
  .../include/mach/clock_manager_soc64.h        | 23 +++++++++++++++++++
  2 files changed, 26 insertions(+), 13 deletions(-)

create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h

arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -13
index fa0ba26f09..223940ba0c 100644
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0
   *
- * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
   *
   */
 
@@ -14,18 +14,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
  unsigned int cm_get_mmc_controller_clk_hz(void);
  unsigned int cm_get_qspi_controller_clk_hz(void);
  unsigned int cm_get_spi_controller_clk_hz(void);
-const unsigned int cm_get_osc_clk_hz(void);
-const unsigned int cm_get_f2s_per_ref_clk_hz(void);
-const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
-const unsigned int cm_get_intosc_clk_hz(void);
-const unsigned int cm_get_fpga_clk_hz(void);
-
-#define CLKMGR_EOSC1_HZ		25000000
-#define CLKMGR_INTOSC_HZ	460000000
-#define CLKMGR_FPGA_CLK_HZ	50000000
-
-/* Clock configuration accessors */
-const struct cm_config * const cm_get_default_config(void);
 
  struct cm_config {
  	/* main group */

arch/arm/mach-socfpga/include/mach/clock_manager_s10.h void cm_basic_init(const struct cm_config * const cfg); · line 177

Quoted 4 lines
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -0
@@ -186,4 +174,6 @@ void cm_basic_init(const struct cm_config * const cfg);
 
  #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK		0x00000020
 
+#include <asm/arch/clock_manager_soc64.h>

Includes are normally at the top, what prevents you from moving this up?

Quoted 32 lines
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -0
+
  #endif /* _CLOCK_MANAGER_S10_ */
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h new file +23 -0
new file mode 100644
index 0000000000..3b4bb62ca5
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _CLOCK_MANAGER_SOC64_
+#define _CLOCK_MANAGER_SOC64_
+
+const unsigned int cm_get_osc_clk_hz(void);
+const unsigned int cm_get_f2s_per_ref_clk_hz(void);
+const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
+const unsigned int cm_get_intosc_clk_hz(void);
+const unsigned int cm_get_fpga_clk_hz(void);
+
+#define CLKMGR_EOSC1_HZ		25000000
+#define CLKMGR_INTOSC_HZ	460000000
+#define CLKMGR_FPGA_CLK_HZ	50000000
+
+/* Clock configuration accessors */
+const struct cm_config * const cm_get_default_config(void);
+
+#endif /* _CLOCK_MANAGER_SOC64_ */
#11 lore raw

PATCH v5 7/19 arm: socfpga: Move Stratix10 and Agilex clock manager common code

Quoted 48 lines · Simon Goldschmidt

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 46 lines

Move Stratix10 and Agilex clock manager common code to new header file.

---
v5:
- Revert CLKMGR_INTOSC_HZ to 460MHz.

---
  .../include/mach/clock_manager_s10.h          | 16 +++----------
  .../include/mach/clock_manager_soc64.h        | 23 +++++++++++++++++++
  2 files changed, 26 insertions(+), 13 deletions(-)

create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h

arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -13
index fa0ba26f09..223940ba0c 100644
@@ -1,6 +1,6 @@
  /* SPDX-License-Identifier: GPL-2.0
   *
- * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
   *
   */
 
@@ -14,18 +14,6 @@ unsigned int cm_get_l4_sp_clk_hz(void);
  unsigned int cm_get_mmc_controller_clk_hz(void);
  unsigned int cm_get_qspi_controller_clk_hz(void);
  unsigned int cm_get_spi_controller_clk_hz(void);
-const unsigned int cm_get_osc_clk_hz(void);
-const unsigned int cm_get_f2s_per_ref_clk_hz(void);
-const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
-const unsigned int cm_get_intosc_clk_hz(void);
-const unsigned int cm_get_fpga_clk_hz(void);
-
-#define CLKMGR_EOSC1_HZ              25000000
-#define CLKMGR_INTOSC_HZ     460000000
-#define CLKMGR_FPGA_CLK_HZ   50000000
-
-/* Clock configuration accessors */
-const struct cm_config * const cm_get_default_config(void);
 
  struct cm_config {
      /* main group */
@@ -186,4 +174,6 @@ void cm_basic_init(const struct cm_config * const cfg);
 
Quoted 5 lines

arch/arm/mach-socfpga/include/mach/clock_manager_s10.h void cm_basic_init(const struct cm_config * const cfg); · line 177

Quoted 3 lines
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -0
  #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK           0x00000020
 
+#include <asm/arch/clock_manager_soc64.h>

Includes are normally at the top, what prevents you from moving this up?

You are right, it should be at top. Will change it.

Thanks
Ley Foon

Quoted 34 lines
Quoted 33 lines
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h +1 -0
+
  #endif /* _CLOCK_MANAGER_S10_ */
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h new file +23 -0
new file mode 100644
index 0000000000..3b4bb62ca5
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _CLOCK_MANAGER_SOC64_
+#define _CLOCK_MANAGER_SOC64_
+
+const unsigned int cm_get_osc_clk_hz(void);
+const unsigned int cm_get_f2s_per_ref_clk_hz(void);
+const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
+const unsigned int cm_get_intosc_clk_hz(void);
+const unsigned int cm_get_fpga_clk_hz(void);
+
+#define CLKMGR_EOSC1_HZ              25000000
+#define CLKMGR_INTOSC_HZ     460000000
+#define CLKMGR_FPGA_CLK_HZ   50000000
+
+/* Clock configuration accessors */
+const struct cm_config * const cm_get_default_config(void);
+
+#endif /* _CLOCK_MANAGER_SOC64_ */
#12 lore raw

PATCH v5 8/19 arm: socfpga: Fix CLKMGR_INTOSC_HZ to 400MHz

In reply to Ley Foon Tan

CLKMGR_INTOSC_HZ should be 400MHz, instead of 460MHz.

---
 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +1 -1
index 3b4bb62ca5..1a134b89ba 100644
@@ -14,7 +14,7 @@ const unsigned int cm_get_intosc_clk_hz(void);
 const unsigned int cm_get_fpga_clk_hz(void);
 
 #define CLKMGR_EOSC1_HZ		25000000
-#define CLKMGR_INTOSC_HZ	460000000
+#define CLKMGR_INTOSC_HZ	400000000
 #define CLKMGR_FPGA_CLK_HZ	50000000
 
 /* Clock configuration accessors */
Signature · 1 line
2.19.0
#13 lore raw

PATCH v5 8/19 arm: socfpga: Fix CLKMGR_INTOSC_HZ to 400MHz

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 1 line

CLKMGR_INTOSC_HZ should be 400MHz, instead of 460MHz.

Having this in a separate patch is clearly better.

Quoted 11 lines
---
  arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +0 -0
index 3b4bb62ca5..1a134b89ba 100644

arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h const unsigned int cm_get_intosc_clk_hz(void); · line 18

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +1 -1
@@ -14,7 +14,7 @@ const unsigned int cm_get_intosc_clk_hz(void);
  const unsigned int cm_get_fpga_clk_hz(void);
 
  #define CLKMGR_EOSC1_HZ		25000000
-#define CLKMGR_INTOSC_HZ	460000000
+#define CLKMGR_INTOSC_HZ	400000000
  #define CLKMGR_FPGA_CLK_HZ	50000000

What are these defines anyway? CLKMGR_EOSC1_HZ and CLKMGR_FPGA_CLK_HZ seem unused? Can they be removed (that comment would probably have been better in 8/19...)?

Regards,
Simon

Quoted 3 lines
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +0 -0
  /* Clock configuration accessors */
 
#14 lore raw

PATCH v5 8/19 arm: socfpga: Fix CLKMGR_INTOSC_HZ to 400MHz

Quoted 19 lines · Simon Goldschmidt

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 1 line

CLKMGR_INTOSC_HZ should be 400MHz, instead of 460MHz.

Having this in a separate patch is clearly better.

Quoted 13 lines
---
  arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +0 -0
index 3b4bb62ca5..1a134b89ba 100644
@@ -14,7 +14,7 @@ const unsigned int cm_get_intosc_clk_hz(void);
  const unsigned int cm_get_fpga_clk_hz(void);
 
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h const unsigned int cm_get_intosc_clk_hz(void); · line 18

Quoted 4 lines
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +1 -1
  #define CLKMGR_EOSC1_HZ             25000000
-#define CLKMGR_INTOSC_HZ     460000000
+#define CLKMGR_INTOSC_HZ     400000000
  #define CLKMGR_FPGA_CLK_HZ  50000000

What are these defines anyway? CLKMGR_EOSC1_HZ and CLKMGR_FPGA_CLK_HZ seem unused? Can they be removed (that comment would probably have been better in 8/19...)?

They are unused now. Will remove them.

Thanks.

Regards
Ley Foon

Quoted 5 lines
Quoted 4 lines
arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h +0 -0
  /* Clock configuration accessors */
 
#15 lore raw

PATCH v5 9/19 clk: agilex: Add clock driver for Agilex

In reply to Ley Foon Tan

Add clock manager driver for Agilex. Provides clock initialization and get_rate functions.

Rename stratix10-clock.h to socfpga-soc64-clock.h.

stratix10-clock.h is from Linux commit ID 89727949ea1e.

---
v4:
- Get address from DT.

v3:
- Fixed clear PLL's lostlock bypass mode to ensure the clock manager provide glitchless clock to downstream logic
- Changed CM_REG_CLRBITS(), CM_REG_SETBITS() and CM_REG_CLRSETBITS() macros argument ordering, to match with clrbits_le32, setbits_le32 and clrsetbits_le32.
- Rename stratix10-clock.h to socfpga-soc64-clock.h.
- Convert struct to defines and move defines to clk-agilex.h

v2:
- Convert Clock driver to DM

---
 arch/arm/mach-socfpga/misc.c                  |   4 +
 drivers/clk/altera/Makefile                   |   1 +
 drivers/clk/altera/clk-agilex.c               | 579 ++++++++++++++++++
 drivers/clk/altera/clk-agilex.h               | 237 +++++++
 .../dt-bindings/clock/socfpga-soc64-clock.h   |  84 +++
 5 files changed, 905 insertions(+)
 create mode 100644 drivers/clk/altera/clk-agilex.c
 create mode 100644 drivers/clk/altera/clk-agilex.h
 create mode 100644 include/dt-bindings/clock/socfpga-soc64-clock.h
arch/arm/mach-socfpga/misc.c +4 -0
index dffd1b2e41..f540606569 100644
@@ -240,7 +240,11 @@ void socfpga_get_manager_addr(void)
 	if (!socfpga_sysmgr_base)
 		hang();
 
+#ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+	socfpga_clkmgr_base = socfpga_get_base_addr("intel,agilex-clkmgr");
+#else
 	socfpga_clkmgr_base = socfpga_get_base_addr("altr,clk-mgr");
+#endif
 	if (!socfpga_clkmgr_base)
 		hang();
 }
drivers/clk/altera/Makefile +1 -0
index a3ae8b24b0..96215ad5c4 100644
@@ -3,4 +3,5 @@
 # Copyright (C) 2018 Marek Vasut <[email protected]>
 #
 
+obj-$(CONFIG_TARGET_SOCFPGA_AGILEX) += clk-agilex.o
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clk-arria10.o
drivers/clk/altera/clk-agilex.c new file +579 -0

579 lines not on this page · raw message

drivers/clk/altera/clk-agilex.h new file +237 -0

237 lines not on this page · raw message

include/dt-bindings/clock/socfpga-soc64-clock.h new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.19.0
#16 lore raw

PATCH v5 10/19 arm: socfpga: agilex: Add clock wrapper functions

In reply to Ley Foon Tan

Add clock wrapper functions call to clock DM functions to get clock frequency and used in cm_print_clock_quick_summary().

---
v4:
- Change to use SYSMGR_SOC64* prefix.

v3:
- Improved commit message.
- Rename STRATIX10_* to SOCFPGA_SOC64_*
- Include clock_manager_soc64.h and clk-agilex.h.

v2:
- Get clocks from clock DM.

---
 arch/arm/mach-socfpga/Makefile                |  4 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  | 84 +++++++++++++++++++
 .../mach-socfpga/include/mach/clock_manager.h |  2 +
 .../include/mach/clock_manager_agilex.h       | 14 ++++
 4 files changed, 104 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
arch/arm/mach-socfpga/Makefile +4 -0
index dab34d0ef2..a403b46b47 100644
@@ -39,6 +39,10 @@ obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
 
+ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y	+= clock_manager_agilex.o
+endif
+
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y	+= spl_gen5.o
arch/arm/mach-socfpga/clock_manager_agilex.c new file +84 -0

84 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
index 4f9d10dd78..5d3ee2a83f 100644
@@ -20,6 +20,8 @@ void cm_print_clock_quick_summary(void);
 #include <asm/arch/clock_manager_arria10.h>
 #elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
 #include <asm/arch/clock_manager_s10.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_AGILEX)
+#include <asm/arch/clock_manager_agilex.h>
 #endif
 
 #endif /* _CLOCK_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h new file +14 -0
new file mode 100644
index 0000000000..386e82a4e3
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ */
+
+#ifndef _CLOCK_MANAGER_AGILEX_
+#define _CLOCK_MANAGER_AGILEX_
+
+unsigned long cm_get_mpu_clk_hz(void);
+
+#include <asm/arch/clock_manager_soc64.h>
+#include "../../../../../drivers/clk/altera/clk-agilex.h"
+
+#endif /* _CLOCK_MANAGER_AGILEX_ */
Signature · 1 line
2.19.0
#17 lore raw

PATCH v5 11/19 cache: Add Arteris Ncore cache coherent unit driver

In reply to Ley Foon Tan

Add Cache Coherency Unit (CCU) driver.
CCU is to ensures consistency of shared data between multi masters in the system.

Driver initializes CCU's directories and coherency agent interfaces in CCU IP.

---
v5:
- Move CCU driver to DM.

---
 drivers/cache/Kconfig       |   8 ++
 drivers/cache/Makefile      |   1 +
 drivers/cache/cache-ncore.c | 164 ++++++++++++++++++++++++++++++++++++
 3 files changed, 173 insertions(+)
 create mode 100644 drivers/cache/cache-ncore.c
drivers/cache/Kconfig +8 -0
index 629039e7a8..1e452ad6d9 100644
@@ -31,4 +31,12 @@ config V5L2_CACHE
 	  It will configure tag and data ram timing control from the
 	  device tree and enable L2 cache.
 
+config NCORE_CACHE
+	bool "Arteris Ncore cache coherent unit driver"
+	select CACHE
+	help
+	  This driver is for the Arteris Ncore cache coherent unit (CCU)
+	  controller. The driver initializes cache directories and coherent
+	  agent interfaces.
+
 endmenu
drivers/cache/Makefile +1 -0
index 4a6458c602..7291fc0b29 100644
@@ -2,4 +2,5 @@
 obj-$(CONFIG_CACHE) += cache-uclass.o
 obj-$(CONFIG_SANDBOX) += sandbox_cache.o
 obj-$(CONFIG_L2X0_CACHE) += cache-l2x0.o
+obj-$(CONFIG_NCORE_CACHE) += cache-ncore.o
 obj-$(CONFIG_V5L2_CACHE) += cache-v5l2.o
drivers/cache/cache-ncore.c new file +164 -0

164 lines not on this page · raw message

Signature · 1 line
2.19.0
#18 lore raw

PATCH v5 11/19 cache: Add Arteris Ncore cache coherent unit driver

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 8 lines

Add Cache Coherency Unit (CCU) driver.
CCU is to ensures consistency of shared data between multi masters in the system.

Driver initializes CCU's directories and coherency agent interfaces in CCU IP.

Quoted 209 lines

---
v5:
- Move CCU driver to DM.

---
  drivers/cache/Kconfig       |   8 ++
  drivers/cache/Makefile      |   1 +
  drivers/cache/cache-ncore.c | 164 ++++++++++++++++++++++++++++++++++++
  3 files changed, 173 insertions(+)

create mode 100644 drivers/cache/cache-ncore.c

drivers/cache/Kconfig +8 -0
index 629039e7a8..1e452ad6d9 100644
@@ -31,4 +31,12 @@ config V5L2_CACHE
  	  It will configure tag and data ram timing control from the
  	  device tree and enable L2 cache.
 
+config NCORE_CACHE
+	bool "Arteris Ncore cache coherent unit driver"
+	select CACHE
+	help
+	  This driver is for the Arteris Ncore cache coherent unit (CCU)
+	  controller. The driver initializes cache directories and coherent
+	  agent interfaces.
+
  endmenu
drivers/cache/Makefile +1 -0
index 4a6458c602..7291fc0b29 100644
@@ -2,4 +2,5 @@
  obj-$(CONFIG_CACHE) += cache-uclass.o
  obj-$(CONFIG_SANDBOX) += sandbox_cache.o
  obj-$(CONFIG_L2X0_CACHE) += cache-l2x0.o
+obj-$(CONFIG_NCORE_CACHE) += cache-ncore.o
  obj-$(CONFIG_V5L2_CACHE) += cache-v5l2.o
drivers/cache/cache-ncore.c new file +164 -0
new file mode 100644
index 0000000000..e3aca36071
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+#include <dm.h>
+#include <wait_bit.h>
+
+#include <asm/io.h>
+
+/* Directory */
+#define DIRUSFER		0x80010
+#define DIRUCASER0		0x80040
+#define DIRUSFMCR		0x80080
+#define DIRUSFMAR		0x80084
+
+#define DIRUSFMCR_SFID_SHIFT	16
+
+/* Coherent cache agent interface */
+#define CAIUIDR			0x00ffc
+
+#define CAIUIDR_CA_GET(v)	(((v) & 0x00008000) >> 15)
+#define CAIUIDR_TYPE_GET(v)	(((v) & 0x000f0000) >> 16)
+#define CAIUIDR_TYPE_ACE_CAI_DVM_SUPPORT	0
+#define CAIUIDR_TYPE_ACELITE_CAI_DVM_SUPPORT	1
+
+/* Coherent subsystem */
+#define CSADSER0		0xff040
+#define CSUIDR			0xffff8
+#define CSIDR			0xffffc
+
+#define CSUIDR_NUMCAIUS_GET(v)	(((v) & 0x0000007f) >> 0)
+#define CSUIDR_NUMDIRUS_GET(v)	(((v) & 0x003f0000) >> 16)
+#define CSUIDR_NUMCMIUS_GET(v)	(((v) & 0x3f000000) >> 24)
+
+#define CSIDR_NUMSFS_GET(v)	(((v) & 0x007c0000) >> 18)
+
+#define DIR_REG_SZ		0x1000
+#define CAIU_REG_SZ		0x1000
+
+#define CCU_DIR_REG_ADDR(base, reg, dir)	\
+		((base) + (reg) + ((dir) * DIR_REG_SZ))
+
+/* OCRAM firewall register */
+#define OCRAM_FW_01			0x100204
+#define OCRAM_SECURE_REGIONS		4
+
+#define OCRAM_PRIVILEGED_MASK		BIT(29)
+#define OCRAM_SECURE_MASK		BIT(30)
+
+static void ncore_ccu_init_dirs(void __iomem *base)
+{
+	ulong i, f;
+	int ret;
+	u32 num_of_dirs;
+	u32 num_of_snoop_filters;
+	u32 reg;
+
+	num_of_dirs = CSUIDR_NUMDIRUS_GET(readl(base + CSUIDR));
+	num_of_snoop_filters =
+		CSIDR_NUMSFS_GET(readl(base + CSIDR)) + 1;
+
+	/* Initialize each snoop filter in each directory */
+	for (f = 0; f < num_of_snoop_filters; f++) {
+		reg = f << DIRUSFMCR_SFID_SHIFT;
+		for (i = 0; i < num_of_dirs; i++) {
+			/* Initialize all entries */
+			writel(reg, CCU_DIR_REG_ADDR(base, DIRUSFMCR, i));
+
+			/* Poll snoop filter maintenance operation active
+			 * bit become 0.
+			 */
+			ret = wait_for_bit_le32((const void *)
+						CCU_DIR_REG_ADDR(base,
+								 DIRUSFMAR, i),
+						BIT(0), false, 1000, false);
+			if (ret) {
+				puts("CCU: Directory initialization failed!\n");
+				hang();
+			}
+
+			/* Enable snoop filter, a bit per snoop filter */
+			setbits_le32((ulong)CCU_DIR_REG_ADDR(base, DIRUSFER, i),
+				     BIT(f));
+		}
+	}
+}
+
+static void ncore_ccu_init_coh_agent(void __iomem *base)
+{
+	u32 num_of_coh_agent_intf;
+	u32 num_of_dirs;
+	u32 reg;
+	u32 type;
+	u32 i, dir;
+
+	num_of_coh_agent_intf =
+		CSUIDR_NUMCAIUS_GET(readl(base + CSUIDR));
+	num_of_dirs = CSUIDR_NUMDIRUS_GET(readl(base + CSUIDR));
+
+	for (i = 0; i < num_of_coh_agent_intf; i++) {
+		reg = readl(base + CAIUIDR + (i * CAIU_REG_SZ));
+		if (CAIUIDR_CA_GET(reg)) {
+			/* Caching agent bit is enabled, enable caching agent
+			 * snoop in each directory
+			 */
+			for (dir = 0; dir < num_of_dirs; dir++) {
+				setbits_le32((ulong)
+					     CCU_DIR_REG_ADDR(base, DIRUCASER0,
+							      dir),
+					     BIT(i));
+			}
+		}
+
+		type = CAIUIDR_TYPE_GET(reg);
+		if (type == CAIUIDR_TYPE_ACE_CAI_DVM_SUPPORT ||
+		    type == CAIUIDR_TYPE_ACELITE_CAI_DVM_SUPPORT) {
+			/* DVM support is enabled, enable ACE DVM snoop*/
+			setbits_le32((ulong)(base + CSADSER0),
+				     BIT(i));
+		}
+	}
+}
+
+static void ocram_bypass_firewall(void __iomem *base)
+{
+	int i;
+
+	for (i = 0; i < OCRAM_SECURE_REGIONS; i++) {
+		clrbits_le32(base + OCRAM_FW_01 + (i * sizeof(u32)),
+			     OCRAM_PRIVILEGED_MASK | OCRAM_SECURE_MASK);
+	}
+}
+
+static int ncore_ccu_probe(struct udevice *dev)
+{
+	void __iomem *base;
+	fdt_addr_t addr;
+
+	addr = dev_read_addr(dev);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+
+	base = (void __iomem *)addr;
+
+	ncore_ccu_init_dirs(base);
+	ncore_ccu_init_coh_agent(base);
+	ocram_bypass_firewall(base);
+
+	return 0;
+}
+
+static const struct udevice_id ncore_ccu_ids[] = {
+	{ .compatible = "arteris,ncore-ccu" },
+	{}
+};
+
+U_BOOT_DRIVER(ncore_ccu) = {
+	.name   = "ncore_ccu",
+	.id     = UCLASS_CACHE,
+	.of_match = ncore_ccu_ids,
+	.probe	= ncore_ccu_probe,
+	.flags  = DM_FLAG_PRE_RELOC,
+};
#19 lore raw

PATCH v5 12/19 drivers: Enable cache driver build in SPL

In reply to Ley Foon Tan

Enable cache driver build in SPL.

---
 drivers/Makefile | 1 +
 1 file changed, 1 insertion(+)
drivers/Makefile +1 -0
index a4bb5e4975..0d231cddbb 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
 ifndef CONFIG_TPL_BUILD
 ifdef CONFIG_SPL_BUILD
 
+obj-$(CONFIG_CACHE) += cache/
 obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/
 obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
 obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
Signature · 1 line
2.19.0
#20 lore raw

PATCH v5 12/19 drivers: Enable cache driver build in SPL

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 12 lines

Enable cache driver build in SPL.

---
  drivers/Makefile | 1 +
  1 file changed, 1 insertion(+)
drivers/Makefile +0 -0
index a4bb5e4975..0d231cddbb 100644

drivers/Makefile obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/ · line 33

Quoted 4 lines
drivers/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
  ifndef CONFIG_TPL_BUILD
  ifdef CONFIG_SPL_BUILD
 
+obj-$(CONFIG_CACHE) += cache/

Hmm, I'm not sure this can go in via the socfpga tree (in this series). Does this change break any existing configs?

You'd probably have to run this separate from this series so that Tom or Simon (Glass) can apply it...?

Regards,
Simon

Quoted 4 lines
drivers/Makefile +0 -0
  obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/
  obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
  obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
#21 lore raw

PATCH v5 12/19 drivers: Enable cache driver build in SPL

Quoted 17 lines · Simon Goldschmidt

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 15 lines

Enable cache driver build in SPL.

---
  drivers/Makefile | 1 +
  1 file changed, 1 insertion(+)
drivers/Makefile +0 -0
index a4bb5e4975..0d231cddbb 100644
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/
  ifndef CONFIG_TPL_BUILD
  ifdef CONFIG_SPL_BUILD
 
Quoted 4 lines

drivers/Makefile obj-$(CONFIG_$(SPL_TPL_)TPM) += tpm/ · line 33

Quoted 1 line
drivers/Makefile +1 -0
+obj-$(CONFIG_CACHE) += cache/

Hmm, I'm not sure this can go in via the socfpga tree (in this series). Does this change break any existing configs?

Tired to compile Cyclone 5 and Arria 10 platform which enable CONFIG_L2X0_CACHE, no compilation.

Quoted 3 lines

You'd probably have to run this separate from this series so that Tom or Simon (Glass) can apply it...?

Okay, I will send this patch separately from this series.

Thanks.
Regards
Ley Foon

Quoted 6 lines
Quoted 5 lines
drivers/Makefile +0 -0
  obj-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += bootcount/
  obj-$(CONFIG_SPL_CPU_SUPPORT) += cpu/
  obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
#22 lore raw

PATCH v5 13/19 arm: agilex: Add clock handoff offset for Agilex

In reply to Ley Foon Tan

Add clock handoff offset for Agilex. Remove S10 prefix to avoid confusion.

---
 arch/arm/mach-socfpga/include/mach/handoff_s10.h | 9 +++++++--
 arch/arm/mach-socfpga/wrap_pll_config_s10.c      | 5 +++--
 2 files changed, 10 insertions(+), 4 deletions(-)
arch/arm/mach-socfpga/include/mach/handoff_s10.h +7 -2
index ba0f1fd1b2..abf04d9b04 100644
@@ -26,8 +26,13 @@
 #define S10_HANDOFF_OFFSET_LENGTH	0x4
 #define S10_HANDOFF_OFFSET_DATA	0x10
 
-#define S10_HANDOFF_CLOCK_OSC	(S10_HANDOFF_BASE + 0x608)
-#define S10_HANDOFF_CLOCK_FPGA	(S10_HANDOFF_BASE + 0x60C)
+#ifdef TARGET_SOCFPGA_STRATIX10
+#define HANDOFF_CLOCK_OSC	(S10_HANDOFF_BASE + 0x608)
+#define HANDOFF_CLOCK_FPGA	(S10_HANDOFF_BASE + 0x60C)
+#else
+#define HANDOFF_CLOCK_OSC	(S10_HANDOFF_BASE + 0x5fc)
+#define HANDOFF_CLOCK_FPGA	(S10_HANDOFF_BASE + 0x600)
+#endif
 
 #define S10_HANDOFF_SIZE	4096
 
arch/arm/mach-socfpga/wrap_pll_config_s10.c +3 -2
index b002f38215..d27accab57 100644
@@ -33,7 +33,8 @@ const struct cm_config * const cm_get_default_config(void)
 const unsigned int cm_get_osc_clk_hz(void)
 {
 #ifdef CONFIG_SPL_BUILD
-	u32 clock = readl(S10_HANDOFF_CLOCK_OSC);
+
+	u32 clock = readl(HANDOFF_CLOCK_OSC);
 
 	writel(clock, socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD1);
 #endif
@@ -48,7 +49,7 @@ const unsigned int cm_get_intosc_clk_hz(void)
 const unsigned int cm_get_fpga_clk_hz(void)
 {
 #ifdef CONFIG_SPL_BUILD
-	u32 clock = readl(S10_HANDOFF_CLOCK_FPGA);
+	u32 clock = readl(HANDOFF_CLOCK_FPGA);
 
 	writel(clock, socfpga_sysmgr_base + SYSMGR_SOC64_BOOT_SCRATCH_COLD2);
 #endif
Signature · 1 line
2.19.0
#23 lore raw

PATCH v5 14/19 ddr: altera: Restructure Stratix 10 SDRAM driver

In reply to Ley Foon Tan

Restructure Stratix 10 SDRAM driver. Move common code to separate file, in preparation to support SDRAM driver for Agilex.

---
v3:
- Change sdram_common.* to sdram_soc64.*

---
 drivers/ddr/altera/Makefile                   |   2 +-
 drivers/ddr/altera/sdram_s10.c                | 296 +----------------
 drivers/ddr/altera/sdram_s10.h                | 148 +--------
 drivers/ddr/altera/sdram_soc64.c              | 304 ++++++++++++++++++
 .../ddr/altera/{sdram_s10.h => sdram_soc64.h} |  70 ++--
 5 files changed, 341 insertions(+), 479 deletions(-)
 create mode 100644 drivers/ddr/altera/sdram_soc64.c
 copy drivers/ddr/altera/{sdram_s10.h => sdram_soc64.h} (79%)
drivers/ddr/altera/Makefile +1 -1
index 341ac0d73b..eb8da13b7d 100644
@@ -9,5 +9,5 @@
 ifdef CONFIG_$(SPL_)ALTERA_SDRAM
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
-obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_s10.o
+obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o
 endif
drivers/ddr/altera/sdram_s10.c +1 -295

330 lines not on this page · raw message

drivers/ddr/altera/sdram_s10.h +1 -147

159 lines not on this page · raw message

drivers/ddr/altera/sdram_soc64.c new file +304 -0

304 lines not on this page · raw message

drivers/ddr/altera/sdram_soc64.h renamed from drivers/ddr/altera/sdram_s10.h +34 -36

85 lines not on this page · raw message

Signature · 1 line
2.19.0
#24 lore raw

PATCH v5 14/19 ddr: altera: Restructure Stratix 10 SDRAM driver

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 819 lines

Restructure Stratix 10 SDRAM driver. Move common code to separate file, in preparation to support SDRAM driver for Agilex.

---
v3:
- Change sdram_common.* to sdram_soc64.*

---
  drivers/ddr/altera/Makefile                   |   2 +-
  drivers/ddr/altera/sdram_s10.c                | 296 +----------------
  drivers/ddr/altera/sdram_s10.h                | 148 +--------
  drivers/ddr/altera/sdram_soc64.c              | 304 ++++++++++++++++++
  .../ddr/altera/{sdram_s10.h => sdram_soc64.h} |  70 ++--
  5 files changed, 341 insertions(+), 479 deletions(-)

create mode 100644 drivers/ddr/altera/sdram_soc64.c copy drivers/ddr/altera/{sdram_s10.h => sdram_soc64.h} (79%)

drivers/ddr/altera/Makefile +1 -1
index 341ac0d73b..eb8da13b7d 100644
@@ -9,5 +9,5 @@
  ifdef CONFIG_$(SPL_)ALTERA_SDRAM
  obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
  obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
-obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_s10.o
+obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o
  endif
drivers/ddr/altera/sdram_s10.c +1 -295
index 9578aa743d..fcab3ae3e4 100644
@@ -14,28 +14,14 @@
  #include "sdram_s10.h"
  #include <wait_bit.h>
  #include <asm/arch/firewall.h>
-#include <asm/arch/system_manager.h>
  #include <asm/arch/reset_manager.h>
  #include <asm/io.h>
  #include <linux/sizes.h>
 
-struct altera_sdram_priv {
-	struct ram_info info;
-	struct reset_ctl_bulk resets;
-};
-
-struct altera_sdram_platdata {
-	void __iomem *hmc;
-	void __iomem *ddr_sch;
-	void __iomem *iomhc;
-};
-
  DECLARE_GLOBAL_DATA_PTR;
 
  #define DDR_CONFIG(A, B, C, R)	(((A) << 24) | ((B) << 16) | ((C) << 8) | (R))
 
-#define PGTABLE_OFF	0x4000
-
  /* The followring are the supported configurations */
  u32 ddr_config[] = {
  	/* DDR_CONFIG(Address order,Bank,Column,Row) */
@@ -62,28 +48,6 @@ u32 ddr_config[] = {
  	DDR_CONFIG(1, 4, 10, 17),
  };
 
-static u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg)
-{
-	return readl(plat->iomhc + reg);
-}
-
-static u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg)
-{
-	return readl(plat->hmc + reg);
-}
-
-static u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
-			  u32 data, u32 reg)
-{
-	return writel(data, plat->hmc + reg);
-}
-
-static u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
-			  u32 reg)
-{
-	return writel(data, plat->ddr_sch + reg);
-}
-
  int match_ddr_conf(u32 ddr_conf)
  {
  	int i;
@@ -95,193 +59,12 @@ int match_ddr_conf(u32 ddr_conf)
  	return 0;
  }
 
-static int emif_clear(struct altera_sdram_platdata *plat)
-{
-	hmc_ecc_writel(plat, 0, RSTHANDSHAKECTRL);
-
-	return wait_for_bit_le32((const void *)(plat->hmc +
-				 RSTHANDSHAKESTAT),
-				 DDR_HMC_RSTHANDSHAKE_MASK,
-				 false, 1000, false);
-}
-
-static int emif_reset(struct altera_sdram_platdata *plat)
-{
-	u32 c2s, s2c, ret;
-
-	c2s = hmc_ecc_readl(plat, RSTHANDSHAKECTRL) & DDR_HMC_RSTHANDSHAKE_MASK;
-	s2c = hmc_ecc_readl(plat, RSTHANDSHAKESTAT) & DDR_HMC_RSTHANDSHAKE_MASK;
-
-	debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
-	      c2s, s2c, hmc_readl(plat, NIOSRESERVED0),
-	      hmc_readl(plat, NIOSRESERVED1), hmc_readl(plat, NIOSRESERVED2),
-	      hmc_readl(plat, DRAMSTS));
-
-	if (s2c && emif_clear(plat)) {
-		printf("DDR: emif_clear() failed\n");
-		return -1;
-	}
-
-	debug("DDR: Triggerring emif reset\n");
-	hmc_ecc_writel(plat, DDR_HMC_CORE2SEQ_INT_REQ, RSTHANDSHAKECTRL);
-
-	/* if seq2core[3] = 0, we are good */
-	ret = wait_for_bit_le32((const void *)(plat->hmc +
-				 RSTHANDSHAKESTAT),
-				 DDR_HMC_SEQ2CORE_INT_RESP_MASK,
-				 false, 1000, false);
-	if (ret) {
-		printf("DDR: failed to get ack from EMIF\n");
-		return ret;
-	}
-
-	ret = emif_clear(plat);
-	if (ret) {
-		printf("DDR: emif_clear() failed\n");
-		return ret;
-	}
-
-	debug("DDR: %s triggered successly\n", __func__);
-	return 0;
-}
-
-static int poll_hmc_clock_status(void)
-{
-	return wait_for_bit_le32((const void *)(socfpga_sysmgr_base +
-				 SYSMGR_SOC64_HMC_CLK),
-				 SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
-}
-
-static void sdram_clear_mem(phys_addr_t addr, phys_size_t size)
-{
-	phys_size_t i;
-
-	if (addr % CONFIG_SYS_CACHELINE_SIZE) {
-		printf("DDR: address 0x%llx is not cacheline size aligned.\n",
-		       addr);
-		hang();
-	}
-
-	if (size % CONFIG_SYS_CACHELINE_SIZE) {
-		printf("DDR: size 0x%llx is not multiple of cacheline size\n",
-		       size);
-		hang();
-	}
-
-	/* Use DC ZVA instruction to clear memory to zeros by a cache line */
-	for (i = 0; i < size; i = i + CONFIG_SYS_CACHELINE_SIZE) {
-		asm volatile("dc zva, %0"
-		     :
-		     : "r"(addr)
-		     : "memory");
-		addr += CONFIG_SYS_CACHELINE_SIZE;
-	}
-}
-
-static void sdram_init_ecc_bits(bd_t *bd)
-{
-	phys_size_t size, size_init;
-	phys_addr_t start_addr;
-	int bank = 0;
-	unsigned int start = get_timer(0);
-
-	icache_enable();
-
-	start_addr = bd->bi_dram[0].start;
-	size = bd->bi_dram[0].size;
-
-	/* Initialize small block for page table */
-	memset((void *)start_addr, 0, PGTABLE_SIZE + PGTABLE_OFF);
-	gd->arch.tlb_addr = start_addr + PGTABLE_OFF;
-	gd->arch.tlb_size = PGTABLE_SIZE;
-	start_addr += PGTABLE_SIZE + PGTABLE_OFF;
-	size -= (PGTABLE_OFF + PGTABLE_SIZE);
-	dcache_enable();
-
-	while (1) {
-		while (size) {
-			size_init = min((phys_addr_t)SZ_1G, (phys_addr_t)size);
-			sdram_clear_mem(start_addr, size_init);
-			size -= size_init;
-			start_addr += size_init;
-			WATCHDOG_RESET();
-		}
-
-		bank++;
-		if (bank >= CONFIG_NR_DRAM_BANKS)
-			break;
-
-		start_addr = bd->bi_dram[bank].start;
-		size = bd->bi_dram[bank].size;
-	}
-
-	dcache_disable();
-	icache_disable();
-
-	printf("SDRAM-ECC: Initialized success with %d ms\n",
-	       (unsigned int)get_timer(start));
-}
-
-static void sdram_size_check(bd_t *bd)
-{
-	phys_size_t total_ram_check = 0;
-	phys_size_t ram_check = 0;
-	phys_addr_t start = 0;
-	int bank;
-
-	/* Sanity check ensure correct SDRAM size specified */
-	debug("DDR: Running SDRAM size sanity check\n");
-
-	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		start = bd->bi_dram[bank].start;
-		while (ram_check < bd->bi_dram[bank].size) {
-			ram_check += get_ram_size((void *)(start + ram_check),
-						 (phys_size_t)SZ_1G);
-		}
-		total_ram_check += ram_check;
-		ram_check = 0;
-	}
-
-	/* If the ram_size is 2GB smaller, we can assume the IO space is
-	 * not mapped in.  gd->ram_size is the actual size of the dram
-	 * not the accessible size.
-	 */
-	if (total_ram_check != gd->ram_size) {
-		puts("DDR: SDRAM size check failed!\n");
-		hang();
-	}
-
-	debug("DDR: SDRAM size check passed!\n");
-}
-
-/**
- * sdram_calculate_size() - Calculate SDRAM size
- *
- * Calculate SDRAM device size based on SDRAM controller parameters.
- * Size is specified in bytes.
- */
-static phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat)
-{
-	u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
-
-	phys_size_t size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
-			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
-			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
-			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
-			 DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
-
-	size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
-			DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
-
-	return size;
-}
-
  /**
   * sdram_mmr_init_full() - Function to initialize SDRAM MMR
   *
   * Initialize the SDRAM MMR.
   */
-static int sdram_mmr_init_full(struct udevice *dev)
+int sdram_mmr_init_full(struct udevice *dev)
  {
  	struct altera_sdram_platdata *plat = dev->platdata;
  	struct altera_sdram_priv *priv = dev_get_priv(dev);
@@ -534,80 +317,3 @@ static int sdram_mmr_init_full(struct udevice *dev)
  	return 0;
  }
 
-static int altera_sdram_ofdata_to_platdata(struct udevice *dev)
-{
-	struct altera_sdram_platdata *plat = dev->platdata;
-	fdt_addr_t addr;
-
-	addr = dev_read_addr_index(dev, 0);
-	if (addr == FDT_ADDR_T_NONE)
-		return -EINVAL;
-	plat->ddr_sch = (void __iomem *)addr;
-
-	addr = dev_read_addr_index(dev, 1);
-	if (addr == FDT_ADDR_T_NONE)
-		return -EINVAL;
-	plat->iomhc = (void __iomem *)addr;
-
-	addr = dev_read_addr_index(dev, 2);
-	if (addr == FDT_ADDR_T_NONE)
-		return -EINVAL;
-	plat->hmc = (void __iomem *)addr;
-
-	return 0;
-}
-
-static int altera_sdram_probe(struct udevice *dev)
-{
-	int ret;
-	struct altera_sdram_priv *priv = dev_get_priv(dev);
-
-	ret = reset_get_bulk(dev, &priv->resets);
-	if (ret) {
-		dev_err(dev, "Can't get reset: %d\n", ret);
-		return -ENODEV;
-	}
-	reset_deassert_bulk(&priv->resets);
-
-	if (sdram_mmr_init_full(dev) != 0) {
-		puts("SDRAM init failed.\n");
-		goto failed;
-	}
-
-	return 0;
-
-failed:
-	reset_release_bulk(&priv->resets);
-	return -ENODEV;
-}
-
-static int altera_sdram_get_info(struct udevice *dev,
-				 struct ram_info *info)
-{
-	struct altera_sdram_priv *priv = dev_get_priv(dev);
-
-	info->base = priv->info.base;
-	info->size = priv->info.size;
-
-	return 0;
-}
-
-static struct ram_ops altera_sdram_ops = {
-	.get_info = altera_sdram_get_info,
-};
-
-static const struct udevice_id altera_sdram_ids[] = {
-	{ .compatible = "altr,sdr-ctl-s10" },
-	{ /* sentinel */ }
-};
-
-U_BOOT_DRIVER(altera_sdram) = {
-	.name = "altr_sdr_ctl",
-	.id = UCLASS_RAM,
-	.of_match = altera_sdram_ids,
-	.ops = &altera_sdram_ops,
-	.ofdata_to_platdata = altera_sdram_ofdata_to_platdata,
-	.platdata_auto_alloc_size = sizeof(struct altera_sdram_platdata),
-	.probe = altera_sdram_probe,
-	.priv_auto_alloc_size = sizeof(struct altera_sdram_priv),
-};
drivers/ddr/altera/sdram_s10.h +1 -147
index 096c06cba2..cca4cb35ec 100644
@@ -11,48 +11,6 @@
  #define DDR_READ_LATENCY_DELAY		40
  #define DDR_ACTIVATE_FAWBANK		0x1
 
-/* ECC HMC registers */
-#define DDRIOCTRL			0x8
-#define DDRCALSTAT			0xc
-#define DRAMADDRWIDTH			0xe0
-#define ECCCTRL1			0x100
-#define ECCCTRL2			0x104
-#define ERRINTEN			0x110
-#define ERRINTENS			0x114
-#define INTMODE				0x11c
-#define INTSTAT				0x120
-#define AUTOWB_CORRADDR			0x138
-#define ECC_REG2WRECCDATABUS		0x144
-#define ECC_DIAGON			0x150
-#define ECC_DECSTAT			0x154
-#define HPSINTFCSEL			0x210
-#define RSTHANDSHAKECTRL		0x214
-#define RSTHANDSHAKESTAT		0x218
-
-#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK		0x00000003
-#define DDR_HMC_DDRCALSTAT_CAL_MSK		BIT(0)
-#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK	BIT(16)
-#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK		BIT(8)
-#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK		BIT(0)
-#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK		BIT(8)
-#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK		BIT(0)
-#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK	BIT(16)
-#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK	BIT(0)
-#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK	BIT(0)
-#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK	BIT(1)
-#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK	BIT(0)
-#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK	BIT(1)
-#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK	BIT(16)
-#define DDR_HMC_INTMODE_INTMODE_SET_MSK		BIT(0)
-#define DDR_HMC_RSTHANDSHAKE_MASK		0x000000ff
-#define DDR_HMC_CORE2SEQ_INT_REQ		0xF
-#define DDR_HMC_SEQ2CORE_INT_RESP_MASK		BIT(3)
-#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK		0x001f1f1f
-
-#define	DDR_HMC_ERRINTEN_INTMASK				\
-		(DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK |	\
-		 DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK)
-
  /* NOC DDR scheduler */
  #define DDR_SCH_ID_COREID		0
  #define DDR_SCH_ID_REVID		0x4
@@ -79,110 +37,6 @@
  #define DDR_SCH_DEVTODEV_BUSRDTOWR_OFF		2
  #define DDR_SCH_DEVTODEV_BUSWRTORD_OFF		4
 
-/* HMC MMR IO48 registers */
-#define CTRLCFG0			0x28
-#define CTRLCFG1			0x2c
-#define DRAMTIMING0			0x50
-#define CALTIMING0			0x7c
-#define CALTIMING1			0x80
-#define CALTIMING2			0x84
-#define CALTIMING3			0x88
-#define CALTIMING4			0x8c
-#define CALTIMING9			0xa0
-#define DRAMADDRW			0xa8
-#define DRAMSTS				0xec
-#define NIOSRESERVED0			0x110
-#define NIOSRESERVED1			0x114
-#define NIOSRESERVED2			0x118
-
-#define DRAMADDRW_CFG_COL_ADDR_WIDTH(x)			\
-	(((x) >> 0) & 0x1F)
-#define DRAMADDRW_CFG_ROW_ADDR_WIDTH(x)			\
-	(((x) >> 5) & 0x1F)
-#define DRAMADDRW_CFG_BANK_ADDR_WIDTH(x)		\
-	(((x) >> 10) & 0xF)
-#define DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(x)		\
-	(((x) >> 14) & 0x3)
-#define DRAMADDRW_CFG_CS_ADDR_WIDTH(x)			\
-	(((x) >> 16) & 0x7)
-
-#define CTRLCFG0_CFG_MEMTYPE(x)				\
-	(((x) >> 0) & 0xF)
-#define CTRLCFG0_CFG_DIMM_TYPE(x)			\
-	(((x) >> 4) & 0x7)
-#define CTRLCFG0_CFG_AC_POS(x)				\
-	(((x) >> 7) & 0x3)
-#define CTRLCFG0_CFG_CTRL_BURST_LEN(x)			\
-	(((x) >> 9) & 0x1F)
-
-#define CTRLCFG1_CFG_DBC3_BURST_LEN(x)			\
-	(((x) >> 0) & 0x1F)
-#define CTRLCFG1_CFG_ADDR_ORDER(x)			\
-	(((x) >> 5) & 0x3)
-#define CTRLCFG1_CFG_CTRL_EN_ECC(x)			\
-	(((x) >> 7) & 0x1)
-
-#define DRAMTIMING0_CFG_TCL(x)				\
-	(((x) >> 0) & 0x7F)
-
-#define CALTIMING0_CFG_ACT_TO_RDWR(x)			\
-	(((x) >> 0) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_PCH(x)			\
-	(((x) >> 6) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_ACT(x)			\
-	(((x) >> 12) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_ACT_DB(x)			\
-	(((x) >> 18) & 0x3F)
-
-#define CALTIMING1_CFG_RD_TO_RD(x)			\
-	(((x) >> 0) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_RD_DC(x)			\
-	(((x) >> 6) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_RD_DB(x)			\
-	(((x) >> 12) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_WR(x)			\
-	(((x) >> 18) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_WR_DC(x)			\
-	(((x) >> 24) & 0x3F)
-
-#define CALTIMING2_CFG_RD_TO_WR_DB(x)			\
-	(((x) >> 0) & 0x3F)
-#define CALTIMING2_CFG_RD_TO_WR_PCH(x)			\
-	(((x) >> 6) & 0x3F)
-#define CALTIMING2_CFG_RD_AP_TO_VALID(x)		\
-	(((x) >> 12) & 0x3F)
-#define CALTIMING2_CFG_WR_TO_WR(x)			\
-	(((x) >> 18) & 0x3F)
-#define CALTIMING2_CFG_WR_TO_WR_DC(x)			\
-	(((x) >> 24) & 0x3F)
-
-#define CALTIMING3_CFG_WR_TO_WR_DB(x)			\
-	(((x) >> 0) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD(x)			\
-	(((x) >> 6) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD_DC(x)			\
-	(((x) >> 12) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD_DB(x)			\
-	(((x) >> 18) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_PCH(x)			\
-	(((x) >> 24) & 0x3F)
-
-#define CALTIMING4_CFG_WR_AP_TO_VALID(x)		\
-	(((x) >> 0) & 0x3F)
-#define CALTIMING4_CFG_PCH_TO_VALID(x)			\
-	(((x) >> 6) & 0x3F)
-#define CALTIMING4_CFG_PCH_ALL_TO_VALID(x)		\
-	(((x) >> 12) & 0x3F)
-#define CALTIMING4_CFG_ARF_TO_VALID(x)			\
-	(((x) >> 18) & 0xFF)
-#define CALTIMING4_CFG_PDN_TO_VALID(x)			\
-	(((x) >> 26) & 0x3F)
-
-#define CALTIMING9_CFG_4_ACT_TO_ACT(x)			\
-	(((x) >> 0) & 0xFF)
-
-/* Firewall DDR scheduler MPFE */
-#define FW_HMC_ADAPTOR_REG_ADDR			0xf8020004
-#define FW_HMC_ADAPTOR_MPU_MASK			BIT(0)
+#include "sdram_soc64.h"
 
  #endif /* _SDRAM_S10_H_ */
drivers/ddr/altera/sdram_soc64.c new file +281 -0
new file mode 100644
index 0000000000..3097e0671c
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <div64.h>
+#include <fdtdec.h>
+#include <ram.h>
+#include <reset.h>
+#include "sdram_soc64.h"
+#include <wait_bit.h>
+#include <asm/arch/firewall.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/io.h>
+#include <linux/sizes.h>
+
+#define PGTABLE_OFF	0x4000
+
+u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg)
+{
+	return readl(plat->iomhc + reg);
+}
+
+u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg)
+{
+	return readl(plat->hmc + reg);
+}
+
+u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
+		   u32 data, u32 reg)
+{
+	return writel(data, plat->hmc + reg);
+}
+
+u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
+		   u32 reg)
+{
+	return writel(data, plat->ddr_sch + reg);
+}
+
+int emif_clear(struct altera_sdram_platdata *plat)
+{
+	hmc_ecc_writel(plat, 0, RSTHANDSHAKECTRL);
+
+	return wait_for_bit_le32((const void *)(plat->hmc +
+				 RSTHANDSHAKESTAT),
+				 DDR_HMC_RSTHANDSHAKE_MASK,
+				 false, 1000, false);
+}
+
+int emif_reset(struct altera_sdram_platdata *plat)
+{
+	u32 c2s, s2c, ret;
+
+	c2s = hmc_ecc_readl(plat, RSTHANDSHAKECTRL) & DDR_HMC_RSTHANDSHAKE_MASK;
+	s2c = hmc_ecc_readl(plat, RSTHANDSHAKESTAT) & DDR_HMC_RSTHANDSHAKE_MASK;
+
+	debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
+	      c2s, s2c, hmc_readl(plat, NIOSRESERVED0),
+	      hmc_readl(plat, NIOSRESERVED1), hmc_readl(plat, NIOSRESERVED2),
+	      hmc_readl(plat, DRAMSTS));
+
+	if (s2c && emif_clear(plat)) {
+		printf("DDR: emif_clear() failed\n");
+		return -1;
+	}
+
+	debug("DDR: Triggerring emif reset\n");
+	hmc_ecc_writel(plat, DDR_HMC_CORE2SEQ_INT_REQ, RSTHANDSHAKECTRL);
+
+	/* if seq2core[3] = 0, we are good */
+	ret = wait_for_bit_le32((const void *)(plat->hmc +
+				 RSTHANDSHAKESTAT),
+				 DDR_HMC_SEQ2CORE_INT_RESP_MASK,
+				 false, 1000, false);
+	if (ret) {
+		printf("DDR: failed to get ack from EMIF\n");
+		return ret;
+	}
+
+	ret = emif_clear(plat);
+	if (ret) {
+		printf("DDR: emif_clear() failed\n");
+		return ret;
+	}
+
+	debug("DDR: %s triggered successly\n", __func__);
+	return 0;
+}
+
+int poll_hmc_clock_status(void)
+{
+	return wait_for_bit_le32((const void *)(socfpga_sysmgr_base +
+				 SYSMGR_SOC64_HMC_CLK),
+				 SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
+}
+
+void sdram_clear_mem(phys_addr_t addr, phys_size_t size)
+{
+	phys_size_t i;
+
+	if (addr % CONFIG_SYS_CACHELINE_SIZE) {
+		printf("DDR: address 0x%llx is not cacheline size aligned.\n",
+		       addr);
+		hang();
+	}
+
+	if (size % CONFIG_SYS_CACHELINE_SIZE) {
+		printf("DDR: size 0x%llx is not multiple of cacheline size\n",
+		       size);
+		hang();
+	}
+
+	/* Use DC ZVA instruction to clear memory to zeros by a cache line */
+	for (i = 0; i < size; i = i + CONFIG_SYS_CACHELINE_SIZE) {
+		asm volatile("dc zva, %0"
+		     :
+		     : "r"(addr)
+		     : "memory");
+		addr += CONFIG_SYS_CACHELINE_SIZE;
+	}
+}
+
+void sdram_init_ecc_bits(bd_t *bd)
+{
+	phys_size_t size, size_init;
+	phys_addr_t start_addr;
+	int bank = 0;
+	unsigned int start = get_timer(0);
+
+	icache_enable();
+
+	start_addr = bd->bi_dram[0].start;
+	size = bd->bi_dram[0].size;
+
+	/* Initialize small block for page table */
+	memset((void *)start_addr, 0, PGTABLE_SIZE + PGTABLE_OFF);
+	gd->arch.tlb_addr = start_addr + PGTABLE_OFF;
+	gd->arch.tlb_size = PGTABLE_SIZE;
+	start_addr += PGTABLE_SIZE + PGTABLE_OFF;
+	size -= (PGTABLE_OFF + PGTABLE_SIZE);
+	dcache_enable();
+
+	while (1) {
+		while (size) {
+			size_init = min((phys_addr_t)SZ_1G, (phys_addr_t)size);
+			sdram_clear_mem(start_addr, size_init);
+			size -= size_init;
+			start_addr += size_init;
+			WATCHDOG_RESET();
+		}
+
+		bank++;
+		if (bank >= CONFIG_NR_DRAM_BANKS)
+			break;
+
+		start_addr = bd->bi_dram[bank].start;
+		size = bd->bi_dram[bank].size;
+	}
+
+	dcache_disable();
+	icache_disable();
+
+	printf("SDRAM-ECC: Initialized success with %d ms\n",
+	       (unsigned int)get_timer(start));
+}
+
+void sdram_size_check(bd_t *bd)
+{
+	phys_size_t total_ram_check = 0;
+	phys_size_t ram_check = 0;
+	phys_addr_t start = 0;
+	int bank;
+
+	/* Sanity check ensure correct SDRAM size specified */
+	debug("DDR: Running SDRAM size sanity check\n");
+
+	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+		start = bd->bi_dram[bank].start;
+		while (ram_check < bd->bi_dram[bank].size) {
+			ram_check += get_ram_size((void *)(start + ram_check),
+						 (phys_size_t)SZ_1G);
+		}
+		total_ram_check += ram_check;
+		ram_check = 0;
+	}
+
+	/* If the ram_size is 2GB smaller, we can assume the IO space is
+	 * not mapped in.  gd->ram_size is the actual size of the dram
+	 * not the accessible size.
+	 */
+	if (total_ram_check != gd->ram_size) {
+		puts("DDR: SDRAM size check failed!\n");
+		hang();
+	}
+
+	debug("DDR: SDRAM size check passed!\n");
+}
+
+/**
+ * sdram_calculate_size() - Calculate SDRAM size
+ *
+ * Calculate SDRAM device size based on SDRAM controller parameters.
+ * Size is specified in bytes.
+ */
+phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat)
+{
+	u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
+
+	phys_size_t size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+			 DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
+			 DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
+			 DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
+			 DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
+
+	size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
+			DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
+
+	return size;
+}
+
+static int altera_sdram_ofdata_to_platdata(struct udevice *dev)
+{
+	struct altera_sdram_platdata *plat = dev->platdata;
+	fdt_addr_t addr;
+
+	addr = dev_read_addr_index(dev, 0);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+	plat->ddr_sch = (void __iomem *)addr;
+
+	addr = dev_read_addr_index(dev, 1);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+	plat->iomhc = (void __iomem *)addr;
+
+	addr = dev_read_addr_index(dev, 2);
+	if (addr == FDT_ADDR_T_NONE)
+		return -EINVAL;
+	plat->hmc = (void __iomem *)addr;
+
+	return 0;
+}
+
+static int altera_sdram_probe(struct udevice *dev)
+{
+	int ret;
+	struct altera_sdram_priv *priv = dev_get_priv(dev);
+
+	ret = reset_get_bulk(dev, &priv->resets);
+	if (ret) {
+		dev_err(dev, "Can't get reset: %d\n", ret);
+		return -ENODEV;
+	}
+	reset_deassert_bulk(&priv->resets);
+
+	if (sdram_mmr_init_full(dev) != 0) {
+		puts("SDRAM init failed.\n");
+		goto failed;
+	}
+
+	return 0;
+
+failed:
+	reset_release_bulk(&priv->resets);
+	return -ENODEV;
+}
+
+static int altera_sdram_get_info(struct udevice *dev,
+				 struct ram_info *info)
+{
+	struct altera_sdram_priv *priv = dev_get_priv(dev);
+
+	info->base = priv->info.base;
+	info->size = priv->info.size;
+

drivers/ddr/altera/sdram_soc64.c line 291

Quoted 10 lines
drivers/ddr/altera/sdram_soc64.c new file +10 -0
+	return 0;
+}
+
+static struct ram_ops altera_sdram_ops = {
+	.get_info = altera_sdram_get_info,
+};
+
+static const struct udevice_id altera_sdram_ids[] = {
+	{ .compatible = "altr,sdr-ctl-s10" },
+	{ .compatible = "intel,sdr-ctl-agilex" },

Sigh, so this is *not* what the commit message says. Please keep changes separate. This patch should merely move code (like the commit message says) but otherwise leave the code unchanged.

In contrast, here, you at least add a new compatible string. And the diff is so big it gets easily lost - e.g. while reviewing. That makes reviewing patches rather annoying: I cannot trust this patch only does what the commit message says :-(

Regards,
Simon

Quoted 109 lines
drivers/ddr/altera/sdram_soc64.c new file +13 -0
+	{ /* sentinel */ }
+};
+
+U_BOOT_DRIVER(altera_sdram) = {
+	.name = "altr_sdr_ctl",
+	.id = UCLASS_RAM,
+	.of_match = altera_sdram_ids,
+	.ops = &altera_sdram_ops,
+	.ofdata_to_platdata = altera_sdram_ofdata_to_platdata,
+	.platdata_auto_alloc_size = sizeof(struct altera_sdram_platdata),
+	.probe = altera_sdram_probe,
+	.priv_auto_alloc_size = sizeof(struct altera_sdram_priv),
+};
drivers/ddr/altera/sdram_soc64.h renamed from drivers/ddr/altera/sdram_s10.h +34 -36
similarity index 79%
copy from drivers/ddr/altera/sdram_s10.h
copy to drivers/ddr/altera/sdram_soc64.h
index 096c06cba2..7d018e76d8 100644
@@ -1,15 +1,24 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
- *
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2017-2019 Intel Corporation <www.intel.com>
   */
 
-#ifndef	_SDRAM_S10_H_
-#define	_SDRAM_S10_H_
+#ifndef	_SDRAM_SOC64_H_
+#define	_SDRAM_SOC64_H_
 
-#define DDR_TWR				15
-#define DDR_READ_LATENCY_DELAY		40
-#define DDR_ACTIVATE_FAWBANK		0x1
+#include <common.h>
+#include <linux/sizes.h>
+
+struct altera_sdram_priv {
+	struct ram_info info;
+	struct reset_ctl_bulk resets;
+};
+
+struct altera_sdram_platdata {
+	void __iomem *hmc;
+	void __iomem *ddr_sch;
+	void __iomem *iomhc;
+};
 
  /* ECC HMC registers */
  #define DDRIOCTRL			0x8
@@ -53,32 +62,6 @@
  		(DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK |	\
  		 DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK)
 
-/* NOC DDR scheduler */
-#define DDR_SCH_ID_COREID		0
-#define DDR_SCH_ID_REVID		0x4
-#define DDR_SCH_DDRCONF			0x8
-#define DDR_SCH_DDRTIMING		0xc
-#define DDR_SCH_DDRMODE			0x10
-#define DDR_SCH_READ_LATENCY		0x14
-#define DDR_SCH_ACTIVATE		0x38
-#define DDR_SCH_DEVTODEV		0x3c
-#define DDR_SCH_DDR4TIMING		0x40
-
-#define DDR_SCH_DDRTIMING_ACTTOACT_OFF		0
-#define DDR_SCH_DDRTIMING_RDTOMISS_OFF		6
-#define DDR_SCH_DDRTIMING_WRTOMISS_OFF		12
-#define DDR_SCH_DDRTIMING_BURSTLEN_OFF		18
-#define DDR_SCH_DDRTIMING_RDTOWR_OFF		21
-#define DDR_SCH_DDRTIMING_WRTORD_OFF		26
-#define DDR_SCH_DDRTIMING_BWRATIO_OFF		31
-#define DDR_SCH_DDRMOD_BWRATIOEXTENDED_OFF	1
-#define DDR_SCH_ACTIVATE_RRD_OFF		0
-#define DDR_SCH_ACTIVATE_FAW_OFF		4
-#define DDR_SCH_ACTIVATE_FAWBANK_OFF		10
-#define DDR_SCH_DEVTODEV_BUSRDTORD_OFF		0
-#define DDR_SCH_DEVTODEV_BUSRDTOWR_OFF		2
-#define DDR_SCH_DEVTODEV_BUSWRTORD_OFF		4
-
  /* HMC MMR IO48 registers */
  #define CTRLCFG0			0x28
  #define CTRLCFG1			0x2c
@@ -185,4 +168,19 @@
  #define FW_HMC_ADAPTOR_REG_ADDR			0xf8020004
  #define FW_HMC_ADAPTOR_MPU_MASK			BIT(0)
 
-#endif /* _SDRAM_S10_H_ */
+u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg);
+u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg);
+u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
+		   u32 data, u32 reg);
+u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
+		   u32 reg);
+int emif_clear(struct altera_sdram_platdata *plat);
+int emif_reset(struct altera_sdram_platdata *plat);
+int poll_hmc_clock_status(void);
+void sdram_clear_mem(phys_addr_t addr, phys_size_t size);
+void sdram_init_ecc_bits(bd_t *bd);
+void sdram_size_check(bd_t *bd);
+phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat);
+int sdram_mmr_init_full(struct udevice *dev);
+
+#endif /* _SDRAM_SOC64_H_ */
#25 lore raw

PATCH v5 14/19 ddr: altera: Restructure Stratix 10 SDRAM driver

Quoted 836 lines · Simon Goldschmidt

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 819 lines

Restructure Stratix 10 SDRAM driver. Move common code to separate file, in preparation to support SDRAM driver for Agilex.

---
v3:
- Change sdram_common.* to sdram_soc64.*

---
  drivers/ddr/altera/Makefile                   |   2 +-
  drivers/ddr/altera/sdram_s10.c                | 296 +----------------
  drivers/ddr/altera/sdram_s10.h                | 148 +--------
  drivers/ddr/altera/sdram_soc64.c              | 304 ++++++++++++++++++
  .../ddr/altera/{sdram_s10.h => sdram_soc64.h} |  70 ++--
  5 files changed, 341 insertions(+), 479 deletions(-)

create mode 100644 drivers/ddr/altera/sdram_soc64.c copy drivers/ddr/altera/{sdram_s10.h => sdram_soc64.h} (79%)

drivers/ddr/altera/Makefile +1 -1
index 341ac0d73b..eb8da13b7d 100644
@@ -9,5 +9,5 @@
  ifdef CONFIG_$(SPL_)ALTERA_SDRAM
  obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
  obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
-obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_s10.o
+obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o
  endif
drivers/ddr/altera/sdram_s10.c +1 -295
index 9578aa743d..fcab3ae3e4 100644
@@ -14,28 +14,14 @@
  #include "sdram_s10.h"
  #include <wait_bit.h>
  #include <asm/arch/firewall.h>
-#include <asm/arch/system_manager.h>
  #include <asm/arch/reset_manager.h>
  #include <asm/io.h>
  #include <linux/sizes.h>
 
-struct altera_sdram_priv {
-     struct ram_info info;
-     struct reset_ctl_bulk resets;
-};
-
-struct altera_sdram_platdata {
-     void __iomem *hmc;
-     void __iomem *ddr_sch;
-     void __iomem *iomhc;
-};
-
  DECLARE_GLOBAL_DATA_PTR;
 
  #define DDR_CONFIG(A, B, C, R)      (((A) << 24) | ((B) << 16) | ((C) << 8) | (R))
 
-#define PGTABLE_OFF  0x4000
-
  /* The followring are the supported configurations */
  u32 ddr_config[] = {
      /* DDR_CONFIG(Address order,Bank,Column,Row) */
@@ -62,28 +48,6 @@ u32 ddr_config[] = {
      DDR_CONFIG(1, 4, 10, 17),
  };
 
-static u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg)
-{
-     return readl(plat->iomhc + reg);
-}
-
-static u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg)
-{
-     return readl(plat->hmc + reg);
-}
-
-static u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
-                       u32 data, u32 reg)
-{
-     return writel(data, plat->hmc + reg);
-}
-
-static u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
-                       u32 reg)
-{
-     return writel(data, plat->ddr_sch + reg);
-}
-
  int match_ddr_conf(u32 ddr_conf)
  {
      int i;
@@ -95,193 +59,12 @@ int match_ddr_conf(u32 ddr_conf)
      return 0;
  }
 
-static int emif_clear(struct altera_sdram_platdata *plat)
-{
-     hmc_ecc_writel(plat, 0, RSTHANDSHAKECTRL);
-
-     return wait_for_bit_le32((const void *)(plat->hmc +
-                              RSTHANDSHAKESTAT),
-                              DDR_HMC_RSTHANDSHAKE_MASK,
-                              false, 1000, false);
-}
-
-static int emif_reset(struct altera_sdram_platdata *plat)
-{
-     u32 c2s, s2c, ret;
-
-     c2s = hmc_ecc_readl(plat, RSTHANDSHAKECTRL) & DDR_HMC_RSTHANDSHAKE_MASK;
-     s2c = hmc_ecc_readl(plat, RSTHANDSHAKESTAT) & DDR_HMC_RSTHANDSHAKE_MASK;
-
-     debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
-           c2s, s2c, hmc_readl(plat, NIOSRESERVED0),
-           hmc_readl(plat, NIOSRESERVED1), hmc_readl(plat, NIOSRESERVED2),
-           hmc_readl(plat, DRAMSTS));
-
-     if (s2c && emif_clear(plat)) {
-             printf("DDR: emif_clear() failed\n");
-             return -1;
-     }
-
-     debug("DDR: Triggerring emif reset\n");
-     hmc_ecc_writel(plat, DDR_HMC_CORE2SEQ_INT_REQ, RSTHANDSHAKECTRL);
-
-     /* if seq2core[3] = 0, we are good */
-     ret = wait_for_bit_le32((const void *)(plat->hmc +
-                              RSTHANDSHAKESTAT),
-                              DDR_HMC_SEQ2CORE_INT_RESP_MASK,
-                              false, 1000, false);
-     if (ret) {
-             printf("DDR: failed to get ack from EMIF\n");
-             return ret;
-     }
-
-     ret = emif_clear(plat);
-     if (ret) {
-             printf("DDR: emif_clear() failed\n");
-             return ret;
-     }
-
-     debug("DDR: %s triggered successly\n", __func__);
-     return 0;
-}
-
-static int poll_hmc_clock_status(void)
-{
-     return wait_for_bit_le32((const void *)(socfpga_sysmgr_base +
-                              SYSMGR_SOC64_HMC_CLK),
-                              SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
-}
-
-static void sdram_clear_mem(phys_addr_t addr, phys_size_t size)
-{
-     phys_size_t i;
-
-     if (addr % CONFIG_SYS_CACHELINE_SIZE) {
-             printf("DDR: address 0x%llx is not cacheline size aligned.\n",
-                    addr);
-             hang();
-     }
-
-     if (size % CONFIG_SYS_CACHELINE_SIZE) {
-             printf("DDR: size 0x%llx is not multiple of cacheline size\n",
-                    size);
-             hang();
-     }
-
-     /* Use DC ZVA instruction to clear memory to zeros by a cache line */
-     for (i = 0; i < size; i = i + CONFIG_SYS_CACHELINE_SIZE) {
-             asm volatile("dc zva, %0"
-                  :
-                  : "r"(addr)
-                  : "memory");
-             addr += CONFIG_SYS_CACHELINE_SIZE;
-     }
-}
-
-static void sdram_init_ecc_bits(bd_t *bd)
-{
-     phys_size_t size, size_init;
-     phys_addr_t start_addr;
-     int bank = 0;
-     unsigned int start = get_timer(0);
-
-     icache_enable();
-
-     start_addr = bd->bi_dram[0].start;
-     size = bd->bi_dram[0].size;
-
-     /* Initialize small block for page table */
-     memset((void *)start_addr, 0, PGTABLE_SIZE + PGTABLE_OFF);
-     gd->arch.tlb_addr = start_addr + PGTABLE_OFF;
-     gd->arch.tlb_size = PGTABLE_SIZE;
-     start_addr += PGTABLE_SIZE + PGTABLE_OFF;
-     size -= (PGTABLE_OFF + PGTABLE_SIZE);
-     dcache_enable();
-
-     while (1) {
-             while (size) {
-                     size_init = min((phys_addr_t)SZ_1G, (phys_addr_t)size);
-                     sdram_clear_mem(start_addr, size_init);
-                     size -= size_init;
-                     start_addr += size_init;
-                     WATCHDOG_RESET();
-             }
-
-             bank++;
-             if (bank >= CONFIG_NR_DRAM_BANKS)
-                     break;
-
-             start_addr = bd->bi_dram[bank].start;
-             size = bd->bi_dram[bank].size;
-     }
-
-     dcache_disable();
-     icache_disable();
-
-     printf("SDRAM-ECC: Initialized success with %d ms\n",
-            (unsigned int)get_timer(start));
-}
-
-static void sdram_size_check(bd_t *bd)
-{
-     phys_size_t total_ram_check = 0;
-     phys_size_t ram_check = 0;
-     phys_addr_t start = 0;
-     int bank;
-
-     /* Sanity check ensure correct SDRAM size specified */
-     debug("DDR: Running SDRAM size sanity check\n");
-
-     for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-             start = bd->bi_dram[bank].start;
-             while (ram_check < bd->bi_dram[bank].size) {
-                     ram_check += get_ram_size((void *)(start + ram_check),
-                                              (phys_size_t)SZ_1G);
-             }
-             total_ram_check += ram_check;
-             ram_check = 0;
-     }
-
-     /* If the ram_size is 2GB smaller, we can assume the IO space is
-      * not mapped in.  gd->ram_size is the actual size of the dram
-      * not the accessible size.
-      */
-     if (total_ram_check != gd->ram_size) {
-             puts("DDR: SDRAM size check failed!\n");
-             hang();
-     }
-
-     debug("DDR: SDRAM size check passed!\n");
-}
-
-/**
- * sdram_calculate_size() - Calculate SDRAM size
- *
- * Calculate SDRAM device size based on SDRAM controller parameters.
- * Size is specified in bytes.
- */
-static phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat)
-{
-     u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
-
-     phys_size_t size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
-                      DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
-                      DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
-                      DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
-                      DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
-
-     size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
-                     DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
-
-     return size;
-}
-
  /**
   * sdram_mmr_init_full() - Function to initialize SDRAM MMR
   *
   * Initialize the SDRAM MMR.
   */
-static int sdram_mmr_init_full(struct udevice *dev)
+int sdram_mmr_init_full(struct udevice *dev)
  {
      struct altera_sdram_platdata *plat = dev->platdata;
      struct altera_sdram_priv *priv = dev_get_priv(dev);
@@ -534,80 +317,3 @@ static int sdram_mmr_init_full(struct udevice *dev)
      return 0;
  }
 
-static int altera_sdram_ofdata_to_platdata(struct udevice *dev)
-{
-     struct altera_sdram_platdata *plat = dev->platdata;
-     fdt_addr_t addr;
-
-     addr = dev_read_addr_index(dev, 0);
-     if (addr == FDT_ADDR_T_NONE)
-             return -EINVAL;
-     plat->ddr_sch = (void __iomem *)addr;
-
-     addr = dev_read_addr_index(dev, 1);
-     if (addr == FDT_ADDR_T_NONE)
-             return -EINVAL;
-     plat->iomhc = (void __iomem *)addr;
-
-     addr = dev_read_addr_index(dev, 2);
-     if (addr == FDT_ADDR_T_NONE)
-             return -EINVAL;
-     plat->hmc = (void __iomem *)addr;
-
-     return 0;
-}
-
-static int altera_sdram_probe(struct udevice *dev)
-{
-     int ret;
-     struct altera_sdram_priv *priv = dev_get_priv(dev);
-
-     ret = reset_get_bulk(dev, &priv->resets);
-     if (ret) {
-             dev_err(dev, "Can't get reset: %d\n", ret);
-             return -ENODEV;
-     }
-     reset_deassert_bulk(&priv->resets);
-
-     if (sdram_mmr_init_full(dev) != 0) {
-             puts("SDRAM init failed.\n");
-             goto failed;
-     }
-
-     return 0;
-
-failed:
-     reset_release_bulk(&priv->resets);
-     return -ENODEV;
-}
-
-static int altera_sdram_get_info(struct udevice *dev,
-                              struct ram_info *info)
-{
-     struct altera_sdram_priv *priv = dev_get_priv(dev);
-
-     info->base = priv->info.base;
-     info->size = priv->info.size;
-
-     return 0;
-}
-
-static struct ram_ops altera_sdram_ops = {
-     .get_info = altera_sdram_get_info,
-};
-
-static const struct udevice_id altera_sdram_ids[] = {
-     { .compatible = "altr,sdr-ctl-s10" },
-     { /* sentinel */ }
-};
-
-U_BOOT_DRIVER(altera_sdram) = {
-     .name = "altr_sdr_ctl",
-     .id = UCLASS_RAM,
-     .of_match = altera_sdram_ids,
-     .ops = &altera_sdram_ops,
-     .ofdata_to_platdata = altera_sdram_ofdata_to_platdata,
-     .platdata_auto_alloc_size = sizeof(struct altera_sdram_platdata),
-     .probe = altera_sdram_probe,
-     .priv_auto_alloc_size = sizeof(struct altera_sdram_priv),
-};
drivers/ddr/altera/sdram_s10.h +1 -147
index 096c06cba2..cca4cb35ec 100644
@@ -11,48 +11,6 @@
  #define DDR_READ_LATENCY_DELAY              40
  #define DDR_ACTIVATE_FAWBANK                0x1
 
-/* ECC HMC registers */
-#define DDRIOCTRL                    0x8
-#define DDRCALSTAT                   0xc
-#define DRAMADDRWIDTH                        0xe0
-#define ECCCTRL1                     0x100
-#define ECCCTRL2                     0x104
-#define ERRINTEN                     0x110
-#define ERRINTENS                    0x114
-#define INTMODE                              0x11c
-#define INTSTAT                              0x120
-#define AUTOWB_CORRADDR                      0x138
-#define ECC_REG2WRECCDATABUS         0x144
-#define ECC_DIAGON                   0x150
-#define ECC_DECSTAT                  0x154
-#define HPSINTFCSEL                  0x210
-#define RSTHANDSHAKECTRL             0x214
-#define RSTHANDSHAKESTAT             0x218
-
-#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK         0x00000003
-#define DDR_HMC_DDRCALSTAT_CAL_MSK           BIT(0)
-#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK   BIT(16)
-#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK               BIT(8)
-#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK                BIT(0)
-#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK               BIT(8)
-#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK               BIT(0)
-#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK      BIT(16)
-#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK       BIT(0)
-#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK        BIT(0)
-#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK        BIT(1)
-#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK     BIT(0)
-#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK     BIT(1)
-#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK   BIT(16)
-#define DDR_HMC_INTMODE_INTMODE_SET_MSK              BIT(0)
-#define DDR_HMC_RSTHANDSHAKE_MASK            0x000000ff
-#define DDR_HMC_CORE2SEQ_INT_REQ             0xF
-#define DDR_HMC_SEQ2CORE_INT_RESP_MASK               BIT(3)
-#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK              0x001f1f1f
-
-#define      DDR_HMC_ERRINTEN_INTMASK                                \
-             (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK |        \
-              DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK)
-
  /* NOC DDR scheduler */
  #define DDR_SCH_ID_COREID           0
  #define DDR_SCH_ID_REVID            0x4
@@ -79,110 +37,6 @@
  #define DDR_SCH_DEVTODEV_BUSRDTOWR_OFF              2
  #define DDR_SCH_DEVTODEV_BUSWRTORD_OFF              4
 
-/* HMC MMR IO48 registers */
-#define CTRLCFG0                     0x28
-#define CTRLCFG1                     0x2c
-#define DRAMTIMING0                  0x50
-#define CALTIMING0                   0x7c
-#define CALTIMING1                   0x80
-#define CALTIMING2                   0x84
-#define CALTIMING3                   0x88
-#define CALTIMING4                   0x8c
-#define CALTIMING9                   0xa0
-#define DRAMADDRW                    0xa8
-#define DRAMSTS                              0xec
-#define NIOSRESERVED0                        0x110
-#define NIOSRESERVED1                        0x114
-#define NIOSRESERVED2                        0x118
-
-#define DRAMADDRW_CFG_COL_ADDR_WIDTH(x)                      \
-     (((x) >> 0) & 0x1F)
-#define DRAMADDRW_CFG_ROW_ADDR_WIDTH(x)                      \
-     (((x) >> 5) & 0x1F)
-#define DRAMADDRW_CFG_BANK_ADDR_WIDTH(x)             \
-     (((x) >> 10) & 0xF)
-#define DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(x)         \
-     (((x) >> 14) & 0x3)
-#define DRAMADDRW_CFG_CS_ADDR_WIDTH(x)                       \
-     (((x) >> 16) & 0x7)
-
-#define CTRLCFG0_CFG_MEMTYPE(x)                              \
-     (((x) >> 0) & 0xF)
-#define CTRLCFG0_CFG_DIMM_TYPE(x)                    \
-     (((x) >> 4) & 0x7)
-#define CTRLCFG0_CFG_AC_POS(x)                               \
-     (((x) >> 7) & 0x3)
-#define CTRLCFG0_CFG_CTRL_BURST_LEN(x)                       \
-     (((x) >> 9) & 0x1F)
-
-#define CTRLCFG1_CFG_DBC3_BURST_LEN(x)                       \
-     (((x) >> 0) & 0x1F)
-#define CTRLCFG1_CFG_ADDR_ORDER(x)                   \
-     (((x) >> 5) & 0x3)
-#define CTRLCFG1_CFG_CTRL_EN_ECC(x)                  \
-     (((x) >> 7) & 0x1)
-
-#define DRAMTIMING0_CFG_TCL(x)                               \
-     (((x) >> 0) & 0x7F)
-
-#define CALTIMING0_CFG_ACT_TO_RDWR(x)                        \
-     (((x) >> 0) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_PCH(x)                 \
-     (((x) >> 6) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_ACT(x)                 \
-     (((x) >> 12) & 0x3F)
-#define CALTIMING0_CFG_ACT_TO_ACT_DB(x)                      \
-     (((x) >> 18) & 0x3F)
-
-#define CALTIMING1_CFG_RD_TO_RD(x)                   \
-     (((x) >> 0) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_RD_DC(x)                        \
-     (((x) >> 6) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_RD_DB(x)                        \
-     (((x) >> 12) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_WR(x)                   \
-     (((x) >> 18) & 0x3F)
-#define CALTIMING1_CFG_RD_TO_WR_DC(x)                        \
-     (((x) >> 24) & 0x3F)
-
-#define CALTIMING2_CFG_RD_TO_WR_DB(x)                        \
-     (((x) >> 0) & 0x3F)
-#define CALTIMING2_CFG_RD_TO_WR_PCH(x)                       \
-     (((x) >> 6) & 0x3F)
-#define CALTIMING2_CFG_RD_AP_TO_VALID(x)             \
-     (((x) >> 12) & 0x3F)
-#define CALTIMING2_CFG_WR_TO_WR(x)                   \
-     (((x) >> 18) & 0x3F)
-#define CALTIMING2_CFG_WR_TO_WR_DC(x)                        \
-     (((x) >> 24) & 0x3F)
-
-#define CALTIMING3_CFG_WR_TO_WR_DB(x)                        \
-     (((x) >> 0) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD(x)                   \
-     (((x) >> 6) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD_DC(x)                        \
-     (((x) >> 12) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_RD_DB(x)                        \
-     (((x) >> 18) & 0x3F)
-#define CALTIMING3_CFG_WR_TO_PCH(x)                  \
-     (((x) >> 24) & 0x3F)
-
-#define CALTIMING4_CFG_WR_AP_TO_VALID(x)             \
-     (((x) >> 0) & 0x3F)
-#define CALTIMING4_CFG_PCH_TO_VALID(x)                       \
-     (((x) >> 6) & 0x3F)
-#define CALTIMING4_CFG_PCH_ALL_TO_VALID(x)           \
-     (((x) >> 12) & 0x3F)
-#define CALTIMING4_CFG_ARF_TO_VALID(x)                       \
-     (((x) >> 18) & 0xFF)
-#define CALTIMING4_CFG_PDN_TO_VALID(x)                       \
-     (((x) >> 26) & 0x3F)
-
-#define CALTIMING9_CFG_4_ACT_TO_ACT(x)                       \
-     (((x) >> 0) & 0xFF)
-
-/* Firewall DDR scheduler MPFE */
-#define FW_HMC_ADAPTOR_REG_ADDR                      0xf8020004
-#define FW_HMC_ADAPTOR_MPU_MASK                      BIT(0)
+#include "sdram_soc64.h"
 
  #endif /* _SDRAM_S10_H_ */
drivers/ddr/altera/sdram_soc64.c new file +281 -0
new file mode 100644
index 0000000000..3097e0671c
@@ -0,0 +1,304 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <div64.h>
+#include <fdtdec.h>
+#include <ram.h>
+#include <reset.h>
+#include "sdram_soc64.h"
+#include <wait_bit.h>
+#include <asm/arch/firewall.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/io.h>
+#include <linux/sizes.h>
+
+#define PGTABLE_OFF  0x4000
+
+u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg)
+{
+     return readl(plat->iomhc + reg);
+}
+
+u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg)
+{
+     return readl(plat->hmc + reg);
+}
+
+u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
+                u32 data, u32 reg)
+{
+     return writel(data, plat->hmc + reg);
+}
+
+u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
+                u32 reg)
+{
+     return writel(data, plat->ddr_sch + reg);
+}
+
+int emif_clear(struct altera_sdram_platdata *plat)
+{
+     hmc_ecc_writel(plat, 0, RSTHANDSHAKECTRL);
+
+     return wait_for_bit_le32((const void *)(plat->hmc +
+                              RSTHANDSHAKESTAT),
+                              DDR_HMC_RSTHANDSHAKE_MASK,
+                              false, 1000, false);
+}
+
+int emif_reset(struct altera_sdram_platdata *plat)
+{
+     u32 c2s, s2c, ret;
+
+     c2s = hmc_ecc_readl(plat, RSTHANDSHAKECTRL) & DDR_HMC_RSTHANDSHAKE_MASK;
+     s2c = hmc_ecc_readl(plat, RSTHANDSHAKESTAT) & DDR_HMC_RSTHANDSHAKE_MASK;
+
+     debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
+           c2s, s2c, hmc_readl(plat, NIOSRESERVED0),
+           hmc_readl(plat, NIOSRESERVED1), hmc_readl(plat, NIOSRESERVED2),
+           hmc_readl(plat, DRAMSTS));
+
+     if (s2c && emif_clear(plat)) {
+             printf("DDR: emif_clear() failed\n");
+             return -1;
+     }
+
+     debug("DDR: Triggerring emif reset\n");
+     hmc_ecc_writel(plat, DDR_HMC_CORE2SEQ_INT_REQ, RSTHANDSHAKECTRL);
+
+     /* if seq2core[3] = 0, we are good */
+     ret = wait_for_bit_le32((const void *)(plat->hmc +
+                              RSTHANDSHAKESTAT),
+                              DDR_HMC_SEQ2CORE_INT_RESP_MASK,
+                              false, 1000, false);
+     if (ret) {
+             printf("DDR: failed to get ack from EMIF\n");
+             return ret;
+     }
+
+     ret = emif_clear(plat);
+     if (ret) {
+             printf("DDR: emif_clear() failed\n");
+             return ret;
+     }
+
+     debug("DDR: %s triggered successly\n", __func__);
+     return 0;
+}
+
+int poll_hmc_clock_status(void)
+{
+     return wait_for_bit_le32((const void *)(socfpga_sysmgr_base +
+                              SYSMGR_SOC64_HMC_CLK),
+                              SYSMGR_HMC_CLK_STATUS_MSK, true, 1000, false);
+}
+
+void sdram_clear_mem(phys_addr_t addr, phys_size_t size)
+{
+     phys_size_t i;
+
+     if (addr % CONFIG_SYS_CACHELINE_SIZE) {
+             printf("DDR: address 0x%llx is not cacheline size aligned.\n",
+                    addr);
+             hang();
+     }
+
+     if (size % CONFIG_SYS_CACHELINE_SIZE) {
+             printf("DDR: size 0x%llx is not multiple of cacheline size\n",
+                    size);
+             hang();
+     }
+
+     /* Use DC ZVA instruction to clear memory to zeros by a cache line */
+     for (i = 0; i < size; i = i + CONFIG_SYS_CACHELINE_SIZE) {
+             asm volatile("dc zva, %0"
+                  :
+                  : "r"(addr)
+                  : "memory");
+             addr += CONFIG_SYS_CACHELINE_SIZE;
+     }
+}
+
+void sdram_init_ecc_bits(bd_t *bd)
+{
+     phys_size_t size, size_init;
+     phys_addr_t start_addr;
+     int bank = 0;
+     unsigned int start = get_timer(0);
+
+     icache_enable();
+
+     start_addr = bd->bi_dram[0].start;
+     size = bd->bi_dram[0].size;
+
+     /* Initialize small block for page table */
+     memset((void *)start_addr, 0, PGTABLE_SIZE + PGTABLE_OFF);
+     gd->arch.tlb_addr = start_addr + PGTABLE_OFF;
+     gd->arch.tlb_size = PGTABLE_SIZE;
+     start_addr += PGTABLE_SIZE + PGTABLE_OFF;
+     size -= (PGTABLE_OFF + PGTABLE_SIZE);
+     dcache_enable();
+
+     while (1) {
+             while (size) {
+                     size_init = min((phys_addr_t)SZ_1G, (phys_addr_t)size);
+                     sdram_clear_mem(start_addr, size_init);
+                     size -= size_init;
+                     start_addr += size_init;
+                     WATCHDOG_RESET();
+             }
+
+             bank++;
+             if (bank >= CONFIG_NR_DRAM_BANKS)
+                     break;
+
+             start_addr = bd->bi_dram[bank].start;
+             size = bd->bi_dram[bank].size;
+     }
+
+     dcache_disable();
+     icache_disable();
+
+     printf("SDRAM-ECC: Initialized success with %d ms\n",
+            (unsigned int)get_timer(start));
+}
+
+void sdram_size_check(bd_t *bd)
+{
+     phys_size_t total_ram_check = 0;
+     phys_size_t ram_check = 0;
+     phys_addr_t start = 0;
+     int bank;
+
+     /* Sanity check ensure correct SDRAM size specified */
+     debug("DDR: Running SDRAM size sanity check\n");
+
+     for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+             start = bd->bi_dram[bank].start;
+             while (ram_check < bd->bi_dram[bank].size) {
+                     ram_check += get_ram_size((void *)(start + ram_check),
+                                              (phys_size_t)SZ_1G);
+             }
+             total_ram_check += ram_check;
+             ram_check = 0;
+     }
+
+     /* If the ram_size is 2GB smaller, we can assume the IO space is
+      * not mapped in.  gd->ram_size is the actual size of the dram
+      * not the accessible size.
+      */
+     if (total_ram_check != gd->ram_size) {
+             puts("DDR: SDRAM size check failed!\n");
+             hang();
+     }
+
+     debug("DDR: SDRAM size check passed!\n");
+}
+
+/**
+ * sdram_calculate_size() - Calculate SDRAM size
+ *
+ * Calculate SDRAM device size based on SDRAM controller parameters.
+ * Size is specified in bytes.
+ */
+phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat)
+{
+     u32 dramaddrw = hmc_readl(plat, DRAMADDRW);
+
+     phys_size_t size = 1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH(dramaddrw) +
+                      DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH(dramaddrw) +
+                      DRAMADDRW_CFG_BANK_ADDR_WIDTH(dramaddrw) +
+                      DRAMADDRW_CFG_ROW_ADDR_WIDTH(dramaddrw) +
+                      DRAMADDRW_CFG_COL_ADDR_WIDTH(dramaddrw));
+
+     size *= (2 << (hmc_ecc_readl(plat, DDRIOCTRL) &
+                     DDR_HMC_DDRIOCTRL_IOSIZE_MSK));
+
+     return size;
+}
+
+static int altera_sdram_ofdata_to_platdata(struct udevice *dev)
+{
+     struct altera_sdram_platdata *plat = dev->platdata;
+     fdt_addr_t addr;
+
+     addr = dev_read_addr_index(dev, 0);
+     if (addr == FDT_ADDR_T_NONE)
+             return -EINVAL;
+     plat->ddr_sch = (void __iomem *)addr;
+
+     addr = dev_read_addr_index(dev, 1);
+     if (addr == FDT_ADDR_T_NONE)
+             return -EINVAL;
+     plat->iomhc = (void __iomem *)addr;
+
+     addr = dev_read_addr_index(dev, 2);
+     if (addr == FDT_ADDR_T_NONE)
+             return -EINVAL;
+     plat->hmc = (void __iomem *)addr;
+
+     return 0;
+}
+
+static int altera_sdram_probe(struct udevice *dev)
+{
+     int ret;
+     struct altera_sdram_priv *priv = dev_get_priv(dev);
+
+     ret = reset_get_bulk(dev, &priv->resets);
+     if (ret) {
+             dev_err(dev, "Can't get reset: %d\n", ret);
+             return -ENODEV;
+     }
+     reset_deassert_bulk(&priv->resets);
+
+     if (sdram_mmr_init_full(dev) != 0) {
+             puts("SDRAM init failed.\n");
+             goto failed;
+     }
+
+     return 0;
+
+failed:
+     reset_release_bulk(&priv->resets);
+     return -ENODEV;
+}
+
+static int altera_sdram_get_info(struct udevice *dev,
+                              struct ram_info *info)
+{
+     struct altera_sdram_priv *priv = dev_get_priv(dev);
+
+     info->base = priv->info.base;
+     info->size = priv->info.size;
+

drivers/ddr/altera/sdram_soc64.c line 291

Quoted 10 lines
drivers/ddr/altera/sdram_soc64.c new file +10 -0
+     return 0;
+}
+
+static struct ram_ops altera_sdram_ops = {
+     .get_info = altera_sdram_get_info,
+};
+
+static const struct udevice_id altera_sdram_ids[] = {
+     { .compatible = "altr,sdr-ctl-s10" },
+     { .compatible = "intel,sdr-ctl-agilex" },

Sigh, so this is *not* what the commit message says. Please keep changes separate. This patch should merely move code (like the commit message says) but otherwise leave the code unchanged.

Quoted 4 lines

In contrast, here, you at least add a new compatible string. And the diff is so big it gets easily lost - e.g. while reviewing. That makes reviewing patches rather annoying: I cannot trust this patch only does what the commit message says :-(

Good catch. It is included to this patch by accident. Will change it.

Thanks.

Regards
Ley Foon

Quoted 111 lines
Quoted 110 lines
drivers/ddr/altera/sdram_soc64.c new file +13 -0
+     { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(altera_sdram) = {
+     .name = "altr_sdr_ctl",
+     .id = UCLASS_RAM,
+     .of_match = altera_sdram_ids,
+     .ops = &altera_sdram_ops,
+     .ofdata_to_platdata = altera_sdram_ofdata_to_platdata,
+     .platdata_auto_alloc_size = sizeof(struct altera_sdram_platdata),
+     .probe = altera_sdram_probe,
+     .priv_auto_alloc_size = sizeof(struct altera_sdram_priv),
+};
drivers/ddr/altera/sdram_soc64.h renamed from drivers/ddr/altera/sdram_s10.h +34 -36
similarity index 79%
copy from drivers/ddr/altera/sdram_s10.h
copy to drivers/ddr/altera/sdram_soc64.h
index 096c06cba2..7d018e76d8 100644
@@ -1,15 +1,24 @@
-/* SPDX-License-Identifier: GPL-2.0
- *
- * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
- *
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2017-2019 Intel Corporation <www.intel.com>
   */
 
-#ifndef      _SDRAM_S10_H_
-#define      _SDRAM_S10_H_
+#ifndef      _SDRAM_SOC64_H_
+#define      _SDRAM_SOC64_H_
 
-#define DDR_TWR                              15
-#define DDR_READ_LATENCY_DELAY               40
-#define DDR_ACTIVATE_FAWBANK         0x1
+#include <common.h>
+#include <linux/sizes.h>
+
+struct altera_sdram_priv {
+     struct ram_info info;
+     struct reset_ctl_bulk resets;
+};
+
+struct altera_sdram_platdata {
+     void __iomem *hmc;
+     void __iomem *ddr_sch;
+     void __iomem *iomhc;
+};
 
  /* ECC HMC registers */
  #define DDRIOCTRL                   0x8
@@ -53,32 +62,6 @@
              (DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK |        \
               DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK)
 
-/* NOC DDR scheduler */
-#define DDR_SCH_ID_COREID            0
-#define DDR_SCH_ID_REVID             0x4
-#define DDR_SCH_DDRCONF                      0x8
-#define DDR_SCH_DDRTIMING            0xc
-#define DDR_SCH_DDRMODE                      0x10
-#define DDR_SCH_READ_LATENCY         0x14
-#define DDR_SCH_ACTIVATE             0x38
-#define DDR_SCH_DEVTODEV             0x3c
-#define DDR_SCH_DDR4TIMING           0x40
-
-#define DDR_SCH_DDRTIMING_ACTTOACT_OFF               0
-#define DDR_SCH_DDRTIMING_RDTOMISS_OFF               6
-#define DDR_SCH_DDRTIMING_WRTOMISS_OFF               12
-#define DDR_SCH_DDRTIMING_BURSTLEN_OFF               18
-#define DDR_SCH_DDRTIMING_RDTOWR_OFF         21
-#define DDR_SCH_DDRTIMING_WRTORD_OFF         26
-#define DDR_SCH_DDRTIMING_BWRATIO_OFF                31
-#define DDR_SCH_DDRMOD_BWRATIOEXTENDED_OFF   1
-#define DDR_SCH_ACTIVATE_RRD_OFF             0
-#define DDR_SCH_ACTIVATE_FAW_OFF             4
-#define DDR_SCH_ACTIVATE_FAWBANK_OFF         10
-#define DDR_SCH_DEVTODEV_BUSRDTORD_OFF               0
-#define DDR_SCH_DEVTODEV_BUSRDTOWR_OFF               2
-#define DDR_SCH_DEVTODEV_BUSWRTORD_OFF               4
-
  /* HMC MMR IO48 registers */
  #define CTRLCFG0                    0x28
  #define CTRLCFG1                    0x2c
@@ -185,4 +168,19 @@
  #define FW_HMC_ADAPTOR_REG_ADDR                     0xf8020004
  #define FW_HMC_ADAPTOR_MPU_MASK                     BIT(0)
 
-#endif /* _SDRAM_S10_H_ */
+u32 hmc_readl(struct altera_sdram_platdata *plat, u32 reg);
+u32 hmc_ecc_readl(struct altera_sdram_platdata *plat, u32 reg);
+u32 hmc_ecc_writel(struct altera_sdram_platdata *plat,
+                u32 data, u32 reg);
+u32 ddr_sch_writel(struct altera_sdram_platdata *plat, u32 data,
+                u32 reg);
+int emif_clear(struct altera_sdram_platdata *plat);
+int emif_reset(struct altera_sdram_platdata *plat);
+int poll_hmc_clock_status(void);
+void sdram_clear_mem(phys_addr_t addr, phys_size_t size);
+void sdram_init_ecc_bits(bd_t *bd);
+void sdram_size_check(bd_t *bd);
+phys_size_t sdram_calculate_size(struct altera_sdram_platdata *plat);
+int sdram_mmr_init_full(struct udevice *dev);
+
+#endif /* _SDRAM_SOC64_H_ */
#26 lore raw

PATCH v5 15/19 ddr: altera: agilex: Add SDRAM driver for Agilex

In reply to Ley Foon Tan

Add SDRAM driver for Agilex SoC.

---
v4:
- Fixed checkpatch warnings

v3:
- Use sdmmc_soc64.*
- Change compatible string to use "intel" (intel,sdr-ctl-agilex).
- Improve error handing if DDR size mismatched.

---
 drivers/ddr/altera/Kconfig        |   6 +-
 drivers/ddr/altera/Makefile       |   1 +
 drivers/ddr/altera/sdram_agilex.c | 168 ++++++++++++++++++++++++++++++
 drivers/ddr/altera/sdram_soc64.h  |   1 +
 4 files changed, 173 insertions(+), 3 deletions(-)
 create mode 100644 drivers/ddr/altera/sdram_agilex.c
drivers/ddr/altera/Kconfig +3 -3
index 2b1c1be3b5..8f590dc5f6 100644
@@ -1,8 +1,8 @@
 config SPL_ALTERA_SDRAM
 	bool "SoCFPGA DDR SDRAM driver in SPL"
 	depends on SPL
-	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10 || TARGET_SOCFPGA_STRATIX10
-	select RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10
-	select SPL_RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10
+	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10 || TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
+	select RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
+	select SPL_RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
 	help
 	  Enable DDR SDRAM controller for the SoCFPGA devices.
drivers/ddr/altera/Makefile +1 -0
index eb8da13b7d..39dfee5d5a 100644
@@ -10,4 +10,5 @@ ifdef CONFIG_$(SPL_)ALTERA_SDRAM
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
 obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_soc64.o sdram_s10.o
+obj-$(CONFIG_TARGET_SOCFPGA_AGILEX) += sdram_soc64.o sdram_agilex.o
 endif
drivers/ddr/altera/sdram_agilex.c new file +168 -0

168 lines not on this page · raw message

drivers/ddr/altera/sdram_soc64.h +1 -0
index 7d018e76d8..7b25a80ae2 100644
@@ -65,6 +65,7 @@ struct altera_sdram_platdata {
 /* HMC MMR IO48 registers */
 #define CTRLCFG0			0x28
 #define CTRLCFG1			0x2c
+#define CTRLCFG3                        0x34
 #define DRAMTIMING0			0x50
 #define CALTIMING0			0x7c
 #define CALTIMING1			0x80
Signature · 1 line
2.19.0
#27 lore raw

PATCH v5 16/19 board: intel: agilex: Add socdk board support for Intel Agilex SoC

In reply to Ley Foon Tan

Add socdk board support for Intel Agilex SoC

---
 board/intel/agilex-socdk/MAINTAINERS | 7 +++++++
 board/intel/agilex-socdk/Makefile    | 7 +++++++
 board/intel/agilex-socdk/socfpga.c   | 7 +++++++
 3 files changed, 21 insertions(+)
 create mode 100644 board/intel/agilex-socdk/MAINTAINERS
 create mode 100644 board/intel/agilex-socdk/Makefile
 create mode 100644 board/intel/agilex-socdk/socfpga.c
board/intel/agilex-socdk/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000000..b8e28f0b24
@@ -0,0 +1,7 @@
+SOCFPGA BOARD
+M:	Ley Foon Tan <[email protected]>
+M:	Chee Hong Ang <[email protected]>
+S:	Maintained
+F:	board/intel/agilex-socdk/
+F:	include/configs/socfpga_agilex_socdk.h
+F:	configs/socfpga_agilex_defconfig
board/intel/agilex-socdk/Makefile new file +7 -0
new file mode 100644
index 0000000000..b86223a571
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2019 Intel Corporation <www.intel.com>
+#
+# SPDX-License-Identifier:	GPL-2.0
+#
+
+obj-y	:= socfpga.o
board/intel/agilex-socdk/socfpga.c new file +7 -0
new file mode 100644
index 0000000000..72a3e0836d
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
Signature · 1 line
2.19.0
#28 lore raw

PATCH v5 17/19 arm: socfpga: agilex: Add SPL for Agilex SoC

In reply to Ley Foon Tan

Add SPL support for Agilex SoC.

---
v5:
- Probe CCU driver with DM method.

v4:
- Move spl_early_init() to entry of board_init_f
- Add socfpga_get_manager_addr().
- Remove SYSMGR_DMA and SYSMGR_DMA_PERIPH, already set in firewall_setup().

v2:
- Change clock driver probing to DM.
- Remove unused OSC1TIMER0 reset
- Remove debug_uart_init(). UART depends on clock driver setup, no point to call debug_uart_init() after spl_early_init() and clock driver initialization.

---
 arch/arm/mach-socfpga/Makefile     |  3 +
 arch/arm/mach-socfpga/spl_agilex.c | 98 ++++++++++++++++++++++++++++++
 2 files changed, 101 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/spl_agilex.c
arch/arm/mach-socfpga/Makefile +3 -0
index a403b46b47..81b6ffc675 100644
@@ -58,6 +58,9 @@ ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= firewall.o
 obj-y	+= spl_s10.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y	+= spl_agilex.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/spl_agilex.c new file +98 -0

98 lines not on this page · raw message

Signature · 1 line
2.19.0
#29 lore raw

PATCH v5 18/19 arm: dts: agilex: Add base dtsi and devkit dts

In reply to Ley Foon Tan

Add device tree files for Agilex SoC platform.

Based on Linux Commit ID 4b36daf9ada30.

---
v5:
- Add CCU DT node.

v4:
- Add u-boot,dm-pre-reloc to sysmgr node.

v3:
- Fixed bank 1 memory alias base address to 0x280000000.
- Rename STRATIX10_*_CLK to SOCFPGA_SOC64_*_CLK.
- Include socfpga-soc64-clock.h
- Change to "intel,sdr-ctl-agilex" for SDRAM node.

v2:
- Add clock property to device node.
- Change memory size to 8GB
- Enable i2c1

---
 arch/arm/dts/Makefile                         |   1 +
 arch/arm/dts/socfpga_agilex.dtsi              | 500 ++++++++++++++++++
 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi |  79 +++
 arch/arm/dts/socfpga_agilex_socdk.dts         | 136 +++++
 4 files changed, 716 insertions(+)
 create mode 100644 arch/arm/dts/socfpga_agilex.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk.dts
arch/arm/dts/Makefile +1 -0
index 62da168ef8..335b989adc 100644
@@ -309,6 +309,7 @@ dtb-$(CONFIG_TI816X) += dm8168-evm.dtb
 dtb-$(CONFIG_THUNDERX) += thunderx-88xx.dtb
 
 dtb-$(CONFIG_ARCH_SOCFPGA) +=				\
+	socfpga_agilex_socdk.dtb			\
 	socfpga_arria5_socdk.dtb			\
 	socfpga_arria10_socdk_sdmmc.dtb			\
 	socfpga_cyclone5_mcvevk.dtb			\
arch/arm/dts/socfpga_agilex.dtsi new file +500 -0

500 lines not on this page · raw message

arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi new file +79 -0

79 lines not on this page · raw message

arch/arm/dts/socfpga_agilex_socdk.dts new file +136 -0

136 lines not on this page · raw message

Signature · 1 line
2.19.0
#30 lore raw

PATCH v5 19/19 arm: socfpga: agilex: Enable Agilex SoC build

In reply to Ley Foon Tan

Add build support for Agilex SoC.

---
v5:
- Enable NCORE_CACHE

v3:
- Disable CONFIG_USE_TINY_PRINTF

v2:
- Remove IC_CLK define, use clock DM method to get i2c clock
- Change CONFIG_ENV_SIZE to 4KB since CONFIG_SPI_FLASH_USE_4K_SECTORS is enabled.

---
 arch/arm/Kconfig                       |   4 +-
 arch/arm/mach-socfpga/Kconfig          |  16 ++
 arch/arm/mach-socfpga/Makefile         |   9 ++
 configs/socfpga_agilex_defconfig       |  59 +++++++
 include/configs/socfpga_agilex_socdk.h | 207 +++++++++++++++++++++++++
 5 files changed, 293 insertions(+), 2 deletions(-)
 create mode 100644 configs/socfpga_agilex_defconfig
 create mode 100644 include/configs/socfpga_agilex_socdk.h
arch/arm/Kconfig +2 -2
index 3b0e315061..e6c9d19968 100644
@@ -888,7 +888,7 @@ config ARCH_SOCFPGA
 	bool "Altera SOCFPGA family"
 	select ARCH_EARLY_INIT_R
 	select ARCH_MISC_INIT if !TARGET_SOCFPGA_ARRIA10
-	select ARM64 if TARGET_SOCFPGA_STRATIX10
+	select ARM64 if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
 	select CPU_V7A if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	select DM
 	select DM_SERIAL
@@ -900,7 +900,7 @@ config ARCH_SOCFPGA
 	select SPL_LIBGENERIC_SUPPORT
 	select SPL_NAND_SUPPORT if SPL_NAND_DENALI
 	select SPL_OF_CONTROL
-	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
+	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
 	select SPL_SERIAL_SUPPORT
 	select SPL_SYSRESET
 	select SPL_WATCHDOG_SUPPORT
arch/arm/mach-socfpga/Kconfig +16 -0
index 1d914648e3..3f5c4b357f 100644
@@ -26,6 +26,15 @@ config SYS_TEXT_BASE
 	default 0x01000040 if TARGET_SOCFPGA_ARRIA10
 	default 0x01000040 if TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_AGILEX
+	bool
+	select ARMV8_MULTIENTRY
+	select ARMV8_SET_SMPEN
+	select ARMV8_SPIN_TABLE
+	select CLK
+	select NCORE_CACHE
+	select SPL_CLK if SPL
+
 config TARGET_SOCFPGA_ARRIA5
 	bool
 	select TARGET_SOCFPGA_GEN5
@@ -72,6 +81,10 @@ choice
 	prompt "Altera SOCFPGA board select"
 	optional
 
+config TARGET_SOCFPGA_AGILEX_SOCDK
+	bool "Intel SOCFPGA SoCDK (Agilex)"
+	select TARGET_SOCFPGA_AGILEX
+
 config TARGET_SOCFPGA_ARIES_MCVEVK
 	bool "Aries MCVEVK (Cyclone V)"
 	select TARGET_SOCFPGA_CYCLONE5
@@ -132,6 +145,7 @@ config TARGET_SOCFPGA_TERASIC_SOCKIT
 endchoice
 
 config SYS_BOARD
+	default "agilex-socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
 	default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
 	default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -148,6 +162,7 @@ config SYS_BOARD
 	default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
 config SYS_VENDOR
+	default "intel" if TARGET_SOCFPGA_AGILEX_SOCDK
 	default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
 	default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -165,6 +180,7 @@ config SYS_SOC
 	default "socfpga"
 
 config SYS_CONFIG_NAME
+	default "socfpga_agilex_socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
 	default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
 	default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
arch/arm/mach-socfpga/Makefile +9 -0
index 81b6ffc675..418f543b20 100644
@@ -41,6 +41,14 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
 obj-y	+= clock_manager_agilex.o
+obj-y	+= mailbox_s10.o
+obj-y	+= misc_s10.o
+obj-y	+= mmu-arm64_s10.o
+obj-y	+= reset_manager_s10.o
+obj-y	+= system_manager_s10.o
+obj-y	+= timer_s10.o
+obj-y	+= wrap_pinmux_config_s10.o
+obj-y	+= wrap_pll_config_s10.o
 endif
 
 ifdef CONFIG_SPL_BUILD
@@ -59,6 +67,7 @@ obj-y	+= firewall.o
 obj-y	+= spl_s10.o
 endif
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y	+= firewall.o
 obj-y	+= spl_agilex.o
 endif
 endif
configs/socfpga_agilex_defconfig new file +59 -0

59 lines not on this page · raw message

include/configs/socfpga_agilex_socdk.h new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
2.19.0
#31 lore raw

PATCH v5 19/19 arm: socfpga: agilex: Enable Agilex SoC build

include/configs/socfpga_agilex_socdk.h

Quoted 196 lines · Ley Foon Tan

Add build support for Agilex SoC.

---
v5:
- Enable NCORE_CACHE

v3:
- Disable CONFIG_USE_TINY_PRINTF

v2:
- Remove IC_CLK define, use clock DM method to get i2c clock
- Change CONFIG_ENV_SIZE to 4KB since CONFIG_SPI_FLASH_USE_4K_SECTORS is enabled.

---
 arch/arm/Kconfig                       |   4 +-
 arch/arm/mach-socfpga/Kconfig          |  16 ++
 arch/arm/mach-socfpga/Makefile         |   9 ++
 configs/socfpga_agilex_defconfig       |  59 +++++++
 include/configs/socfpga_agilex_socdk.h | 207 +++++++++++++++++++++++++
 5 files changed, 293 insertions(+), 2 deletions(-)
 create mode 100644 configs/socfpga_agilex_defconfig
 create mode 100644 include/configs/socfpga_agilex_socdk.h
arch/arm/Kconfig +2 -2
index 3b0e315061..e6c9d19968 100644
@@ -888,7 +888,7 @@ config ARCH_SOCFPGA
        bool "Altera SOCFPGA family"
        select ARCH_EARLY_INIT_R
        select ARCH_MISC_INIT if !TARGET_SOCFPGA_ARRIA10
-       select ARM64 if TARGET_SOCFPGA_STRATIX10
+       select ARM64 if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
        select CPU_V7A if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
        select DM
        select DM_SERIAL
@@ -900,7 +900,7 @@ config ARCH_SOCFPGA
        select SPL_LIBGENERIC_SUPPORT
        select SPL_NAND_SUPPORT if SPL_NAND_DENALI
        select SPL_OF_CONTROL
-       select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
+       select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
        select SPL_SERIAL_SUPPORT
        select SPL_SYSRESET
        select SPL_WATCHDOG_SUPPORT
arch/arm/mach-socfpga/Kconfig +16 -0
index 1d914648e3..3f5c4b357f 100644
@@ -26,6 +26,15 @@ config SYS_TEXT_BASE
        default 0x01000040 if TARGET_SOCFPGA_ARRIA10
        default 0x01000040 if TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_AGILEX
+       bool
+       select ARMV8_MULTIENTRY
+       select ARMV8_SET_SMPEN
+       select ARMV8_SPIN_TABLE
+       select CLK
+       select NCORE_CACHE
+       select SPL_CLK if SPL
+
 config TARGET_SOCFPGA_ARRIA5
        bool
        select TARGET_SOCFPGA_GEN5
@@ -72,6 +81,10 @@ choice
        prompt "Altera SOCFPGA board select"
        optional
 
+config TARGET_SOCFPGA_AGILEX_SOCDK
+       bool "Intel SOCFPGA SoCDK (Agilex)"
+       select TARGET_SOCFPGA_AGILEX
+
 config TARGET_SOCFPGA_ARIES_MCVEVK
        bool "Aries MCVEVK (Cyclone V)"
        select TARGET_SOCFPGA_CYCLONE5
@@ -132,6 +145,7 @@ config TARGET_SOCFPGA_TERASIC_SOCKIT
 endchoice
 
 config SYS_BOARD
+       default "agilex-socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -148,6 +162,7 @@ config SYS_BOARD
        default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
 config SYS_VENDOR
+       default "intel" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -165,6 +180,7 @@ config SYS_SOC
        default "socfpga"
 
 config SYS_CONFIG_NAME
+       default "socfpga_agilex_socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
arch/arm/mach-socfpga/Makefile +9 -0
index 81b6ffc675..418f543b20 100644
@@ -41,6 +41,14 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
 obj-y  += clock_manager_agilex.o
+obj-y  += mailbox_s10.o
+obj-y  += misc_s10.o
+obj-y  += mmu-arm64_s10.o
+obj-y  += reset_manager_s10.o
+obj-y  += system_manager_s10.o
+obj-y  += timer_s10.o
+obj-y  += wrap_pinmux_config_s10.o
+obj-y  += wrap_pll_config_s10.o
 endif
 
 ifdef CONFIG_SPL_BUILD
@@ -59,6 +67,7 @@ obj-y += firewall.o
 obj-y  += spl_s10.o
 endif
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y  += firewall.o
 obj-y  += spl_agilex.o
 endif
 endif
configs/socfpga_agilex_defconfig new file +59 -0
new file mode 100644
index 0000000000..daf71ff0eb
@@ -0,0 +1,59 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_TEXT_BASE=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_TARGET_SOCFPGA_AGILEX_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_agilex"
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_TEXT_BASE=0xFFE00000
+CONFIG_BOOTDELAY=5
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x3c00000
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="SOCFPGA_AGILEX # "
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_EMBED=y
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_agilex_socdk"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_ALTERA_SDRAM=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SF_DEFAULT_MODE=0x2003
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_MII=y
+CONFIG_DM_RESET=y
+CONFIG_SPI=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_STORAGE=y
+# CONFIG_USE_TINY_PRINTF is not set
include/configs/socfpga_agilex_socdk.h +0 -0

I know I already sent my r-b, but seeing this file and the s10 one are nearly the same, why don't you merge them?

Regards,
Simon

Quoted 215 lines

new file mode 100644
index 0000000000..8ed96ed252

include/configs/socfpga_agilex_socdk.h new file +207 -1
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef __CONFIG_SOCFGPA_AGILEX_H__
+#define __CONFIG_SOCFGPA_AGILEX_H__
+
+#include <asm/arch/base_addr_s10.h>
+#include <asm/arch/handoff_s10.h>
+
+/*
+ * U-Boot general configurations
+ */
+#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#define CONFIG_LOADADDR                        0x2000000
+#define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
+#define CONFIG_REMAKE_ELF
+/* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */
+#define CPU_RELEASE_ADDR               0xFFD12210
+#define CONFIG_SYS_CACHELINE_SIZE      64
+#define CONFIG_SYS_MEM_RESERVE_SECURE  0       /* using OCRAM, not DDR */
+
+/*
+ * U-Boot console configurations
+ */
+#define CONFIG_SYS_MAXARGS             64
+#define CONFIG_SYS_CBSIZE              2048
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
+
+/* Extend size of kernel image for uncompression */
+#define CONFIG_SYS_BOOTM_LEN           (32 * 1024 * 1024)
+
+/*
+ * U-Boot run time memory configurations
+ */
+#define CONFIG_SYS_INIT_RAM_ADDR       0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE       0x40000
+#define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INIT_RAM_ADDR  \
+                                       + CONFIG_SYS_INIT_RAM_SIZE \
+                                       - S10_HANDOFF_SIZE)
+#define CONFIG_SYS_INIT_SP_OFFSET      (CONFIG_SYS_INIT_SP_ADDR)
+#define CONFIG_SYS_MALLOC_LEN          (5 * 1024 * 1024)
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_SYS_MMC_ENV_DEV         0       /* device 0 */
+#define CONFIG_ENV_OFFSET              512     /* just after the MBR */
+
+/*
+ * QSPI support
+ */
+ #ifdef CONFIG_CADENCE_QSPI
+/* Enable it if you want to use dual-stacked mode */
+/*#define CONFIG_QSPI_RBF_ADDR         0x720000*/
+
+/* Flash device info */
+
+/*#define CONFIG_ENV_IS_IN_SPI_FLASH*/
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+#undef CONFIG_ENV_OFFSET
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_OFFSET              0x710000
+#define CONFIG_ENV_SIZE                        (4 * 1024)
+#define CONFIG_ENV_SECT_SIZE           (4 * 1024)
+#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nor0=ff705000.spi.0"
+#endif /* CONFIG_SPL_BUILD */
+
+#ifndef __ASSEMBLY__
+unsigned int cm_get_qspi_controller_clk_hz(void);
+#define CONFIG_CQSPI_REF_CLK           cm_get_qspi_controller_clk_hz()
+#endif
+
+#endif /* CONFIG_CADENCE_QSPI */
+
+/*
+ * Boot arguments passed to the boot command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will override also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "earlycon"
+#define CONFIG_BOOTCOMMAND "run fatscript; run mmcload;run linux_qspi_enable;" \
+                          "run mmcboot"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+       "bootfile=Image\0" \
+       "fdt_addr=8000000\0" \
+       "fdtimage=socfpga_agilex_socdk.dtb\0" \
+       "mmcroot=/dev/mmcblk0p2\0" \
+       "mmcboot=setenv bootargs " CONFIG_BOOTARGS \
+               " root=${mmcroot} rw rootwait;" \
+               "booti ${loadaddr} - ${fdt_addr}\0" \
+       "mmcload=mmc rescan;" \
+               "load mmc 0:1 ${loadaddr} ${bootfile};" \
+               "load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \
+       "linux_qspi_enable=if sf probe; then " \
+               "echo Enabling QSPI at Linux DTB...;" \
+               "fdt addr ${fdt_addr}; fdt resize;" \
+               "fdt set /soc/spi at ff8d2000 status okay;" \
+               "fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency " \
+               " ${qspi_clock}; fi; \0" \
+       "scriptaddr=0x02100000\0" \
+       "scriptfile=u-boot.scr\0" \
+       "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
+                  "then source ${scriptaddr}; fi\0"
+
+/*
+ * Generic Interrupt Controller Definitions
+ */
+#define CONFIG_GICV2
+
+/*
+ * External memory configurations
+ */
+#define PHYS_SDRAM_1                   0x0
+#define PHYS_SDRAM_1_SIZE              (1 * 1024 * 1024 * 1024)
+#define CONFIG_SYS_SDRAM_BASE          0
+#define CONFIG_SYS_MEMTEST_START       0
+#define CONFIG_SYS_MEMTEST_END         PHYS_SDRAM_1_SIZE - 0x200000
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_CLK         100000000
+#define CONFIG_SYS_NS16550_MEM32
+
+/*
+ * Timer & watchdog configurations
+ */
+#define COUNTER_FREQUENCY              400000000
+
+/*
+ * SDMMC configurations
+ */
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT   256
+#endif
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_DW_ALTDESCRIPTOR
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * L4 Watchdog
+ */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_HW_WATCHDOG
+#define CONFIG_DESIGNWARE_WATCHDOG
+#define CONFIG_DW_WDT_BASE             SOCFPGA_L4WD0_ADDRESS
+#ifndef __ASSEMBLY__
+#define CONFIG_DW_WDT_CLOCK_KHZ                100000
+#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  3000
+#endif
+
+/*
+ * SPL memory layout
+ *
+ * On chip RAM
+ * 0xFFE0_0000 ...... Start of OCRAM
+ * SPL code, rwdata
+ * empty space
+ * 0xFFEx_xxxx ...... Top of stack (grows down)
+ * 0xFFEy_yyyy ...... Global Data
+ * 0xFFEz_zzzz ...... Malloc prior relocation (size CONFIG_SYS_MALLOC_F_LEN)
+ * 0xFFE3_F000 ...... Hardware handdoff blob (size 4KB)
+ * 0xFFE3_FFFF ...... End of OCRAM
+ *
+ * SDRAM
+ * 0x0000_0000 ...... Start of SDRAM_1
+ * unused / empty space for image loading
+ * Size 64MB   ...... MALLOC (size CONFIG_SYS_SPL_MALLOC_SIZE)
+ * Size 1MB    ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE)
+ * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB)
+ *
+ */
+#define CONFIG_SPL_TARGET              "spl/u-boot-spl.hex"
+#define CONFIG_SPL_MAX_SIZE            CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_STACK               CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SPL_BSS_MAX_SIZE                0x100000        /* 1 MB */
+#define CONFIG_SPL_BSS_START_ADDR      (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE \
+                                       - CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (CONFIG_SYS_MALLOC_LEN)
+#define CONFIG_SYS_SPL_MALLOC_START    (CONFIG_SPL_BSS_START_ADDR \
+                                       - CONFIG_SYS_SPL_MALLOC_SIZE)
+
+/* SPL SDMMC boot support */
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME                "u-boot.img"
+
+#endif /* __CONFIG_H */
--

2.19.0

#32 lore raw

PATCH v5 19/19 arm: socfpga: agilex: Enable Agilex SoC build

Quoted 193 lines · Simon Goldschmidt
Quoted 191 lines · Ley Foon Tan

Add build support for Agilex SoC.

---
v5:
- Enable NCORE_CACHE

v3:
- Disable CONFIG_USE_TINY_PRINTF

v2:
- Remove IC_CLK define, use clock DM method to get i2c clock
- Change CONFIG_ENV_SIZE to 4KB since CONFIG_SPI_FLASH_USE_4K_SECTORS is enabled.

---
 arch/arm/Kconfig                       |   4 +-
 arch/arm/mach-socfpga/Kconfig          |  16 ++
 arch/arm/mach-socfpga/Makefile         |   9 ++
 configs/socfpga_agilex_defconfig       |  59 +++++++
 include/configs/socfpga_agilex_socdk.h | 207 +++++++++++++++++++++++++
 5 files changed, 293 insertions(+), 2 deletions(-)
 create mode 100644 configs/socfpga_agilex_defconfig
 create mode 100644 include/configs/socfpga_agilex_socdk.h
arch/arm/Kconfig +2 -2
index 3b0e315061..e6c9d19968 100644
@@ -888,7 +888,7 @@ config ARCH_SOCFPGA
        bool "Altera SOCFPGA family"
        select ARCH_EARLY_INIT_R
        select ARCH_MISC_INIT if !TARGET_SOCFPGA_ARRIA10
-       select ARM64 if TARGET_SOCFPGA_STRATIX10
+       select ARM64 if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
        select CPU_V7A if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
        select DM
        select DM_SERIAL
@@ -900,7 +900,7 @@ config ARCH_SOCFPGA
        select SPL_LIBGENERIC_SUPPORT
        select SPL_NAND_SUPPORT if SPL_NAND_DENALI
        select SPL_OF_CONTROL
-       select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
+       select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
        select SPL_SERIAL_SUPPORT
        select SPL_SYSRESET
        select SPL_WATCHDOG_SUPPORT
arch/arm/mach-socfpga/Kconfig +16 -0
index 1d914648e3..3f5c4b357f 100644
@@ -26,6 +26,15 @@ config SYS_TEXT_BASE
        default 0x01000040 if TARGET_SOCFPGA_ARRIA10
        default 0x01000040 if TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_AGILEX
+       bool
+       select ARMV8_MULTIENTRY
+       select ARMV8_SET_SMPEN
+       select ARMV8_SPIN_TABLE
+       select CLK
+       select NCORE_CACHE
+       select SPL_CLK if SPL
+
 config TARGET_SOCFPGA_ARRIA5
        bool
        select TARGET_SOCFPGA_GEN5
@@ -72,6 +81,10 @@ choice
        prompt "Altera SOCFPGA board select"
        optional
 
+config TARGET_SOCFPGA_AGILEX_SOCDK
+       bool "Intel SOCFPGA SoCDK (Agilex)"
+       select TARGET_SOCFPGA_AGILEX
+
 config TARGET_SOCFPGA_ARIES_MCVEVK
        bool "Aries MCVEVK (Cyclone V)"
        select TARGET_SOCFPGA_CYCLONE5
@@ -132,6 +145,7 @@ config TARGET_SOCFPGA_TERASIC_SOCKIT
 endchoice
 
 config SYS_BOARD
+       default "agilex-socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -148,6 +162,7 @@ config SYS_BOARD
        default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
 config SYS_VENDOR
+       default "intel" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -165,6 +180,7 @@ config SYS_SOC
        default "socfpga"
 
 config SYS_CONFIG_NAME
+       default "socfpga_agilex_socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
        default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
        default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
        default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
arch/arm/mach-socfpga/Makefile +9 -0
index 81b6ffc675..418f543b20 100644
@@ -41,6 +41,14 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
 obj-y  += clock_manager_agilex.o
+obj-y  += mailbox_s10.o
+obj-y  += misc_s10.o
+obj-y  += mmu-arm64_s10.o
+obj-y  += reset_manager_s10.o
+obj-y  += system_manager_s10.o
+obj-y  += timer_s10.o
+obj-y  += wrap_pinmux_config_s10.o
+obj-y  += wrap_pll_config_s10.o
 endif
 
 ifdef CONFIG_SPL_BUILD
@@ -59,6 +67,7 @@ obj-y += firewall.o
 obj-y  += spl_s10.o
 endif
 ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y  += firewall.o
 obj-y  += spl_agilex.o
 endif
 endif
configs/socfpga_agilex_defconfig new file +55 -0
new file mode 100644
index 0000000000..daf71ff0eb
@@ -0,0 +1,59 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_TEXT_BASE=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_TARGET_SOCFPGA_AGILEX_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_agilex"
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_TEXT_BASE=0xFFE00000
+CONFIG_BOOTDELAY=5
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x3c00000
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="SOCFPGA_AGILEX # "
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_EMBED=y
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_agilex_socdk"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_ALTERA_SDRAM=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SF_DEFAULT_MODE=0x2003
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_MII=y
+CONFIG_DM_RESET=y
+CONFIG_SPI=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_USB=y
Quoted 8 lines

include/configs/socfpga_agilex_socdk.h

Quoted 5 lines
configs/socfpga_agilex_defconfig new file +4 -0
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_STORAGE=y
+# CONFIG_USE_TINY_PRINTF is not set
include/configs/socfpga_agilex_socdk.h +0 -0

I know I already sent my r-b, but seeing this file and the s10 one are nearly the same, why don't you merge them?

Yes, they are quite similar with minor differences. I can merge them.

Regards
Ley Foon

Quoted 216 lines
Quoted 216 lines

new file mode 100644
index 0000000000..8ed96ed252

include/configs/socfpga_agilex_socdk.h new file +207 -1
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef __CONFIG_SOCFGPA_AGILEX_H__
+#define __CONFIG_SOCFGPA_AGILEX_H__
+
+#include <asm/arch/base_addr_s10.h>
+#include <asm/arch/handoff_s10.h>
+
+/*
+ * U-Boot general configurations
+ */
+#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#define CONFIG_LOADADDR                        0x2000000
+#define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
+#define CONFIG_REMAKE_ELF
+/* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */
+#define CPU_RELEASE_ADDR               0xFFD12210
+#define CONFIG_SYS_CACHELINE_SIZE      64
+#define CONFIG_SYS_MEM_RESERVE_SECURE  0       /* using OCRAM, not DDR */
+
+/*
+ * U-Boot console configurations
+ */
+#define CONFIG_SYS_MAXARGS             64
+#define CONFIG_SYS_CBSIZE              2048
+#define CONFIG_SYS_PBSIZE              (CONFIG_SYS_CBSIZE + \
+                                       sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_BARGSIZE            CONFIG_SYS_CBSIZE
+
+/* Extend size of kernel image for uncompression */
+#define CONFIG_SYS_BOOTM_LEN           (32 * 1024 * 1024)
+
+/*
+ * U-Boot run time memory configurations
+ */
+#define CONFIG_SYS_INIT_RAM_ADDR       0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE       0x40000
+#define CONFIG_SYS_INIT_SP_ADDR                (CONFIG_SYS_INIT_RAM_ADDR  \
+                                       + CONFIG_SYS_INIT_RAM_SIZE \
+                                       - S10_HANDOFF_SIZE)
+#define CONFIG_SYS_INIT_SP_OFFSET      (CONFIG_SYS_INIT_SP_ADDR)
+#define CONFIG_SYS_MALLOC_LEN          (5 * 1024 * 1024)
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_SIZE                        0x1000
+#define CONFIG_SYS_MMC_ENV_DEV         0       /* device 0 */
+#define CONFIG_ENV_OFFSET              512     /* just after the MBR */
+
+/*
+ * QSPI support
+ */
+ #ifdef CONFIG_CADENCE_QSPI
+/* Enable it if you want to use dual-stacked mode */
+/*#define CONFIG_QSPI_RBF_ADDR         0x720000*/
+
+/* Flash device info */
+
+/*#define CONFIG_ENV_IS_IN_SPI_FLASH*/
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+#undef CONFIG_ENV_OFFSET
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_OFFSET              0x710000
+#define CONFIG_ENV_SIZE                        (4 * 1024)
+#define CONFIG_ENV_SECT_SIZE           (4 * 1024)
+#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                 "nor0=ff705000.spi.0"
+#endif /* CONFIG_SPL_BUILD */
+
+#ifndef __ASSEMBLY__
+unsigned int cm_get_qspi_controller_clk_hz(void);
+#define CONFIG_CQSPI_REF_CLK           cm_get_qspi_controller_clk_hz()
+#endif
+
+#endif /* CONFIG_CADENCE_QSPI */
+
+/*
+ * Boot arguments passed to the boot command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will override also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "earlycon"
+#define CONFIG_BOOTCOMMAND "run fatscript; run mmcload;run linux_qspi_enable;" \
+                          "run mmcboot"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+       "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+       "bootfile=Image\0" \
+       "fdt_addr=8000000\0" \
+       "fdtimage=socfpga_agilex_socdk.dtb\0" \
+       "mmcroot=/dev/mmcblk0p2\0" \
+       "mmcboot=setenv bootargs " CONFIG_BOOTARGS \
+               " root=${mmcroot} rw rootwait;" \
+               "booti ${loadaddr} - ${fdt_addr}\0" \
+       "mmcload=mmc rescan;" \
+               "load mmc 0:1 ${loadaddr} ${bootfile};" \
+               "load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \
+       "linux_qspi_enable=if sf probe; then " \
+               "echo Enabling QSPI at Linux DTB...;" \
+               "fdt addr ${fdt_addr}; fdt resize;" \
+               "fdt set /soc/spi at ff8d2000 status okay;" \
+               "fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency " \
+               " ${qspi_clock}; fi; \0" \
+       "scriptaddr=0x02100000\0" \
+       "scriptfile=u-boot.scr\0" \
+       "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
+                  "then source ${scriptaddr}; fi\0"
+
+/*
+ * Generic Interrupt Controller Definitions
+ */
+#define CONFIG_GICV2
+
+/*
+ * External memory configurations
+ */
+#define PHYS_SDRAM_1                   0x0
+#define PHYS_SDRAM_1_SIZE              (1 * 1024 * 1024 * 1024)
+#define CONFIG_SYS_SDRAM_BASE          0
+#define CONFIG_SYS_MEMTEST_START       0
+#define CONFIG_SYS_MEMTEST_END         PHYS_SDRAM_1_SIZE - 0x200000
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_CLK         100000000
+#define CONFIG_SYS_NS16550_MEM32
+
+/*
+ * Timer & watchdog configurations
+ */
+#define COUNTER_FREQUENCY              400000000
+
+/*
+ * SDMMC configurations
+ */
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT   256
+#endif
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_DW_ALTDESCRIPTOR
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * L4 Watchdog
+ */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_HW_WATCHDOG
+#define CONFIG_DESIGNWARE_WATCHDOG
+#define CONFIG_DW_WDT_BASE             SOCFPGA_L4WD0_ADDRESS
+#ifndef __ASSEMBLY__
+#define CONFIG_DW_WDT_CLOCK_KHZ                100000
+#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS  3000
+#endif
+
+/*
+ * SPL memory layout
+ *
+ * On chip RAM
+ * 0xFFE0_0000 ...... Start of OCRAM
+ * SPL code, rwdata
+ * empty space
+ * 0xFFEx_xxxx ...... Top of stack (grows down)
+ * 0xFFEy_yyyy ...... Global Data
+ * 0xFFEz_zzzz ...... Malloc prior relocation (size CONFIG_SYS_MALLOC_F_LEN)
+ * 0xFFE3_F000 ...... Hardware handdoff blob (size 4KB)
+ * 0xFFE3_FFFF ...... End of OCRAM
+ *
+ * SDRAM
+ * 0x0000_0000 ...... Start of SDRAM_1
+ * unused / empty space for image loading
+ * Size 64MB   ...... MALLOC (size CONFIG_SYS_SPL_MALLOC_SIZE)
+ * Size 1MB    ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE)
+ * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB)
+ *
+ */
+#define CONFIG_SPL_TARGET              "spl/u-boot-spl.hex"
+#define CONFIG_SPL_MAX_SIZE            CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_STACK               CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SPL_BSS_MAX_SIZE                0x100000        /* 1 MB */
+#define CONFIG_SPL_BSS_START_ADDR      (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE \
+                                       - CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE     (CONFIG_SYS_MALLOC_LEN)
+#define CONFIG_SYS_SPL_MALLOC_START    (CONFIG_SPL_BSS_START_ADDR \
+                                       - CONFIG_SYS_SPL_MALLOC_SIZE)
+
+/* SPL SDMMC boot support */
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION     1
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME                "u-boot.img"
+
+#endif /* __CONFIG_H */
--

2.19.0

#33 lore raw

PATCH v5 19/19 arm: socfpga: agilex: Enable Agilex SoC build

In reply to Ley Foon Tan

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 4 lines

Add build support for Agilex SoC.

This does not apply any more, you'll need to rebase it (Marek has changed mach-socfpga/Kconfig by renaming a board).

Regards,
Simon

Quoted 404 lines

---
v5:
- Enable NCORE_CACHE

v3:
- Disable CONFIG_USE_TINY_PRINTF

v2:
- Remove IC_CLK define, use clock DM method to get i2c clock
- Change CONFIG_ENV_SIZE to 4KB since CONFIG_SPI_FLASH_USE_4K_SECTORS is enabled.

---
  arch/arm/Kconfig                       |   4 +-
  arch/arm/mach-socfpga/Kconfig          |  16 ++
  arch/arm/mach-socfpga/Makefile         |   9 ++
  configs/socfpga_agilex_defconfig       |  59 +++++++
  include/configs/socfpga_agilex_socdk.h | 207 +++++++++++++++++++++++++
  5 files changed, 293 insertions(+), 2 deletions(-)

create mode 100644 configs/socfpga_agilex_defconfig create mode 100644 include/configs/socfpga_agilex_socdk.h

arch/arm/Kconfig +2 -2
index 3b0e315061..e6c9d19968 100644
@@ -888,7 +888,7 @@ config ARCH_SOCFPGA
  	bool "Altera SOCFPGA family"
  	select ARCH_EARLY_INIT_R
  	select ARCH_MISC_INIT if !TARGET_SOCFPGA_ARRIA10
-	select ARM64 if TARGET_SOCFPGA_STRATIX10
+	select ARM64 if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
  	select CPU_V7A if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
  	select DM
  	select DM_SERIAL
@@ -900,7 +900,7 @@ config ARCH_SOCFPGA
  	select SPL_LIBGENERIC_SUPPORT
  	select SPL_NAND_SUPPORT if SPL_NAND_DENALI
  	select SPL_OF_CONTROL
-	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
+	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
  	select SPL_SERIAL_SUPPORT
  	select SPL_SYSRESET
  	select SPL_WATCHDOG_SUPPORT
arch/arm/mach-socfpga/Kconfig +16 -0
index 1d914648e3..3f5c4b357f 100644
@@ -26,6 +26,15 @@ config SYS_TEXT_BASE
  	default 0x01000040 if TARGET_SOCFPGA_ARRIA10
  	default 0x01000040 if TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_AGILEX
+	bool
+	select ARMV8_MULTIENTRY
+	select ARMV8_SET_SMPEN
+	select ARMV8_SPIN_TABLE
+	select CLK
+	select NCORE_CACHE
+	select SPL_CLK if SPL
+
  config TARGET_SOCFPGA_ARRIA5
  	bool
  	select TARGET_SOCFPGA_GEN5
@@ -72,6 +81,10 @@ choice
  	prompt "Altera SOCFPGA board select"
  	optional
 
+config TARGET_SOCFPGA_AGILEX_SOCDK
+	bool "Intel SOCFPGA SoCDK (Agilex)"
+	select TARGET_SOCFPGA_AGILEX
+
  config TARGET_SOCFPGA_ARIES_MCVEVK
  	bool "Aries MCVEVK (Cyclone V)"
  	select TARGET_SOCFPGA_CYCLONE5
@@ -132,6 +145,7 @@ config TARGET_SOCFPGA_TERASIC_SOCKIT
  endchoice
 
  config SYS_BOARD
+	default "agilex-socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
  	default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
  	default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
  	default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -148,6 +162,7 @@ config SYS_BOARD
  	default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
  config SYS_VENDOR
+	default "intel" if TARGET_SOCFPGA_AGILEX_SOCDK
  	default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
  	default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
  	default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -165,6 +180,7 @@ config SYS_SOC
  	default "socfpga"
 
  config SYS_CONFIG_NAME
+	default "socfpga_agilex_socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
  	default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
  	default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
  	default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
arch/arm/mach-socfpga/Makefile +9 -0
index 81b6ffc675..418f543b20 100644
@@ -41,6 +41,14 @@ endif
 
  ifdef CONFIG_TARGET_SOCFPGA_AGILEX
  obj-y	+= clock_manager_agilex.o
+obj-y	+= mailbox_s10.o
+obj-y	+= misc_s10.o
+obj-y	+= mmu-arm64_s10.o
+obj-y	+= reset_manager_s10.o
+obj-y	+= system_manager_s10.o
+obj-y	+= timer_s10.o
+obj-y	+= wrap_pinmux_config_s10.o
+obj-y	+= wrap_pll_config_s10.o
  endif
 
  ifdef CONFIG_SPL_BUILD
@@ -59,6 +67,7 @@ obj-y	+= firewall.o
  obj-y	+= spl_s10.o
  endif
  ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y	+= firewall.o
  obj-y	+= spl_agilex.o
  endif
  endif
configs/socfpga_agilex_defconfig new file +59 -0
new file mode 100644
index 0000000000..daf71ff0eb
@@ -0,0 +1,59 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_TEXT_BASE=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_TARGET_SOCFPGA_AGILEX_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_agilex"
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_TEXT_BASE=0xFFE00000
+CONFIG_BOOTDELAY=5
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x3c00000
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="SOCFPGA_AGILEX # "
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_EMBED=y
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_agilex_socdk"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_ALTERA_SDRAM=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SF_DEFAULT_MODE=0x2003
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_MII=y
+CONFIG_DM_RESET=y
+CONFIG_SPI=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_STORAGE=y
+# CONFIG_USE_TINY_PRINTF is not set
include/configs/socfpga_agilex_socdk.h new file +207 -0
new file mode 100644
index 0000000000..8ed96ed252
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef __CONFIG_SOCFGPA_AGILEX_H__
+#define __CONFIG_SOCFGPA_AGILEX_H__
+
+#include <asm/arch/base_addr_s10.h>
+#include <asm/arch/handoff_s10.h>
+
+/*
+ * U-Boot general configurations
+ */
+#define CONFIG_SYS_MONITOR_BASE		CONFIG_SYS_TEXT_BASE
+#define CONFIG_LOADADDR			0x2000000
+#define CONFIG_SYS_LOAD_ADDR		CONFIG_LOADADDR
+#define CONFIG_REMAKE_ELF
+/* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */
+#define CPU_RELEASE_ADDR		0xFFD12210
+#define CONFIG_SYS_CACHELINE_SIZE	64
+#define CONFIG_SYS_MEM_RESERVE_SECURE	0	/* using OCRAM, not DDR */
+
+/*
+ * U-Boot console configurations
+ */
+#define CONFIG_SYS_MAXARGS		64
+#define CONFIG_SYS_CBSIZE		2048
+#define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
+					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
+
+/* Extend size of kernel image for uncompression */
+#define CONFIG_SYS_BOOTM_LEN		(32 * 1024 * 1024)
+
+/*
+ * U-Boot run time memory configurations
+ */
+#define CONFIG_SYS_INIT_RAM_ADDR	0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE	0x40000
+#define CONFIG_SYS_INIT_SP_ADDR		(CONFIG_SYS_INIT_RAM_ADDR  \
+					+ CONFIG_SYS_INIT_RAM_SIZE \
+					- S10_HANDOFF_SIZE)
+#define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_INIT_SP_ADDR)
+#define CONFIG_SYS_MALLOC_LEN		(5 * 1024 * 1024)
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_SIZE			0x1000
+#define CONFIG_SYS_MMC_ENV_DEV		0	/* device 0 */
+#define CONFIG_ENV_OFFSET		512	/* just after the MBR */
+
+/*
+ * QSPI support
+ */
+ #ifdef CONFIG_CADENCE_QSPI
+/* Enable it if you want to use dual-stacked mode */
+/*#define CONFIG_QSPI_RBF_ADDR		0x720000*/
+
+/* Flash device info */
+
+/*#define CONFIG_ENV_IS_IN_SPI_FLASH*/
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+#undef CONFIG_ENV_OFFSET
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_OFFSET		0x710000
+#define CONFIG_ENV_SIZE			(4 * 1024)
+#define CONFIG_ENV_SECT_SIZE		(4 * 1024)
+#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT			"nor0=ff705000.spi.0"
+#endif /* CONFIG_SPL_BUILD */
+
+#ifndef __ASSEMBLY__
+unsigned int cm_get_qspi_controller_clk_hz(void);
+#define CONFIG_CQSPI_REF_CLK		cm_get_qspi_controller_clk_hz()
+#endif
+
+#endif /* CONFIG_CADENCE_QSPI */
+
+/*
+ * Boot arguments passed to the boot command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will override also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "earlycon"
+#define CONFIG_BOOTCOMMAND "run fatscript; run mmcload;run linux_qspi_enable;" \
+			   "run mmcboot"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+	"bootfile=Image\0" \
+	"fdt_addr=8000000\0" \
+	"fdtimage=socfpga_agilex_socdk.dtb\0" \
+	"mmcroot=/dev/mmcblk0p2\0" \
+	"mmcboot=setenv bootargs " CONFIG_BOOTARGS \
+		" root=${mmcroot} rw rootwait;" \
+		"booti ${loadaddr} - ${fdt_addr}\0" \
+	"mmcload=mmc rescan;" \
+		"load mmc 0:1 ${loadaddr} ${bootfile};" \
+		"load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \
+	"linux_qspi_enable=if sf probe; then " \
+		"echo Enabling QSPI at Linux DTB...;" \
+		"fdt addr ${fdt_addr}; fdt resize;" \
+		"fdt set /soc/spi at ff8d2000 status okay;" \
+		"fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency " \
+		" ${qspi_clock}; fi; \0" \
+	"scriptaddr=0x02100000\0" \
+	"scriptfile=u-boot.scr\0" \
+	"fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
+		   "then source ${scriptaddr}; fi\0"
+
+/*
+ * Generic Interrupt Controller Definitions
+ */
+#define CONFIG_GICV2
+
+/*
+ * External memory configurations
+ */
+#define PHYS_SDRAM_1			0x0
+#define PHYS_SDRAM_1_SIZE		(1 * 1024 * 1024 * 1024)
+#define CONFIG_SYS_SDRAM_BASE		0
+#define CONFIG_SYS_MEMTEST_START	0
+#define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE - 0x200000
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_CLK		100000000
+#define CONFIG_SYS_NS16550_MEM32
+
+/*
+ * Timer & watchdog configurations
+ */
+#define COUNTER_FREQUENCY		400000000
+
+/*
+ * SDMMC configurations
+ */
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT	256
+#endif
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS	1
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_DW_ALTDESCRIPTOR
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * L4 Watchdog
+ */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_HW_WATCHDOG
+#define CONFIG_DESIGNWARE_WATCHDOG
+#define CONFIG_DW_WDT_BASE		SOCFPGA_L4WD0_ADDRESS
+#ifndef __ASSEMBLY__
+#define CONFIG_DW_WDT_CLOCK_KHZ		100000
+#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS	3000
+#endif
+
+/*
+ * SPL memory layout
+ *
+ * On chip RAM
+ * 0xFFE0_0000 ...... Start of OCRAM
+ * SPL code, rwdata
+ * empty space
+ * 0xFFEx_xxxx ...... Top of stack (grows down)
+ * 0xFFEy_yyyy ...... Global Data
+ * 0xFFEz_zzzz ...... Malloc prior relocation (size CONFIG_SYS_MALLOC_F_LEN)
+ * 0xFFE3_F000 ...... Hardware handdoff blob (size 4KB)
+ * 0xFFE3_FFFF ...... End of OCRAM
+ *
+ * SDRAM
+ * 0x0000_0000 ...... Start of SDRAM_1
+ * unused / empty space for image loading
+ * Size 64MB   ...... MALLOC (size CONFIG_SYS_SPL_MALLOC_SIZE)
+ * Size 1MB    ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE)
+ * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB)
+ *
+ */
+#define CONFIG_SPL_TARGET		"spl/u-boot-spl.hex"
+#define CONFIG_SPL_MAX_SIZE		CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_STACK		CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SPL_BSS_MAX_SIZE		0x100000	/* 1 MB */
+#define CONFIG_SPL_BSS_START_ADDR	(PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE \
+					- CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE	(CONFIG_SYS_MALLOC_LEN)
+#define CONFIG_SYS_SPL_MALLOC_START	(CONFIG_SPL_BSS_START_ADDR \
+					- CONFIG_SYS_SPL_MALLOC_SIZE)
+
+/* SPL SDMMC boot support */
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION	1
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME		"u-boot.img"
+
+#endif	/* __CONFIG_H */
#34 lore raw

PATCH v5 19/19 arm: socfpga: agilex: Enable Agilex SoC build

Quoted 10 lines · Simon Goldschmidt

Am 11.10.2019 um 11:52 schrieb Ley Foon Tan:

Quoted 4 lines

Add build support for Agilex SoC.

This does not apply any more, you'll need to rebase it (Marek has changed mach-socfpga/Kconfig by renaming a board).

Okay, noted.

Thanks.
Regards
Ley Foon

Quoted 405 lines
Quoted 404 lines

---
v5:
- Enable NCORE_CACHE

v3:
- Disable CONFIG_USE_TINY_PRINTF

v2:
- Remove IC_CLK define, use clock DM method to get i2c clock
- Change CONFIG_ENV_SIZE to 4KB since CONFIG_SPI_FLASH_USE_4K_SECTORS is enabled.

---
  arch/arm/Kconfig                       |   4 +-
  arch/arm/mach-socfpga/Kconfig          |  16 ++
  arch/arm/mach-socfpga/Makefile         |   9 ++
  configs/socfpga_agilex_defconfig       |  59 +++++++
  include/configs/socfpga_agilex_socdk.h | 207 +++++++++++++++++++++++++
  5 files changed, 293 insertions(+), 2 deletions(-)

create mode 100644 configs/socfpga_agilex_defconfig create mode 100644 include/configs/socfpga_agilex_socdk.h

arch/arm/Kconfig +2 -2
index 3b0e315061..e6c9d19968 100644
@@ -888,7 +888,7 @@ config ARCH_SOCFPGA
      bool "Altera SOCFPGA family"
      select ARCH_EARLY_INIT_R
      select ARCH_MISC_INIT if !TARGET_SOCFPGA_ARRIA10
-     select ARM64 if TARGET_SOCFPGA_STRATIX10
+     select ARM64 if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
      select CPU_V7A if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
      select DM
      select DM_SERIAL
@@ -900,7 +900,7 @@ config ARCH_SOCFPGA
      select SPL_LIBGENERIC_SUPPORT
      select SPL_NAND_SUPPORT if SPL_NAND_DENALI
      select SPL_OF_CONTROL
-     select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
+     select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10 || TARGET_SOCFPGA_AGILEX
      select SPL_SERIAL_SUPPORT
      select SPL_SYSRESET
      select SPL_WATCHDOG_SUPPORT
arch/arm/mach-socfpga/Kconfig +16 -0
index 1d914648e3..3f5c4b357f 100644
@@ -26,6 +26,15 @@ config SYS_TEXT_BASE
      default 0x01000040 if TARGET_SOCFPGA_ARRIA10
      default 0x01000040 if TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_AGILEX
+     bool
+     select ARMV8_MULTIENTRY
+     select ARMV8_SET_SMPEN
+     select ARMV8_SPIN_TABLE
+     select CLK
+     select NCORE_CACHE
+     select SPL_CLK if SPL
+
  config TARGET_SOCFPGA_ARRIA5
      bool
      select TARGET_SOCFPGA_GEN5
@@ -72,6 +81,10 @@ choice
      prompt "Altera SOCFPGA board select"
      optional
 
+config TARGET_SOCFPGA_AGILEX_SOCDK
+     bool "Intel SOCFPGA SoCDK (Agilex)"
+     select TARGET_SOCFPGA_AGILEX
+
  config TARGET_SOCFPGA_ARIES_MCVEVK
      bool "Aries MCVEVK (Cyclone V)"
      select TARGET_SOCFPGA_CYCLONE5
@@ -132,6 +145,7 @@ config TARGET_SOCFPGA_TERASIC_SOCKIT
  endchoice
 
  config SYS_BOARD
+     default "agilex-socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
      default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
      default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
      default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -148,6 +162,7 @@ config SYS_BOARD
      default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
  config SYS_VENDOR
+     default "intel" if TARGET_SOCFPGA_AGILEX_SOCDK
      default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
      default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
      default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
@@ -165,6 +180,7 @@ config SYS_SOC
      default "socfpga"
 
  config SYS_CONFIG_NAME
+     default "socfpga_agilex_socdk" if TARGET_SOCFPGA_AGILEX_SOCDK
      default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
      default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
      default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
arch/arm/mach-socfpga/Makefile +9 -0
index 81b6ffc675..418f543b20 100644
@@ -41,6 +41,14 @@ endif
 
  ifdef CONFIG_TARGET_SOCFPGA_AGILEX
  obj-y       += clock_manager_agilex.o
+obj-y        += mailbox_s10.o
+obj-y        += misc_s10.o
+obj-y        += mmu-arm64_s10.o
+obj-y        += reset_manager_s10.o
+obj-y        += system_manager_s10.o
+obj-y        += timer_s10.o
+obj-y        += wrap_pinmux_config_s10.o
+obj-y        += wrap_pll_config_s10.o
  endif
 
  ifdef CONFIG_SPL_BUILD
@@ -59,6 +67,7 @@ obj-y       += firewall.o
  obj-y       += spl_s10.o
  endif
  ifdef CONFIG_TARGET_SOCFPGA_AGILEX
+obj-y        += firewall.o
  obj-y       += spl_agilex.o
  endif
  endif
configs/socfpga_agilex_defconfig new file +59 -0
new file mode 100644
index 0000000000..daf71ff0eb
@@ -0,0 +1,59 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_TEXT_BASE=0x1000
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_NR_DRAM_BANKS=2
+CONFIG_TARGET_SOCFPGA_AGILEX_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_agilex"
+CONFIG_SPL_FS_FAT=y
+CONFIG_SPL_TEXT_BASE=0xFFE00000
+CONFIG_BOOTDELAY=5
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x3c00000
+CONFIG_HUSH_PARSER=y
+CONFIG_SYS_PROMPT="SOCFPGA_AGILEX # "
+CONFIG_CMD_MEMTEST=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_SF=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+CONFIG_CMD_FS_GENERIC=y
+CONFIG_OF_EMBED=y
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_agilex_socdk"
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_ALTERA_SDRAM=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_DW=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SF_DEFAULT_MODE=0x2003
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_PHY_MICREL=y
+CONFIG_PHY_MICREL_KSZ90X1=y
+CONFIG_DM_ETH=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_MII=y
+CONFIG_DM_RESET=y
+CONFIG_SPI=y
+CONFIG_CADENCE_QSPI=y
+CONFIG_DESIGNWARE_SPI=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_DWC2=y
+CONFIG_USB_STORAGE=y
+# CONFIG_USE_TINY_PRINTF is not set
include/configs/socfpga_agilex_socdk.h new file +207 -0
new file mode 100644
index 0000000000..8ed96ed252
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2019 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef __CONFIG_SOCFGPA_AGILEX_H__
+#define __CONFIG_SOCFGPA_AGILEX_H__
+
+#include <asm/arch/base_addr_s10.h>
+#include <asm/arch/handoff_s10.h>
+
+/*
+ * U-Boot general configurations
+ */
+#define CONFIG_SYS_MONITOR_BASE              CONFIG_SYS_TEXT_BASE
+#define CONFIG_LOADADDR                      0x2000000
+#define CONFIG_SYS_LOAD_ADDR         CONFIG_LOADADDR
+#define CONFIG_REMAKE_ELF
+/* sysmgr.boot_scratch_cold4 & 5 (64bit) will be used for PSCI_CPU_ON call */
+#define CPU_RELEASE_ADDR             0xFFD12210
+#define CONFIG_SYS_CACHELINE_SIZE    64
+#define CONFIG_SYS_MEM_RESERVE_SECURE        0       /* using OCRAM, not DDR */
+
+/*
+ * U-Boot console configurations
+ */
+#define CONFIG_SYS_MAXARGS           64
+#define CONFIG_SYS_CBSIZE            2048
+#define CONFIG_SYS_PBSIZE            (CONFIG_SYS_CBSIZE + \
+                                     sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_BARGSIZE          CONFIG_SYS_CBSIZE
+
+/* Extend size of kernel image for uncompression */
+#define CONFIG_SYS_BOOTM_LEN         (32 * 1024 * 1024)
+
+/*
+ * U-Boot run time memory configurations
+ */
+#define CONFIG_SYS_INIT_RAM_ADDR     0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE     0x40000
+#define CONFIG_SYS_INIT_SP_ADDR              (CONFIG_SYS_INIT_RAM_ADDR  \
+                                     + CONFIG_SYS_INIT_RAM_SIZE \
+                                     - S10_HANDOFF_SIZE)
+#define CONFIG_SYS_INIT_SP_OFFSET    (CONFIG_SYS_INIT_SP_ADDR)
+#define CONFIG_SYS_MALLOC_LEN                (5 * 1024 * 1024)
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_SIZE                      0x1000
+#define CONFIG_SYS_MMC_ENV_DEV               0       /* device 0 */
+#define CONFIG_ENV_OFFSET            512     /* just after the MBR */
+
+/*
+ * QSPI support
+ */
+ #ifdef CONFIG_CADENCE_QSPI
+/* Enable it if you want to use dual-stacked mode */
+/*#define CONFIG_QSPI_RBF_ADDR               0x720000*/
+
+/* Flash device info */
+
+/*#define CONFIG_ENV_IS_IN_SPI_FLASH*/
+#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+#undef CONFIG_ENV_OFFSET
+#undef CONFIG_ENV_SIZE
+#define CONFIG_ENV_OFFSET            0x710000
+#define CONFIG_ENV_SIZE                      (4 * 1024)
+#define CONFIG_ENV_SECT_SIZE         (4 * 1024)
+#endif /* CONFIG_ENV_IS_IN_SPI_FLASH */
+
+#ifndef CONFIG_SPL_BUILD
+#define CONFIG_MTD_DEVICE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT                       "nor0=ff705000.spi.0"
+#endif /* CONFIG_SPL_BUILD */
+
+#ifndef __ASSEMBLY__
+unsigned int cm_get_qspi_controller_clk_hz(void);
+#define CONFIG_CQSPI_REF_CLK         cm_get_qspi_controller_clk_hz()
+#endif
+
+#endif /* CONFIG_CADENCE_QSPI */
+
+/*
+ * Boot arguments passed to the boot command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will override also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "earlycon"
+#define CONFIG_BOOTCOMMAND "run fatscript; run mmcload;run linux_qspi_enable;" \
+                        "run mmcboot"
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+     "loadaddr=" __stringify(CONFIG_SYS_LOAD_ADDR) "\0" \
+     "bootfile=Image\0" \
+     "fdt_addr=8000000\0" \
+     "fdtimage=socfpga_agilex_socdk.dtb\0" \
+     "mmcroot=/dev/mmcblk0p2\0" \
+     "mmcboot=setenv bootargs " CONFIG_BOOTARGS \
+             " root=${mmcroot} rw rootwait;" \
+             "booti ${loadaddr} - ${fdt_addr}\0" \
+     "mmcload=mmc rescan;" \
+             "load mmc 0:1 ${loadaddr} ${bootfile};" \
+             "load mmc 0:1 ${fdt_addr} ${fdtimage}\0" \
+     "linux_qspi_enable=if sf probe; then " \
+             "echo Enabling QSPI at Linux DTB...;" \
+             "fdt addr ${fdt_addr}; fdt resize;" \
+             "fdt set /soc/spi at ff8d2000 status okay;" \
+             "fdt set /soc/clkmgr/clocks/qspi_clk clock-frequency " \
+             " ${qspi_clock}; fi; \0" \
+     "scriptaddr=0x02100000\0" \
+     "scriptfile=u-boot.scr\0" \
+     "fatscript=if fatload mmc 0:1 ${scriptaddr} ${scriptfile};" \
+                "then source ${scriptaddr}; fi\0"
+
+/*
+ * Generic Interrupt Controller Definitions
+ */
+#define CONFIG_GICV2
+
+/*
+ * External memory configurations
+ */
+#define PHYS_SDRAM_1                 0x0
+#define PHYS_SDRAM_1_SIZE            (1 * 1024 * 1024 * 1024)
+#define CONFIG_SYS_SDRAM_BASE                0
+#define CONFIG_SYS_MEMTEST_START     0
+#define CONFIG_SYS_MEMTEST_END               PHYS_SDRAM_1_SIZE - 0x200000
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_CLK               100000000
+#define CONFIG_SYS_NS16550_MEM32
+
+/*
+ * Timer & watchdog configurations
+ */
+#define COUNTER_FREQUENCY            400000000
+
+/*
+ * SDMMC configurations
+ */
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_SYS_MMC_MAX_BLK_COUNT 256
+#endif
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS   1
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_DW_ALTDESCRIPTOR
+#endif /* CONFIG_CMD_NET */
+
+/*
+ * L4 Watchdog
+ */
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_HW_WATCHDOG
+#define CONFIG_DESIGNWARE_WATCHDOG
+#define CONFIG_DW_WDT_BASE           SOCFPGA_L4WD0_ADDRESS
+#ifndef __ASSEMBLY__
+#define CONFIG_DW_WDT_CLOCK_KHZ              100000
+#endif
+#define CONFIG_WATCHDOG_TIMEOUT_MSECS        3000
+#endif
+
+/*
+ * SPL memory layout
+ *
+ * On chip RAM
+ * 0xFFE0_0000 ...... Start of OCRAM
+ * SPL code, rwdata
+ * empty space
+ * 0xFFEx_xxxx ...... Top of stack (grows down)
+ * 0xFFEy_yyyy ...... Global Data
+ * 0xFFEz_zzzz ...... Malloc prior relocation (size CONFIG_SYS_MALLOC_F_LEN)
+ * 0xFFE3_F000 ...... Hardware handdoff blob (size 4KB)
+ * 0xFFE3_FFFF ...... End of OCRAM
+ *
+ * SDRAM
+ * 0x0000_0000 ...... Start of SDRAM_1
+ * unused / empty space for image loading
+ * Size 64MB   ...... MALLOC (size CONFIG_SYS_SPL_MALLOC_SIZE)
+ * Size 1MB    ...... BSS (size CONFIG_SPL_BSS_MAX_SIZE)
+ * 0x8000_0000 ...... End of SDRAM_1 (assume 2GB)
+ *
+ */
+#define CONFIG_SPL_TARGET            "spl/u-boot-spl.hex"
+#define CONFIG_SPL_MAX_SIZE          CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_STACK             CONFIG_SYS_INIT_SP_ADDR
+#define CONFIG_SPL_BSS_MAX_SIZE              0x100000        /* 1 MB */
+#define CONFIG_SPL_BSS_START_ADDR    (PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE \
+                                     - CONFIG_SPL_BSS_MAX_SIZE)
+#define CONFIG_SYS_SPL_MALLOC_SIZE   (CONFIG_SYS_MALLOC_LEN)
+#define CONFIG_SYS_SPL_MALLOC_START  (CONFIG_SPL_BSS_START_ADDR \
+                                     - CONFIG_SYS_SPL_MALLOC_SIZE)
+
+/* SPL SDMMC boot support */
+#define CONFIG_SYS_MMCSD_FS_BOOT_PARTITION   1
+#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME              "u-boot.img"
+
+#endif       /* __CONFIG_H */
#35 lore raw

v5 cover Add Intel Agilex SoC support

In reply to Ley Foon Tan
Quoted 21 lines · Ley Foon Tan

This is 5th version of patchset to add Intel Agilex SoC[1] support. Most of changes are related to move CCU driver to DM, remove *_manager_s10.h and include *_manager_soc64.h directly. Detail changelog can find in commit message.

This patchset needs to apply after patchset in [2] for manager driver struct to defines conversion.

Patch status:
No change: Patch 1, 2, 9, 10, 13, 14, 15, 16
Have changes: Patch 3, 4, 5, 6, 7, 11, 17, 18, 19
New: Patch 8, 12

Intel Agilex SoC is with a 64-bit quad core ARM Cortex-A53 MPCore hard processor system (HPS). New IPs in Agilex are CCU, clock manager and SDRAM, other IPs have minor changes compared to Stratix 10.

Intel Agilex HPS TRM:
https://www.intel.com/content/dam/www/programmable/us/en/pdfs/literature/hb/agilex/mnl-1100.pdf

Quoted 6 lines

v4->v5:
-------
- Move CCU driver to DM
- Remove system_manager_s10.h and use system_manager_soc64.h directly.
- Remove reset_manager_s10.h and use reset_manager_soc64.h directly.
- Separate patch to fix INTOSC clock to 400MHz. [Patch 8]

Hi

Any further comments on this series?

Regards
Ley Foon

Quoted 113 lines

History:
---------
[v1]: https://patchwork.ozlabs.org/cover/1097830/
[v2]: https://patchwork.ozlabs.org/cover/1127440/
[v3]: https://patchwork.ozlabs.org/cover/1149863/
[v4]: https://patchwork.ozlabs.org/cover/1161483/

[1]: https://www.intel.com/content/www/us/en/products/programmable/fpga/agilex.html
[2]: https://patchwork.ozlabs.org/cover/1174347/

Ley Foon Tan (19):
arm: socfpga: agilex: Add base address for Intel Agilex SoC
arm: socfpga: Move firewall code to firewall file
arm: socfpga: Move Stratix10 and Agilex reset manager common code
arm: socfpga: agilex: Add reset manager support
arm: socfpga: Move Stratix10 and Agilex system manager common code
arm: socfpga: agilex: Add system manager support
arm: socfpga: Move Stratix10 and Agilex clock manager common code
arm: socfpga: Fix CLKMGR_INTOSC_HZ to 400MHz
clk: agilex: Add clock driver for Agilex
arm: socfpga: agilex: Add clock wrapper functions
cache: Add Arteris Ncore cache coherent unit driver
drivers: Enable cache driver build in SPL
arm: agilex: Add clock handoff offset for Agilex
ddr: altera: Restructure Stratix 10 SDRAM driver
ddr: altera: agilex: Add SDRAM driver for Agilex
board: intel: agilex: Add socdk board support for Intel Agilex SoC
arm: socfpga: agilex: Add SPL for Agilex SoC
arm: dts: agilex: Add base dtsi and devkit dts
arm: socfpga: agilex: Enable Agilex SoC build

 arch/arm/Kconfig                              |   4 +-
 arch/arm/dts/Makefile                         |   1 +
 arch/arm/dts/socfpga_agilex.dtsi              | 500 +++++++++++++++
 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi |  79 +++
 arch/arm/dts/socfpga_agilex_socdk.dts         | 136 ++++
 arch/arm/mach-socfpga/Kconfig                 |  16 +
 arch/arm/mach-socfpga/Makefile                |  17 +
 arch/arm/mach-socfpga/clock_manager_agilex.c  |  84 +++
 arch/arm/mach-socfpga/clock_manager_s10.c     |   2 +-
 .../mach-socfpga/{spl_s10.c => firewall.c}    | 122 +---
 .../mach-socfpga/include/mach/base_addr_s10.h |   4 +
 .../mach-socfpga/include/mach/clock_manager.h |   2 +
 .../include/mach/clock_manager_agilex.h       |  14 +
 .../include/mach/clock_manager_s10.h          |  16 +-
 .../include/mach/clock_manager_soc64.h        |  23 +
 .../mach/{firewall_s10.h => firewall.h}       |  10 +-
 .../mach-socfpga/include/mach/handoff_s10.h   |   9 +-
 .../mach-socfpga/include/mach/reset_manager.h |   5 +-
 .../include/mach/reset_manager_s10.h          |  95 ---
 .../include/mach/reset_manager_soc64.h        |  38 ++
 .../include/mach/system_manager.h             |   5 +-
 .../include/mach/system_manager_s10.h         | 124 ----
 .../include/mach/system_manager_soc64.h       | 123 ++++
 arch/arm/mach-socfpga/mailbox_s10.c           |   2 +-
 arch/arm/mach-socfpga/misc.c                  |   4 +
 arch/arm/mach-socfpga/misc_s10.c              |   4 +-
 arch/arm/mach-socfpga/reset_manager_s10.c     |  34 +-
 arch/arm/mach-socfpga/spl_agilex.c            |  98 +++
 arch/arm/mach-socfpga/spl_s10.c               |  95 +--
 arch/arm/mach-socfpga/system_manager_s10.c    |  26 +-
 arch/arm/mach-socfpga/wrap_pll_config_s10.c   |  13 +-
 board/intel/agilex-socdk/MAINTAINERS          |   7 +
 board/intel/agilex-socdk/Makefile             |   7 +
 board/intel/agilex-socdk/socfpga.c            |   7 +
 configs/socfpga_agilex_defconfig              |  59 ++
 drivers/Makefile                              |   1 +
 drivers/cache/Kconfig                         |   8 +
 drivers/cache/Makefile                        |   1 +
 drivers/cache/cache-ncore.c                   | 164 +++++
 drivers/clk/altera/Makefile                   |   1 +
 drivers/clk/altera/clk-agilex.c               | 579 ++++++++++++++++++
 drivers/clk/altera/clk-agilex.h               | 237 +++++++
 drivers/ddr/altera/Kconfig                    |   6 +-
 drivers/ddr/altera/Makefile                   |   3 +-
 drivers/ddr/altera/sdram_agilex.c             | 168 +++++
 drivers/ddr/altera/sdram_s10.c                | 298 +--------
 drivers/ddr/altera/sdram_s10.h                | 148 +----
 drivers/ddr/altera/sdram_soc64.c              | 304 +++++++++
 .../ddr/altera/{sdram_s10.h => sdram_soc64.h} |  71 ++-
 include/configs/socfpga_agilex_socdk.h        | 207 +++++++
 .../dt-bindings/clock/socfpga-soc64-clock.h   |  84 +++
 51 files changed, 3101 insertions(+), 964 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_agilex.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk-u-boot.dtsi
 create mode 100644 arch/arm/dts/socfpga_agilex_socdk.dts
 create mode 100644 arch/arm/mach-socfpga/clock_manager_agilex.c
 copy arch/arm/mach-socfpga/{spl_s10.c => firewall.c} (54%)
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_agilex.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_soc64.h
 rename arch/arm/mach-socfpga/include/mach/{firewall_s10.h => firewall.h} (94%)
 delete mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_soc64.h
 delete mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_soc64.h
 create mode 100644 arch/arm/mach-socfpga/spl_agilex.c
 create mode 100644 board/intel/agilex-socdk/MAINTAINERS
 create mode 100644 board/intel/agilex-socdk/Makefile
 create mode 100644 board/intel/agilex-socdk/socfpga.c
 create mode 100644 configs/socfpga_agilex_defconfig
 create mode 100644 drivers/cache/cache-ncore.c
 create mode 100644 drivers/clk/altera/clk-agilex.c
 create mode 100644 drivers/clk/altera/clk-agilex.h
 create mode 100644 drivers/ddr/altera/sdram_agilex.c
 create mode 100644 drivers/ddr/altera/sdram_soc64.c
 copy drivers/ddr/altera/{sdram_s10.h => sdram_soc64.h} (79%)
 create mode 100644 include/configs/socfpga_agilex_socdk.h
 create mode 100644 include/dt-bindings/clock/socfpga-soc64-clock.h

--
2.19.0