Skip to contentSkip to conversation

Add Intel Stratix 10 SoC support

PATCH Superseded Ley Foon Tan 4 participants 62 messages Apr 19, 2018 – May 11, 2018

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Add Intel Stratix 10 SoC support

This patchset adds Intel Stratix 10 SoC support.

Regards
Ley Foon

Ley Foon Tan (16):
arm: socfpga: stratix10: Add base address map for Statix10 SoC
arm: socfpga: stratix10: Add clock manager driver for Stratix10 SoC
arm: socfpga: stratix10: Add reset manager driver for Stratix10 SoC
arm: socfpga: stratix10: Add pinmux support for Stratix10 SoC
arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch
arm: socfpga: misc: Move eth reset to common misc driver
arm: socfpga: stratix10: Add misc support for Stratix10 SoC
arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC
arm: socfpga: stratix10: Add MMU support for Stratix10 SoC
arm: dts: Add dts for Stratix10 SoC
arm: socfpga: Restructure the SPL file
arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC
arm: socfpga: stratix10: Add timer support for Stratix10 SoC
ddr: altera: stratix10: Add DDR support for Stratix10 SoC
board: altera: stratix10: Add socdk board support for Stratix10 SoC
arm: socfpga: stratix10: Enable Stratix10 SoC build

 arch/arm/Kconfig                                   |    9 +-
 arch/arm/dts/Makefile                              |    3 +-
 arch/arm/dts/socfpga_stratix10_socdk.dts           |  282 ++++++++++++++
 arch/arm/mach-socfpga/Kconfig                      |   13 +
 arch/arm/mach-socfpga/Makefile                     |   19 +-
 arch/arm/mach-socfpga/clock_manager.c              |    4 +-
 arch/arm/mach-socfpga/clock_manager_s10.c          |  380 +++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |   38 ++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    2 +
 .../mach-socfpga/include/mach/clock_manager_s10.h  |  210 +++++++++++
 arch/arm/mach-socfpga/include/mach/firewall_s10.h  |   84 +++++
 arch/arm/mach-socfpga/include/mach/handoff_s10.h   |   32 ++
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h   |  155 ++++++++
 arch/arm/mach-socfpga/include/mach/misc.h          |    1 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |    2 +
 .../mach-socfpga/include/mach/reset_manager_s10.h  |  116 ++++++
 arch/arm/mach-socfpga/include/mach/sdram_s10.h     |  340 +++++++++++++++++
 .../arm/mach-socfpga/include/mach/system_manager.h |    5 +-
 .../mach-socfpga/include/mach/system_manager_s10.h |  176 +++++++++
 arch/arm/mach-socfpga/mailbox_s10.c                |  378 +++++++++++++++++++
 arch/arm/mach-socfpga/misc.c                       |   73 ++++
 arch/arm/mach-socfpga/misc_gen5.c                  |   74 +----
 arch/arm/mach-socfpga/misc_s10.c                   |  103 +++++
 arch/arm/mach-socfpga/mmu-arm64_s10.c              |   71 ++++
 arch/arm/mach-socfpga/reset_manager.c              |   11 +
 arch/arm/mach-socfpga/reset_manager_s10.c          |  140 +++++++
 arch/arm/mach-socfpga/spl_a10.c                    |  105 ++++++
 arch/arm/mach-socfpga/{spl.c => spl_gen5.c}        |   57 +---
 arch/arm/mach-socfpga/spl_s10.c                    |  205 ++++++++++
 arch/arm/mach-socfpga/system_manager_s10.c         |   91 +++++
 arch/arm/mach-socfpga/timer.c                      |   17 +-
 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c     |   56 +++
 arch/arm/mach-socfpga/wrap_pll_config_s10.c        |   59 +++
 board/altera/stratix10-socdk/MAINTAINERS           |    7 +
 board/altera/stratix10-socdk/Makefile              |    7 +
 board/altera/stratix10-socdk/socfpga.c             |    7 +
 configs/socfpga_stratix10_defconfig                |   52 +++
 drivers/ddr/altera/Makefile                        |    1 +
 drivers/ddr/altera/sdram_s10.c                     |  392 ++++++++++++++++++++
 include/configs/socfpga_stratix10_socdk.h          |  234 ++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-s10.h       |   96 +++++
 41 files changed, 3979 insertions(+), 128 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_stratix10_socdk.dts
 create mode 100644 arch/arm/mach-socfpga/clock_manager_s10.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/base_addr_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/firewall_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/handoff_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/mailbox_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/mailbox_s10.c
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
 create mode 100644 arch/arm/mach-socfpga/mmu-arm64_s10.c
 create mode 100644 arch/arm/mach-socfpga/reset_manager_s10.c
 create mode 100644 arch/arm/mach-socfpga/spl_a10.c
 rename arch/arm/mach-socfpga/{spl.c => spl_gen5.c} (82%)
 create mode 100644 arch/arm/mach-socfpga/spl_s10.c
 create mode 100644 arch/arm/mach-socfpga/system_manager_s10.c
 create mode 100644 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c
 create mode 100644 arch/arm/mach-socfpga/wrap_pll_config_s10.c
 create mode 100644 board/altera/stratix10-socdk/MAINTAINERS
 create mode 100644 board/altera/stratix10-socdk/Makefile
 create mode 100644 board/altera/stratix10-socdk/socfpga.c
 create mode 100644 configs/socfpga_stratix10_defconfig
 create mode 100644 drivers/ddr/altera/sdram_s10.c
 create mode 100644 include/configs/socfpga_stratix10_socdk.h
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-s10.h
#1 lore raw

PATCH 1/16 arm: socfpga: stratix10: Add base address map for Statix10 SoC

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |   38 ++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/base_addr_s10.h
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +38 -0
new file mode 100644
index 0000000..e18d2bf
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _SOCFPGA_S10_BASE_HARDWARE_H_
+#define _SOCFPGA_S10_BASE_HARDWARE_H_
+
+#define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xf8000400
+#define SOCFPGA_HMC_MMR_IO48_ADDRESS		0xf8010000
+#define SOCFPGA_SDR_ADDRESS			0xf8011000
+#define SOCFPGA_SMMU_ADDRESS			0xfa000000
+#define SOCFPGA_MAILBOX_ADDRESS			0xffA30000
+#define SOCFPGA_UART0_ADDRESS			0xffc02000
+#define SOCFPGA_UART1_ADDRESS			0xffc02100
+#define SOCFPGA_L4WD0_ADDRESS			0xffd00200
+#define SOCFPGA_L4WD1_ADDRESS			0xffd00300
+#define SOCFPGA_L4WD2_ADDRESS			0xffd00400
+#define SOCFPGA_L4WD3_ADDRESS			0xffd00500
+#define SOCFPGA_GTIMER_SEC_ADDRESS		0xffd01000
+#define SOCFPGA_GTIMER_NSEC_ADDRESS		0xffd02000
+#define SOCFPGA_CLKMGR_ADDRESS			0xffd10000
+#define SOCFPGA_RSTMGR_ADDRESS			0xffd11000
+#define SOCFPGA_SYSMGR_ADDRESS			0xffd12000
+#define SOCFPGA_PINMUX_DEDICATED_IO_ADDRESS	0xffd13000
+#define SOCFPGA_FIREWALL_L4_PER			0xffd21000
+#define SOCFPGA_FIREWALL_L4_SYS			0xffd21100
+#define SOCFPGA_FIREWALL_SOC2FPGA		0xffd21200
+#define SOCFPGA_FIREWALL_LWSOC2FPGA		0xffd21300
+#define SOCFPGA_FIREWALL_TCU			0xffd21400
+#define SOCFPGA_DMANONSECURE_ADDRESS		0xffda0000
+#define SOCFPGA_DMASECURE_ADDRESS		0xffda1000
+#define SOCFPGA_OCRAM_ADDRESS			0xffe00000
+#define GICD_BASE				0xfffc1000
+#define GICC_BASE				0xfffc2000
+
+#endif /* _SOCFPGA_S10_BASE_HARDWARE_H_ */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/16 arm: socfpga: stratix10: Add base address map for Statix10 SoC

Quoted 41 lines · Ley Foon Tan

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |   38 ++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/base_addr_s10.h
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +26 -0
new file mode 100644
index 0000000..e18d2bf
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _SOCFPGA_S10_BASE_HARDWARE_H_
+#define _SOCFPGA_S10_BASE_HARDWARE_H_
+
+#define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xf8000400
+#define SOCFPGA_HMC_MMR_IO48_ADDRESS		0xf8010000
+#define SOCFPGA_SDR_ADDRESS			0xf8011000
+#define SOCFPGA_SMMU_ADDRESS			0xfa000000
+#define SOCFPGA_MAILBOX_ADDRESS			0xffA30000
+#define SOCFPGA_UART0_ADDRESS			0xffc02000
+#define SOCFPGA_UART1_ADDRESS			0xffc02100
+#define SOCFPGA_L4WD0_ADDRESS			0xffd00200
+#define SOCFPGA_L4WD1_ADDRESS			0xffd00300
+#define SOCFPGA_L4WD2_ADDRESS			0xffd00400
+#define SOCFPGA_L4WD3_ADDRESS			0xffd00500
+#define SOCFPGA_GTIMER_SEC_ADDRESS		0xffd01000
+#define SOCFPGA_GTIMER_NSEC_ADDRESS		0xffd02000
+#define SOCFPGA_CLKMGR_ADDRESS			0xffd10000
+#define SOCFPGA_RSTMGR_ADDRESS			0xffd11000
+#define SOCFPGA_SYSMGR_ADDRESS			0xffd12000
+#define SOCFPGA_PINMUX_DEDICATED_IO_ADDRESS	0xffd13000

arch/arm/mach-socfpga/include/mach/base_addr_s10.h line 36

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +10 -0
+#define SOCFPGA_FIREWALL_L4_PER			0xffd21000
+#define SOCFPGA_FIREWALL_L4_SYS			0xffd21100
+#define SOCFPGA_FIREWALL_SOC2FPGA		0xffd21200
+#define SOCFPGA_FIREWALL_LWSOC2FPGA		0xffd21300
+#define SOCFPGA_FIREWALL_TCU			0xffd21400
+#define SOCFPGA_DMANONSECURE_ADDRESS		0xffda0000
+#define SOCFPGA_DMASECURE_ADDRESS		0xffda1000
+#define SOCFPGA_OCRAM_ADDRESS			0xffe00000
+#define GICD_BASE				0xfffc1000
+#define GICC_BASE				0xfffc2000

How much of this can come from DT ?

Quoted 2 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +1 -0
+#endif /* _SOCFPGA_S10_BASE_HARDWARE_H_ */
Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

PATCH 1/16 arm: socfpga: stratix10: Add base address map for Statix10 SoC

Quoted 49 lines · Marek Vasut
Quoted 48 lines · Ley Foon Tan

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |   38
++++++++++++++++++++

 1 files changed, 38 insertions(+), 0 deletions(-)

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

arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +29 -0
new file mode 100644
index 0000000..e18d2bf
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _SOCFPGA_S10_BASE_HARDWARE_H_
+#define _SOCFPGA_S10_BASE_HARDWARE_H_
+
+#define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xf8000400
+#define SOCFPGA_HMC_MMR_IO48_ADDRESS		0xf8010000
+#define SOCFPGA_SDR_ADDRESS			0xf8011000
+#define SOCFPGA_SMMU_ADDRESS			0xfa000000
+#define SOCFPGA_MAILBOX_ADDRESS			0xffA30000
+#define SOCFPGA_UART0_ADDRESS			0xffc02000
+#define SOCFPGA_UART1_ADDRESS			0xffc02100
+#define SOCFPGA_L4WD0_ADDRESS			0xffd00200
+#define SOCFPGA_L4WD1_ADDRESS			0xffd00300
+#define SOCFPGA_L4WD2_ADDRESS			0xffd00400
+#define SOCFPGA_L4WD3_ADDRESS			0xffd00500
+#define SOCFPGA_GTIMER_SEC_ADDRESS		0xffd01000
+#define SOCFPGA_GTIMER_NSEC_ADDRESS		0xffd02000
+#define SOCFPGA_CLKMGR_ADDRESS			0xffd10000
+#define SOCFPGA_RSTMGR_ADDRESS			0xffd11000
+#define SOCFPGA_SYSMGR_ADDRESS			0xffd12000
+#define SOCFPGA_PINMUX_DEDICATED_IO_ADDRESS	0xffd13000
+#define SOCFPGA_FIREWALL_L4_PER			0xffd21000
+#define SOCFPGA_FIREWALL_L4_SYS			0xffd21100
+#define SOCFPGA_FIREWALL_SOC2FPGA		0xffd21200
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/base_addr_s10.h line 36

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +7 -0
+#define SOCFPGA_FIREWALL_LWSOC2FPGA		0xffd21300
+#define SOCFPGA_FIREWALL_TCU			0xffd21400
+#define SOCFPGA_DMANONSECURE_ADDRESS		0xffda0000
+#define SOCFPGA_DMASECURE_ADDRESS		0xffda1000
+#define SOCFPGA_OCRAM_ADDRESS			0xffe00000
+#define GICD_BASE				0xfffc1000
+#define GICC_BASE				0xfffc2000

How much of this can come from DT ?

Just found out Dinh already upstreamed this patch. BTW, we will try to use DT when it is possible.

Thanks.

Regards
Ley Foon

#4 lore raw

PATCH 1/16 arm: socfpga: stratix10: Add base address map for Statix10 SoC

Quoted 60 lines · Ley Foon Tan
Quoted 49 lines · Marek Vasut
Quoted 48 lines · Ley Foon Tan

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |   38
++++++++++++++++++++

 1 files changed, 38 insertions(+), 0 deletions(-)

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

arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +29 -0
new file mode 100644
index 0000000..e18d2bf
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _SOCFPGA_S10_BASE_HARDWARE_H_
+#define _SOCFPGA_S10_BASE_HARDWARE_H_
+
+#define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xf8000400
+#define SOCFPGA_HMC_MMR_IO48_ADDRESS		0xf8010000
+#define SOCFPGA_SDR_ADDRESS			0xf8011000
+#define SOCFPGA_SMMU_ADDRESS			0xfa000000
+#define SOCFPGA_MAILBOX_ADDRESS			0xffA30000
+#define SOCFPGA_UART0_ADDRESS			0xffc02000
+#define SOCFPGA_UART1_ADDRESS			0xffc02100
+#define SOCFPGA_L4WD0_ADDRESS			0xffd00200
+#define SOCFPGA_L4WD1_ADDRESS			0xffd00300
+#define SOCFPGA_L4WD2_ADDRESS			0xffd00400
+#define SOCFPGA_L4WD3_ADDRESS			0xffd00500
+#define SOCFPGA_GTIMER_SEC_ADDRESS		0xffd01000
+#define SOCFPGA_GTIMER_NSEC_ADDRESS		0xffd02000
+#define SOCFPGA_CLKMGR_ADDRESS			0xffd10000
+#define SOCFPGA_RSTMGR_ADDRESS			0xffd11000
+#define SOCFPGA_SYSMGR_ADDRESS			0xffd12000
+#define SOCFPGA_PINMUX_DEDICATED_IO_ADDRESS	0xffd13000
+#define SOCFPGA_FIREWALL_L4_PER			0xffd21000
+#define SOCFPGA_FIREWALL_L4_SYS			0xffd21100
+#define SOCFPGA_FIREWALL_SOC2FPGA		0xffd21200
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/base_addr_s10.h line 36

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +7 -0
+#define SOCFPGA_FIREWALL_LWSOC2FPGA		0xffd21300
+#define SOCFPGA_FIREWALL_TCU			0xffd21400
+#define SOCFPGA_DMANONSECURE_ADDRESS		0xffda0000
+#define SOCFPGA_DMASECURE_ADDRESS		0xffda1000
+#define SOCFPGA_OCRAM_ADDRESS			0xffe00000
+#define GICD_BASE				0xfffc1000
+#define GICC_BASE				0xfffc2000

How much of this can come from DT ?

Quoted 2 lines

Just found out Dinh already upstreamed this patch. BTW, we will try to use DT when it is possible.

It is possible since years ago :-)

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

PATCH 2/16 arm: socfpga: stratix10: Add clock manager driver for Stratix10 SoC

In reply to Ley Foon Tan

Add Clock Manager driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                     |    4 +
 arch/arm/mach-socfpga/clock_manager.c              |    4 +-
 arch/arm/mach-socfpga/clock_manager_s10.c          |  380 ++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    2 +
 .../mach-socfpga/include/mach/clock_manager_s10.h  |  210 +++++++++++
 arch/arm/mach-socfpga/include/mach/handoff_s10.h   |   32 ++
 arch/arm/mach-socfpga/wrap_pll_config_s10.c        |   59 +++
 7 files changed, 689 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_s10.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/handoff_s10.h
 create mode 100644 arch/arm/mach-socfpga/wrap_pll_config_s10.c
arch/arm/mach-socfpga/Makefile +4 -0
index 286bfef..e5f9dd7 100644
@@ -30,6 +30,10 @@ obj-y	+= pinmux_arria10.o
 obj-y	+= reset_manager_arria10.o
 endif
 
+ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y	+= clock_manager_s10.o
+obj-y	+= wrap_pll_config_s10.o
+endif
 ifdef CONFIG_SPL_BUILD
 obj-y	+= spl.o
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/clock_manager.c +2 -2
index 43e72a8..924b3c7 100644
@@ -21,7 +21,7 @@ void cm_wait_for_lock(u32 mask)
 	do {
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 		inter_val = readl(&clock_manager_base->inter) & mask;
-#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#else
 		inter_val = readl(&clock_manager_base->stat) & mask;
 #endif
 		/* Wait for stable lock */
@@ -52,7 +52,7 @@ int set_cpu_clk_info(void)
 
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000;
-#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#else
 	gd->bd->bi_ddr_freq = 0;
 #endif
 
arch/arm/mach-socfpga/clock_manager_s10.c new file +380 -0

380 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
index 4c6b1f8..ddf814f 100644
@@ -17,6 +17,8 @@ void cm_print_clock_quick_summary(void);
 #include <asm/arch/clock_manager_gen5.h>
 #elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
 #include <asm/arch/clock_manager_arria10.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/clock_manager_s10.h>
 #endif
 
 #endif /* _CLOCK_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/clock_manager_s10.h new file +210 -0

210 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/handoff_s10.h new file +32 -0
new file mode 100644
index 0000000..c32b431
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _HANDOFF_S10_H_
+#define _HANDOFF_S10_H_
+
+/*
+ * Offset for HW handoff from Quartus tools
+ */
+#define CONFIG_HANDOFF_BASE		0xFFE3F000
+#define CONFIG_HANDOFF_MUX		(CONFIG_HANDOFF_BASE + 0x10)
+#define CONFIG_HANDOFF_IOCTL		(CONFIG_HANDOFF_BASE + 0x1A0)
+#define CONFIG_HANDOFF_FPGA		(CONFIG_HANDOFF_BASE + 0x330)
+#define CONFIG_HANODFF_DELAY		(CONFIG_HANDOFF_BASE + 0x3F0)
+#define CONFIG_HANDOFF_CLOCK		(CONFIG_HANDOFF_BASE + 0x580)
+#define CONFIG_HANDOFF_MISC		(CONFIG_HANDOFF_BASE + 0x610)
+#define CONFIG_HANDOFF_MAGIC_MUX	0x504D5558
+#define CONFIG_HANDOFF_MAGIC_IOCTL	0x494F4354
+#define CONFIG_HANDOFF_MAGIC_FPGA	0x46504741
+#define CONFIG_HANDOFF_MAGIC_DELAY	0x444C4159
+#define CONFIG_HANDOFF_MAGIC_CLOCK	0x434C4B53
+#define CONFIG_HANDOFF_MAGIC_MISC	0x4D495343
+#define CONFIG_HANDOFF_OFFSET_LENGTH	0x4
+#define CONFIG_HANDOFF_OFFSET_DATA	0x10
+
+#define CONFIG_HANDOFF_CLOCK_OSC	(CONFIG_HANDOFF_BASE + 0x608)
+#define CONFIG_HANDOFF_CLOCK_FPGA	(CONFIG_HANDOFF_BASE + 0x60C)
+
+#endif /* _HANDOFF_S10_H_ */
arch/arm/mach-socfpga/wrap_pll_config_s10.c new file +59 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.1
#6 lore raw

PATCH 3/16 arm: socfpga: stratix10: Add reset manager driver for Stratix10 SoC

In reply to Ley Foon Tan

Add Reset Manager driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                     |    1 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |    2 +
 .../mach-socfpga/include/mach/reset_manager_s10.h  |  116 ++++++++++++++++
 arch/arm/mach-socfpga/reset_manager.c              |   11 ++
 arch/arm/mach-socfpga/reset_manager_s10.c          |  140 ++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-s10.h       |   96 +++++++++++++
 6 files changed, 366 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/reset_manager_s10.c
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-s10.h
arch/arm/mach-socfpga/Makefile +1 -0
index e5f9dd7..f10b05c 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
+obj-y	+= reset_manager_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
 ifdef CONFIG_SPL_BUILD
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
index 6591745..577fcce 100644
@@ -45,6 +45,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)
+#include <asm/arch/reset_manager_s10.h>
 #endif
 
 #endif /* _RESET_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_s10.h new file +116 -0

116 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager.c +11 -0
index 29438ed..06cd020 100644
@@ -9,10 +9,16 @@
 #include <asm/io.h>
 #include <asm/arch/reset_manager.h>
 
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/mailbox_s10.h>
+#endif
+
 DECLARE_GLOBAL_DATA_PTR;
 
+#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
 static const struct socfpga_reset_manager *reset_manager_base =
 		(void *)SOCFPGA_RSTMGR_ADDRESS;
+#endif
 
 /*
  * Write the reset manager register to cause reset
@@ -20,8 +26,13 @@ static const struct socfpga_reset_manager *reset_manager_base =
 void reset_cpu(ulong addr)
 {
 	/* request a warm reset */
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+	puts("Mailbox: Issuing mailbox cmd REBOOT_HPS\n");
+	mbox_reset_cold();
+#else
 	writel(1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB,
 	       &reset_manager_base->ctrl);
