Skip to contentSkip to conversation

Enable Stratix10 SoC support

PATCH New chin.liang.see at intel.com 3 participants 30 messages Oct 5, 2017 – Oct 11, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover Enable Stratix10 SoC support

From: Chin Liang See <[email protected]>

This patch series are enabling support for Stratix 10 SoC

Changes for v2
- Removed defines for base addresses that can be extracted from DTS
- Added CPU node plus MDIO node for Ethernet at DTS
- Added defines for constant value for readability
- Consolidated common code for Clock Manager and misc code

Chin Liang See (14):
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: 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                                   |   8 +-
 arch/arm/dts/Makefile                              |   3 +-
 arch/arm/dts/socfpga_stratix10_socdk.dts           | 180 ++++++++++
 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          | 355 +++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h |  56 +++
 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   |  29 ++
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h   | 108 ++++++
 arch/arm/mach-socfpga/include/mach/misc.h          |   1 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           |   8 +-
 .../mach-socfpga/include/mach/reset_manager_s10.h  | 116 +++++++
 arch/arm/mach-socfpga/include/mach/sdram_s10.h     | 333 ++++++++++++++++++
 .../arm/mach-socfpga/include/mach/system_manager.h |   5 +-
 .../mach-socfpga/include/mach/system_manager_s10.h | 169 +++++++++
 arch/arm/mach-socfpga/mailbox_s10.c                | 238 +++++++++++++
 arch/arm/mach-socfpga/misc.c                       |  76 ++++
 arch/arm/mach-socfpga/misc_gen5.c                  |  75 +---
 arch/arm/mach-socfpga/misc_s10.c                   | 115 +++++++
 arch/arm/mach-socfpga/mmu-arm64_s10.c              |  71 ++++
 arch/arm/mach-socfpga/reset_manager.c              |  41 +++
 arch/arm/mach-socfpga/reset_manager_arria10.c      |  67 +---
 arch/arm/mach-socfpga/reset_manager_gen5.c         |  33 --
 arch/arm/mach-socfpga/reset_manager_s10.c          | 118 +++++++
 arch/arm/mach-socfpga/spl_a10.c                    | 105 ++++++
 arch/arm/mach-socfpga/{spl.c => spl_gen5.c}        |  46 ---
 arch/arm/mach-socfpga/spl_s10.c                    | 138 ++++++++
 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     |  55 +++
 arch/arm/mach-socfpga/wrap_pll_config_s10.c        |  44 +++
 board/altera/stratix10-socdk/MAINTAINERS           |   7 +
 board/altera/stratix10-socdk/Makefile              |   7 +
 board/altera/stratix10-socdk/socfpga.c             |   7 +
 configs/socfpga_stratix10_defconfig                |  39 +++
 drivers/ddr/altera/Makefile                        |   1 +
 drivers/ddr/altera/sdram_s10.c                     | 382 +++++++++++++++++++++
 include/configs/socfpga_stratix10_socdk.h          | 216 ++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-s10.h       |  97 ++++++
 44 files changed, 3577 insertions(+), 214 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} (83%)
 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

--
2.2.2

#1 lore raw

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

From: Chin Liang See <[email protected]>

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 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 +56 -0
new file mode 100644
index 0000000..2fdc917
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#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_USB0_ADDRESS			0xffb00000
+#define SOCFPGA_USB1_ADDRESS			0xffb40000
+#define SOCFPGA_NANDREGS_ADDRESS		0xffb80000
+#define SOCFPGA_NANDDATA_ADDRESS		0xffb90000
+#define SOCFPGA_UART0_ADDRESS			0xffc02000
+#define SOCFPGA_UART1_ADDRESS			0xffc02100
+#define SOCFPGA_I2C0_ADDRESS			0xffc02800
+#define SOCFPGA_I2C1_ADDRESS			0xffc02900
+#define SOCFPGA_I2C2_ADDRESS			0xffc02a00
+#define SOCFPGA_I2C3_ADDRESS			0xffc02b00
+#define SOCFPGA_I2C4_ADDRESS			0xffc02c00
+#define SOCFPGA_SPTIMER0_ADDRESS		0xffc03000
+#define SOCFPGA_SPTIMER1_ADDRESS		0xffc03100
+#define SOCFPGA_GPIO0_ADDRESS			0xffc03200
+#define SOCFPGA_GPIO1_ADDRESS			0xffc03300
+#define SOCFPGA_SYSTIMER0_ADDRESS		0xffd00000
+#define SOCFPGA_SYSTIMER1_ADDRESS		0xffd00100
+#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_DMANONSECURE_ADDRESS		0xffda0000
+#define SOCFPGA_DMASECURE_ADDRESS		0xffda1000
+#define SOCFPGA_SPIS0_ADDRESS			0xffda2000
+#define SOCFPGA_SPIS1_ADDRESS			0xffda3000
+#define SOCFPGA_SPIM0_ADDRESS			0xffda4000
+#define SOCFPGA_SPIM1_ADDRESS			0xffda5000
+#define SOCFPGA_OCRAM_ADDRESS			0xffe00000
+#define GICD_BASE				0xfffc1000
+#define GICC_BASE				0xfffc2000
+
+#endif /* _SOCFPGA_S10_BASE_HARDWARE_H_ */
Signature · 1 line
2.2.2
#2 lore raw

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

Quoted 22 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add the base address map for Statix10 SoC

---
 arch/arm/mach-socfpga/include/mach/base_addr_s10.h | 56 ++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 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 +6 -0
new file mode 100644
index 0000000..2fdc917
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+

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

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +10 -0
+#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_USB0_ADDRESS                   0xffb00000
+#define SOCFPGA_USB1_ADDRESS                   0xffb40000

USB address is obtainable from DT.

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

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/base_addr_s10.h new file +9 -0
+#define SOCFPGA_NANDREGS_ADDRESS               0xffb80000
+#define SOCFPGA_NANDDATA_ADDRESS               0xffb90000
+#define SOCFPGA_UART0_ADDRESS                  0xffc02000
+#define SOCFPGA_UART1_ADDRESS                  0xffc02100
+#define SOCFPGA_I2C0_ADDRESS                   0xffc02800
+#define SOCFPGA_I2C1_ADDRESS                   0xffc02900
+#define SOCFPGA_I2C2_ADDRESS                   0xffc02a00
+#define SOCFPGA_I2C3_ADDRESS                   0xffc02b00
+#define SOCFPGA_I2C4_ADDRESS                   0xffc02c00

I2C is also obtainabled

Please check the other peripherals.

Dinh

#3 lore raw

PATCH v2 2/14 arm: socfpga: stratix10: Add Clock Manager driver for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add Clock Manager driver support for Stratix SoC

--
Changes in v2
- Declared defines for constant value used
- Fixed spacing and comments

---
 arch/arm/mach-socfpga/Makefile                     |   4 +
 arch/arm/mach-socfpga/clock_manager.c              |   4 +-
 arch/arm/mach-socfpga/clock_manager_s10.c          | 355 +++++++++++++++++++++
 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   |  29 ++
 arch/arm/mach-socfpga/wrap_pll_config_s10.c        |  44 +++
 7 files changed, 646 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 cb6ae03..f9450a4 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 +355 -0

355 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 +29 -0
new file mode 100644
index 0000000..d4b89ac
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#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
+
+#endif /* _HANDOFF_S10_H_ */
arch/arm/mach-socfpga/wrap_pll_config_s10.c new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
2.2.2
#4 lore raw

PATCH v2 2/14 arm: socfpga: stratix10: Add Clock Manager driver for Stratix10 SoC

Quoted 708 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add Clock Manager driver support for Stratix SoC

--
Changes in v2
- Declared defines for constant value used
- Fixed spacing and comments

---
 arch/arm/mach-socfpga/Makefile                     |   4 +
 arch/arm/mach-socfpga/clock_manager.c              |   4 +-
 arch/arm/mach-socfpga/clock_manager_s10.c          | 355 +++++++++++++++++++++
 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   |  29 ++
 arch/arm/mach-socfpga/wrap_pll_config_s10.c        |  44 +++
 7 files changed, 646 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 cb6ae03..f9450a4 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 +355 -0