+#endif
 	/*
 	 * infinite loop here as watchdog will trigger and reset
 	 * the processor
arch/arm/mach-socfpga/reset_manager_s10.c new file +140 -0

140 lines not on this page · raw message

include/dt-bindings/reset/altr,rst-mgr-s10.h new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

PATCH 4/16 arm: socfpga: stratix10: Add pinmux support for Stratix10 SoC

In reply to Ley Foon Tan

Add pinmux driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                     |    2 +
 .../arm/mach-socfpga/include/mach/system_manager.h |    5 +-
 .../mach-socfpga/include/mach/system_manager_s10.h |  176 ++++++++++++++++++++
 arch/arm/mach-socfpga/system_manager_s10.c         |   91 ++++++++++
 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c     |   56 ++++++
 5 files changed, 329 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_s10.h
 create mode 100644 arch/arm/mach-socfpga/system_manager_s10.c
 create mode 100644 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c
arch/arm/mach-socfpga/Makefile +2 -0
index f10b05c..910eb6f 100644
@@ -33,6 +33,8 @@ endif
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
 obj-y	+= reset_manager_s10.o
+obj-y	+= system_manager_s10.o
+obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
 ifdef CONFIG_SPL_BUILD
arch/arm/mach-socfpga/include/mach/system_manager.h +4 -1
index e6d4280..80c7d0b 100644
@@ -7,6 +7,9 @@
 #ifndef _SYSTEM_MANAGER_H_
 #define _SYSTEM_MANAGER_H_
 
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+#include <asm/arch/system_manager_s10.h>
+#else
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
 #define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	BIT(1)
 #define SYSMGR_ECC_OCRAM_EN	BIT(0)
@@ -89,5 +92,5 @@
 
 #define SYSMGR_GET_BOOTINFO_BSEL(bsel)		\
 		(((bsel) >> SYSMGR_BOOTINFO_BSEL_SHIFT) & 7)
-
+#endif
 #endif /* _SYSTEM_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/system_manager_s10.h new file +176 -0

176 lines not on this page · raw message

arch/arm/mach-socfpga/system_manager_s10.c new file +91 -0

91 lines not on this page · raw message

arch/arm/mach-socfpga/wrap_pinmux_config_s10.c new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

In reply to Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

---
 arch/arm/mach-socfpga/misc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-socfpga/misc.c +4 -0
index 692466c..01f824c 100644
@@ -23,8 +23,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SYS_L2_PL310
 static const struct pl310_regs *const pl310 =
 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+#endif
 
 struct bsel bsel_str[] = {
 	{ "rsvd", "Reserved", },
@@ -53,6 +55,7 @@ void enable_caches(void)
 #endif
 }
 
+#ifdef CONFIG_SYS_L2_PL310
 void v7_outer_cache_enable(void)
 {
 	/* Disable the L2 cache */
@@ -73,6 +76,7 @@ void v7_outer_cache_disable(void)
 	/* Disable the L2 cache */
 	clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
 }
+#endif
 
 #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \
 defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE)
Signature · 1 line
1.7.1
#9 lore raw

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 1 line · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

Quoted 38 lines
---
 arch/arm/mach-socfpga/misc.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/mach-socfpga/misc.c +4 -0
index 692466c..01f824c 100644
@@ -23,8 +23,10 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_SYS_L2_PL310
 static const struct pl310_regs *const pl310 =
 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+#endif
 
 struct bsel bsel_str[] = {
 	{ "rsvd", "Reserved", },
@@ -53,6 +55,7 @@ void enable_caches(void)
 #endif
 }
 
+#ifdef CONFIG_SYS_L2_PL310
 void v7_outer_cache_enable(void)
 {
 	/* Disable the L2 cache */
@@ -73,6 +76,7 @@ void v7_outer_cache_disable(void)
 	/* Disable the L2 cache */
 	clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
 }
+#endif
 
 #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \
 defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE)
Signature · 2 lines
Best regards,
Marek Vasut
#10 lore raw

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

In ARM64, L2 cache controller is accessed through processor registers. Hence we shall make this conditional in order this file can be shared across SOCFPGAs.

Thanks
Chin Liang

#11 lore raw

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 10 lines · Chin Liang
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

In ARM64, L2 cache controller is accessed through processor registers. Hence we shall make this conditional in order this file can be shared across SOCFPGAs.

That should be in the patch description .
Do you ever add the PL310 register access on S10 later in the set?

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

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 8 lines · Marek Vasut
Quoted 7 lines · Chin Liang
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

Quoted 8 lines
Quoted 3 lines

In ARM64, L2 cache controller is accessed through processor registers. Hence we shall make this conditional in order this file can be shared across SOCFPGAs.

That should be in the patch description .
Do you ever add the PL310 register access on S10 later in the set?

--

Okay, will update description.
No, S10 doesn't use PL310 registers.

Thanks.

Regards
Ley Foon

#13 lore raw

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 13 lines · Ley Foon Tan
Quoted 12 lines · Marek Vasut
Quoted 10 lines · Chin Liang
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

In ARM64, L2 cache controller is accessed through processor registers. Hence we shall make this conditional in order this file can be shared across SOCFPGAs.

Quoted 6 lines
Quoted 4 lines

That should be in the patch description .
Do you ever add the PL310 register access on S10 later in the set?

--

Okay, will update description.
No, S10 doesn't use PL310 registers.

If this PL310 is Gen5 specific, then keep it in some Gen5 file.

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

PATCH 5/16 arm: socfpga: misc: Add CONFIG_SYS_L2_PL310 switch

Quoted 18 lines · Marek Vasut
Quoted 17 lines · Ley Foon Tan
Quoted 16 lines · Marek Vasut
Quoted 10 lines · Chin Liang
Quoted 5 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add CONFIG_SYS_L2_PL310 conditional build.

Why ?

In ARM64, L2 cache controller is accessed through processor registers. Hence we shall make this conditional in order this file can be shared across SOCFPGAs.

That should be in the patch description .
Do you ever add the PL310 register access on S10 later in the set?

--

Quoted 8 lines
Quoted 2 lines

Okay, will update description.
No, S10 doesn't use PL310 registers.

If this PL310 is Gen5 specific, then keep it in some Gen5 file.

--
Best regards,
Marek Vasut.

Arria 10 needs this PL310 as well. So, we keep it in common misc.

Regards
Ley Foon

#15 lore raw

PATCH 6/16 arm: socfpga: misc: Move eth reset to common misc driver

In reply to Ley Foon Tan

Move eth reset to common misc driver so can used by other device families.

---
 arch/arm/mach-socfpga/include/mach/misc.h |    1 +
 arch/arm/mach-socfpga/misc.c              |   69 +++++++++++++++++++++++++++
 arch/arm/mach-socfpga/misc_gen5.c         |   74 +----------------------------
 3 files changed, 72 insertions(+), 72 deletions(-)
arch/arm/mach-socfpga/include/mach/misc.h +1 -0
index 0b65783..8466023 100644
@@ -8,6 +8,7 @@
 #define _MISC_H_
 
 void dwmac_deassert_reset(const unsigned int of_reset_id, const u32 phymode);
+int socfpga_eth_reset(void);
 
 struct bsel {
 	const char	*mode;
arch/arm/mach-socfpga/misc.c +69 -0

72 lines not on this page · raw message

arch/arm/mach-socfpga/misc_gen5.c +2 -72

92 lines not on this page · raw message

Signature · 1 line
1.7.1
#18 lore raw

PATCH 6/16 arm: socfpga: misc: Move eth reset to common misc driver

Quoted 10 lines · Ley Foon Tan
Quoted 8 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan

Move eth reset to common misc driver so can used by other device families.

Shouldn't this use the reset framework instead ?

What reset framework you refer to? drivers/reset?

I think so, there were patches from Dinh earlier this month
2ac718821a | Dinh Nguyen | reset: socfpga: add reset driver for
SoCFPGA platform

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

PATCH 6/16 arm: socfpga: misc: Move eth reset to common misc driver

Quoted 8 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan

Move eth reset to common misc driver so can used by other device families.

Quoted 8 lines
Quoted 3 lines
Quoted 2 lines

Shouldn't this use the reset framework instead ?

What reset framework you refer to? drivers/reset?

I think so, there were patches from Dinh earlier this month
2ac718821a | Dinh Nguyen | reset: socfpga: add reset driver for
SoCFPGA platform

Noted, will remove this change.

Regards
Ley Foon

#20 lore raw

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

In reply to Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
+obj-y	+= misc_s10.o
 obj-y	+= reset_manager_s10.o
 obj-y	+= system_manager_s10.o
 obj-y	+= wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
1.7.1
#21 lore raw

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 49 lines · Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
+obj-y	+= misc_s10.o
 obj-y	+= reset_manager_s10.o
 obj-y	+= system_manager_s10.o
 obj-y	+= wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +21 -0
new file mode 100644
index 0000000..b1cc6ca
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/pl310.h>
+#include <linux/libfdt.h>
+
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>

arch/arm/mach-socfpga/misc_s10.c line 31

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE

Use the reset framework ? Talk to Dinh if in doubt

Quoted 14 lines
arch/arm/mach-socfpga/misc_s10.c new file +14 -0
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+			  const u32 phymode)
+{
+	/* Put the emac we're using into reset.
+	 * This is required before configuring the PHY interface
+	 */
+	socfpga_emac_manage_reset(of_reset_id, 1);
+
+	clrsetbits_le32(&sysmgr_regs->emac0 + (of_reset_id - EMAC0_RESET),
+			SYSMGR_EMACGRP_CTRL_PHYSEL_MASK,
+			phymode);
+
+	socfpga_emac_manage_reset(of_reset_id, 0);
+}

arch/arm/mach-socfpga/misc_s10.c line 55

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+#endif
+
+/*
+ * Print CPU information
+ */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+	puts("CPU:   Intel FPGA SoCFPGA Platform\n");
+	puts("FPGA:  Intel FPGA Stratix 10\n");

This can well come from DT.

Quoted 9 lines
arch/arm/mach-socfpga/misc_s10.c new file +9 -0
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MISC_INIT
+int arch_misc_init(void)
+{
+	char qspi_string[13];
+

arch/arm/mach-socfpga/misc_s10.c line 74

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+	sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
+	env_set("qspi_clock", qspi_string);
+
+	return socfpga_eth_reset();
+}
+#endif
+
+int arch_early_init_r(void)
+{
+	return 0;

Needed ?

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+}
+
+int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	if (argc != 2)
+		return CMD_RET_USAGE;

arch/arm/mach-socfpga/misc_s10.c line 90

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+
+	argv++;
+
+	switch (*argv[0]) {
+	case 'e':	/* Enable */
+		socfpga_bridges_reset(1);
+		break;
+	case 'd':	/* Disable */
+		socfpga_bridges_reset(0);
+		break;

Do you really need to duplicate this command ?

Quoted 14 lines
arch/arm/mach-socfpga/misc_s10.c new file +13 -0
+	default:
+		return CMD_RET_USAGE;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(bridge, 2, 1, do_bridge,
+	   "SoCFPGA HPS FPGA bridge control",
+	   "enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+	   "bridge disable - Disable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+	   ""
+);
Signature · 2 lines
Best regards,
Marek Vasut
#22 lore raw

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 54 lines · Marek Vasut
Quoted 53 lines · Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y        += clock_manager_s10.o
+obj-y        += misc_s10.o
 obj-y        += reset_manager_s10.o
 obj-y        += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +25 -0
new file mode 100644
index 0000000..b1cc6ca
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/pl310.h>
+#include <linux/libfdt.h>
+
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct socfpga_system_manager *sysmgr_regs =
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 31

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE

Use the reset framework ? Talk to Dinh if in doubt

Yes, will convert this to reset framework. Will send out separate patches to convert device drivers to use reset framework.

Quoted 19 lines
Quoted 19 lines
arch/arm/mach-socfpga/misc_s10.c new file +18 -0
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+                       const u32 phymode)
+{
+     /* Put the emac we're using into reset.
+      * This is required before configuring the PHY interface
+      */
+     socfpga_emac_manage_reset(of_reset_id, 1);
+
+     clrsetbits_le32(&sysmgr_regs->emac0 + (of_reset_id - EMAC0_RESET),
+                     SYSMGR_EMACGRP_CTRL_PHYSEL_MASK,
+                     phymode);
+
+     socfpga_emac_manage_reset(of_reset_id, 0);
+}
+#endif
+
+/*
+ * Print CPU information
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 55

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+ */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+     puts("CPU:   Intel FPGA SoCFPGA Platform\n");
+     puts("FPGA:  Intel FPGA Stratix 10\n");

This can well come from DT.

DT only contains the "model" and this is already display in common/board_info.c:show_board_info().
So, will use simple puts here for the CPU info, unless we want add new DT property.

Below is example output from console, model is retrieved from DT.

CPU:   Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)
Model: SoCFPGA Stratix 10 SoCDK
Quoted 14 lines
Quoted 14 lines
arch/arm/mach-socfpga/misc_s10.c new file +13 -0
+     return 0;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MISC_INIT
+int arch_misc_init(void)
+{
+     char qspi_string[13];
+
+     sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
+     env_set("qspi_clock", qspi_string);
+
+     return socfpga_eth_reset();
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 74

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+}
+#endif
+
+int arch_early_init_r(void)
+{
+     return 0;

Needed ?

Will remove.

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+}
+
+int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+     if (argc != 2)
+             return CMD_RET_USAGE;
+
+     argv++;
+
+     switch (*argv[0]) {
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 90

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+     case 'e':       /* Enable */
+             socfpga_bridges_reset(1);
+             break;
+     case 'd':       /* Disable */
+             socfpga_bridges_reset(0);
+             break;

Do you really need to duplicate this command ?

Will rework this part and merge with Gen5.

Quoted 15 lines
Quoted 5 lines
arch/arm/mach-socfpga/misc_s10.c new file +3 -0
+     default:
+             return CMD_RET_USAGE;
+     }

arch/arm/mach-socfpga/misc_s10.c line 103

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+
+     return 0;
+}
+
+U_BOOT_CMD(bridge, 2, 1, do_bridge,
+        "SoCFPGA HPS FPGA bridge control",
+        "enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+        "bridge disable - Disable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+        ""
+);

Thanks.

Regards
Ley Foon

#23 lore raw

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 63 lines · Ley Foon Tan
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y        += clock_manager_s10.o
+obj-y        += misc_s10.o
 obj-y        += reset_manager_s10.o
 obj-y        += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +25 -0
new file mode 100644
index 0000000..b1cc6ca
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/pl310.h>
+#include <linux/libfdt.h>
+
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct socfpga_system_manager *sysmgr_regs =
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 31

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE

Use the reset framework ? Talk to Dinh if in doubt

Quoted 2 lines

Yes, will convert this to reset framework. Will send out separate patches to convert device drivers to use reset framework.

Thanks, this really helps even for the A10.

http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=shortlog;h=refs/heads/arria10

Quoted 27 lines
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-socfpga/misc_s10.c new file +18 -0
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+                       const u32 phymode)
+{
+     /* Put the emac we're using into reset.
+      * This is required before configuring the PHY interface
+      */
+     socfpga_emac_manage_reset(of_reset_id, 1);
+
+     clrsetbits_le32(&sysmgr_regs->emac0 + (of_reset_id - EMAC0_RESET),
+                     SYSMGR_EMACGRP_CTRL_PHYSEL_MASK,
+                     phymode);
+
+     socfpga_emac_manage_reset(of_reset_id, 0);
+}
+#endif
+
+/*
+ * Print CPU information
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 55

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+ */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+     puts("CPU:   Intel FPGA SoCFPGA Platform\n");
+     puts("FPGA:  Intel FPGA Stratix 10\n");

This can well come from DT.

Quoted 4 lines

DT only contains the "model" and this is already display in common/board_info.c:show_board_info().
So, will use simple puts here for the CPU info, unless we want add new DT property.

I don't, nope.

Quoted 4 lines

Below is example output from console, model is retrieved from DT.

CPU:   Intel FPGA SoCFPGA Platform (ARMv8 64bit Cortex-A53)
Model: SoCFPGA Stratix 10 SoCDK

Ah OK, got it.

Quoted 41 lines
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-socfpga/misc_s10.c new file +13 -0
+     return 0;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MISC_INIT
+int arch_misc_init(void)
+{
+     char qspi_string[13];
+
+     sprintf(qspi_string, "<0x%08x>", cm_get_qspi_controller_clk_hz());
+     env_set("qspi_clock", qspi_string);
+
+     return socfpga_eth_reset();
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 74

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+}
+#endif
+
+int arch_early_init_r(void)
+{
+     return 0;

Needed ?

Will remove.

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+}
+
+int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+     if (argc != 2)
+             return CMD_RET_USAGE;
+
+     argv++;
+
+     switch (*argv[0]) {
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 90

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+     case 'e':       /* Enable */
+             socfpga_bridges_reset(1);
+             break;
+     case 'd':       /* Disable */
+             socfpga_bridges_reset(0);
+             break;

Do you really need to duplicate this command ?

Quoted 1 line

Will rework this part and merge with Gen5.

Great!

Quoted 21 lines
Quoted 15 lines
Quoted 5 lines
arch/arm/mach-socfpga/misc_s10.c new file +3 -0
+     default:
+             return CMD_RET_USAGE;
+     }

arch/arm/mach-socfpga/misc_s10.c line 103

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+
+     return 0;
+}
+
+U_BOOT_CMD(bridge, 2, 1, do_bridge,
+        "SoCFPGA HPS FPGA bridge control",
+        "enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+        "bridge disable - Disable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+        ""
+);

Thanks.

Regards
Ley Foon

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

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 64 lines · Marek Vasut
Quoted 63 lines · Ley Foon Tan
Quoted 62 lines · Marek Vasut
Quoted 49 lines · Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y        += clock_manager_s10.o
+obj-y        += misc_s10.o
 obj-y        += reset_manager_s10.o
 obj-y        += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +21 -0
new file mode 100644
index 0000000..b1cc6ca
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/pl310.h>
+#include <linux/libfdt.h>
+
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>

arch/arm/mach-socfpga/misc_s10.c line 31

Quoted 10 lines
arch/arm/mach-socfpga/misc_s10.c new file +10 -0
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct socfpga_system_manager *sysmgr_regs =
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE

Use the reset framework ? Talk to Dinh if in doubt

Quoted 6 lines
Quoted 2 lines

Yes, will convert this to reset framework. Will send out separate patches to convert device drivers to use reset framework.

Thanks, this really helps even for the A10.

http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=shortlog;h=refs/heads/arria10

I saw you have new patches on this git repo, should I rebase my patchset on top of this git repo or using main u-boot.git?

Regards
Ley Foon

#25 lore raw

PATCH 7/16 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 68 lines · Ley Foon Tan
Quoted 67 lines · Marek Vasut
Quoted 65 lines · Ley Foon Tan
Quoted 54 lines · Marek Vasut
Quoted 53 lines · Ley Foon Tan

Add misc support such as EMAC and cpu info printout for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile   |    1 +
 arch/arm/mach-socfpga/misc_s10.c |  103 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 910eb6f..b253914 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y        += clock_manager_s10.o
+obj-y        += misc_s10.o
 obj-y        += reset_manager_s10.o
 obj-y        += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/misc_s10.c new file +25 -0
new file mode 100644
index 0000000..b1cc6ca
@@ -0,0 +1,103 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/io.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/pl310.h>
+#include <linux/libfdt.h>
+
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct socfpga_system_manager *sysmgr_regs =
Quoted 8 lines

arch/arm/mach-socfpga/misc_s10.c line 31

Quoted 6 lines
arch/arm/mach-socfpga/misc_s10.c new file +6 -0
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE

Use the reset framework ? Talk to Dinh if in doubt

Yes, will convert this to reset framework. Will send out separate patches to convert device drivers to use reset framework.

Quoted 6 lines
Quoted 3 lines

Thanks, this really helps even for the A10.

http://git.denx.de/?p=u-boot/u-boot-socfpga.git;a=shortlog;h=refs/heads/arria10

I saw you have new patches on this git repo, should I rebase my patchset on top of this git repo or using main u-boot.git?

Is there anything that'll collide ? If you find anything useful there, feel free to use it.

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

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

In reply to Ley Foon Tan

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |    1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  155 +++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              |  378 ++++++++++++++++++++++
 3 files changed, 534 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/mailbox_s10.h
 create mode 100644 arch/arm/mach-socfpga/mailbox_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index b253914..43e18d2 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
+obj-y	+= mailbox_s10.o
 obj-y	+= misc_s10.o
 obj-y	+= reset_manager_s10.o
 obj-y	+= system_manager_s10.o
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +155 -0

155 lines not on this page · raw message

arch/arm/mach-socfpga/mailbox_s10.c new file +378 -0

378 lines not on this page · raw message

Signature · 1 line
1.7.1
#27 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 111 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |    1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  155 +++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              |  378 ++++++++++++++++++++++
 3 files changed, 534 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/mailbox_s10.h
 create mode 100644 arch/arm/mach-socfpga/mailbox_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index b253914..43e18d2 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.o
+obj-y	+= mailbox_s10.o
 obj-y	+= misc_s10.o
 obj-y	+= reset_manager_s10.o
 obj-y	+= system_manager_s10.o
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +81 -0
new file mode 100644
index 0000000..85e7f84
@@ -0,0 +1,155 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _MAILBOX_S10_H_
+#define _MAILBOX_S10_H_
+
+/* user define Uboot ID */
+#define MBOX_CLIENT_ID_UBOOT	0xB
+#define MBOX_ID_UBOOT		0x1
+
+#define MBOX_CMD_DIRECT	0
+#define MBOX_CMD_INDIRECT	1
+
+#define MBOX_MAX_CMD_INDEX	2047
+#define MBOX_CMD_BUFFER_SIZE	32
+#define MBOX_RESP_BUFFER_SIZE	16
+
+#define MBOX_HDR_CMD_LSB	0
+#define MBOX_HDR_CMD_MSK	(BIT(11) - 1)
+#define MBOX_HDR_I_LSB		11
+#define MBOX_HDR_I_MSK		BIT(11)
+#define MBOX_HDR_LEN_LSB	12
+#define MBOX_HDR_LEN_MSK	0x007FF000
+#define MBOX_HDR_ID_LSB		24
+#define MBOX_HDR_ID_MSK		0x0F000000
+#define MBOX_HDR_CLIENT_LSB	28
+#define MBOX_HDR_CLIENT_MSK	0xF0000000
+
+/* Interrupt flags */
+#define MBOX_FLAGS_INT_COE	BIT(0)	/* COUT update interrupt enable */
+#define MBOX_FLAGS_INT_RIE	BIT(1)	/* RIN update interrupt enable */
+#define MBOX_FLAGS_INT_UAE	BIT(8)	/* Urgent ACK interrupt enable */
+#define MBOX_ALL_INTRS		(MBOX_FLAGS_INT_COE | \
+				 MBOX_FLAGS_INT_RIE | \
+				 MBOX_FLAGS_INT_UAE)
+
+/* Status */
+#define MBOX_STATUS_UA_MSK	BIT(8)
+
+#define MBOX_CMD_HEADER(client, id, len, indirect, cmd)     \
+	((((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_MSK) | \
+	(((indirect) << MBOX_HDR_I_LSB) & MBOX_HDR_I_MSK) | \
+	(((len) << MBOX_HDR_LEN_LSB) & MBOX_HDR_LEN_MSK)  | \
+	(((id) << MBOX_HDR_ID_LSB) & MBOX_HDR_ID_MSK)     | \
+	(((client) << MBOX_HDR_CLIENT_LSB) & MBOX_HDR_CLIENT_MSK))
+
+#define MBOX_RESP_ERR_GET(resp)				\
+	(((resp) & MBOX_HDR_CMD_MSK) >> MBOX_HDR_CMD_LSB)
+#define MBOX_RESP_LEN_GET(resp)			\
+	(((resp) & MBOX_HDR_LEN_MSK) >> MBOX_HDR_LEN_LSB)
+#define MBOX_RESP_ID_GET(resp)				\
+	(((resp) & MBOX_HDR_ID_MSK) >> MBOX_HDR_ID_LSB)
+#define MBOX_RESP_CLIENT_GET(resp)			\
+	(((resp) & MBOX_HDR_CLIENT_MSK) >> MBOX_HDR_CLIENT_LSB)
+
+/* Response error list */
+enum ALT_SDM_MBOX_RESP_CODE {
+	/* CMD completed successfully, but check resp ARGS for any errors */
+	MBOX_RESP_STATOK = 0,
+	/* CMD is incorrectly formatted in some way */
+	MBOX_RESP_INVALID_COMMAND = 1,
+	/* BootROM Command code not undesrtood */
+	MBOX_RESP_UNKNOWN_BR = 2,
+	/* CMD code not recognized by firmware */
+	MBOX_RESP_UNKNOWN = 3,
+	/* Indicates that the device is not configured */
+	MBOX_RESP_NOT_CONFIGURED = 256,
+	/* Indicates that the device is busy */
+	MBOX_RESP_DEVICE_BUSY = 0x1FF,
+	/* Indicates that there is no valid response available */
+	MBOX_RESP_NO_VALID_RESP_AVAILABLE = 0x2FF,
+	/* General Error */
+	MBOX_RESP_ERROR = 0x3FF,
+};
+
+/* Mailbox command list */
+#define MBOX_RESTART		2
+#define MBOX_CONFIG_STATUS	4

arch/arm/mach-socfpga/include/mach/mailbox_s10.h line 91

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +10 -0
+#define MBOX_RECONFIG		6
+#define MBOX_RECONFIG_MSEL	7
+#define MBOX_RECONFIG_DATA	8
+#define MBOX_RECONFIG_STATUS	9
+#define MBOX_QSPI_OPEN		50
+#define MBOX_QSPI_CLOSE		51
+#define MBOX_QSPI_DIRECT	59
+#define MBOX_REBOOT_HPS		71
+
+struct socfpga_mailbox {

We should probably just use register offset macros in new code, this struct {} stuff often doesn't work too well and the limitations are showing.

Quoted 86 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +64 -0
+	u32 cin;		/* command valid offset */
+	u32 rout;		/* response output offset */
+	u32 urg;		/* urgent command */
+	u32 flags;		/* interrupt enables */
+	u32 pad_0x10_0x1f[4];	/* 0x10 - 0x1F reserved */
+	u32 cout;		/* command free offset */
+	u32 rin;		/* respond valid offset */
+	u32 pad_0x28;		/* 0x28 reserved */
+	u32 status;		/* mailbox status */
+	u32 pad_0x30_0x3f[4];	/* 0x30 - 0x3F reserved */
+	u32 cmd_buf[MBOX_CMD_BUFFER_SIZE];	/* 0x40 - 0xBC circular command
+						 * buffer to SDM
+						 */
+	u32 resp_buf[MBOX_RESP_BUFFER_SIZE];	/* 0xC0 - 0xFF circular
+						 * response buffer
+						 */
+};
+
+/* Use define other than put into struct socfpga_mailbox to save spaces */
+#define MBOX_DOORBELL_TO_SDM_REG	(SOCFPGA_MAILBOX_ADDRESS + 0x400)
+#define MBOX_DOORBELL_FROM_SDM_REG	(SOCFPGA_MAILBOX_ADDRESS + 0x480)
+
+/******** Status and bit information returned by RECONFIG_STATUS ********/
+#define RECONFIG_STATUS_RESPONSE_LEN			6
+#define RECONFIG_STATUS_STATE				0
+#define RECONFIG_STATUS_PIN_STATUS			2
+#define RECONFIG_STATUS_SOFTFUNC_STATUS			3
+
+#define MBOX_CFGSTAT_STATE_IDLE				0x00000000
+#define MBOX_CFGSTAT_STATE_CONFIG			0x10000000
+#define MBOX_CFGSTAT_STATE_FAILACK			0x08000000
+#define MBOX_CFGSTAT_STATE_ERROR_INVALID		0xf0000001
+#define MBOX_CFGSTAT_STATE_ERROR_CORRUPT		0xf0000002
+#define MBOX_CFGSTAT_STATE_ERROR_AUTH			0xf0000003
+#define MBOX_CFGSTAT_STATE_ERROR_CORE_IO		0xf0000004
+#define MBOX_CFGSTAT_STATE_ERROR_HARDWARE		0xf0000005
+#define MBOX_CFGSTAT_STATE_ERROR_FAKE			0xf0000006
+#define MBOX_CFGSTAT_STATE_ERROR_BOOT_INFO		0xf0000007
+#define MBOX_CFGSTAT_STATE_ERROR_QSPI_ERROR		0xf0000008
+
+#define RCF_SOFTFUNC_STATUS_CONF_DONE			BIT(0)
+#define RCF_SOFTFUNC_STATUS_INIT_DONE			BIT(1)
+#define RCF_SOFTFUNC_STATUS_SEU_ERROR			BIT(3)
+#define RCF_PIN_STATUS_NSTATUS				BIT(31)
+/************************************************************************/
+
+int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg, u8 urgent,
+		  u32 *resp_buf_len, u32 *resp_buf);
+int mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
+		       u8 urgent, u32 *resp_buf_len, u32 *resp_buf);
+int mbox_send_cmd_only(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
+int mbox_send_cmd_only_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
+int mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len);
+int mbox_rcv_resp_psci(u32 *resp_buf, u32 resp_buf_max_len);
+int mbox_init(void);
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void);
+int mbox_qspi_open(void);
+#endif
+
+int mbox_reset_cold(void);
+
+#endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c new file +16 -0
new file mode 100644
index 0000000..ed713a9
@@ -0,0 +1,378 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/arch/system_manager.h>
+#include <asm/secure.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static __always_inline int mbox_polling_resp(u32 rout)

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+{
+	static const struct socfpga_mailbox *mbox_base =
+					(void *)SOCFPGA_MAILBOX_ADDRESS;
+	u32 rin;
+	unsigned long i = ~0;
+
+	while (i) {
+		rin = readl(&mbox_base->rin);
+		if (rout != rin)
+			return 0;

This looks like include/wait_bit.h reimplementation

Quoted 74 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +74 -0
+		i--;
+	}
+
+	return -ETIMEDOUT;
+}
+
+/* Check for available slot and write to circular buffer.
+ * It also update command valid offset (cin) register.
+ */
+static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
+						       u32 *arg)
+{
+	static const struct socfpga_mailbox *mbox_base =
+					(void *)SOCFPGA_MAILBOX_ADDRESS;
+	u32 cin;
+	u32 cout;
+	u32 i;
+
+	cin = readl(&mbox_base->cin) % MBOX_CMD_BUFFER_SIZE;
+	cout = readl(&mbox_base->cout) % MBOX_CMD_BUFFER_SIZE;
+
+	/* if command buffer is full or not enough free space
+	 * to fit the data
+	 */
+	if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
+	    ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
+	     MBOX_CMD_BUFFER_SIZE) < len)
+		return -ENOMEM;
+
+	/* write header to circular buffer */
+	writel(header, &mbox_base->cmd_buf[cin++]);
+	/* wrapping around when it reach the buffer size */
+	cin %= MBOX_CMD_BUFFER_SIZE;
+
+	/* write arguments */
+	for (i = 0; i < len; i++) {
+		writel(arg[i], &mbox_base->cmd_buf[cin++]);
+		/* wrapping around when it reach the buffer size */
+		cin %= MBOX_CMD_BUFFER_SIZE;
+	}
+
+	/* write command valid offset */
+	writel(cin, &mbox_base->cin);
+
+	return 0;
+}
+
+/* Check the command and fill it into circular buffer */
+static __always_inline int mbox_prepare_cmd_only(u8 id, u32 cmd,
+						 u8 is_indirect, u32 len,
+						 u32 *arg)
+{
+	u32 header;
+	int ret;
+
+	/* Total length is command + argument length */
+	if ((len + 1) > MBOX_CMD_BUFFER_SIZE)
+		return -EINVAL;
+
+	if (cmd > MBOX_MAX_CMD_INDEX)
+		return -EINVAL;
+
+	header = MBOX_CMD_HEADER(MBOX_CLIENT_ID_UBOOT, id, len,
+				 (is_indirect) ? 1 : 0, cmd);
+
+	ret = mbox_fill_cmd_circular_buff(header, len, arg);
+
+	return ret;
+}
+
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+						u8 is_indirect, u32 len,
+						u32 *arg)

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+{
+	int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+	/* write doorbell */
+	writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+	return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

Quoted 59 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +59 -0
+{
+	static const struct socfpga_mailbox *mbox_base =
+					(void *)SOCFPGA_MAILBOX_ADDRESS;
+	u32 rin;
+	u32 rout;
+	u32 resp_len = 0;
+
+	/* clear doorbell from SDM if it was SET */
+	if (readl((const u32 *)MBOX_DOORBELL_FROM_SDM_REG) & 1)
+		writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+	/* read current response offset */
+	rout = readl(&mbox_base->rout);
+	/* read response valid offset */
+	rin = readl(&mbox_base->rin);
+
+	while (rin != rout && (resp_len < resp_buf_max_len)) {
+		/* Response received */
+		if (resp_buf)
+			resp_buf[resp_len++] =
+				readl(&mbox_base->resp_buf[rout]);
+		rout++;
+		/* wrapping around when it reach the buffer size */
+		rout %= MBOX_RESP_BUFFER_SIZE;
+		/* update next ROUT */
+		writel(rout, &mbox_base->rout);
+	}
+
+	return resp_len;
+}
+
+/* Support one command and up to 31 words argument length only */
+static __always_inline int __mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect,
+					   u32 len, u32 *arg, u8 urgent,
+					   u32 *resp_buf_len, u32 *resp_buf)
+{
+	static const struct socfpga_mailbox *mbox_base =
+					(void *)SOCFPGA_MAILBOX_ADDRESS;
+
+	u32 rin;
+	u32 resp;
+	u32 rout;
+	u32 status;
+	u32 resp_len;
+	u32 buf_len;
+	int ret;
+
+	ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+	if (ret)
+		return ret;
+
+	if (urgent) {
+		/* Read status because it is toggled */
+		status = readl(&mbox_base->status) & MBOX_STATUS_UA_MSK;
+		/* Send command as urgent command */
+		writel(1, &mbox_base->urg);
+	}
+
+	/* write doorbell */

arch/arm/mach-socfpga/mailbox_s10.c line 180

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+	writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+	while (1) {
+		ret = ~0;
+
+		/* Wait for doorbell from SDM */
+		while (!readl(MBOX_DOORBELL_FROM_SDM_REG) && ret--)
+			;
+		if (!ret)
+			return -ETIMEDOUT;

wait_for_bit...

Quoted 127 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +127 -0
+		/* clear interrupt */
+		writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+		if (urgent) {
+			u32 new_status = readl(&mbox_base->status);
+			/* urgent command doesn't have response */
+			writel(0, &mbox_base->urg);
+			/* Urgent ACK is toggled */
+			if ((new_status & MBOX_STATUS_UA_MSK) ^ status)
+				return 0;
+
+			return -ECOMM;
+		}
+
+		/* read current response offset */
+		rout = readl(&mbox_base->rout);
+
+		/* read response valid offset */
+		rin = readl(&mbox_base->rin);
+
+		if (rout != rin) {
+			/* Response received */
+			resp = readl(&mbox_base->resp_buf[rout]);
+			rout++;
+			/* wrapping around when it reach the buffer size */
+			rout %= MBOX_RESP_BUFFER_SIZE;
+			/* update next ROUT */
+			writel(rout, &mbox_base->rout);
+
+			/* check client ID and ID */
+			if ((MBOX_RESP_CLIENT_GET(resp) == MBOX_CLIENT_ID_UBOOT) &&
+			    (MBOX_RESP_ID_GET(resp) == id)) {
+				ret = MBOX_RESP_ERR_GET(resp);
+				if (ret)
+					return ret;
+
+				if (resp_buf_len) {
+					buf_len = *resp_buf_len;
+					*resp_buf_len = 0;
+				} else {
+					buf_len = 0;
+				}
+
+				resp_len = MBOX_RESP_LEN_GET(resp);
+				while (resp_len) {
+					ret = mbox_polling_resp(rout);
+					if (ret)
+						return ret;
+					/* we need to process response buffer
+					 * even caller doesn't need it
+					 */
+					resp = readl(&mbox_base->resp_buf[rout]);
+					rout++;
+					resp_len--;
+					rout %= MBOX_RESP_BUFFER_SIZE;
+					writel(rout, &mbox_base->rout);
+					if (buf_len) {
+						/* copy response to buffer */
+						resp_buf[*resp_buf_len] = resp;
+						(*resp_buf_len)++;
+						buf_len--;
+					}
+				}
+				return ret;
+			}
+		}
+	};
+
+	return -EIO;
+}
+
+int mbox_init(void)
+{
+	static const struct socfpga_mailbox *mbox_base =
+					(void *)SOCFPGA_MAILBOX_ADDRESS;
+	int ret;
+
+	/* enable mailbox interrupts */
+	writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+	/* Ensure urgent request is cleared */
+	writel(0, &mbox_base->urg);
+
+	/* Ensure the Doorbell Interrupt is cleared */
+	writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+	ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_RESTART, MBOX_CMD_DIRECT, 0,
+			    NULL, 1, 0, NULL);
+	if (ret)
+		return ret;
+
+	/* Renable mailbox interrupts after MBOX_RESTART */
+	writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+	return 0;
+}
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void)
+{
+	return mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_CLOSE, MBOX_CMD_DIRECT,
+			     0, NULL, 0, 0, NULL);
+}
+
+int mbox_qspi_open(void)
+{
+	static const struct socfpga_system_manager *sysmgr_regs =
+		(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+	int ret;
+	u32 resp_buf[1];
+	u32 resp_buf_len;
+
+	ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_OPEN, MBOX_CMD_DIRECT,
+			    0, NULL, 0, 0, NULL);
+	if (ret) {
+		/* retry again by closing and reopen the QSPI again */
+		ret = mbox_qspi_close();
+		if (ret)
+			return ret;
+
+		ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_OPEN,
+				    MBOX_CMD_DIRECT, 0, NULL, 0, 0, NULL);
+		if (ret)
+			return ret;
+	}
+

arch/arm/mach-socfpga/mailbox_s10.c line 318

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+	/* HPS will directly control the QSPI controller, no longer mailbox */
+	resp_buf_len = 1;
+	ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_DIRECT, MBOX_CMD_DIRECT,
+			    0, NULL, 0, (u32 *)&resp_buf_len,
+			    (u32 *)&resp_buf);
+	if (ret)
+		goto error;
+
+	/* We are getting QSPI ref clock and set into sysmgr boot register */
+	printf("QSPI: Reference clock at %d Hz\n", resp_buf[0]);

Certainly something I can get out of clock or clk command, drop the print.

Quoted 11 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +11 -0
+	writel(resp_buf[0], &sysmgr_regs->boot_scratch_cold0);
+
+	return 0;
+
+error:
+	mbox_qspi_close();
+
+	return ret;
+}
+#endif /* CONFIG_CADENCE_QSPI */
+

arch/arm/mach-socfpga/mailbox_s10.c line 339

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+int mbox_reset_cold(void)
+{
+	int ret;
+
+	ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_REBOOT_HPS, MBOX_CMD_DIRECT,
+			    0, NULL, 0, 0, NULL);
+	if (ret) {
+		/* mailbox sent failure, wait for watchdog to kick in */
+		while (1)
+			;

Is this supposed to be hang() ?

arch/arm/mach-socfpga/mailbox_s10.c line 349

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+	}
+	return 0;
+}
+
+int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
+		  u8 urgent, u32 *resp_buf_len, u32 *resp_buf)
+{
+	return __mbox_send_cmd(id, cmd, is_indirect, len, arg, urgent,
+			       resp_buf_len, resp_buf);
+}

__anything is reserved for compiler, drop the leading underscores

Quoted 1 line
Signature · 2 lines
Best regards,
Marek Vasut
#28 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 117 lines · Marek Vasut
Quoted 116 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |    1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h |  155 +++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              |  378 ++++++++++++++++++++++
 3 files changed, 534 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/mailbox_s10.h
 create mode 100644 arch/arm/mach-socfpga/mailbox_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index b253914..43e18d2 100644
@@ -32,6 +32,7 @@ endif
 
 ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y        += clock_manager_s10.o