new file mode 100644
index 0000000..cfb6708
@@ -0,0 +1,355 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/arch/handoff_s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_clock_manager *clock_manager_base =
+       (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
+
+/*
+ * function to write the bypass register which requires a poll of the
+ * busy bit
+ */
+static void cm_write_bypass_mainpll(uint32_t val)
+{
+       writel(val, &clock_manager_base->main_pll.bypass);
+       cm_wait_for_fsm();
+}
+
+static void cm_write_bypass_perpll(uint32_t val)
+{
+       writel(val, &clock_manager_base->per_pll.bypass);
+       cm_wait_for_fsm();
+}
+
+/* function to write the ctrl register which requires a poll of the busy bit */
+static void cm_write_ctrl(uint32_t val)
+{
+       writel(val, &clock_manager_base->ctrl);
+       cm_wait_for_fsm();
+}
+
+/*
+ * Setup clocks while making no assumptions about previous state of the clocks.
+ */
+void cm_basic_init(const struct cm_config * const cfg)
+{
+       uint32_t mdiv, refclkdiv, mscnt, hscnt, vcocalib;
+
+       if (cfg == 0)
+               return;
+
+       /* Put all plls in bypass */
+       cm_write_bypass_mainpll(CLKMGR_BYPASS_MAINPLL_ALL);
+       cm_write_bypass_perpll(CLKMGR_BYPASS_PERPLL_ALL);
+
+       /* setup main PLL dividers where calculate the vcocalib value */
+       mdiv = (cfg->main_pll_fdbck >> CLKMGR_FDBCK_MDIV_OFFSET) &
+               CLKMGR_FDBCK_MDIV_MASK;
+       refclkdiv = (cfg->main_pll_pllglob >> CLKMGR_PLLGLOB_REFCLKDIV_OFFSET) &
+                    CLKMGR_PLLGLOB_REFCLKDIV_MASK;
+       mscnt = CLKMGR_MSCNT_CONST / (CLKMGR_MDIV_CONST + mdiv) / refclkdiv;
+       hscnt = (mdiv + CLKMGR_MDIV_CONST) * mscnt / refclkdiv -
+               CLKMGR_HSCNT_CONST;
+       vcocalib = (hscnt & CLKMGR_VCOCALIB_HSCNT_MASK) |
+                  ((mscnt & CLKMGR_VCOCALIB_MSCNT_MASK) <<
+                  CLKMGR_VCOCALIB_MSCNT_OFFSET);
+
+       writel((cfg->main_pll_pllglob & ~CLKMGR_PLLGLOB_PD_MASK &
+               ~CLKMGR_PLLGLOB_RST_MASK),
+               &clock_manager_base->main_pll.pllglob);
+       writel(cfg->main_pll_fdbck, &clock_manager_base->main_pll.fdbck);
+       writel(vcocalib, &clock_manager_base->main_pll.vcocalib);
+       writel(cfg->main_pll_pllc0, &clock_manager_base->main_pll.pllc0);
+       writel(cfg->main_pll_pllc1, &clock_manager_base->main_pll.pllc1);
+       writel(cfg->main_pll_nocdiv, &clock_manager_base->main_pll.nocdiv);
+
+       /* setup peripheral PLL dividers */
+       /* calculate the vcocalib value */
+       mdiv = (cfg->per_pll_fdbck >> CLKMGR_FDBCK_MDIV_OFFSET) &
+               CLKMGR_FDBCK_MDIV_MASK;
+       refclkdiv = (cfg->per_pll_pllglob >> CLKMGR_PLLGLOB_REFCLKDIV_OFFSET) &
+                    CLKMGR_PLLGLOB_REFCLKDIV_MASK;
+       mscnt = CLKMGR_MSCNT_CONST / (CLKMGR_MDIV_CONST + mdiv) / refclkdiv;
+       hscnt = (mdiv + CLKMGR_MDIV_CONST) * mscnt / refclkdiv -
+               CLKMGR_HSCNT_CONST;
+       vcocalib = (hscnt & CLKMGR_VCOCALIB_HSCNT_MASK) |
+                  ((mscnt & CLKMGR_VCOCALIB_MSCNT_MASK) <<
+                  CLKMGR_VCOCALIB_MSCNT_OFFSET);
+
+       writel((cfg->per_pll_pllglob & ~CLKMGR_PLLGLOB_PD_MASK &
+               ~CLKMGR_PLLGLOB_RST_MASK),
+               &clock_manager_base->per_pll.pllglob);
+       writel(cfg->per_pll_fdbck, &clock_manager_base->per_pll.fdbck);
+       writel(vcocalib, &clock_manager_base->per_pll.vcocalib);
+       writel(cfg->per_pll_pllc0, &clock_manager_base->per_pll.pllc0);
+       writel(cfg->per_pll_pllc1, &clock_manager_base->per_pll.pllc1);
+       writel(cfg->per_pll_emacctl, &clock_manager_base->per_pll.emacctl);
+       writel(cfg->per_pll_gpiodiv, &clock_manager_base->per_pll.gpiodiv);
+
+       /* Take both PLL out of reset and power up */
+       setbits_le32(&clock_manager_base->main_pll.pllglob,
+                    CLKMGR_PLLGLOB_PD_MASK | CLKMGR_PLLGLOB_RST_MASK);
+       setbits_le32(&clock_manager_base->per_pll.pllglob,
+                    CLKMGR_PLLGLOB_PD_MASK | CLKMGR_PLLGLOB_RST_MASK);
+
+#define LOCKED_MASK \
+       (CLKMGR_STAT_MAINPLL_LOCKED | \
+       CLKMGR_STAT_PERPLL_LOCKED)
+
+       cm_wait_for_lock(LOCKED_MASK);
+
+       /*
+        * Dividers for C2 to C9 only init after PLLs are lock. As dividers
+        * only take effect upon value change, we shall set a maximum value as
+        * default value.
+        */
+       writel(0xff, &clock_manager_base->main_pll.mpuclk);
+       writel(0xff, &clock_manager_base->main_pll.nocclk);
+       writel(0xff, &clock_manager_base->main_pll.cntr2clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr3clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr4clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr5clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr6clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr7clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr8clk);
+       writel(0xff, &clock_manager_base->main_pll.cntr9clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr2clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr3clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr4clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr5clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr6clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr7clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr8clk);
+       writel(0xff, &clock_manager_base->per_pll.cntr9clk);
+
+       writel(cfg->main_pll_mpuclk, &clock_manager_base->main_pll.mpuclk);
+       writel(cfg->main_pll_nocclk, &clock_manager_base->main_pll.nocclk);
+       writel(cfg->main_pll_cntr2clk, &clock_manager_base->main_pll.cntr2clk);
+       writel(cfg->main_pll_cntr3clk, &clock_manager_base->main_pll.cntr3clk);
+       writel(cfg->main_pll_cntr4clk, &clock_manager_base->main_pll.cntr4clk);
+       writel(cfg->main_pll_cntr5clk, &clock_manager_base->main_pll.cntr5clk);
+       writel(cfg->main_pll_cntr6clk, &clock_manager_base->main_pll.cntr6clk);
+       writel(cfg->main_pll_cntr7clk, &clock_manager_base->main_pll.cntr7clk);
+       writel(cfg->main_pll_cntr8clk, &clock_manager_base->main_pll.cntr8clk);
+       writel(cfg->main_pll_cntr9clk, &clock_manager_base->main_pll.cntr9clk);
+       writel(cfg->per_pll_cntr2clk, &clock_manager_base->per_pll.cntr2clk);
+       writel(cfg->per_pll_cntr3clk, &clock_manager_base->per_pll.cntr3clk);
+       writel(cfg->per_pll_cntr4clk, &clock_manager_base->per_pll.cntr4clk);
+       writel(cfg->per_pll_cntr5clk, &clock_manager_base->per_pll.cntr5clk);
+       writel(cfg->per_pll_cntr6clk, &clock_manager_base->per_pll.cntr6clk);
+       writel(cfg->per_pll_cntr7clk, &clock_manager_base->per_pll.cntr7clk);
+       writel(cfg->per_pll_cntr8clk, &clock_manager_base->per_pll.cntr8clk);
+       writel(cfg->per_pll_cntr9clk, &clock_manager_base->per_pll.cntr9clk);
+
+       /* Take all PLLs out of bypass */
+       cm_write_bypass_mainpll(0);
+       cm_write_bypass_perpll(0);
+
+       /* clear safe mode / out of boot mode */
+       cm_write_ctrl(readl(&clock_manager_base->ctrl)
+                       & ~(CLKMGR_CTRL_SAFEMODE));
+
+       /* Now ungate non-hw-managed clocks */
+       writel(~0, &clock_manager_base->main_pll.en);
+       writel(~0, &clock_manager_base->per_pll.en);
+
+       /* Clear the loss of lock bits (write 1 to clear) */
+       writel(CLKMGR_INTER_PERPLLLOST_MASK | CLKMGR_INTER_MAINPLLLOST_MASK,
+              &clock_manager_base->intrclr);
+}
+
+static unsigned long cm_get_main_vco_clk_hz(void)
+{
+        unsigned long fref, refdiv, mdiv, reg, vco;
+
+       reg = readl(&clock_manager_base->main_pll.pllglob);
+
+       fref = (reg >> CLKMGR_PLLGLOB_VCO_PSRC_OFFSET) &
+               CLKMGR_PLLGLOB_VCO_PSRC_MASK;
+       switch (fref) {
+       case CLKMGR_VCO_PSRC_EOSC1:
+               fref = cm_get_osc_clk_hz(0);
+               break;
+       case CLKMGR_VCO_PSRC_INTOSC:
+               fref = cm_get_intosc_clk_hz();
+               break;
+       case CLKMGR_VCO_PSRC_F2S:
+               fref = cm_get_fpga_clk_hz();
+               break;
+       }
+
+       refdiv = (reg >> CLKMGR_PLLGLOB_REFCLKDIV_OFFSET) &
+                 CLKMGR_PLLGLOB_REFCLKDIV_MASK;
+
+       reg = readl(&clock_manager_base->main_pll.fdbck);
+       mdiv = (reg >> CLKMGR_FDBCK_MDIV_OFFSET) & CLKMGR_FDBCK_MDIV_MASK;
+
+       vco = fref / refdiv;
+       vco = vco * (CLKMGR_MDIV_CONST + mdiv);
+       return vco;
+}
+
+static unsigned long cm_get_per_vco_clk_hz(void)
+{
+       unsigned long fref, refdiv, mdiv, reg, vco;
+
+       reg = readl(&clock_manager_base->per_pll.pllglob);
+
+       fref = (reg >> CLKMGR_PLLGLOB_VCO_PSRC_OFFSET) &
+               CLKMGR_PLLGLOB_VCO_PSRC_MASK;
+       switch (fref) {
+       case CLKMGR_VCO_PSRC_EOSC1:
+               fref = cm_get_osc_clk_hz(0);
+               break;
+       case CLKMGR_VCO_PSRC_INTOSC:
+               fref = cm_get_intosc_clk_hz();
+               break;
+       case CLKMGR_VCO_PSRC_F2S:
+               fref = cm_get_fpga_clk_hz();
+               break;
+       }
+
+       refdiv = (reg >> CLKMGR_PLLGLOB_REFCLKDIV_OFFSET) &
+                 CLKMGR_PLLGLOB_REFCLKDIV_MASK;
+
+       reg = readl(&clock_manager_base->per_pll.fdbck);
+       mdiv = (reg >> CLKMGR_FDBCK_MDIV_OFFSET) & CLKMGR_FDBCK_MDIV_MASK;
+
+       vco = fref / refdiv;
+       vco = vco * (CLKMGR_MDIV_CONST + mdiv);
+       return vco;
+}
+
+unsigned long cm_get_mpu_clk_hz(void)
+{
+       unsigned long clock = readl(&clock_manager_base->main_pll.mpuclk);
+       clock = (clock >> CLKMGR_CLKSRC_OFFSET) & CLKMGR_CLKSRC_MASK;
+
+       switch (clock) {
+       case CLKMGR_CLKSRC_MAIN:
+               clock = cm_get_main_vco_clk_hz();
+               clock /= (readl(&clock_manager_base->main_pll.pllc0) &
+                         CLKMGR_PLLC0_DIV_MASK);
+               break;
+
+       case CLKMGR_CLKSRC_PER:
+               clock = cm_get_per_vco_clk_hz();
+               clock /= (readl(&clock_manager_base->per_pll.pllc0) &
+                         CLKMGR_CLKCNT_MSK);
+               break;
+
+       case CLKMGR_CLKSRC_OSC1:
+               clock = cm_get_osc_clk_hz(0);
+               break;
+
+       case CLKMGR_CLKSRC_INTOSC:
+               clock = cm_get_intosc_clk_hz();
+               break;
+
+       case CLKMGR_CLKSRC_FPGA:
+               clock = cm_get_fpga_clk_hz();
+               break;
+       }
+
+       clock /= 1 + (readl(&clock_manager_base->main_pll.mpuclk) &
+               CLKMGR_CLKCNT_MSK);
+       return clock;
+}
+
+unsigned int cm_get_l3_main_clk_hz(void)
+{
+       uint32_t clock = readl(&clock_manager_base->main_pll.nocclk);
+       clock = (clock >> CLKMGR_CLKSRC_OFFSET) & CLKMGR_CLKSRC_MASK;
+
+       switch (clock) {
+       case CLKMGR_CLKSRC_MAIN:
+               clock = cm_get_main_vco_clk_hz();
+               clock /= (readl(&clock_manager_base->main_pll.pllc1) &
+                         CLKMGR_PLLC0_DIV_MASK);
+               break;
+
+       case CLKMGR_CLKSRC_PER:
+               clock = cm_get_per_vco_clk_hz();
+               clock /= (readl(&clock_manager_base->per_pll.pllc1) &
+                         CLKMGR_CLKCNT_MSK);
+               break;
+
+       case CLKMGR_CLKSRC_OSC1:
+               clock = cm_get_osc_clk_hz(0);
+               break;
+
+       case CLKMGR_CLKSRC_INTOSC:
+               clock = cm_get_intosc_clk_hz();
+               break;
+
+       case CLKMGR_CLKSRC_FPGA:
+               clock = cm_get_fpga_clk_hz();
+               break;
+       }
+
+       clock /= 1 + (readl(&clock_manager_base->main_pll.nocclk) &
+               CLKMGR_CLKCNT_MSK);
+       return clock;
+}
+
+unsigned int cm_get_mmc_controller_clk_hz(void)
+{
+       uint32_t clock = readl(&clock_manager_base->per_pll.cntr6clk);
+       clock = (clock >> CLKMGR_CLKSRC_OFFSET) & CLKMGR_CLKSRC_MASK;
+
+       switch (clock) {
+       case CLKMGR_CLKSRC_MAIN:
+               clock = cm_get_l3_main_clk_hz();
+               clock /= 1 + (readl(&clock_manager_base->main_pll.cntr6clk) &
+                       CLKMGR_CLKCNT_MSK);
+               break;
+
+       case CLKMGR_CLKSRC_PER:
+               clock = cm_get_l3_main_clk_hz();
+               clock /= 1 + (readl(&clock_manager_base->per_pll.cntr6clk) &
+                       CLKMGR_CLKCNT_MSK);
+               break;
+
+       case CLKMGR_CLKSRC_OSC1:
+               clock = cm_get_osc_clk_hz(0);
+               break;
+
+       case CLKMGR_CLKSRC_INTOSC:
+               clock = cm_get_intosc_clk_hz();
+               break;
+
+       case CLKMGR_CLKSRC_FPGA:
+               clock = cm_get_fpga_clk_hz();
+               break;
+       }
+       return clock / 4;
+}
+
+unsigned int cm_get_l4_sp_clk_hz(void)
+{
+       uint32_t clock = cm_get_l3_main_clk_hz();
+
+       clock /= (1 << ((readl(&clock_manager_base->main_pll.nocdiv) >>
+                 CLKMGR_NOCDIV_L4SPCLK_OFFSET) & CLKMGR_CLKCNT_MSK));
+       return clock;
+}
+
+void cm_print_clock_quick_summary(void)
+{
+       printf("MPU         %d kHz\n", (u32)(cm_get_mpu_clk_hz() / 1000));
+       printf("L3 main     %d kHz\n", cm_get_l3_main_clk_hz() / 1000);
+       printf("Main VCO    %d kHz\n", (u32)(cm_get_main_vco_clk_hz() / 1000));
+       printf("Per VCO     %d kHz\n", (u32)(cm_get_per_vco_clk_hz() / 1000));
+       printf("EOSC1       %d kHz\n", cm_get_osc_clk_hz(0) / 1000);
+       printf("HPS MMC     %d kHz\n", cm_get_mmc_controller_clk_hz() / 1000);
+       printf("UART        %d kHz\n", cm_get_l4_sp_clk_hz() / 1000);
+}
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
new file mode 100644
index 0000000..831cf2c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef        _CLOCK_MANAGER_S10_
+#define        _CLOCK_MANAGER_S10_
+
+/* Clock speed accessors */
+unsigned long cm_get_mpu_clk_hz(void);
+unsigned long cm_get_sdram_clk_hz(void);
+unsigned int cm_get_l4_sp_clk_hz(void);
+unsigned int cm_get_mmc_controller_clk_hz(void);
+unsigned int cm_get_qspi_controller_clk_hz(void);
+unsigned int cm_get_spi_controller_clk_hz(void);
+const unsigned int cm_get_osc_clk_hz(const int osc);
+const unsigned int cm_get_f2s_per_ref_clk_hz(void);
+const unsigned int cm_get_f2s_sdr_ref_clk_hz(void);
+const unsigned int cm_get_intosc_clk_hz(void);
+const unsigned int cm_get_fpga_clk_hz(void);
+
+#define CLKMGR_EOSC1_HZ                25000000
+#define CLKMGR_INTOSC_HZ       460000000
+#define CLKMGR_FPGA_CLK_HZ     50000000
+
+/* Clock configuration accessors */
+const struct cm_config * const cm_get_default_config(void);
+
+struct cm_config {
+       /* main group */
+       uint32_t main_pll_mpuclk;
+       uint32_t main_pll_nocclk;
+       uint32_t main_pll_cntr2clk;
+       uint32_t main_pll_cntr3clk;
+       uint32_t main_pll_cntr4clk;
+       uint32_t main_pll_cntr5clk;
+       uint32_t main_pll_cntr6clk;
+       uint32_t main_pll_cntr7clk;
+       uint32_t main_pll_cntr8clk;
+       uint32_t main_pll_cntr9clk;
+       uint32_t main_pll_nocdiv;
+       uint32_t main_pll_pllglob;
+       uint32_t main_pll_fdbck;
+       uint32_t main_pll_pllc0;
+       uint32_t main_pll_pllc1;
+       uint32_t spare;
+
+       /* peripheral group */
+       uint32_t per_pll_cntr2clk;
+       uint32_t per_pll_cntr3clk;
+       uint32_t per_pll_cntr4clk;
+       uint32_t per_pll_cntr5clk;
+       uint32_t per_pll_cntr6clk;
+       uint32_t per_pll_cntr7clk;
+       uint32_t per_pll_cntr8clk;
+       uint32_t per_pll_cntr9clk;
+       uint32_t per_pll_emacctl;
+       uint32_t per_pll_gpiodiv;
+       uint32_t per_pll_pllglob;
+       uint32_t per_pll_fdbck;
+       uint32_t per_pll_pllc0;
+       uint32_t per_pll_pllc1;
+
+       /* incoming clock */
+       uint32_t hps_osc_clk_hz;
+       uint32_t fpga_clk_hz;
+};
+
+void cm_basic_init(const struct cm_config * const cfg);
+
+struct socfpga_clock_manager_main_pll {
+       u32     en;
+       u32     ens;
+       u32     enr;
+       u32     bypass;
+       u32     bypasss;
+       u32     bypassr;
+       u32     mpuclk;
+       u32     nocclk;
+       u32     cntr2clk;
+       u32     cntr3clk;
+       u32     cntr4clk;
+       u32     cntr5clk;
+       u32     cntr6clk;
+       u32     cntr7clk;
+       u32     cntr8clk;
+       u32     cntr9clk;
+       u32     nocdiv;
+       u32     pllglob;
+       u32     fdbck;
+       u32     mem;
+       u32     memstat;
+       u32     pllc0;
+       u32     pllc1;
+       u32     vcocalib;
+       u32     _pad_0x90_0xA0[5];
+};
+
+struct socfpga_clock_manager_per_pll {
+       u32     en;
+       u32     ens;
+       u32     enr;
+       u32     bypass;
+       u32     bypasss;
+       u32     bypassr;
+       u32     cntr2clk;
+       u32     cntr3clk;
+       u32     cntr4clk;
+       u32     cntr5clk;
+       u32     cntr6clk;
+       u32     cntr7clk;
+       u32     cntr8clk;
+       u32     cntr9clk;
+       u32     emacctl;
+       u32     gpiodiv;
+       u32     pllglob;
+       u32     fdbck;
+       u32     mem;
+       u32     memstat;
+       u32     pllc0;
+       u32     pllc1;
+       u32     vcocalib;
+       u32     _pad_0x100_0x124[10];
+};
+
+struct socfpga_clock_manager {
+       u32     ctrl;
+       u32     stat;
+       u32     testioctrl;
+       u32     intrgen;
+       u32     intrmsk;
+       u32     intrclr;
+       u32     intrsts;
+       u32     intrstk;
+       u32     intrraw;
+       u32     _pad_0x24_0x2c[3];
+       struct socfpga_clock_manager_main_pll main_pll;
+       struct socfpga_clock_manager_per_pll per_pll;
+};
+
+#define CLKMGR_CTRL_SAFEMODE                           (1 << 0)
+#define CLKMGR_BYPASS_MAINPLL_ALL                      0x00000007
+#define CLKMGR_BYPASS_PERPLL_ALL                       0x0000007f
+
+#define CLKMGR_INTER_MAINPLLLOCKED_MASK                        0x00000001
+#define CLKMGR_INTER_PERPLLLOCKED_MASK                 0x00000002
+#define CLKMGR_INTER_MAINPLLLOST_MASK                  0x00000004
+#define CLKMGR_INTER_PERPLLLOST_MASK                   0x00000008
+#define CLKMGR_STAT_BUSY                               (1 << 0)
+#define CLKMGR_STAT_MAINPLL_LOCKED                     (1 << 8)
+#define CLKMGR_STAT_PERPLL_LOCKED                      (1 << 9)
+
+#define CLKMGR_PLLGLOB_PD_MASK                         0x00000001
+#define CLKMGR_PLLGLOB_RST_MASK                                0x00000002
+#define CLKMGR_PLLGLOB_VCO_PSRC_MASK                   0X3
+#define CLKMGR_PLLGLOB_VCO_PSRC_OFFSET                 16
+#define CLKMGR_VCO_PSRC_EOSC1                          0
+#define CLKMGR_VCO_PSRC_INTOSC                         1
+#define CLKMGR_VCO_PSRC_F2S                            2
+#define CLKMGR_PLLGLOB_REFCLKDIV_MASK                  0X3f
+#define CLKMGR_PLLGLOB_REFCLKDIV_OFFSET                        8
+
+#define CLKMGR_CLKSRC_MASK                             0x7
+#define CLKMGR_CLKSRC_OFFSET                           16
+#define CLKMGR_CLKSRC_MAIN                             0
+#define CLKMGR_CLKSRC_PER                              1
+#define CLKMGR_CLKSRC_OSC1                             2
+#define CLKMGR_CLKSRC_INTOSC                           3
+#define CLKMGR_CLKSRC_FPGA                             4
+#define CLKMGR_CLKCNT_MSK                              0x7ff
+
+#define CLKMGR_FDBCK_MDIV_MASK                         0xff
+#define CLKMGR_FDBCK_MDIV_OFFSET                       24
+
+#define CLKMGR_PLLC0_DIV_MASK                          0xff
+#define CLKMGR_PLLC1_DIV_MASK                          0xff
+#define CLKMGR_PLLC0_EN_OFFSET                         27
+#define CLKMGR_PLLC1_EN_OFFSET                         24
+
+#define CLKMGR_NOCDIV_L4MAIN_OFFSET                    0
+#define CLKMGR_NOCDIV_L4MPCLK_OFFSET                   8
+#define CLKMGR_NOCDIV_L4SPCLK_OFFSET                   16
+#define CLKMGR_NOCDIV_CSATCLK_OFFSET                   24
+#define CLKMGR_NOCDIV_CSTRACECLK_OFFSET                        26
+#define CLKMGR_NOCDIV_CSPDBGCLK_OFFSET                 28
+
+#define CLKMGR_NOCDIV_L4SPCLK_MASK                     0X3
+#define CLKMGR_NOCDIV_DIV1                             0
+#define CLKMGR_NOCDIV_DIV2                             1
+#define CLKMGR_NOCDIV_DIV4                             2
+#define CLKMGR_NOCDIV_DIV8                             3
+#define CLKMGR_CSPDBGCLK_DIV1                          0
+#define CLKMGR_CSPDBGCLK_DIV4                          1
+
+#define CLKMGR_MSCNT_CONST                             200
+#define CLKMGR_MDIV_CONST                              6
+#define CLKMGR_HSCNT_CONST                             9
+
+#define CLKMGR_VCOCALIB_MSCNT_MASK                     0xff
+#define CLKMGR_VCOCALIB_MSCNT_OFFSET                   9
+#define CLKMGR_VCOCALIB_HSCNT_MASK                     0xff
+
+#define CLKMGR_EMACCTL_EMAC0SEL_OFFSET                 26
+#define CLKMGR_EMACCTL_EMAC1SEL_OFFSET                 27
+#define CLKMGR_EMACCTL_EMAC2SEL_OFFSET                 28
+
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK              0x00000020
+
+#endif /* _CLOCK_MANAGER_S10_ */
arch/arm/mach-socfpga/include/mach/handoff_s10.h new file +29 -0
new file mode 100644
index 0000000..d4b89ac
@@ -0,0 +1,29 @@
+/*
+ *  Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#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
+
+#endif /* _HANDOFF_S10_H_ */
arch/arm/mach-socfpga/wrap_pll_config_s10.c new file +17 -0
new file mode 100644
index 0000000..3f19534
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <asm/arch/clock_manager.h>
+#include <asm/io.h>
+#include <asm/arch/handoff_s10.h>
+
+const struct cm_config * const cm_get_default_config(void)
+{
+       struct cm_config *cm_handoff_cfg = (struct cm_config *)
+               (CONFIG_HANDOFF_CLOCK + CONFIG_HANDOFF_OFFSET_DATA);
+       u32 *conversion = (u32 *)cm_handoff_cfg;
+       u32 i;

arch/arm/mach-socfpga/wrap_pll_config_s10.c line 27

Quoted 10 lines
arch/arm/mach-socfpga/wrap_pll_config_s10.c new file +10 -0
+
+       if (swab32(readl(CONFIG_HANDOFF_CLOCK)) == CONFIG_HANDOFF_MAGIC_CLOCK) {
+               writel(swab32(readl(CONFIG_HANDOFF_CLOCK)),
+                       CONFIG_HANDOFF_CLOCK);
+               for (i = 0; i < (sizeof(*cm_handoff_cfg) / sizeof(u32)); i++)
+                       conversion[i] = swab32(conversion[i]);
+               return cm_handoff_cfg;
+       } else if (readl(CONFIG_HANDOFF_CLOCK) == CONFIG_HANDOFF_MAGIC_CLOCK) {
+               return cm_handoff_cfg;
+       } else

the above code doesn't really read well. Can you do something like this?

handoff_clk = readl(CONFIG_HANDOFF_CLOCK);

if (swab32(handoff_clk) == CONFIG_HANDOFF_MAGIC_CLOCK) {
       writel(swab32(handoff_clk);
       for...
} else if (handoff_clk == CONFIG_HANDOFF_MAGIC_CLOCK)
      return cm_handoff_cfg;

return 0;

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

Quoted 4 lines
arch/arm/mach-socfpga/wrap_pll_config_s10.c new file +4 -0
+               return 0;
+}
+
+const unsigned int cm_get_osc_clk_hz(const int osc)

What's "osc" used for?

Dinh

#5 lore raw

PATCH v2 3/14 arm: socfpga: stratix10: Add Reset Manager driver for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add Reset Manager driver support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                     |   1 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           |   8 +-
 .../mach-socfpga/include/mach/reset_manager_s10.h  | 116 ++++++++++++++++++++
 arch/arm/mach-socfpga/reset_manager.c              |  41 +++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      |  67 +++---------
 arch/arm/mach-socfpga/reset_manager_gen5.c         |  33 ------
 arch/arm/mach-socfpga/reset_manager_s10.c          | 118 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-s10.h       |  97 +++++++++++++++++
 9 files changed, 395 insertions(+), 88 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_arria10.h +4 -4
index b6d7f4f..e521839 100644
@@ -28,10 +28,10 @@ struct socfpga_reset_manager {
 	u32	hdskreq;
 	u32	hdskack;
 	u32	counts;
-	u32	mpumodrst;
-	u32	per0modrst;
-	u32	per1modrst;
-	u32	brgmodrst;
+	u32	mpu_mod_reset;
+	u32	per_mod_reset;
+	u32	per2_mod_reset;
+	u32	brg_mod_reset;
 	u32	sysmodrst;
 	u32	coldmodrst;
 	u32	nrstmodrst;
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 +41 -0

52 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager_arria10.c +16 -51

128 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager_gen5.c +0 -33
index aa88adb..0abb519 100644
@@ -18,39 +18,6 @@ static const struct socfpga_reset_manager *reset_manager_base =
 static const struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
 
-/* Assert or de-assert SoCFPGA reset manager reset. */
-void socfpga_per_reset(u32 reset, int set)
-{
-	const u32 *reg;
-	u32 rstmgr_bank = RSTMGR_BANK(reset);
-
-	switch (rstmgr_bank) {
-	case 0:
-		reg = &reset_manager_base->mpu_mod_reset;
-		break;
-	case 1:
-		reg = &reset_manager_base->per_mod_reset;
-		break;
-	case 2:
-		reg = &reset_manager_base->per2_mod_reset;
-		break;
-	case 3:
-		reg = &reset_manager_base->brg_mod_reset;
-		break;
-	case 4:
-		reg = &reset_manager_base->misc_mod_reset;
-		break;
-
-	default:
-		return;
-	}
-
-	if (set)
-		setbits_le32(reg, 1 << RSTMGR_RESET(reset));
-	else
-		clrbits_le32(reg, 1 << RSTMGR_RESET(reset));
-}
-
 /*
  * Assert reset on every peripheral but L4WD0.
  * Watchdog must be kept intact to prevent glitches
arch/arm/mach-socfpga/reset_manager_s10.c new file +118 -0

118 lines not on this page · raw message

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

97 lines not on this page · raw message

Signature · 1 line
2.2.2
#6 lore raw

PATCH v2 3/14 arm: socfpga: stratix10: Add Reset Manager driver for Stratix10 SoC

Quoted 5 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add Reset Manager driver support for Stratix SoC

Quoted 11 lines
---
 arch/arm/mach-socfpga/Makefile                     |   1 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           |   8 +-
 .../mach-socfpga/include/mach/reset_manager_s10.h  | 116 ++++++++++++++++++++
 arch/arm/mach-socfpga/reset_manager.c              |  41 +++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      |  67 +++---------
 arch/arm/mach-socfpga/reset_manager_gen5.c         |  33 ------
 arch/arm/mach-socfpga/reset_manager_s10.c          | 118 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-s10.h       |  97 +++++++++++++++++
 9 files changed, 395 insertions(+), 88 deletions(-)

Yikes! Can you find a way to split this patch up? Looks like you're adding support
for Stratix10, but you're also messing with gen5 and arria10 stuff, it's a bit hard to
review.

Thanks,
Dinh

#7 lore raw

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

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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 | 169 +++++++++++++++++++++
 arch/arm/mach-socfpga/system_manager_s10.c         |  91 +++++++++++
 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c     |  55 +++++++
 5 files changed, 321 insertions(+), 1 deletion(-)
 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 +169 -0

169 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 +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.2.2
#8 lore raw

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

Quoted 5 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add pinmux driver support for Stratix SoC

Quoted 11 lines
---
 arch/arm/mach-socfpga/Makefile                     |   2 +
 .../arm/mach-socfpga/include/mach/system_manager.h |   5 +-
 .../mach-socfpga/include/mach/system_manager_s10.h | 169 +++++++++++++++++++++
 arch/arm/mach-socfpga/system_manager_s10.c         |  91 +++++++++++
 arch/arm/mach-socfpga/wrap_pinmux_config_s10.c     |  55 +++++++
 5 files changed, 321 insertions(+), 1 deletion(-)
 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
#9 lore raw

PATCH v2 5/14 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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

---
 arch/arm/mach-socfpga/Makefile            |   1 +
 arch/arm/mach-socfpga/include/mach/misc.h |   1 +
 arch/arm/mach-socfpga/misc.c              |  76 ++++++++++++++++++++
 arch/arm/mach-socfpga/misc_gen5.c         |  75 ++-----------------
 arch/arm/mach-socfpga/misc_s10.c          | 115 ++++++++++++++++++++++++++++++
 5 files changed, 197 insertions(+), 71 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/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 +76 -0

102 lines not on this page · raw message

arch/arm/mach-socfpga/misc_gen5.c +4 -71

87 lines not on this page · raw message

arch/arm/mach-socfpga/misc_s10.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.2.2
#10 lore raw

PATCH v2 5/14 arm: socfpga: stratix10: Add misc support for Stratix10 SoC

Quoted 5 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

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

Quoted 9 lines
---
 arch/arm/mach-socfpga/Makefile            |   1 +
 arch/arm/mach-socfpga/include/mach/misc.h |   1 +
 arch/arm/mach-socfpga/misc.c              |  76 ++++++++++++++++++++
 arch/arm/mach-socfpga/misc_gen5.c         |  75 ++-----------------
 arch/arm/mach-socfpga/misc_s10.c          | 115 ++++++++++++++++++++++++++++++
 5 files changed, 197 insertions(+), 71 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/misc_s10.c

I can see a few ways this patch can get split up to more manageable pieces. The bridge enablement can be separated. The wrap of CONFIG_SYS_L2_PL310 can be separate. The split of the emac reset can be separate. This would allow for easier review.

Dinh

#11 lore raw

PATCH v2 6/14 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |   1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 108 ++++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              | 238 +++++++++++++++++++++++
 3 files changed, 347 insertions(+)
 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 +108 -0

108 lines not on this page · raw message

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

238 lines not on this page · raw message

Signature · 1 line
2.2.2
#12 lore raw

PATCH v2 6/14 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 100 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |   1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 108 ++++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              | 238 +++++++++++++++++++++++
 3 files changed, 347 insertions(+)
 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 +68 -0
new file mode 100644
index 0000000..b9bddf6
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+#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_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, cmd)             \
+       (((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_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 */
+typedef enum {
+       /* CMD completed succesfully, 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 */

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

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +10 -0
+       MBOX_RESP_NO_VALID_RESP_AVAILABLE = 0x2FF,
+       /* General Error */
+       MBOX_RESP_ERROR = 0x3FF,
+} ALT_SDM_MBOX_RESP_CODE;
+
+/* Mailbox command list */
+#define MBOX_RESTART           2
+#define MBOX_QSPI_OPEN         50
+#define MBOX_QSPI_CLOSE                51
+#define MBOX_QSPI_DIRECT       59

Only 3 commands?

Quoted 18 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +18 -0
+
+struct socfpga_mailbox {
+       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 */
+};
+

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

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +10 -0
+/* 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)
+
+int mbox_init(void);
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void);
+int mbox_qspi_open(void);
+#endif

I think these should be in a separate patch.

Quoted 112 lines
arch/arm/mach-socfpga/include/mach/mailbox_s10.h new file +2 -0
+
+#endif /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c new file +104 -0
new file mode 100644
index 0000000..de836b1
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <asm/arch/mailbox_s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_mailbox *mbox_base =
+               (void *)SOCFPGA_MAILBOX_ADDRESS;
+
+#define MBOX_POLL_RESP_TIMEOUT         50 /* ms */
+
+static int mbox_polling_resp(u32 rout)
+{
+       u32 rin;
+       unsigned long start = get_timer(0);
+
+       while (1) {
+               rin = readl(&mbox_base->rin);
+               if (rout != rin)
+                       return 0;
+
+               if (get_timer(start) > MBOX_POLL_RESP_TIMEOUT)
+                       break;
+
+               udelay(1);
+       }
+
+       debug("mailbox: polling response timeout\n");
+       return -ETIMEDOUT;
+}
+
+/* Check for available slot and write to circular buffer.
+ * It also update command valid offset (cin) register.
+ */
+static int mbox_fill_cmd_circular_buff(u32 header, u32 len, u32 *arg)
+{
+       u32 cmd_free_offset;
+       u32 i;
+
+       /* checking available command free slot */
+       cmd_free_offset = readl(&mbox_base->cout);
+       if (cmd_free_offset >= MBOX_CMD_BUFFER_SIZE) {
+               error("ERROR: Not enough space, cout %d\n", cmd_free_offset);
+               return -ENOMEM;
+       }
+
+       /* write header to circular buffer */
+       writel(header, &mbox_base->cmd_buf[cmd_free_offset++]);
+       /* wrapping around when it reach the buffer size */
+       cmd_free_offset %= MBOX_CMD_BUFFER_SIZE;
+
+       /* write arguments */
+       for (i = 0; i < len; i++) {
+               writel(arg[i], &mbox_base->cmd_buf[cmd_free_offset++]);
+               /* wrapping around when it reach the buffer size */
+               cmd_free_offset %= MBOX_CMD_BUFFER_SIZE;
+       }
+
+       /* write command valid offset */
+       writel(cmd_free_offset, &mbox_base->cin);
+       return 0;
+}
+
+/* Support one command and up to 31 words argument length only */
+int mbox_send_cmd(u8 id, u32 cmd, u32 len, u32 *arg, u8 urgent,
+                       u32 *resp_buf_len, u32 *resp_buf)
+{
+       u32 header;
+       u32 rin;
+       u32 resp;
+       u32 rout;
+       u32 status;
+       u32 resp_len;
+       u32 buf_len;
+       int ret;
+
+       /* Total lenght is command + argument length */
+       if ((len + 1) > MBOX_CMD_BUFFER_SIZE) {
+               error("ERROR: command %d arguments too long, max %d\n", cmd,
+                     MBOX_CMD_BUFFER_SIZE - 1);
+               return -EINVAL;
+       }
+
+       if (cmd > MBOX_MAX_CMD_INDEX) {
+               error("ERROR: Unsupported command index %d\n", cmd);
+               return -EINVAL;
+       }
+
+       header = MBOX_CMD_HEADER(MBOX_CLIENT_ID_UBOOT, id , len, cmd);
+
+       ret = mbox_fill_cmd_circular_buff(header, len, arg);
+       if (ret)
+               return ret;
+
+       if (urgent) {
+               /* Send command as urgent command */
+               writel(1, &mbox_base->urg);

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+       }
+
+       /* write doorbell */
+       writel(1, MBOX_DOORBELL_TO_SDM_REG);
+
+       while (1) {
+               /* Wait for doorbell from SDM */
+               ret = wait_for_bit(__func__,
+                                  (const u32 *)MBOX_DOORBELL_FROM_SDM_REG,
+                                  1, true, 500000, false);

Add a define for 500000.

Quoted 7 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +7 -0
+               if (ret) {
+                       error("mailbox: timeout from SDM\n");
+                       return ret;
+               }
+
+               /* clear interrupt */
+               writel(0, MBOX_DOORBELL_FROM_SDM_REG);

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+
+               if (urgent) {
+                       /* urgent command doesn't has response */
+                       writel(0, &mbox_base->urg);
+                       status = readl(&mbox_base->status);
+                       if (status & MBOX_STATUS_UA_MSK)
+                               return 0;
+
+                       error("mailbox: cmd %d no urgent ACK\n", cmd);
+                       return -1;

Use '-EPERM' for -1.

Quoted 32 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +32 -0
+               }
+
+               /* 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) {
+                                       error("mailbox send command %d error %d\n",
+                                             cmd, ret);
+                                       return ret;
+                               }
+
+                               if (resp_buf_len) {
+                                       buf_len = *resp_buf_len;
+                                       *resp_buf_len = 0;
+                               } else {

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+                                       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 */

Fix comment style.

Quoted 28 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +28 -0
+                                       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)
+{
+       int ret;
+
+       /* enable mailbox interrupts */
+       writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+       ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_RESTART, 0, NULL, 1, 0, NULL);

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+       if (ret)
+               return ret;
+
+       /* Renable mailbox interrupts after MBOX_RESTART */
+       writel(MBOX_ALL_INTRS, &mbox_base->flags);
+
+       return 0;
+}
+
+#ifdef CONFIG_CADENCE_QSPI

I think this should be in a separate patch.

Dinh

maintainer
#13 lore raw

PATCH v2 6/14 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

In reply to chin.liang.see at intel.com
Quoted 186 lines · chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |   1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 108 ++++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              | 238 +++++++++++++++++++++++
 3 files changed, 347 insertions(+)
 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 +108 -0
new file mode 100644
index 0000000..b9bddf6
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+#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_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, cmd)		   \
+	(((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_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 */
+typedef enum {
+	/* CMD completed succesfully, 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,
+} ALT_SDM_MBOX_RESP_CODE;
+
+/* Mailbox command list */
+#define MBOX_RESTART		2
+#define MBOX_QSPI_OPEN		50
+#define MBOX_QSPI_CLOSE		51
+#define MBOX_QSPI_DIRECT	59
+
+struct socfpga_mailbox {
+	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)
+
+int mbox_init(void);
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void);
+int mbox_qspi_open(void);
+#endif
+
+#endif	/* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c new file +40 -0
new file mode 100644
index 0000000..de836b1
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <asm/arch/mailbox_s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_mailbox *mbox_base =
+		(void *)SOCFPGA_MAILBOX_ADDRESS;
+
+#define MBOX_POLL_RESP_TIMEOUT		50 /* ms */
+
+static int mbox_polling_resp(u32 rout)
+{
+	u32 rin;
+	unsigned long start = get_timer(0);
+
+	while (1) {
+		rin = readl(&mbox_base->rin);
+		if (rout != rin)
+			return 0;
+
+		if (get_timer(start) > MBOX_POLL_RESP_TIMEOUT)
+			break;
+
+		udelay(1);
+	}
+
+	debug("mailbox: polling response timeout\n");
+	return -ETIMEDOUT;
+}
+
+/* Check for available slot and write to circular buffer.
+ * It also update command valid offset (cin) register.

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+ */
+static int mbox_fill_cmd_circular_buff(u32 header, u32 len, u32 *arg)
+{
+	u32 cmd_free_offset;
+	u32 i;
+
+	/* checking available command free slot */
+	cmd_free_offset = readl(&mbox_base->cout);
+	if (cmd_free_offset >= MBOX_CMD_BUFFER_SIZE) {
+		error("ERROR: Not enough space, cout %d\n", cmd_free_offset);

I'm getting these build error:

arch/arm/mach-socfpga/mailbox_s10.c: In function ‘mbox_fill_cmd_circular_buff’:
arch/arm/mach-socfpga/mailbox_s10.c:50:3: warning: implicit declaration of function ‘error’ [-Wimplicit-function-declaration]
error("ERROR: Not enough space, cout %d\n", cmd_free_offset)

arch/arm/mach-socfpga/built-in.o: In function `mbox_send_cmd':
/home/dinguyen/linux_dev/u-boot/arch/arm/mach-socfpga/mailbox_s10.c:86:
undefined reference to `error'

Please at least do a compile test on your patches in the future.

Dinh

#14 lore raw

PATCH v2 6/14 arm: socfpga: stratix10: Add mailbox support for Stratix10 SoC

Quoted 208 lines · Dinh Nguyen
Quoted 186 lines · chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add mailbox support for Stratix SoC

---
 arch/arm/mach-socfpga/Makefile                   |   1 +
 arch/arm/mach-socfpga/include/mach/mailbox_s10.h | 108 ++++++++++
 arch/arm/mach-socfpga/mailbox_s10.c              | 238 +++++++++++++++++++++++
 3 files changed, 347 insertions(+)
 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 +108 -0
new file mode 100644
index 0000000..b9bddf6
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+#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_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, cmd)                   \
+     (((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_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 */
+typedef enum {
+     /* CMD completed succesfully, 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,
+} ALT_SDM_MBOX_RESP_CODE;
+
+/* Mailbox command list */
+#define MBOX_RESTART         2
+#define MBOX_QSPI_OPEN               50
+#define MBOX_QSPI_CLOSE              51
+#define MBOX_QSPI_DIRECT     59
+
+struct socfpga_mailbox {
+     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)
+
+int mbox_init(void);
+
+#ifdef CONFIG_CADENCE_QSPI
+int mbox_qspi_close(void);
+int mbox_qspi_open(void);
+#endif
+
+#endif       /* _MAILBOX_S10_H_ */
arch/arm/mach-socfpga/mailbox_s10.c new file +40 -0
new file mode 100644
index 0000000..de836b1
@@ -0,0 +1,238 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+
+#include <common.h>
+#include <wait_bit.h>
+#include <asm/io.h>
+#include <asm/arch/mailbox_s10.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_mailbox *mbox_base =
+             (void *)SOCFPGA_MAILBOX_ADDRESS;
+
+#define MBOX_POLL_RESP_TIMEOUT               50 /* ms */
+
+static int mbox_polling_resp(u32 rout)
+{
+     u32 rin;
+     unsigned long start = get_timer(0);
+
+     while (1) {
+             rin = readl(&mbox_base->rin);
+             if (rout != rin)
+                     return 0;
+
+             if (get_timer(start) > MBOX_POLL_RESP_TIMEOUT)
+                     break;
+
+             udelay(1);
+     }
+
+     debug("mailbox: polling response timeout\n");
+     return -ETIMEDOUT;
+}
+
+/* Check for available slot and write to circular buffer.
+ * It also update command valid offset (cin) register.

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

Quoted 10 lines
arch/arm/mach-socfpga/mailbox_s10.c new file +10 -0
+ */
+static int mbox_fill_cmd_circular_buff(u32 header, u32 len, u32 *arg)
+{
+     u32 cmd_free_offset;
+     u32 i;
+
+     /* checking available command free slot */
+     cmd_free_offset = readl(&mbox_base->cout);
+     if (cmd_free_offset >= MBOX_CMD_BUFFER_SIZE) {
+             error("ERROR: Not enough space, cout %d\n", cmd_free_offset);

I'm getting these build error:

arch/arm/mach-socfpga/mailbox_s10.c: In function ‘mbox_fill_cmd_circular_buff’:
arch/arm/mach-socfpga/mailbox_s10.c:50:3: warning: implicit declaration of function ‘error’ [-Wimplicit-function-declaration]
error("ERROR: Not enough space, cout %d\n", cmd_free_offset)

Quoted 6 lines

arch/arm/mach-socfpga/built-in.o: In function `mbox_send_cmd':
/home/dinguyen/linux_dev/u-boot/arch/arm/mach-socfpga/mailbox_s10.c:86:
undefined reference to `error'

Please at least do a compile test on your patches in the future.

FYI: the reason for the above error is because of this commit:

commit 9b643e312d528f291966c1f30b0d90bf3b1d43dc

Author: Masahiro Yamada <[email protected]>
Date:   Sat Sep 16 14:10:41 2017 +0900

treewide: replace with error() with pr_err()

Please use pr_error().

Dinh

#15 lore raw

PATCH v2 7/14 arm: socfpga: stratix10: Add MMU support for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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

PATCH v2 8/14 arm: dts: Add dts for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Device tree for Stratix10 SoC

---
 arch/arm/dts/Makefile                    |   3 +-
 arch/arm/dts/socfpga_stratix10_socdk.dts | 180 +++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/socfpga_stratix10_socdk.dts
arch/arm/dts/Makefile +2 -1
index 7c062f0..f66b9c9 100644
@@ -171,7 +171,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 +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.2.2
#17 lore raw

PATCH v2 8/14 arm: dts: Add dts for Stratix10 SoC

Quoted 10 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Device tree for Stratix10 SoC

---
 arch/arm/dts/Makefile                    |   3 +-
 arch/arm/dts/socfpga_stratix10_socdk.dts | 180 +++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/socfpga_stratix10_socdk.dts

Shouldn't you have a dtsi base file for the SOC, and then subsequent boards would be the dts?

Quoted 125 lines
arch/arm/dts/Makefile +2 -1
index 7c062f0..f66b9c9 100644
@@ -171,7 +171,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 +104 -0
new file mode 100644
index 0000000..26b407f
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+/dts-v1/;
+#include "skeleton.dtsi"
+#include <dt-bindings/reset/altr,rst-mgr-s10.h>
+
+/ {
+       model = "Intel SOCFPGA Stratix 10 SoC Development Kit";
+       compatible = "altr,socfpga-stratix10", "altr,socfpga";
+
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       chosen {
+               bootargs = "console=ttyS0,115200";
+       };
+
+       aliases {
+               ethernet0 = &gmac0;
+               spi0 = &qspi;
+       };
+
+       memory {
+               name = "memory";
+               device_type = "memory";
+               reg = <0x0 0x80000000>; /* 2GB */
+       };
+
+       regulator_3_3v: 3-3-v-regulator {
+               compatible = "regulator-fixed";
+               regulator-name = "3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu at 0 {
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       device_type = "cpu";
+                       enable-method = "psci";
+                       reg = <0x0>;
+               };
+
+               cpu at 1 {
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       device_type = "cpu";
+                       enable-method = "psci";
+                       reg = <0x1>;
+               };
+
+               cpu at 2 {
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       device_type = "cpu";
+                       enable-method = "psci";
+                       reg = <0x2>;
+               };
+
+               cpu at 3 {
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       device_type = "cpu";
+                       enable-method = "psci";
+                       reg = <0x3>;
+               };
+       };
+
+       soc {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "simple-bus";
+               device_type = "soc";
+               ranges;
+               u-boot,dm-pre-reloc;
+
+               rst: rstmgr at ffd11000 {
+                       #reset-cells = <1>;
+                       compatible = "altr,rst-mgr";
+                       reg = <0xffd11000 0x100>;
+                       altr,modrst-offset = <0x20>;
+               };
+
+               mdio {
+                       phy0: ethernet-phy at 0 {
+                               txd0-skew-ps = <0>; /* -420ps */
+                               txd1-skew-ps = <0>; /* -420ps */
+                               txd2-skew-ps = <0>; /* -420ps */
+                               txd3-skew-ps = <0>; /* -420ps */
+                               rxd0-skew-ps = <420>; /* 0ps */
+                               rxd1-skew-ps = <420>; /* 0ps */
+                               rxd2-skew-ps = <420>; /* 0ps */
+                               rxd3-skew-ps = <420>; /* 0ps */
+                               txen-skew-ps = <0>; /* -420ps */
+                               txc-skew-ps = <1860>; /* 960ps */
+                               rxdv-skew-ps = <420>; /* 0ps */
+                               rxc-skew-ps = <1680>; /* 780ps */
+                       };
+               };
+

arch/arm/dts/socfpga_stratix10_socdk.dts line 114

Quoted 10 lines
arch/arm/dts/socfpga_stratix10_socdk.dts new file +10 -0
+               gmac0: ethernet at ff800000 {
+                       compatible = "altr,socfpga-stmmac", "snps,dwmac-3.74a", "snps,dwmac";
+                       reg = <0xff800000 0x2000>;
+                       interrupts = <0 90 4>;
+                       interrupt-names = "macirq";
+                       mac-address = [00 00 00 00 00 00];
+                       resets = <&rst EMAC0_RESET>;
+                       reset-names = "stmmaceth";
+                       phy-mode = "rgmii";
+                       phy-addr = <0xffffffff>; /* probe for phy addr */

I don't a usage for 'phy-addr' in the code anymore.

Dinh

#18 lore raw

PATCH v2 9/14 arm: socfpga: Restructure the SPL file

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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} |  46 ------------
 3 files changed, 109 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/spl_a10.c
 rename arch/arm/mach-socfpga/{spl.c => spl_gen5.c} (83%)
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 +0 -46

70 lines not on this page · raw message

Signature · 1 line
2.2.2
maintainer
#19 lore raw

PATCH v2 9/14 arm: socfpga: Restructure the SPL file

Quoted 6 lines · chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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

Quoted 9 lines
---
 arch/arm/mach-socfpga/Makefile              |   5 +-
 arch/arm/mach-socfpga/spl_a10.c             | 105 ++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/{spl.c => spl_gen5.c} |  46 ------------
 3 files changed, 109 insertions(+), 47 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/spl_a10.c
 rename arch/arm/mach-socfpga/{spl.c => spl_gen5.c} (83%)

Dinh

#20 lore raw

PATCH v2 10/14 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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                   | 138 ++++++++++++++++++++++
 3 files changed, 226 insertions(+)
 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 +138 -0

138 lines not on this page · raw message

Signature · 1 line
2.2.2
maintainer
#21 lore raw

PATCH v2 10/14 arm: socfpga: stratix10: Add SPL driver for Stratix10 SoC

Quoted 152 lines · chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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                   | 138 ++++++++++++++++++++++
 3 files changed, 226 insertions(+)
 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
new file mode 100644
index 0000000..6894bb9
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#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)
+
+#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))
+
+#endif /* _FIREWALL_S10_ */
arch/arm/mach-socfpga/spl_s10.c new file +21 -0
new file mode 100644
index 0000000..12cafe6
@@ -0,0 +1,138 @@
+/*
+ *  Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#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>
+
+DECLARE_GLOBAL_DATA_PTR;
+

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

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+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;
+
+u32 spl_boot_device(void)
+{
+	/* TODO: Get from SDM or handoff */
+/* #ifdef CONFIG_CADENCE_QSPI*/
+#if 0

Remove the '#if 0'.

Quoted 58 lines
arch/arm/mach-socfpga/spl_s10.c new file +58 -0
+	return BOOT_DEVICE_SPI;
+#else
+	return BOOT_DEVICE_MMC1;
+#endif
+}
+
+#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();
+
+	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)
+	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();
+
+	/* enable all EMACs */
+	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);
+	/* 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 SDMMC */
+	socfpga_per_reset(SOCFPGA_RESET(SDMMC_OCP), 0);
+	socfpga_per_reset(SOCFPGA_RESET(SDMMC), 0);

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

Quoted 10 lines
arch/arm/mach-socfpga/spl_s10.c new file +10 -0
+	/* Enables nonsecure access to SDMMC */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->sdmmc);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_sys_base->sdmmc_ecc);
+
+	/* enable i2c0 and i2c1 */
+	socfpga_per_reset(SOCFPGA_RESET(I2C0), 0);
+	socfpga_per_reset(SOCFPGA_RESET(I2C1), 0);
+	/* enables nonsecure access to i2c0 and i2c1 */
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c0);
+	writel(FIREWALL_L4_DISABLE_ALL, &firwall_l4_per_base->i2c1);

I'd enable non-secure access to all of the HPS peripherals, USB, SPIM, GPIO, and timers.

Dinh

#22 lore raw

PATCH v2 11/14 arm: socfpga: stratix10: Add timer support for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add timer support for Stratix SoC

---
 arch/arm/mach-socfpga/timer.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/timer.c +16 -1
index 253cde3..23450b0 100644
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ * Copyright (C) 2016-2017 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
2.2.2
#24 lore raw

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

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add DDR support for Stratix SoC

---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h | 333 +++++++++++++++++++++
 drivers/ddr/altera/Makefile                    |   1 +
 drivers/ddr/altera/sdram_s10.c                 | 382 +++++++++++++++++++++++++
 3 files changed, 716 insertions(+)
 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 +333 -0
new file mode 100644
index 0000000..d0fd958
@@ -0,0 +1,333 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#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 {
+	uint32_t ip_rev_id;
+	uint32_t _pad_0x4_0x7;
+	uint32_t ddrioctrl;
+	uint32_t ddrcalstat;
+	uint32_t mpr_0beat1;
+	uint32_t mpr_1beat1;
+	uint32_t mpr_2beat1;
+	uint32_t mpr_3beat1;
+	uint32_t mpr_4beat1;
+	uint32_t mpr_5beat1;
+	uint32_t mpr_6beat1;
+	uint32_t mpr_7beat1;
+	uint32_t mpr_8beat1;
+	uint32_t mpr_0beat2;
+	uint32_t mpr_1beat2;
+	uint32_t mpr_2beat2;
+	uint32_t mpr_3beat2;
+	uint32_t mpr_4beat2;
+	uint32_t mpr_5beat2;
+	uint32_t mpr_6beat2;
+	uint32_t mpr_7beat2;
+	uint32_t mpr_8beat2;
+	uint32_t _pad_0x58_0x5f[2];
+	uint32_t auto_precharge;
+	uint32_t _pad_0x64_0xdf[31];
+	uint32_t dramaddrwidth;
+	uint32_t _pad_0xe4_0xff[7];
+	uint32_t eccctrl;
+	uint32_t eccctrl2;
+	uint32_t _pad_0x108_0x10f[2];
+	uint32_t errinten;
+	uint32_t errintens;
+	uint32_t errintenr;
+	uint32_t intmode;
+	uint32_t intstat;
+	uint32_t diaginttest;
+	uint32_t modstat;
+	uint32_t derraddra;
+	uint32_t serraddra;
+	uint32_t _pad_0x134_0x137;
+	uint32_t autowb_corraddr;
+	uint32_t serrcntreg;
+	uint32_t autowb_drop_cntreg;
+	uint32_t ecc_reg2wreccdatabus;
+	uint32_t ecc_rdeccdata2regbus;
+	uint32_t ecc_reg2rdeccdatabus;
+	uint32_t ecc_diagon;
+	uint32_t ecc_decstat;
+	uint32_t _pad_0x158_0x15f[2];
+	uint32_t ecc_errgenaddr_0;
+	uint32_t ecc_errgenaddr_1;
+	uint32_t ecc_errgenaddr_2;
+	uint32_t ecc_errgenaddr_3;
+	uint32_t ecc_ref2rddatabus_beat0;
+	uint32_t ecc_ref2rddatabus_beat1;
+	uint32_t ecc_ref2rddatabus_beat2;
+	uint32_t ecc_ref2rddatabus_beat3;
+	uint32_t ecc_errgenhaddr_0;
+	uint32_t ecc_errgenhaddr_1;
+	uint32_t ecc_errgenhaddr_2;
+	uint32_t ecc_errgenhaddr_3;
+	uint32_t ecc_rdeccdata2regbus_beat0;
+	uint32_t ecc_rdeccdata2regbus_beat1;
+	uint32_t ecc_rdeccdata2regbus_beat2;
+	uint32_t ecc_rdeccdata2regbus_beat3;
+	uint32_t _pad_0x1a0_0x1af[4];
+	uint32_t derrhaddr;
+	uint32_t serrhaddr;
+	uint32_t _pad_0x1b8_0x1bb;
+	uint32_t autowb_corrhaddr;
+	uint32_t _pad_0x1c0_0x20f[20];
+	uint32_t hpsintfcsel;
+	uint32_t rsthandshakectrl;
+	uint32_t rsthandshakestat;
+};
+
+struct socfpga_noc_ddr_scheduler {
+	uint32_t main_scheduler_id_coreid;
+	uint32_t main_scheduler_id_revisionid;
+	uint32_t main_scheduler_ddrconf;
+	uint32_t main_scheduler_ddrtiming;
+	uint32_t main_scheduler_ddrmode;
+	uint32_t main_scheduler_readlatency;
+	uint32_t _pad_0x18_0x37[8];
+	uint32_t main_scheduler_activate;
+	uint32_t main_scheduler_devtodev;
+	uint32_t main_scheduler_ddr4timing;
+};
+
+struct socfpga_io48_mmr {
+	uint32_t dbgcfg0;
+	uint32_t dbgcfg1;
+	uint32_t dbgcfg2;
+	uint32_t dbgcfg3;
+	uint32_t dbgcfg4;
+	uint32_t dbgcfg5;
+	uint32_t dbgcfg6;
+	uint32_t reserve0;
+	uint32_t reserve1;
+	uint32_t reserve2;
+	uint32_t ctrlcfg0;
+	uint32_t ctrlcfg1;
+	uint32_t ctrlcfg2;
+	uint32_t ctrlcfg3;
+	uint32_t ctrlcfg4;
+	uint32_t ctrlcfg5;
+	uint32_t ctrlcfg6;
+	uint32_t ctrlcfg7;
+	uint32_t ctrlcfg8;
+	uint32_t ctrlcfg9;
+	uint32_t dramtiming0;
+	uint32_t dramodt0;
+	uint32_t dramodt1;
+	uint32_t sbcfg0;
+	uint32_t sbcfg1;
+	uint32_t sbcfg2;
+	uint32_t sbcfg3;
+	uint32_t sbcfg4;
+	uint32_t sbcfg5;
+	uint32_t sbcfg6;
+	uint32_t sbcfg7;
+	uint32_t caltiming0;
+	uint32_t caltiming1;
+	uint32_t caltiming2;
+	uint32_t caltiming3;
+	uint32_t caltiming4;
+	uint32_t caltiming5;
+	uint32_t caltiming6;
+	uint32_t caltiming7;
+	uint32_t caltiming8;
+	uint32_t caltiming9;
+	uint32_t caltiming10;
+	uint32_t dramaddrw;
+	uint32_t sideband0;
+	uint32_t sideband1;
+	uint32_t sideband2;
+	uint32_t sideband3;
+	uint32_t sideband4;
+	uint32_t sideband5;
+	uint32_t sideband6;
+	uint32_t sideband7;
+	uint32_t sideband8;
+	uint32_t sideband9;
+	uint32_t sideband10;
+	uint32_t sideband11;
+	uint32_t sideband12;
+	uint32_t sideband13;
+	uint32_t sideband14;
+	uint32_t sideband15;
+	uint32_t dramsts;
+	uint32_t dbgdone;
+	uint32_t dbgsignals;
+	uint32_t dbgreset;
+	uint32_t dbgmatch;
+	uint32_t counter0mask;
+	uint32_t counter1mask;
+	uint32_t counter0match;
+	uint32_t counter1match;
+	uint32_t niosreserve0;
+	uint32_t niosreserve1;
+	uint32_t 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_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 +382 -0

382 lines not on this page · raw message

Signature · 1 line
2.2.2
#25 lore raw

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

Quoted 16 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add DDR support for Stratix SoC

---
 arch/arm/mach-socfpga/include/mach/sdram_s10.h | 333 +++++++++++++++++++++
 drivers/ddr/altera/Makefile                    |   1 +
 drivers/ddr/altera/sdram_s10.c                 | 382 +++++++++++++++++++++++++
 3 files changed, 716 insertions(+)
 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 +0 -0
new file mode 100644
index 0000000..d0fd958

[...]

Quoted 63 lines
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 +47 -0
new file mode 100644
index 0000000..c488caf
@@ -0,0 +1,382 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <div64.h>
+#include <asm/io.h>
+#include <watchdog.h>
+#include <asm/arch/sdram_s10.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/reset_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_ecc_hmc *socfpga_ecc_hmc_base =
+               (void *)SOCFPGA_SDR_ADDRESS;
+static const struct socfpga_noc_ddr_scheduler *socfpga_noc_ddr_scheduler_base =
+               (void *)SOCFPGA_SDR_SCHEDULER_ADDRESS;
+static const struct socfpga_io48_mmr *socfpga_io48_mmr_base =
+               (void *)SOCFPGA_HMC_MMR_IO48_ADDRESS;
+static const struct socfpga_system_manager *sysmgr_regs =
+               (void *)SOCFPGA_SYSMGR_ADDRESS;
+
+#define DDR_CONFIG(A, B, C, R) ((A<<24)|(B<<16)|(C<<8)|R)
+
+/* 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),

drivers/ddr/altera/sdram_s10.c line 57

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+       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))
+
+int match_ddr_conf(u32 ddr_conf)

Should be static.

Quoted 17 lines
drivers/ddr/altera/sdram_s10.c new file +17 -0
+{
+       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;
+

drivers/ddr/altera/sdram_s10.c line 84

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+       for (i = 1000; (i > 0) && s2c; i--) {
+               WATCHDOG_RESET();
+               mdelay(1);
+               s2c = readl(&socfpga_ecc_hmc_base->rsthandshakestat) &
+                     DDR_HMC_RSTHANDSHAKE_MASK;
+       }
+       return !s2c;
+}
+
+static int emif_reset(void)

What's the return used for? I don't see the callers of emif_reset checking the return values at all.

Quoted 55 lines
drivers/ddr/altera/sdram_s10.c new file +55 -0
+{
+       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--) {
+               /* 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);
+       }
+
+       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: emif_reset triggered successly\n");
+       return 0;
+}
+
+static int poll_hmc_clock_status(void)
+{
+       u32 status, i;
+
+       for (i = 1000; i > 0; i--) {
+               status = readl(&sysmgr_regs->hmc_clk) &
+                        SYSMGR_HMC_CLK_STATUS_MSK;
+               udelay(1);
+               if (status)

drivers/ddr/altera/sdram_s10.c line 149

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+                       break;
+               WATCHDOG_RESET();
+       }
+       return status;
+}
+
+/**
+ * sdram_mmr_init_full() - Function to initialize SDRAM MMR
+ *
+ * Initialize the SDRAM MMR.

Remove extra comment that says the same thing.

Quoted 24 lines
drivers/ddr/altera/sdram_s10.c new file +24 -0
+ */
+int sdram_mmr_init_full(unsigned int unused)
+{
+       u32 update_value, io48_value, ddrioctl;
+       u32 i, j, cal_success;
+
+       /* Enable access to DDR from CPU master */
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_DDRREG_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE0_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE1A_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE1B_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE1C_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE1D_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_CPU0_MPRT_ADBASE_MEMSPACE1E_ADDR, CCU_ADBASE_DI_MASK);
+
+       /* Enable access to DDR from IO master */
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE0_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE1A_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE1B_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE1C_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE1D_ADDR, CCU_ADBASE_DI_MASK);
+       clrbits_le32(CCU_IOM_MPRT_ADBASE_MEMSPACE1E_ADDR, CCU_ADBASE_DI_MASK);
+
+       /* this enables nonsecure access to DDR */

drivers/ddr/altera/sdram_s10.c line 183

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+       /* mpuregion0addr_limit */
+       writel(0xFFFF0000, 0xF8020118);
+       writel(0x1F, 0xF802011c);
+
+       /* nonmpuregion0addr_limit */
+       writel(0xFFFF0000, 0xF8020198);
+       writel(0x1F, 0xF802019C);
+
+       /* Enable mpuregion0enable and nonmpuregion0enable */
+       writel(BIT(0) | BIT(8), 0xF8020100);

Add defines for the above addresses please.

drivers/ddr/altera/sdram_s10.c line 188

Quoted 5 lines
drivers/ddr/altera/sdram_s10.c new file +5 -0
+
+       /* Ensure HMC clock is running */
+       if (!poll_hmc_clock_status()) {
+               puts("DDR: Error as HMC clock not running\n");
+               return -1;

Use a valid error code...

Quoted 16 lines
drivers/ddr/altera/sdram_s10.c new file +16 -0
+       }
+
+       /* release DDR scheduler from reset */
+       socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
+
+       /* Try 3 times to do a calibration */
+       for (i = 0; i < 3; i++) {
+               cal_success = readl(&socfpga_ecc_hmc_base->ddrcalstat) &
+                             DDR_HMC_DDRCALSTAT_CAL_MSK;
+               /* A delay to wait for calibration bit to set */
+               for (j = 0; (j < 1000) && !cal_success; j++) {
+                       WATCHDOG_RESET();
+                       mdelay(1);
+                       cal_success = readl(&socfpga_ecc_hmc_base->ddrcalstat)
+                                     & DDR_HMC_DDRCALSTAT_CAL_MSK;
+               }

drivers/ddr/altera/sdram_s10.c line 214

Quoted 10 lines
drivers/ddr/altera/sdram_s10.c new file +10 -0
+
+               if (cal_success)
+                       break;
+               else
+                       emif_reset();
+       }
+
+       if (!cal_success) {
+               puts("DDR: Error as SDRAM calibration failed\n");
+               return -1;

Use a valid error code..

Dinh

#26 lore raw

PATCH v2 13/14 board: altera: stratix10: Add socdk board support for Stratix10 SoC

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

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(+)
 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..3deb989
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
Signature · 1 line
2.2.2
#27 lore raw

PATCH v2 13/14 board: altera: stratix10: Add socdk board support for Stratix10 SoC

Quoted 20 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

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(+)
 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 +0 -0
new file mode 100644
index 0000000..6192bc9

board/altera/stratix10-socdk/MAINTAINERS line 3

Quoted 3 lines
board/altera/stratix10-socdk/MAINTAINERS new file +3 -0
@@ -0,0 +1,7 @@
+SOCFPGA BOARD
+M:     Chin-Liang See <[email protected]>
+M:     Dinh Nguyen <[email protected]>

Use dinguyen at kernel.org please.

Dinh

#28 lore raw

PATCH v2 14/14 arm: socfpga: stratix10: Enable Stratix10 SoC build

In reply to chin.liang.see at intel.com

From: Chin Liang See <[email protected]>

Add build support for Stratix SoC

---
 arch/arm/Kconfig                          |   8 +-
 arch/arm/mach-socfpga/Kconfig             |  13 ++
 configs/socfpga_stratix10_defconfig       |  39 ++++++
 include/configs/socfpga_stratix10_socdk.h | 216 ++++++++++++++++++++++++++++++
 4 files changed, 273 insertions(+), 3 deletions(-)
 create mode 100644 configs/socfpga_stratix10_defconfig
 create mode 100644 include/configs/socfpga_stratix10_socdk.h
arch/arm/Kconfig +5 -3
index d6d9558..4a6b9da 100644
@@ -656,21 +656,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 DM_SPI_FLASH
 	select DM_SPI
-	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_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
-	select SYS_THUMB_BUILD
+	select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	imply CMD_MTDPARTS
 	imply CRC32_VERIFY
 	imply FAT_WRITE
+	select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
 
 config ARCH_SUNXI
 	bool "Support sunxi (Allwinner) SoCs"
arch/arm/mach-socfpga/Kconfig +13 -0
index 45e5379..03ab956 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
@@ -86,6 +92,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
@@ -116,12 +126,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 "ebv" if TARGET_SOCFPGA_EBV_SOCRATES
 	default "samtec" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
@@ -145,6 +157,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 +39 -0
new file mode 100644
index 0000000..e5a7a69
@@ -0,0 +1,39 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_FAT_SUPPORT=y
+CONFIG_TARGET_SOCFPGA_STRATIX10_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_stratix10"
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_stratix10_socdk"
+CONFIG_BOOTDELAY=5
+CONFIG_SYS_PROMPT="SOCFPGA_STRATIX10 # "
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_SF=y
+CONFIG_SPL=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DM_MMC=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_DFU_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_CADENCE_QSPI=y
+CONFIG_DM_ETH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
include/configs/socfpga_stratix10_socdk.h new file +216 -0

216 lines not on this page · raw message

Signature · 1 line
2.2.2
#29 lore raw

PATCH v2 14/14 arm: socfpga: stratix10: Enable Stratix10 SoC build

Quoted 158 lines · On Thu, Oct 5, 2017 at 8:07 AM, <[email protected]> wrote:

From: Chin Liang See <[email protected]>

Add build support for Stratix SoC

---
 arch/arm/Kconfig                          |   8 +-
 arch/arm/mach-socfpga/Kconfig             |  13 ++
 configs/socfpga_stratix10_defconfig       |  39 ++++++
 include/configs/socfpga_stratix10_socdk.h | 216 ++++++++++++++++++++++++++++++
 4 files changed, 273 insertions(+), 3 deletions(-)
 create mode 100644 configs/socfpga_stratix10_defconfig
 create mode 100644 include/configs/socfpga_stratix10_socdk.h
arch/arm/Kconfig +5 -3
index d6d9558..4a6b9da 100644
@@ -656,21 +656,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 DM_SPI_FLASH
        select DM_SPI
-       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_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
-       select SYS_THUMB_BUILD
+       select SYS_THUMB_BUILD if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
        imply CMD_MTDPARTS
        imply CRC32_VERIFY
        imply FAT_WRITE
+       select SPL_SEPARATE_BSS if TARGET_SOCFPGA_STRATIX10
 
 config ARCH_SUNXI
        bool "Support sunxi (Allwinner) SoCs"
arch/arm/mach-socfpga/Kconfig +13 -0
index 45e5379..03ab956 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
@@ -86,6 +92,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
@@ -116,12 +126,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 "ebv" if TARGET_SOCFPGA_EBV_SOCRATES
        default "samtec" if TARGET_SOCFPGA_SAMTEC_VINING_FPGA
@@ -145,6 +157,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 +39 -0
new file mode 100644
index 0000000..e5a7a69
@@ -0,0 +1,39 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_SPL_FAT_SUPPORT=y
+CONFIG_TARGET_SOCFPGA_STRATIX10_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_stratix10"
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_stratix10_socdk"
+CONFIG_BOOTDELAY=5
+CONFIG_SYS_PROMPT="SOCFPGA_STRATIX10 # "
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_FAT=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_FS_GENERIC=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_SF=y
+CONFIG_SPL=y
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DM_MMC=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_DFU_MMC=y
+CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_BAR=y
+CONFIG_SPI_FLASH_SPANSION=y
+CONFIG_SPI_FLASH_STMICRO=y
+# CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_CADENCE_QSPI=y
+CONFIG_DM_ETH=y
+CONFIG_NET_RANDOM_ETHADDR=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
include/configs/socfpga_stratix10_socdk.h new file +11 -0
new file mode 100644
index 0000000..0d955f8
@@ -0,0 +1,216 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef __CONFIG_SOCFGPA_STRATIX10_H__
+#define __CONFIG_SOCFGPA_STRATIX10_H__
+
+#include <asm/arch/base_addr_s10.h>
+

include/configs/socfpga_stratix10_socdk.h line 21

Quoted 10 lines
include/configs/socfpga_stratix10_socdk.h new file +10 -0
+/*
+ * U-Boot general configurations
+ */
+#define CONFIG_SYS_TEXT_BASE           0x1000
+#define CONFIG_SYS_MONITOR_BASE                CONFIG_SYS_TEXT_BASE
+#define CONFIG_LOADADDR                        0x80000
+#define CONFIG_SYS_LOAD_ADDR           CONFIG_LOADADDR
+#define CONFIG_REMAKE_ELF
+#define CPU_RELEASE_ADDR               0x80
+#define CONFIG_SYS_CACHELINE_SIZE      64

Can you trim this file and use socfpga_common.h for alot these defines?

Dinh