+obj-y        += mailbox_s10.o
 obj-y        += misc_s10.o
 obj-y        += reset_manager_s10.o
 obj-y        += system_manager_s10.o
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +86 -0
new file mode 100644
index 0000000..85e7f84
@@ -0,0 +1,155 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef _MAILBOX_S10_H_
+#define _MAILBOX_S10_H_
+
+/* user define Uboot ID */
+#define MBOX_CLIENT_ID_UBOOT 0xB
+#define MBOX_ID_UBOOT                0x1
+
+#define MBOX_CMD_DIRECT      0
+#define MBOX_CMD_INDIRECT    1
+
+#define MBOX_MAX_CMD_INDEX   2047
+#define MBOX_CMD_BUFFER_SIZE 32
+#define MBOX_RESP_BUFFER_SIZE        16
+
+#define MBOX_HDR_CMD_LSB     0
+#define MBOX_HDR_CMD_MSK     (BIT(11) - 1)
+#define MBOX_HDR_I_LSB               11
+#define MBOX_HDR_I_MSK               BIT(11)
+#define MBOX_HDR_LEN_LSB     12
+#define MBOX_HDR_LEN_MSK     0x007FF000
+#define MBOX_HDR_ID_LSB              24
+#define MBOX_HDR_ID_MSK              0x0F000000
+#define MBOX_HDR_CLIENT_LSB  28
+#define MBOX_HDR_CLIENT_MSK  0xF0000000
+
+/* Interrupt flags */
+#define MBOX_FLAGS_INT_COE   BIT(0)  /* COUT update interrupt enable */
+#define MBOX_FLAGS_INT_RIE   BIT(1)  /* RIN update interrupt enable */
+#define MBOX_FLAGS_INT_UAE   BIT(8)  /* Urgent ACK interrupt enable */
+#define MBOX_ALL_INTRS               (MBOX_FLAGS_INT_COE | \
+                              MBOX_FLAGS_INT_RIE | \
+                              MBOX_FLAGS_INT_UAE)
+
+/* Status */
+#define MBOX_STATUS_UA_MSK   BIT(8)
+
+#define MBOX_CMD_HEADER(client, id, len, indirect, cmd)     \
+     ((((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_MSK) | \
+     (((indirect) << MBOX_HDR_I_LSB) & MBOX_HDR_I_MSK) | \
+     (((len) << MBOX_HDR_LEN_LSB) & MBOX_HDR_LEN_MSK)  | \
+     (((id) << MBOX_HDR_ID_LSB) & MBOX_HDR_ID_MSK)     | \
+     (((client) << MBOX_HDR_CLIENT_LSB) & MBOX_HDR_CLIENT_MSK))
+
+#define MBOX_RESP_ERR_GET(resp)                              \
+     (((resp) & MBOX_HDR_CMD_MSK) >> MBOX_HDR_CMD_LSB)
+#define MBOX_RESP_LEN_GET(resp)                      \
+     (((resp) & MBOX_HDR_LEN_MSK) >> MBOX_HDR_LEN_LSB)
+#define MBOX_RESP_ID_GET(resp)                               \
+     (((resp) & MBOX_HDR_ID_MSK) >> MBOX_HDR_ID_LSB)
+#define MBOX_RESP_CLIENT_GET(resp)                   \
+     (((resp) & MBOX_HDR_CLIENT_MSK) >> MBOX_HDR_CLIENT_LSB)
+
+/* Response error list */
+enum ALT_SDM_MBOX_RESP_CODE {
+     /* CMD completed successfully, but check resp ARGS for any errors */
+     MBOX_RESP_STATOK = 0,
+     /* CMD is incorrectly formatted in some way */
+     MBOX_RESP_INVALID_COMMAND = 1,
+     /* BootROM Command code not undesrtood */
+     MBOX_RESP_UNKNOWN_BR = 2,
+     /* CMD code not recognized by firmware */
+     MBOX_RESP_UNKNOWN = 3,
+     /* Indicates that the device is not configured */
+     MBOX_RESP_NOT_CONFIGURED = 256,
+     /* Indicates that the device is busy */
+     MBOX_RESP_DEVICE_BUSY = 0x1FF,
+     /* Indicates that there is no valid response available */
+     MBOX_RESP_NO_VALID_RESP_AVAILABLE = 0x2FF,
+     /* General Error */
+     MBOX_RESP_ERROR = 0x3FF,
+};
+
+/* Mailbox command list */
+#define MBOX_RESTART         2
+#define MBOX_CONFIG_STATUS   4
+#define MBOX_RECONFIG                6
+#define MBOX_RECONFIG_MSEL   7
+#define MBOX_RECONFIG_DATA   8
+#define MBOX_RECONFIG_STATUS 9
+#define MBOX_QSPI_OPEN               50
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/mailbox_s10.h line 91

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +5 -0
+#define MBOX_QSPI_CLOSE              51
+#define MBOX_QSPI_DIRECT     59
+#define MBOX_REBOOT_HPS              71
+
+struct socfpga_mailbox {

We should probably just use register offset macros in new code, this struct {} stuff often doesn't work too well and the limitations are showing.

Okay, will change this.

Quoted 91 lines
Quoted 91 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +64 -0
+     u32 cin;                /* command valid offset */
+     u32 rout;               /* response output offset */
+     u32 urg;                /* urgent command */
+     u32 flags;              /* interrupt enables */
+     u32 pad_0x10_0x1f[4];   /* 0x10 - 0x1F reserved */
+     u32 cout;               /* command free offset */
+     u32 rin;                /* respond valid offset */
+     u32 pad_0x28;           /* 0x28 reserved */
+     u32 status;             /* mailbox status */
+     u32 pad_0x30_0x3f[4];   /* 0x30 - 0x3F reserved */
+     u32 cmd_buf[MBOX_CMD_BUFFER_SIZE];      /* 0x40 - 0xBC circular command
+                                              * buffer to SDM
+                                              */
+     u32 resp_buf[MBOX_RESP_BUFFER_SIZE];    /* 0xC0 - 0xFF circular
+                                              * response buffer
+                                              */
+};
+
+/* Use define other than put into struct socfpga_mailbox to save spaces */
+#define MBOX_DOORBELL_TO_SDM_REG     (SOCFPGA_MAILBOX_ADDRESS + 0x400)
+#define MBOX_DOORBELL_FROM_SDM_REG   (SOCFPGA_MAILBOX_ADDRESS + 0x480)
+
+/******** Status and bit information returned by RECONFIG_STATUS ********/
+#define RECONFIG_STATUS_RESPONSE_LEN                 6
+#define RECONFIG_STATUS_STATE                                0
+#define RECONFIG_STATUS_PIN_STATUS                   2
+#define RECONFIG_STATUS_SOFTFUNC_STATUS                      3
+
+#define MBOX_CFGSTAT_STATE_IDLE                              0x00000000
+#define MBOX_CFGSTAT_STATE_CONFIG                    0x10000000
+#define MBOX_CFGSTAT_STATE_FAILACK                   0x08000000
+#define MBOX_CFGSTAT_STATE_ERROR_INVALID             0xf0000001
+#define MBOX_CFGSTAT_STATE_ERROR_CORRUPT             0xf0000002
+#define MBOX_CFGSTAT_STATE_ERROR_AUTH                        0xf0000003
+#define MBOX_CFGSTAT_STATE_ERROR_CORE_IO             0xf0000004
+#define MBOX_CFGSTAT_STATE_ERROR_HARDWARE            0xf0000005
+#define MBOX_CFGSTAT_STATE_ERROR_FAKE                        0xf0000006
+#define MBOX_CFGSTAT_STATE_ERROR_BOOT_INFO           0xf0000007
+#define MBOX_CFGSTAT_STATE_ERROR_QSPI_ERROR          0xf0000008
+
+#define RCF_SOFTFUNC_STATUS_CONF_DONE                        BIT(0)
+#define RCF_SOFTFUNC_STATUS_INIT_DONE                        BIT(1)
+#define RCF_SOFTFUNC_STATUS_SEU_ERROR                        BIT(3)
+#define RCF_PIN_STATUS_NSTATUS                               BIT(31)
+/************************************************************************/
+
+int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg, u8 urgent,
+               u32 *resp_buf_len, u32 *resp_buf);
+int mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
+                    u8 urgent, u32 *resp_buf_len, u32 *resp_buf);
+int mbox_send_cmd_only(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
+int mbox_send_cmd_only_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
+int mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len);
+int mbox_rcv_resp_psci(u32 *resp_buf, u32 resp_buf_max_len);
+int mbox_init(void);
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void);
+int mbox_qspi_open(void);
+#endif
+
+int mbox_reset_cold(void);
+
+#endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c new file +20 -0
new file mode 100644
index 0000000..ed713a9
@@ -0,0 +1,378 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/arch/system_manager.h>
+#include <asm/secure.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Quoted 79 lines
Quoted 79 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +78 -0
+             i--;
+     }
+
+     return -ETIMEDOUT;
+}
+
+/* Check for available slot and write to circular buffer.
+ * It also update command valid offset (cin) register.
+ */
+static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
+                                                    u32 *arg)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 cin;
+     u32 cout;
+     u32 i;
+
+     cin = readl(&mbox_base->cin) % MBOX_CMD_BUFFER_SIZE;
+     cout = readl(&mbox_base->cout) % MBOX_CMD_BUFFER_SIZE;
+
+     /* if command buffer is full or not enough free space
+      * to fit the data
+      */
+     if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
+         ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
+          MBOX_CMD_BUFFER_SIZE) < len)
+             return -ENOMEM;
+
+     /* write header to circular buffer */
+     writel(header, &mbox_base->cmd_buf[cin++]);
+     /* wrapping around when it reach the buffer size */
+     cin %= MBOX_CMD_BUFFER_SIZE;
+
+     /* write arguments */
+     for (i = 0; i < len; i++) {
+             writel(arg[i], &mbox_base->cmd_buf[cin++]);
+             /* wrapping around when it reach the buffer size */
+             cin %= MBOX_CMD_BUFFER_SIZE;
+     }
+
+     /* write command valid offset */
+     writel(cin, &mbox_base->cin);
+
+     return 0;
+}
+
+/* Check the command and fill it into circular buffer */
+static __always_inline int mbox_prepare_cmd_only(u8 id, u32 cmd,
+                                              u8 is_indirect, u32 len,
+                                              u32 *arg)
+{
+     u32 header;
+     int ret;
+
+     /* Total length is command + argument length */
+     if ((len + 1) > MBOX_CMD_BUFFER_SIZE)
+             return -EINVAL;
+
+     if (cmd > MBOX_MAX_CMD_INDEX)
+             return -EINVAL;
+
+     header = MBOX_CMD_HEADER(MBOX_CLIENT_ID_UBOOT, id, len,
+                              (is_indirect) ? 1 : 0, cmd);
+
+     ret = mbox_fill_cmd_circular_buff(header, len, arg);
+
+     return ret;
+}
+
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+                                             u8 is_indirect, u32 len,
+                                             u32 *arg)
+{
+     int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+
+     return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

This function used in SMC call as well, so it needs to be inline when in secure section.

Quoted 64 lines
Quoted 64 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +63 -0
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
+     u32 rout;
+     u32 resp_len = 0;
+
+     /* clear doorbell from SDM if it was SET */
+     if (readl((const u32 *)MBOX_DOORBELL_FROM_SDM_REG) & 1)
+             writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+     /* read current response offset */
+     rout = readl(&mbox_base->rout);
+     /* read response valid offset */
+     rin = readl(&mbox_base->rin);
+
+     while (rin != rout && (resp_len < resp_buf_max_len)) {
+             /* Response received */
+             if (resp_buf)
+                     resp_buf[resp_len++] =
+                             readl(&mbox_base->resp_buf[rout]);
+             rout++;
+             /* wrapping around when it reach the buffer size */
+             rout %= MBOX_RESP_BUFFER_SIZE;
+             /* update next ROUT */
+             writel(rout, &mbox_base->rout);
+     }
+
+     return resp_len;
+}
+
+/* Support one command and up to 31 words argument length only */
+static __always_inline int __mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect,
+                                        u32 len, u32 *arg, u8 urgent,
+                                        u32 *resp_buf_len, u32 *resp_buf)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+
+     u32 rin;
+     u32 resp;
+     u32 rout;
+     u32 status;
+     u32 resp_len;
+     u32 buf_len;
+     int ret;
+
+     ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     if (ret)
+             return ret;
+
+     if (urgent) {
+             /* Read status because it is toggled */
+             status = readl(&mbox_base->status) & MBOX_STATUS_UA_MSK;
+             /* Send command as urgent command */
+             writel(1, &mbox_base->urg);
+     }
+
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+     while (1) {
+             ret = ~0;
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 180

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+
+             /* Wait for doorbell from SDM */
+             while (!readl(MBOX_DOORBELL_FROM_SDM_REG) && ret--)
+                     ;
+             if (!ret)
+                     return -ETIMEDOUT;

wait_for_bit...

Same reason as above.

Quoted 132 lines
Quoted 132 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +131 -0
+             /* clear interrupt */
+             writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+             if (urgent) {
+                     u32 new_status = readl(&mbox_base->status);
+                     /* urgent command doesn't have response */
+                     writel(0, &mbox_base->urg);
+                     /* Urgent ACK is toggled */
+                     if ((new_status & MBOX_STATUS_UA_MSK) ^ status)
+                             return 0;
+
+                     return -ECOMM;
+             }
+
+             /* read current response offset */
+             rout = readl(&mbox_base->rout);
+
+             /* read response valid offset */
+             rin = readl(&mbox_base->rin);
+
+             if (rout != rin) {
+                     /* Response received */
+                     resp = readl(&mbox_base->resp_buf[rout]);
+                     rout++;
+                     /* wrapping around when it reach the buffer size */
+                     rout %= MBOX_RESP_BUFFER_SIZE;
+                     /* update next ROUT */
+                     writel(rout, &mbox_base->rout);
+
+                     /* check client ID and ID */
+                     if ((MBOX_RESP_CLIENT_GET(resp) == MBOX_CLIENT_ID_UBOOT) &&
+                         (MBOX_RESP_ID_GET(resp) == id)) {
+                             ret = MBOX_RESP_ERR_GET(resp);
+                             if (ret)
+                                     return ret;
+
+                             if (resp_buf_len) {
+                                     buf_len = *resp_buf_len;
+                                     *resp_buf_len = 0;
+                             } else {
+                                     buf_len = 0;
+                             }
+
+                             resp_len = MBOX_RESP_LEN_GET(resp);
+                             while (resp_len) {
+                                     ret = mbox_polling_resp(rout);
+                                     if (ret)
+                                             return ret;
+                                     /* we need to process response buffer
+                                      * even caller doesn't need it
+                                      */
+                                     resp = readl(&mbox_base->resp_buf[rout]);
+                                     rout++;
+                                     resp_len--;
+                                     rout %= MBOX_RESP_BUFFER_SIZE;
+                                     writel(rout, &mbox_base->rout);
+                                     if (buf_len) {
+                                             /* copy response to buffer */
+                                             resp_buf[*resp_buf_len] = resp;
+                                             (*resp_buf_len)++;
+                                             buf_len--;
+                                     }
+                             }
+                             return ret;
+                     }
+             }
+     };
+
+     return -EIO;
+}
+
+int mbox_init(void)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     int ret;
+
+     /* enable mailbox interrupts */
+     writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+     /* Ensure urgent request is cleared */
+     writel(0, &mbox_base->urg);
+
+     /* Ensure the Doorbell Interrupt is cleared */
+     writel(0, MBOX_DOORBELL_FROM_SDM_REG);
+
+     ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_RESTART, MBOX_CMD_DIRECT, 0,
+                         NULL, 1, 0, NULL);
+     if (ret)
+             return ret;
+
+     /* Renable mailbox interrupts after MBOX_RESTART */
+     writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+     return 0;
+}
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void)
+{
+     return mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_CLOSE, MBOX_CMD_DIRECT,
+                          0, NULL, 0, 0, NULL);
+}
+
+int mbox_qspi_open(void)
+{
+     static const struct socfpga_system_manager *sysmgr_regs =
+             (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+     int ret;
+     u32 resp_buf[1];
+     u32 resp_buf_len;
+
+     ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_OPEN, MBOX_CMD_DIRECT,
+                         0, NULL, 0, 0, NULL);
+     if (ret) {
+             /* retry again by closing and reopen the QSPI again */
+             ret = mbox_qspi_close();
+             if (ret)
+                     return ret;
+
+             ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_OPEN,
+                                 MBOX_CMD_DIRECT, 0, NULL, 0, 0, NULL);
+             if (ret)
+                     return ret;
+     }
+
+     /* HPS will directly control the QSPI controller, no longer mailbox */
+     resp_buf_len = 1;
+     ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_QSPI_DIRECT, MBOX_CMD_DIRECT,
+                         0, NULL, 0, (u32 *)&resp_buf_len,
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 318

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+                         (u32 *)&resp_buf);
+     if (ret)
+             goto error;
+
+     /* We are getting QSPI ref clock and set into sysmgr boot register */
+     printf("QSPI: Reference clock at %d Hz\n", resp_buf[0]);

Certainly something I can get out of clock or clk command, drop the print.

In Stratix 10, QSPI IP is not in HPS, but in the SDM side. So, SW needs send mailbox command to get QSPI clock.
Will change printf to debug().

Quoted 16 lines
Quoted 16 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +15 -0
+     writel(resp_buf[0], &sysmgr_regs->boot_scratch_cold0);
+
+     return 0;
+
+error:
+     mbox_qspi_close();
+
+     return ret;
+}
+#endif /* CONFIG_CADENCE_QSPI */
+
+int mbox_reset_cold(void)
+{
+     int ret;
+
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 339

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+     ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_REBOOT_HPS, MBOX_CMD_DIRECT,
+                         0, NULL, 0, 0, NULL);
+     if (ret) {
+             /* mailbox sent failure, wait for watchdog to kick in */
+             while (1)
+                     ;

Is this supposed to be hang() ?

Okay, will change this.

Quoted 13 lines

arch/arm/mach-socfpga/mailbox_s10.c line 349

Quoted 11 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+     }
+     return 0;
+}
+
+int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
+               u8 urgent, u32 *resp_buf_len, u32 *resp_buf)
+{
+     return __mbox_send_cmd(id, cmd, is_indirect, len, arg, urgent,
+                            resp_buf_len, resp_buf);
+}

__anything is reserved for compiler, drop the leading underscores

Okay, will change to other name.

Quoted 6 lines
Quoted 1 line

--
Best regards,
Marek Vasut

#29 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +5 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

Quoted 4 lines

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Can't you just do timer_init() then ?

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +8 -0
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+                                             u8 is_indirect, u32 len,
+                                             u32 *arg)
+{
+     int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+
+     return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

Quoted 2 lines

This function used in SMC call as well, so it needs to be inline when in secure section.

Why ?

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

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 24 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 13 lines
Quoted 13 lines

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 11 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +11 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

Quoted 6 lines
Quoted 4 lines

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +4 -0
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+                                             u8 is_indirect, u32 len,
+                                             u32 *arg)

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+{
+     int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+     return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

Quoted 4 lines
Quoted 2 lines

This function used in SMC call as well, so it needs to be inline when in secure section.

Why ?

These functions needed for normal U-boot and SMC (secure section in OCM) and we need to copy the whole function to secure section, not just the API call.
This also avoid code duplication for U-boot and SMC.

Regards
Ley Foon

#31 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +5 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Quoted 4 lines
Quoted 1 line

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

So pieces of U-Boot remain in memory and get called by Linux, right ?

I am CCing a few more people , since this might need further discussion.

btw does this work when Linux is compiled in AArch32 mode while U-Boot is AArch64 ? I think it might not.

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 4 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +4 -0
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+                                             u8 is_indirect, u32 len,
+                                             u32 *arg)

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+{
+     int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+     return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This function used in SMC call as well, so it needs to be inline when in secure section.

Why ?

These functions needed for normal U-boot and SMC (secure section in OCM) and we need to copy the whole function to secure section, not just the API call.
This also avoid code duplication for U-boot and SMC.

Thanks for the explanation!

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

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 31 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +5 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

arch/arm/mach-socfpga/mailbox_s10.c line 26

Quoted 6 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

So pieces of U-Boot remain in memory and get called by Linux, right ?

Normal U-boot (in DDR) is destroyed after Linux is running, only SMC code Onchip memory will remain.
The existing U-boot have support this SMC feature, platform just need to configure the CONFIG_ARMV8_SECURE_BASE for the secure section. Of course, we need to enable CONFIG_ARMV8_PSCI too.

Quoted 5 lines

I am CCing a few more people , since this might need further discussion.

btw does this work when Linux is compiled in AArch32 mode while U-Boot is AArch64 ? I think it might not.

It should work. PSCI handle checks ESR_EL3.EC field to know whether it is SMC32 or SMC64.
See code in handle_sync near line 230 in
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv8/psci.S

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
Quoted 17 lines
Quoted 17 lines
Quoted 5 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +4 -0
+/* Send command only without waiting for responses from SDM */
+static __always_inline int __mbox_send_cmd_only(u8 id, u32 cmd,
+                                             u8 is_indirect, u32 len,
+                                             u32 *arg)

arch/arm/mach-socfpga/mailbox_s10.c line 111

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+{
+     int ret = mbox_prepare_cmd_only(id, cmd, is_indirect, len, arg);
+     /* write doorbell */
+     writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+     return ret;
+}
+
+/* Return number of responses received in buffer */
+static __always_inline int __mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len)

__always_inline is nonsense, drop it. Let the compiler do it's thing.

Quoted 2 lines

This function used in SMC call as well, so it needs to be inline when in secure section.

Why ?

Quoted 8 lines
Quoted 4 lines

These functions needed for normal U-boot and SMC (secure section in OCM) and we need to copy the whole function to secure section, not just the API call.
This also avoid code duplication for U-boot and SMC.

Thanks for the explanation!

--

Regards
Ley Foon

#33 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 37 lines · Ley Foon Tan
Quoted 36 lines · Marek Vasut
Quoted 34 lines · Ley Foon Tan
Quoted 24 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 13 lines
Quoted 13 lines

Review

Quoted 11 lines
(quoted diff) +11 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

Quoted 6 lines
Quoted 4 lines

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

Quoted 6 lines
Quoted 1 line

So pieces of U-Boot remain in memory and get called by Linux, right ?

Normal U-boot (in DDR) is destroyed after Linux is running, only SMC code Onchip memory will remain.
The existing U-boot have support this SMC feature, platform just need to configure the CONFIG_ARMV8_SECURE_BASE for the secure section. Of course, we need to enable CONFIG_ARMV8_PSCI too.

So piece of U-Boot then becomes the part which handles PSCI calls from Linux, do I understand it correctly ?

Quoted 8 lines
Quoted 4 lines

I am CCing a few more people , since this might need further discussion.

btw does this work when Linux is compiled in AArch32 mode while U-Boot is AArch64 ? I think it might not.

It should work. PSCI handle checks ESR_EL3.EC field to know whether it is SMC32 or SMC64.
See code in handle_sync near line 230 in
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv8/psci.S

Will do, thanks!

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

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 39 lines · Marek Vasut
Quoted 38 lines · Ley Foon Tan
Quoted 37 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Quoted 4 lines
Quoted 1 line

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

So pieces of U-Boot remain in memory and get called by Linux, right ?

Quoted 8 lines
Quoted 5 lines

Normal U-boot (in DDR) is destroyed after Linux is running, only SMC code Onchip memory will remain.
The existing U-boot have support this SMC feature, platform just need to configure the CONFIG_ARMV8_SECURE_BASE for the secure section. Of course, we need to enable CONFIG_ARMV8_PSCI too.

So piece of U-Boot then becomes the part which handles PSCI calls from Linux, do I understand it correctly ?

Yes, and we put this piece of code in onchip memory in our platform so it doesn't corrupted by Linux.

You can see detail in
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv8/u-boot.lds
All code related to PSCI/SMC will put in secure section.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I am CCing a few more people , since this might need further discussion.

btw does this work when Linux is compiled in AArch32 mode while U-Boot is AArch64 ? I think it might not.

Quoted 7 lines
Quoted 4 lines

It should work. PSCI handle checks ESR_EL3.EC field to know whether it is SMC32 or SMC64.
See code in handle_sync near line 230 in
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv8/psci.S

Will do, thanks!

--

Regards
Ley Foon

#35 lore raw

PATCH 8/16 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 46 lines · Ley Foon Tan
Quoted 45 lines · Marek Vasut
Quoted 43 lines · Ley Foon Tan
Quoted 31 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 7 lines · Ley Foon Tan
Quoted 6 lines · Marek Vasut
Quoted 5 lines · Ley Foon Tan

Add mailbox support for Stratix SoC

---

[...]

Quoted 17 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+static __always_inline int mbox_polling_resp(u32 rout)
+{
+     static const struct socfpga_mailbox *mbox_base =
+                                     (void *)SOCFPGA_MAILBOX_ADDRESS;
+     u32 rin;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+     unsigned long i = ~0;
+
+     while (i) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;

This looks like include/wait_bit.h reimplementation

The reason we use this method instead of using wait_bit because this function will use in Secure Monitor Call (SMC) call as well. When run in secure section, timer is not available. So, we can't use wait_for_bit.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Can't you just do timer_init() then ?

We can't use timer in secure region. This SMC code is resident in onchip memory (secure region) while Linux is running. So, timer might be used by Linux.

So pieces of U-Boot remain in memory and get called by Linux, right ?

Normal U-boot (in DDR) is destroyed after Linux is running, only SMC code Onchip memory will remain.
The existing U-boot have support this SMC feature, platform just need to configure the CONFIG_ARMV8_SECURE_BASE for the secure section. Of course, we need to enable CONFIG_ARMV8_PSCI too.

Quoted 8 lines
Quoted 2 lines

So piece of U-Boot then becomes the part which handles PSCI calls from Linux, do I understand it correctly ?

Yes, and we put this piece of code in onchip memory in our platform so it doesn't corrupted by Linux.

You can see detail in
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/cpu/armv8/u-boot.lds
All code related to PSCI/SMC will put in secure section.

I see, nice, I didnt know about that. Thanks

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

PATCH 9/16 arm: socfpga: stratix10: Add MMU support for Stratix10 SoC

In reply to Ley Foon Tan

Add MMU support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile        |    1 +
 arch/arm/mach-socfpga/mmu-arm64_s10.c |   71 +++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/mmu-arm64_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 43e18d2..098e5e9 100644
@@ -34,6 +34,7 @@ ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.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	+= wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/mmu-arm64_s10.c new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
1.7.1
#37 lore raw

PATCH 9/16 arm: socfpga: stratix10: Add MMU support for Stratix10 SoC

Quoted 1 line · Ley Foon Tan

Add MMU support for Stratix SoC

You could get more creative with the commit messages ;-)

Quoted 2 lines
Quoted 96 lines
---
 arch/arm/mach-socfpga/Makefile        |    1 +
 arch/arm/mach-socfpga/mmu-arm64_s10.c |   71 +++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/mmu-arm64_s10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 43e18d2..098e5e9 100644
@@ -34,6 +34,7 @@ ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
 obj-y	+= clock_manager_s10.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	+= wrap_pinmux_config_s10.o
arch/arm/mach-socfpga/mmu-arm64_s10.c new file +71 -0
new file mode 100644
index 0000000..670ceb9
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <asm/armv8/mmu.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct mm_region socfpga_stratix10_mem_map[] = {
+	{
+		/* MEM 2GB*/
+		.virt	= 0x0UL,
+		.phys	= 0x0UL,
+		.size	= 0x80000000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+				PTE_BLOCK_INNER_SHARE,
+	}, {
+		/* FPGA 1.5GB */
+		.virt	= 0x80000000UL,
+		.phys	= 0x80000000UL,
+		.size	= 0x60000000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+				PTE_BLOCK_NON_SHARE |
+				PTE_BLOCK_PXN | PTE_BLOCK_UXN,
+	}, {
+		/* DEVICE 142MB */
+		.virt	= 0xF7000000UL,
+		.phys	= 0xF7000000UL,
+		.size	= 0x08E00000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+				PTE_BLOCK_NON_SHARE |
+				PTE_BLOCK_PXN | PTE_BLOCK_UXN,
+	}, {
+		/* OCRAM 1MB but available 256KB */
+		.virt	= 0xFFE00000UL,
+		.phys	= 0xFFE00000UL,
+		.size	= 0x00100000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+				PTE_BLOCK_INNER_SHARE,
+	}, {
+		/* DEVICE 32KB */
+		.virt	= 0xFFFC0000UL,
+		.phys	= 0xFFFC0000UL,
+		.size	= 0x00008000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+				PTE_BLOCK_NON_SHARE |
+				PTE_BLOCK_PXN | PTE_BLOCK_UXN,
+	}, {
+		/* MEM 124GB */
+		.virt	= 0x0100000000UL,
+		.phys	= 0x0100000000UL,
+		.size	= 0x1F00000000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+				PTE_BLOCK_INNER_SHARE,
+	}, {
+		/* DEVICE 4GB */
+		.virt	= 0x2000000000UL,
+		.phys	= 0x2000000000UL,
+		.size	= 0x0100000000UL,
+		.attrs	= PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+				PTE_BLOCK_NON_SHARE |
+				PTE_BLOCK_PXN | PTE_BLOCK_UXN,
+	}, {
+		/* List terminator */
+	},
+};
+
+struct mm_region *mem_map = socfpga_stratix10_mem_map;
Signature · 2 lines
Best regards,
Marek Vasut
#38 lore raw

PATCH 10/16 arm: dts: Add dts for Stratix10 SoC

In reply to Ley Foon Tan

Device tree for Stratix10 SoC

---
 arch/arm/dts/Makefile                    |    3 +-
 arch/arm/dts/socfpga_stratix10_socdk.dts |  282 ++++++++++++++++++++++++++++++
 2 files changed, 284 insertions(+), 1 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_stratix10_socdk.dts
arch/arm/dts/Makefile +2 -1
index 62fbf32..61df5af 100644
@@ -193,7 +193,8 @@ dtb-$(CONFIG_ARCH_SOCFPGA) +=				\
 	socfpga_cyclone5_sockit.dtb			\
 	socfpga_cyclone5_socrates.dtb			\
 	socfpga_cyclone5_sr1500.dtb			\
-	socfpga_cyclone5_vining_fpga.dtb
+	socfpga_cyclone5_vining_fpga.dtb		\
+	socfpga_stratix10_socdk.dtb
 
 dtb-$(CONFIG_TARGET_DRA7XX_EVM) += dra72-evm.dtb dra7-evm.dtb	\
 	dra72-evm-revc.dtb dra71-evm.dtb dra76-evm.dtb
arch/arm/dts/socfpga_stratix10_socdk.dts new file +282 -0

282 lines not on this page · raw message

Signature · 1 line
1.7.1
#41 lore raw

PATCH 11/16 arm: socfpga: Restructure the SPL file

In reply to Ley Foon Tan

Restructure the SPL so each devices such as CV, A10 and S10 will have their own dedicated SPL file. SPL file determine the HW initialization flow which is device specific

---
 arch/arm/mach-socfpga/Makefile              |    5 +-
 arch/arm/mach-socfpga/spl_a10.c             |  105 +++++++++++++++++++++++++++
 arch/arm/mach-socfpga/{spl.c => spl_gen5.c} |   57 +++------------
 3 files changed, 120 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/spl_a10.c
 rename arch/arm/mach-socfpga/{spl.c => spl_gen5.c} (82%)
arch/arm/mach-socfpga/Makefile +4 -1
index 098e5e9..b669d43 100644
@@ -41,13 +41,16 @@ obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
 ifdef CONFIG_SPL_BUILD
-obj-y	+= spl.o
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
+obj-y	+= spl_gen5.o
 obj-y	+= freeze_controller.o
 obj-y	+= wrap_iocsr_config.o
 obj-y	+= wrap_pinmux_config.o
 obj-y	+= wrap_sdram_config.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
+obj-y	+= spl_a10.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/spl_a10.c new file +105 -0

105 lines not on this page · raw message

arch/arm/mach-socfpga/spl_gen5.c renamed from arch/arm/mach-socfpga/spl.c +11 -46

81 lines not on this page · raw message

Signature · 1 line
1.7.1
#42 lore raw

PATCH 12/16 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

In reply to Ley Foon Tan

Add SPL driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                    |    4 +
 arch/arm/mach-socfpga/include/mach/firewall_s10.h |   84 +++++++++
 arch/arm/mach-socfpga/spl_s10.c                   |  205 +++++++++++++++++++++
 3 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/firewall_s10.h
 create mode 100644 arch/arm/mach-socfpga/spl_s10.c
arch/arm/mach-socfpga/Makefile +4 -0
index b669d43..35b124a 100644
@@ -40,6 +40,7 @@ obj-y	+= system_manager_s10.o
 obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
+
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y	+= spl_gen5.o
@@ -51,6 +52,9 @@ endif
 ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
 obj-y	+= spl_a10.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y	+= spl_s10.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +84 -0

84 lines not on this page · raw message

arch/arm/mach-socfpga/spl_s10.c new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
1.7.1
#43 lore raw

PATCH 12/16 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

Quoted 112 lines · Ley Foon Tan

Add SPL driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                    |    4 +
 arch/arm/mach-socfpga/include/mach/firewall_s10.h |   84 +++++++++
 arch/arm/mach-socfpga/spl_s10.c                   |  205 +++++++++++++++++++++
 3 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/firewall_s10.h
 create mode 100644 arch/arm/mach-socfpga/spl_s10.c
arch/arm/mach-socfpga/Makefile +4 -0
index b669d43..35b124a 100644
@@ -40,6 +40,7 @@ obj-y	+= system_manager_s10.o
 obj-y	+= wrap_pinmux_config_s10.o
 obj-y	+= wrap_pll_config_s10.o
 endif
+
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y	+= spl_gen5.o
@@ -51,6 +52,9 @@ endif
 ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
 obj-y	+= spl_a10.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y	+= spl_s10.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +72 -0
new file mode 100644
index 0000000..70aa9a6
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef	_FIREWALL_S10_
+#define	_FIREWALL_S10_
+
+struct socfpga_firwall_l4_per {
+	u32	nand;		/* 0x00 */
+	u32	nand_data;
+	u32	_pad_0x8;
+	u32	usb0;
+	u32	usb1;		/* 0x10 */
+	u32	_pad_0x14;
+	u32	_pad_0x18;
+	u32	spim0;
+	u32	spim1;		/* 0x20 */
+	u32	spis0;
+	u32	spis1;
+	u32	emac0;
+	u32	emac1;		/* 0x30 */
+	u32	emac2;
+	u32	_pad_0x38;
+	u32	_pad_0x3c;
+	u32	sdmmc;		/* 0x40 */
+	u32	gpio0;
+	u32	gpio1;
+	u32	_pad_0x4c;
+	u32	i2c0;		/* 0x50 */
+	u32	i2c1;
+	u32	i2c2;
+	u32	i2c3;
+	u32	i2c4;		/* 0x60 */
+	u32	timer0;
+	u32	timer1;
+	u32	uart0;
+	u32	uart1;		/* 0x70 */
+};
+
+struct socfpga_firwall_l4_sys {
+	u32	_pad_0x00;		/* 0x00 */
+	u32	_pad_0x04;
+	u32	dma_ecc;
+	u32	emac0rx_ecc;
+	u32	emac0tx_ecc;		/* 0x10 */
+	u32	emac1rx_ecc;
+	u32	emac1tx_ecc;
+	u32	emac2rx_ecc;
+	u32	emac2tx_ecc;		/* 0x20 */
+	u32	_pad_0x24;
+	u32	_pad_0x28;
+	u32	nand_ecc;
+	u32	nand_read_ecc;		/* 0x30 */
+	u32	nand_write_ecc;
+	u32	ocram_ecc;
+	u32	_pad_0x3c;
+	u32	sdmmc_ecc;		/* 0x40 */
+	u32	usb0_ecc;
+	u32	usb1_ecc;
+	u32	clock_manager;
+	u32	_pad_0x50;		/* 0x50 */
+	u32	io_manager;
+	u32	reset_manager;
+	u32	system_manager;
+	u32	osc0_timer;		/* 0x60 */
+	u32	osc1_timer;
+	u32	watchdog0;
+	u32	watchdog1;
+	u32	watchdog2;		/* 0x70 */
+	u32	watchdog3;

arch/arm/mach-socfpga/include/mach/firewall_s10.h line 82

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +10 -0
+};
+
+#define FIREWALL_L4_DISABLE_ALL		(BIT(0) | BIT(24) | BIT(16))
+#define FIREWALL_BRIDGE_DISABLE_ALL	(~0)
+
+#define CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR	0xf7004688
+#define CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR	0xf7018628
+
+#define CCU_ADMASK_P_MASK			(BIT(0))
+#define CCU_ADMASK_NS_MASK			(BIT(1))

Drop outer parenthesis

Quoted 71 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +2 -0
+
+#endif /* _FIREWALL_S10_ */
arch/arm/mach-socfpga/spl_s10.c new file +63 -0
new file mode 100644
index 0000000..3b3833d
@@ -0,0 +1,205 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <image.h>
+#include <asm/arch/reset_manager.h>
+#include <spl.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/sdram_s10.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/arch/firewall_s10.h>
+#include <watchdog.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_firwall_l4_per *firwall_l4_per_base =
+	(struct socfpga_firwall_l4_per *)SOCFPGA_FIREWALL_L4_PER;
+static const struct socfpga_firwall_l4_sys *firwall_l4_sys_base =
+	(struct socfpga_firwall_l4_sys *)SOCFPGA_FIREWALL_L4_SYS;
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+u32 spl_boot_device(void)
+{
+	/* TODO: Get from SDM or handoff */
+	return BOOT_DEVICE_MMC1;
+}
+
+#ifdef CONFIG_SPL_MMC_SUPPORT
+u32 spl_boot_mode(const u32 boot_device)
+{
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+	return MMCSD_MODE_FS;
+#else
+	return MMCSD_MODE_RAW;
+#endif
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+	const struct cm_config *cm_default_cfg = cm_get_default_config();
+
+#ifdef CONFIG_HW_WATCHDOG
+	/* Ensure watchdog is paused when debugging is happening */
+	writel(SYSMGR_WDDBG_PAUSE_ALL_CPU, &sysmgr_regs->wddbg);
+
+	/* Enable watchdog before initializing the HW */
+	socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
+	socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
+	hw_watchdog_init();
+#endif
+
+	/* ensure all processors are not released prior Linux boot */
+	writeq(0, CPU_RELEASE_ADDR);
+

arch/arm/mach-socfpga/spl_s10.c line 73

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+	socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0);
+	timer_init();
+
+	populate_sysmgr_pinmux();
+
+	/* configuring the HPS clocks */
+	cm_basic_init(cm_default_cfg);
+
+	/* enable console uart printing */
+#if (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART0_ADDRESS)

Yoda notation, please fix. Also, shouldn't the reset controller handle this ?

arch/arm/mach-socfpga/spl_s10.c line 84

Quoted 11 lines
arch/arm/mach-socfpga/spl_s10.c new file +11 -0
+	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
+	/* enables nonsecure access to UART0 */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart0);
+#elif (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART1_ADDRESS)
+	socfpga_per_reset(SOCFPGA_RESET(UART1), 0);
+	/* enables nonsecure access to UART1 */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart1);
+#endif
+
+	preloader_console_init();
+	cm_print_clock_quick_summary();

This function doesn't fit on my pivoted 4k screen with small font, it is clearly too long. Please split it.

Quoted 23 lines
arch/arm/mach-socfpga/spl_s10.c new file +23 -0
+	/* enable non-secure interface to DMA330 DMA and peripherals */
+	writel(SYSMGR_DMA_IRQ_NS | SYSMGR_DMA_MGR_NS, &sysmgr_regs->dma);
+	writel(SYSMGR_DMAPERIPH_ALL_NS, &sysmgr_regs->dma_periph);
+	/* enable DMA330 DMA */
+	socfpga_per_reset(SOCFPGA_RESET(DMA), 0);
+
+	/*
+	 * The following lines of code will enable non-secure access
+	 * to nand, usb, spi, emac, sdmmc, gpio, i2c, and timers. This
+	 * is needed as most OS run in non-secure mode. Thus we need to
+	 * enable non-secure access to these peripherals in order for the
+	 * OS to use these peripherals.
+	 */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand_data);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac2);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->sdmmc);

arch/arm/mach-socfpga/spl_s10.c line 118

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->sdmmc_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c2);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c3);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c4);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer1);

Turn this into a table ?

Quoted 29 lines
arch/arm/mach-socfpga/spl_s10.c new file +29 -0
+	/* enables nonsecure access to clock mgr */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->clock_manager);
+
+	/* enables nonsecure access to reset mgr */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->reset_manager);
+
+	/* enables nonsecure access to system mgr */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->system_manager);
+
+	/* enables nonsecure access to OCRAM */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->ocram_ecc);
+
+	/* enables nonsecure access to all the emacs */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0rx_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0tx_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1rx_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1tx_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2rx_ecc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2tx_ecc);
+
+	/* enables nonsecure access to SMMU */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->io_manager);
+
+	/* enables nonsecure access to watchdog */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog1);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog2);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog3);
+

arch/arm/mach-socfpga/spl_s10.c line 158

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+	/* enables SDMMC */
+	socfpga_per_reset(SOCFPGA_RESET(SDMMC_OCP), 0);
+	socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0);
+	/* enable usb0 and usb1 */
+	socfpga_per_reset(SOCFPGA_RESET(USB0), 0);
+	socfpga_per_reset(SOCFPGA_RESET(USB1), 0);
+	socfpga_per_reset(SOCFPGA_RESET(USB0_OCP), 0);
+	socfpga_per_reset(SOCFPGA_RESET(USB1_OCP), 0);
+	/* enable SPIM1 */
+	socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

See below.

Quoted 9 lines
arch/arm/mach-socfpga/spl_s10.c new file +9 -0
+	/* disable lwsocf2fpga and soc2fpga bridge security */
+	writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_SOC2FPGA);
+	writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_LWSOC2FPGA);
+
+	/* disable SMMU security */
+	writel(FIREWALL_L4_DISABLE_ALL, SOCFPGA_FIREWALL_TCU);
+
+	/* disable ocram security at CCU for non secure access */
+	clrbits_le32(CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR,

arch/arm/mach-socfpga/spl_s10.c line 178

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+		     CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+	clrbits_le32(CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR,
+		     CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+
+	/* enable i2c1 */
+	socfpga_per_reset(SOCFPGA_RESET(I2C1), 0);
+
+	/* Take GPIO0 & GPIO1 out of reset */
+	socfpga_per_reset(SOCFPGA_RESET(GPIO0), 0);
+	socfpga_per_reset(SOCFPGA_RESET(GPIO1), 0);

Shouldn't this be done by the reset framework ?

arch/arm/mach-socfpga/spl_s10.c line 182

Quoted 3 lines
arch/arm/mach-socfpga/spl_s10.c new file +3 -0
+	/* enable SPIM0 and SPIM1 */
+	socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
+	socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

You ungated this SPI block already like 20 lines above.

Quoted 6 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+	puts("DDR: Initializing Hard Memory Controller\n");
+	if (sdram_mmr_init_full(0)) {
+		puts("DDR: Initialization failed.\n");
+		hang();
+	}
+

arch/arm/mach-socfpga/spl_s10.c line 199

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+	gd->ram_size = sdram_calculate_size();
+	printf("DDR: %d MiB\n", (int)(gd->ram_size >> 20));
+
+	/* Sanity check ensure correct SDRAM size specified */
+	puts("DDR: Running SDRAM size sanity check\n");
+	if (get_ram_size(0, gd->ram_size) != gd->ram_size) {
+		puts("DDR: SDRAM size check failed!\n");
+		hang();
+	}
+	puts("DDR: SDRAM size check passed!\n");

You can probably turn most of those ad-hoc prints into debug()s.

Quoted 7 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+
+#ifdef CONFIG_CADENCE_QSPI
+	mbox_init();
+	mbox_qspi_open();
+#endif
+}
Signature · 2 lines
Best regards,
Marek Vasut
#44 lore raw

PATCH 12/16 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

Quoted 117 lines · Marek Vasut
Quoted 116 lines · Ley Foon Tan

Add SPL driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                    |    4 +
 arch/arm/mach-socfpga/include/mach/firewall_s10.h |   84 +++++++++
 arch/arm/mach-socfpga/spl_s10.c                   |  205 +++++++++++++++++++++
 3 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/firewall_s10.h
 create mode 100644 arch/arm/mach-socfpga/spl_s10.c
arch/arm/mach-socfpga/Makefile +4 -0
index b669d43..35b124a 100644
@@ -40,6 +40,7 @@ obj-y       += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
 obj-y        += wrap_pll_config_s10.o
 endif
+
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y        += spl_gen5.o
@@ -51,6 +52,9 @@ endif
 ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
 obj-y        += spl_a10.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y        += spl_s10.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +76 -0
new file mode 100644
index 0000000..70aa9a6
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef      _FIREWALL_S10_
+#define      _FIREWALL_S10_
+
+struct socfpga_firwall_l4_per {
+     u32     nand;           /* 0x00 */
+     u32     nand_data;
+     u32     _pad_0x8;
+     u32     usb0;
+     u32     usb1;           /* 0x10 */
+     u32     _pad_0x14;
+     u32     _pad_0x18;
+     u32     spim0;
+     u32     spim1;          /* 0x20 */
+     u32     spis0;
+     u32     spis1;
+     u32     emac0;
+     u32     emac1;          /* 0x30 */
+     u32     emac2;
+     u32     _pad_0x38;
+     u32     _pad_0x3c;
+     u32     sdmmc;          /* 0x40 */
+     u32     gpio0;
+     u32     gpio1;
+     u32     _pad_0x4c;
+     u32     i2c0;           /* 0x50 */
+     u32     i2c1;
+     u32     i2c2;
+     u32     i2c3;
+     u32     i2c4;           /* 0x60 */
+     u32     timer0;
+     u32     timer1;
+     u32     uart0;
+     u32     uart1;          /* 0x70 */
+};
+
+struct socfpga_firwall_l4_sys {
+     u32     _pad_0x00;              /* 0x00 */
+     u32     _pad_0x04;
+     u32     dma_ecc;
+     u32     emac0rx_ecc;
+     u32     emac0tx_ecc;            /* 0x10 */
+     u32     emac1rx_ecc;
+     u32     emac1tx_ecc;
+     u32     emac2rx_ecc;
+     u32     emac2tx_ecc;            /* 0x20 */
+     u32     _pad_0x24;
+     u32     _pad_0x28;
+     u32     nand_ecc;
+     u32     nand_read_ecc;          /* 0x30 */
+     u32     nand_write_ecc;
+     u32     ocram_ecc;
+     u32     _pad_0x3c;
+     u32     sdmmc_ecc;              /* 0x40 */
+     u32     usb0_ecc;
+     u32     usb1_ecc;
+     u32     clock_manager;
+     u32     _pad_0x50;              /* 0x50 */
+     u32     io_manager;
+     u32     reset_manager;
+     u32     system_manager;
+     u32     osc0_timer;             /* 0x60 */
+     u32     osc1_timer;
+     u32     watchdog0;
+     u32     watchdog1;
+     u32     watchdog2;              /* 0x70 */
+     u32     watchdog3;
+};
+
+#define FIREWALL_L4_DISABLE_ALL              (BIT(0) | BIT(24) | BIT(16))
+#define FIREWALL_BRIDGE_DISABLE_ALL  (~0)
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/firewall_s10.h line 82

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +6 -0
+
+#define CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR   0xf7004688
+#define CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR    0xf7018628
+
+#define CCU_ADMASK_P_MASK                    (BIT(0))
+#define CCU_ADMASK_NS_MASK                   (BIT(1))

Drop outer parenthesis

Noted.

Quoted 77 lines
Quoted 77 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +2 -0
+
+#endif /* _FIREWALL_S10_ */
arch/arm/mach-socfpga/spl_s10.c new file +68 -0
new file mode 100644
index 0000000..3b3833d
@@ -0,0 +1,205 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <image.h>
+#include <asm/arch/reset_manager.h>
+#include <spl.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/sdram_s10.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/arch/firewall_s10.h>
+#include <watchdog.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_firwall_l4_per *firwall_l4_per_base =
+     (struct socfpga_firwall_l4_per *)SOCFPGA_FIREWALL_L4_PER;
+static const struct socfpga_firwall_l4_sys *firwall_l4_sys_base =
+     (struct socfpga_firwall_l4_sys *)SOCFPGA_FIREWALL_L4_SYS;
+static struct socfpga_system_manager *sysmgr_regs =
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+u32 spl_boot_device(void)
+{
+     /* TODO: Get from SDM or handoff */
+     return BOOT_DEVICE_MMC1;
+}
+
+#ifdef CONFIG_SPL_MMC_SUPPORT
+u32 spl_boot_mode(const u32 boot_device)
+{
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+     return MMCSD_MODE_FS;
+#else
+     return MMCSD_MODE_RAW;
+#endif
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+     const struct cm_config *cm_default_cfg = cm_get_default_config();
+
+#ifdef CONFIG_HW_WATCHDOG
+     /* Ensure watchdog is paused when debugging is happening */
+     writel(SYSMGR_WDDBG_PAUSE_ALL_CPU, &sysmgr_regs->wddbg);
+
+     /* Enable watchdog before initializing the HW */
+     socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
+     socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
+     hw_watchdog_init();
+#endif
+
+     /* ensure all processors are not released prior Linux boot */
+     writeq(0, CPU_RELEASE_ADDR);
+
+     socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0);
+     timer_init();
+
+     populate_sysmgr_pinmux();
+
Quoted 8 lines

arch/arm/mach-socfpga/spl_s10.c line 73

Quoted 5 lines
arch/arm/mach-socfpga/spl_s10.c new file +5 -0
+     /* configuring the HPS clocks */
+     cm_basic_init(cm_default_cfg);
+
+     /* enable console uart printing */
+#if (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART0_ADDRESS)

Yoda notation, please fix. Also, shouldn't the reset controller handle this ?

Will remove this and use reset framework.

Quoted 15 lines

arch/arm/mach-socfpga/spl_s10.c line 84

Quoted 12 lines
arch/arm/mach-socfpga/spl_s10.c new file +11 -0
+     socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
+     /* enables nonsecure access to UART0 */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart0);
+#elif (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART1_ADDRESS)
+     socfpga_per_reset(SOCFPGA_RESET(UART1), 0);
+     /* enables nonsecure access to UART1 */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart1);
+#endif
+
+     preloader_console_init();
+     cm_print_clock_quick_summary();

This function doesn't fit on my pivoted 4k screen with small font, it is clearly too long. Please split it.

Okay, will split this function into sub-functions.

Quoted 35 lines
Quoted 24 lines
arch/arm/mach-socfpga/spl_s10.c new file +23 -0
+     /* enable non-secure interface to DMA330 DMA and peripherals */
+     writel(SYSMGR_DMA_IRQ_NS | SYSMGR_DMA_MGR_NS, &sysmgr_regs->dma);
+     writel(SYSMGR_DMAPERIPH_ALL_NS, &sysmgr_regs->dma_periph);
+     /* enable DMA330 DMA */
+     socfpga_per_reset(SOCFPGA_RESET(DMA), 0);
+
+     /*
+      * The following lines of code will enable non-secure access
+      * to nand, usb, spi, emac, sdmmc, gpio, i2c, and timers. This
+      * is needed as most OS run in non-secure mode. Thus we need to
+      * enable non-secure access to these peripherals in order for the
+      * OS to use these peripherals.
+      */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand_data);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->sdmmc);

arch/arm/mach-socfpga/spl_s10.c line 118

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->sdmmc_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c3);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c4);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer1);
Quoted 1 line

Turn this into a table ?

Okay.

Quoted 56 lines
Quoted 30 lines
arch/arm/mach-socfpga/spl_s10.c new file +29 -0
+     /* enables nonsecure access to clock mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->clock_manager);
+
+     /* enables nonsecure access to reset mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->reset_manager);
+
+     /* enables nonsecure access to system mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->system_manager);
+
+     /* enables nonsecure access to OCRAM */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->ocram_ecc);
+
+     /* enables nonsecure access to all the emacs */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0tx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1tx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2tx_ecc);
+
+     /* enables nonsecure access to SMMU */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->io_manager);
+
+     /* enables nonsecure access to watchdog */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog3);
+

arch/arm/mach-socfpga/spl_s10.c line 158

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+     /* enables SDMMC */
+     socfpga_per_reset(SOCFPGA_RESET(SDMMC_OCP), 0);
+     socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0);
+     /* enable usb0 and usb1 */
+     socfpga_per_reset(SOCFPGA_RESET(USB0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB1), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB0_OCP), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB1_OCP), 0);
+     /* enable SPIM1 */
+     socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

See below.

Quoted 13 lines
arch/arm/mach-socfpga/spl_s10.c new file +13 -0
+     /* disable lwsocf2fpga and soc2fpga bridge security */
+     writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_SOC2FPGA);
+     writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_LWSOC2FPGA);
+
+     /* disable SMMU security */
+     writel(FIREWALL_L4_DISABLE_ALL, SOCFPGA_FIREWALL_TCU);
+
+     /* disable ocram security at CCU for non secure access */
+     clrbits_le32(CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR,
+                  CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+     clrbits_le32(CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR,
+                  CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+
Quoted 8 lines

arch/arm/mach-socfpga/spl_s10.c line 178

Quoted 6 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+     /* enable i2c1 */
+     socfpga_per_reset(SOCFPGA_RESET(I2C1), 0);
+
+     /* Take GPIO0 & GPIO1 out of reset */
+     socfpga_per_reset(SOCFPGA_RESET(GPIO0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(GPIO1), 0);

Shouldn't this be done by the reset framework ?

Yes, will update DW GPIO to use reset framework.

Quoted 6 lines

arch/arm/mach-socfpga/spl_s10.c line 182

Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c new file +3 -0
+     /* enable SPIM0 and SPIM1 */
+     socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

You ungated this SPI block already like 20 lines above.

Will remove.

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+     puts("DDR: Initializing Hard Memory Controller\n");
+     if (sdram_mmr_init_full(0)) {
+             puts("DDR: Initialization failed.\n");
+             hang();
+     }
+
+     gd->ram_size = sdram_calculate_size();
+     printf("DDR: %d MiB\n", (int)(gd->ram_size >> 20));
+
+     /* Sanity check ensure correct SDRAM size specified */
Quoted 8 lines

arch/arm/mach-socfpga/spl_s10.c line 199

Quoted 6 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+     puts("DDR: Running SDRAM size sanity check\n");
+     if (get_ram_size(0, gd->ram_size) != gd->ram_size) {
+             puts("DDR: SDRAM size check failed!\n");
+             hang();
+     }
+     puts("DDR: SDRAM size check passed!\n");

You can probably turn most of those ad-hoc prints into debug()s.

Noted.

Quoted 13 lines

arch/arm/mach-socfpga/spl_s10.c line 205

Quoted 8 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+
+#ifdef CONFIG_CADENCE_QSPI
+     mbox_init();
+     mbox_qspi_open();
+#endif
+}

--
Best regards,
Marek Vasut

#45 lore raw

PATCH 12/16 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

Quoted 330 lines · Ley Foon Tan
Quoted 117 lines · Marek Vasut
Quoted 116 lines · Ley Foon Tan

Add SPL driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                    |    4 +
 arch/arm/mach-socfpga/include/mach/firewall_s10.h |   84 +++++++++
 arch/arm/mach-socfpga/spl_s10.c                   |  205 +++++++++++++++++++++
 3 files changed, 293 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/firewall_s10.h
 create mode 100644 arch/arm/mach-socfpga/spl_s10.c
arch/arm/mach-socfpga/Makefile +4 -0
index b669d43..35b124a 100644
@@ -40,6 +40,7 @@ obj-y       += system_manager_s10.o
 obj-y        += wrap_pinmux_config_s10.o
 obj-y        += wrap_pll_config_s10.o
 endif
+
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
 obj-y        += spl_gen5.o
@@ -51,6 +52,9 @@ endif
 ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
 obj-y        += spl_a10.o
 endif
+ifdef CONFIG_TARGET_SOCFPGA_STRATIX10
+obj-y        += spl_s10.o
+endif
 endif
 
 ifdef CONFIG_TARGET_SOCFPGA_GEN5
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +76 -0
new file mode 100644
index 0000000..70aa9a6
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef      _FIREWALL_S10_
+#define      _FIREWALL_S10_
+
+struct socfpga_firwall_l4_per {
+     u32     nand;           /* 0x00 */
+     u32     nand_data;
+     u32     _pad_0x8;
+     u32     usb0;
+     u32     usb1;           /* 0x10 */
+     u32     _pad_0x14;
+     u32     _pad_0x18;
+     u32     spim0;
+     u32     spim1;          /* 0x20 */
+     u32     spis0;
+     u32     spis1;
+     u32     emac0;
+     u32     emac1;          /* 0x30 */
+     u32     emac2;
+     u32     _pad_0x38;
+     u32     _pad_0x3c;
+     u32     sdmmc;          /* 0x40 */
+     u32     gpio0;
+     u32     gpio1;
+     u32     _pad_0x4c;
+     u32     i2c0;           /* 0x50 */
+     u32     i2c1;
+     u32     i2c2;
+     u32     i2c3;
+     u32     i2c4;           /* 0x60 */
+     u32     timer0;
+     u32     timer1;
+     u32     uart0;
+     u32     uart1;          /* 0x70 */
+};
+
+struct socfpga_firwall_l4_sys {
+     u32     _pad_0x00;              /* 0x00 */
+     u32     _pad_0x04;
+     u32     dma_ecc;
+     u32     emac0rx_ecc;
+     u32     emac0tx_ecc;            /* 0x10 */
+     u32     emac1rx_ecc;
+     u32     emac1tx_ecc;
+     u32     emac2rx_ecc;
+     u32     emac2tx_ecc;            /* 0x20 */
+     u32     _pad_0x24;
+     u32     _pad_0x28;
+     u32     nand_ecc;
+     u32     nand_read_ecc;          /* 0x30 */
+     u32     nand_write_ecc;
+     u32     ocram_ecc;
+     u32     _pad_0x3c;
+     u32     sdmmc_ecc;              /* 0x40 */
+     u32     usb0_ecc;
+     u32     usb1_ecc;
+     u32     clock_manager;
+     u32     _pad_0x50;              /* 0x50 */
+     u32     io_manager;
+     u32     reset_manager;
+     u32     system_manager;
+     u32     osc0_timer;             /* 0x60 */
+     u32     osc1_timer;
+     u32     watchdog0;
+     u32     watchdog1;
+     u32     watchdog2;              /* 0x70 */
+     u32     watchdog3;
+};
+
+#define FIREWALL_L4_DISABLE_ALL              (BIT(0) | BIT(24) | BIT(16))
+#define FIREWALL_BRIDGE_DISABLE_ALL  (~0)
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/firewall_s10.h line 82

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +6 -0
+
+#define CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR   0xf7004688
+#define CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR    0xf7018628
+
+#define CCU_ADMASK_P_MASK                    (BIT(0))
+#define CCU_ADMASK_NS_MASK                   (BIT(1))

Drop outer parenthesis

Noted.

Quoted 77 lines
Quoted 77 lines
arch/arm/mach-socfpga/include/mach/firewall_s10.h new file +2 -0
+
+#endif /* _FIREWALL_S10_ */
arch/arm/mach-socfpga/spl_s10.c new file +68 -0
new file mode 100644
index 0000000..3b3833d
@@ -0,0 +1,205 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/u-boot.h>
+#include <asm/utils.h>
+#include <image.h>
+#include <asm/arch/reset_manager.h>
+#include <spl.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/sdram_s10.h>
+#include <asm/arch/mailbox_s10.h>
+#include <asm/arch/firewall_s10.h>
+#include <watchdog.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_firwall_l4_per *firwall_l4_per_base =
+     (struct socfpga_firwall_l4_per *)SOCFPGA_FIREWALL_L4_PER;
+static const struct socfpga_firwall_l4_sys *firwall_l4_sys_base =
+     (struct socfpga_firwall_l4_sys *)SOCFPGA_FIREWALL_L4_SYS;
+static struct socfpga_system_manager *sysmgr_regs =
+     (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+u32 spl_boot_device(void)
+{
+     /* TODO: Get from SDM or handoff */
+     return BOOT_DEVICE_MMC1;
+}
+
+#ifdef CONFIG_SPL_MMC_SUPPORT
+u32 spl_boot_mode(const u32 boot_device)
+{
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+     return MMCSD_MODE_FS;
+#else
+     return MMCSD_MODE_RAW;
+#endif
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+     const struct cm_config *cm_default_cfg = cm_get_default_config();
+
+#ifdef CONFIG_HW_WATCHDOG
+     /* Ensure watchdog is paused when debugging is happening */
+     writel(SYSMGR_WDDBG_PAUSE_ALL_CPU, &sysmgr_regs->wddbg);
+
+     /* Enable watchdog before initializing the HW */
+     socfpga_per_reset(SOCFPGA_RESET(L4WD0), 1);
+     socfpga_per_reset(SOCFPGA_RESET(L4WD0), 0);
+     hw_watchdog_init();
+#endif
+
+     /* ensure all processors are not released prior Linux boot */
+     writeq(0, CPU_RELEASE_ADDR);
+
+     socfpga_per_reset(SOCFPGA_RESET(OSC1TIMER0), 0);
+     timer_init();
+
+     populate_sysmgr_pinmux();
+
Quoted 8 lines

arch/arm/mach-socfpga/spl_s10.c line 73

Quoted 5 lines
arch/arm/mach-socfpga/spl_s10.c new file +5 -0
+     /* configuring the HPS clocks */
+     cm_basic_init(cm_default_cfg);
+
+     /* enable console uart printing */
+#if (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART0_ADDRESS)

Yoda notation, please fix. Also, shouldn't the reset controller handle this ?

Will remove this and use reset framework.

Quoted 15 lines

arch/arm/mach-socfpga/spl_s10.c line 84

Quoted 12 lines
arch/arm/mach-socfpga/spl_s10.c new file +11 -0
+     socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
+     /* enables nonsecure access to UART0 */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart0);
+#elif (CONFIG_SYS_NS16550_COM1 == SOCFPGA_UART1_ADDRESS)
+     socfpga_per_reset(SOCFPGA_RESET(UART1), 0);
+     /* enables nonsecure access to UART1 */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->uart1);
+#endif
+
+     preloader_console_init();
+     cm_print_clock_quick_summary();

This function doesn't fit on my pivoted 4k screen with small font, it is clearly too long. Please split it.

Okay, will split this function into sub-functions.

Quoted 35 lines
Quoted 24 lines
arch/arm/mach-socfpga/spl_s10.c new file +23 -0
+     /* enable non-secure interface to DMA330 DMA and peripherals */
+     writel(SYSMGR_DMA_IRQ_NS | SYSMGR_DMA_MGR_NS, &sysmgr_regs->dma);
+     writel(SYSMGR_DMAPERIPH_ALL_NS, &sysmgr_regs->dma_periph);
+     /* enable DMA330 DMA */
+     socfpga_per_reset(SOCFPGA_RESET(DMA), 0);
+
+     /*
+      * The following lines of code will enable non-secure access
+      * to nand, usb, spi, emac, sdmmc, gpio, i2c, and timers. This
+      * is needed as most OS run in non-secure mode. Thus we need to
+      * enable non-secure access to these peripherals in order for the
+      * OS to use these peripherals.
+      */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->nand_data);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->usb1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->spim1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->emac2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->sdmmc);

arch/arm/mach-socfpga/spl_s10.c line 118

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->sdmmc_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->gpio1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c3);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c4);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->timer1);
Quoted 1 line

Turn this into a table ?

Okay.

Quoted 56 lines
Quoted 30 lines
arch/arm/mach-socfpga/spl_s10.c new file +29 -0
+     /* enables nonsecure access to clock mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->clock_manager);
+
+     /* enables nonsecure access to reset mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->reset_manager);
+
+     /* enables nonsecure access to system mgr */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->system_manager);
+
+     /* enables nonsecure access to OCRAM */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->ocram_ecc);
+
+     /* enables nonsecure access to all the emacs */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac0tx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac1tx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2rx_ecc);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->emac2tx_ecc);
+
+     /* enables nonsecure access to SMMU */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->io_manager);
+
+     /* enables nonsecure access to watchdog */
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog0);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog1);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog2);
+     writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->watchdog3);
+

arch/arm/mach-socfpga/spl_s10.c line 158

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+     /* enables SDMMC */
+     socfpga_per_reset(SOCFPGA_RESET(SDMMC_OCP), 0);
+     socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0);
+     /* enable usb0 and usb1 */
+     socfpga_per_reset(SOCFPGA_RESET(USB0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB1), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB0_OCP), 0);
+     socfpga_per_reset(SOCFPGA_RESET(USB1_OCP), 0);
+     /* enable SPIM1 */
+     socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

See below.

Quoted 13 lines
arch/arm/mach-socfpga/spl_s10.c new file +13 -0
+     /* disable lwsocf2fpga and soc2fpga bridge security */
+     writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_SOC2FPGA);
+     writel(FIREWALL_BRIDGE_DISABLE_ALL, SOCFPGA_FIREWALL_LWSOC2FPGA);
+
+     /* disable SMMU security */
+     writel(FIREWALL_L4_DISABLE_ALL, SOCFPGA_FIREWALL_TCU);
+
+     /* disable ocram security at CCU for non secure access */
+     clrbits_le32(CCU_CPU0_MPRT_ADMASK_MEM_RAM0_ADDR,
+                  CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+     clrbits_le32(CCU_IOM_MPRT_ADMASK_MEM_RAM0_ADDR,
+                  CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
+
Quoted 8 lines

arch/arm/mach-socfpga/spl_s10.c line 178

Quoted 6 lines
arch/arm/mach-socfpga/spl_s10.c new file +6 -0
+     /* enable i2c1 */
+     socfpga_per_reset(SOCFPGA_RESET(I2C1), 0);
+
+     /* Take GPIO0 & GPIO1 out of reset */
+     socfpga_per_reset(SOCFPGA_RESET(GPIO0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(GPIO1), 0);

Shouldn't this be done by the reset framework ?

Quoted 8 lines

Yes, will update DW GPIO to use reset framework.

Quoted 6 lines

arch/arm/mach-socfpga/spl_s10.c line 182

Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c new file +3 -0
+     /* enable SPIM0 and SPIM1 */
+     socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
+     socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);

You ungated this SPI block already like 20 lines above.

Will remove.

Thanks

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

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

In reply to Ley Foon Tan

Add timer support for Stratix SoC

---
 arch/arm/mach-socfpga/timer.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
arch/arm/mach-socfpga/timer.c +16 -1
index 253cde3..4c90b57 100644
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2012-2016 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -10,15 +11,29 @@
 
 #define TIMER_LOAD_VAL		0xFFFFFFFF
 
+#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
 static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE;
+#endif
 
 /*
  * Timer initialization
  */
 int timer_init(void)
 {
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+	int enable = 0x3;	/* timer enable + output signal masked */
+	int loadval = ~0;
+
+	/* enable system counter */
+	writel(enable, SOCFPGA_GTIMER_SEC_ADDRESS);
+	/* enable processor pysical counter */
+	asm volatile("msr cntp_ctl_el0, %0" : : "r" (enable));
+	asm volatile("msr cntp_tval_el0, %0" : : "r" (loadval));
+
+#else
 	writel(TIMER_LOAD_VAL, &timer_base->load_val);
 	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
 	writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl);
+#endif
 	return 0;
 }
Signature · 1 line
1.7.1
#47 lore raw

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 1 line · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not, that's what we should do here.

Quoted 49 lines
---
 arch/arm/mach-socfpga/timer.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
arch/arm/mach-socfpga/timer.c +16 -1
index 253cde3..4c90b57 100644
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ * Copyright (C) 2012-2016 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -10,15 +11,29 @@
 
 #define TIMER_LOAD_VAL		0xFFFFFFFF
 
+#if !defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
 static const struct socfpga_timer *timer_base = (void *)CONFIG_SYS_TIMERBASE;
+#endif
 
 /*
  * Timer initialization
  */
 int timer_init(void)
 {
+#if defined(CONFIG_TARGET_SOCFPGA_STRATIX10)
+	int enable = 0x3;	/* timer enable + output signal masked */
+	int loadval = ~0;
+
+	/* enable system counter */
+	writel(enable, SOCFPGA_GTIMER_SEC_ADDRESS);
+	/* enable processor pysical counter */
+	asm volatile("msr cntp_ctl_el0, %0" : : "r" (enable));
+	asm volatile("msr cntp_tval_el0, %0" : : "r" (loadval));
+
+#else
 	writel(TIMER_LOAD_VAL, &timer_base->load_val);
 	writel(TIMER_LOAD_VAL, &timer_base->curr_val);
 	writel(readl(&timer_base->ctrl) | 0x3, &timer_base->ctrl);
+#endif
 	return 0;
 }
Signature · 2 lines
Best regards,
Marek Vasut
#48 lore raw

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Yes but not the init function. It's left with platform specific code to init it.

Thanks
Chin Liang

#49 lore raw

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 11 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

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

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 10 lines · Marek Vasut
Quoted 9 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Quoted 8 lines
Quoted 2 lines

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

--
Best regards,
Marek Vasut

timer_init weak function is in lib/time.c and common code is in this file as well.

int __weak timer_init(void)

{
    return 0;
}
#51 lore raw

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 20 lines · Ley Foon Tan
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Quoted 8 lines
Quoted 2 lines

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

--
Best regards,
Marek Vasut

Quoted 7 lines

timer_init weak function is in lib/time.c and common code is in this file as well.

int __weak timer_init(void)

{
    return 0;
}

Oh, that's what you use, I see.

I suspect having a timer_gen5. and timer_gen10.c would be a bit cleaner than the ifdef.

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

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 29 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Quoted 8 lines
Quoted 2 lines

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

--
Best regards,
Marek Vasut

Quoted 7 lines

timer_init weak function is in lib/time.c and common code is in this file as well.

int __weak timer_init(void)

{
    return 0;
}
Quoted 6 lines

Oh, that's what you use, I see.

I suspect having a timer_gen5. and timer_gen10.c would be a bit cleaner than the ifdef.

--

Okay, will split them into different files.

Thanks.

Regards
Ley Foon

#53 lore raw

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 27 lines · Ley Foon Tan
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Quoted 8 lines
Quoted 2 lines

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

--
Best regards,
Marek Vasut

timer_init weak function is in lib/time.c and common code is in this file as well.

int __weak timer_init(void)

{
    return 0;
}
Quoted 7 lines
Quoted 6 lines

Oh, that's what you use, I see.

I suspect having a timer_gen5. and timer_gen10.c would be a bit cleaner than the ifdef.

--

Okay, will split them into different files.

Thanks

Also please rebase the patchset on u-boot/master , so you won't get collisions.

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

PATCH 13/16 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

Quoted 36 lines · Marek Vasut
Quoted 35 lines · Ley Foon Tan
Quoted 34 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan
Quoted 10 lines · Marek Vasut
Quoted 9 lines · Chin Liang
Quoted 7 lines · Marek Vasut
Quoted 2 lines · Ley Foon Tan

Add timer support for Stratix SoC

Is this really custom timer or is that some armv8 thing you're adding here ? Don't we already have a generic implementation for that ? If not,
that's what we should do here.

Quoted 8 lines
Quoted 2 lines

Yes but not the init function. It's left with platform specific code to init it.

Where is the common part ?

--
Best regards,
Marek Vasut

Quoted 7 lines

timer_init weak function is in lib/time.c and common code is in this file as well.

int __weak timer_init(void)

{
    return 0;
}

Oh, that's what you use, I see.

I suspect having a timer_gen5. and timer_gen10.c would be a bit cleaner than the ifdef.

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

--

Okay, will split them into different files.

Thanks

Also please rebase the patchset on u-boot/master , so you won't get collisions.

Noted, will do that.

Thanks.

Regards
Ley Foon

#55 lore raw

PATCH 14/16 ddr: altera: stratix10: Add DDR support for Stratix10 SoC

In reply to Ley Foon Tan

Add DDR support for Stratix SoC

---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h |  340 ++++++++++++++++++++
 drivers/ddr/altera/Makefile                    |    1 +
 drivers/ddr/altera/sdram_s10.c                 |  392 ++++++++++++++++++++++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 drivers/ddr/altera/sdram_s10.c
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +340 -0
new file mode 100644
index 0000000..6ce5180
@@ -0,0 +1,340 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#ifndef	_SDRAM_S10_H_
+#define	_SDRAM_S10_H_
+
+unsigned long sdram_calculate_size(void);
+int sdram_mmr_init_full(unsigned int sdr_phy_reg);
+int sdram_calibration_full(void);
+
+#define DDR_TWR				15
+#define DDR_READ_LATENCY_DELAY		40
+#define DDR_ACTIVATE_FAWBANK		0x1
+
+struct socfpga_ecc_hmc {
+	u32 ip_rev_id;
+	u32 _pad_0x4_0x7;
+	u32 ddrioctrl;
+	u32 ddrcalstat;
+	u32 mpr_0beat1;
+	u32 mpr_1beat1;
+	u32 mpr_2beat1;
+	u32 mpr_3beat1;
+	u32 mpr_4beat1;
+	u32 mpr_5beat1;
+	u32 mpr_6beat1;
+	u32 mpr_7beat1;
+	u32 mpr_8beat1;
+	u32 mpr_0beat2;
+	u32 mpr_1beat2;
+	u32 mpr_2beat2;
+	u32 mpr_3beat2;
+	u32 mpr_4beat2;
+	u32 mpr_5beat2;
+	u32 mpr_6beat2;
+	u32 mpr_7beat2;
+	u32 mpr_8beat2;
+	u32 _pad_0x58_0x5f[2];
+	u32 auto_precharge;
+	u32 _pad_0x64_0xdf[31];
+	u32 dramaddrwidth;
+	u32 _pad_0xe4_0xff[7];
+	u32 eccctrl;
+	u32 eccctrl2;
+	u32 _pad_0x108_0x10f[2];
+	u32 errinten;
+	u32 errintens;
+	u32 errintenr;
+	u32 intmode;
+	u32 intstat;
+	u32 diaginttest;
+	u32 modstat;
+	u32 derraddra;
+	u32 serraddra;
+	u32 _pad_0x134_0x137;
+	u32 autowb_corraddr;
+	u32 serrcntreg;
+	u32 autowb_drop_cntreg;
+	u32 ecc_reg2wreccdatabus;
+	u32 ecc_rdeccdata2regbus;
+	u32 ecc_reg2rdeccdatabus;
+	u32 ecc_diagon;
+	u32 ecc_decstat;
+	u32 _pad_0x158_0x15f[2];
+	u32 ecc_errgenaddr_0;
+	u32 ecc_errgenaddr_1;
+	u32 ecc_errgenaddr_2;
+	u32 ecc_errgenaddr_3;
+	u32 ecc_ref2rddatabus_beat0;
+	u32 ecc_ref2rddatabus_beat1;
+	u32 ecc_ref2rddatabus_beat2;
+	u32 ecc_ref2rddatabus_beat3;
+	u32 ecc_errgenhaddr_0;
+	u32 ecc_errgenhaddr_1;
+	u32 ecc_errgenhaddr_2;
+	u32 ecc_errgenhaddr_3;
+	u32 ecc_rdeccdata2regbus_beat0;
+	u32 ecc_rdeccdata2regbus_beat1;
+	u32 ecc_rdeccdata2regbus_beat2;
+	u32 ecc_rdeccdata2regbus_beat3;
+	u32 _pad_0x1a0_0x1af[4];
+	u32 derrhaddr;
+	u32 serrhaddr;
+	u32 _pad_0x1b8_0x1bb;
+	u32 autowb_corrhaddr;
+	u32 _pad_0x1c0_0x20f[20];
+	u32 hpsintfcsel;
+	u32 rsthandshakectrl;
+	u32 rsthandshakestat;
+};
+
+struct socfpga_noc_ddr_scheduler {
+	u32 main_scheduler_id_coreid;
+	u32 main_scheduler_id_revisionid;
+	u32 main_scheduler_ddrconf;
+	u32 main_scheduler_ddrtiming;
+	u32 main_scheduler_ddrmode;
+	u32 main_scheduler_readlatency;
+	u32 _pad_0x18_0x37[8];
+	u32 main_scheduler_activate;
+	u32 main_scheduler_devtodev;
+	u32 main_scheduler_ddr4timing;
+};
+
+struct socfpga_io48_mmr {
+	u32 dbgcfg0;
+	u32 dbgcfg1;
+	u32 dbgcfg2;
+	u32 dbgcfg3;
+	u32 dbgcfg4;
+	u32 dbgcfg5;
+	u32 dbgcfg6;
+	u32 reserve0;
+	u32 reserve1;
+	u32 reserve2;
+	u32 ctrlcfg0;
+	u32 ctrlcfg1;
+	u32 ctrlcfg2;
+	u32 ctrlcfg3;
+	u32 ctrlcfg4;
+	u32 ctrlcfg5;
+	u32 ctrlcfg6;
+	u32 ctrlcfg7;
+	u32 ctrlcfg8;
+	u32 ctrlcfg9;
+	u32 dramtiming0;
+	u32 dramodt0;
+	u32 dramodt1;
+	u32 sbcfg0;
+	u32 sbcfg1;
+	u32 sbcfg2;
+	u32 sbcfg3;
+	u32 sbcfg4;
+	u32 sbcfg5;
+	u32 sbcfg6;
+	u32 sbcfg7;
+	u32 caltiming0;
+	u32 caltiming1;
+	u32 caltiming2;
+	u32 caltiming3;
+	u32 caltiming4;
+	u32 caltiming5;
+	u32 caltiming6;
+	u32 caltiming7;
+	u32 caltiming8;
+	u32 caltiming9;
+	u32 caltiming10;
+	u32 dramaddrw;
+	u32 sideband0;
+	u32 sideband1;
+	u32 sideband2;
+	u32 sideband3;
+	u32 sideband4;
+	u32 sideband5;
+	u32 sideband6;
+	u32 sideband7;
+	u32 sideband8;
+	u32 sideband9;
+	u32 sideband10;
+	u32 sideband11;
+	u32 sideband12;
+	u32 sideband13;
+	u32 sideband14;
+	u32 sideband15;
+	u32 dramsts;
+	u32 dbgdone;
+	u32 dbgsignals;
+	u32 dbgreset;
+	u32 dbgmatch;
+	u32 counter0mask;
+	u32 counter1mask;
+	u32 counter0match;
+	u32 counter1match;
+	u32 niosreserve0;
+	u32 niosreserve1;
+	u32 niosreserve2;
+};
+
+union dramaddrw_reg {
+	struct {
+		u32 cfg_col_addr_width:5;
+		u32 cfg_row_addr_width:5;
+		u32 cfg_bank_addr_width:4;
+		u32 cfg_bank_group_addr_width:2;
+		u32 cfg_cs_addr_width:3;
+		u32 reserved:13;
+	};
+	u32 word;
+};
+
+union ctrlcfg0_reg {
+	struct {
+		u32 cfg_mem_type:4;
+		u32 cfg_dimm_type:3;
+		u32 cfg_ac_pos:2;
+		u32 cfg_ctrl_burst_len:5;
+		u32 reserved:18;  /* Other fields unused */
+	};
+	u32 word;
+};
+
+union ctrlcfg1_reg {
+	struct {
+		u32 cfg_dbc3_burst_len:5;
+		u32 cfg_addr_order:2;
+		u32 cfg_ctrl_enable_ecc:1;
+		u32 reserved:24;  /* Other fields unused */
+	};
+	u32 word;
+};
+
+union dramtiming0_reg {
+	struct {
+		u32 cfg_tcl:6;
+		u32 reserved:8;  /* Other fields unused */
+	};
+	u32 word;
+};
+
+union caltiming0_reg {
+	struct {
+		u32 cfg_act_to_rdwr:6;
+		u32 cfg_act_to_pch:6;
+		u32 cfg_act_to_act:6;
+		u32 cfg_act_to_act_db:6;
+		u32 reserved:8;  /* Other fields unused */
+	};
+	u32 word;
+};
+
+union caltiming1_reg {
+	struct {
+		u32 cfg_rd_to_rd:6;
+		u32 cfg_rd_to_rd_dc:6;
+		u32 cfg_rd_to_rd_db:6;
+		u32 cfg_rd_to_wr:6;
+		u32 cfg_rd_to_wr_dc:6;
+		u32 reserved:2;
+	};
+	u32 word;
+};
+
+union caltiming2_reg {
+	struct {
+		u32 cfg_rd_to_wr_db:6;
+		u32 cfg_rd_to_pch:6;
+		u32 cfg_rd_ap_to_valid:6;
+		u32 cfg_wr_to_wr:6;
+		u32 cfg_wr_to_wr_dc:6;
+		u32 reserved:2;
+	};
+	u32 word;
+};
+
+union caltiming3_reg {
+	struct {
+		u32 cfg_wr_to_wr_db:6;
+		u32 cfg_wr_to_rd:6;
+		u32 cfg_wr_to_rd_dc:6;
+		u32 cfg_wr_to_rd_db:6;
+		u32 cfg_wr_to_pch:6;
+		u32 reserved:2;
+	};
+	u32 word;
+};
+
+union caltiming4_reg {
+	struct {
+		u32 cfg_wr_ap_to_valid:6;
+		u32 cfg_pch_to_valid:6;
+		u32 cfg_pch_all_to_valid:6;
+		u32 cfg_arf_to_valid:8;
+		u32 cfg_pdn_to_valid:6;
+	};
+	u32 word;
+};
+
+union caltiming9_reg {
+	struct {
+		u32 cfg_4_act_to_act:8;
+		u32 reserved:24;
+	};
+	u32 word;
+};
+
+#define DDR_SCHED_DDRTIMING_ACTTOACT_OFFSET	0
+#define DDR_SCHED_DDRTIMING_RDTOMISS_OFFSET	6
+#define DDR_SCHED_DDRTIMING_WRTOMISS_OFFSET	12
+#define DDR_SCHED_DDRTIMING_BURSTLEN_OFFSET	18
+#define DDR_SCHED_DDRTIMING_RDTOWR_OFFSET	21
+#define DDR_SCHED_DDRTIMING_WRTORD_OFFSET	26
+#define DDR_SCHED_DDRTIMING_BWRATIO_OFFSET	31
+#define DDR_SCHED_DDRMOD_BWRATIOEXTENDED_OFFSET	1
+#define DDR_SCHED_ACTIVATE_RRD_OFFSET		0
+#define DDR_SCHED_ACTIVATE_FAW_OFFSET		4
+#define DDR_SCHED_ACTIVATE_FAWBANK_OFFSET	10
+#define DDR_SCHED_DEVTODEV_BUSRDTORD_OFFSET	0
+#define DDR_SCHED_DEVTODEV_BUSRDTOWR_OFFSET	2
+#define DDR_SCHED_DEVTODEV_BUSWRTORD_OFFSET	4
+#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK		0x00000003
+#define DDR_HMC_DDRCALSTAT_CAL_MSK		0x00000001
+#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK	0x00010000
+#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK		0x00000100
+#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK		0x00000001
+#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK		0x00000100
+#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK		0x00000001
+#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK	0x00010000
+#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK	0x00000001
+#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK	0x00000001
+#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK	0x00000002
+#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK	0x00000001
+#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK	0x00000002
+#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK	0x00010000
+#define DDR_HMC_INTMODE_INTMODE_SET_MSK		0x00000001
+#define DDR_HMC_RSTHANDSHAKE_MASK		0x000000ff
+#define DDR_HMC_CORE2SEQ_INT_REQ		0xF
+#define DDR_HMC_SEQ2CORE_INT_RESP_MASK		0x8
+#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK		0x001f1f1f
+
+#define CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR	0xf7004400
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR	0xf70045c0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR	0xf70045e0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR	0xf7004600
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR	0xf7004620
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR	0xf7004640
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR	0xf7004660
+
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR	0xf7018560
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR	0xf7018580
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR	0xf70185a0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR	0xf70185c0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR	0xf70185e0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR	0xf7018600
+
+#define CCU_ADBASE_DI_MASK			0x00000010
+
+#endif /* _SDRAM_S10_H_ */
drivers/ddr/altera/Makefile +1 -0
index bdd2872..943b6cd 100644
@@ -10,4 +10,5 @@
 
 ifdef CONFIG_ALTERA_SDRAM
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram.o sequencer.o
+obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_s10.o
 endif
drivers/ddr/altera/sdram_s10.c new file +392 -0

392 lines not on this page · raw message

Signature · 1 line
1.7.1
#56 lore raw

PATCH 14/16 ddr: altera: stratix10: Add DDR support for Stratix10 SoC

Quoted 1 line · Ley Foon Tan

Add DDR support for Stratix SoC

OT: How very different is the DDR controller on Stratix 10 and Arria 10?

Quoted 4 lines
---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h |  340 ++++++++++++++++++++

If this is used only be the driver, no point having it in mach/

Quoted 5 lines
 drivers/ddr/altera/Makefile                    |    1 +
 drivers/ddr/altera/sdram_s10.c                 |  392 ++++++++++++++++++++++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 drivers/ddr/altera/sdram_s10.c

[...]

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 287

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+
+union caltiming9_reg {
+	struct {
+		u32 cfg_4_act_to_act:8;
+		u32 reserved:24;
+	};
+	u32 word;
+};

I wonder if this struct stuff is really a good idea.

Quoted 31 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +31 -0
+#define DDR_SCHED_DDRTIMING_ACTTOACT_OFFSET	0
+#define DDR_SCHED_DDRTIMING_RDTOMISS_OFFSET	6
+#define DDR_SCHED_DDRTIMING_WRTOMISS_OFFSET	12
+#define DDR_SCHED_DDRTIMING_BURSTLEN_OFFSET	18
+#define DDR_SCHED_DDRTIMING_RDTOWR_OFFSET	21
+#define DDR_SCHED_DDRTIMING_WRTORD_OFFSET	26
+#define DDR_SCHED_DDRTIMING_BWRATIO_OFFSET	31
+#define DDR_SCHED_DDRMOD_BWRATIOEXTENDED_OFFSET	1
+#define DDR_SCHED_ACTIVATE_RRD_OFFSET		0
+#define DDR_SCHED_ACTIVATE_FAW_OFFSET		4
+#define DDR_SCHED_ACTIVATE_FAWBANK_OFFSET	10
+#define DDR_SCHED_DEVTODEV_BUSRDTORD_OFFSET	0
+#define DDR_SCHED_DEVTODEV_BUSRDTOWR_OFFSET	2
+#define DDR_SCHED_DEVTODEV_BUSWRTORD_OFFSET	4
+#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK		0x00000003
+#define DDR_HMC_DDRCALSTAT_CAL_MSK		0x00000001
+#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK	0x00010000
+#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK		0x00000100
+#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK		0x00000001
+#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK		0x00000100
+#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK		0x00000001
+#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK	0x00010000
+#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK	0x00000001
+#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK	0x00000001
+#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK	0x00000002
+#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK	0x00000001
+#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK	0x00000002
+#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK	0x00010000
+#define DDR_HMC_INTMODE_INTMODE_SET_MSK		0x00000001
+#define DDR_HMC_RSTHANDSHAKE_MASK		0x000000ff
+#define DDR_HMC_CORE2SEQ_INT_REQ		0xF

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 329

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +10 -0
+#define DDR_HMC_SEQ2CORE_INT_RESP_MASK		0x8
+#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK		0x001f1f1f
+
+#define CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR	0xf7004400
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR	0xf70045c0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR	0xf70045e0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR	0xf7004600
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR	0xf7004620
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR	0xf7004640
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR	0xf7004660

Can all this come from DT, maybe except for the offsets ?

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR	0xf7018560
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR	0xf7018580
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR	0xf70185a0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR	0xf70185c0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR	0xf70185e0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR	0xf7018600
+
+#define CCU_ADBASE_DI_MASK			0x00000010

[...]

Quoted 1 line

+#define DDR_CONFIG(A, B, C, R) ((A << 24) | (B << 16) | (C << 8) | R)

You need parenthesis around A, B, C, R in the macro.

Quoted 17 lines
drivers/ddr/altera/sdram_s10.c new file +17 -0
+/* The followring are the supported configurations */
+u32 ddr_config[] = {
+	/* DDR_CONFIG(Address order,Bank,Column,Row) */
+	/* List for DDR3 or LPDDR3 (pinout order > chip, row, bank, column) */
+	DDR_CONFIG(0, 3, 10, 12),
+	DDR_CONFIG(0, 3,  9, 13),
+	DDR_CONFIG(0, 3, 10, 13),
+	DDR_CONFIG(0, 3,  9, 14),
+	DDR_CONFIG(0, 3, 10, 14),
+	DDR_CONFIG(0, 3, 10, 15),
+	DDR_CONFIG(0, 3, 11, 14),
+	DDR_CONFIG(0, 3, 11, 15),
+	DDR_CONFIG(0, 3, 10, 16),
+	DDR_CONFIG(0, 3, 11, 16),
+	DDR_CONFIG(0, 3, 12, 15),	/* 0xa */
+	/* List for DDR4 only (pinout order > chip, bank, row, column) */
+	DDR_CONFIG(1, 3, 10, 14),

drivers/ddr/altera/sdram_s10.c line 55

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+	DDR_CONFIG(1, 4, 10, 14),
+	DDR_CONFIG(1, 3, 10, 15),
+	DDR_CONFIG(1, 4, 10, 15),
+	DDR_CONFIG(1, 3, 10, 16),
+	DDR_CONFIG(1, 4, 10, 16),
+	DDR_CONFIG(1, 3, 10, 17),
+	DDR_CONFIG(1, 4, 10, 17),
+};
+
+#define DDR_CONFIG_ELEMENTS	(sizeof(ddr_config) / sizeof(u32))

Is that ARRAY_SIZE() ?

Quoted 14 lines
drivers/ddr/altera/sdram_s10.c new file +14 -0
+int match_ddr_conf(u32 ddr_conf)
+{
+	int i;
+
+	for (i = 0; i < DDR_CONFIG_ELEMENTS; i++) {
+		if (ddr_conf == ddr_config[i])
+			return i;
+	}
+	return 0;
+}
+
+static int emif_clear(void)
+{
+	u32 s2c, i;

drivers/ddr/altera/sdram_s10.c line 80

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+
+	writel(0, &socfpga_ecc_hmc_base->rsthandshakectrl);
+	s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+	      DDR_HMC_RSTHANDSHAKE_MASK;
+
+	for (i = 1000; (i > 0) && s2c; i--) {
+		WATCHDOG_RESET();
+		mdelay(1);
+		s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+		      DDR_HMC_RSTHANDSHAKE_MASK;

wait_for_bit() ?

Quoted 25 lines
drivers/ddr/altera/sdram_s10.c new file +25 -0
+	}
+	return !s2c;
+}
+
+static int emif_reset(void)
+{
+	u32 c2s, s2c, i;
+
+	c2s = readl(&socfpga_ecc_hmc_base->rsthandshakectrl) &
+	      DDR_HMC_RSTHANDSHAKE_MASK;
+	s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+	      DDR_HMC_RSTHANDSHAKE_MASK;
+
+	debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
+	      c2s, s2c, readl(&socfpga_io48_mmr_base->niosreserve0),
+	      readl(&socfpga_io48_mmr_base->niosreserve1),
+	      readl(&socfpga_io48_mmr_base->niosreserve2),
+	      readl(&socfpga_io48_mmr_base->dramsts));
+
+	if (s2c && emif_clear()) {
+		printf("DDR: emif_clear() failed\n");
+		return -1;
+	}
+
+	puts("DDR: Triggerring emif reset\n");

drivers/ddr/altera/sdram_s10.c line 115

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+	writel(DDR_HMC_CORE2SEQ_INT_REQ,
+	       &socfpga_ecc_hmc_base->rsthandshakectrl);
+
+	for (i = 1000; i > 0; i--) {
+		/* if seq2core[3] = 0, we are good */
+		if (!(readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+		    DDR_HMC_SEQ2CORE_INT_RESP_MASK))
+			break;
+		WATCHDOG_RESET();
+		mdelay(1);

Another wait_for_bit() ?

drivers/ddr/altera/sdram_s10.c line 128

Quoted 13 lines
drivers/ddr/altera/sdram_s10.c new file +13 -0
+	}
+
+	if (!i) {
+		printf("DDR: failed to get ack from EMIF\n");
+		return -2;
+	}
+
+	if (emif_clear()) {
+		printf("DDR: emif_clear() failed\n");
+		return -3;
+	}
+
+	printf("DDR: %s triggered successly\n", __func__);

debug() ?

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return 0;
+}

Comb through this and fix the things mentioned above globally.

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

PATCH 14/16 ddr: altera: stratix10: Add DDR support for Stratix10 SoC

Quoted 4 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

Add DDR support for Stratix SoC

OT: How very different is the DDR controller on Stratix 10 and Arria 10?

The IP blocks are different, so can't combine both of them.

Quoted 15 lines
Quoted 5 lines
---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h |  340 ++++++++++++++++++++

If this is used only be the driver, no point having it in mach/

Quoted 5 lines
 drivers/ddr/altera/Makefile                    |    1 +
 drivers/ddr/altera/sdram_s10.c                 |  392 ++++++++++++++++++++++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 drivers/ddr/altera/sdram_s10.c

[...]

Quoted 10 lines

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 287

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+
+union caltiming9_reg {
+     struct {
+             u32 cfg_4_act_to_act:8;
+             u32 reserved:24;
+     };
+     u32 word;
+};

I wonder if this struct stuff is really a good idea.

This easier for driver to access each field in register.

Quoted 36 lines
Quoted 36 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +35 -0
+#define DDR_SCHED_DDRTIMING_ACTTOACT_OFFSET  0
+#define DDR_SCHED_DDRTIMING_RDTOMISS_OFFSET  6
+#define DDR_SCHED_DDRTIMING_WRTOMISS_OFFSET  12
+#define DDR_SCHED_DDRTIMING_BURSTLEN_OFFSET  18
+#define DDR_SCHED_DDRTIMING_RDTOWR_OFFSET    21
+#define DDR_SCHED_DDRTIMING_WRTORD_OFFSET    26
+#define DDR_SCHED_DDRTIMING_BWRATIO_OFFSET   31
+#define DDR_SCHED_DDRMOD_BWRATIOEXTENDED_OFFSET      1
+#define DDR_SCHED_ACTIVATE_RRD_OFFSET                0
+#define DDR_SCHED_ACTIVATE_FAW_OFFSET                4
+#define DDR_SCHED_ACTIVATE_FAWBANK_OFFSET    10
+#define DDR_SCHED_DEVTODEV_BUSRDTORD_OFFSET  0
+#define DDR_SCHED_DEVTODEV_BUSRDTOWR_OFFSET  2
+#define DDR_SCHED_DEVTODEV_BUSWRTORD_OFFSET  4
+#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK         0x00000003
+#define DDR_HMC_DDRCALSTAT_CAL_MSK           0x00000001
+#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK   0x00010000
+#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK                0x00000001
+#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK               0x00000001
+#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK      0x00010000
+#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK       0x00000001
+#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK        0x00000001
+#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK        0x00000002
+#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK     0x00000001
+#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK     0x00000002
+#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK   0x00010000
+#define DDR_HMC_INTMODE_INTMODE_SET_MSK              0x00000001
+#define DDR_HMC_RSTHANDSHAKE_MASK            0x000000ff
+#define DDR_HMC_CORE2SEQ_INT_REQ             0xF
+#define DDR_HMC_SEQ2CORE_INT_RESP_MASK               0x8
+#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK              0x001f1f1f
+
+#define CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR     0xf7004400
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 329

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +6 -0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR  0xf70045c0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR 0xf70045e0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR 0xf7004600
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR 0xf7004620
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR 0xf7004640
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR 0xf7004660

Can all this come from DT, maybe except for the offsets ?

Need to add a new node in DT if want get from DT. Or another way is add CCU base address to base_addr_s10.h and remove all these defines and use offset instead. Is it okay?

Quoted 12 lines
Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR   0xf7018560
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR  0xf7018580
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR  0xf70185a0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR  0xf70185c0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR  0xf70185e0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR  0xf7018600
+
+#define CCU_ADBASE_DI_MASK                   0x00000010

[...]

Quoted 3 lines
Quoted 1 line

+#define DDR_CONFIG(A, B, C, R) ((A << 24) | (B << 16) | (C << 8) | R)

You need parenthesis around A, B, C, R in the macro.

Okay.

Quoted 22 lines
Quoted 22 lines
drivers/ddr/altera/sdram_s10.c new file +21 -0
+/* The followring are the supported configurations */
+u32 ddr_config[] = {
+     /* DDR_CONFIG(Address order,Bank,Column,Row) */
+     /* List for DDR3 or LPDDR3 (pinout order > chip, row, bank, column) */
+     DDR_CONFIG(0, 3, 10, 12),
+     DDR_CONFIG(0, 3,  9, 13),
+     DDR_CONFIG(0, 3, 10, 13),
+     DDR_CONFIG(0, 3,  9, 14),
+     DDR_CONFIG(0, 3, 10, 14),
+     DDR_CONFIG(0, 3, 10, 15),
+     DDR_CONFIG(0, 3, 11, 14),
+     DDR_CONFIG(0, 3, 11, 15),
+     DDR_CONFIG(0, 3, 10, 16),
+     DDR_CONFIG(0, 3, 11, 16),
+     DDR_CONFIG(0, 3, 12, 15),       /* 0xa */
+     /* List for DDR4 only (pinout order > chip, bank, row, column) */
+     DDR_CONFIG(1, 3, 10, 14),
+     DDR_CONFIG(1, 4, 10, 14),
+     DDR_CONFIG(1, 3, 10, 15),
+     DDR_CONFIG(1, 4, 10, 15),
+     DDR_CONFIG(1, 3, 10, 16),
Quoted 8 lines

drivers/ddr/altera/sdram_s10.c line 55

Quoted 6 lines
drivers/ddr/altera/sdram_s10.c new file +6 -0
+     DDR_CONFIG(1, 4, 10, 16),
+     DDR_CONFIG(1, 3, 10, 17),
+     DDR_CONFIG(1, 4, 10, 17),
+};
+
+#define DDR_CONFIG_ELEMENTS  (sizeof(ddr_config) / sizeof(u32))

Is that ARRAY_SIZE() ?

Yes, will change this.

Quoted 19 lines
Quoted 19 lines
drivers/ddr/altera/sdram_s10.c new file +18 -0
+int match_ddr_conf(u32 ddr_conf)
+{
+     int i;
+
+     for (i = 0; i < DDR_CONFIG_ELEMENTS; i++) {
+             if (ddr_conf == ddr_config[i])
+                     return i;
+     }
+     return 0;
+}
+
+static int emif_clear(void)
+{
+     u32 s2c, i;
+
+     writel(0, &socfpga_ecc_hmc_base->rsthandshakectrl);
+     s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+           DDR_HMC_RSTHANDSHAKE_MASK;
Quoted 8 lines

drivers/ddr/altera/sdram_s10.c line 80

Quoted 6 lines
drivers/ddr/altera/sdram_s10.c new file +6 -0
+
+     for (i = 1000; (i > 0) && s2c; i--) {
+             WATCHDOG_RESET();
+             mdelay(1);
+             s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+                   DDR_HMC_RSTHANDSHAKE_MASK;

wait_for_bit() ?

Okay.

Quoted 30 lines
Quoted 30 lines
drivers/ddr/altera/sdram_s10.c new file +29 -0
+     }
+     return !s2c;
+}
+
+static int emif_reset(void)
+{
+     u32 c2s, s2c, i;
+
+     c2s = readl(&socfpga_ecc_hmc_base->rsthandshakectrl) &
+           DDR_HMC_RSTHANDSHAKE_MASK;
+     s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+           DDR_HMC_RSTHANDSHAKE_MASK;
+
+     debug("DDR: c2s=%08x s2c=%08x nr0=%08x nr1=%08x nr2=%08x dst=%08x\n",
+           c2s, s2c, readl(&socfpga_io48_mmr_base->niosreserve0),
+           readl(&socfpga_io48_mmr_base->niosreserve1),
+           readl(&socfpga_io48_mmr_base->niosreserve2),
+           readl(&socfpga_io48_mmr_base->dramsts));
+
+     if (s2c && emif_clear()) {
+             printf("DDR: emif_clear() failed\n");
+             return -1;
+     }
+
+     puts("DDR: Triggerring emif reset\n");
+     writel(DDR_HMC_CORE2SEQ_INT_REQ,
+            &socfpga_ecc_hmc_base->rsthandshakectrl);
+
+     for (i = 1000; i > 0; i--) {
Quoted 8 lines

drivers/ddr/altera/sdram_s10.c line 115

Quoted 6 lines
drivers/ddr/altera/sdram_s10.c new file +6 -0
+             /* if seq2core[3] = 0, we are good */
+             if (!(readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+                 DDR_HMC_SEQ2CORE_INT_RESP_MASK))
+                     break;
+             WATCHDOG_RESET();
+             mdelay(1);

Another wait_for_bit() ?

Okay.

Quoted 16 lines
Quoted 4 lines
drivers/ddr/altera/sdram_s10.c new file +3 -0
+     }
+
+     if (!i) {

drivers/ddr/altera/sdram_s10.c line 128

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+             printf("DDR: failed to get ack from EMIF\n");
+             return -2;
+     }
+
+     if (emif_clear()) {
+             printf("DDR: emif_clear() failed\n");
+             return -3;
+     }
+
+     printf("DDR: %s triggered successly\n", __func__);

debug() ?

Okay.

Quoted 8 lines

Review

Quoted 3 lines
(quoted diff) +2 -0
+     return 0;
+}

Comb through this and fix the things mentioned above globally.

--
Best regards,
Marek Vasut

Regards
Ley Foon

#58 lore raw

PATCH 14/16 ddr: altera: stratix10: Add DDR support for Stratix10 SoC

Quoted 6 lines · Ley Foon Tan
Quoted 4 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

Add DDR support for Stratix SoC

OT: How very different is the DDR controller on Stratix 10 and Arria 10?

The IP blocks are different, so can't combine both of them.

I see, thanks

Quoted 24 lines
Quoted 14 lines
Quoted 4 lines
---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h |  340 ++++++++++++++++++++

If this is used only be the driver, no point having it in mach/

Quoted 5 lines
 drivers/ddr/altera/Makefile                    |    1 +
 drivers/ddr/altera/sdram_s10.c                 |  392 ++++++++++++++++++++++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 drivers/ddr/altera/sdram_s10.c

[...]

Quoted 10 lines

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 287

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+
+union caltiming9_reg {
+     struct {
+             u32 cfg_4_act_to_act:8;
+             u32 reserved:24;
+     };
+     u32 word;
+};

I wonder if this struct stuff is really a good idea.

Quoted 1 line

This easier for driver to access each field in register.

And also not super portable. I'd rather see a macro really. Something like define foo (((x) >> 24) & 0xff)

Quoted 43 lines
Quoted 35 lines
Quoted 35 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +35 -0
+#define DDR_SCHED_DDRTIMING_ACTTOACT_OFFSET  0
+#define DDR_SCHED_DDRTIMING_RDTOMISS_OFFSET  6
+#define DDR_SCHED_DDRTIMING_WRTOMISS_OFFSET  12
+#define DDR_SCHED_DDRTIMING_BURSTLEN_OFFSET  18
+#define DDR_SCHED_DDRTIMING_RDTOWR_OFFSET    21
+#define DDR_SCHED_DDRTIMING_WRTORD_OFFSET    26
+#define DDR_SCHED_DDRTIMING_BWRATIO_OFFSET   31
+#define DDR_SCHED_DDRMOD_BWRATIOEXTENDED_OFFSET      1
+#define DDR_SCHED_ACTIVATE_RRD_OFFSET                0
+#define DDR_SCHED_ACTIVATE_FAW_OFFSET                4
+#define DDR_SCHED_ACTIVATE_FAWBANK_OFFSET    10
+#define DDR_SCHED_DEVTODEV_BUSRDTORD_OFFSET  0
+#define DDR_SCHED_DEVTODEV_BUSRDTOWR_OFFSET  2
+#define DDR_SCHED_DEVTODEV_BUSWRTORD_OFFSET  4
+#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK         0x00000003
+#define DDR_HMC_DDRCALSTAT_CAL_MSK           0x00000001
+#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK   0x00010000
+#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK                0x00000001
+#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK               0x00000001
+#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK      0x00010000
+#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK       0x00000001
+#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK        0x00000001
+#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK        0x00000002
+#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK     0x00000001
+#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK     0x00000002
+#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK   0x00010000
+#define DDR_HMC_INTMODE_INTMODE_SET_MSK              0x00000001
+#define DDR_HMC_RSTHANDSHAKE_MASK            0x000000ff
+#define DDR_HMC_CORE2SEQ_INT_REQ             0xF
+#define DDR_HMC_SEQ2CORE_INT_RESP_MASK               0x8
+#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK              0x001f1f1f
+
+#define CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR     0xf7004400
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 329

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +6 -0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR  0xf70045c0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR 0xf70045e0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR 0xf7004600
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR 0xf7004620
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR 0xf7004640
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR 0xf7004660

Can all this come from DT, maybe except for the offsets ?

Quoted 3 lines

Need to add a new node in DT if want get from DT. Or another way is add CCU base address to base_addr_s10.h and remove all these defines and use offset instead. Is it okay?

I'd prefer to have everything in DT obviously, but I guess using CCU base + offset is a good start for now. It could be easily converted to DT when the bindings are ready later.

Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR   0xf7018560
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR  0xf7018580
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR  0xf70185a0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR  0xf70185c0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR  0xf70185e0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR  0xf7018600
+
+#define CCU_ADBASE_DI_MASK                   0x00000010

[...]

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

PATCH 14/16 ddr: altera: stratix10: Add DDR support for Stratix10 SoC

Quoted 34 lines · Marek Vasut
Quoted 6 lines · Ley Foon Tan
Quoted 4 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

Add DDR support for Stratix SoC

OT: How very different is the DDR controller on Stratix 10 and Arria 10?

The IP blocks are different, so can't combine both of them.

I see, thanks

Quoted 24 lines
Quoted 24 lines
Quoted 4 lines
---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h |  340 ++++++++++++++++++++

If this is used only be the driver, no point having it in mach/

Quoted 5 lines
 drivers/ddr/altera/Makefile                    |    1 +
 drivers/ddr/altera/sdram_s10.c                 |  392 ++++++++++++++++++++++++
 3 files changed, 733 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_s10.h
 create mode 100644 drivers/ddr/altera/sdram_s10.c

[...]

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 287

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+
+union caltiming9_reg {
+     struct {
+             u32 cfg_4_act_to_act:8;
+             u32 reserved:24;
+     };
+     u32 word;
+};

I wonder if this struct stuff is really a good idea.

Quoted 4 lines
Quoted 1 line

This easier for driver to access each field in register.

And also not super portable. I'd rather see a macro really. Something like define foo (((x) >> 24) & 0xff)

Okay, I will to update these.

Quoted 44 lines
Quoted 44 lines
Quoted 44 lines
Quoted 32 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +31 -0
+#define DDR_SCHED_DDRTIMING_ACTTOACT_OFFSET  0
+#define DDR_SCHED_DDRTIMING_RDTOMISS_OFFSET  6
+#define DDR_SCHED_DDRTIMING_WRTOMISS_OFFSET  12
+#define DDR_SCHED_DDRTIMING_BURSTLEN_OFFSET  18
+#define DDR_SCHED_DDRTIMING_RDTOWR_OFFSET    21
+#define DDR_SCHED_DDRTIMING_WRTORD_OFFSET    26
+#define DDR_SCHED_DDRTIMING_BWRATIO_OFFSET   31
+#define DDR_SCHED_DDRMOD_BWRATIOEXTENDED_OFFSET      1
+#define DDR_SCHED_ACTIVATE_RRD_OFFSET                0
+#define DDR_SCHED_ACTIVATE_FAW_OFFSET                4
+#define DDR_SCHED_ACTIVATE_FAWBANK_OFFSET    10
+#define DDR_SCHED_DEVTODEV_BUSRDTORD_OFFSET  0
+#define DDR_SCHED_DEVTODEV_BUSRDTOWR_OFFSET  2
+#define DDR_SCHED_DEVTODEV_BUSWRTORD_OFFSET  4
+#define DDR_HMC_DDRIOCTRL_IOSIZE_MSK         0x00000003
+#define DDR_HMC_DDRCALSTAT_CAL_MSK           0x00000001
+#define DDR_HMC_ECCCTL_AWB_CNT_RST_SET_MSK   0x00010000
+#define DDR_HMC_ECCCTL_CNT_RST_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL_ECC_EN_SET_MSK                0x00000001
+#define DDR_HMC_ECCCTL2_RMW_EN_SET_MSK               0x00000100
+#define DDR_HMC_ECCCTL2_AWB_EN_SET_MSK               0x00000001
+#define DDR_HMC_ECC_DIAGON_ECCDIAGON_EN_SET_MSK      0x00010000
+#define DDR_HMC_ECC_DIAGON_WRDIAGON_EN_SET_MSK       0x00000001
+#define DDR_HMC_ERRINTEN_SERRINTEN_EN_SET_MSK        0x00000001
+#define DDR_HMC_ERRINTEN_DERRINTEN_EN_SET_MSK        0x00000002
+#define DDR_HMC_INTSTAT_SERRPENA_SET_MSK     0x00000001
+#define DDR_HMC_INTSTAT_DERRPENA_SET_MSK     0x00000002
+#define DDR_HMC_INTSTAT_ADDRMTCFLG_SET_MSK   0x00010000
+#define DDR_HMC_INTMODE_INTMODE_SET_MSK              0x00000001
+#define DDR_HMC_RSTHANDSHAKE_MASK            0x000000ff
+#define DDR_HMC_CORE2SEQ_INT_REQ             0xF

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 329

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +10 -0
+#define DDR_HMC_SEQ2CORE_INT_RESP_MASK               0x8
+#define DDR_HMC_HPSINTFCSEL_ENABLE_MASK              0x001f1f1f
+
+#define CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR     0xf7004400
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR  0xf70045c0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR 0xf70045e0
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR 0xf7004600
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR 0xf7004620
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR 0xf7004640
+#define CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR 0xf7004660

Can all this come from DT, maybe except for the offsets ?

Quoted 7 lines
Quoted 3 lines

Need to add a new node in DT if want get from DT. Or another way is add CCU base address to base_addr_s10.h and remove all these defines and use offset instead. Is it okay?

I'd prefer to have everything in DT obviously, but I guess using CCU base + offset is a good start for now. It could be easily converted to DT when the bindings are ready later.

Yes, will use base+offset as for now.

Quoted 11 lines
Quoted 10 lines
Quoted 10 lines

arch/arm/mach-socfpga/include/mach/sdram_s10.h line 338

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/sdram_s10.h new file +8 -0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR   0xf7018560
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR  0xf7018580
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR  0xf70185a0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR  0xf70185c0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR  0xf70185e0
+#define CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR  0xf7018600
+
+#define CCU_ADBASE_DI_MASK                   0x00000010

Regards
Ley Foon

#60 lore raw

PATCH 15/16 board: altera: stratix10: Add socdk board support for Stratix10 SoC

In reply to Ley Foon Tan

Add socdk board support for Stratix SoC

---
 board/altera/stratix10-socdk/MAINTAINERS |    7 +++++++
 board/altera/stratix10-socdk/Makefile    |    7 +++++++
 board/altera/stratix10-socdk/socfpga.c   |    7 +++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 board/altera/stratix10-socdk/MAINTAINERS
 create mode 100644 board/altera/stratix10-socdk/Makefile
 create mode 100644 board/altera/stratix10-socdk/socfpga.c
board/altera/stratix10-socdk/MAINTAINERS new file +7 -0
new file mode 100644
index 0000000..6192bc9
@@ -0,0 +1,7 @@
+SOCFPGA BOARD
+M:	Chin-Liang See <[email protected]>
+M:	Dinh Nguyen <[email protected]>
+S:	Maintained
+F:	board/altera/stratix10-socdk/
+F:	include/configs/socfpga_stratix10_socdk.h
+F:	configs/socfpga_stratix10_defconfig
board/altera/stratix10-socdk/Makefile new file +7 -0
new file mode 100644
index 0000000..02a9cad
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+#
+# SPDX-License-Identifier:	GPL-2.0
+#
+
+obj-y	:= socfpga.o
board/altera/stratix10-socdk/socfpga.c new file +7 -0
new file mode 100644
index 0000000..043fc54
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
+ *
+ */
+
+#include <common.h>
Signature · 1 line
1.7.1
#61 lore raw

PATCH 16/16 arm: socfpga: stratix10: Enable Stratix10 SoC build

In reply to Ley Foon Tan

Add build support for Stratix SoC

---
 arch/arm/Kconfig                          |    9 +-
 arch/arm/mach-socfpga/Kconfig             |   13 ++
 configs/socfpga_stratix10_defconfig       |   52 +++++++
 include/configs/socfpga_stratix10_socdk.h |  234 +++++++++++++++++++++++++++++
 4 files changed, 304 insertions(+), 4 deletions(-)
 create mode 100644 configs/socfpga_stratix10_defconfig
 create mode 100644 include/configs/socfpga_stratix10_socdk.h
arch/arm/Kconfig +5 -4
index 190f883..b31cc7e 100644
@@ -693,22 +693,23 @@ config ARCH_SNAPDRAGON
 
 config ARCH_SOCFPGA
 	bool "Altera SOCFPGA family"
-	select CPU_V7
+	select CPU_V7 if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
+	select ARM64 if TARGET_SOCFPGA_STRATIX10
 	select SUPPORT_SPL
 	select OF_CONTROL
 	select SPL_OF_CONTROL
 	select DM
-	select ENABLE_ARM_SOC_BOOT0_HOOK
+	select ENABLE_ARM_SOC_BOOT0_HOOK if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	select ARCH_EARLY_INIT_R
 	select ARCH_MISC_INIT
-	select SYS_THUMB_BUILD
+	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	imply CMD_MTDPARTS
 	imply CRC32_VERIFY
 	imply DM_SPI
 	imply DM_SPI_FLASH
 	imply FAT_WRITE
-	imply HW_WATCHDOG
 	imply SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
 
 config ARCH_SUNXI
 	bool "Support sunxi (Allwinner) SoCs"
arch/arm/mach-socfpga/Kconfig +13 -0
index afc38d5..f15a42e 100644
@@ -49,6 +49,12 @@ config TARGET_SOCFPGA_GEN5
 	bool
 	select ALTERA_SDRAM
 
+config TARGET_SOCFPGA_STRATIX10
+	bool
+	select ARMV8_MULTIENTRY
+	select ARMV8_SPIN_TABLE
+	select ARMV8_SET_SMPEN
+
 choice
 	prompt "Altera SOCFPGA board select"
 	optional
@@ -90,6 +96,10 @@ config TARGET_SOCFPGA_SR1500
 	bool "SR1500 (Cyclone V)"
 	select TARGET_SOCFPGA_CYCLONE5
 
+config TARGET_SOCFPGA_STRATIX10_SOCDK
+	bool "Intel SOCFPGA SoCDK (Stratix 10)"
+	select TARGET_SOCFPGA_STRATIX10
+
 config TARGET_SOCFPGA_TERASIC_DE0_NANO
 	bool "Terasic DE0-Nano-Atlas (Cyclone V)"
 	select TARGET_SOCFPGA_CYCLONE5
@@ -121,12 +131,14 @@ config SYS_BOARD
 	default "sockit" if TARGET_SOCFPGA_TERASIC_SOCKIT
 	default "socrates" if TARGET_SOCFPGA_EBV_SOCRATES
 	default "sr1500" if TARGET_SOCFPGA_SR1500
+	default "stratix10-socdk" if TARGET_SOCFPGA_STRATIX10_SOCDK
 	default "vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
 config SYS_VENDOR
 	default "altera" if TARGET_SOCFPGA_ARRIA5_SOCDK
 	default "altera" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "altera" if TARGET_SOCFPGA_CYCLONE5_SOCDK
+	default "altera" if TARGET_SOCFPGA_STRATIX10_SOCDK
 	default "aries" if TARGET_SOCFPGA_ARIES_MCVEVK
 	default "devboards" if TARGET_SOCFPGA_DEVBOARDS_DBM_SOC1
 	default "ebv" if TARGET_SOCFPGA_EBV_SOCRATES
@@ -152,6 +164,7 @@ config SYS_CONFIG_NAME
 	default "socfpga_sockit" if TARGET_SOCFPGA_TERASIC_SOCKIT
 	default "socfpga_socrates" if TARGET_SOCFPGA_EBV_SOCRATES
 	default "socfpga_sr1500" if TARGET_SOCFPGA_SR1500
+	default "socfpga_stratix10_socdk" if TARGET_SOCFPGA_STRATIX10_SOCDK
 	default "socfpga_vining_fpga" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
 
 endif
configs/socfpga_stratix10_defconfig new file +52 -0

52 lines not on this page · raw message

include/configs/socfpga_stratix10_socdk.h new file +234 -0

234 lines not on this page · raw message

Signature · 1 line
1.7.1