Skip to contentSkip to conversation

Add Intel Arria 10 SoC support

PATCH Superseded Ley Foon Tan 5 participants 60 messages Mar 9, 2017 – Mar 23, 2017

Subsystems (7)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add Intel Arria 10 SoC support

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

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

v1 -> v2 changes:
-----------------
- Changed to use wait_for_bit() for status polling
- Sorted #ifdef in GEN5 then ARRIA10 order.
- Removed the keyword "register" and "volatile"
- Changed to use errno.h error code
- Dropped "drivers: Makefile: include fpga build in SPL" patch
- A10 reset driver
- Combined reset_assert_uart() & reset_deassert_uart()
- Moved reset_uart to later patch
- A10 clock driver
- Moved clock driver GEN5 update to new patch
- Changed global clock variables to static
- Moved cm_print_clock_quick_summary() to Gen5 and Arria 10
- Resolved warnings and errors from checkpatch.pl.

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

Ley Foon Tan (20):
arm: socfpga: Restructure clock manager driver
arm: socfpga: Update clock for Gen5
arm: socfpga: Restructure reset manager driver
arm: socfpga: Restructure misc driver
arm: socfpga: Restructure system manager
arm: socfpga: Add A10 defines
arm: socfpga: Add reset driver support for Arria 10
arm: socfpga: Add clock driver for Arria 10
arm: socfpga: Add system manager for Arria 10
arm: socfpga: Add sdram header file for Arria 10
arm: socfpga: Add misc support for Arria 10
arm: socfpga: Add pinmux for Arria 10
fdt: Add compatible strings for Arria 10
arm: dts: Add dts and dtsi for Arria 10
arm: socfpga: Add SPL support for Arria 10
drivers: fpga: Add compile switch for Gen5 only registers
arm: socfpga: Convert Altera ddr driver to use Kconfig
arm: socfpga: Add config and defconfig for Arria 10
arm: socfpga: Add board files for the Arria10
arm: socfpga: Enable build for Arria 10

 arch/arm/dts/Makefile                              |    1 +
 arch/arm/dts/socfpga_arria10.dtsi                  |  859 +++++++++++++++
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts       |   30 +
 .../dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi   |  479 +++++++++
 arch/arm/mach-socfpga/Kconfig                      |   10 +
 arch/arm/mach-socfpga/Makefile                     |   41 +-
 arch/arm/mach-socfpga/clock_manager.c              |  526 +---------
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1104 ++++++++++++++++++++
 arch/arm/mach-socfpga/clock_manager_gen5.c         |  536 ++++++++++
 arch/arm/mach-socfpga/include/mach/base_addr_a10.h |    8 +-
 arch/arm/mach-socfpga/include/mach/clock_manager.h |  314 +-----
 .../include/mach/clock_manager_arria10.h           |  222 ++++
 .../mach-socfpga/include/mach/clock_manager_gen5.h |  322 ++++++
 arch/arm/mach-socfpga/include/mach/misc.h          |   32 +
 arch/arm/mach-socfpga/include/mach/pinmux.h        |   15 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   44 +-
 .../include/mach/reset_manager_arria10.h           |  144 +++
 .../mach-socfpga/include/mach/reset_manager_gen5.h |   47 +
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h |  380 +++++++
 .../arm/mach-socfpga/include/mach/system_manager.h |  177 ++--
 .../include/mach/system_manager_arria10.h          |   81 ++
 .../include/mach/system_manager_gen5.h             |  122 +++
 arch/arm/mach-socfpga/misc.c                       |  361 +------
 arch/arm/mach-socfpga/misc_arria10.c               |  254 +++++
 arch/arm/mach-socfpga/misc_gen5.c                  |  356 +++++++
 arch/arm/mach-socfpga/pinmux_arria10.c             |   96 ++
 arch/arm/mach-socfpga/reset_manager.c              |   93 +-
 arch/arm/mach-socfpga/reset_manager_arria10.c      |  380 +++++++
 arch/arm/mach-socfpga/reset_manager_gen5.c         |  113 ++
 arch/arm/mach-socfpga/spl.c                        |   55 +-
 arch/arm/mach-socfpga/system_manager.c             |   85 --
 arch/arm/mach-socfpga/system_manager_gen5.c        |   85 ++
 board/altera/arria10-socdk/Kconfig                 |   18 +
 board/altera/arria10-socdk/Makefile                |    7 +
 board/altera/arria10-socdk/socfpga.c               |    7 +
 configs/socfpga_arria10_defconfig                  |   30 +
 drivers/Kconfig                                    |    2 +
 drivers/ddr/Kconfig                                |    1 +
 drivers/ddr/altera/Kconfig                         |    6 +
 drivers/fpga/socfpga.c                             |    6 +
 include/configs/socfpga_arria10_socdk.h            |   67 ++
 include/configs/socfpga_common.h                   |   33 +-
 include/dt-bindings/reset/altr,rst-mgr-a10.h       |  103 ++
 include/fdtdec.h                                   |    8 +
 lib/fdtdec.c                                       |    8 +
 45 files changed, 6163 insertions(+), 1505 deletions(-)
 create mode 100644 arch/arm/dts/socfpga_arria10.dtsi
 create mode 100644 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
 create mode 100644 arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi
 create mode 100644 arch/arm/mach-socfpga/clock_manager_arria10.c
 create mode 100644 arch/arm/mach-socfpga/clock_manager_gen5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/pinmux.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_arria10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_gen5.h
 create mode 100644 arch/arm/mach-socfpga/misc_arria10.c
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
 create mode 100644 arch/arm/mach-socfpga/pinmux_arria10.c
 create mode 100644 arch/arm/mach-socfpga/reset_manager_arria10.c
 create mode 100644 arch/arm/mach-socfpga/reset_manager_gen5.c
 delete mode 100644 arch/arm/mach-socfpga/system_manager.c
 create mode 100644 arch/arm/mach-socfpga/system_manager_gen5.c
 create mode 100644 board/altera/arria10-socdk/Kconfig
 create mode 100644 board/altera/arria10-socdk/Makefile
 create mode 100644 board/altera/arria10-socdk/socfpga.c
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h
Signature · 1 line
1.8.2.3
#1 lore raw

PATCH v2 1/20 arm: socfpga: Restructure clock manager driver

Restructure clock manager driver in the preparation to support A10. Move the Gen5 specific code to _gen5 files. No functional change.

Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.

---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 510 +--------------------
 arch/arm/mach-socfpga/clock_manager_gen5.c         | 510 +++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 312 +------------
 .../mach-socfpga/include/mach/clock_manager_gen5.h | 322 +++++++++++++
 5 files changed, 846 insertions(+), 811 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_gen5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h
arch/arm/mach-socfpga/Makefile +2 -1
index 809cd47..b76de4c 100644
@@ -13,7 +13,8 @@ obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
-obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o
+obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o \
+					   clock_manager_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o	\
 			   wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/clock_manager.c +5 -505

532 lines not on this page · raw message

arch/arm/mach-socfpga/clock_manager_gen5.c new file +510 -0

510 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +7 -305

322 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h new file +322 -0

322 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#4 lore raw

PATCH v2 2/20 arm: socfpga: Update clock for Gen5

In reply to Ley Foon Tan

Rename some of variables and fixes on clock calculation.

---
 arch/arm/mach-socfpga/clock_manager_gen5.c | 126 +++++++++++++++++------------
 1 file changed, 76 insertions(+), 50 deletions(-)
arch/arm/mach-socfpga/clock_manager_gen5.c +76 -50
index bca27df..bef0adb 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
+ * Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -66,7 +66,6 @@ static void cm_write_with_phase(u32 value,
  * set source main and peripheral clocks
  * Ungate clocks
  */
-
 void cm_basic_init(const struct cm_config * const cfg)
 {
 	unsigned long end;
@@ -307,56 +306,73 @@ void cm_basic_init(const struct cm_config * const cfg)
 
 static unsigned int cm_get_main_vco_clk_hz(void)
 {
-	u32 reg, clock;
+	u32 src_hz, numer, denom, vco;
 
 	/* get the main VCO clock */
-	reg = readl(&clock_manager_base->main_pll.vco);
-	clock = cm_get_osc_clk_hz(1);
-	clock /= ((reg & CLKMGR_MAINPLLGRP_VCO_DENOM_MASK) >>
-		  CLKMGR_MAINPLLGRP_VCO_DENOM_OFFSET) + 1;
-	clock *= ((reg & CLKMGR_MAINPLLGRP_VCO_NUMER_MASK) >>
-		  CLKMGR_MAINPLLGRP_VCO_NUMER_OFFSET) + 1;
+	vco = readl(&clock_manager_base->main_pll.vco);
 
-	return clock;
+	numer = ((vco & CLKMGR_MAINPLLGRP_VCO_NUMER_MASK) >>
+		CLKMGR_MAINPLLGRP_VCO_NUMER_OFFSET);
+	denom = ((vco & CLKMGR_MAINPLLGRP_VCO_DENOM_MASK) >>
+		 CLKMGR_MAINPLLGRP_VCO_DENOM_OFFSET);
+
+	src_hz = cm_get_osc_clk_hz(1);
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);
+
+	return vco;
 }
 
 static unsigned int cm_get_per_vco_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 src_hz = 0;
+	u32 clk_src = 0;
+	u32 numer = 0;
+	u32 denom = 0;
+	u32 vco = 0;
 
 	/* identify PER PLL clock source */
-	reg = readl(&clock_manager_base->per_pll.vco);
-	reg = (reg & CLKMGR_PERPLLGRP_VCO_SSRC_MASK) >>
+	clk_src = readl(&clock_manager_base->per_pll.vco);
+	clk_src = (clk_src & CLKMGR_PERPLLGRP_VCO_SSRC_MASK) >>
 	      CLKMGR_PERPLLGRP_VCO_SSRC_OFFSET;
-	if (reg == CLKMGR_VCO_SSRC_EOSC1)
-		clock = cm_get_osc_clk_hz(1);
-	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-		clock = cm_get_osc_clk_hz(2);
-	else if (reg == CLKMGR_VCO_SSRC_F2S)
-		clock = cm_get_f2s_per_ref_clk_hz();
+	if (clk_src == CLKMGR_VCO_SSRC_EOSC1)
+		src_hz = cm_get_osc_clk_hz(1);
+	else if (clk_src == CLKMGR_VCO_SSRC_EOSC2)
+		src_hz = cm_get_osc_clk_hz(2);
+	else if (clk_src == CLKMGR_VCO_SSRC_F2S)
+		src_hz = cm_get_f2s_per_ref_clk_hz();
 
 	/* get the PER VCO clock */
-	reg = readl(&clock_manager_base->per_pll.vco);
-	clock /= ((reg & CLKMGR_PERPLLGRP_VCO_DENOM_MASK) >>
-		  CLKMGR_PERPLLGRP_VCO_DENOM_OFFSET) + 1;
-	clock *= ((reg & CLKMGR_PERPLLGRP_VCO_NUMER_MASK) >>
-		  CLKMGR_PERPLLGRP_VCO_NUMER_OFFSET) + 1;
+	vco = readl(&clock_manager_base->per_pll.vco);
 
-	return clock;
+	numer = (vco & CLKMGR_PERPLLGRP_VCO_NUMER_MASK) >>
+		CLKMGR_PERPLLGRP_VCO_NUMER_OFFSET;
+
+	denom = (vco & CLKMGR_PERPLLGRP_VCO_DENOM_MASK) >>
+		CLKMGR_PERPLLGRP_VCO_DENOM_OFFSET;
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);
+
+	return vco;
 }
 
 unsigned long cm_get_mpu_clk_hz(void)
 {
-	u32 reg, clock;
+	u32 reg, clk_hz;
 
-	clock = cm_get_main_vco_clk_hz();
+	clk_hz = cm_get_main_vco_clk_hz();
 
 	/* get the MPU clock */
 	reg = readl(&clock_manager_base->altera.mpuclk);
-	clock /= (reg + 1);
+	clk_hz /= (reg + 1);
 	reg = readl(&clock_manager_base->main_pll.mpuclk);
-	clock /= (reg + 1);
-	return clock;
+	clk_hz /= (reg + 1);
+
+	return clk_hz;
 }
 
 unsigned long cm_get_sdram_clk_hz(void)
@@ -392,7 +408,8 @@ unsigned long cm_get_sdram_clk_hz(void)
 
 unsigned int cm_get_l4_sp_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 
 	/* identify the source of L4 SP clock */
 	reg = readl(&clock_manager_base->main_pll.l4src);
@@ -426,37 +443,45 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 
 unsigned int cm_get_mmc_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clk_hz = 0;
+	u32 clk_input = 0;
 
-	/* identify the source of MMC clock */
-	reg = readl(&clock_manager_base->per_pll.src);
-	reg = (reg & CLKMGR_PERPLLGRP_SRC_SDMMC_MASK) >>
+	clk_input = readl(&clock_manager_base->per_pll.src);
+	clk_input = (clk_input & CLKMGR_PERPLLGRP_SRC_SDMMC_MASK) >>
 	      CLKMGR_PERPLLGRP_SRC_SDMMC_OFFSET;
 
-	if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) {
-		clock = cm_get_f2s_per_ref_clk_hz();
-	} else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) {
-		clock = cm_get_main_vco_clk_hz();
+	switch (clk_input) {
+	case CLKMGR_SDMMC_CLK_SRC_F2S:
+		clk_hz = cm_get_f2s_per_ref_clk_hz();
+		break;
+
+	case CLKMGR_SDMMC_CLK_SRC_MAIN:
+		clk_hz = cm_get_main_vco_clk_hz();
 
 		/* get the SDMMC clock */
-		reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
-		clock /= (reg + 1);
-	} else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) {
-		clock = cm_get_per_vco_clk_hz();
+		clk_input =
+			readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
+		clk_hz /= (clk_input + 1);
+		break;
+
+	case CLKMGR_SDMMC_CLK_SRC_PER:
+		clk_hz = cm_get_per_vco_clk_hz();
 
 		/* get the SDMMC clock */
-		reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk);
-		clock /= (reg + 1);
+		clk_input =
+			readl(&clock_manager_base->per_pll.pernandsdmmcclk);
+		clk_hz /= (clk_input + 1);
+		break;
 	}
 
-	/* further divide by 4 as we have fixed divider at wrapper */
-	clock /= 4;
-	return clock;
+	return clk_hz / 4;
 }
 
+
 unsigned int cm_get_qspi_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 
 	/* identify the source of QSPI clock */
 	reg = readl(&clock_manager_base->per_pll.src);
@@ -484,7 +509,8 @@ unsigned int cm_get_qspi_controller_clk_hz(void)
 
 unsigned int cm_get_spi_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 
 	clock = cm_get_per_vco_clk_hz();
 
Signature · 1 line
1.8.2.3
#6 lore raw

PATCH v2 3/20 arm: socfpga: Restructure reset manager driver

In reply to Ley Foon Tan

Restructure reset manager driver in the preparation to support A10. Move the Gen5 specific code to _gen5 files. Minor update in socfpga_per_reset(). No functional change.

---
 arch/arm/mach-socfpga/Makefile                     |   2 +-
 arch/arm/mach-socfpga/include/mach/reset_manager.h |  42 +-------
 .../mach-socfpga/include/mach/reset_manager_gen5.h |  47 +++++++++
 arch/arm/mach-socfpga/reset_manager.c              |  93 +----------------
 arch/arm/mach-socfpga/reset_manager_gen5.c         | 113 +++++++++++++++++++++
 5 files changed, 168 insertions(+), 129 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h
 create mode 100644 arch/arm/mach-socfpga/reset_manager_gen5.c
arch/arm/mach-socfpga/Makefile +1 -1
index b76de4c..97819ac 100644
@@ -14,7 +14,7 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o \
-					   clock_manager_gen5.o
+					   clock_manager_gen5.o reset_manager_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o	\
 			   wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/reset_manager.h +5 -37

65 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h new file +47 -0

47 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager.c +2 -91

114 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager_gen5.c new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#7 lore raw

PATCH v2 4/20 arm: socfpga: Restructure misc driver

In reply to Ley Foon Tan

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to _gen5 file. No functional change.

Change all uint32_t_to u32.

---
 arch/arm/mach-socfpga/Makefile            |   3 +-
 arch/arm/mach-socfpga/include/mach/misc.h |  26 +++
 arch/arm/mach-socfpga/misc.c              | 361 ++----------------------------
 arch/arm/mach-socfpga/misc_gen5.c         | 355 +++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 347 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/Makefile +2 -1
index 97819ac..5b09ea9 100644
@@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o \
-					   clock_manager_gen5.o reset_manager_gen5.o
+					   clock_manager_gen5.o reset_manager_gen5.o \
+					   misc_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o	\
 			   wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/misc.h new file +26 -0
new file mode 100644
index 0000000..64f9b86
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+				 const u32 phymode);
+
+struct bsel {
+	const char	*mode;
+	const char	*name;
+};
+
+extern struct bsel bsel_str[];
+
+#ifdef CONFIG_FPGA
+void socfpga_fpga_add(void);
+#else
+inline void socfpga_fpga_add(void) {}
+#endif
+
+#endif /* _MISC_H_ */
arch/arm/mach-socfpga/misc.c +15 -346

399 lines not on this page · raw message

arch/arm/mach-socfpga/misc_gen5.c new file +355 -0

355 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#12 lore raw

PATCH v2 5/20 arm: socfpga: Restructure system manager

In reply to Ley Foon Tan

Restructure system manager in the preparation to support A10. No functional change.

Change uint32_t to u32.

---
 arch/arm/mach-socfpga/Makefile                     |   4 +-
 .../arm/mach-socfpga/include/mach/system_manager.h | 125 ++-------------------
 .../include/mach/system_manager_gen5.h             | 121 ++++++++++++++++++++
 arch/arm/mach-socfpga/system_manager.c             |  85 --------------
 arch/arm/mach-socfpga/system_manager_gen5.c        |  85 ++++++++++++++
 5 files changed, 215 insertions(+), 205 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_gen5.h
 delete mode 100644 arch/arm/mach-socfpga/system_manager.c
 create mode 100644 arch/arm/mach-socfpga/system_manager_gen5.c
arch/arm/mach-socfpga/Makefile +2 -2
index 5b09ea9..e83da2e 100644
@@ -7,7 +7,7 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-y	+= misc.o timer.o reset_manager.o system_manager.o clock_manager.o \
+obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
@@ -15,7 +15,7 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o \
 					   clock_manager_gen5.o reset_manager_gen5.o \
-					   misc_gen5.o
+					   misc_gen5.o system_manager_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o	\
 			   wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/system_manager.h +7 -118

143 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_gen5.h new file +121 -0

121 lines not on this page · raw message

arch/arm/mach-socfpga/system_manager.c deleted +0 -85

85 lines not on this page · raw message

arch/arm/mach-socfpga/system_manager_gen5.c new file +85 -0

85 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#13 lore raw

PATCH v2 6/20 arm: socfpga: Add A10 defines

In reply to Ley Foon Tan

Add i2c, timer and other A10 defines.

---
 arch/arm/mach-socfpga/include/mach/base_addr_a10.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/base_addr_a10.h +7 -1
index a7056d4..448fbdc 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Altera Corporation <www.altera.com>
+ * Copyright (C) 2014-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -29,14 +29,20 @@
 #define SOCFPGA_MPUL2_ADDRESS			0xfffff000
 #define SOCFPGA_I2C0_ADDRESS			0xffc02200
 #define SOCFPGA_I2C1_ADDRESS			0xffc02300
+#define SOCFPGA_I2C2_ADDRESS			0xffc02400
+#define SOCFPGA_I2C3_ADDRESS			0xffc02500
+#define SOCFPGA_I2C4_ADDRESS			0xffc02600
 
 #define SOCFPGA_ECC_OCRAM_ADDRESS		0xff8c3000
 #define SOCFPGA_UART0_ADDRESS			0xffc02000
 #define SOCFPGA_OSC1TIMER0_ADDRESS		0xffd00000
+#define SOCFPGA_OSC1TIMER1_ADDRESS		0xffd00100
 #define SOCFPGA_CLKMGR_ADDRESS			0xffd04000
 #define SOCFPGA_RSTMGR_ADDRESS			0xffd05000
 
 #define SOCFPGA_SDR_ADDRESS			0xffcfb000
+#define SOCFPGA_NOC_L4_PRIV_FLT_OFST		0xffd11000
+#define SOCFPGA_NOC_FW_H2F_SCR_OFST		0xffd13500
 #define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xffd12400
 #define SOCFPGA_SDR_FIREWALL_OCRAM_ADDRESS	0xffd13200
 #define SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS	0xffd13300
Signature · 1 line
1.8.2.3
#16 lore raw

PATCH v2 7/20 arm: socfpga: Add reset driver support for Arria 10

In reply to Ley Foon Tan

Add reset driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |   2 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           | 143 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 362 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 612 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/reset_manager_arria10.c
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h
arch/arm/mach-socfpga/Makefile +2 -0
index e83da2e..d81f003 100644
@@ -10,6 +10,8 @@
 obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
index 9e253bf..57dc034 100644
@@ -45,6 +45,8 @@ void socfpga_per_reset_all(void);
 
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/reset_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/reset_manager_arria10.h>
 #endif
 
 #endif /* _RESET_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +143 -0

143 lines not on this page · raw message

arch/arm/mach-socfpga/reset_manager_arria10.c new file +362 -0

362 lines not on this page · raw message

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

103 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#19 lore raw

PATCH v2 8/20 arm: socfpga: Add clock driver for Arria 10

In reply to Ley Foon Tan

Add clock driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |    3 +-
 arch/arm/mach-socfpga/clock_manager.c              |   18 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1104 ++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    6 +
 .../include/mach/clock_manager_arria10.h           |  222 ++++
 5 files changed, 1350 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_arria10.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h
arch/arm/mach-socfpga/Makefile +2 -1
index d81f003..c494930 100644
@@ -10,7 +10,8 @@
 obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
-obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
+					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
arch/arm/mach-socfpga/clock_manager.c +16 -2
index c2af6f3..ad602c8 100644
@@ -5,6 +5,8 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
+#include <wait_bit.h>
 #include <asm/io.h>
 #include <asm/arch/clock_manager.h>
 
@@ -18,7 +20,12 @@ void cm_wait_for_lock(u32 mask)
 	u32 inter_val;
 	u32 retry = 0;
 	do {
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 		inter_val = readl(&clock_manager_base->inter) & mask;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+		inter_val = readl(&clock_manager_base->stat) & mask;
+#endif
+		/* Wait for stable lock */
 		if (inter_val == mask)
 			retry++;
 		else
@@ -31,8 +38,10 @@ void cm_wait_for_lock(u32 mask)
 /* function to poll in the fsm busy bit */
 void cm_wait_for_fsm(void)
 {
-	while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY)
-		;
+	wait_for_bit(__func__, (const u32 *)&clock_manager_base->stat,
+		     CLKMGR_CLKMGR_STAT_BUSY_SET_MSK,
+		     false, 20000, false);
+
 }
 
 int set_cpu_clk_info(void)
@@ -43,7 +52,12 @@ int set_cpu_clk_info(void)
 
 	gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000;
 	gd->bd->bi_dsp_freq = 0;
+
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+	gd->bd->bi_ddr_freq = 0;
+#endif
 
 	return 0;
 }
arch/arm/mach-socfpga/clock_manager_arria10.c new file +1104 -0

1,104 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +6 -0
index d0d0487..ec067ae 100644
@@ -13,7 +13,13 @@ void cm_wait_for_fsm(void);
 void cm_print_clock_quick_summary(void);
 #endif
 
+/* Common mask */
+#define CLKMGR_CLKMGR_STAT_BUSY_SET_MSK			0x00000001
+
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/clock_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/clock_manager_arria10.h>
 #endif
+
 #endif /* _CLOCK_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h new file +222 -0

222 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#22 lore raw

PATCH v2 9/20 arm: socfpga: Add system manager for Arria 10

In reply to Ley Foon Tan

Add system manager register struct and defines for Arria 10.

---
 .../arm/mach-socfpga/include/mach/system_manager.h | 52 ++++++++++++++
 .../include/mach/system_manager_arria10.h          | 81 ++++++++++++++++++++++
 .../include/mach/system_manager_gen5.h             |  1 +
 3 files changed, 134 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_arria10.h
arch/arm/mach-socfpga/include/mach/system_manager.h +52 -0
index 53ced81..54078ce 100644
@@ -31,8 +31,60 @@
 #define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
 
+/* For dedicated IO configuration */
+/* Voltage select enums */
+#define VOLTAGE_SEL_3V		0x0
+#define VOLTAGE_SEL_1P8V	0x1
+#define VOLTAGE_SEL_2P5V	0x2
+
+/* Input buffer enable */
+#define INPUT_BUF_DISABLE	0
+#define INPUT_BUF_1P8V		1
+#define INPUT_BUF_2P5V3V	2
+
+/* Weak pull up enable */
+#define WK_PU_DISABLE		0
+#define WK_PU_ENABLE		1
+
+/* Pull up slew rate control */
+#define PU_SLW_RT_SLOW		0
+#define PU_SLW_RT_FAST		1
+#define PU_SLW_RT_DEFAULT	PU_SLW_RT_SLOW
+
+/* Pull down slew rate control */
+#define PD_SLW_RT_SLOW		0
+#define PD_SLW_RT_FAST		1
+#define PD_SLW_RT_DEFAULT	PD_SLW_RT_SLOW
+
+/* Drive strength control */
+#define PU_DRV_STRG_DEFAULT	0x10
+#define PD_DRV_STRG_DEFAULT	0x10
+
+/* bit position */
+#define PD_DRV_STRG_LSB		0
+#define PD_SLW_RT_LSB		5
+#define PU_DRV_STRG_LSB		8
+#define PU_SLW_RT_LSB		13
+#define WK_PU_LSB		16
+#define INPUT_BUF_LSB		17
+#define BIAS_TRIM_LSB		19
+#define VOLTAGE_SEL_LSB		0
+
+#define ALT_SYSMGR_NOC_H2F_SET_MSK	0x00000001
+#define ALT_SYSMGR_NOC_LWH2F_SET_MSK	0x00000010
+#define ALT_SYSMGR_NOC_F2H_SET_MSK	0x00000100
+#define ALT_SYSMGR_NOC_F2SDR0_SET_MSK	0x00010000
+#define ALT_SYSMGR_NOC_F2SDR1_SET_MSK	0x00100000
+#define ALT_SYSMGR_NOC_F2SDR2_SET_MSK	0x01000000
+#define ALT_SYSMGR_NOC_TMO_EN_SET_MSK	0x00000001
+
+#define ALT_SYSMGR_ECC_INTSTAT_SERR_OCRAM_SET_MSK	0x00000002
+#define ALT_SYSMGR_ECC_INTSTAT_DERR_OCRAM_SET_MSK	0x00000002
+
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/system_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/system_manager_arria10.h>
 #endif
 
 #endif /* _SYSTEM_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h new file +81 -0

81 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_gen5.h +1 -0
index 3ad4ca1..285c1a2 100644
@@ -117,5 +117,6 @@ struct socfpga_system_manager {
 #endif
 
 #define SYSMGR_SDMMC_SMPLSEL_SHIFT	3
+#define SYSMGR_BOOTINFO_BSEL_SHIFT	0
 
 #endif /* _SYSTEM_MANAGER_GEN5_H_ */
Signature · 1 line
1.8.2.3
#24 lore raw

PATCH v2 10/20 arm: socfpga: Add sdram header file for Arria 10

In reply to Ley Foon Tan

Add sdram header file for Arria 10.

---
 arch/arm/mach-socfpga/include/mach/sdram_arria10.h | 380 +++++++++++++++++++++
 1 file changed, 380 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/sdram_arria10.h
arch/arm/mach-socfpga/include/mach/sdram_arria10.h new file +380 -0
new file mode 100644
index 0000000..1d7b7c1
@@ -0,0 +1,380 @@
+/*
+ * Copyright (C) 2015-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _SOCFPGA_SDRAM_ARRIA10_H_
+#define _SOCFPGA_SDRAM_ARRIA10_H_
+
+#ifndef __ASSEMBLY__
+
+struct socfpga_ecc_hmc {
+	u32 ip_rev_id;
+	u32 _pad_0x4_0x7;
+	u32 ddrioctrl;
+	u32 ddrcalstat;
+	u32 mpr_0beat1;
+	u32 mpr_1beat1;
+	u32 mpr_2beat1;
+	u32 mpr_3beat1;
+	u32 mpr_4beat1;
+	u32 mpr_5beat1;
+	u32 mpr_6beat1;
+	u32 mpr_7beat1;
+	u32 mpr_8beat1;
+	u32 mpr_0beat2;
+	u32 mpr_1beat2;
+	u32 mpr_2beat2;
+	u32 mpr_3beat2;
+	u32 mpr_4beat2;
+	u32 mpr_5beat2;
+	u32 mpr_6beat2;
+	u32 mpr_7beat2;
+	u32 mpr_8beat2;
+	u32 _pad_0x58_0x5f[2];
+	u32 auto_precharge;
+	u32 _pad_0x64_0xff[39];
+	u32 eccctrl;
+	u32 eccctrl2;
+	u32 _pad_0x108_0x10f[2];
+	u32 errinten;
+	u32 errintens;
+	u32 errintenr;
+	u32 intmode;
+	u32 intstat;
+	u32 diaginttest;
+	u32 modstat;
+	u32 derraddra;
+	u32 serraddra;
+	u32 _pad_0x134_0x137;
+	u32 autowb_corraddr;
+	u32 serrcntreg;
+	u32 autowb_drop_cntreg;
+	u32 _pad_0x144_0x147;
+	u32 ecc_reg2wreccdatabus;
+	u32 ecc_rdeccdata2regbus;
+	u32 ecc_reg2rdeccdatabus;
+	u32 _pad_0x154_0x15f[3];
+	u32 ecc_diagon;
+	u32 ecc_decstat;
+	u32 _pad_0x168_0x16f[2];
+	u32 ecc_errgenaddr_0;
+	u32 ecc_errgenaddr_1;
+	u32 ecc_errgenaddr_2;
+	u32 ecc_errgenaddr_3;
+};
+
+struct socfpga_noc_ddr_scheduler {
+	u32 ddr_t_main_scheduler_id_coreid;
+	u32 ddr_t_main_scheduler_id_revisionid;
+	u32 ddr_t_main_scheduler_ddrconf;
+	u32 ddr_t_main_scheduler_ddrtiming;
+	u32 ddr_t_main_scheduler_ddrmode;
+	u32 ddr_t_main_scheduler_readlatency;
+	u32 _pad_0x20_0x34[8];
+	u32 ddr_t_main_scheduler_activate;
+	u32 ddr_t_main_scheduler_devtodev;
+};
+
+/*
+ * OCRAM firewall
+ */
+struct socfpga_noc_fw_ocram {
+	u32 enable;
+	u32 enable_set;
+	u32 enable_clear;
+	u32 region0;
+	u32 region1;
+	u32 region2;
+	u32 region3;
+	u32 region4;
+	u32 region5;
+};
+
+/* for master such as MPU and FPGA */
+struct socfpga_noc_fw_ddr_mpu_fpga2sdram {
+	u32 enable;
+	u32 enable_set;
+	u32 enable_clear;
+	u32 _pad_0xc_0xf;
+	u32 mpuregion0addr;
+	u32 mpuregion1addr;
+	u32 mpuregion2addr;
+	u32 mpuregion3addr;
+	u32 fpga2sdram0region0addr;
+	u32 fpga2sdram0region1addr;
+	u32 fpga2sdram0region2addr;
+	u32 fpga2sdram0region3addr;
+	u32 fpga2sdram1region0addr;
+	u32 fpga2sdram1region1addr;
+	u32 fpga2sdram1region2addr;
+	u32 fpga2sdram1region3addr;
+	u32 fpga2sdram2region0addr;
+	u32 fpga2sdram2region1addr;
+	u32 fpga2sdram2region2addr;
+	u32 fpga2sdram2region3addr;
+};
+
+/* for L3 master */
+struct socfpga_noc_fw_ddr_l3 {
+	u32 enable;
+	u32 enable_set;
+	u32 enable_clear;
+	u32 hpsregion0addr;
+	u32 hpsregion1addr;
+	u32 hpsregion2addr;
+	u32 hpsregion3addr;
+	u32 hpsregion4addr;
+	u32 hpsregion5addr;
+	u32 hpsregion6addr;
+	u32 hpsregion7addr;
+};
+
+struct socfpga_io48_mmr {
+	u32 dbgcfg0;
+	u32 dbgcfg1;
+	u32 dbgcfg2;
+	u32 dbgcfg3;
+	u32 dbgcfg4;
+	u32 dbgcfg5;
+	u32 dbgcfg6;
+	u32 reserve0;
+	u32 reserve1;
+	u32 reserve2;
+	u32 ctrlcfg0;
+	u32 ctrlcfg1;
+	u32 ctrlcfg2;
+	u32 ctrlcfg3;
+	u32 ctrlcfg4;
+	u32 ctrlcfg5;
+	u32 ctrlcfg6;
+	u32 ctrlcfg7;
+	u32 ctrlcfg8;
+	u32 ctrlcfg9;
+	u32 dramtiming0;
+	u32 dramodt0;
+	u32 dramodt1;
+	u32 sbcfg0;
+	u32 sbcfg1;
+	u32 sbcfg2;
+	u32 sbcfg3;
+	u32 sbcfg4;
+	u32 sbcfg5;
+	u32 sbcfg6;
+	u32 sbcfg7;
+	u32 caltiming0;
+	u32 caltiming1;
+	u32 caltiming2;
+	u32 caltiming3;
+	u32 caltiming4;
+	u32 caltiming5;
+	u32 caltiming6;
+	u32 caltiming7;
+	u32 caltiming8;
+	u32 caltiming9;
+	u32 caltiming10;
+	u32 dramaddrw;
+	u32 sideband0;
+	u32 sideband1;
+	u32 sideband2;
+	u32 sideband3;
+	u32 sideband4;
+	u32 sideband5;
+	u32 sideband6;
+	u32 sideband7;
+	u32 sideband8;
+	u32 sideband9;
+	u32 sideband10;
+	u32 sideband11;
+	u32 sideband12;
+	u32 sideband13;
+	u32 sideband14;
+	u32 sideband15;
+	u32 dramsts;
+	u32 dbgdone;
+	u32 dbgsignals;
+	u32 dbgreset;
+	u32 dbgmatch;
+	u32 counter0mask;
+	u32 counter1mask;
+	u32 counter0match;
+	u32 counter1match;
+	u32 niosreserve0;
+	u32 niosreserve1;
+	u32 niosreserve2;
+};
+#endif /*__ASSEMBLY__*/
+
+#define IO48_MMR_CTRLCFG0_DB2_BURST_LENGTH_MASK		0x1F000000
+#define IO48_MMR_CTRLCFG0_DB2_BURST_LENGTH_SHIFT	24
+#define IO48_MMR_CTRLCFG0_DB1_BURST_LENGTH_MASK		0x00F80000
+#define IO48_MMR_CTRLCFG0_DB1_BURST_LENGTH_SHIFT	19
+#define IO48_MMR_CTRLCFG0_DB0_BURST_LENGTH_MASK		0x0007C000
+#define IO48_MMR_CTRLCFG0_DB0_BURST_LENGTH_SHIFT	14
+#define IO48_MMR_CTRLCFG0_CTRL_BURST_LENGTH_MASK	0x00003E00
+#define IO48_MMR_CTRLCFG0_CTRL_BURST_LENGTH_SHIFT	9
+#define IO48_MMR_CTRLCFG0_AC_POS_MASK			0x00000180
+#define IO48_MMR_CTRLCFG0_AC_POS_SHIFT			7
+#define IO48_MMR_CTRLCFG0_DIMM_TYPE_MASK		0x00000070
+#define IO48_MMR_CTRLCFG0_DIM_TYPE_SHIFT		4
+#define IO48_MMR_CTRLCFG0_MEM_TYPE_MASK			0x0000000F
+#define IO48_MMR_CTRLCFG0_MEM_TYPE_SHIFT		0
+
+#define IO48_MMR_CTRLCFG1_DBC3_ENABLE_DM		BIT(30)
+#define IO48_MMR_CTRLCFG1_DBC2_ENABLE_DM		BIT(29)
+#define IO48_MMR_CTRLCFG1_DBC1_ENABLE_DM		BIT(28)
+#define IO48_MMR_CTRLCFG1_DBC0_ENABLE_DM		BIT(27)
+#define IO48_MMR_CTRLCFG1_CTRL_ENABLE_DM		BIT(26)
+#define IO48_MMR_CTRLCFG1_DQSTRK_EN			BIT(25)
+#define IO48_MMR_CTRLCFG1_STARVE_LIMIT_MASK		0x01F80000
+#define IO48_MMR_CTRLCFG1_STARVE_LIMIT_SHIFT		19
+#define IO48_MMR_CTRLCFG1_REORDER_READ			BIT(18)
+#define IO48_MMR_CTRLCFG1_DBC3_REORDER_RDATA		BIT(17)
+#define IO48_MMR_CTRLCFG1_DBC2_REORDER_RDATA		BIT(16)
+#define IO48_MMR_CTRLCFG1_DBC1_REORDER_RDATA		BIT(15)
+#define IO48_MMR_CTRLCFG1_DBC0_REORDER_RDATA		BIT(14)
+#define IO48_MMR_CTRLCFG1_CTRL_REORDER_RDATA		BIT(13)
+#define IO48_MMR_CTRLCFG1_REORDER_DATA			BIT(12)
+#define IO48_MMR_CTRLCFG1_DBC3_ENABLE_ECC		BIT(11)
+#define IO48_MMR_CTRLCFG1_DBC2_ENABLE_ECC		BIT(10)
+#define IO48_MMR_CTRLCFG1_DBC1_ENABLE_ECC		BIT(9)
+#define IO48_MMR_CTRLCFG1_DBC0_ENABLE_ECC		BIT(8)
+#define IO48_MMR_CTRLCFG1_CTRL_ENABLE_ECC		BIT(7)
+#define IO48_MMR_CTRLCFG1_ADDR_ORDER_MASK		0x00000060
+#define IO48_MMR_CTRLCFG1_ADDR_ORDER_SHIFT		5
+#define IO48_MMR_CTRLCFG1_DBC3_BURST_LENGTH_MASK	0x0000001F
+#define IO48_MMR_CTRLCFG1_DBC3_BURST_LENGTH_SHIFT	0
+
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_DIFF_BG_MASK		0x3F000000
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_DIFF_BG_SHIFT	24
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_DIFF_BANK_MASK	0x00FC0000
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_DIFF_BANK_SHIFT	18
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_MASK			0x0003F000
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_ACT_SHIFT		12
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_PCH_MASK			0x00000FC0
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_PCH_SHIFT		6
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_RDWR_MASK		0x0000003F
+#define IO48_MMR_CALTIMING0_CFG_ACT_TO_RDWR_SHIFT		0
+
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_WR_DIFF_CHIP_MASK		0x3F000000
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_WR_DIFF_CHIP_SHIFT	24
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_WR_MASK			0x00FC0000
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_WR_SHIFT			18
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_DB_MASK		0x0003F000
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_DB_SHIFT		12
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_DC_MASK		0x00000FC0
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_DC_SHIFT		6
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_MASK			0x0000003F
+#define IO48_MMR_CALTIMING1_CFG_RD_TO_RD_SHIFT			0
+
+#define IO48_MMR_CALTIMING2_CFG_WR_TO_WR_DIFF_CHIP_MASK		0x3F000000
+#define IO48_MMR_CALTIMING2_CFG_WR_TO_WR_DIFF_CHIP_SHIFT	24
+#define IO48_MMR_CALTIMING2_CFG_WR_TO_WR_MASK			0x00FC0000
+#define IO48_MMR_CALTIMING2_CFG_WR_TO_WR_SHIFT			18
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_AP_VALID_MASK		0x0003F000
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_AP_VALID_SHIFT		12
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_PCH_MASK			0x00000FC0
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_PCH_SHIFT			6
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_WR_DIFF_BG_MASK		0x0000003F
+#define IO48_MMR_CALTIMING2_CFG_RD_TO_WR_DIFF_BG_SHIFT		0
+
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_PCH_MASK			0x3F000000
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_PCH_SHIFT			24
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_DIFF_BG_MASK		0x00FC0000
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_DIFF_BG_SHIFT		18
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_DIFF_CHIP_MASK		0x0003F000
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_DIFF_CHIP_SHIFT	12
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_MASK			0x00000FC0
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_RD_SHIFT			6
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_WR_DIFF_BG_MASK		0x0000003F
+#define IO48_MMR_CALTIMING3_CFG_WR_TO_WR_DIFF_BG_SHIFT		0
+
+#define IO48_MMR_CALTIMING4_CFG_PDN_TO_VALID_MASK		0xFC000000
+#define IO48_MMR_CALTIMING4_CFG_PDN_TO_VALID_SHIFT		26
+#define IO48_MMR_CALTIMING4_CFG_ARF_TO_VALID_MASK		0x03FC0000
+#define IO48_MMR_CALTIMING4_CFG_ARF_TO_VALID_SHIFT		18
+#define IO48_MMR_CALTIMING4_CFG_PCH_ALL_TO_VALID_MASK		0x0003F000
+#define IO48_MMR_CALTIMING4_CFG_PCH_ALL_TO_VALID_SHIFT		12
+#define IO48_MMR_CALTIMING4_CFG_PCH_TO_VALID_MASK		0x00000FC0
+#define IO48_MMR_CALTIMING4_CFG_PCH_TO_VALID_SHIFT		6
+#define IO48_MMR_CALTIMING4_CFG_WR_AP_TO_VALID_MASK		0x0000003F
+#define IO48_MMR_CALTIMING4_CFG_WR_AP_TO_VALID_SHIFT		0
+
+#define IO48_MMR_CALTIMING9_CFG_WR_4_ACT_TO_ACT_MASK		0x000000FF
+#define IO48_MMR_CALTIMING9_CFG_WR_4_ACT_TO_ACT_SHIFT		0
+
+#define IO48_MMR_DRAMADDRW_CFG_CS_ADDR_WIDTH_MASK		0x00070000
+#define IO48_MMR_DRAMADDRW_CFG_CS_ADDR_WIDTH_SHIFT		16
+#define IO48_MMR_DRAMADDRW_CFG_BANK_GROUP_ADDR_WIDTH_MASK	0x0000C000
+#define IO48_MMR_DRAMADDRW_CFG_BANK_GROUP_ADDR_WIDTH_SHIFT	14
+#define IO48_MMR_DRAMADDRW_CFG_BANK_ADDR_WIDTH_MASK		0x00003C00
+#define IO48_MMR_DRAMADDRW_CFG_BANK_ADDR_WIDTH_SHIFT		10
+#define IO48_MMR_DRAMADDRW_CFG_ROW_ADDR_WIDTH_MASK		0x000003E0
+#define IO48_MMR_DRAMADDRW_CFG_ROW_ADDR_WIDTH_SHIFT		5
+#define IO48_MMR_DRAMADDRW_CFG_COL_ADDR_WIDTH_MASK		0x0000001F
+#define IO48_MMR_DRAMADDRW_CFG_COL_ADDR_WIDTH_SHIFT		0
+
+#define ALT_ECC_HMC_OCP_DDRIOCTRL_IO_SIZE_MSK		0x00000003
+
+#define ALT_ECC_HMC_OCP_INTSTAT_SERRPENA_SET_MSK	BIT(0)
+#define ALT_ECC_HMC_OCP_INTSTAT_DERRPENA_SET_MSK	BIT(1)
+#define ALT_ECC_HMC_OCP_ERRINTEN_SERRINTEN_SET_MSK	BIT(0)
+#define ALT_ECC_HMC_OCP_ERRINTEN_DERRINTEN_SET_MSK	BIT(1)
+#define ALT_ECC_HMC_OCP_INTMOD_INTONCMP_SET_MSK		BIT(16)
+#define ALT_ECC_HMC_OCP_ECCCTL_AWB_CNT_RST_SET_MSK	BIT(16)
+#define ALT_ECC_HMC_OCP_ECCCTL_CNT_RST_SET_MSK		BIT(8)
+#define ALT_ECC_HMC_OCP_ECCCTL_ECC_EN_SET_MSK		BIT(0)
+#define ALT_ECC_HMC_OCP_ECCCTL2_RMW_EN_SET_MSK		BIT(8)
+#define ALT_ECC_HMC_OCP_ECCCTL2_AWB_EN_SET_MSK		BIT(0)
+
+#define ALT_ECC_HMC_OCP_SERRCNTREG_VALUE		8
+
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_ACTTOACT_LSB	0
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_RDTOMISS_LSB	6
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_WRTOMISS_LSB	12
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_BURSTLEN_LSB	18
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_RDTOWR_LSB	21
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_WRTORD_LSB	26
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRTIMING_BWRATIO_LSB	31
+
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRMOD_AUTOPRECHARGE_LSB	0
+#define ALT_NOC_MPU_DDR_T_SCHED_DDRMOD_BWRATIOEXTENDED_LSB	1
+
+#define ALT_NOC_MPU_DDR_T_SCHED_ACTIVATE_RRD_LSB	0
+#define ALT_NOC_MPU_DDR_T_SCHED_ACTIVATE_FAW_LSB	4
+#define ALT_NOC_MPU_DDR_T_SCHED_ACTIVATE_FAWBANK_LSB	10
+
+#define ALT_NOC_MPU_DDR_T_SCHED_DEVTODEV_BUSRDTORD_LSB	0
+#define ALT_NOC_MPU_DDR_T_SCHED_DEVTODEV_BUSRDTOWR_LSB	2
+#define ALT_NOC_MPU_DDR_T_SCHED_DEVTODEV_BUSWRTORD_LSB	4
+
+#define ALT_NOC_FW_DDR_END_ADDR_LSB	16
+#define ALT_NOC_FW_DDR_ADDR_MASK	0xFFFF
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG0EN_SET_MSK		BIT(0)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG1EN_SET_MSK		BIT(1)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG2EN_SET_MSK		BIT(2)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG3EN_SET_MSK		BIT(3)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG4EN_SET_MSK		BIT(4)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG5EN_SET_MSK		BIT(5)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG6EN_SET_MSK		BIT(6)
+#define ALT_NOC_FW_DDR_SCR_EN_HPSREG7EN_SET_MSK		BIT(7)
+#define ALT_NOC_FW_DDR_SCR_EN_MPUREG0EN_SET_MSK		BIT(0)
+#define ALT_NOC_FW_DDR_SCR_EN_MPUREG1EN_SET_MSK		BIT(1)
+#define ALT_NOC_FW_DDR_SCR_EN_MPUREG2EN_SET_MSK		BIT(2)
+#define ALT_NOC_FW_DDR_SCR_EN_MPUREG3EN_SET_MSK		BIT(3)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR0REG0EN_SET_MSK	BIT(4)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR0REG1EN_SET_MSK	BIT(5)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR0REG2EN_SET_MSK	BIT(6)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR0REG3EN_SET_MSK	BIT(7)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR1REG0EN_SET_MSK	BIT(8)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR1REG1EN_SET_MSK	BIT(9)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR1REG2EN_SET_MSK	BIT(10)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR1REG3EN_SET_MSK	BIT(11)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR2REG0EN_SET_MSK	BIT(12)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR2REG1EN_SET_MSK	BIT(13)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR2REG2EN_SET_MSK	BIT(14)
+#define ALT_NOC_FW_DDR_SCR_EN_F2SDR2REG3EN_SET_MSK	BIT(15)
+
+#define ALT_IO48_DRAMTIME_MEM_READ_LATENCY_MASK		0x0000003F
+#endif /* _SOCFPGA_SDRAM_ARRIA10_H_ */
Signature · 1 line
1.8.2.3
#25 lore raw

PATCH v2 11/20 arm: socfpga: Add misc support for Arria 10

In reply to Ley Foon Tan

Add misc support for Arria 10 and minor fix on misc Gen5.

---
 arch/arm/mach-socfpga/Makefile            |   1 +
 arch/arm/mach-socfpga/include/mach/misc.h |   6 +
 arch/arm/mach-socfpga/misc_arria10.c      | 254 ++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/misc_gen5.c         |   3 +-
 4 files changed, 263 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-socfpga/misc_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index c494930..9c4617f 100644
@@ -11,6 +11,7 @@ obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
+					misc_arria10.o		\
 					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
arch/arm/mach-socfpga/include/mach/misc.h +6 -0
index 64f9b86..446ee0f 100644
@@ -23,4 +23,10 @@ void socfpga_fpga_add(void);
 inline void socfpga_fpga_add(void) {}
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+unsigned int dedicated_uart_com_port(const void *blob);
+unsigned int shared_uart_com_port(const void *blob);
+unsigned int uart_com_port(const void *blob);
+#endif
+
 #endif /* _MISC_H_ */
arch/arm/mach-socfpga/misc_arria10.c new file +254 -0

254 lines not on this page · raw message

arch/arm/mach-socfpga/misc_gen5.c +2 -1
index f870e1f..3b8ce11 100644
@@ -200,7 +200,8 @@ static int socfpga_fpga_id(const bool print_id)
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
-	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
+	const u32 bsel = (readl(&sysmgr_regs->bootinfo) >>
+			  SYSMGR_BOOTINFO_BSEL_SHIFT) & 0x7;
 
 	puts("CPU:   Altera SoCFPGA Platform\n");
 	socfpga_fpga_id(1);
Signature · 1 line
1.8.2.3
#27 lore raw

PATCH v2 12/20 arm: socfpga: Add pinmux for Arria 10

In reply to Ley Foon Tan

Add pinmux support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile              |  1 +
 arch/arm/mach-socfpga/include/mach/pinmux.h | 15 +++++
 arch/arm/mach-socfpga/pinmux_arria10.c      | 96 +++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/pinmux.h
 create mode 100644 arch/arm/mach-socfpga/pinmux_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 9c4617f..68d55e4 100644
@@ -12,6 +12,7 @@ obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
 					misc_arria10.o		\
+					pinmux_arria10.o	\
 					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
arch/arm/mach-socfpga/include/mach/pinmux.h new file +15 -0
new file mode 100644
index 0000000..c5d5dd6
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef	_PINMUX_H_
+#define	_PINMUX_H_
+
+#ifndef __ASSEMBLY__
+int config_dedicated_pins(const void *blob);
+int config_pins(const void *blob, const char *pin_grp);
+#endif
+
+#endif /* _PINMUX_H_ */
arch/arm/mach-socfpga/pinmux_arria10.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#30 lore raw

PATCH v2 13/20 fdt: Add compatible strings for Arria 10

In reply to Ley Foon Tan

Add compatible strings for Intel Arria 10 SoCFPGA device.

---
 include/fdtdec.h | 8 ++++++++
 lib/fdtdec.c     | 8 ++++++++
 2 files changed, 16 insertions(+)
include/fdtdec.h +8 -0
index d074478..2134701 100644
@@ -155,6 +155,14 @@ enum fdt_compat_id {
 	COMPAT_INTEL_BAYTRAIL_FSP_MDP,	/* Intel FSP memory-down params */
 	COMPAT_INTEL_IVYBRIDGE_FSP,	/* Intel Ivy Bridge FSP */
 	COMPAT_SUNXI_NAND,		/* SUNXI NAND controller */
+	COMPAT_ALTERA_SOCFPGA_CLK,	/* SoCFPGA Clock initialization */
+	COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE,	/* SoCFPGA pinctrl-single */
+	COMPAT_ALTERA_SOCFPGA_H2F_BRG,          /* SoCFPGA hps2fpga bridge */
+	COMPAT_ALTERA_SOCFPGA_LWH2F_BRG,        /* SoCFPGA lwhps2fpga bridge */
+	COMPAT_ALTERA_SOCFPGA_F2H_BRG,          /* SoCFPGA fpga2hps bridge */
+	COMPAT_ALTERA_SOCFPGA_F2SDR0,           /* SoCFPGA fpga2SDRAM0 bridge */
+	COMPAT_ALTERA_SOCFPGA_F2SDR1,           /* SoCFPGA fpga2SDRAM1 bridge */
+	COMPAT_ALTERA_SOCFPGA_F2SDR2,           /* SoCFPGA fpga2SDRAM2 bridge */
 
 	COMPAT_COUNT,
 };
lib/fdtdec.c +8 -0
index 81f47ef..ebe4a9a 100644
@@ -66,6 +66,14 @@ static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(INTEL_BAYTRAIL_FSP_MDP, "intel,baytrail-fsp-mdp"),
 	COMPAT(INTEL_IVYBRIDGE_FSP, "intel,ivybridge-fsp"),
 	COMPAT(COMPAT_SUNXI_NAND, "allwinner,sun4i-a10-nand"),
+	COMPAT(ALTERA_SOCFPGA_CLK, "altr,clk-mgr"),
+	COMPAT(ALTERA_SOCFPGA_PINCTRL_SINGLE, "pinctrl-single"),
+	COMPAT(ALTERA_SOCFPGA_H2F_BRG, "altr,socfpga-hps2fpga-bridge"),
+	COMPAT(ALTERA_SOCFPGA_LWH2F_BRG, "altr,socfpga-lwhps2fpga-bridge"),
+	COMPAT(ALTERA_SOCFPGA_F2H_BRG, "altr,socfpga-fpga2hps-bridge"),
+	COMPAT(ALTERA_SOCFPGA_F2SDR0, "altr,socfpga-fpga2sdram0-bridge"),
+	COMPAT(ALTERA_SOCFPGA_F2SDR1, "altr,socfpga-fpga2sdram1-bridge"),
+	COMPAT(ALTERA_SOCFPGA_F2SDR2, "altr,socfpga-fpga2sdram2-bridge"),
 };
 
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
Signature · 1 line
1.8.2.3
#31 lore raw

PATCH v2 14/20 arm: dts: Add dts and dtsi for Arria 10

In reply to Ley Foon Tan

Device tree files for Arria 10

---
 arch/arm/dts/Makefile                              |   1 +
 arch/arm/dts/socfpga_arria10.dtsi                  | 859 +++++++++++++++++++++
 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts       |  30 +
 .../dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi   | 479 ++++++++++++
 4 files changed, 1369 insertions(+)
 create mode 100644 arch/arm/dts/socfpga_arria10.dtsi
 create mode 100644 arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts
 create mode 100644 arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi
arch/arm/dts/Makefile +1 -0
index eb68c20..25e08eb 100644
@@ -139,6 +139,7 @@ dtb-$(CONFIG_AM43XX) += am437x-gp-evm.dtb am437x-sk-evm.dtb	\
 dtb-$(CONFIG_THUNDERX) += thunderx-88xx.dtb
 
 dtb-$(CONFIG_ARCH_SOCFPGA) +=				\
+	socfpga_arria10_socdk_sdmmc.dtb			\
 	socfpga_arria5_socdk.dtb			\
 	socfpga_cyclone5_is1.dtb			\
 	socfpga_cyclone5_mcvevk.dtb			\
arch/arm/dts/socfpga_arria10.dtsi new file +859 -0

859 lines not on this page · raw message

arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts new file +30 -0
new file mode 100644
index 0000000..a4215ee
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0        X11
+ */
+
+/dts-v1/;
+#include "socfpga_arria10_socdk_sdmmc_handoff.dtsi"
+
+/ {
+	chosen {
+		bootargs = "console=ttyS0,115200";
+	};
+};
+
+&uart1 {
+	u-boot,dm-pre-reloc;
+	status = "okay";
+};
+
+&mmc {
+	u-boot,dm-pre-reloc;
+	status = "okay";
+	num-slots = <1>;
+	cap-sd-highspeed;
+	broken-cd;
+	bus-width = <4>;
+	altr,dw-mshc-ciu-div = <3>;
+	altr,dw-mshc-sdr-timing = <0 3>;
+};
arch/arm/dts/socfpga_arria10_socdk_sdmmc_handoff.dtsi new file +479 -0

479 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#32 lore raw

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

In reply to Ley Foon Tan

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
 struct socfpga_reset_manager {
 	u32	stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +18 -0
index 547a8bb..bbf54f0 100644
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
 	ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
 	ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)
 
+void reset_uart(int assert)
+{
+	u32 mask = 0;
+	unsigned int com_port;
+
+	com_port = uart_com_port(gd->fdt_blob);
+
+	if (com_port == SOCFPGA_UART1_ADDRESS)
+		mask |= ALT_RSTMGR_PER1MODRST_UART1_SET_MSK;
+	else if (com_port == SOCFPGA_UART0_ADDRESS)
+		mask |= ALT_RSTMGR_PER1MODRST_UART0_SET_MSK;
+
+	if (assert)
+		setbits_le32(&reset_manager_base->per1modrst, mask);
+	else
+		clrbits_le32(&reset_manager_base->per1modrst, mask);
+}
+
 static const u32 per0fpgamasks[] = {
 	ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
 	ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK,
arch/arm/mach-socfpga/spl.c +53 -2

85 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#38 lore raw

PATCH v2 16/20 drivers: fpga: Add compile switch for Gen5 only registers

In reply to Ley Foon Tan

These registers only available for Gen5 device, excludes them if for Arria 10 build.

---
 drivers/fpga/socfpga.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/fpga/socfpga.c +6 -0
index f1b2f2c..3751574 100644
@@ -19,8 +19,10 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct socfpga_fpga_manager *fpgamgr_regs =
 	(struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS;
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+#endif
 
 /* Set CD ratio */
 static void fpgamgr_set_cd_ratio(unsigned long ratio)
@@ -268,8 +270,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 
 	/* Prior programming the FPGA, all bridges need to be shut off */
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	/* Disable all signals from hps peripheral controller to fpga */
 	writel(0, &sysmgr_regs->fpgaintfgrp_module);
+#endif
 
 	/* Disable all signals from FPGA to HPS SDRAM */
 #define SDR_CTRLGRP_FPGAPORTRST_ADDRESS	0x5080
@@ -278,8 +282,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 	/* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
 	socfpga_bridges_reset(1);
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	/* Unmap the bridges from NIC-301 */
 	writel(0x1, SOCFPGA_L3REGS_ADDRESS);
+#endif
 
 	/* Initialize the FPGA Manager */
 	status = fpgamgr_program_init();
Signature · 1 line
1.8.2.3
#41 lore raw

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

In reply to Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +6 -0
new file mode 100644
index 0000000..9554da7
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+	bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"
+	default y if TARGET_SOCFPGA_GEN5
+	help
+	  This is for building the SDRAM controller for the Arria5/Cyclone5
+	  devices.
include/configs/socfpga_common.h +0 -5
index 55e0bf9..bc92a2c 100644
@@ -77,11 +77,6 @@
 #define CONFIG_SYS_PL310_BASE		SOCFPGA_MPUL2_ADDRESS
 
 /*
- * SDRAM controller
- */
-#define CONFIG_ALTERA_SDRAM
-
-/*
  * EPCS/EPCQx1 Serial Flash Controller
  */
 #ifdef CONFIG_ALTERA_SPI
Signature · 1 line
1.8.2.3
#48 lore raw

PATCH v2 18/20 arm: socfpga: Add config and defconfig for Arria 10

In reply to Ley Foon Tan

Add config and defconfig for the Arria10 and update socfpga_common.h.

---
 configs/socfpga_arria10_defconfig       | 30 +++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 67 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 ++++++++++++--
 3 files changed, 121 insertions(+), 4 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
configs/socfpga_arria10_defconfig new file +30 -0
new file mode 100644
index 0000000..9e6bc1e0
@@ -0,0 +1,30 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_arria10"
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
+CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_SPL=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_DOS_PARTITION=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE=0xa2
include/configs/socfpga_arria10_socdk.h new file +67 -0

67 lines not on this page · raw message

include/configs/socfpga_common.h +24 -4
index bc92a2c..a228ea5 100644
@@ -34,9 +34,13 @@
 #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
 #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
 #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
-
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SYS_INIT_RAM_ADDR	0xFFFF0000
 #define CONFIG_SYS_INIT_RAM_SIZE	0x10000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_INIT_RAM_ADDR	0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE	0x40000 /* 256KB */
+#endif
 #define CONFIG_SYS_INIT_SP_OFFSET		\
 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_INIT_SP_ADDR			\
@@ -67,8 +71,10 @@
 #define CONFIG_SYS_HOSTNAME	CONFIG_SYS_BOARD
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif
 
 /*
  * Cache
@@ -103,13 +109,14 @@
 /*
  * FPGA Driver
  */
+#ifdef CONFIG_TARGET_SOCFPGA_GEN5
 #ifdef CONFIG_CMD_FPGA
 #define CONFIG_FPGA
 #define CONFIG_FPGA_ALTERA
 #define CONFIG_FPGA_SOCFPGA
 #define CONFIG_FPGA_COUNT		1
 #endif
-
+#endif
 /*
  * L4 OSC1 Timer 0
  */
@@ -209,11 +216,14 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	-4
-#define CONFIG_SYS_NS16550_COM1		SOCFPGA_UART0_ADDRESS
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_NS16550_CLK		1000000
-#else
+#elif defined(CONFIG_TARGET_SOCFPGA_GEN5)
+#define CONFIG_SYS_NS16550_COM1		SOCFPGA_UART0_ADDRESS
 #define CONFIG_SYS_NS16550_CLK		100000000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_NS16550_COM1        SOCFPGA_UART1_ADDRESS
+#define CONFIG_SYS_NS16550_CLK		50000000
 #endif
 #define CONFIG_CONS_INDEX		1
 #define CONFIG_BAUDRATE			115200
@@ -301,7 +311,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_MAX_SIZE		CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_BOARD_INIT
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -349,10 +364,15 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define BOOT_TARGET_DEVICES(func) \
 	BOOT_TARGET_DEVICES_MMC(func) \
 	BOOT_TARGET_DEVICES_PXE(func) \
 	func(DHCP, dhcp, na)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define BOOT_TARGET_DEVICES(func) \
+	BOOT_TARGET_DEVICES_MMC(func)
+#endif
 
 #include <config_distro_bootcmd.h>
 
Signature · 1 line
1.8.2.3
#51 lore raw

PATCH v2 19/20 arm: socfpga: Add board files for the Arria10

In reply to Ley Foon Tan

Add support for the Arria10 SoCDK.

---
 board/altera/arria10-socdk/Kconfig   | 18 ++++++++++++++++++
 board/altera/arria10-socdk/Makefile  |  7 +++++++
 board/altera/arria10-socdk/socfpga.c |  7 +++++++
 3 files changed, 32 insertions(+)
 create mode 100644 board/altera/arria10-socdk/Kconfig
 create mode 100644 board/altera/arria10-socdk/Makefile
 create mode 100644 board/altera/arria10-socdk/socfpga.c
board/altera/arria10-socdk/Kconfig new file +18 -0
new file mode 100644
index 0000000..b80cc6d
@@ -0,0 +1,18 @@
+if TARGET_SOCFPGA_ARRIA10
+
+config SYS_CPU
+	default "armv7"
+
+config SYS_BOARD
+	default "socfpga_arria10"
+
+config SYS_VENDOR
+	default "altera"
+
+config SYS_SOC
+	default "socfpga_arria10"
+
+config SYS_CONFIG_NAME
+	default "socfpga_arria10"
+
+endif
board/altera/arria10-socdk/Makefile new file +7 -0
new file mode 100644
index 0000000..1d885ce
@@ -0,0 +1,7 @@
+#
+# Copyright (C) 2015 Altera Corporation <www.altera.com>
+#
+# SPDX-License-Identifier:	GPL-2.0
+#
+
+obj-y	:= socfpga.o
board/altera/arria10-socdk/socfpga.c new file +7 -0
new file mode 100644
index 0000000..8516633
@@ -0,0 +1,7 @@
+/*
+ * Copyright (C) 2015 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <common.h>
Signature · 1 line
1.8.2.3
#52 lore raw

PATCH v2 20/20 arm: socfpga: Enable build for Arria 10

In reply to Ley Foon Tan

Update Kconfig and Makefile to enable Arria 10. Clean up Makefile and sorting *.o alphanumerically.

---
 arch/arm/mach-socfpga/Kconfig  | 10 +++++++++
 arch/arm/mach-socfpga/Makefile | 46 ++++++++++++++++++++++++++++++------------
 2 files changed, 43 insertions(+), 13 deletions(-)
arch/arm/mach-socfpga/Kconfig +10 -0
index e56b3db..ee98a44 100644
@@ -37,6 +37,9 @@ config TARGET_SOCFPGA_ARRIA5
 	bool
 	select TARGET_SOCFPGA_GEN5
 
+config TARGET_SOCFPGA_ARRIA10
+	bool
+
 config TARGET_SOCFPGA_CYCLONE5
 	bool
 	select TARGET_SOCFPGA_GEN5
@@ -48,6 +51,10 @@ choice
 	prompt "Altera SOCFPGA board select"
 	optional
 
+config TARGET_SOCFPGA_ARRIA10_SOCDK
+	bool "Altera SOCFPGA SoCDK (Arria 10)"
+	select TARGET_SOCFPGA_ARRIA10
+
 config TARGET_SOCFPGA_ARRIA5_SOCDK
 	bool "Altera SOCFPGA SoCDK (Arria V)"
 	select TARGET_SOCFPGA_ARRIA5
@@ -93,6 +100,7 @@ endchoice
 
 config SYS_BOARD
 	default "arria5-socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
+	default "arria10-socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "cyclone5-socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
 	default "de0-nano-soc" if TARGET_SOCFPGA_TERASIC_DE0_NANO
 	default "de1-soc" if TARGET_SOCFPGA_TERASIC_DE1_SOC
@@ -105,6 +113,7 @@ config SYS_BOARD
 
 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 "denx" if TARGET_SOCFPGA_DENX_MCVEVK
 	default "ebv" if TARGET_SOCFPGA_EBV_SOCRATES
@@ -118,6 +127,7 @@ config SYS_SOC
 
 config SYS_CONFIG_NAME
 	default "socfpga_arria5_socdk" if TARGET_SOCFPGA_ARRIA5_SOCDK
+	default "socfpga_arria10_socdk" if TARGET_SOCFPGA_ARRIA10_SOCDK
 	default "socfpga_cyclone5_socdk" if TARGET_SOCFPGA_CYCLONE5_SOCDK
 	default "socfpga_de0_nano_soc" if TARGET_SOCFPGA_TERASIC_DE0_NANO
 	default "socfpga_de1_soc" if TARGET_SOCFPGA_TERASIC_DE1_SOC
arch/arm/mach-socfpga/Makefile +33 -13

61 lines not on this page · raw message

Signature · 1 line
1.8.2.3
maintainer
#2 lore raw

PATCH v2 1/20 arm: socfpga: Restructure clock manager driver

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

Restructure clock manager driver in the preparation to support A10. Move the Gen5 specific code to _gen5 files. No functional change.

Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.

Quoted 10 lines
---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 510 +--------------------
 arch/arm/mach-socfpga/clock_manager_gen5.c         | 510 +++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 312 +------------
 .../mach-socfpga/include/mach/clock_manager_gen5.h | 322 +++++++++++++
 5 files changed, 846 insertions(+), 811 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_gen5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h

Please add a -C when you run format-patch, you'll get something like this:

 5 files changed, 104 insertions(+), 947 deletions(-)
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (88%)
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h =>

clock_manager_gen5.h} (87%)

It it make things a bit smaller to review for simple file copies.

Thanks,
Dinh

maintainer
#5 lore raw

PATCH v2 2/20 arm: socfpga: Update clock for Gen5

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

Rename some of variables and fixes on clock calculation.

Why? Please be more specific with why this change is necessary?

Quoted 44 lines
---
 arch/arm/mach-socfpga/clock_manager_gen5.c | 126 +++++++++++++++++------------
 1 file changed, 76 insertions(+), 50 deletions(-)
arch/arm/mach-socfpga/clock_manager_gen5.c +5 -10
index bca27df..bef0adb 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
+ * Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -66,7 +66,6 @@ static void cm_write_with_phase(u32 value,
  * set source main and peripheral clocks
  * Ungate clocks
  */
-
 void cm_basic_init(const struct cm_config * const cfg)
 {
 	unsigned long end;
@@ -307,56 +306,73 @@ void cm_basic_init(const struct cm_config * const cfg)
 
 static unsigned int cm_get_main_vco_clk_hz(void)
 {
-	u32 reg, clock;
+	u32 src_hz, numer, denom, vco;
 
 	/* get the main VCO clock */
-	reg = readl(&clock_manager_base->main_pll.vco);
-	clock = cm_get_osc_clk_hz(1);
-	clock /= ((reg & CLKMGR_MAINPLLGRP_VCO_DENOM_MASK) >>
-		  CLKMGR_MAINPLLGRP_VCO_DENOM_OFFSET) + 1;
-	clock *= ((reg & CLKMGR_MAINPLLGRP_VCO_NUMER_MASK) >>
-		  CLKMGR_MAINPLLGRP_VCO_NUMER_OFFSET) + 1;
+	vco = readl(&clock_manager_base->main_pll.vco);
 
-	return clock;
+	numer = ((vco & CLKMGR_MAINPLLGRP_VCO_NUMER_MASK) >>
+		CLKMGR_MAINPLLGRP_VCO_NUMER_OFFSET);

arch/arm/mach-socfpga/clock_manager_gen5.c void cm_basic_init(const struct cm_config * const cfg) · line 325

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +10 -0
+	denom = ((vco & CLKMGR_MAINPLLGRP_VCO_DENOM_MASK) >>
+		 CLKMGR_MAINPLLGRP_VCO_DENOM_OFFSET);
+
+	src_hz = cm_get_osc_clk_hz(1);
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);
+
+	return vco;

It seems like this change is beyond just "Rename some of variables and fixes on clock calculation". Could probably be it's own patch?

Quoted 41 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +16 -15
 }
 
 static unsigned int cm_get_per_vco_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 src_hz = 0;
+	u32 clk_src = 0;
+	u32 numer = 0;
+	u32 denom = 0;
+	u32 vco = 0;
 
 	/* identify PER PLL clock source */
-	reg = readl(&clock_manager_base->per_pll.vco);
-	reg = (reg & CLKMGR_PERPLLGRP_VCO_SSRC_MASK) >>
+	clk_src = readl(&clock_manager_base->per_pll.vco);
+	clk_src = (clk_src & CLKMGR_PERPLLGRP_VCO_SSRC_MASK) >>
 	      CLKMGR_PERPLLGRP_VCO_SSRC_OFFSET;
-	if (reg == CLKMGR_VCO_SSRC_EOSC1)
-		clock = cm_get_osc_clk_hz(1);
-	else if (reg == CLKMGR_VCO_SSRC_EOSC2)
-		clock = cm_get_osc_clk_hz(2);
-	else if (reg == CLKMGR_VCO_SSRC_F2S)
-		clock = cm_get_f2s_per_ref_clk_hz();
+	if (clk_src == CLKMGR_VCO_SSRC_EOSC1)
+		src_hz = cm_get_osc_clk_hz(1);
+	else if (clk_src == CLKMGR_VCO_SSRC_EOSC2)
+		src_hz = cm_get_osc_clk_hz(2);
+	else if (clk_src == CLKMGR_VCO_SSRC_F2S)
+		src_hz = cm_get_f2s_per_ref_clk_hz();
 
 	/* get the PER VCO clock */
-	reg = readl(&clock_manager_base->per_pll.vco);
-	clock /= ((reg & CLKMGR_PERPLLGRP_VCO_DENOM_MASK) >>
-		  CLKMGR_PERPLLGRP_VCO_DENOM_OFFSET) + 1;
-	clock *= ((reg & CLKMGR_PERPLLGRP_VCO_NUMER_MASK) >>
-		  CLKMGR_PERPLLGRP_VCO_NUMER_OFFSET) + 1;
+	vco = readl(&clock_manager_base->per_pll.vco);
 
-	return clock;
+	numer = (vco & CLKMGR_PERPLLGRP_VCO_NUMER_MASK) >>
+		CLKMGR_PERPLLGRP_VCO_NUMER_OFFSET;

arch/arm/mach-socfpga/clock_manager_gen5.c void cm_basic_init(const struct cm_config * const cfg) · line 361

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +9 -0
+
+	denom = (vco & CLKMGR_PERPLLGRP_VCO_DENOM_MASK) >>
+		CLKMGR_PERPLLGRP_VCO_DENOM_OFFSET;
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);
+
+	return vco;
 }

Ditto..

Quoted 84 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +30 -23
 unsigned long cm_get_mpu_clk_hz(void)
 {
-	u32 reg, clock;
+	u32 reg, clk_hz;
 
-	clock = cm_get_main_vco_clk_hz();
+	clk_hz = cm_get_main_vco_clk_hz();
 
 	/* get the MPU clock */
 	reg = readl(&clock_manager_base->altera.mpuclk);
-	clock /= (reg + 1);
+	clk_hz /= (reg + 1);
 	reg = readl(&clock_manager_base->main_pll.mpuclk);
-	clock /= (reg + 1);
-	return clock;
+	clk_hz /= (reg + 1);
+
+	return clk_hz;
 }
 
 unsigned long cm_get_sdram_clk_hz(void)
@@ -392,7 +408,8 @@ unsigned long cm_get_sdram_clk_hz(void)
 
 unsigned int cm_get_l4_sp_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 
 	/* identify the source of L4 SP clock */
 	reg = readl(&clock_manager_base->main_pll.l4src);
@@ -426,37 +443,45 @@ unsigned int cm_get_l4_sp_clk_hz(void)
 
 unsigned int cm_get_mmc_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clk_hz = 0;
+	u32 clk_input = 0;
 
-	/* identify the source of MMC clock */
-	reg = readl(&clock_manager_base->per_pll.src);
-	reg = (reg & CLKMGR_PERPLLGRP_SRC_SDMMC_MASK) >>
+	clk_input = readl(&clock_manager_base->per_pll.src);
+	clk_input = (clk_input & CLKMGR_PERPLLGRP_SRC_SDMMC_MASK) >>
 	      CLKMGR_PERPLLGRP_SRC_SDMMC_OFFSET;
 
-	if (reg == CLKMGR_SDMMC_CLK_SRC_F2S) {
-		clock = cm_get_f2s_per_ref_clk_hz();
-	} else if (reg == CLKMGR_SDMMC_CLK_SRC_MAIN) {
-		clock = cm_get_main_vco_clk_hz();
+	switch (clk_input) {
+	case CLKMGR_SDMMC_CLK_SRC_F2S:
+		clk_hz = cm_get_f2s_per_ref_clk_hz();
+		break;
+
+	case CLKMGR_SDMMC_CLK_SRC_MAIN:
+		clk_hz = cm_get_main_vco_clk_hz();
 
 		/* get the SDMMC clock */
-		reg = readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
-		clock /= (reg + 1);
-	} else if (reg == CLKMGR_SDMMC_CLK_SRC_PER) {
-		clock = cm_get_per_vco_clk_hz();
+		clk_input =
+			readl(&clock_manager_base->main_pll.mainnandsdmmcclk);
+		clk_hz /= (clk_input + 1);
+		break;
+
+	case CLKMGR_SDMMC_CLK_SRC_PER:
+		clk_hz = cm_get_per_vco_clk_hz();
 
 		/* get the SDMMC clock */
-		reg = readl(&clock_manager_base->per_pll.pernandsdmmcclk);
-		clock /= (reg + 1);
+		clk_input =
+			readl(&clock_manager_base->per_pll.pernandsdmmcclk);
+		clk_hz /= (clk_input + 1);
+		break;
 	}
 
-	/* further divide by 4 as we have fixed divider at wrapper */
-	clock /= 4;
-	return clock;

arch/arm/mach-socfpga/clock_manager_gen5.c unsigned int cm_get_l4_sp_clk_hz(void) · line 485

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +4 -1
+	return clk_hz / 4;
 }
 
+
 unsigned int cm_get_qspi_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 

Why is this necessary?

arch/arm/mach-socfpga/clock_manager_gen5.c unsigned int cm_get_qspi_controller_clk_hz(void) · line 514

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_gen5.c +2 -1
 	/* identify the source of QSPI clock */
 	reg = readl(&clock_manager_base->per_pll.src);
@@ -484,7 +509,8 @@ unsigned int cm_get_qspi_controller_clk_hz(void)
 
 unsigned int cm_get_spi_controller_clk_hz(void)
 {
-	u32 reg, clock = 0;
+	u32 clock = 0;
+	u32 reg;
 

Ditto..

Dinh

#53 lore raw

v2 cover Add Intel Arria 10 SoC support

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

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

Can you please include me on this patchset? I'd like to help with the review process.

Thanks,
Dinh

#8 lore raw

PATCH v2 4/20 arm: socfpga: Restructure misc driver

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

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to _gen5 file. No functional change.

Change all uint32_t_to u32.

---
 arch/arm/mach-socfpga/Makefile            |   3 +-
 arch/arm/mach-socfpga/include/mach/misc.h |  26 +++
 arch/arm/mach-socfpga/misc.c              | 361 ++----------------------------
 arch/arm/mach-socfpga/misc_gen5.c         | 355 +++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 347 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/Makefile +2 -1
index 97819ac..5b09ea9 100644
@@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)	+= scan_manager.o wrap_pll_config.o \
-					   clock_manager_gen5.o reset_manager_gen5.o
+					   clock_manager_gen5.o reset_manager_gen5.o \
+					   misc_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o	\
 			   wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o	+= -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/misc.h new file +8 -0
new file mode 100644
index 0000000..64f9b86
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_

arch/arm/mach-socfpga/include/mach/misc.h line 18

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +10 -0
+
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+				 const u32 phymode);
+
+struct bsel {
+	const char	*mode;
+	const char	*name;
+};
+
+extern struct bsel bsel_str[];

I'm really not a big fan of extern variables, can we get rid of this?

arch/arm/mach-socfpga/include/mach/misc.h line 23

Quoted 4 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +4 -0
+#ifdef CONFIG_FPGA
+void socfpga_fpga_add(void);
+#else
+inline void socfpga_fpga_add(void) {}

static

Quoted 774 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +3 -0
+#endif
+
+#endif /* _MISC_H_ */
arch/arm/mach-socfpga/misc.c +15 -346
index dd6b53b..cd250af 100644
@@ -1,5 +1,5 @@
 /*
- *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *  Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -13,6 +13,7 @@
 #include <miiphy.h>
 #include <netdev.h>
 #include <watchdog.h>
+#include <asm/arch/misc.h>
 #include <asm/arch/reset_manager.h>
 #include <asm/arch/scan_manager.h>
 #include <asm/arch/system_manager.h>
@@ -24,16 +25,19 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-static struct pl310_regs *const pl310 =
+static const struct pl310_regs *const pl310 =
 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
-static struct socfpga_system_manager *sysmgr_regs =
-	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
-static struct socfpga_reset_manager *reset_manager_base =
-	(struct socfpga_reset_manager *)SOCFPGA_RSTMGR_ADDRESS;
-static struct nic301_registers *nic301_regs =
-	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
-static struct scu_registers *scu_regs =
-	(struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
+
+struct bsel bsel_str[] = {
+	{ "rsvd", "Reserved", },
+	{ "fpga", "FPGA (HPS2FPGA Bridge)", },
+	{ "nand", "NAND Flash (1.8V)", },
+	{ "nand", "NAND Flash (3.0V)", },
+	{ "sd", "SD/MMC External Transceiver (1.8V)", },
+	{ "sd", "SD/MMC Internal Transceiver (3.0V)", },
+	{ "qspi", "QSPI Flash (1.8V)", },
+	{ "qspi", "QSPI Flash (3.0V)", },
+};
 
 int dram_init(void)
 {
@@ -72,207 +76,6 @@ void v7_outer_cache_disable(void)
 	clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
 }
 
-/*
- * DesignWare Ethernet initialization
- */
-#ifdef CONFIG_ETH_DESIGNWARE
-static void dwmac_deassert_reset(const unsigned int of_reset_id,
-				 const u32 phymode)
-{
-	u32 physhift, reset;
-
-	if (of_reset_id == EMAC0_RESET) {
-		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB;
-		reset = SOCFPGA_RESET(EMAC0);
-	} else if (of_reset_id == EMAC1_RESET) {
-		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB;
-		reset = SOCFPGA_RESET(EMAC1);
-	} else {
-		printf("GMAC: Invalid reset ID (%i)!\n", of_reset_id);
-		return;
-	}
-
-	/* Clearing emac0 PHY interface select to 0 */
-	clrbits_le32(&sysmgr_regs->emacgrp_ctrl,
-		     SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift);
-
-	/* configure to PHY interface select choosed */
-	setbits_le32(&sysmgr_regs->emacgrp_ctrl,
-		     phymode << physhift);
-
-	/* Release the EMAC controller from reset */
-	socfpga_per_reset(reset, 0);
-}
-
-static u32 dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
-{
-	if (!phymode)
-		return -EINVAL;
-
-	if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii")) {
-		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
-		return 0;
-	}
-
-	if (!strcmp(phymode, "rgmii")) {
-		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
-		return 0;
-	}
-
-	if (!strcmp(phymode, "rmii")) {
-		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII;
-		return 0;
-	}
-
-	return -EINVAL;
-}
-
-static int socfpga_eth_reset(void)
-{
-	const void *fdt = gd->fdt_blob;
-	struct fdtdec_phandle_args args;
-	const char *phy_mode;
-	u32 phy_modereg;
-	int nodes[2];	/* Max. two GMACs */
-	int ret, count;
-	int i, node;
-
-	/* Put both GMACs into RESET state. */
-	socfpga_per_reset(SOCFPGA_RESET(EMAC0), 1);
-	socfpga_per_reset(SOCFPGA_RESET(EMAC1), 1);
-
-	count = fdtdec_find_aliases_for_id(fdt, "ethernet",
-					   COMPAT_ALTERA_SOCFPGA_DWMAC,
-					   nodes, ARRAY_SIZE(nodes));
-	for (i = 0; i < count; i++) {
-		node = nodes[i];
-		if (node <= 0)
-			continue;
-
-		ret = fdtdec_parse_phandle_with_args(fdt, node, "resets",
-						     "#reset-cells", 1, 0,
-						     &args);
-		if (ret || (args.args_count != 1)) {
-			debug("GMAC%i: Failed to parse DT 'resets'!\n", i);
-			continue;
-		}
-
-		phy_mode = fdt_getprop(fdt, node, "phy-mode", NULL);
-		ret = dwmac_phymode_to_modereg(phy_mode, &phy_modereg);
-		if (ret) {
-			debug("GMAC%i: Failed to parse DT 'phy-mode'!\n", i);
-			continue;
-		}
-
-		dwmac_deassert_reset(args.args[0], phy_modereg);
-	}
-
-	return 0;
-}
-#else
-static int socfpga_eth_reset(void)
-{
-	return 0;
-};
-#endif
-
-struct {
-	const char	*mode;
-	const char	*name;
-} bsel_str[] = {
-	{ "rsvd", "Reserved", },
-	{ "fpga", "FPGA (HPS2FPGA Bridge)", },
-	{ "nand", "NAND Flash (1.8V)", },
-	{ "nand", "NAND Flash (3.0V)", },
-	{ "sd", "SD/MMC External Transceiver (1.8V)", },
-	{ "sd", "SD/MMC Internal Transceiver (3.0V)", },
-	{ "qspi", "QSPI Flash (1.8V)", },
-	{ "qspi", "QSPI Flash (3.0V)", },
-};
-
-static const struct {
-	const u16	pn;
-	const char	*name;
-	const char	*var;
-} const socfpga_fpga_model[] = {
-	/* Cyclone V E */
-	{ 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
-	{ 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
-	{ 0x2b22, "Cyclone V, E/A5", "cv_e_a5" },
-	{ 0x2b13, "Cyclone V, E/A7", "cv_e_a7" },
-	{ 0x2b14, "Cyclone V, E/A9", "cv_e_a9" },
-	/* Cyclone V GX/GT */
-	{ 0x2b01, "Cyclone V, GX/C3", "cv_gx_c3" },
-	{ 0x2b12, "Cyclone V, GX/C4", "cv_gx_c4" },
-	{ 0x2b02, "Cyclone V, GX/C5 or GT/D5", "cv_gx_c5" },
-	{ 0x2b03, "Cyclone V, GX/C7 or GT/D7", "cv_gx_c7" },
-	{ 0x2b04, "Cyclone V, GX/C9 or GT/D9", "cv_gx_c9" },
-	/* Cyclone V SE/SX/ST */
-	{ 0x2d11, "Cyclone V, SE/A2 or SX/C2", "cv_se_a2" },
-	{ 0x2d01, "Cyclone V, SE/A4 or SX/C4", "cv_se_a4" },
-	{ 0x2d12, "Cyclone V, SE/A5 or SX/C5 or ST/D5", "cv_se_a5" },
-	{ 0x2d02, "Cyclone V, SE/A6 or SX/C6 or ST/D6", "cv_se_a6" },
-	/* Arria V */
-	{ 0x2d03, "Arria V, D5", "av_d5" },
-};
-
-static int socfpga_fpga_id(const bool print_id)
-{
-	const u32 altera_mi = 0x6e;
-	const u32 id = scan_mgr_get_fpga_id();
-
-	const u32 lsb = id & 0x00000001;
-	const u32 mi = (id >> 1) & 0x000007ff;
-	const u32 pn = (id >> 12) & 0x0000ffff;
-	const u32 version = (id >> 28) & 0x0000000f;
-	int i;
-
-	if ((mi != altera_mi) || (lsb != 1)) {
-		printf("FPGA:  Not Altera chip ID\n");
-		return -EINVAL;
-	}
-
-	for (i = 0; i < ARRAY_SIZE(socfpga_fpga_model); i++)
-		if (pn == socfpga_fpga_model[i].pn)
-			break;
-
-	if (i == ARRAY_SIZE(socfpga_fpga_model)) {
-		printf("FPGA:  Unknown Altera chip, ID 0x%08x\n", id);
-		return -EINVAL;
-	}
-
-	if (print_id)
-		printf("FPGA:  Altera %s, version 0x%01x\n",
-		       socfpga_fpga_model[i].name, version);
-	return i;
-}
-
-/*
- * Print CPU information
- */
-#if defined(CONFIG_DISPLAY_CPUINFO)
-int print_cpuinfo(void)
-{
-	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
-	puts("CPU:   Altera SoCFPGA Platform\n");
-	socfpga_fpga_id(1);
-	printf("BOOT:  %s\n", bsel_str[bsel].name);
-	return 0;
-}
-#endif
-
-#ifdef CONFIG_ARCH_MISC_INIT
-int arch_misc_init(void)
-{
-	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
-	const int fpga_id = socfpga_fpga_id(0);
-	setenv("bootmode", bsel_str[bsel].mode);
-	if (fpga_id >= 0)
-		setenv("fpgatype", socfpga_fpga_model[fpga_id].var);
-	return socfpga_eth_reset();
-}
-#endif
-
 #if defined(CONFIG_SYS_CONSOLE_IS_IN_ENV) && \
 defined(CONFIG_SYS_CONSOLE_OVERWRITE_ROUTINE)
 int overwrite_console(void)
@@ -303,15 +106,13 @@ static Altera_desc altera_fpga[] = {
 };
 
 /* add device descriptor to FPGA device table */
-static void socfpga_fpga_add(void)
+void socfpga_fpga_add(void)
 {
 	int i;
 	fpga_init();
 	for (i = 0; i < ARRAY_SIZE(altera_fpga); i++)
 		fpga_add(fpga_altera, &altera_fpga[i]);
 }
-#else
-static inline void socfpga_fpga_add(void) {}
 #endif
 
 int arch_cpu_init(void)
@@ -337,135 +138,3 @@ int arch_cpu_init(void)
 
 	return 0;
 }
-
-/*
- * Convert all NIC-301 AMBA slaves from secure to non-secure
- */
-static void socfpga_nic301_slave_ns(void)
-{
-	writel(0x1, &nic301_regs->lwhps2fpgaregs);
-	writel(0x1, &nic301_regs->hps2fpgaregs);
-	writel(0x1, &nic301_regs->acp);
-	writel(0x1, &nic301_regs->rom);
-	writel(0x1, &nic301_regs->ocram);
-	writel(0x1, &nic301_regs->sdrdata);
-}
-
-static uint32_t iswgrp_handoff[8];
-
-int arch_early_init_r(void)
-{
-	int i;
-
-	/*
-	 * Write magic value into magic register to unlock support for
-	 * issuing warm reset. The ancient kernel code expects this
-	 * value to be written into the register by the bootloader, so
-	 * to support that old code, we write it here instead of in the
-	 * reset_cpu() function just before resetting the CPU.
-	 */
-	writel(0xae9efebc, &sysmgr_regs->romcodegrp_warmramgrp_enable);
-
-	for (i = 0; i < 8; i++)	/* Cache initial SW setting regs */
-		iswgrp_handoff[i] = readl(&sysmgr_regs->iswgrp_handoff[i]);
-
-	socfpga_bridges_reset(1);
-	socfpga_nic301_slave_ns();
-
-	/*
-	 * Private components security:
-	 * U-Boot : configure private timer, global timer and cpu component
-	 * access as non secure for kernel stage (as required by Linux)
-	 */
-	setbits_le32(&scu_regs->sacr, 0xfff);
-
-	/* Configure the L2 controller to make SDRAM start at 0 */
-#ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
-	writel(0x2, &nic301_regs->remap);
-#else
-	writel(0x1, &nic301_regs->remap);	/* remap.mpuzero */
-	writel(0x1, &pl310->pl310_addr_filter_start);
-#endif
-
-	/* Add device descriptor to FPGA device table */
-	socfpga_fpga_add();
-
-#ifdef CONFIG_DESIGNWARE_SPI
-	/* Get Designware SPI controller out of reset */
-	socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
-	socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);
-#endif
-
-#ifdef CONFIG_NAND_DENALI
-	socfpga_per_reset(SOCFPGA_RESET(NAND), 0);
-#endif
-
-	return 0;
-}
-
-static void socfpga_sdram_apply_static_cfg(void)
-{
-	const uint32_t staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;
-	const uint32_t applymask = 0x8;
-	uint32_t val = readl(staticcfg) | applymask;
-
-	/*
-	 * SDRAM staticcfg register specific:
-	 * When applying the register setting, the CPU must not access
-	 * SDRAM. Luckily for us, we can abuse i-cache here to help us
-	 * circumvent the SDRAM access issue. The idea is to make sure
-	 * that the code is in one full i-cache line by branching past
-	 * it and back. Once it is in the i-cache, we execute the core
-	 * of the code and apply the register settings.
-	 *
-	 * The code below uses 7 instructions, while the Cortex-A9 has
-	 * 32-byte cachelines, thus the limit is 8 instructions total.
-	 */
-	asm volatile(
-		".align	5			\n"
-		"	b	2f		\n"
-		"1:	str	%0,	[%1]	\n"
-		"	dsb			\n"
-		"	isb			\n"
-		"	b	3f		\n"
-		"2:	b	1b		\n"
-		"3:	nop			\n"
-	: : "r"(val), "r"(staticcfg) : "memory", "cc");
-}
-
-int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-	if (argc != 2)
-		return CMD_RET_USAGE;
-
-	argv++;
-
-	switch (*argv[0]) {
-	case 'e':	/* Enable */
-		writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
-		socfpga_sdram_apply_static_cfg();
-		writel(iswgrp_handoff[3], SOCFPGA_SDR_ADDRESS + 0x5080);
-		writel(iswgrp_handoff[0], &reset_manager_base->brg_mod_reset);
-		writel(iswgrp_handoff[1], &nic301_regs->remap);
-		break;
-	case 'd':	/* Disable */
-		writel(0, &sysmgr_regs->fpgaintfgrp_module);
-		writel(0, SOCFPGA_SDR_ADDRESS + 0x5080);
-		socfpga_sdram_apply_static_cfg();
-		writel(0, &reset_manager_base->brg_mod_reset);
-		writel(1, &nic301_regs->remap);
-		break;
-	default:
-		return CMD_RET_USAGE;
-	}
-
-	return 0;
-}
-
-U_BOOT_CMD(
-	bridge, 2, 1, do_bridge,
-	"SoCFPGA HPS FPGA bridge control",
-	"enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
-	"bridge disable - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
-	""
-);
arch/arm/mach-socfpga/misc_gen5.c new file +355 -0
new file mode 100644
index 0000000..f870e1f
@@ -0,0 +1,355 @@
+/*
+ *  Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <libfdt.h>
+#include <altera.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <watchdog.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/scan_manager.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/nic301.h>
+#include <asm/arch/scu.h>
+#include <asm/pl310.h>
+
+#include <dt-bindings/reset/altr,rst-mgr.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct pl310_regs *const pl310 =
+	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+static struct socfpga_reset_manager *reset_manager_base =
+	(struct socfpga_reset_manager *)SOCFPGA_RSTMGR_ADDRESS;
+static struct nic301_registers *nic301_regs =
+	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
+static struct scu_registers *scu_regs =
+	(struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+				 const u32 phymode)
+{
+	u32 physhift, reset;
+
+	if (of_reset_id == EMAC0_RESET) {
+		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB;
+		reset = SOCFPGA_RESET(EMAC0);
+	} else if (of_reset_id == EMAC1_RESET) {
+		physhift = SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB;
+		reset = SOCFPGA_RESET(EMAC1);
+	} else {
+		printf("GMAC: Invalid reset ID (%i)!\n", of_reset_id);
+		return;
+	}
+
+	/* configure to PHY interface select choosed */
+	clrsetbits_le32(&sysmgr_regs->emacgrp_ctrl,
+			SYSMGR_EMACGRP_CTRL_PHYSEL_MASK << physhift,
+			phymode << physhift);
+
+	/* Release the EMAC controller from reset */
+	socfpga_per_reset(reset, 0);
+}
+
+static u32 dwmac_phymode_to_modereg(const char *phymode, u32 *modereg)
+{
+	if (!phymode)
+		return -EINVAL;
+
+	if (!strcmp(phymode, "mii") || !strcmp(phymode, "gmii")) {
+		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII;
+		return 0;
+	}
+
+	if (!strcmp(phymode, "rgmii")) {
+		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII;
+		return 0;
+	}
+
+	if (!strcmp(phymode, "rmii")) {
+		*modereg = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII;
+		return 0;
+	}
+
+	return -EINVAL;
+}
+
+static int socfpga_eth_reset(void)
+{
+	const void *fdt = gd->fdt_blob;
+	struct fdtdec_phandle_args args;
+	const char *phy_mode;
+	u32 phy_modereg;
+	int nodes[2];	/* Max. two GMACs */
+	int ret, count;
+	int i, node;
+
+	/* Put both GMACs into RESET state. */
+	socfpga_per_reset(SOCFPGA_RESET(EMAC0), 1);
+	socfpga_per_reset(SOCFPGA_RESET(EMAC1), 1);
+
+	count = fdtdec_find_aliases_for_id(fdt, "ethernet",
+					   COMPAT_ALTERA_SOCFPGA_DWMAC,
+					   nodes, ARRAY_SIZE(nodes));
+	for (i = 0; i < count; i++) {
+		node = nodes[i];
+		if (node <= 0)
+			continue;
+
+		ret = fdtdec_parse_phandle_with_args(fdt, node, "resets",
+						     "#reset-cells", 1, 0,
+						     &args);
+		if (ret || (args.args_count != 1)) {
+			debug("GMAC%i: Failed to parse DT 'resets'!\n", i);
+			continue;
+		}
+
+		phy_mode = fdt_getprop(fdt, node, "phy-mode", NULL);
+		ret = dwmac_phymode_to_modereg(phy_mode, &phy_modereg);
+		if (ret) {
+			debug("GMAC%i: Failed to parse DT 'phy-mode'!\n", i);
+			continue;
+		}
+
+		dwmac_deassert_reset(args.args[0], phy_modereg);
+	}
+
+	return 0;
+}
+#else
+static int socfpga_eth_reset(void)
+{
+	return 0;
+};
+#endif
+
+static const struct {
+	const u16	pn;
+	const char	*name;
+	const char	*var;
+} const socfpga_fpga_model[] = {
+	/* Cyclone V E */
+	{ 0x2b15, "Cyclone V, E/A2", "cv_e_a2" },
+	{ 0x2b05, "Cyclone V, E/A4", "cv_e_a4" },
+	{ 0x2b22, "Cyclone V, E/A5", "cv_e_a5" },
+	{ 0x2b13, "Cyclone V, E/A7", "cv_e_a7" },
+	{ 0x2b14, "Cyclone V, E/A9", "cv_e_a9" },
+	/* Cyclone V GX/GT */
+	{ 0x2b01, "Cyclone V, GX/C3", "cv_gx_c3" },
+	{ 0x2b12, "Cyclone V, GX/C4", "cv_gx_c4" },
+	{ 0x2b02, "Cyclone V, GX/C5 or GT/D5", "cv_gx_c5" },
+	{ 0x2b03, "Cyclone V, GX/C7 or GT/D7", "cv_gx_c7" },
+	{ 0x2b04, "Cyclone V, GX/C9 or GT/D9", "cv_gx_c9" },
+	/* Cyclone V SE/SX/ST */
+	{ 0x2d11, "Cyclone V, SE/A2 or SX/C2", "cv_se_a2" },
+	{ 0x2d01, "Cyclone V, SE/A4 or SX/C4", "cv_se_a4" },
+	{ 0x2d12, "Cyclone V, SE/A5 or SX/C5 or ST/D5", "cv_se_a5" },
+	{ 0x2d02, "Cyclone V, SE/A6 or SX/C6 or ST/D6", "cv_se_a6" },
+	/* Arria V */
+	{ 0x2d03, "Arria V, D5", "av_d5" },
+};
+
+static int socfpga_fpga_id(const bool print_id)
+{
+	const u32 altera_mi = 0x6e;
+	const u32 id = scan_mgr_get_fpga_id();
+
+	const u32 lsb = id & 0x00000001;
+	const u32 mi = (id >> 1) & 0x000007ff;
+	const u32 pn = (id >> 12) & 0x0000ffff;
+	const u32 version = (id >> 28) & 0x0000000f;
+	int i;
+
+	if ((mi != altera_mi) || (lsb != 1)) {
+		printf("FPGA:  Not Altera chip ID\n");
+		return -EINVAL;
+	}
+
+	for (i = 0; i < ARRAY_SIZE(socfpga_fpga_model); i++)
+		if (pn == socfpga_fpga_model[i].pn)
+			break;
+
+	if (i == ARRAY_SIZE(socfpga_fpga_model)) {
+		printf("FPGA:  Unknown Altera chip, ID 0x%08x\n", id);
+		return -EINVAL;
+	}
+
+	if (print_id)
+		printf("FPGA:  Altera %s, version 0x%01x\n",
+		       socfpga_fpga_model[i].name, version);
+	return i;
+}
+
+/*
+ * Print CPU information
+ */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
+
+	puts("CPU:   Altera SoCFPGA Platform\n");
+	socfpga_fpga_id(1);
+
+	printf("BOOT:  %s\n", bsel_str[bsel].name);
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MISC_INIT
+int arch_misc_init(void)
+{
+	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
+	const int fpga_id = socfpga_fpga_id(0);
+	setenv("bootmode", bsel_str[bsel].mode);
+	if (fpga_id >= 0)
+		setenv("fpgatype", socfpga_fpga_model[fpga_id].var);
+	return socfpga_eth_reset();
+}
+#endif
+
+/*
+ * Convert all NIC-301 AMBA slaves from secure to non-secure
+ */
+static void socfpga_nic301_slave_ns(void)
+{
+	writel(0x1, &nic301_regs->lwhps2fpgaregs);
+	writel(0x1, &nic301_regs->hps2fpgaregs);
+	writel(0x1, &nic301_regs->acp);
+	writel(0x1, &nic301_regs->rom);
+	writel(0x1, &nic301_regs->ocram);
+	writel(0x1, &nic301_regs->sdrdata);
+}
+
+static u32 iswgrp_handoff[8];
+
+int arch_early_init_r(void)
+{
+	int i;
+
+	/*
+	 * Write magic value into magic register to unlock support for
+	 * issuing warm reset. The ancient kernel code expects this
+	 * value to be written into the register by the bootloader, so
+	 * to support that old code, we write it here instead of in the
+	 * reset_cpu() function just before resetting the CPU.
+	 */
+	writel(0xae9efebc, &sysmgr_regs->romcodegrp_warmramgrp_enable);
+
+	for (i = 0; i < 8; i++)	/* Cache initial SW setting regs */
+		iswgrp_handoff[i] = readl(&sysmgr_regs->iswgrp_handoff[i]);
+
+	socfpga_bridges_reset(1);
+	socfpga_nic301_slave_ns();
+
+	/*
+	 * Private components security:
+	 * U-Boot : configure private timer, global timer and cpu component
+	 * access as non secure for kernel stage (as required by Linux)
+	 */
+	setbits_le32(&scu_regs->sacr, 0xfff);
+
+	/* Configure the L2 controller to make SDRAM start at 0 */
+#ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
+	writel(0x2, &nic301_regs->remap);
+#else
+	writel(0x1, &nic301_regs->remap);	/* remap.mpuzero */
+	writel(0x1, &pl310->pl310_addr_filter_start);
+#endif
+
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
+
+#ifdef CONFIG_DESIGNWARE_SPI
+	/* Get Designware SPI controller out of reset */
+	socfpga_per_reset(SOCFPGA_RESET(SPIM0), 0);
+	socfpga_per_reset(SOCFPGA_RESET(SPIM1), 0);
+#endif
+
+#ifdef CONFIG_NAND_DENALI
+	socfpga_per_reset(SOCFPGA_RESET(NAND), 0);
+#endif
+
+	return 0;
+}
+
+static void socfpga_sdram_apply_static_cfg(void)
+{
+	const u32 staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;
+	const u32 applymask = 0x8;
+	u32 val = readl(staticcfg) | applymask;
+
+	/*
+	 * SDRAM staticcfg register specific:
+	 * When applying the register setting, the CPU must not access
+	 * SDRAM. Luckily for us, we can abuse i-cache here to help us
+	 * circumvent the SDRAM access issue. The idea is to make sure
+	 * that the code is in one full i-cache line by branching past
+	 * it and back. Once it is in the i-cache, we execute the core
+	 * of the code and apply the register settings.
+	 *
+	 * The code below uses 7 instructions, while the Cortex-A9 has
+	 * 32-byte cachelines, thus the limit is 8 instructions total.
+	 */
+	asm volatile(
+		".align	5			\n"
+		"	b	2f		\n"
+		"1:	str	%0,	[%1]	\n"
+		"	dsb			\n"
+		"	isb			\n"
+		"	b	3f		\n"
+		"2:	b	1b		\n"
+		"3:	nop			\n"
+	: : "r"(val), "r"(staticcfg) : "memory", "cc");
+}
+
+int do_bridge(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	if (argc != 2)
+		return CMD_RET_USAGE;
+
+	argv++;
+
+	switch (*argv[0]) {
+	case 'e':	/* Enable */
+		writel(iswgrp_handoff[2], &sysmgr_regs->fpgaintfgrp_module);
+		socfpga_sdram_apply_static_cfg();
+		writel(iswgrp_handoff[3], SOCFPGA_SDR_ADDRESS + 0x5080);
+		writel(iswgrp_handoff[0], &reset_manager_base->brg_mod_reset);
+		writel(iswgrp_handoff[1], &nic301_regs->remap);
+		break;
+	case 'd':	/* Disable */
+		writel(0, &sysmgr_regs->fpgaintfgrp_module);
+		writel(0, SOCFPGA_SDR_ADDRESS + 0x5080);
+		socfpga_sdram_apply_static_cfg();
+		writel(0, &reset_manager_base->brg_mod_reset);
+		writel(1, &nic301_regs->remap);
+		break;
+	default:
+		return CMD_RET_USAGE;
+	}
+
+	return 0;
+}
+
+U_BOOT_CMD(
+	bridge, 2, 1, do_bridge,
+	"SoCFPGA HPS FPGA bridge control",
+	"enable  - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+	"bridge disable - Enable HPS-to-FPGA, FPGA-to-HPS, LWHPS-to-FPGA bridges\n"
+	""
+);
Signature · 2 lines
Best regards,
Marek Vasut
#14 lore raw

PATCH v2 6/20 arm: socfpga: Add A10 defines

In reply to Ley Foon Tan
Quoted 1 line · Ley Foon Tan

Add i2c, timer and other A10 defines.

macros ... btw. you're defining macro with their address.

Quoted 38 lines
---
 arch/arm/mach-socfpga/include/mach/base_addr_a10.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm/mach-socfpga/include/mach/base_addr_a10.h +7 -1
index a7056d4..448fbdc 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Altera Corporation <www.altera.com>
+ * Copyright (C) 2014-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -29,14 +29,20 @@
 #define SOCFPGA_MPUL2_ADDRESS			0xfffff000
 #define SOCFPGA_I2C0_ADDRESS			0xffc02200
 #define SOCFPGA_I2C1_ADDRESS			0xffc02300
+#define SOCFPGA_I2C2_ADDRESS			0xffc02400
+#define SOCFPGA_I2C3_ADDRESS			0xffc02500
+#define SOCFPGA_I2C4_ADDRESS			0xffc02600
 
 #define SOCFPGA_ECC_OCRAM_ADDRESS		0xff8c3000
 #define SOCFPGA_UART0_ADDRESS			0xffc02000
 #define SOCFPGA_OSC1TIMER0_ADDRESS		0xffd00000
+#define SOCFPGA_OSC1TIMER1_ADDRESS		0xffd00100
 #define SOCFPGA_CLKMGR_ADDRESS			0xffd04000
 #define SOCFPGA_RSTMGR_ADDRESS			0xffd05000
 
 #define SOCFPGA_SDR_ADDRESS			0xffcfb000
+#define SOCFPGA_NOC_L4_PRIV_FLT_OFST		0xffd11000
+#define SOCFPGA_NOC_FW_H2F_SCR_OFST		0xffd13500
 #define SOCFPGA_SDR_SCHEDULER_ADDRESS		0xffd12400
 #define SOCFPGA_SDR_FIREWALL_OCRAM_ADDRESS	0xffd13200
 #define SOCFPGA_SDR_FIREWALL_MPU_FPGA_ADDRESS	0xffd13300
Signature · 2 lines
Best regards,
Marek Vasut
#17 lore raw

PATCH v2 7/20 arm: socfpga: Add reset driver support for Arria 10

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

Add reset driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |   2 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           | 143 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 362 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 612 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/reset_manager_arria10.c
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h
arch/arm/mach-socfpga/Makefile +2 -0
index e83da2e..d81f003 100644
@@ -10,6 +10,8 @@
 obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
index 9e253bf..57dc034 100644
@@ -45,6 +45,8 @@ void socfpga_per_reset_all(void);
 
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/reset_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/reset_manager_arria10.h>
 #endif
 
 #endif /* _RESET_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +6 -0
new file mode 100644
index 0000000..e3171d1
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+

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

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +10 -0
+#ifndef _RESET_MANAGER_ARRIA10_H_
+#define _RESET_MANAGER_ARRIA10_H_
+
+void watchdog_disable(void);
+void reset_deassert_noc_ddr_scheduler(void);
+int is_wdt_in_reset(void);
+void emac_manage_reset(ulong emacbase, uint state);
+int reset_deassert_bridges_handoff(void);
+void reset_assert_fpga_connected_peripherals(void);
+void reset_deassert_osc1wd0(void);

Nit, it'd be nice to prefix all exported functions with socfpga_ , so it's obvious where they come from if you debug u-boot .

Quoted 460 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +126 -0
+struct socfpga_reset_manager {
+	u32	stat;
+	u32	ramstat;
+	u32	miscstat;
+	u32	ctrl;
+	u32	hdsken;
+	u32	hdskreq;
+	u32	hdskack;
+	u32	counts;
+	u32	mpumodrst;
+	u32	per0modrst;
+	u32	per1modrst;
+	u32	brgmodrst;
+	u32	sysmodrst;
+	u32	coldmodrst;
+	u32	nrstmodrst;
+	u32	dbgmodrst;
+	u32	mpuwarmmask;
+	u32	per0warmmask;
+	u32	per1warmmask;
+	u32	brgwarmmask;
+	u32	syswarmmask;
+	u32	nrstwarmmask;
+	u32	l3warmmask;
+	u32	tststa;
+	u32	tstscratch;
+	u32	hdsktimeout;
+	u32	hmcintr;
+	u32	hmcintren;
+	u32	hmcintrens;
+	u32	hmcintrenr;
+	u32	hmcgpout;
+	u32	hmcgpin;
+};
+
+/*
+ * SocFPGA Arria10 reset IDs, bank mapping is as follows:
+ * 0 ... mpumodrst
+ * 1 ... per0modrst
+ * 2 ... per1modrst
+ * 3 ... brgmodrst
+ * 4 ... sysmodrst
+ */
+#define RSTMGR_EMAC0		RSTMGR_DEFINE(1, 0)
+#define RSTMGR_EMAC1		RSTMGR_DEFINE(1, 1)
+#define RSTMGR_EMAC2		RSTMGR_DEFINE(1, 2)
+#define RSTMGR_NAND		RSTMGR_DEFINE(1, 5)
+#define RSTMGR_QSPI		RSTMGR_DEFINE(1, 6)
+#define RSTMGR_SDMMC		RSTMGR_DEFINE(1, 7)
+#define RSTMGR_DMA		RSTMGR_DEFINE(1, 16)
+#define RSTMGR_SPIM0		RSTMGR_DEFINE(1, 17)
+#define RSTMGR_SPIM1		RSTMGR_DEFINE(1, 18)
+#define RSTMGR_L4WD0		RSTMGR_DEFINE(2, 0)
+#define RSTMGR_L4WD1		RSTMGR_DEFINE(2, 1)
+#define RSTMGR_L4SYSTIMER0	RSTMGR_DEFINE(2, 2)
+#define RSTMGR_L4SYSTIMER1	RSTMGR_DEFINE(2, 3)
+#define RSTMGR_SPTIMER0		RSTMGR_DEFINE(2, 4)
+#define RSTMGR_SPTIMER1		RSTMGR_DEFINE(2, 5)
+#define RSTMGR_UART0		RSTMGR_DEFINE(2, 16)
+#define RSTMGR_UART1		RSTMGR_DEFINE(2, 17)
+#define RSTMGR_DDRSCH		RSTMGR_DEFINE(3, 6)
+
+#define ALT_RSTMGR_CTL_SWWARMRSTREQ_SET_MSK	BIT(1)
+#define ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK	BIT(0)
+#define ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK	BIT(1)
+#define ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK	BIT(2)
+#define ALT_RSTMGR_PER0MODRST_USB0_SET_MSK	BIT(3)
+#define ALT_RSTMGR_PER0MODRST_USB1_SET_MSK	BIT(4)
+#define ALT_RSTMGR_PER0MODRST_NAND_SET_MSK	BIT(5)
+#define ALT_RSTMGR_PER0MODRST_QSPI_SET_MSK	BIT(6)
+#define ALT_RSTMGR_PER0MODRST_SDMMC_SET_MSK	BIT(7)
+#define ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK	BIT(8)
+#define ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK	BIT(9)
+#define ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK	BIT(10)
+#define ALT_RSTMGR_PER0MODRST_USBECC0_SET_MSK	BIT(11)
+#define ALT_RSTMGR_PER0MODRST_USBECC1_SET_MSK	BIT(12)
+#define ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK	BIT(13)
+#define ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK	BIT(14)
+#define ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK	BIT(15)
+#define ALT_RSTMGR_PER0MODRST_DMA_SET_MSK	BIT(16)
+#define ALT_RSTMGR_PER0MODRST_SPIM0_SET_MSK	BIT(17)
+#define ALT_RSTMGR_PER0MODRST_SPIM1_SET_MSK	BIT(18)
+#define ALT_RSTMGR_PER0MODRST_SPIS0_SET_MSK	BIT(19)
+#define ALT_RSTMGR_PER0MODRST_SPIS1_SET_MSK	BIT(20)
+#define ALT_RSTMGR_PER0MODRST_DMAECC_SET_MSK	BIT(21)
+#define ALT_RSTMGR_PER0MODRST_EMACPTP_SET_MSK	BIT(22)
+#define ALT_RSTMGR_PER0MODRST_DMAIF0_SET_MSK	BIT(24)
+#define ALT_RSTMGR_PER0MODRST_DMAIF1_SET_MSK	BIT(25)
+#define ALT_RSTMGR_PER0MODRST_DMAIF2_SET_MSK	BIT(26)
+#define ALT_RSTMGR_PER0MODRST_DMAIF3_SET_MSK	BIT(27)
+#define ALT_RSTMGR_PER0MODRST_DMAIF4_SET_MSK	BIT(28)
+#define ALT_RSTMGR_PER0MODRST_DMAIF5_SET_MSK	BIT(29)
+#define ALT_RSTMGR_PER0MODRST_DMAIF6_SET_MSK	BIT(30)
+#define ALT_RSTMGR_PER0MODRST_DMAIF7_SET_MSK	BIT(31)
+
+#define ALT_RSTMGR_PER1MODRST_WD0_SET_MSK	BIT(0)
+#define ALT_RSTMGR_PER1MODRST_WD1_SET_MSK	BIT(1)
+#define ALT_RSTMGR_PER1MODRST_L4SYSTMR0_SET_MSK	BIT(2)
+#define ALT_RSTMGR_PER1MODRST_L4SYSTMR1_SET_MSK	BIT(3)
+#define ALT_RSTMGR_PER1MODRST_SPTMR0_SET_MSK	BIT(4)
+#define ALT_RSTMGR_PER1MODRST_SPTMR1_SET_MSK	BIT(5)
+#define ALT_RSTMGR_PER1MODRST_I2C0_SET_MSK	BIT(8)
+#define ALT_RSTMGR_PER1MODRST_I2C1_SET_MSK	BIT(9)
+#define ALT_RSTMGR_PER1MODRST_I2C2_SET_MSK	BIT(10)
+#define ALT_RSTMGR_PER1MODRST_I2C3_SET_MSK	BIT(11)
+#define ALT_RSTMGR_PER1MODRST_I2C4_SET_MSK	BIT(12)
+#define ALT_RSTMGR_PER1MODRST_UART0_SET_MSK	BIT(16)
+#define ALT_RSTMGR_PER1MODRST_UART1_SET_MSK	BIT(17)
+#define ALT_RSTMGR_PER1MODRST_GPIO0_SET_MSK	BIT(24)
+#define ALT_RSTMGR_PER1MODRST_GPIO1_SET_MSK	BIT(25)
+#define ALT_RSTMGR_PER1MODRST_GPIO2_SET_MSK	BIT(26)
+
+#define ALT_RSTMGR_BRGMODRST_H2F_SET_MSK	BIT(0)
+#define ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK	BIT(1)
+#define ALT_RSTMGR_BRGMODRST_F2H_SET_MSK	BIT(2)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK	BIT(3)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK	BIT(4)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK	BIT(5)
+#define ALT_RSTMGR_BRGMODRST_DDRSCH_SET_MSK	BIT(6)
+
+#define ALT_RSTMGR_HDSKEN_SDRSELFREFEN_SET_MSK	BIT(0)
+#define ALT_RSTMGR_HDSKEN_FPGAMGRHSEN_SET_MSK	BIT(1)
+#define ALT_RSTMGR_HDSKEN_FPGAHSEN_SET_MSK	BIT(2)
+#define ALT_RSTMGR_HDSKEN_ETRSTALLEN_SET_MSK	BIT(3)
+
+#endif /* _RESET_MANAGER_ARRIA10_H_ */
arch/arm/mach-socfpga/reset_manager_arria10.c new file +328 -0
new file mode 100644
index 0000000..547a8bb
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/io.h>
+#include <asm/arch/fpga_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <wait_bit.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_reset_manager *reset_manager_base =
+		(void *)SOCFPGA_RSTMGR_ADDRESS;
+static const struct socfpga_system_manager *sysmgr_regs =
+		(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+#define ECC_MASK (ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK | \
+	ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK | \
+	ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK | \
+	ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK | \
+	ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
+	ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)
+
+static const u32 per0fpgamasks[] = {
+	ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK,
+	0, /* i2c0 per1mod */
+	0, /* i2c1 per1mod */
+	0, /* i2c0_emac */
+	0, /* i2c1_emac */
+	0, /* i2c2_emac */
+	ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_NAND_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_QSPI_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK |
+	ALT_RSTMGR_PER0MODRST_SDMMC_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_SPIM0_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_SPIM1_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_SPIS0_SET_MSK,
+	ALT_RSTMGR_PER0MODRST_SPIS1_SET_MSK,
+	0, /* uart0 per1mod */
+	0, /* uart1 per1mod */
+};
+
+static const u32 per1fpgamasks[] = {
+	0, /* emac0 per0mod */
+	0, /* emac1 per0mod */
+	0, /* emac2 per0mod */
+	ALT_RSTMGR_PER1MODRST_I2C0_SET_MSK,
+	ALT_RSTMGR_PER1MODRST_I2C1_SET_MSK,
+	ALT_RSTMGR_PER1MODRST_I2C2_SET_MSK, /* i2c0_emac */
+	ALT_RSTMGR_PER1MODRST_I2C3_SET_MSK, /* i2c1_emac */
+	ALT_RSTMGR_PER1MODRST_I2C4_SET_MSK, /* i2c2_emac */
+	0, /* nand per0mod */
+	0, /* qspi per0mod */
+	0, /* sdmmc per0mod */
+	0, /* spim0 per0mod */
+	0, /* spim1 per0mod */
+	0, /* spis0 per0mod */
+	0, /* spis1 per0mod */
+	ALT_RSTMGR_PER1MODRST_UART0_SET_MSK,
+	ALT_RSTMGR_PER1MODRST_UART1_SET_MSK,
+};
+
+struct bridge_cfg {
+	int compat_id;
+	u32  mask_noc;
+	u32  mask_rstmgr;
+};
+
+static const struct bridge_cfg bridge_cfg_tbl[] = {
+	{
+		COMPAT_ALTERA_SOCFPGA_H2F_BRG,
+		ALT_SYSMGR_NOC_H2F_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_H2F_SET_MSK,
+	},
+	{
+		COMPAT_ALTERA_SOCFPGA_LWH2F_BRG,
+		ALT_SYSMGR_NOC_LWH2F_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK,
+	},
+	{
+		COMPAT_ALTERA_SOCFPGA_F2H_BRG,
+		ALT_SYSMGR_NOC_F2H_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_F2H_SET_MSK,
+	},
+	{
+		COMPAT_ALTERA_SOCFPGA_F2SDR0,
+		ALT_SYSMGR_NOC_F2SDR0_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK,
+	},
+	{
+		COMPAT_ALTERA_SOCFPGA_F2SDR1,
+		ALT_SYSMGR_NOC_F2SDR1_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK,
+	},
+	{
+		COMPAT_ALTERA_SOCFPGA_F2SDR2,
+		ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+		ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK,
+	},
+};
+
+/* Disable the watchdog (toggle reset to watchdog) */
+void watchdog_disable(void)
+{
+	/* assert reset for watchdog */
+	setbits_le32(&reset_manager_base->per1modrst,
+		     ALT_RSTMGR_PER1MODRST_WD0_SET_MSK);
+}
+
+/* Release NOC ddr scheduler from reset */
+void reset_deassert_noc_ddr_scheduler(void)
+{
+	clrbits_le32(&reset_manager_base->brgmodrst,
+		     ALT_RSTMGR_BRGMODRST_DDRSCH_SET_MSK);
+}
+
+/* Check whether Watchdog in reset state? */
+int is_wdt_in_reset(void)
+{
+	u32 val;
+
+	val = readl(&reset_manager_base->per1modrst);
+	val &= ALT_RSTMGR_PER1MODRST_WD0_SET_MSK;
+
+	/* return 0x1 if watchdog in reset */
+	return val;
+}
+
+/* emacbase: base address of emac to enable/disable reset
+ * state: 0 - disable reset, !0 - enable reset
+ */
+void emac_manage_reset(ulong emacbase, uint state)
+{
+	ulong eccmask;
+	ulong emacmask;
+
+	switch (emacbase) {
+	case SOCFPGA_EMAC0_ADDRESS:
+		eccmask = ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK;
+		emacmask = ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK;
+		break;
+	case SOCFPGA_EMAC1_ADDRESS:
+		eccmask = ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK;
+		emacmask = ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK;
+		break;
+	case SOCFPGA_EMAC2_ADDRESS:
+		eccmask = ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK;
+		emacmask = ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK;
+		break;
+	default:
+		error("emac base address unexpected! %lx", emacbase);
+		hang();
+		break;
+	}
+
+	if (state) {
+		/* Enable ECC OCP first */
+		setbits_le32(&reset_manager_base->per0modrst, eccmask);
+		setbits_le32(&reset_manager_base->per0modrst, emacmask);
+	} else {
+		/* Disable ECC OCP first */
+		clrbits_le32(&reset_manager_base->per0modrst, emacmask);
+		clrbits_le32(&reset_manager_base->per0modrst, eccmask);
+	}
+}
+
+static int get_bridge_init_val(const void *blob, int compat_id)
+{
+	int node;
+
+	node = fdtdec_next_compatible(blob, 0, compat_id);
+	if (node < 0)
+		return 0;
+
+	return fdtdec_get_uint(blob, node, "init-val", 0);
+}
+
+/* Enable bridges (hps2fpga, lwhps2fpga, fpga2hps, fpga2sdram) per handoff */
+int reset_deassert_bridges_handoff(void)
+{
+	u32 mask_noc = 0, mask_rstmgr = 0;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(bridge_cfg_tbl); i++) {
+		if (get_bridge_init_val(gd->fdt_blob,
+					bridge_cfg_tbl[i].compat_id)) {
+			mask_noc |= bridge_cfg_tbl[i].mask_noc;
+			mask_rstmgr |= bridge_cfg_tbl[i].mask_rstmgr;
+		}
+	}
+
+	/* clear idle request to all bridges */
+	setbits_le32(&sysmgr_regs->noc_idlereq_clr, mask_noc);
+
+	/* Release bridges from reset state per handoff value */
+	clrbits_le32(&reset_manager_base->brgmodrst, mask_rstmgr);
+
+	/* Poll until all idleack to 0, timeout at 1000ms */
+	return wait_for_bit(__func__, &sysmgr_regs->noc_idleack, mask_noc,
+			    false, 1000, false);
+}
+
+void reset_assert_fpga_connected_peripherals(void)
+{
+	u32 mask0 = 0;
+	u32 mask1 = 0;
+	u32 fpga_pinux_addr = SOCFPGA_PINMUX_FPGA_INTERFACE_ADDRESS;
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(per1fpgamasks); i++) {
+		if (readl(fpga_pinux_addr)) {
+			mask0 |= per0fpgamasks[i];
+			mask1 |= per1fpgamasks[i];
+		}
+		fpga_pinux_addr += sizeof(u32);
+	}
+
+	setbits_le32(&reset_manager_base->per0modrst, mask0 & ECC_MASK);
+	setbits_le32(&reset_manager_base->per1modrst, mask1);
+	setbits_le32(&reset_manager_base->per0modrst, mask0);
+}
+
+/* Release L4 OSC1 Watchdog Timer 0 from reset through reset manager */
+void reset_deassert_osc1wd0(void)
+{
+	clrbits_le32(&reset_manager_base->per1modrst,
+		     ALT_RSTMGR_PER1MODRST_WD0_SET_MSK);
+}
+
+/*
+ * 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->mpumodrst;
+		break;
+	case 1:
+		reg = &reset_manager_base->per0modrst;
+		break;
+	case 2:
+		reg = &reset_manager_base->per1modrst;
+		break;
+	case 3:
+		reg = &reset_manager_base->brgmodrst;
+		break;
+	case 4:
+		reg = &reset_manager_base->sysmodrst;
+		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
+ * and/or hangs.
+ * For the Arria10, we disable all the peripherals except L4 watchdog0,
+ * L4 Timer 0, and ECC.
+ */
+void socfpga_per_reset_all(void)
+{
+	const u32 l4wd0 = (1 << RSTMGR_RESET(SOCFPGA_RESET(L4WD0)) |
+			  (1 << RSTMGR_RESET(SOCFPGA_RESET(L4SYSTIMER0))));
+	unsigned mask_ecc_ocp =
+		ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_USBECC0_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_USBECC1_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK |
+		ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK;
+
+	/* disable all components except ECC_OCP, L4 Timer0 and L4 WD0 */
+	writel(~l4wd0, &reset_manager_base->per1modrst);
+	setbits_le32(&reset_manager_base->per0modrst, ~mask_ecc_ocp);
+
+	/* Finally disable the ECC_OCP */
+	setbits_le32(&reset_manager_base->per0modrst, mask_ecc_ocp);
+}
+
+#if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
+void socfpga_bridges_reset(int enable)
+{
+	/* For SoCFPGA-VT, this is NOP. */
+}
+#else
+void socfpga_bridges_reset(int enable)
+{
+	/* Disable all the bridges (hps2fpga, lwhps2fpga, fpga2hps,
+	   fpga2sdram) */
+	/* set idle request to all bridges */
+	writel(ALT_SYSMGR_NOC_H2F_SET_MSK |
+		ALT_SYSMGR_NOC_LWH2F_SET_MSK |
+		ALT_SYSMGR_NOC_F2H_SET_MSK |
+		ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+		ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+		ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+		&sysmgr_regs->noc_idlereq_set);
+
+	/* Enable the NOC timeout */
+	writel(ALT_SYSMGR_NOC_TMO_EN_SET_MSK, &sysmgr_regs->noc_timeout);

arch/arm/mach-socfpga/reset_manager_arria10.c line 338

Quoted 10 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +10 -0
+
+	/* Poll until all idleack to 1 */
+	wait_for_bit(__func__, &sysmgr_regs->noc_idleack,
+		     ALT_SYSMGR_NOC_H2F_SET_MSK |
+		     ALT_SYSMGR_NOC_LWH2F_SET_MSK |
+		     ALT_SYSMGR_NOC_F2H_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+		     true, 10000, false);

You should check return value of all these wait_for_bit() calls, otherwise you might ignore errors.

Quoted 133 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +23 -0
+	/* Poll until all idlestatus to 1 */
+	wait_for_bit(__func__, &sysmgr_regs->noc_idlestatus,
+		     ALT_SYSMGR_NOC_H2F_SET_MSK |
+		     ALT_SYSMGR_NOC_LWH2F_SET_MSK |
+		     ALT_SYSMGR_NOC_F2H_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+		     ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+		     true, 10000, false);
+
+	/* Put all bridges (except NOR DDR scheduler) into reset state */
+	setbits_le32(&reset_manager_base->brgmodrst,
+		     (ALT_RSTMGR_BRGMODRST_H2F_SET_MSK |
+		     ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK |
+		     ALT_RSTMGR_BRGMODRST_F2H_SET_MSK |
+		     ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK |
+		     ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK |
+		     ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK));
+
+	/* Disable NOC timeout */
+	writel(0, &sysmgr_regs->noc_timeout);
+}
+#endif
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +103 -0
new file mode 100644
index 0000000..99875de
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+#define _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+
+/* MPUMODRST */
+#define CPU0_RESET		0
+#define CPU1_RESET		1
+#define WDS_RESET		2
+#define SCUPER_RESET		3
+
+/* PER0MODRST */
+#define EMAC0_RESET		32
+#define EMAC1_RESET		33
+#define EMAC2_RESET		34
+#define USB0_RESET		35
+#define USB1_RESET		36
+#define NAND_RESET		37
+#define QSPI_RESET		38
+#define SDMMC_RESET		39
+#define EMAC0_OCP_RESET		40
+#define EMAC1_OCP_RESET		41
+#define EMAC2_OCP_RESET		42
+#define USB0_OCP_RESET		43
+#define USB1_OCP_RESET		44
+#define NAND_OCP_RESET		45
+#define QSPI_OCP_RESET		46
+#define SDMMC_OCP_RESET		47
+#define DMA_RESET		48
+#define SPIM0_RESET		49
+#define SPIM1_RESET		50
+#define SPIS0_RESET		51
+#define SPIS1_RESET		52
+#define DMA_OCP_RESET		53
+#define EMAC_PTP_RESET		54
+/* 55 is empty*/
+#define DMAIF0_RESET		56
+#define DMAIF1_RESET		57
+#define DMAIF2_RESET		58
+#define DMAIF3_RESET		59
+#define DMAIF4_RESET		60
+#define DMAIF5_RESET		61
+#define DMAIF6_RESET		62
+#define DMAIF7_RESET		63
+
+/* PER1MODRST */
+#define L4WD0_RESET		64
+#define L4WD1_RESET		65
+#define L4SYSTIMER0_RESET	66
+#define L4SYSTIMER1_RESET	67
+#define SPTIMER0_RESET		68
+#define SPTIMER1_RESET		69
+/* 70-71 is reserved */
+#define I2C0_RESET		72
+#define I2C1_RESET		73
+#define I2C2_RESET		74
+#define I2C3_RESET		75
+#define I2C4_RESET		76
+/* 77-79 is reserved */
+#define UART0_RESET		80
+#define UART1_RESET		81
+/* 82-87 is reserved */
+#define GPIO0_RESET		88
+#define GPIO1_RESET		89
+#define GPIO2_RESET		90
+
+/* BRGMODRST */
+#define HPS2FPGA_RESET		96
+#define LWHPS2FPGA_RESET	97
+#define FPGA2HPS_RESET		98
+#define F2SSDRAM0_RESET		99
+#define F2SSDRAM1_RESET		100
+#define F2SSDRAM2_RESET		101
+#define DDRSCH_RESET		102
+
+/* SYSMODRST*/
+#define ROM_RESET		128
+#define OCRAM_RESET		129
+/* 130 is reserved */
+#define FPGAMGR_RESET		131
+#define S2F_RESET		132
+#define SYSDBG_RESET		133
+#define OCRAM_OCP_RESET		134
+
+/* COLDMODRST */
+#define CLKMGRCOLD_RESET	160
+/* 161-162 is reserved */
+#define S2FCOLD_RESET		163
+#define TIMESTAMPCOLD_RESET	164
+#define TAPCOLD_RESET		165
+#define HMCCOLD_RESET		166
+#define IOMGRCOLD_RESET		167
+
+/* NRSTMODRST */
+#define NRSTPINOE_RESET		192
+
+/* DBGMODRST */
+#define DBG_RESET		224
+#endif
Signature · 2 lines
Best regards,
Marek Vasut
#20 lore raw

PATCH v2 8/20 arm: socfpga: Add clock driver for Arria 10

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

Add clock driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |    3 +-
 arch/arm/mach-socfpga/clock_manager.c              |   18 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1104 ++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    6 +
 .../include/mach/clock_manager_arria10.h           |  222 ++++
 5 files changed, 1350 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_arria10.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h
arch/arm/mach-socfpga/Makefile +2 -1
index d81f003..c494930 100644
@@ -10,7 +10,8 @@
 obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
-obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
+					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
arch/arm/mach-socfpga/clock_manager.c +7 -0
index c2af6f3..ad602c8 100644
@@ -5,6 +5,8 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
+#include <wait_bit.h>
 #include <asm/io.h>
 #include <asm/arch/clock_manager.h>
 
@@ -18,7 +20,12 @@ void cm_wait_for_lock(u32 mask)
 	u32 inter_val;
 	u32 retry = 0;
 	do {
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 		inter_val = readl(&clock_manager_base->inter) & mask;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+		inter_val = readl(&clock_manager_base->stat) & mask;
+#endif
+		/* Wait for stable lock */
 		if (inter_val == mask)
 			retry++;
 		else

arch/arm/mach-socfpga/clock_manager.c void cm_wait_for_lock(u32 mask) · line 43

Quoted 8 lines
arch/arm/mach-socfpga/clock_manager.c +3 -2
@@ -31,8 +38,10 @@ void cm_wait_for_lock(u32 mask)
 /* function to poll in the fsm busy bit */
 void cm_wait_for_fsm(void)
 {
-	while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY)
-		;
+	wait_for_bit(__func__, (const u32 *)&clock_manager_base->stat,
+		     CLKMGR_CLKMGR_STAT_BUSY_SET_MSK,
+		     false, 20000, false);

Please do test this change on CV or AV if you didn't already.

Quoted 232 lines
arch/arm/mach-socfpga/clock_manager.c +6 -0
+
 }
 
 int set_cpu_clk_info(void)
@@ -43,7 +52,12 @@ int set_cpu_clk_info(void)
 
 	gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000;
 	gd->bd->bi_dsp_freq = 0;
+
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+	gd->bd->bi_ddr_freq = 0;
+#endif
 
 	return 0;
 }
arch/arm/mach-socfpga/clock_manager_arria10.c new file +209 -0
new file mode 100644
index 0000000..67b3e58
@@ -0,0 +1,1104 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <asm/io.h>
+#include <asm/arch/clock_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static u32 eosc1_hz;
+static u32 cb_intosc_hz;
+static u32 f2s_free_hz;
+static u32 cm_l4_main_clk_hz;
+static u32 cm_l4_sp_clk_hz;
+static u32 cm_l4_mp_clk_hz;
+static u32 cm_l4_sys_free_clk_hz;
+
+struct mainpll_cfg {
+	u32 vco0_psrc;
+	u32 vco1_denom;
+	u32 vco1_numer;
+	u32 mpuclk;
+	u32 mpuclk_cnt;
+	u32 mpuclk_src;
+	u32 nocclk;
+	u32 nocclk_cnt;
+	u32 nocclk_src;
+	u32 cntr2clk_cnt;
+	u32 cntr3clk_cnt;
+	u32 cntr4clk_cnt;
+	u32 cntr5clk_cnt;
+	u32 cntr6clk_cnt;
+	u32 cntr7clk_cnt;
+	u32 cntr7clk_src;
+	u32 cntr8clk_cnt;
+	u32 cntr9clk_cnt;
+	u32 cntr9clk_src;
+	u32 cntr15clk_cnt;
+	u32 nocdiv_l4mainclk;
+	u32 nocdiv_l4mpclk;
+	u32 nocdiv_l4spclk;
+	u32 nocdiv_csatclk;
+	u32 nocdiv_cstraceclk;
+	u32 nocdiv_cspdbclk;
+};
+
+struct perpll_cfg {
+	u32 vco0_psrc;
+	u32 vco1_denom;
+	u32 vco1_numer;
+	u32 cntr2clk_cnt;
+	u32 cntr2clk_src;
+	u32 cntr3clk_cnt;
+	u32 cntr3clk_src;
+	u32 cntr4clk_cnt;
+	u32 cntr4clk_src;
+	u32 cntr5clk_cnt;
+	u32 cntr5clk_src;
+	u32 cntr6clk_cnt;
+	u32 cntr6clk_src;
+	u32 cntr7clk_cnt;
+	u32 cntr8clk_cnt;
+	u32 cntr8clk_src;
+	u32 cntr9clk_cnt;
+	u32 emacctl_emac0sel;
+	u32 emacctl_emac1sel;
+	u32 emacctl_emac2sel;
+	u32 gpiodiv_gpiodbclk;
+};
+
+struct alteragrp_cfg {
+	u32 nocclk;
+	u32 mpuclk;
+};
+
+static const struct socfpga_clock_manager *clock_manager_base =
+	(struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
+
+static int of_to_struct(const void *blob, int node, int cfg_len, void *cfg)
+{
+	if (fdtdec_get_int_array(blob, node, "altr,of_reg_value",
+				 (u32 *)cfg, cfg_len)) {
+		/* could not find required property */
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int of_get_input_clks(const void *blob, int node, u32 *val)
+{
+	*val = fdtdec_get_uint(blob, node, "clock-frequency", 0);
+	if (!*val)
+		return -EINVAL;
+
+	return 0;
+}
+
+static int of_get_clk_cfg(const void *blob, struct mainpll_cfg *main_cfg,
+			  struct perpll_cfg *per_cfg,
+			  struct alteragrp_cfg *altrgrp_cfg)
+{
+	int node, child, len;
+	const char *node_name;
+
+	node = fdtdec_next_compatible(blob, 0, COMPAT_ALTERA_SOCFPGA_CLK);
+	if (node < 0)
+		return -EINVAL;
+
+	child = fdt_first_subnode(blob, node);
+	if (child < 0)
+		return -EINVAL;
+
+	child = fdt_first_subnode(blob, child);
+	if (child < 0)
+		return -EINVAL;
+
+	node_name = fdt_get_name(blob, child, &len);
+
+	while (node_name) {
+		if (!strcmp(node_name, "osc1")) {
+			if (of_get_input_clks(blob, child, &eosc1_hz))
+				return -EINVAL;
+		} else if (!strcmp(node_name, "cb_intosc_ls_clk")) {
+			if (of_get_input_clks(blob, child, &cb_intosc_hz))
+				return -EINVAL;
+		} else if (!strcmp(node_name, "f2s_free_clk")) {
+			if (of_get_input_clks(blob, child, &f2s_free_hz))
+				return -EINVAL;
+		} else if (!strcmp(node_name, "main_pll")) {
+			if (of_to_struct(blob, child,
+					 sizeof(*main_cfg)/sizeof(u32),
+					 main_cfg))
+				return -EINVAL;
+		} else if (!strcmp(node_name, "periph_pll")) {
+			if (of_to_struct(blob, child,
+					 sizeof(*per_cfg)/sizeof(u32),
+					 per_cfg))
+				return -EINVAL;
+		} else if (!strcmp(node_name, "altera")) {
+			if (of_to_struct(blob, child,
+					 sizeof(*altrgrp_cfg)/sizeof(u32),
+					 altrgrp_cfg))
+				return -EINVAL;
+
+			main_cfg->mpuclk = altrgrp_cfg->mpuclk;
+			main_cfg->nocclk = altrgrp_cfg->nocclk;
+		}
+		child = fdt_next_subnode(blob, child);
+
+		if (child < 0)
+			break;
+
+		node_name = fdt_get_name(blob, child, &len);
+	}
+
+	return 0;
+}
+
+/* calculate the intended main VCO frequency based on handoff */
+static unsigned int cm_calc_handoff_main_vco_clk_hz
+					(struct mainpll_cfg *main_cfg)
+{
+	unsigned int clk_hz;
+
+	/* Check main VCO clock source: eosc, intosc or f2s? */
+	switch (main_cfg->vco0_psrc) {
+	case CLKMGR_MAINPLL_VCO0_PSRC_EOSC:
+		clk_hz = eosc1_hz;
+		break;
+	case CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC:
+		clk_hz = cb_intosc_hz;
+		break;
+	case CLKMGR_MAINPLL_VCO0_PSRC_F2S:
+		clk_hz = f2s_free_hz;
+		break;
+	default:
+		return 0;
+	}
+
+	/* calculate the VCO frequency */
+	clk_hz /= (1 + main_cfg->vco1_denom);
+	clk_hz *= (1 + main_cfg->vco1_numer);
+
+	return clk_hz;
+}
+
+/* calculate the intended periph VCO frequency based on handoff */
+static unsigned int cm_calc_handoff_periph_vco_clk_hz(
+		struct mainpll_cfg *main_cfg, struct perpll_cfg *per_cfg)
+{
+	unsigned int clk_hz;
+
+	/* Check periph VCO clock source: eosc, intosc, f2s or mainpll? */
+	switch (per_cfg->vco0_psrc) {
+	case CLKMGR_PERPLL_VCO0_PSRC_EOSC:
+		clk_hz = eosc1_hz;
+		break;
+	case CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC:
+		clk_hz = cb_intosc_hz;
+		break;
+	case CLKMGR_PERPLL_VCO0_PSRC_F2S:
+		clk_hz = f2s_free_hz;
+		break;
+	case CLKMGR_PERPLL_VCO0_PSRC_MAIN:

arch/arm/mach-socfpga/clock_manager_arria10.c line 219

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+		clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+		clk_hz /= main_cfg->cntr15clk_cnt;
+		break;
+	default:
+		return 0;
+	}
+
+	/* calculate the VCO frequency */
+	clk_hz /= (1 + per_cfg->vco1_denom);
+	clk_hz *= (1 + per_cfg->vco1_numer);

Extra parenthesis around statement not needed, fix globally.

Quoted 5 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +5 -0
+	return clk_hz;
+}
+
+/* calculate the intended MPU clock frequency based on handoff */
+static unsigned int cm_calc_handoff_mpu_clk_hz(struct mainpll_cfg *main_cfg,

arch/arm/mach-socfpga/clock_manager_arria10.c line 235

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+					       struct perpll_cfg *per_cfg)
+{
+	unsigned int clk_hz;
+
+	/* Check MPU clock source: main, periph, osc1, intosc or f2s? */
+	switch (main_cfg->mpuclk_src) {
+	case CLKMGR_MAINPLL_MPUCLK_SRC_MAIN:
+		clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+		clk_hz /= ((main_cfg->mpuclk & CLKMGR_MAINPLL_MPUCLK_CNT_MSK)
+			   + 1);

DTTO

arch/arm/mach-socfpga/clock_manager_arria10.c line 241

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+		break;
+	case CLKMGR_MAINPLL_MPUCLK_SRC_PERI:
+		clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg);
+		clk_hz /= (((main_cfg->mpuclk >>
+			   CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB) &
+			   CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1);

DTTO

Quoted 20 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +20 -0
+		break;
+	case CLKMGR_MAINPLL_MPUCLK_SRC_OSC1:
+		clk_hz = eosc1_hz;
+		break;
+	case CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC:
+		clk_hz = cb_intosc_hz;
+		break;
+	case CLKMGR_MAINPLL_MPUCLK_SRC_FPGA:
+		clk_hz = f2s_free_hz;
+		break;
+	default:
+		return 0;
+	}
+
+	clk_hz /= (main_cfg->mpuclk_cnt + 1);
+	return clk_hz;
+}
+
+/* calculate the intended NOC clock frequency based on handoff */
+static unsigned int cm_calc_handoff_noc_clk_hz(struct mainpll_cfg *main_cfg,

arch/arm/mach-socfpga/clock_manager_arria10.c line 271

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+					       struct perpll_cfg *per_cfg)
+{
+	unsigned int clk_hz;
+
+	/* Check MPU clock source: main, periph, osc1, intosc or f2s? */
+	switch (main_cfg->nocclk_src) {
+	case CLKMGR_MAINPLL_NOCCLK_SRC_MAIN:
+		clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+		clk_hz /= ((main_cfg->nocclk & CLKMGR_MAINPLL_NOCCLK_CNT_MSK)
+			   + 1);

DTTO

arch/arm/mach-socfpga/clock_manager_arria10.c line 277

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+		break;
+	case CLKMGR_MAINPLL_NOCCLK_SRC_PERI:
+		clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg);
+		clk_hz /= (((main_cfg->nocclk >>
+			   CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB) &
+			   CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1);

DTTO

Quoted 112 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +112 -0
+		break;
+	case CLKMGR_MAINPLL_NOCCLK_SRC_OSC1:
+		clk_hz = eosc1_hz;
+		break;
+	case CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC:
+		clk_hz = cb_intosc_hz;
+		break;
+	case CLKMGR_MAINPLL_NOCCLK_SRC_FPGA:
+		clk_hz = f2s_free_hz;
+		break;
+	default:
+		return 0;
+	}
+
+	clk_hz /= (main_cfg->nocclk_cnt + 1);
+	return clk_hz;
+}
+
+/* return 1 if PLL ramp is required */
+static int cm_is_pll_ramp_required(int main0periph1,
+				   struct mainpll_cfg *main_cfg,
+				   struct perpll_cfg *per_cfg)
+{
+	/* Check for main PLL */
+	if (main0periph1 == 0) {
+		/*
+		 * PLL ramp is not required if both MPU clock and NOC clock are
+		 * not sourced from main PLL
+		 */
+		if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_MAIN &&
+		    main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_MAIN)
+			return 0;
+
+		/*
+		 * PLL ramp is required if MPU clock is sourced from main PLL
+		 * and MPU clock is over 900MHz (as advised by HW team)
+		 */
+		if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN &&
+		    (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) >
+		     CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ))
+			return 1;
+
+		/*
+		 * PLL ramp is required if NOC clock is sourced from main PLL
+		 * and NOC clock is over 300MHz (as advised by HW team)
+		 */
+		if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_MAIN &&
+		    (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) >
+		     CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ))
+			return 2;
+
+	} else if (main0periph1 == 1) {
+		/*
+		 * PLL ramp is not required if both MPU clock and NOC clock are
+		 * not sourced from periph PLL
+		 */
+		if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_PERI &&
+		    main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_PERI)
+			return 0;
+
+		/*
+		 * PLL ramp is required if MPU clock are source from periph PLL
+		 * and MPU clock is over 900MHz (as advised by HW team)
+		 */
+		if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI &&
+		    (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) >
+		     CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ))
+			return 1;
+
+		/*
+		 * PLL ramp is required if NOC clock are source from periph PLL
+		 * and NOC clock is over 300MHz (as advised by HW team)
+		 */
+		if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_PERI &&
+		    (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) >
+		     CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ))
+			return 2;
+	}
+
+	return 0;
+}
+
+/*
+ * Calculate the new PLL numerator which is based on existing DTS hand off and
+ * intended safe frequency (safe_hz). Note that PLL ramp is only modifying the
+ * numerator while maintaining denominator as denominator will influence the
+ * jitter condition. Please refer A10 HPS TRM for the jitter guide. Note final
+ * value for numerator is minus with 1 to cater our register value
+ * representation.
+ */
+static unsigned int cm_calc_safe_pll_numer(int main0periph1,
+					   struct mainpll_cfg *main_cfg,
+					   struct perpll_cfg *per_cfg,
+					   unsigned int safe_hz)
+{
+	unsigned int clk_hz = 0;
+
+	/* Check for main PLL */
+	if (main0periph1 == 0) {
+		/* Check main VCO clock source: eosc, intosc or f2s? */
+		switch (main_cfg->vco0_psrc) {
+		case CLKMGR_MAINPLL_VCO0_PSRC_EOSC:
+			clk_hz = eosc1_hz;
+			break;
+		case CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC:
+			clk_hz = cb_intosc_hz;
+			break;
+		case CLKMGR_MAINPLL_VCO0_PSRC_F2S:
+			clk_hz = f2s_free_hz;
+			break;
+		default:
+			return 0;

arch/arm/mach-socfpga/clock_manager_arria10.c line 399

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+		}
+
+		/* Applicable if MPU clock is from main PLL */
+		if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN) {
+			/* calculate the safe numer value */
+			clk_hz = (safe_hz / clk_hz) *
+				(main_cfg->mpuclk_cnt + 1) *
+				((main_cfg->mpuclk &
+				  CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1) *
+				(1 + main_cfg->vco1_denom) - 1;

Maybe you can factor out this awful equation into a function somehow ?

Quoted 58 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +58 -0
+		}
+		/* Reach here if MPU clk not from main PLL but NOC clk is */
+		else if (main_cfg->nocclk_src ==
+			 CLKMGR_MAINPLL_NOCCLK_SRC_MAIN) {
+			/* calculate the safe numer value */
+			clk_hz = (safe_hz / clk_hz) *
+				(main_cfg->nocclk_cnt + 1) *
+				((main_cfg->nocclk &
+				  CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1) *
+				(1 + main_cfg->vco1_denom) - 1;
+		} else
+			clk_hz = 0;
+
+	} else if (main0periph1 == 1) {
+		/* Check periph VCO clock source: eosc, intosc, f2s, mainpll */
+		switch (per_cfg->vco0_psrc) {
+		case CLKMGR_PERPLL_VCO0_PSRC_EOSC:
+			clk_hz = eosc1_hz;
+			break;
+		case CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC:
+			clk_hz = cb_intosc_hz;
+			break;
+		case CLKMGR_PERPLL_VCO0_PSRC_F2S:
+			clk_hz = f2s_free_hz;
+			break;
+		case CLKMGR_PERPLL_VCO0_PSRC_MAIN:
+			clk_hz = cm_calc_handoff_main_vco_clk_hz(
+				 main_cfg);
+			clk_hz /= main_cfg->cntr15clk_cnt;
+			break;
+		default:
+			return 0;
+		}
+		/* Applicable if MPU clock is from periph PLL */
+		if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI) {
+			/* calculate the safe numer value */
+			clk_hz = (safe_hz / clk_hz) *
+				(main_cfg->mpuclk_cnt + 1) *
+				(((main_cfg->mpuclk >>
+				  CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB) &
+				  CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1) *
+				(1 + per_cfg->vco1_denom) - 1;
+		}
+		/* Reach here if MPU clk not from periph PLL but NOC clk is */
+		else if (main_cfg->nocclk_src ==
+			 CLKMGR_MAINPLL_NOCCLK_SRC_PERI) {
+			/* calculate the safe numer value */
+			clk_hz = (safe_hz / clk_hz) *
+				(main_cfg->nocclk_cnt + 1) *
+				(((main_cfg->nocclk >>
+				  CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB) &
+				  CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1) *
+				(1 + per_cfg->vco1_denom) - 1;
+		} else
+			clk_hz = 0;
+	}
+	return clk_hz;
+}

[...]

Quoted 29 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +29 -0
+unsigned int cm_get_per_vco_clk_hz(void)
+{
+	u32 src_hz = 0;
+	u32 clk_src = 0;
+	u32 numer = 0;
+	u32 denom = 0;
+	u32 vco = 0;
+
+	clk_src = readl(&clock_manager_base->per_pll.vco0);
+
+	clk_src = (clk_src >> CLKMGR_PERPLL_VCO0_PSRC_LSB) &
+		CLKMGR_PERPLL_VCO0_PSRC_MSK;
+
+	if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_EOSC) {
+		src_hz = eosc1_hz;
+	} else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC) {
+		src_hz = cb_intosc_hz;
+	} else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_F2S) {
+		src_hz = f2s_free_hz;
+	} else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_MAIN) {
+		src_hz = cm_get_main_vco_clk_hz();
+		src_hz /= (readl
+			(&clock_manager_base->main_pll.cntr15clk) &
+			CLKMGR_MAINPLL_CNTRCLK_MSK) + 1;
+	} else {
+		printf("cm_get_per_vco_clk_hz invalid clk_src %d\n", clk_src);
+		return 0;
+	}
+

arch/arm/mach-socfpga/clock_manager_arria10.c line 990

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+	vco = readl(&clock_manager_base->per_pll.vco1);
+
+	numer = vco & CLKMGR_PERPLL_VCO1_NUMER_MSK;
+
+	denom = (vco >> CLKMGR_PERPLL_VCO1_DENOM_LSB) &
+			CLKMGR_PERPLL_VCO1_DENOM_MSK;
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);

Extra parenthesis, not needed ...

Quoted 23 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +23 -0
+	return vco;
+}
+
+unsigned int cm_get_main_vco_clk_hz(void)
+{
+	u32 src_hz, numer, denom, vco;
+
+	u32 clk_src = readl(&clock_manager_base->main_pll.vco0);
+
+	clk_src = (clk_src >> CLKMGR_MAINPLL_VCO0_PSRC_LSB) &
+		CLKMGR_MAINPLL_VCO0_PSRC_MSK;
+
+	if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_EOSC) {
+		src_hz = eosc1_hz;
+	} else if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC) {
+		src_hz = cb_intosc_hz;
+	} else if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_F2S) {
+		src_hz = f2s_free_hz;
+	} else {
+		printf("cm_get_main_vco_clk_hz invalid clk_src %d\n", clk_src);
+		return 0;
+	}
+

arch/arm/mach-socfpga/clock_manager_arria10.c line 1024

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+	vco = readl(&clock_manager_base->main_pll.vco1);
+
+	numer = vco & CLKMGR_MAINPLL_VCO1_NUMER_MSK;
+
+	denom = (vco >> CLKMGR_MAINPLL_VCO1_DENOM_LSB) &
+			CLKMGR_MAINPLL_VCO1_DENOM_MSK;
+
+	vco = src_hz;
+	vco /= (1 + denom);
+	vco *= (1 + numer);

DTTO

btw this function looks just like the previous one ...

Quoted 68 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +68 -0
+	return vco;
+}
+
+unsigned int cm_get_l4_sp_clk_hz(void)
+{
+	return cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB);
+}
+
+unsigned int cm_get_mmc_controller_clk_hz(void)
+{
+	u32 clk_hz = 0;
+	u32 clk_input = 0;
+
+	clk_input = readl(&clock_manager_base->per_pll.cntr6clk);
+	clk_input = (clk_input >> CLKMGR_PERPLL_CNTR6CLK_SRC_LSB) &
+		CLKMGR_PERPLLGRP_SRC_MSK;
+
+	switch (clk_input) {
+	case CLKMGR_PERPLLGRP_SRC_MAIN:
+		clk_hz = cm_get_main_vco_clk_hz();
+		clk_hz /= 1 +
+			(readl
+			(&clock_manager_base->main_pll.cntr6clk) &
+			CLKMGR_MAINPLL_CNTRCLK_MSK);
+		break;
+
+	case CLKMGR_PERPLLGRP_SRC_PERI:
+		clk_hz = cm_get_per_vco_clk_hz();
+		clk_hz /= 1 + (readl
+			(&clock_manager_base->per_pll.cntr6clk) &
+			CLKMGR_PERPLL_CNTRCLK_MSK);
+		break;
+
+	case CLKMGR_PERPLLGRP_SRC_OSC1:
+		clk_hz = eosc1_hz;
+		break;
+
+	case CLKMGR_PERPLLGRP_SRC_INTOSC:
+		clk_hz = cb_intosc_hz;
+		break;
+
+	case CLKMGR_PERPLLGRP_SRC_FPGA:
+		clk_hz = f2s_free_hz;
+		break;
+	}
+
+	return clk_hz / 4;
+}
+
+unsigned int cm_get_spi_controller_clk_hz(void)
+{
+	return cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB);
+}
+
+unsigned int cm_get_qspi_controller_clk_hz(void)
+{
+	return  cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB);
+}
+
+void cm_print_clock_quick_summary(void)
+{
+	printf("MPU       %10ld kHz\n", cm_get_mpu_clk_hz() / 1000);
+	printf("MMC         %8d kHz\n", cm_get_mmc_controller_clk_hz() / 1000);
+	printf("QSPI        %8d kHz\n",
+	       cm_get_qspi_controller_clk_hz() / 1000);
+	printf("SPI         %8d kHz\n", cm_get_spi_controller_clk_hz() / 1000);
+	printf("EOSC1       %8d kHz\n", eosc1_hz / 1000);
+	printf("cb_intosc   %8d kHz\n", cb_intosc_hz / 1000);

arch/arm/mach-socfpga/clock_manager_arria10.c line 1103

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+	printf("f2s_free    %8d kHz\n", f2s_free_hz / 1000);
+	printf("Main VCO    %8d kHz\n", cm_get_main_vco_clk_hz() / 1000);
+	printf("NOC         %8d kHz\n", cm_get_noc_clk_hz() / 1000);
+	printf("L4 Main	    %8d kHz\n",
+	       cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB) / 1000);
+	printf("L4 MP       %8d kHz\n",
+	       cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB) / 1000);
+	printf("L4 SP       %8d kHz\n",
+	       cm_get_l4_sp_clk_hz() / 1000);
+	printf("L4 sys free %8d kHz\n", cm_l4_sys_free_clk_hz / 1000);

This should be part of the clock command ... see CV clock command.

arch/arm/mach-socfpga/include/mach/clock_manager.h void cm_wait_for_fsm(void); · line 17

Quoted 11 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +1 -0
+}
arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
index d0d0487..ec067ae 100644
@@ -13,7 +13,13 @@ void cm_wait_for_fsm(void);
 void cm_print_clock_quick_summary(void);
 #endif
 
+/* Common mask */
+#define CLKMGR_CLKMGR_STAT_BUSY_SET_MSK			0x00000001

BIT(0) ?

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +3 -0
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/clock_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/clock_manager_arria10.h>
 #endif
+
 #endif /* _CLOCK_MANAGER_H_ */

[...]

arch/arm/mach-socfpga/include/mach/clock_manager.h

Quoted 2 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
+/* mask */
+#define CLKMGR_MAINPLL_EN_S2FUSER0CLKEN_SET_MSK		0x00000040

Looks more like a BIT() to me ...

Quoted 93 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +92 -0
+#define CLKMGR_MAINPLL_EN_HMCPLLREFCLKEN_SET_MSK	0x00000080
+#define CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK	0x00000100
+#define CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK		0x00000200
+#define CLKMGR_CLKMGR_STAT_BOOTCLKSRC_SET_MSK		0x00020000
+#define CLKMGR_MAINPLL_VCO0_BGPWRDN_SET_MSK		0x00000001
+#define CLKMGR_MAINPLL_VCO0_PWRDN_SET_MSK		0x00000002
+#define CLKMGR_MAINPLL_VCO0_EN_SET_MSK			0x00000004
+#define CLKMGR_MAINPLL_VCO0_OUTRSTALL_SET_MSK		0x00000008
+#define CLKMGR_MAINPLL_VCO0_REGEXTSEL_SET_MSK		0x00000010
+#define CLKMGR_PERPLL_VCO0_BGPWRDN_SET_MSK		0x00000001
+#define CLKMGR_PERPLL_VCO0_PWRDN_SET_MSK		0x00000002
+#define CLKMGR_PERPLL_VCO0_EN_SET_MSK			0x00000004
+#define CLKMGR_PERPLL_VCO0_OUTRSTALL_SET_MSK		0x00000008
+#define CLKMGR_PERPLL_VCO0_REGEXTSEL_SET_MSK		0x00000010
+#define CLKMGR_CLKMGR_INTR_PERPLLFBSLIP_SET_MSK		0x00000800
+#define CLKMGR_CLKMGR_INTR_MAINPLLFBSLIP_SET_MSK	0x00000400
+#define CLKMGR_CLKMGR_INTR_PERPLLRFSLIP_SET_MSK		0x00000200
+#define CLKMGR_CLKMGR_INTR_MAINPLLRFSLIP_SET_MSK	0x00000100
+#define CLKMGR_CLKMGR_INTR_PERPLLLOST_SET_MSK		0x00000008
+#define CLKMGR_CLKMGR_INTR_MAINPLLLOST_SET_MSK		0x00000004
+#define CLKMGR_CLKMGR_INTR_MAINPLLACHIEVED_SET_MSK	0x00000001
+#define CLKMGR_CLKMGR_INTR_PERPLLACHIEVED_SET_MSK	0x00000002
+#define CLKMGR_CLKMGR_CTL_BOOTMOD_SET_MSK		0x00000001
+#define CLKMGR_CLKMGR_CTL_BOOTCLK_INTOSC_SET_MSK	0x00000300
+#define CLKMGR_PERPLL_EN_RESET				0x00000f7f
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK		0x00000020
+#define CLKMGR_MAINPLL_VCO0_PSRC_MSK			0x00000003
+#define CLKMGR_MAINPLL_VCO1_NUMER_MSK			0x00001fff
+#define CLKMGR_MAINPLL_VCO1_DENOM_MSK			0x0000003f
+#define CLKMGR_MAINPLL_CNTRCLK_MSK			0x000003ff
+#define CLKMGR_PERPLL_VCO0_PSRC_MSK			0x00000003
+#define CLKMGR_PERPLL_VCO1_NUMER_MSK			0x00001fff
+#define CLKMGR_PERPLL_VCO1_DENOM_MSK			0x0000003f
+#define CLKMGR_PERPLL_CNTRCLK_MSK			0x000003ff
+#define CLKMGR_MAINPLL_MPUCLK_SRC_MSK			0x00000007
+#define CLKMGR_MAINPLL_MPUCLK_CNT_MSK			0x000003ff
+#define CLKMGR_MAINPLL_MPUCLK_SRC_MAIN			0
+#define CLKMGR_MAINPLL_MPUCLK_SRC_PERI			1
+#define CLKMGR_MAINPLL_MPUCLK_SRC_OSC1			2
+#define CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC		3
+#define CLKMGR_MAINPLL_MPUCLK_SRC_FPGA			4
+#define CLKMGR_MAINPLL_NOCDIV_MSK			0x00000003
+#define CLKMGR_MAINPLL_NOCCLK_CNT_MSK			0x000003ff
+#define CLKMGR_MAINPLL_NOCCLK_SRC_MSK			0x00000007
+#define CLKMGR_MAINPLL_NOCCLK_SRC_MAIN			0
+#define CLKMGR_MAINPLL_NOCCLK_SRC_PERI			1
+#define CLKMGR_MAINPLL_NOCCLK_SRC_OSC1			2
+#define CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC		3
+#define CLKMGR_MAINPLL_NOCCLK_SRC_FPGA			4
+
+#define CLKMGR_PERPLLGRP_SRC_MSK			0x00000007
+#define CLKMGR_PERPLLGRP_SRC_MAIN			0
+#define CLKMGR_PERPLLGRP_SRC_PERI			1
+#define CLKMGR_PERPLLGRP_SRC_OSC1			2
+#define CLKMGR_PERPLLGRP_SRC_INTOSC			3
+#define CLKMGR_PERPLLGRP_SRC_FPGA			4
+
+/* bit shifting macro */
+#define CLKMGR_MAINPLL_VCO0_PSRC_LSB		8
+#define CLKMGR_PERPLL_VCO0_PSRC_LSB		8
+#define CLKMGR_MAINPLL_VCO1_DENOM_LSB		16
+#define CLKMGR_PERPLL_VCO1_DENOM_LSB		16
+#define CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB	16
+#define CLKMGR_MAINPLL_NOCCLK_SRC_LSB		16
+#define CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB	0
+#define CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB	8
+#define CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB	16
+#define CLKMGR_MAINPLL_NOCDIV_CSATCLK_LSB	24
+#define CLKMGR_MAINPLL_NOCDIV_CSTRACECLK_LSB	26
+#define CLKMGR_MAINPLL_NOCDIV_CSPDBGCLK_LSB	28
+#define CLKMGR_MAINPLL_MPUCLK_SRC_LSB		16
+#define CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB	16
+#define CLKMGR_MAINPLL_NOCCLK_SRC_LSB		16
+#define CLKMGR_MAINPLL_CNTR7CLK_SRC_LSB		16
+#define CLKMGR_MAINPLL_CNTR9CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR2CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR3CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR4CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR5CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR6CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_CNTR8CLK_SRC_LSB		16
+#define CLKMGR_PERPLL_EMACCTL_EMAC0SEL_LSB	26
+#define CLKMGR_PERPLL_EMACCTL_EMAC1SEL_LSB	27
+#define CLKMGR_PERPLL_EMACCTL_EMAC2SEL_LSB	28
+
+/* PLL ramping work around */
+#define CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ	900000000
+#define CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ	300000000
+#define CLKMGR_PLL_RAMP_MPUCLK_INCREMENT_HZ	100000000
+#define CLKMGR_PLL_RAMP_NOCCLK_INCREMENT_HZ	33000000
+
+#endif /* CLOCK_MANAGER_ARRIA10 */
Signature · 2 lines
Best regards,
Marek Vasut
#23 lore raw

PATCH v2 9/20 arm: socfpga: Add system manager for Arria 10

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

Add system manager register struct and defines for Arria 10.

---
 .../arm/mach-socfpga/include/mach/system_manager.h | 52 ++++++++++++++
 .../include/mach/system_manager_arria10.h          | 81 ++++++++++++++++++++++
 .../include/mach/system_manager_gen5.h             |  1 +
 3 files changed, 134 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_arria10.h
arch/arm/mach-socfpga/include/mach/system_manager.h +32 -0
index 53ced81..54078ce 100644
@@ -31,8 +31,60 @@
 #define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
 #define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
 
+/* For dedicated IO configuration */
+/* Voltage select enums */
+#define VOLTAGE_SEL_3V		0x0
+#define VOLTAGE_SEL_1P8V	0x1
+#define VOLTAGE_SEL_2P5V	0x2
+
+/* Input buffer enable */
+#define INPUT_BUF_DISABLE	0
+#define INPUT_BUF_1P8V		1
+#define INPUT_BUF_2P5V3V	2
+
+/* Weak pull up enable */
+#define WK_PU_DISABLE		0
+#define WK_PU_ENABLE		1
+
+/* Pull up slew rate control */
+#define PU_SLW_RT_SLOW		0
+#define PU_SLW_RT_FAST		1
+#define PU_SLW_RT_DEFAULT	PU_SLW_RT_SLOW
+
+/* Pull down slew rate control */
+#define PD_SLW_RT_SLOW		0
+#define PD_SLW_RT_FAST		1
+#define PD_SLW_RT_DEFAULT	PD_SLW_RT_SLOW
+
+/* Drive strength control */
+#define PU_DRV_STRG_DEFAULT	0x10
+#define PD_DRV_STRG_DEFAULT	0x10
+
+/* bit position */
+#define PD_DRV_STRG_LSB		0
+#define PD_SLW_RT_LSB		5

arch/arm/mach-socfpga/include/mach/system_manager.h line 75

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/system_manager.h +10 -0
+#define PU_DRV_STRG_LSB		8
+#define PU_SLW_RT_LSB		13
+#define WK_PU_LSB		16
+#define INPUT_BUF_LSB		17
+#define BIAS_TRIM_LSB		19
+#define VOLTAGE_SEL_LSB		0
+
+#define ALT_SYSMGR_NOC_H2F_SET_MSK	0x00000001
+#define ALT_SYSMGR_NOC_LWH2F_SET_MSK	0x00000010
+#define ALT_SYSMGR_NOC_F2H_SET_MSK	0x00000100

BIT() ?

Quoted 114 lines
arch/arm/mach-socfpga/include/mach/system_manager.h +10 -0
+#define ALT_SYSMGR_NOC_F2SDR0_SET_MSK	0x00010000
+#define ALT_SYSMGR_NOC_F2SDR1_SET_MSK	0x00100000
+#define ALT_SYSMGR_NOC_F2SDR2_SET_MSK	0x01000000
+#define ALT_SYSMGR_NOC_TMO_EN_SET_MSK	0x00000001
+
+#define ALT_SYSMGR_ECC_INTSTAT_SERR_OCRAM_SET_MSK	0x00000002
+#define ALT_SYSMGR_ECC_INTSTAT_DERR_OCRAM_SET_MSK	0x00000002
+
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/system_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/system_manager_arria10.h>
 #endif
 
 #endif /* _SYSTEM_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h new file +81 -0
new file mode 100644
index 0000000..f235aba
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _SYSTEM_MANAGER_ARRIA10_H_
+#define _SYSTEM_MANAGER_ARRIA10_H_
+
+struct socfpga_system_manager {
+	u32  siliconid1;
+	u32  siliconid2;
+	u32  wddbg;
+	u32  bootinfo;
+	u32  mpu_ctrl_l2_ecc;
+	u32  _pad_0x14_0x1f[3];
+	u32  dma;
+	u32  dma_periph;
+	u32  sdmmcgrp_ctrl;
+	u32  sdmmc_l3master;
+	u32  nand_bootstrap;
+	u32  nand_l3master;
+	u32  usb0_l3master;
+	u32  usb1_l3master;
+	u32  emac_global;
+	u32  emac[3];
+	u32  _pad_0x50_0x5f[4];
+	u32  fpgaintf_en_global;
+	u32  fpgaintf_en_0;
+	u32  fpgaintf_en_1;
+	u32  fpgaintf_en_2;
+	u32  fpgaintf_en_3;
+	u32  _pad_0x74_0x7f[3];
+	u32  noc_addr_remap_value;
+	u32  noc_addr_remap_set;
+	u32  noc_addr_remap_clear;
+	u32  _pad_0x8c_0x8f;
+	u32  ecc_intmask_value;
+	u32  ecc_intmask_set;
+	u32  ecc_intmask_clr;
+	u32  ecc_intstatus_serr;
+	u32  ecc_intstatus_derr;
+	u32  mpu_status_l2_ecc;
+	u32  mpu_clear_l2_ecc;
+	u32  mpu_status_l1_parity;
+	u32  mpu_clear_l1_parity;
+	u32  mpu_set_l1_parity;
+	u32  _pad_0xb8_0xbf[2];
+	u32  noc_timeout;
+	u32  noc_idlereq_set;
+	u32  noc_idlereq_clr;
+	u32  noc_idlereq_value;
+	u32  noc_idleack;
+	u32  noc_idlestatus;
+	u32  fpga2soc_ctrl;
+	u32  _pad_0xdc_0xff[9];
+	u32  tsmc_tsel_0;
+	u32  tsmc_tsel_1;
+	u32  tsmc_tsel_2;
+	u32  tsmc_tsel_3;
+	u32  _pad_0x110_0x200[60];
+	u32  romhw_ctrl;
+	u32  romcode_ctrl;
+	u32  romcode_cpu1startaddr;
+	u32  romcode_initswstate;
+	u32  romcode_initswlastld;
+	u32  _pad_0x214_0x217;
+	u32  warmram_enable;
+	u32  warmram_datastart;
+	u32  warmram_length;
+	u32  warmram_execution;
+	u32  warmram_crc;
+	u32  _pad_0x22c_0x22f;
+	u32  isw_handoff[8];
+	u32  romcode_bootromswstate[8];
+};
+
+#define SYSMGR_SDMMC_SMPLSEL_SHIFT	4
+#define SYSMGR_BOOTINFO_BSEL_SHIFT	12
+
+#endif /* _SYSTEM_MANAGER_ARRIA10_H_ */
arch/arm/mach-socfpga/include/mach/system_manager_gen5.h +1 -0
index 3ad4ca1..285c1a2 100644
@@ -117,5 +117,6 @@ struct socfpga_system_manager {
 #endif
 
 #define SYSMGR_SDMMC_SMPLSEL_SHIFT	3
+#define SYSMGR_BOOTINFO_BSEL_SHIFT	0
 
 #endif /* _SYSTEM_MANAGER_GEN5_H_ */
Signature · 2 lines
Best regards,
Marek Vasut
#26 lore raw

PATCH v2 11/20 arm: socfpga: Add misc support for Arria 10

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

Add misc support for Arria 10 and minor fix on misc Gen5.

---
 arch/arm/mach-socfpga/Makefile            |   1 +
 arch/arm/mach-socfpga/include/mach/misc.h |   6 +
 arch/arm/mach-socfpga/misc_arria10.c      | 254 ++++++++++++++++++++++++++++++
 arch/arm/mach-socfpga/misc_gen5.c         |   3 +-
 4 files changed, 263 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-socfpga/misc_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index c494930..9c4617f 100644
@@ -11,6 +11,7 @@ obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 	   fpga_manager.o board.o
 
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
+					misc_arria10.o		\
 					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
arch/arm/mach-socfpga/include/mach/misc.h +0 -0
index 64f9b86..446ee0f 100644

arch/arm/mach-socfpga/include/mach/misc.h void socfpga_fpga_add(void); · line 29

Quoted 7 lines
arch/arm/mach-socfpga/include/mach/misc.h +4 -0
@@ -23,4 +23,10 @@ void socfpga_fpga_add(void);
 inline void socfpga_fpga_add(void) {}
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+unsigned int dedicated_uart_com_port(const void *blob);
+unsigned int shared_uart_com_port(const void *blob);
+unsigned int uart_com_port(const void *blob);

Prefix them with socfpga_ if they're in the global namespace ...

Quoted 123 lines
arch/arm/mach-socfpga/include/mach/misc.h +2 -0
+#endif
+
 #endif /* _MISC_H_ */
arch/arm/mach-socfpga/misc_arria10.c new file +114 -0
new file mode 100644
index 0000000..d2bad13
@@ -0,0 +1,254 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <altera.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <miiphy.h>
+#include <netdev.h>
+#include <ns16550.h>
+#include <watchdog.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/sdram_arria10.h>
+#include <asm/arch/system_manager.h>
+#include <asm/arch/nic301.h>
+#include <asm/io.h>
+#include <asm/pl310.h>
+
+#define PINMUX_UART0_TX_SHARED_IO_OFFSET_Q1_3	0x08
+#define PINMUX_UART0_TX_SHARED_IO_OFFSET_Q2_11	0x58
+#define PINMUX_UART0_TX_SHARED_IO_OFFSET_Q3_3	0x68
+#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q1_7	0x18
+#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q3_7	0x78
+#define PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3	0x98
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct pl310_regs *const pl310 =
+	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
+static struct socfpga_system_manager *sysmgr_regs =
+	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+static const struct socfpga_noc_fw_ocram *noc_fw_ocram_base =
+	(void *)SOCFPGA_SDR_FIREWALL_OCRAM_ADDRESS;
+static const struct socfpga_noc_fw_ddr_l3 *noc_fw_ddr_l3_base =
+	(void *)SOCFPGA_SDR_FIREWALL_L3_ADDRESS;
+
+/*
+ * DesignWare Ethernet initialization
+ */
+#ifdef CONFIG_ETH_DESIGNWARE
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+				 const u32 phymode)
+{
+	u32 reset;
+
+	if (of_reset_id == EMAC0_RESET) {
+		reset = SOCFPGA_RESET(EMAC0);
+	} else if (of_reset_id == EMAC1_RESET) {
+		reset = SOCFPGA_RESET(EMAC1);
+	} else if (of_reset_id == EMAC2_RESET) {
+		reset = SOCFPGA_RESET(EMAC2);
+	} else {
+		printf("GMAC: Invalid reset ID (%i)!\n", of_reset_id);
+		return;
+	}
+
+	clrsetbits_le32(&sysmgr_regs->emac[of_reset_id - EMAC0_RESET],
+			SYSMGR_EMACGRP_CTRL_PHYSEL_MASK,
+			phymode);
+
+	/* Release the EMAC controller from reset */
+	socfpga_per_reset(reset, 0);
+}
+#endif
+
+/*
++ * This function initializes security policies to be consistent across
++ * all logic units in the Arria 10.
++ *
++ * The idea is to set all security policies to be normal, nonsecure
++ * for all units.
++ */
+static void initialize_security_policies(void)
+{
+	/* Put OCRAM in non-secure */
+	writel(0x003f0000, &noc_fw_ocram_base->region0);
+	writel(0x1, &noc_fw_ocram_base->enable);
+
+	/* Put DDR in non-secure */
+	writel(0xffff0000, &noc_fw_ddr_l3_base->hpsregion0addr);
+	writel(0x1, &noc_fw_ddr_l3_base->enable);
+}
+
+int arch_early_init_r(void)
+{
+	initialize_security_policies();
+
+	/* Configure the L2 controller to make SDRAM start at 0 */
+	writel(0x1, &pl310->pl310_addr_filter_start);
+
+	/* assert reset to all except L4WD0 and L4TIMER0 */
+	socfpga_per_reset_all();
+
+	/* configuring the clock based on handoff */
+	/* TODO: Add call to cm_basic_init() */
+
+	/* Add device descriptor to FPGA device table */
+	socfpga_fpga_add();
+	return 0;
+}
+
+/*
+ * This function looking the 1st encounter UART peripheral,
+ * and then return its offset of the dedicated/shared IO pin
+ * mux. offset value (zero and above).
+ */
+static int find_peripheral_uart(const void *blob,
+	int child, const char *node_name)
+{
+	int len;

arch/arm/mach-socfpga/misc_arria10.c line 124

Quoted 10 lines
arch/arm/mach-socfpga/misc_arria10.c new file +10 -0
+	fdt_addr_t base_addr = 0;
+	fdt_size_t size;
+	const u32 *cell;
+	u32 value, offset = 0;
+
+	base_addr = fdtdec_get_addr_size(blob, child, "reg", &size);
+	if (base_addr != FDT_ADDR_T_NONE) {
+		cell = fdt_getprop(blob, child, "pinctrl-single,pins",
+			&len);
+		if (cell != NULL) {

if (!cell)
continue;

and remove one level of indent ...

Quoted 145 lines
arch/arm/mach-socfpga/misc_arria10.c new file +130 -0
+			for (; len > 0; len -= (2 * sizeof(u32))) {
+				offset = fdt32_to_cpu(*cell++);
+				value = fdt32_to_cpu(*cell++);
+				/* Found UART peripheral */
+				if (value == 0x0D)
+					return offset;
+			}
+		}
+	}
+	return -EINVAL;
+}
+
+/*
+ * This function looks up the 1st encounter UART peripheral,
+ * and then return its offset of the dedicated/shared IO pin
+ * mux. UART peripheral is found if the offset is not in negative
+ * value.
+ */
+static int is_peripheral_uart_true(const void *blob,
+	int node, const char *child_name)
+{
+	int child, len;
+	const char *node_name;
+
+	child = fdt_first_subnode(blob, node);
+
+	if (child < 0)
+		return -EINVAL;
+
+	node_name = fdt_get_name(blob, child, &len);
+
+	while (node_name) {
+		if (!strcmp(child_name, node_name))
+			return find_peripheral_uart(blob, child, node_name);
+
+		child = fdt_next_subnode(blob, child);
+		if (child < 0)
+			break;
+
+		node_name = fdt_get_name(blob, child, &len);
+	}
+
+	return -1;
+}
+
+/*
+ * This function looking the 1st encounter UART dedicated IO peripheral,
+ * and then return based address of the 1st encounter UART dedicated
+ * IO peripheral.
+ */
+unsigned int dedicated_uart_com_port(const void *blob)
+{
+	int node;
+
+	node = fdtdec_next_compatible(blob, 0,
+		 COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE);
+	if (node < 0)
+		return 0;
+
+	if (is_peripheral_uart_true(blob, node, "dedicated") >= 0)
+		return SOCFPGA_UART1_ADDRESS;
+
+	return 0;
+}
+
+/*
+ * This function looking the 1st encounter UART shared IO peripheral, and then
+ * return based address of the 1st encounter UART shared IO peripheral.
+ */
+unsigned int shared_uart_com_port(const void *blob)
+{
+	int node, ret;
+
+	node = fdtdec_next_compatible(blob, 0,
+		 COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE);
+	if (node < 0)
+		return 0;
+
+	ret = is_peripheral_uart_true(blob, node, "shared");
+
+	if (ret == PINMUX_UART0_TX_SHARED_IO_OFFSET_Q1_3 ||
+	    ret == PINMUX_UART0_TX_SHARED_IO_OFFSET_Q2_11 ||
+	    ret == PINMUX_UART0_TX_SHARED_IO_OFFSET_Q3_3)
+		return SOCFPGA_UART0_ADDRESS;
+	else if (ret == PINMUX_UART1_TX_SHARED_IO_OFFSET_Q1_7 ||
+		ret == PINMUX_UART1_TX_SHARED_IO_OFFSET_Q3_7 ||
+		ret == PINMUX_UART1_TX_SHARED_IO_OFFSET_Q4_3)
+		return SOCFPGA_UART1_ADDRESS;
+
+	return 0;
+}
+
+/*
+ * This function looking the 1st encounter UART peripheral, and then return
+ * base address of the 1st encounter UART peripheral.
+ */
+unsigned int uart_com_port(const void *blob)
+{
+	unsigned int ret;
+
+	ret = dedicated_uart_com_port(blob);
+
+	if (ret)
+		return ret;
+
+	return shared_uart_com_port(blob);
+}
+
+/*
+ * Print CPU information
+ */
+#if defined(CONFIG_DISPLAY_CPUINFO)
+int print_cpuinfo(void)
+{
+	const u32 bsel = (readl(&sysmgr_regs->bootinfo) >>
+			  SYSMGR_BOOTINFO_BSEL_SHIFT) & 0x7;
+
+	puts("CPU:   Altera SoCFPGA Arria 10\n");
+
+	printf("BOOT:  %s\n", bsel_str[bsel].name);
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_ARCH_MISC_INIT
+int arch_misc_init(void)
+{
+	return 0;
+}
+#endif
arch/arm/mach-socfpga/misc_gen5.c +2 -1
index f870e1f..3b8ce11 100644
@@ -200,7 +200,8 @@ static int socfpga_fpga_id(const bool print_id)
 #if defined(CONFIG_DISPLAY_CPUINFO)
 int print_cpuinfo(void)
 {
-	const u32 bsel = readl(&sysmgr_regs->bootinfo) & 0x7;
+	const u32 bsel = (readl(&sysmgr_regs->bootinfo) >>
+			  SYSMGR_BOOTINFO_BSEL_SHIFT) & 0x7;
 
 	puts("CPU:   Altera SoCFPGA Platform\n");
 	socfpga_fpga_id(1);
Signature · 2 lines
Best regards,
Marek Vasut
#28 lore raw

PATCH v2 12/20 arm: socfpga: Add pinmux for Arria 10

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

Add pinmux support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile              |  1 +
 arch/arm/mach-socfpga/include/mach/pinmux.h | 15 +++++
 arch/arm/mach-socfpga/pinmux_arria10.c      | 96 +++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/pinmux.h
 create mode 100644 arch/arm/mach-socfpga/pinmux_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 9c4617f..68d55e4 100644
@@ -12,6 +12,7 @@ obj-y	+= misc.o timer.o reset_manager.o clock_manager.o \
 
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
 					misc_arria10.o		\
+					pinmux_arria10.o	\
 					reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
arch/arm/mach-socfpga/include/mach/pinmux.h new file +0 -0
new file mode 100644
index 0000000..c5d5dd6

arch/arm/mach-socfpga/include/mach/pinmux.h line 8

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/pinmux.h new file +8 -0
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef	_PINMUX_H_
+#define	_PINMUX_H_

#ifndef[SPACE]FOO
#define[SPACE]FOO

please fix globally

Quoted 26 lines
arch/arm/mach-socfpga/include/mach/pinmux.h new file +6 -0
+#ifndef __ASSEMBLY__
+int config_dedicated_pins(const void *blob);
+int config_pins(const void *blob, const char *pin_grp);
+#endif
+
+#endif /* _PINMUX_H_ */
arch/arm/mach-socfpga/pinmux_arria10.c new file +14 -0
new file mode 100644
index 0000000..47339ea
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <asm/arch/pinmux.h>
+#include <asm/io.h>
+#include <common.h>
+#include <fdtdec.h>
+
+static int do_pinctr_pin(const void *blob, int child, const char *node_name)
+{
+	int len;

arch/arm/mach-socfpga/pinmux_arria10.c line 24

Quoted 10 lines
arch/arm/mach-socfpga/pinmux_arria10.c new file +10 -0
+	fdt_addr_t base_addr;
+	fdt_size_t size;
+	const u32 *cell;
+	u32 offset, value;
+
+	base_addr = fdtdec_get_addr_size(blob, child, "reg", &size);
+	if (base_addr != FDT_ADDR_T_NONE) {
+		cell = fdt_getprop(blob, child, "pinctrl-single,pins",
+			&len);
+		if (cell != NULL && len > 0) {

if (!cell)
continue;
if (len <= 0)
continue;

Quoted 73 lines
arch/arm/mach-socfpga/pinmux_arria10.c new file +72 -0
+			debug("%p %d\n", cell, len);
+			for (; len > 0; len -= (2 * sizeof(u32))) {
+				offset = fdt32_to_cpu(*cell++);
+				value = fdt32_to_cpu(*cell++);
+				debug("<0x%x 0x%x>\n", offset, value);
+				writel(value, base_addr + offset);
+			}
+			return 0;
+		}
+	}
+	return -EFAULT;
+}
+
+static int do_pinctrl_pins(const void *blob, int node, const char *child_name)
+{
+	int child, len;
+	const char *node_name;
+
+	child = fdt_first_subnode(blob, node);
+
+	if (child < 0)
+		return -EINVAL;
+
+	node_name = fdt_get_name(blob, child, &len);
+
+	while (node_name) {
+		if (!strcmp(child_name, node_name))
+			return do_pinctr_pin(blob, child, node_name);
+
+		child = fdt_next_subnode(blob, child);
+
+		if (child < 0)
+			break;
+
+		node_name = fdt_get_name(blob, child, &len);
+	}
+
+	return -EFAULT;
+}
+
+int config_dedicated_pins(const void *blob)
+{
+	int node;
+
+	node = fdtdec_next_compatible(blob, 0,
+			COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE);
+	if (node < 0)
+		return -EINVAL;
+
+	if (do_pinctrl_pins(blob, node, "dedicated_cfg"))
+		return -EFAULT;
+
+	if (do_pinctrl_pins(blob, node, "dedicated"))
+		return -EFAULT;
+
+	return 0;
+}
+
+int config_pins(const void *blob, const char *pin_grp)
+{
+	int node;
+
+	node = fdtdec_next_compatible(blob, 0,
+			COMPAT_ALTERA_SOCFPGA_PINCTRL_SINGLE);
+	if (node < 0)
+		return -EINVAL;
+
+	if (do_pinctrl_pins(blob, node, pin_grp))
+		return -EFAULT;
+
+	return 0;
+}
Signature · 2 lines
Best regards,
Marek Vasut
#54 lore raw

v2 cover Add Intel Arria 10 SoC support

In reply to Dinh Nguyen
Quoted 7 lines · Dinh Nguyen
Quoted 3 lines · Ley Foon Tan

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

Can you please include me on this patchset? I'd like to help with the review process.

Appreciated, thanks.

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

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

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

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
 struct socfpga_reset_manager {
 	u32	stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
index 547a8bb..bbf54f0 100644

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 29

Quoted 2 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
 	ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
 	ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)

Should be part of reset manager patch ...

Quoted 114 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +18 -0
+void reset_uart(int assert)
+{
+	u32 mask = 0;
+	unsigned int com_port;
+
+	com_port = uart_com_port(gd->fdt_blob);
+
+	if (com_port == SOCFPGA_UART1_ADDRESS)
+		mask |= ALT_RSTMGR_PER1MODRST_UART1_SET_MSK;
+	else if (com_port == SOCFPGA_UART0_ADDRESS)
+		mask |= ALT_RSTMGR_PER1MODRST_UART0_SET_MSK;
+
+	if (assert)
+		setbits_le32(&reset_manager_base->per1modrst, mask);
+	else
+		clrbits_le32(&reset_manager_base->per1modrst, mask);
+}
+
 static const u32 per0fpgamasks[] = {
 	ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
 	ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK,
arch/arm/mach-socfpga/spl.c +53 -2
index fec4c7a..5c0cc98 100644
@@ -19,23 +19,32 @@
 #include <asm/arch/sdram.h>
 #include <asm/arch/scu.h>
 #include <asm/arch/nic301.h>
+#include <asm/sections.h>
+#include <fdtdec.h>
+#include <watchdog.h>
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/pinmux.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct pl310_regs *const pl310 =
 	(struct pl310_regs *)CONFIG_SYS_PL310_BASE;
 static struct scu_registers *scu_regs =
 	(struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
 static struct nic301_registers *nic301_regs =
 	(struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
-static struct socfpga_system_manager *sysmgr_regs =
+#endif
+
+static const struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
 
 u32 spl_boot_device(void)
 {
 	const u32 bsel = readl(&sysmgr_regs->bootinfo);
 
-	switch (bsel & 0x7) {
+	switch ((bsel >> SYSMGR_BOOTINFO_BSEL_SHIFT) & 0x7) {
 	case 0x1:	/* FPGA (HPS2FPGA Bridge) */
 		return BOOT_DEVICE_RAM;
 	case 0x2:	/* NAND Flash (1.8V) */
@@ -68,6 +77,7 @@ u32 spl_boot_mode(const u32 boot_device)
 }
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static void socfpga_nic301_slave_ns(void)
 {
 	writel(0x1, &nic301_regs->lwhps2fpgaregs);
@@ -182,3 +192,44 @@ void board_init_f(ulong dummy)
 	/* Configure simple malloc base pointer into RAM. */
 	gd->malloc_base = CONFIG_SYS_TEXT_BASE + (1024 * 1024);
 }
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#ifdef CONFIG_SPL_BOARD_INIT
+void spl_board_init(void)
+{
+	/* configuring the clock based on handoff */
+	cm_basic_init(gd->fdt_blob);
+	WATCHDOG_RESET();
+
+	config_dedicated_pins(gd->fdt_blob);
+	WATCHDOG_RESET();
+
+	/* Release UART from reset */
+	reset_uart(0);
+
+	/* enable console uart printing */
+	preloader_console_init();
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+	/*
+	 * Configure Clock Manager to use intosc clock instead external osc to
+	 * ensure success watchdog operation. We do it as early as possible.
+	 */
+	cm_use_intosc();
+
+	watchdog_disable();
+
+	arch_early_init_r();
+
+#ifdef CONFIG_HW_WATCHDOG
+	/* release osc1 watchdog timer 0 from reset */
+	reset_deassert_osc1wd0();
+
+	/* reconfigure and enable the watchdog */
+	hw_watchdog_init();
+	WATCHDOG_RESET();
+#endif /* CONFIG_HW_WATCHDOG */
+}
+#endif
Signature · 2 lines
Best regards,
Marek Vasut
#39 lore raw

PATCH v2 16/20 drivers: fpga: Add compile switch for Gen5 only registers

In reply to Ley Foon Tan
Quoted 1 line · Ley Foon Tan

These registers only available for Gen5 device, excludes them

exclude

Quoted 1 line

if for Arria 10 build.

s/if for/from/

Quoted 44 lines
---
 drivers/fpga/socfpga.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/fpga/socfpga.c +6 -0
index f1b2f2c..3751574 100644
@@ -19,8 +19,10 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct socfpga_fpga_manager *fpgamgr_regs =
 	(struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS;
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct socfpga_system_manager *sysmgr_regs =
 	(struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+#endif
 
 /* Set CD ratio */
 static void fpgamgr_set_cd_ratio(unsigned long ratio)
@@ -268,8 +270,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 
 	/* Prior programming the FPGA, all bridges need to be shut off */
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	/* Disable all signals from hps peripheral controller to fpga */
 	writel(0, &sysmgr_regs->fpgaintfgrp_module);
+#endif
 
 	/* Disable all signals from FPGA to HPS SDRAM */
 #define SDR_CTRLGRP_FPGAPORTRST_ADDRESS	0x5080
@@ -278,8 +282,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 	/* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
 	socfpga_bridges_reset(1);
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 	/* Unmap the bridges from NIC-301 */
 	writel(0x1, SOCFPGA_L3REGS_ADDRESS);
+#endif
 
 	/* Initialize the FPGA Manager */
 	status = fpgamgr_program_init();
Signature · 2 lines
Best regards,
Marek Vasut
#42 lore raw

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

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

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
index 0000000..9554da7

drivers/ddr/altera/Kconfig line 2

Quoted 2 lines
drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+	bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

Quoted 21 lines
drivers/ddr/altera/Kconfig new file +4 -0
+	default y if TARGET_SOCFPGA_GEN5
+	help
+	  This is for building the SDRAM controller for the Arria5/Cyclone5
+	  devices.
include/configs/socfpga_common.h +0 -5
index 55e0bf9..bc92a2c 100644
@@ -77,11 +77,6 @@
 #define CONFIG_SYS_PL310_BASE		SOCFPGA_MPUL2_ADDRESS
 
 /*
- * SDRAM controller
- */
-#define CONFIG_ALTERA_SDRAM
-
-/*
  * EPCS/EPCQx1 Serial Flash Controller
  */
 #ifdef CONFIG_ALTERA_SPI
Signature · 2 lines
Best regards,
Marek Vasut
#49 lore raw

PATCH v2 18/20 arm: socfpga: Add config and defconfig for Arria 10

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

Add config and defconfig for the Arria10 and update socfpga_common.h.

---
 configs/socfpga_arria10_defconfig       | 30 +++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 67 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 ++++++++++++--
 3 files changed, 121 insertions(+), 4 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
configs/socfpga_arria10_defconfig new file +30 -0
new file mode 100644
index 0000000..9e6bc1e0
@@ -0,0 +1,30 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_arria10"
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
+CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_SPL=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_DOS_PARTITION=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE=0xa2
include/configs/socfpga_arria10_socdk.h new file +5 -0
new file mode 100644
index 0000000..5b7d572
@@ -0,0 +1,67 @@
+/*
+ *  Copyright (C) 2015-2017 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */

include/configs/socfpga_arria10_socdk.h line 15

Quoted 10 lines
include/configs/socfpga_arria10_socdk.h new file +10 -0
+
+#ifndef __CONFIG_SOCFGPA_ARRIA10_H__
+#define __CONFIG_SOCFGPA_ARRIA10_H__
+
+#include <asm/arch/base_addr_a10.h>
+/* U-Boot Commands */
+#define CONFIG_FAT_WRITE
+#define CONFIG_HW_WATCHDOG
+
+

Drop this extra newline

Quoted 116 lines
include/configs/socfpga_arria10_socdk.h new file +52 -0
+/* Booting Linux */
+#define CONFIG_LOADADDR		0x01000000
+#define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
+
+/*
+ * U-Boot general configurations
+ */
+/* Cache options */
+#define CONFIG_SYS_DCACHE_OFF
+
+/* Memory configurations  */
+#define PHYS_SDRAM_1_SIZE		0x80000000
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_PHY_MICREL
+#define CONFIG_PHY_MICREL_KSZ9031
+#endif
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_IS_IN_MMC
+
+/*
+ * arguments passed to the bootz command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will overide also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "console=ttyS0," __stringify(CONFIG_BAUDRATE)
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_MEM32
+#define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, 115200}
+
+/*
+ * L4 OSC1 Timer 0
+ */
+/* reload value when timer count to zero */
+#define TIMER_LOAD_VAL			0xFFFFFFFF
+
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+
+/* The rest of the configuration is shared */
+#include <configs/socfpga_common.h>
+
+#endif	/* __CONFIG_SOCFGPA_ARRIA10_H__ */
include/configs/socfpga_common.h +14 -4
index bc92a2c..a228ea5 100644
@@ -34,9 +34,13 @@
 #define CONFIG_SYS_MALLOC_LEN		(64 * 1024 * 1024)
 #define CONFIG_SYS_MEMTEST_START	PHYS_SDRAM_1
 #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE
-
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SYS_INIT_RAM_ADDR	0xFFFF0000
 #define CONFIG_SYS_INIT_RAM_SIZE	0x10000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_INIT_RAM_ADDR	0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE	0x40000 /* 256KB */
+#endif
 #define CONFIG_SYS_INIT_SP_OFFSET		\
 	(CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_INIT_SP_ADDR			\
@@ -67,8 +71,10 @@
 #define CONFIG_SYS_HOSTNAME	CONFIG_SYS_BOARD
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif
 
 /*
  * Cache
@@ -103,13 +109,14 @@
 /*
  * FPGA Driver
  */
+#ifdef CONFIG_TARGET_SOCFPGA_GEN5
 #ifdef CONFIG_CMD_FPGA
 #define CONFIG_FPGA
 #define CONFIG_FPGA_ALTERA
 #define CONFIG_FPGA_SOCFPGA
 #define CONFIG_FPGA_COUNT		1
 #endif
-
+#endif
 /*
  * L4 OSC1 Timer 0
  */
@@ -209,11 +216,14 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE	-4
-#define CONFIG_SYS_NS16550_COM1		SOCFPGA_UART0_ADDRESS
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_NS16550_CLK		1000000
-#else
+#elif defined(CONFIG_TARGET_SOCFPGA_GEN5)
+#define CONFIG_SYS_NS16550_COM1		SOCFPGA_UART0_ADDRESS
 #define CONFIG_SYS_NS16550_CLK		100000000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_NS16550_COM1        SOCFPGA_UART1_ADDRESS
+#define CONFIG_SYS_NS16550_CLK		50000000
 #endif
 #define CONFIG_CONS_INDEX		1
 #define CONFIG_BAUDRATE			115200

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 315

Quoted 5 lines
include/configs/socfpga_common.h +1 -0
@@ -301,7 +311,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SPL_MAX_SIZE		(64 * 1024)

This should also be INIT_RAM_SIZE IMO ^^

Quoted 24 lines
include/configs/socfpga_common.h +9 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_MAX_SIZE		CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_BOARD_INIT
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -349,10 +364,15 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define BOOT_TARGET_DEVICES(func) \
 	BOOT_TARGET_DEVICES_MMC(func) \
 	BOOT_TARGET_DEVICES_PXE(func) \
 	func(DHCP, dhcp, na)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define BOOT_TARGET_DEVICES(func) \
+	BOOT_TARGET_DEVICES_MMC(func)
+#endif
 
 #include <config_distro_bootcmd.h>
 
Signature · 2 lines
Best regards,
Marek Vasut
#55 lore raw

v2 cover Add Intel Arria 10 SoC support

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

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

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

I have to wonder, will the A10 SoCDK be usable with mainline U-Boot with just this patchset or is something else missing, like ie. the DDR driver ?

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

v2 cover Add Intel Arria 10 SoC support

Hi Marek

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

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

Quoted 8 lines
Quoted 4 lines

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

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

I have to wonder, will the A10 SoCDK be usable with mainline U-Boot with just this patchset or is something else missing, like ie. the DDR driver ?

We want to get the basic upstream first and then will submit the patchset for DDR and other components after this.

Regards
Ley Foon

#57 lore raw

v2 cover Add Intel Arria 10 SoC support

Quoted 1 line · Ley Foon Tan

Hi Marek

Hi!

Quoted 11 lines · Marek Vasut
Quoted 10 lines · Ley Foon Tan
Quoted 9 lines

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

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

I have to wonder, will the A10 SoCDK be usable with mainline U-Boot with just this patchset or is something else missing, like ie. the DDR driver ?

We want to get the basic upstream first and then will submit the patchset for DDR and other components after this.

Do you have the full patchset, which can be used to boot Arria10 SoCDK, available somewhere ? I would like to know how the pieces fit together.

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

v2 cover Add Intel Arria 10 SoC support

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

Hi Marek

Hi!

Quoted 17 lines · Marek Vasut
Quoted 15 lines · Ley Foon Tan
Quoted 10 lines

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

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

I have to wonder, will the A10 SoCDK be usable with mainline U-Boot with just this patchset or is something else missing, like ie. the DDR driver ?

Quoted 5 lines
Quoted 2 lines

We want to get the basic upstream first and then will submit the patchset for DDR and other components after this.

Do you have the full patchset, which can be used to boot Arria10 SoCDK, available somewhere ? I would like to know how the pieces fit together.

Tien Foong is working on the sub sequence patchset, eg: for FPGA manager and DDR.
He already got these 2 drivers, but still trying to get it boot to U-boot stage with mainline U-boot.
We can send to you if you want take a look.

Thanks.

Regards
Ley Foon

#3 lore raw

PATCH v2 1/20 arm: socfpga: Restructure clock manager driver

In reply to Dinh Nguyen
Quoted 20 lines · Dinh Nguyen
Quoted 6 lines · Ley Foon Tan

Restructure clock manager driver in the preparation to support A10. Move the Gen5 specific code to _gen5 files. No functional change.

Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.

Quoted 10 lines
---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 510 +--------------------
 arch/arm/mach-socfpga/clock_manager_gen5.c         | 510 +++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 312 +------------
 .../mach-socfpga/include/mach/clock_manager_gen5.h | 322 +++++++++++++
 5 files changed, 846 insertions(+), 811 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_gen5.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h
Quoted 9 lines

Please add a -C when you run format-patch, you'll get something like this:

 5 files changed, 104 insertions(+), 947 deletions(-)
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (88%)
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h =>

clock_manager_gen5.h} (87%)

It it make things a bit smaller to review for simple file copies.

Okay, will do it next revision.
Thanks.

Regards
Ley Foon

#9 lore raw

PATCH v2 4/20 arm: socfpga: Restructure misc driver

In reply to Marek Vasut
Quoted 48 lines · Marek Vasut
Quoted 47 lines · Ley Foon Tan

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to _gen5 file. No functional change.

Change all uint32_t_to u32.

---
 arch/arm/mach-socfpga/Makefile            |   3 +-
 arch/arm/mach-socfpga/include/mach/misc.h |  26 +++
 arch/arm/mach-socfpga/misc.c              | 361 ++----------------------------
 arch/arm/mach-socfpga/misc_gen5.c         | 355 +++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 347 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/Makefile +2 -1
index 97819ac..5b09ea9 100644
@@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)    += scan_manager.o wrap_pll_config.o \
-                                        clock_manager_gen5.o reset_manager_gen5.o
+                                        clock_manager_gen5.o reset_manager_gen5.o \
+                                        misc_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o  \
                         wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o   += -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/misc.h new file +12 -0
new file mode 100644
index 0000000..64f9b86
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+                              const u32 phymode);
+
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/misc.h line 18

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +6 -0
+struct bsel {
+     const char      *mode;
+     const char      *name;
+};
+
+extern struct bsel bsel_str[];

I'm really not a big fan of extern variables, can we get rid of this?

For public variable, we need extern keyword here. Only function prototype doesn't need the extern.

Quoted 8 lines

arch/arm/mach-socfpga/include/mach/misc.h line 23

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +4 -0
+#ifdef CONFIG_FPGA
+void socfpga_fpga_add(void);
+#else
+inline void socfpga_fpga_add(void) {}

static

Okay.

[...]

Regards
Ley Foon

#15 lore raw

PATCH v2 6/20 arm: socfpga: Add A10 defines

In reply to Marek Vasut
Quoted 5 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

Add i2c, timer and other A10 defines.

macros ... btw. you're defining macro with their address.

Okay.

Thanks.
Regards
Ley Foon

#10 lore raw

PATCH v2 4/20 arm: socfpga: Restructure misc driver

In reply to Ley Foon Tan
Quoted 57 lines · Ley Foon Tan
Quoted 48 lines · Marek Vasut
Quoted 47 lines · Ley Foon Tan

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to _gen5 file. No functional change.

Change all uint32_t_to u32.

---
 arch/arm/mach-socfpga/Makefile            |   3 +-
 arch/arm/mach-socfpga/include/mach/misc.h |  26 +++
 arch/arm/mach-socfpga/misc.c              | 361 ++----------------------------
 arch/arm/mach-socfpga/misc_gen5.c         | 355 +++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 347 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/Makefile +2 -1
index 97819ac..5b09ea9 100644
@@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)    += scan_manager.o wrap_pll_config.o \
-                                        clock_manager_gen5.o reset_manager_gen5.o
+                                        clock_manager_gen5.o reset_manager_gen5.o \
+                                        misc_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o  \
                         wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o   += -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/misc.h new file +12 -0
new file mode 100644
index 0000000..64f9b86
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_
+
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+                              const u32 phymode);
+
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/misc.h line 18

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +6 -0
+struct bsel {
+     const char      *mode;
+     const char      *name;
+};
+
+extern struct bsel bsel_str[];

I'm really not a big fan of extern variables, can we get rid of this?

Quoted 2 lines

For public variable, we need extern keyword here. Only function prototype doesn't need the extern.

Why does this have to be in public namespace anyway ?

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

v2 cover Add Intel Arria 10 SoC support

In reply to Ley Foon Tan
Quoted 26 lines · Ley Foon Tan
Quoted 25 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

Hi Marek

Hi!

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

This is the 2nd version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek in [v1].

This is initial patchset enables the basic support for Arria 10 and other features will come after this.

Quoted 8 lines
Quoted 4 lines

This series is working on top of “arm: socfpga: Move to using distro boot” series [1] from Dalon Westergreen.

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

I have to wonder, will the A10 SoCDK be usable with mainline U-Boot with just this patchset or is something else missing, like ie. the DDR driver ?

We want to get the basic upstream first and then will submit the patchset for DDR and other components after this.

Quoted 7 lines
Quoted 2 lines

Do you have the full patchset, which can be used to boot Arria10 SoCDK, available somewhere ? I would like to know how the pieces fit together.

Tien Foong is working on the sub sequence patchset, eg: for FPGA manager and DDR.
He already got these 2 drivers, but still trying to get it boot to U-boot stage with mainline U-boot.
We can send to you if you want take a look.

That'd be real nice, thanks !

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

PATCH v2 8/20 arm: socfpga: Add clock driver for Arria 10

In reply to Marek Vasut
Quoted 303 lines · Marek Vasut
Quoted 55 lines · Ley Foon Tan

Add clock driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |    3 +-
 arch/arm/mach-socfpga/clock_manager.c              |   18 +-
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1104 ++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    6 +
 .../include/mach/clock_manager_arria10.h           |  222 ++++
 5 files changed, 1350 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/clock_manager_arria10.c
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h
arch/arm/mach-socfpga/Makefile +2 -1
index d81f003..c494930 100644
@@ -10,7 +10,8 @@
 obj-y        += misc.o timer.o reset_manager.o clock_manager.o \
         fpga_manager.o board.o
 
-obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
+                                     reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
arch/arm/mach-socfpga/clock_manager.c +7 -0
index c2af6f3..ad602c8 100644
@@ -5,6 +5,8 @@
  */
 
 #include <common.h>
+#include <fdtdec.h>
+#include <wait_bit.h>
 #include <asm/io.h>
 #include <asm/arch/clock_manager.h>
 
@@ -18,7 +20,12 @@ void cm_wait_for_lock(u32 mask)
      u32 inter_val;
      u32 retry = 0;
      do {
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
              inter_val = readl(&clock_manager_base->inter) & mask;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+             inter_val = readl(&clock_manager_base->stat) & mask;
+#endif
+             /* Wait for stable lock */
              if (inter_val == mask)
                      retry++;
              else

arch/arm/mach-socfpga/clock_manager.c void cm_wait_for_lock(u32 mask) · line 43

Quoted 8 lines
arch/arm/mach-socfpga/clock_manager.c +3 -2
@@ -31,8 +38,10 @@ void cm_wait_for_lock(u32 mask)
 /* function to poll in the fsm busy bit */
 void cm_wait_for_fsm(void)
 {
-     while (readl(&clock_manager_base->stat) & CLKMGR_STAT_BUSY)
-             ;
+     wait_for_bit(__func__, (const u32 *)&clock_manager_base->stat,
+                  CLKMGR_CLKMGR_STAT_BUSY_SET_MSK,
+                  false, 20000, false);

Please do test this change on CV or AV if you didn't already.

Quoted 236 lines
arch/arm/mach-socfpga/clock_manager.c +6 -0
+
 }
 
 int set_cpu_clk_info(void)
@@ -43,7 +52,12 @@ int set_cpu_clk_info(void)
 
      gd->bd->bi_arm_freq = cm_get_mpu_clk_hz() / 1000000;
      gd->bd->bi_dsp_freq = 0;
+
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
      gd->bd->bi_ddr_freq = cm_get_sdram_clk_hz() / 1000000;
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+     gd->bd->bi_ddr_freq = 0;
+#endif
 
      return 0;
 }
arch/arm/mach-socfpga/clock_manager_arria10.c new file +213 -0
new file mode 100644
index 0000000..67b3e58
@@ -0,0 +1,1104 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <common.h>
+#include <fdtdec.h>
+#include <asm/io.h>
+#include <asm/arch/clock_manager.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static u32 eosc1_hz;
+static u32 cb_intosc_hz;
+static u32 f2s_free_hz;
+static u32 cm_l4_main_clk_hz;
+static u32 cm_l4_sp_clk_hz;
+static u32 cm_l4_mp_clk_hz;
+static u32 cm_l4_sys_free_clk_hz;
+
+struct mainpll_cfg {
+     u32 vco0_psrc;
+     u32 vco1_denom;
+     u32 vco1_numer;
+     u32 mpuclk;
+     u32 mpuclk_cnt;
+     u32 mpuclk_src;
+     u32 nocclk;
+     u32 nocclk_cnt;
+     u32 nocclk_src;
+     u32 cntr2clk_cnt;
+     u32 cntr3clk_cnt;
+     u32 cntr4clk_cnt;
+     u32 cntr5clk_cnt;
+     u32 cntr6clk_cnt;
+     u32 cntr7clk_cnt;
+     u32 cntr7clk_src;
+     u32 cntr8clk_cnt;
+     u32 cntr9clk_cnt;
+     u32 cntr9clk_src;
+     u32 cntr15clk_cnt;
+     u32 nocdiv_l4mainclk;
+     u32 nocdiv_l4mpclk;
+     u32 nocdiv_l4spclk;
+     u32 nocdiv_csatclk;
+     u32 nocdiv_cstraceclk;
+     u32 nocdiv_cspdbclk;
+};
+
+struct perpll_cfg {
+     u32 vco0_psrc;
+     u32 vco1_denom;
+     u32 vco1_numer;
+     u32 cntr2clk_cnt;
+     u32 cntr2clk_src;
+     u32 cntr3clk_cnt;
+     u32 cntr3clk_src;
+     u32 cntr4clk_cnt;
+     u32 cntr4clk_src;
+     u32 cntr5clk_cnt;
+     u32 cntr5clk_src;
+     u32 cntr6clk_cnt;
+     u32 cntr6clk_src;
+     u32 cntr7clk_cnt;
+     u32 cntr8clk_cnt;
+     u32 cntr8clk_src;
+     u32 cntr9clk_cnt;
+     u32 emacctl_emac0sel;
+     u32 emacctl_emac1sel;
+     u32 emacctl_emac2sel;
+     u32 gpiodiv_gpiodbclk;
+};
+
+struct alteragrp_cfg {
+     u32 nocclk;
+     u32 mpuclk;
+};
+
+static const struct socfpga_clock_manager *clock_manager_base =
+     (struct socfpga_clock_manager *)SOCFPGA_CLKMGR_ADDRESS;
+
+static int of_to_struct(const void *blob, int node, int cfg_len, void *cfg)
+{
+     if (fdtdec_get_int_array(blob, node, "altr,of_reg_value",
+                              (u32 *)cfg, cfg_len)) {
+             /* could not find required property */
+             return -EINVAL;
+     }
+
+     return 0;
+}
+
+static int of_get_input_clks(const void *blob, int node, u32 *val)
+{
+     *val = fdtdec_get_uint(blob, node, "clock-frequency", 0);
+     if (!*val)
+             return -EINVAL;
+
+     return 0;
+}
+
+static int of_get_clk_cfg(const void *blob, struct mainpll_cfg *main_cfg,
+                       struct perpll_cfg *per_cfg,
+                       struct alteragrp_cfg *altrgrp_cfg)
+{
+     int node, child, len;
+     const char *node_name;
+
+     node = fdtdec_next_compatible(blob, 0, COMPAT_ALTERA_SOCFPGA_CLK);
+     if (node < 0)
+             return -EINVAL;
+
+     child = fdt_first_subnode(blob, node);
+     if (child < 0)
+             return -EINVAL;
+
+     child = fdt_first_subnode(blob, child);
+     if (child < 0)
+             return -EINVAL;
+
+     node_name = fdt_get_name(blob, child, &len);
+
+     while (node_name) {
+             if (!strcmp(node_name, "osc1")) {
+                     if (of_get_input_clks(blob, child, &eosc1_hz))
+                             return -EINVAL;
+             } else if (!strcmp(node_name, "cb_intosc_ls_clk")) {
+                     if (of_get_input_clks(blob, child, &cb_intosc_hz))
+                             return -EINVAL;
+             } else if (!strcmp(node_name, "f2s_free_clk")) {
+                     if (of_get_input_clks(blob, child, &f2s_free_hz))
+                             return -EINVAL;
+             } else if (!strcmp(node_name, "main_pll")) {
+                     if (of_to_struct(blob, child,
+                                      sizeof(*main_cfg)/sizeof(u32),
+                                      main_cfg))
+                             return -EINVAL;
+             } else if (!strcmp(node_name, "periph_pll")) {
+                     if (of_to_struct(blob, child,
+                                      sizeof(*per_cfg)/sizeof(u32),
+                                      per_cfg))
+                             return -EINVAL;
+             } else if (!strcmp(node_name, "altera")) {
+                     if (of_to_struct(blob, child,
+                                      sizeof(*altrgrp_cfg)/sizeof(u32),
+                                      altrgrp_cfg))
+                             return -EINVAL;
+
+                     main_cfg->mpuclk = altrgrp_cfg->mpuclk;
+                     main_cfg->nocclk = altrgrp_cfg->nocclk;
+             }
+             child = fdt_next_subnode(blob, child);
+
+             if (child < 0)
+                     break;
+
+             node_name = fdt_get_name(blob, child, &len);
+     }
+
+     return 0;
+}
+
+/* calculate the intended main VCO frequency based on handoff */
+static unsigned int cm_calc_handoff_main_vco_clk_hz
+                                     (struct mainpll_cfg *main_cfg)
+{
+     unsigned int clk_hz;
+
+     /* Check main VCO clock source: eosc, intosc or f2s? */
+     switch (main_cfg->vco0_psrc) {
+     case CLKMGR_MAINPLL_VCO0_PSRC_EOSC:
+             clk_hz = eosc1_hz;
+             break;
+     case CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC:
+             clk_hz = cb_intosc_hz;
+             break;
+     case CLKMGR_MAINPLL_VCO0_PSRC_F2S:
+             clk_hz = f2s_free_hz;
+             break;
+     default:
+             return 0;
+     }
+
+     /* calculate the VCO frequency */
+     clk_hz /= (1 + main_cfg->vco1_denom);
+     clk_hz *= (1 + main_cfg->vco1_numer);
+
+     return clk_hz;
+}
+
+/* calculate the intended periph VCO frequency based on handoff */
+static unsigned int cm_calc_handoff_periph_vco_clk_hz(
+             struct mainpll_cfg *main_cfg, struct perpll_cfg *per_cfg)
+{
+     unsigned int clk_hz;
+
+     /* Check periph VCO clock source: eosc, intosc, f2s or mainpll? */
+     switch (per_cfg->vco0_psrc) {
+     case CLKMGR_PERPLL_VCO0_PSRC_EOSC:
+             clk_hz = eosc1_hz;
+             break;
+     case CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC:
+             clk_hz = cb_intosc_hz;
+             break;
+     case CLKMGR_PERPLL_VCO0_PSRC_F2S:
+             clk_hz = f2s_free_hz;
+             break;
+     case CLKMGR_PERPLL_VCO0_PSRC_MAIN:
+             clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+             clk_hz /= main_cfg->cntr15clk_cnt;
+             break;
+     default:
Quoted 8 lines

arch/arm/mach-socfpga/clock_manager_arria10.c line 219

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+             return 0;
+     }
+
+     /* calculate the VCO frequency */
+     clk_hz /= (1 + per_cfg->vco1_denom);
+     clk_hz *= (1 + per_cfg->vco1_numer);

Extra parenthesis around statement not needed, fix globally.

Okay.

Quoted 186 lines
Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +5 -0
+     return clk_hz;
+}
+
+/* calculate the intended MPU clock frequency based on handoff */
+static unsigned int cm_calc_handoff_mpu_clk_hz(struct mainpll_cfg *main_cfg,

arch/arm/mach-socfpga/clock_manager_arria10.c line 235

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+                                            struct perpll_cfg *per_cfg)
+{
+     unsigned int clk_hz;
+
+     /* Check MPU clock source: main, periph, osc1, intosc or f2s? */
+     switch (main_cfg->mpuclk_src) {
+     case CLKMGR_MAINPLL_MPUCLK_SRC_MAIN:
+             clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+             clk_hz /= ((main_cfg->mpuclk & CLKMGR_MAINPLL_MPUCLK_CNT_MSK)
+                        + 1);

DTTO

arch/arm/mach-socfpga/clock_manager_arria10.c line 241

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+             break;
+     case CLKMGR_MAINPLL_MPUCLK_SRC_PERI:
+             clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg);
+             clk_hz /= (((main_cfg->mpuclk >>
+                        CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB) &
+                        CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1);

DTTO

Quoted 20 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +20 -0
+             break;
+     case CLKMGR_MAINPLL_MPUCLK_SRC_OSC1:
+             clk_hz = eosc1_hz;
+             break;
+     case CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC:
+             clk_hz = cb_intosc_hz;
+             break;
+     case CLKMGR_MAINPLL_MPUCLK_SRC_FPGA:
+             clk_hz = f2s_free_hz;
+             break;
+     default:
+             return 0;
+     }
+
+     clk_hz /= (main_cfg->mpuclk_cnt + 1);
+     return clk_hz;
+}
+
+/* calculate the intended NOC clock frequency based on handoff */
+static unsigned int cm_calc_handoff_noc_clk_hz(struct mainpll_cfg *main_cfg,

arch/arm/mach-socfpga/clock_manager_arria10.c line 271

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+                                            struct perpll_cfg *per_cfg)
+{
+     unsigned int clk_hz;
+
+     /* Check MPU clock source: main, periph, osc1, intosc or f2s? */
+     switch (main_cfg->nocclk_src) {
+     case CLKMGR_MAINPLL_NOCCLK_SRC_MAIN:
+             clk_hz = cm_calc_handoff_main_vco_clk_hz(main_cfg);
+             clk_hz /= ((main_cfg->nocclk & CLKMGR_MAINPLL_NOCCLK_CNT_MSK)
+                        + 1);

DTTO

arch/arm/mach-socfpga/clock_manager_arria10.c line 277

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+             break;
+     case CLKMGR_MAINPLL_NOCCLK_SRC_PERI:
+             clk_hz = cm_calc_handoff_periph_vco_clk_hz(main_cfg, per_cfg);
+             clk_hz /= (((main_cfg->nocclk >>
+                        CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB) &
+                        CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1);

DTTO

Quoted 116 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +116 -0
+             break;
+     case CLKMGR_MAINPLL_NOCCLK_SRC_OSC1:
+             clk_hz = eosc1_hz;
+             break;
+     case CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC:
+             clk_hz = cb_intosc_hz;
+             break;
+     case CLKMGR_MAINPLL_NOCCLK_SRC_FPGA:
+             clk_hz = f2s_free_hz;
+             break;
+     default:
+             return 0;
+     }
+
+     clk_hz /= (main_cfg->nocclk_cnt + 1);
+     return clk_hz;
+}
+
+/* return 1 if PLL ramp is required */
+static int cm_is_pll_ramp_required(int main0periph1,
+                                struct mainpll_cfg *main_cfg,
+                                struct perpll_cfg *per_cfg)
+{
+     /* Check for main PLL */
+     if (main0periph1 == 0) {
+             /*
+              * PLL ramp is not required if both MPU clock and NOC clock are
+              * not sourced from main PLL
+              */
+             if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_MAIN &&
+                 main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_MAIN)
+                     return 0;
+
+             /*
+              * PLL ramp is required if MPU clock is sourced from main PLL
+              * and MPU clock is over 900MHz (as advised by HW team)
+              */
+             if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN &&
+                 (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) >
+                  CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ))
+                     return 1;
+
+             /*
+              * PLL ramp is required if NOC clock is sourced from main PLL
+              * and NOC clock is over 300MHz (as advised by HW team)
+              */
+             if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_MAIN &&
+                 (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) >
+                  CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ))
+                     return 2;
+
+     } else if (main0periph1 == 1) {
+             /*
+              * PLL ramp is not required if both MPU clock and NOC clock are
+              * not sourced from periph PLL
+              */
+             if (main_cfg->mpuclk_src != CLKMGR_MAINPLL_MPUCLK_SRC_PERI &&
+                 main_cfg->nocclk_src != CLKMGR_MAINPLL_NOCCLK_SRC_PERI)
+                     return 0;
+
+             /*
+              * PLL ramp is required if MPU clock are source from periph PLL
+              * and MPU clock is over 900MHz (as advised by HW team)
+              */
+             if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI &&
+                 (cm_calc_handoff_mpu_clk_hz(main_cfg, per_cfg) >
+                  CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ))
+                     return 1;
+
+             /*
+              * PLL ramp is required if NOC clock are source from periph PLL
+              * and NOC clock is over 300MHz (as advised by HW team)
+              */
+             if (main_cfg->nocclk_src == CLKMGR_MAINPLL_NOCCLK_SRC_PERI &&
+                 (cm_calc_handoff_noc_clk_hz(main_cfg, per_cfg) >
+                  CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ))
+                     return 2;
+     }
+
+     return 0;
+}
+
+/*
+ * Calculate the new PLL numerator which is based on existing DTS hand off and
+ * intended safe frequency (safe_hz). Note that PLL ramp is only modifying the
+ * numerator while maintaining denominator as denominator will influence the
+ * jitter condition. Please refer A10 HPS TRM for the jitter guide. Note final
+ * value for numerator is minus with 1 to cater our register value
+ * representation.
+ */
+static unsigned int cm_calc_safe_pll_numer(int main0periph1,
+                                        struct mainpll_cfg *main_cfg,
+                                        struct perpll_cfg *per_cfg,
+                                        unsigned int safe_hz)
+{
+     unsigned int clk_hz = 0;
+
+     /* Check for main PLL */
+     if (main0periph1 == 0) {
+             /* Check main VCO clock source: eosc, intosc or f2s? */
+             switch (main_cfg->vco0_psrc) {
+             case CLKMGR_MAINPLL_VCO0_PSRC_EOSC:
+                     clk_hz = eosc1_hz;
+                     break;
+             case CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC:
+                     clk_hz = cb_intosc_hz;
+                     break;
+             case CLKMGR_MAINPLL_VCO0_PSRC_F2S:
+                     clk_hz = f2s_free_hz;
+                     break;
+             default:
+                     return 0;
+             }
+
+             /* Applicable if MPU clock is from main PLL */
+             if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_MAIN) {
Quoted 8 lines

arch/arm/mach-socfpga/clock_manager_arria10.c line 399

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+                     /* calculate the safe numer value */
+                     clk_hz = (safe_hz / clk_hz) *
+                             (main_cfg->mpuclk_cnt + 1) *
+                             ((main_cfg->mpuclk &
+                               CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1) *
+                             (1 + main_cfg->vco1_denom) - 1;

Maybe you can factor out this awful equation into a function somehow ?

Okay, will refactor this part.

Quoted 140 lines
Quoted 59 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +58 -0
+             }
+             /* Reach here if MPU clk not from main PLL but NOC clk is */
+             else if (main_cfg->nocclk_src ==
+                      CLKMGR_MAINPLL_NOCCLK_SRC_MAIN) {
+                     /* calculate the safe numer value */
+                     clk_hz = (safe_hz / clk_hz) *
+                             (main_cfg->nocclk_cnt + 1) *
+                             ((main_cfg->nocclk &
+                               CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1) *
+                             (1 + main_cfg->vco1_denom) - 1;
+             } else
+                     clk_hz = 0;
+
+     } else if (main0periph1 == 1) {
+             /* Check periph VCO clock source: eosc, intosc, f2s, mainpll */
+             switch (per_cfg->vco0_psrc) {
+             case CLKMGR_PERPLL_VCO0_PSRC_EOSC:
+                     clk_hz = eosc1_hz;
+                     break;
+             case CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC:
+                     clk_hz = cb_intosc_hz;
+                     break;
+             case CLKMGR_PERPLL_VCO0_PSRC_F2S:
+                     clk_hz = f2s_free_hz;
+                     break;
+             case CLKMGR_PERPLL_VCO0_PSRC_MAIN:
+                     clk_hz = cm_calc_handoff_main_vco_clk_hz(
+                              main_cfg);
+                     clk_hz /= main_cfg->cntr15clk_cnt;
+                     break;
+             default:
+                     return 0;
+             }
+             /* Applicable if MPU clock is from periph PLL */
+             if (main_cfg->mpuclk_src == CLKMGR_MAINPLL_MPUCLK_SRC_PERI) {
+                     /* calculate the safe numer value */
+                     clk_hz = (safe_hz / clk_hz) *
+                             (main_cfg->mpuclk_cnt + 1) *
+                             (((main_cfg->mpuclk >>
+                               CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB) &
+                               CLKMGR_MAINPLL_MPUCLK_CNT_MSK) + 1) *
+                             (1 + per_cfg->vco1_denom) - 1;
+             }
+             /* Reach here if MPU clk not from periph PLL but NOC clk is */
+             else if (main_cfg->nocclk_src ==
+                      CLKMGR_MAINPLL_NOCCLK_SRC_PERI) {
+                     /* calculate the safe numer value */
+                     clk_hz = (safe_hz / clk_hz) *
+                             (main_cfg->nocclk_cnt + 1) *
+                             (((main_cfg->nocclk >>
+                               CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB) &
+                               CLKMGR_MAINPLL_NOCCLK_CNT_MSK) + 1) *
+                             (1 + per_cfg->vco1_denom) - 1;
+             } else
+                     clk_hz = 0;
+     }
+     return clk_hz;
+}

[...]

Quoted 29 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +29 -0
+unsigned int cm_get_per_vco_clk_hz(void)
+{
+     u32 src_hz = 0;
+     u32 clk_src = 0;
+     u32 numer = 0;
+     u32 denom = 0;
+     u32 vco = 0;
+
+     clk_src = readl(&clock_manager_base->per_pll.vco0);
+
+     clk_src = (clk_src >> CLKMGR_PERPLL_VCO0_PSRC_LSB) &
+             CLKMGR_PERPLL_VCO0_PSRC_MSK;
+
+     if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_EOSC) {
+             src_hz = eosc1_hz;
+     } else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC) {
+             src_hz = cb_intosc_hz;
+     } else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_F2S) {
+             src_hz = f2s_free_hz;
+     } else if (clk_src == CLKMGR_PERPLL_VCO0_PSRC_MAIN) {
+             src_hz = cm_get_main_vco_clk_hz();
+             src_hz /= (readl
+                     (&clock_manager_base->main_pll.cntr15clk) &
+                     CLKMGR_MAINPLL_CNTRCLK_MSK) + 1;
+     } else {
+             printf("cm_get_per_vco_clk_hz invalid clk_src %d\n", clk_src);
+             return 0;
+     }
+

arch/arm/mach-socfpga/clock_manager_arria10.c line 990

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+     vco = readl(&clock_manager_base->per_pll.vco1);
+
+     numer = vco & CLKMGR_PERPLL_VCO1_NUMER_MSK;
+
+     denom = (vco >> CLKMGR_PERPLL_VCO1_DENOM_LSB) &
+                     CLKMGR_PERPLL_VCO1_DENOM_MSK;
+
+     vco = src_hz;
+     vco /= (1 + denom);
+     vco *= (1 + numer);

Extra parenthesis, not needed ...

Quoted 23 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +23 -0
+     return vco;
+}
+
+unsigned int cm_get_main_vco_clk_hz(void)
+{
+     u32 src_hz, numer, denom, vco;
+
+     u32 clk_src = readl(&clock_manager_base->main_pll.vco0);
+
+     clk_src = (clk_src >> CLKMGR_MAINPLL_VCO0_PSRC_LSB) &
+             CLKMGR_MAINPLL_VCO0_PSRC_MSK;
+
+     if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_EOSC) {
+             src_hz = eosc1_hz;
+     } else if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC) {
+             src_hz = cb_intosc_hz;
+     } else if (clk_src == CLKMGR_MAINPLL_VCO0_PSRC_F2S) {
+             src_hz = f2s_free_hz;
+     } else {
+             printf("cm_get_main_vco_clk_hz invalid clk_src %d\n", clk_src);
+             return 0;
+     }
+

arch/arm/mach-socfpga/clock_manager_arria10.c line 1024

Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +10 -0
+     vco = readl(&clock_manager_base->main_pll.vco1);
+
+     numer = vco & CLKMGR_MAINPLL_VCO1_NUMER_MSK;
+
+     denom = (vco >> CLKMGR_MAINPLL_VCO1_DENOM_LSB) &
+                     CLKMGR_MAINPLL_VCO1_DENOM_MSK;
+
+     vco = src_hz;
+     vco /= (1 + denom);
+     vco *= (1 + numer);

DTTO

Quoted 1 line

btw this function looks just like the previous one ...

Similar but there are some differences.

Quoted 73 lines
Quoted 73 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +72 -0
+     return vco;
+}
+
+unsigned int cm_get_l4_sp_clk_hz(void)
+{
+     return cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB);
+}
+
+unsigned int cm_get_mmc_controller_clk_hz(void)
+{
+     u32 clk_hz = 0;
+     u32 clk_input = 0;
+
+     clk_input = readl(&clock_manager_base->per_pll.cntr6clk);
+     clk_input = (clk_input >> CLKMGR_PERPLL_CNTR6CLK_SRC_LSB) &
+             CLKMGR_PERPLLGRP_SRC_MSK;
+
+     switch (clk_input) {
+     case CLKMGR_PERPLLGRP_SRC_MAIN:
+             clk_hz = cm_get_main_vco_clk_hz();
+             clk_hz /= 1 +
+                     (readl
+                     (&clock_manager_base->main_pll.cntr6clk) &
+                     CLKMGR_MAINPLL_CNTRCLK_MSK);
+             break;
+
+     case CLKMGR_PERPLLGRP_SRC_PERI:
+             clk_hz = cm_get_per_vco_clk_hz();
+             clk_hz /= 1 + (readl
+                     (&clock_manager_base->per_pll.cntr6clk) &
+                     CLKMGR_PERPLL_CNTRCLK_MSK);
+             break;
+
+     case CLKMGR_PERPLLGRP_SRC_OSC1:
+             clk_hz = eosc1_hz;
+             break;
+
+     case CLKMGR_PERPLLGRP_SRC_INTOSC:
+             clk_hz = cb_intosc_hz;
+             break;
+
+     case CLKMGR_PERPLLGRP_SRC_FPGA:
+             clk_hz = f2s_free_hz;
+             break;
+     }
+
+     return clk_hz / 4;
+}
+
+unsigned int cm_get_spi_controller_clk_hz(void)
+{
+     return cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB);
+}
+
+unsigned int cm_get_qspi_controller_clk_hz(void)
+{
+     return  cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB);
+}
+
+void cm_print_clock_quick_summary(void)
+{
+     printf("MPU       %10ld kHz\n", cm_get_mpu_clk_hz() / 1000);
+     printf("MMC         %8d kHz\n", cm_get_mmc_controller_clk_hz() / 1000);
+     printf("QSPI        %8d kHz\n",
+            cm_get_qspi_controller_clk_hz() / 1000);
+     printf("SPI         %8d kHz\n", cm_get_spi_controller_clk_hz() / 1000);
+     printf("EOSC1       %8d kHz\n", eosc1_hz / 1000);
+     printf("cb_intosc   %8d kHz\n", cb_intosc_hz / 1000);
+     printf("f2s_free    %8d kHz\n", f2s_free_hz / 1000);
+     printf("Main VCO    %8d kHz\n", cm_get_main_vco_clk_hz() / 1000);
+     printf("NOC         %8d kHz\n", cm_get_noc_clk_hz() / 1000);
+     printf("L4 Main     %8d kHz\n",
Quoted 8 lines

arch/arm/mach-socfpga/clock_manager_arria10.c line 1103

Quoted 6 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +6 -0
+            cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB) / 1000);
+     printf("L4 MP       %8d kHz\n",
+            cm_get_l4_noc_hz(CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB) / 1000);
+     printf("L4 SP       %8d kHz\n",
+            cm_get_l4_sp_clk_hz() / 1000);
+     printf("L4 sys free %8d kHz\n", cm_l4_sys_free_clk_hz / 1000);

This should be part of the clock command ... see CV clock command.

Yes, it is part of the clock command. do_showclocks() in clock_manager.c will call to this function.

Quoted 10 lines
Quoted 10 lines
arch/arm/mach-socfpga/clock_manager_arria10.c new file +1 -0
+}
arch/arm/mach-socfpga/include/mach/clock_manager.h +0 -0
index d0d0487..ec067ae 100644
@@ -13,7 +13,13 @@ void cm_wait_for_fsm(void);
 void cm_print_clock_quick_summary(void);
 #endif
 
Quoted 4 lines

arch/arm/mach-socfpga/include/mach/clock_manager.h void cm_wait_for_fsm(void); · line 17

Quoted 2 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
+/* Common mask */
+#define CLKMGR_CLKMGR_STAT_BUSY_SET_MSK                      0x00000001

BIT(0) ?

Okay.

Quoted 11 lines
Quoted 8 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +3 -0
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/clock_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/clock_manager_arria10.h>
 #endif
+
 #endif /* _CLOCK_MANAGER_H_ */

[...]

Quoted 4 lines

arch/arm/mach-socfpga/include/mach/clock_manager.h

Quoted 2 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +2 -0
+/* mask */
+#define CLKMGR_MAINPLL_EN_S2FUSER0CLKEN_SET_MSK              0x00000040

Looks more like a BIT() to me ...

Yes, will change this and the rest.

Quoted 78 lines
Quoted 78 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +77 -0
+#define CLKMGR_MAINPLL_EN_HMCPLLREFCLKEN_SET_MSK     0x00000080
+#define CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK     0x00000100
+#define CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK              0x00000200
+#define CLKMGR_CLKMGR_STAT_BOOTCLKSRC_SET_MSK                0x00020000
+#define CLKMGR_MAINPLL_VCO0_BGPWRDN_SET_MSK          0x00000001
+#define CLKMGR_MAINPLL_VCO0_PWRDN_SET_MSK            0x00000002
+#define CLKMGR_MAINPLL_VCO0_EN_SET_MSK                       0x00000004
+#define CLKMGR_MAINPLL_VCO0_OUTRSTALL_SET_MSK                0x00000008
+#define CLKMGR_MAINPLL_VCO0_REGEXTSEL_SET_MSK                0x00000010
+#define CLKMGR_PERPLL_VCO0_BGPWRDN_SET_MSK           0x00000001
+#define CLKMGR_PERPLL_VCO0_PWRDN_SET_MSK             0x00000002
+#define CLKMGR_PERPLL_VCO0_EN_SET_MSK                        0x00000004
+#define CLKMGR_PERPLL_VCO0_OUTRSTALL_SET_MSK         0x00000008
+#define CLKMGR_PERPLL_VCO0_REGEXTSEL_SET_MSK         0x00000010
+#define CLKMGR_CLKMGR_INTR_PERPLLFBSLIP_SET_MSK              0x00000800
+#define CLKMGR_CLKMGR_INTR_MAINPLLFBSLIP_SET_MSK     0x00000400
+#define CLKMGR_CLKMGR_INTR_PERPLLRFSLIP_SET_MSK              0x00000200
+#define CLKMGR_CLKMGR_INTR_MAINPLLRFSLIP_SET_MSK     0x00000100
+#define CLKMGR_CLKMGR_INTR_PERPLLLOST_SET_MSK                0x00000008
+#define CLKMGR_CLKMGR_INTR_MAINPLLLOST_SET_MSK               0x00000004
+#define CLKMGR_CLKMGR_INTR_MAINPLLACHIEVED_SET_MSK   0x00000001
+#define CLKMGR_CLKMGR_INTR_PERPLLACHIEVED_SET_MSK    0x00000002
+#define CLKMGR_CLKMGR_CTL_BOOTMOD_SET_MSK            0x00000001
+#define CLKMGR_CLKMGR_CTL_BOOTCLK_INTOSC_SET_MSK     0x00000300
+#define CLKMGR_PERPLL_EN_RESET                               0x00000f7f
+#define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK            0x00000020
+#define CLKMGR_MAINPLL_VCO0_PSRC_MSK                 0x00000003
+#define CLKMGR_MAINPLL_VCO1_NUMER_MSK                        0x00001fff
+#define CLKMGR_MAINPLL_VCO1_DENOM_MSK                        0x0000003f
+#define CLKMGR_MAINPLL_CNTRCLK_MSK                   0x000003ff
+#define CLKMGR_PERPLL_VCO0_PSRC_MSK                  0x00000003
+#define CLKMGR_PERPLL_VCO1_NUMER_MSK                 0x00001fff
+#define CLKMGR_PERPLL_VCO1_DENOM_MSK                 0x0000003f
+#define CLKMGR_PERPLL_CNTRCLK_MSK                    0x000003ff
+#define CLKMGR_MAINPLL_MPUCLK_SRC_MSK                        0x00000007
+#define CLKMGR_MAINPLL_MPUCLK_CNT_MSK                        0x000003ff
+#define CLKMGR_MAINPLL_MPUCLK_SRC_MAIN                       0
+#define CLKMGR_MAINPLL_MPUCLK_SRC_PERI                       1
+#define CLKMGR_MAINPLL_MPUCLK_SRC_OSC1                       2
+#define CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC             3
+#define CLKMGR_MAINPLL_MPUCLK_SRC_FPGA                       4
+#define CLKMGR_MAINPLL_NOCDIV_MSK                    0x00000003
+#define CLKMGR_MAINPLL_NOCCLK_CNT_MSK                        0x000003ff
+#define CLKMGR_MAINPLL_NOCCLK_SRC_MSK                        0x00000007
+#define CLKMGR_MAINPLL_NOCCLK_SRC_MAIN                       0
+#define CLKMGR_MAINPLL_NOCCLK_SRC_PERI                       1
+#define CLKMGR_MAINPLL_NOCCLK_SRC_OSC1                       2
+#define CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC             3
+#define CLKMGR_MAINPLL_NOCCLK_SRC_FPGA                       4
+
+#define CLKMGR_PERPLLGRP_SRC_MSK                     0x00000007
+#define CLKMGR_PERPLLGRP_SRC_MAIN                    0
+#define CLKMGR_PERPLLGRP_SRC_PERI                    1
+#define CLKMGR_PERPLLGRP_SRC_OSC1                    2
+#define CLKMGR_PERPLLGRP_SRC_INTOSC                  3
+#define CLKMGR_PERPLLGRP_SRC_FPGA                    4
+
+/* bit shifting macro */
+#define CLKMGR_MAINPLL_VCO0_PSRC_LSB         8
+#define CLKMGR_PERPLL_VCO0_PSRC_LSB          8
+#define CLKMGR_MAINPLL_VCO1_DENOM_LSB                16
+#define CLKMGR_PERPLL_VCO1_DENOM_LSB         16
+#define CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB    16
+#define CLKMGR_MAINPLL_NOCCLK_SRC_LSB                16
+#define CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB  0
+#define CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB    8
+#define CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB    16
+#define CLKMGR_MAINPLL_NOCDIV_CSATCLK_LSB    24
+#define CLKMGR_MAINPLL_NOCDIV_CSTRACECLK_LSB 26
+#define CLKMGR_MAINPLL_NOCDIV_CSPDBGCLK_LSB  28
+#define CLKMGR_MAINPLL_MPUCLK_SRC_LSB                16
+#define CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB    16
+#define CLKMGR_MAINPLL_NOCCLK_SRC_LSB                16
+#define CLKMGR_MAINPLL_CNTR7CLK_SRC_LSB              16
+#define CLKMGR_MAINPLL_CNTR9CLK_SRC_LSB              16
+#define CLKMGR_PERPLL_CNTR2CLK_SRC_LSB               16
+#define CLKMGR_PERPLL_CNTR3CLK_SRC_LSB               16
Quoted 8 lines

arch/arm/mach-socfpga/include/mach/clock_manager.h

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/clock_manager.h +8 -0
+#define CLKMGR_PERPLL_CNTR4CLK_SRC_LSB               16
+#define CLKMGR_PERPLL_CNTR5CLK_SRC_LSB               16
+#define CLKMGR_PERPLL_CNTR6CLK_SRC_LSB               16
+#define CLKMGR_PERPLL_CNTR8CLK_SRC_LSB               16
+#define CLKMGR_PERPLL_EMACCTL_EMAC0SEL_LSB   26
+#define CLKMGR_PERPLL_EMACCTL_EMAC1SEL_LSB   27
+#define CLKMGR_PERPLL_EMACCTL_EMAC2SEL_LSB   28
+

Regards
Ley Foon

#29 lore raw

PATCH v2 12/20 arm: socfpga: Add pinmux for Arria 10

In reply to Marek Vasut
Quoted 43 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan

Add pinmux support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile              |  1 +
 arch/arm/mach-socfpga/include/mach/pinmux.h | 15 +++++
 arch/arm/mach-socfpga/pinmux_arria10.c      | 96 +++++++++++++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/pinmux.h
 create mode 100644 arch/arm/mach-socfpga/pinmux_arria10.c
arch/arm/mach-socfpga/Makefile +1 -0
index 9c4617f..68d55e4 100644
@@ -12,6 +12,7 @@ obj-y       += misc.o timer.o reset_manager.o clock_manager.o \
 
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += clock_manager_arria10.o \
                                      misc_arria10.o          \
+                                     pinmux_arria10.o        \
                                      reset_manager_arria10.o
 
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
arch/arm/mach-socfpga/include/mach/pinmux.h new file +0 -0
new file mode 100644
index 0000000..c5d5dd6

arch/arm/mach-socfpga/include/mach/pinmux.h line 8

Quoted 8 lines
arch/arm/mach-socfpga/include/mach/pinmux.h new file +8 -0
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+
+#ifndef      _PINMUX_H_
+#define      _PINMUX_H_

#ifndef[SPACE]FOO
#define[SPACE]FOO

Quoted 1 line

please fix globally

Okay.

Quoted 34 lines
Quoted 34 lines
arch/arm/mach-socfpga/include/mach/pinmux.h new file +6 -0
+#ifndef __ASSEMBLY__
+int config_dedicated_pins(const void *blob);
+int config_pins(const void *blob, const char *pin_grp);
+#endif
+
+#endif /* _PINMUX_H_ */
arch/arm/mach-socfpga/pinmux_arria10.c new file +21 -0
new file mode 100644
index 0000000..47339ea
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (C) 2016-2017 Intel Corporation <www.intel.com>
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+
+#include <asm/arch/pinmux.h>
+#include <asm/io.h>
+#include <common.h>
+#include <fdtdec.h>
+
+static int do_pinctr_pin(const void *blob, int child, const char *node_name)
+{
+     int len;
+     fdt_addr_t base_addr;
+     fdt_size_t size;
+     const u32 *cell;
+     u32 offset, value;
+
+     base_addr = fdtdec_get_addr_size(blob, child, "reg", &size);
+     if (base_addr != FDT_ADDR_T_NONE) {
Quoted 8 lines

arch/arm/mach-socfpga/pinmux_arria10.c line 24

Quoted 3 lines
arch/arm/mach-socfpga/pinmux_arria10.c new file +3 -0
+             cell = fdt_getprop(blob, child, "pinctrl-single,pins",
+                     &len);
+             if (cell != NULL && len > 0) {

if (!cell)
continue;
if (len <= 0)
continue;

Will change to something like this:
if (!cell || len <= 0)

        return -EFAULT;

[...]

Regards
Ley Foon

#11 lore raw

PATCH v2 4/20 arm: socfpga: Restructure misc driver

In reply to Marek Vasut
Quoted 58 lines · Marek Vasut
Quoted 57 lines · Ley Foon Tan
Quoted 56 lines · Marek Vasut
Quoted 43 lines · Ley Foon Tan

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to _gen5 file. No functional change.

Change all uint32_t_to u32.

---
 arch/arm/mach-socfpga/Makefile            |   3 +-
 arch/arm/mach-socfpga/include/mach/misc.h |  26 +++
 arch/arm/mach-socfpga/misc.c              | 361 ++----------------------------
 arch/arm/mach-socfpga/misc_gen5.c         | 355 +++++++++++++++++++++++++++++
 4 files changed, 398 insertions(+), 347 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 create mode 100644 arch/arm/mach-socfpga/misc_gen5.c
arch/arm/mach-socfpga/Makefile +2 -1
index 97819ac..5b09ea9 100644
@@ -14,7 +14,8 @@ obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5)    += scan_manager.o wrap_pll_config.o \
-                                        clock_manager_gen5.o reset_manager_gen5.o
+                                        clock_manager_gen5.o reset_manager_gen5.o \
+                                        misc_gen5.o
 obj-$(CONFIG_SPL_BUILD) += wrap_iocsr_config.o wrap_pinmux_config.o  \
                         wrap_sdram_config.o
 CFLAGS_wrap_iocsr_config.o   += -I$(srctree)/board/$(BOARDDIR)
arch/arm/mach-socfpga/include/mach/misc.h new file +8 -0
new file mode 100644
index 0000000..64f9b86
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _MISC_H_
+#define _MISC_H_

arch/arm/mach-socfpga/include/mach/misc.h line 18

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/misc.h new file +10 -0
+
+void dwmac_deassert_reset(const unsigned int of_reset_id,
+                              const u32 phymode);
+
+struct bsel {
+     const char      *mode;
+     const char      *name;
+};
+
+extern struct bsel bsel_str[];

I'm really not a big fan of extern variables, can we get rid of this?

Quoted 4 lines
Quoted 2 lines

For public variable, we need extern keyword here. Only function prototype doesn't need the extern.

Why does this have to be in public namespace anyway ?

We have same bsel_str[] array shared by both Gen5 and A10. It used by both misc_gen5.c and misc_arria10.c.

Regards
Ley Foon

#34 lore raw

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

In reply to Marek Vasut
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
Quoted 11 lines

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 29

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -0
 struct socfpga_reset_manager {
      u32     stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
index 547a8bb..bbf54f0 100644
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
      ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
      ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)

Should be part of reset manager patch ...

Do you mean by the reset_uart() below? In the last review, you comment that uart_com_port() is in later patch (misc path) of reset manager patch. So, I moved this function to this here. Let me know if you prefer a new patch this reset_uart().

Quoted 106 lines
Quoted 106 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +18 -0
+void reset_uart(int assert)
+{
+     u32 mask = 0;
+     unsigned int com_port;
+
+     com_port = uart_com_port(gd->fdt_blob);
+
+     if (com_port == SOCFPGA_UART1_ADDRESS)
+             mask |= ALT_RSTMGR_PER1MODRST_UART1_SET_MSK;
+     else if (com_port == SOCFPGA_UART0_ADDRESS)
+             mask |= ALT_RSTMGR_PER1MODRST_UART0_SET_MSK;
+
+     if (assert)
+             setbits_le32(&reset_manager_base->per1modrst, mask);
+     else
+             clrbits_le32(&reset_manager_base->per1modrst, mask);
+}
+
 static const u32 per0fpgamasks[] = {
      ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
      ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK,
arch/arm/mach-socfpga/spl.c +45 -2
index fec4c7a..5c0cc98 100644
@@ -19,23 +19,32 @@
 #include <asm/arch/sdram.h>
 #include <asm/arch/scu.h>
 #include <asm/arch/nic301.h>
+#include <asm/sections.h>
+#include <fdtdec.h>
+#include <watchdog.h>
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/pinmux.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct pl310_regs *const pl310 =
      (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
 static struct scu_registers *scu_regs =
      (struct scu_registers *)SOCFPGA_MPUSCU_ADDRESS;
 static struct nic301_registers *nic301_regs =
      (struct nic301_registers *)SOCFPGA_L3REGS_ADDRESS;
-static struct socfpga_system_manager *sysmgr_regs =
+#endif
+
+static const struct socfpga_system_manager *sysmgr_regs =
      (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
 
 u32 spl_boot_device(void)
 {
      const u32 bsel = readl(&sysmgr_regs->bootinfo);
 
-     switch (bsel & 0x7) {
+     switch ((bsel >> SYSMGR_BOOTINFO_BSEL_SHIFT) & 0x7) {
      case 0x1:       /* FPGA (HPS2FPGA Bridge) */
              return BOOT_DEVICE_RAM;
      case 0x2:       /* NAND Flash (1.8V) */
@@ -68,6 +77,7 @@ u32 spl_boot_mode(const u32 boot_device)
 }
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static void socfpga_nic301_slave_ns(void)
 {
      writel(0x1, &nic301_regs->lwhps2fpgaregs);
@@ -182,3 +192,44 @@ void board_init_f(ulong dummy)
      /* Configure simple malloc base pointer into RAM. */
      gd->malloc_base = CONFIG_SYS_TEXT_BASE + (1024 * 1024);
 }
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#ifdef CONFIG_SPL_BOARD_INIT
+void spl_board_init(void)
+{
+     /* configuring the clock based on handoff */
+     cm_basic_init(gd->fdt_blob);
+     WATCHDOG_RESET();
+
+     config_dedicated_pins(gd->fdt_blob);
+     WATCHDOG_RESET();
+
+     /* Release UART from reset */
+     reset_uart(0);
+
+     /* enable console uart printing */
+     preloader_console_init();
+}
+#endif
+
+void board_init_f(ulong dummy)
+{
+     /*
+      * Configure Clock Manager to use intosc clock instead external osc to
+      * ensure success watchdog operation. We do it as early as possible.
+      */
+     cm_use_intosc();
+
+     watchdog_disable();
+
+     arch_early_init_r();
+
+#ifdef CONFIG_HW_WATCHDOG
+     /* release osc1 watchdog timer 0 from reset */
Quoted 8 lines

arch/arm/mach-socfpga/spl.c void board_init_f(ulong dummy) · line 235

Quoted 8 lines
arch/arm/mach-socfpga/spl.c +8 -0
+     reset_deassert_osc1wd0();
+
+     /* reconfigure and enable the watchdog */
+     hw_watchdog_init();
+     WATCHDOG_RESET();
+#endif /* CONFIG_HW_WATCHDOG */
+}
+#endif

Regards
Ley Foon

#40 lore raw

PATCH v2 16/20 drivers: fpga: Add compile switch for Gen5 only registers

In reply to Marek Vasut
Quoted 4 lines · Marek Vasut
Quoted 1 line · Ley Foon Tan

These registers only available for Gen5 device, excludes them

exclude

Okay.

Quoted 4 lines
Quoted 2 lines

if for Arria 10 build.

s/if for/from/

Okay.

Quoted 37 lines
Quoted 37 lines
---
 drivers/fpga/socfpga.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/fpga/socfpga.c +4 -0
index f1b2f2c..3751574 100644
@@ -19,8 +19,10 @@ DECLARE_GLOBAL_DATA_PTR;
 
 static struct socfpga_fpga_manager *fpgamgr_regs =
      (struct socfpga_fpga_manager *)SOCFPGA_FPGAMGRREGS_ADDRESS;
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static struct socfpga_system_manager *sysmgr_regs =
      (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+#endif
 
 /* Set CD ratio */
 static void fpgamgr_set_cd_ratio(unsigned long ratio)
@@ -268,8 +270,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
 
      /* Prior programming the FPGA, all bridges need to be shut off */
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
      /* Disable all signals from hps peripheral controller to fpga */
      writel(0, &sysmgr_regs->fpgaintfgrp_module);
+#endif
 
      /* Disable all signals from FPGA to HPS SDRAM */
 #define SDR_CTRLGRP_FPGAPORTRST_ADDRESS      0x5080
@@ -278,8 +282,10 @@ int socfpga_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
      /* Disable all axi bridge (hps2fpga, lwhps2fpga & fpga2hps) */
      socfpga_bridges_reset(1);
 
Quoted 8 lines

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

Quoted 8 lines
drivers/fpga/socfpga.c +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
      /* Unmap the bridges from NIC-301 */
      writel(0x1, SOCFPGA_L3REGS_ADDRESS);
+#endif
 
      /* Initialize the FPGA Manager */
      status = fpgamgr_program_init();

Regards
Ley Foon

#50 lore raw

PATCH v2 18/20 arm: socfpga: Add config and defconfig for Arria 10

In reply to Marek Vasut
Quoted 64 lines · Marek Vasut
Quoted 63 lines · Ley Foon Tan

Add config and defconfig for the Arria10 and update socfpga_common.h.

---
 configs/socfpga_arria10_defconfig       | 30 +++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 67 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 ++++++++++++--
 3 files changed, 121 insertions(+), 4 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
configs/socfpga_arria10_defconfig new file +30 -0
new file mode 100644
index 0000000..9e6bc1e0
@@ -0,0 +1,30 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SOCFPGA=y
+CONFIG_SYS_MALLOC_F_LEN=0x2000
+CONFIG_TARGET_SOCFPGA_ARRIA10_SOCDK=y
+CONFIG_IDENT_STRING="socfpga_arria10"
+CONFIG_DEFAULT_DEVICE_TREE="socfpga_arria10_socdk_sdmmc"
+CONFIG_DEFAULT_FDT_FILE="socfpga_arria10_socdk_sdmmc.dtb"
+CONFIG_SPL=y
+CONFIG_CMD_BOOTZ=y
+# CONFIG_CMD_IMLS is not set
+CONFIG_CMD_ASKENV=y
+CONFIG_CMD_GREPENV=y
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_MMC=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_CACHE=y
+CONFIG_CMD_EXT4=y
+CONFIG_CMD_EXT4_WRITE=y
+CONFIG_DOS_PARTITION=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_DM=y
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_DM_GPIO=y
+CONFIG_DWAPB_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_SYS_NS16550=y
+CONFIG_USE_TINY_PRINTF=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION_TYPE=y
+CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_TYPE=0xa2
include/configs/socfpga_arria10_socdk.h new file +9 -0
new file mode 100644
index 0000000..5b7d572
@@ -0,0 +1,67 @@
+/*
+ *  Copyright (C) 2015-2017 Altera Corporation <www.altera.com>
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+
+#ifndef __CONFIG_SOCFGPA_ARRIA10_H__
+#define __CONFIG_SOCFGPA_ARRIA10_H__
+
Quoted 8 lines

include/configs/socfpga_arria10_socdk.h line 15

Quoted 6 lines
include/configs/socfpga_arria10_socdk.h new file +6 -0
+#include <asm/arch/base_addr_a10.h>
+/* U-Boot Commands */
+#define CONFIG_FAT_WRITE
+#define CONFIG_HW_WATCHDOG
+
+

Drop this extra newline

Okay.

Quoted 116 lines
Quoted 116 lines
include/configs/socfpga_arria10_socdk.h new file +52 -0
+/* Booting Linux */
+#define CONFIG_LOADADDR              0x01000000
+#define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
+
+/*
+ * U-Boot general configurations
+ */
+/* Cache options */
+#define CONFIG_SYS_DCACHE_OFF
+
+/* Memory configurations  */
+#define PHYS_SDRAM_1_SIZE            0x80000000
+
+/* Ethernet on SoC (EMAC) */
+#if defined(CONFIG_CMD_NET)
+#define CONFIG_PHY_MICREL
+#define CONFIG_PHY_MICREL_KSZ9031
+#endif
+
+/*
+ * U-Boot environment configurations
+ */
+#define CONFIG_ENV_IS_IN_MMC
+
+/*
+ * arguments passed to the bootz command. The value of
+ * CONFIG_BOOTARGS goes into the environment value "bootargs".
+ * Do note the value will overide also the chosen node in FDT blob.
+ */
+#define CONFIG_BOOTARGS "console=ttyS0," __stringify(CONFIG_BAUDRATE)
+
+/*
+ * Serial / UART configurations
+ */
+#define CONFIG_SYS_NS16550_MEM32
+#define CONFIG_SYS_BAUDRATE_TABLE {4800, 9600, 19200, 38400, 57600, 115200}
+
+/*
+ * L4 OSC1 Timer 0
+ */
+/* reload value when timer count to zero */
+#define TIMER_LOAD_VAL                       0xFFFFFFFF
+
+/*
+ * Flash configurations
+ */
+#define CONFIG_SYS_MAX_FLASH_BANKS     1
+
+/* The rest of the configuration is shared */
+#include <configs/socfpga_common.h>
+
+#endif       /* __CONFIG_SOCFGPA_ARRIA10_H__ */
include/configs/socfpga_common.h +14 -4
index bc92a2c..a228ea5 100644
@@ -34,9 +34,13 @@
 #define CONFIG_SYS_MALLOC_LEN                (64 * 1024 * 1024)
 #define CONFIG_SYS_MEMTEST_START     PHYS_SDRAM_1
 #define CONFIG_SYS_MEMTEST_END               PHYS_SDRAM_1_SIZE
-
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SYS_INIT_RAM_ADDR     0xFFFF0000
 #define CONFIG_SYS_INIT_RAM_SIZE     0x10000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_INIT_RAM_ADDR     0xFFE00000
+#define CONFIG_SYS_INIT_RAM_SIZE     0x40000 /* 256KB */
+#endif
 #define CONFIG_SYS_INIT_SP_OFFSET            \
      (CONFIG_SYS_INIT_RAM_SIZE - GENERATED_GBL_DATA_SIZE)
 #define CONFIG_SYS_INIT_SP_ADDR                      \
@@ -67,8 +71,10 @@
 #define CONFIG_SYS_HOSTNAME  CONFIG_SYS_BOARD
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif
 
 /*
  * Cache
@@ -103,13 +109,14 @@
 /*
  * FPGA Driver
  */
+#ifdef CONFIG_TARGET_SOCFPGA_GEN5
 #ifdef CONFIG_CMD_FPGA
 #define CONFIG_FPGA
 #define CONFIG_FPGA_ALTERA
 #define CONFIG_FPGA_SOCFPGA
 #define CONFIG_FPGA_COUNT            1
 #endif
-
+#endif
 /*
  * L4 OSC1 Timer 0
  */
@@ -209,11 +216,14 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_REG_SIZE  -4
-#define CONFIG_SYS_NS16550_COM1              SOCFPGA_UART0_ADDRESS
 #ifdef CONFIG_SOCFPGA_VIRTUAL_TARGET
 #define CONFIG_SYS_NS16550_CLK               1000000
-#else
+#elif defined(CONFIG_TARGET_SOCFPGA_GEN5)
+#define CONFIG_SYS_NS16550_COM1              SOCFPGA_UART0_ADDRESS
 #define CONFIG_SYS_NS16550_CLK               100000000
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SYS_NS16550_COM1        SOCFPGA_UART1_ADDRESS
+#define CONFIG_SYS_NS16550_CLK               50000000
 #endif
 #define CONFIG_CONS_INDEX            1
 #define CONFIG_BAUDRATE                      115200
Quoted 8 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 315

Quoted 6 lines
include/configs/socfpga_common.h +1 -0
@@ -301,7 +311,12 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE         CONFIG_SYS_INIT_RAM_ADDR
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_SPL_MAX_SIZE          (64 * 1024)

This should also be INIT_RAM_SIZE IMO ^^

Yes, you are right. Will change this.

Quoted 22 lines
Quoted 22 lines
include/configs/socfpga_common.h +9 -0
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_MAX_SIZE          CONFIG_SYS_INIT_RAM_SIZE
+#define CONFIG_SPL_BOARD_INIT
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -349,10 +364,15 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define BOOT_TARGET_DEVICES(func) \
      BOOT_TARGET_DEVICES_MMC(func) \
      BOOT_TARGET_DEVICES_PXE(func) \
      func(DHCP, dhcp, na)
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define BOOT_TARGET_DEVICES(func) \
+     BOOT_TARGET_DEVICES_MMC(func)
+#endif
 
Quoted 2 lines

include/configs/socfpga_common.h unsigned int cm_get_qspi_controller_clk_hz(void); · line 378

Quoted 2 lines
include/configs/socfpga_common.h +0 -0
 #include <config_distro_bootcmd.h>
 

Regards
Ley Foon

#35 lore raw

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

In reply to Ley Foon Tan
Quoted 33 lines · Ley Foon Tan
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
Quoted 11 lines

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 29

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -0
 struct socfpga_reset_manager {
      u32     stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
index 547a8bb..bbf54f0 100644
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
      ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
      ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)

Should be part of reset manager patch ...

Quoted 4 lines

Do you mean by the reset_uart() below? In the last review, you comment that uart_com_port() is in later patch (misc path) of reset manager patch. So, I moved this function to this here. Let me know if you prefer a new patch this reset_uart().

It just doesn't seem right to have reset-manager code bits in SPL patch, that's all . Do you mean you have the uart_com_port() function in misc.c and this reset manager bit depends on it ? Then swap patches 3 and 4 and you can wrap this function into the reset manager part, no?

Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +18 -0
+void reset_uart(int assert)
+{
+     u32 mask = 0;
+     unsigned int com_port;
+
+     com_port = uart_com_port(gd->fdt_blob);
+
+     if (com_port == SOCFPGA_UART1_ADDRESS)
+             mask |= ALT_RSTMGR_PER1MODRST_UART1_SET_MSK;
+     else if (com_port == SOCFPGA_UART0_ADDRESS)
+             mask |= ALT_RSTMGR_PER1MODRST_UART0_SET_MSK;
+
+     if (assert)
+             setbits_le32(&reset_manager_base->per1modrst, mask);
+     else
+             clrbits_le32(&reset_manager_base->per1modrst, mask);
+}
+

[...]

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

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

Quoted 39 lines · Marek Vasut
Quoted 33 lines · Ley Foon Tan
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
Quoted 11 lines

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 29

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -0
 struct socfpga_reset_manager {
      u32     stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
index 547a8bb..bbf54f0 100644
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
      ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
      ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)

Should be part of reset manager patch ...

Quoted 4 lines

Do you mean by the reset_uart() below? In the last review, you comment that uart_com_port() is in later patch (misc path) of reset manager patch. So, I moved this function to this here. Let me know if you prefer a new patch this reset_uart().

Quoted 4 lines

It just doesn't seem right to have reset-manager code bits in SPL patch, that's all . Do you mean you have the uart_com_port() function in misc.c and this reset manager bit depends on it ? Then swap patches 3 and 4 and you can wrap this function into the reset manager part, no?

uart_com_port() is in patch 10 (misc arria10). I can't swap reset arria 10 and misc arria 10 because misc arria 10 got dependency on reset arria 10 patch too..:(
What I mean is add a new patch just before this SPL patch to add reset_uart().

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +10 -0
+void reset_uart(int assert)
+{
+     u32 mask = 0;
+     unsigned int com_port;
+
+     com_port = uart_com_port(gd->fdt_blob);
+
+     if (com_port == SOCFPGA_UART1_ADDRESS)
+             mask |= ALT_RSTMGR_PER1MODRST_UART1_SET_MSK;
+     else if (com_port == SOCFPGA_UART0_ADDRESS)
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 48

Quoted 8 lines
arch/arm/mach-socfpga/reset_manager_arria10.c +8 -0
+             mask |= ALT_RSTMGR_PER1MODRST_UART0_SET_MSK;
+
+     if (assert)
+             setbits_le32(&reset_manager_base->per1modrst, mask);
+     else
+             clrbits_le32(&reset_manager_base->per1modrst, mask);
+}
+

Regards
Ley Foon

#43 lore raw

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

In reply to Marek Vasut
Quoted 37 lines · Marek Vasut
Quoted 36 lines · Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
Quoted 8 lines

drivers/ddr/altera/Kconfig line 2

Quoted 6 lines

index 0000000..9554da7

drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+     bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

The existing DDR driver is for Gen5 only. We will have new DDR driver for Arria 10 in later patchset.

Quoted 12 lines
Quoted 12 lines
drivers/ddr/altera/Kconfig new file +4 -0
+     default y if TARGET_SOCFPGA_GEN5
+     help
+       This is for building the SDRAM controller for the Arria5/Cyclone5
+       devices.
include/configs/socfpga_common.h +0 -0
index 55e0bf9..bc92a2c 100644
@@ -77,11 +77,6 @@
 #define CONFIG_SYS_PL310_BASE                SOCFPGA_MPUL2_ADDRESS
 
Quoted 10 lines

include/configs/socfpga_common.h line 82

Quoted 10 lines
include/configs/socfpga_common.h +0 -5
 /*
- * SDRAM controller
- */
-#define CONFIG_ALTERA_SDRAM
-
-/*
  * EPCS/EPCQx1 Serial Flash Controller
  */
 #ifdef CONFIG_ALTERA_SPI

Regards
Ley Foon

#44 lore raw

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

Quoted 46 lines · Ley Foon Tan
Quoted 37 lines · Marek Vasut
Quoted 36 lines · Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
Quoted 8 lines

drivers/ddr/altera/Kconfig line 2

Quoted 6 lines

index 0000000..9554da7

drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+     bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

Quoted 2 lines

The existing DDR driver is for Gen5 only. We will have new DDR driver for Arria 10 in later patchset.

I was asking about the SDRAM support in Gen5 controller though :)

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

PATCH v2 15/20 arm: socfpga: Add SPL support for Arria 10

In reply to Ley Foon Tan
Quoted 45 lines · Ley Foon Tan
Quoted 39 lines · Marek Vasut
Quoted 33 lines · Ley Foon Tan
Quoted 21 lines · Marek Vasut
Quoted 20 lines · Ley Foon Tan

Add SPL support for Arria 10 and add reset_uart() to use in SPL.

---
 .../include/mach/reset_manager_arria10.h           |  1 +
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 18 +++++++
 arch/arm/mach-socfpga/spl.c                        | 55 +++++++++++++++++++++-
 3 files changed, 72 insertions(+), 2 deletions(-)
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +1 -0
index e3171d1..d0711cf 100644
@@ -14,6 +14,7 @@ void emac_manage_reset(ulong emacbase, uint state);
 int reset_deassert_bridges_handoff(void);
 void reset_assert_fpga_connected_peripherals(void);
 void reset_deassert_osc1wd0(void);
+void reset_uart(int assert);
 
Quoted 11 lines

arch/arm/mach-socfpga/reset_manager_arria10.c static const struct socfpga_system_manager *sysmgr_regs = · line 29

Quoted 9 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h +0 -0
 struct socfpga_reset_manager {
      u32     stat;
arch/arm/mach-socfpga/reset_manager_arria10.c +0 -0
index 547a8bb..bbf54f0 100644
@@ -28,6 +28,24 @@ static const struct socfpga_system_manager *sysmgr_regs =
      ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
      ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)

Should be part of reset manager patch ...

Quoted 4 lines

Do you mean by the reset_uart() below? In the last review, you comment that uart_com_port() is in later patch (misc path) of reset manager patch. So, I moved this function to this here. Let me know if you prefer a new patch this reset_uart().

Quoted 4 lines

It just doesn't seem right to have reset-manager code bits in SPL patch, that's all . Do you mean you have the uart_com_port() function in misc.c and this reset manager bit depends on it ? Then swap patches 3 and 4 and you can wrap this function into the reset manager part, no?

Quoted 5 lines

uart_com_port() is in patch 10 (misc arria10). I can't swap reset arria 10 and misc arria 10 because misc arria 10 got dependency on reset arria 10 patch too..:(
What I mean is add a new patch just before this SPL patch to add reset_uart().

Well uh, I have to admit I'm a bit lost in the series and the discussion. Is there any chance you can make the series bisectable ? That's what I'd like to see.

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

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

In reply to Marek Vasut
Quoted 47 lines · Marek Vasut
Quoted 46 lines · Ley Foon Tan
Quoted 45 lines · Marek Vasut
Quoted 40 lines · Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
index 0000000..9554da7

drivers/ddr/altera/Kconfig line 2

Quoted 2 lines
drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+     bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

Quoted 4 lines
Quoted 2 lines

The existing DDR driver is for Gen5 only. We will have new DDR driver for Arria 10 in later patchset.

I was asking about the SDRAM support in Gen5 controller though :)

Yes, it support for double data rate 2 (DDR2), DDR3, and low-power DDR2 (LPDDR2) SDRAM.

Regards
Ley Foon

#18 lore raw

PATCH v2 7/20 arm: socfpga: Add reset driver support for Arria 10

In reply to Marek Vasut
Quoted 59 lines · Marek Vasut
Quoted 58 lines · Ley Foon Tan

Add reset driver support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile                     |   2 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   2 +
 .../include/mach/reset_manager_arria10.h           | 143 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 362 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 612 insertions(+)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h
 create mode 100644 arch/arm/mach-socfpga/reset_manager_arria10.c
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h
arch/arm/mach-socfpga/Makefile +2 -0
index e83da2e..d81f003 100644
@@ -10,6 +10,8 @@
 obj-y        += misc.o timer.o reset_manager.o clock_manager.o \
         fpga_manager.o board.o
 
+obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += reset_manager_arria10.o
+
 obj-$(CONFIG_SPL_BUILD) += spl.o freeze_controller.o
 
 # QTS-generated config file wrappers
arch/arm/mach-socfpga/include/mach/reset_manager.h +2 -0
index 9e253bf..57dc034 100644
@@ -45,6 +45,8 @@ void socfpga_per_reset_all(void);
 
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #include <asm/arch/reset_manager_gen5.h>
+#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#include <asm/arch/reset_manager_arria10.h>
 #endif
 
 #endif /* _RESET_MANAGER_H_ */
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +11 -0
new file mode 100644
index 0000000..e3171d1
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:  GPL-2.0
+ */
+
+#ifndef _RESET_MANAGER_ARRIA10_H_
+#define _RESET_MANAGER_ARRIA10_H_
+
+void watchdog_disable(void);
+void reset_deassert_noc_ddr_scheduler(void);
Quoted 8 lines

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

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +5 -0
+int is_wdt_in_reset(void);
+void emac_manage_reset(ulong emacbase, uint state);
+int reset_deassert_bridges_handoff(void);
+void reset_assert_fpga_connected_peripherals(void);
+void reset_deassert_osc1wd0(void);

Nit, it'd be nice to prefix all exported functions with socfpga_ , so it's obvious where they come from if you debug u-boot .

Okay.

Quoted 466 lines
Quoted 466 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +126 -0
+struct socfpga_reset_manager {
+     u32     stat;
+     u32     ramstat;
+     u32     miscstat;
+     u32     ctrl;
+     u32     hdsken;
+     u32     hdskreq;
+     u32     hdskack;
+     u32     counts;
+     u32     mpumodrst;
+     u32     per0modrst;
+     u32     per1modrst;
+     u32     brgmodrst;
+     u32     sysmodrst;
+     u32     coldmodrst;
+     u32     nrstmodrst;
+     u32     dbgmodrst;
+     u32     mpuwarmmask;
+     u32     per0warmmask;
+     u32     per1warmmask;
+     u32     brgwarmmask;
+     u32     syswarmmask;
+     u32     nrstwarmmask;
+     u32     l3warmmask;
+     u32     tststa;
+     u32     tstscratch;
+     u32     hdsktimeout;
+     u32     hmcintr;
+     u32     hmcintren;
+     u32     hmcintrens;
+     u32     hmcintrenr;
+     u32     hmcgpout;
+     u32     hmcgpin;
+};
+
+/*
+ * SocFPGA Arria10 reset IDs, bank mapping is as follows:
+ * 0 ... mpumodrst
+ * 1 ... per0modrst
+ * 2 ... per1modrst
+ * 3 ... brgmodrst
+ * 4 ... sysmodrst
+ */
+#define RSTMGR_EMAC0         RSTMGR_DEFINE(1, 0)
+#define RSTMGR_EMAC1         RSTMGR_DEFINE(1, 1)
+#define RSTMGR_EMAC2         RSTMGR_DEFINE(1, 2)
+#define RSTMGR_NAND          RSTMGR_DEFINE(1, 5)
+#define RSTMGR_QSPI          RSTMGR_DEFINE(1, 6)
+#define RSTMGR_SDMMC         RSTMGR_DEFINE(1, 7)
+#define RSTMGR_DMA           RSTMGR_DEFINE(1, 16)
+#define RSTMGR_SPIM0         RSTMGR_DEFINE(1, 17)
+#define RSTMGR_SPIM1         RSTMGR_DEFINE(1, 18)
+#define RSTMGR_L4WD0         RSTMGR_DEFINE(2, 0)
+#define RSTMGR_L4WD1         RSTMGR_DEFINE(2, 1)
+#define RSTMGR_L4SYSTIMER0   RSTMGR_DEFINE(2, 2)
+#define RSTMGR_L4SYSTIMER1   RSTMGR_DEFINE(2, 3)
+#define RSTMGR_SPTIMER0              RSTMGR_DEFINE(2, 4)
+#define RSTMGR_SPTIMER1              RSTMGR_DEFINE(2, 5)
+#define RSTMGR_UART0         RSTMGR_DEFINE(2, 16)
+#define RSTMGR_UART1         RSTMGR_DEFINE(2, 17)
+#define RSTMGR_DDRSCH                RSTMGR_DEFINE(3, 6)
+
+#define ALT_RSTMGR_CTL_SWWARMRSTREQ_SET_MSK  BIT(1)
+#define ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK  BIT(0)
+#define ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK  BIT(1)
+#define ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK  BIT(2)
+#define ALT_RSTMGR_PER0MODRST_USB0_SET_MSK   BIT(3)
+#define ALT_RSTMGR_PER0MODRST_USB1_SET_MSK   BIT(4)
+#define ALT_RSTMGR_PER0MODRST_NAND_SET_MSK   BIT(5)
+#define ALT_RSTMGR_PER0MODRST_QSPI_SET_MSK   BIT(6)
+#define ALT_RSTMGR_PER0MODRST_SDMMC_SET_MSK  BIT(7)
+#define ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK       BIT(8)
+#define ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK       BIT(9)
+#define ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK       BIT(10)
+#define ALT_RSTMGR_PER0MODRST_USBECC0_SET_MSK        BIT(11)
+#define ALT_RSTMGR_PER0MODRST_USBECC1_SET_MSK        BIT(12)
+#define ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK        BIT(13)
+#define ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK        BIT(14)
+#define ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK       BIT(15)
+#define ALT_RSTMGR_PER0MODRST_DMA_SET_MSK    BIT(16)
+#define ALT_RSTMGR_PER0MODRST_SPIM0_SET_MSK  BIT(17)
+#define ALT_RSTMGR_PER0MODRST_SPIM1_SET_MSK  BIT(18)
+#define ALT_RSTMGR_PER0MODRST_SPIS0_SET_MSK  BIT(19)
+#define ALT_RSTMGR_PER0MODRST_SPIS1_SET_MSK  BIT(20)
+#define ALT_RSTMGR_PER0MODRST_DMAECC_SET_MSK BIT(21)
+#define ALT_RSTMGR_PER0MODRST_EMACPTP_SET_MSK        BIT(22)
+#define ALT_RSTMGR_PER0MODRST_DMAIF0_SET_MSK BIT(24)
+#define ALT_RSTMGR_PER0MODRST_DMAIF1_SET_MSK BIT(25)
+#define ALT_RSTMGR_PER0MODRST_DMAIF2_SET_MSK BIT(26)
+#define ALT_RSTMGR_PER0MODRST_DMAIF3_SET_MSK BIT(27)
+#define ALT_RSTMGR_PER0MODRST_DMAIF4_SET_MSK BIT(28)
+#define ALT_RSTMGR_PER0MODRST_DMAIF5_SET_MSK BIT(29)
+#define ALT_RSTMGR_PER0MODRST_DMAIF6_SET_MSK BIT(30)
+#define ALT_RSTMGR_PER0MODRST_DMAIF7_SET_MSK BIT(31)
+
+#define ALT_RSTMGR_PER1MODRST_WD0_SET_MSK    BIT(0)
+#define ALT_RSTMGR_PER1MODRST_WD1_SET_MSK    BIT(1)
+#define ALT_RSTMGR_PER1MODRST_L4SYSTMR0_SET_MSK      BIT(2)
+#define ALT_RSTMGR_PER1MODRST_L4SYSTMR1_SET_MSK      BIT(3)
+#define ALT_RSTMGR_PER1MODRST_SPTMR0_SET_MSK BIT(4)
+#define ALT_RSTMGR_PER1MODRST_SPTMR1_SET_MSK BIT(5)
+#define ALT_RSTMGR_PER1MODRST_I2C0_SET_MSK   BIT(8)
+#define ALT_RSTMGR_PER1MODRST_I2C1_SET_MSK   BIT(9)
+#define ALT_RSTMGR_PER1MODRST_I2C2_SET_MSK   BIT(10)
+#define ALT_RSTMGR_PER1MODRST_I2C3_SET_MSK   BIT(11)
+#define ALT_RSTMGR_PER1MODRST_I2C4_SET_MSK   BIT(12)
+#define ALT_RSTMGR_PER1MODRST_UART0_SET_MSK  BIT(16)
+#define ALT_RSTMGR_PER1MODRST_UART1_SET_MSK  BIT(17)
+#define ALT_RSTMGR_PER1MODRST_GPIO0_SET_MSK  BIT(24)
+#define ALT_RSTMGR_PER1MODRST_GPIO1_SET_MSK  BIT(25)
+#define ALT_RSTMGR_PER1MODRST_GPIO2_SET_MSK  BIT(26)
+
+#define ALT_RSTMGR_BRGMODRST_H2F_SET_MSK     BIT(0)
+#define ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK   BIT(1)
+#define ALT_RSTMGR_BRGMODRST_F2H_SET_MSK     BIT(2)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK       BIT(3)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK       BIT(4)
+#define ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK       BIT(5)
+#define ALT_RSTMGR_BRGMODRST_DDRSCH_SET_MSK  BIT(6)
+
+#define ALT_RSTMGR_HDSKEN_SDRSELFREFEN_SET_MSK       BIT(0)
+#define ALT_RSTMGR_HDSKEN_FPGAMGRHSEN_SET_MSK        BIT(1)
+#define ALT_RSTMGR_HDSKEN_FPGAHSEN_SET_MSK   BIT(2)
+#define ALT_RSTMGR_HDSKEN_ETRSTALLEN_SET_MSK BIT(3)
+
+#endif /* _RESET_MANAGER_ARRIA10_H_ */
arch/arm/mach-socfpga/reset_manager_arria10.c new file +333 -0
new file mode 100644
index 0000000..547a8bb
@@ -0,0 +1,362 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#include <asm/io.h>
+#include <asm/arch/fpga_manager.h>
+#include <asm/arch/misc.h>
+#include <asm/arch/reset_manager.h>
+#include <asm/arch/system_manager.h>
+#include <common.h>
+#include <errno.h>
+#include <fdtdec.h>
+#include <wait_bit.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct socfpga_reset_manager *reset_manager_base =
+             (void *)SOCFPGA_RSTMGR_ADDRESS;
+static const struct socfpga_system_manager *sysmgr_regs =
+             (struct socfpga_system_manager *)SOCFPGA_SYSMGR_ADDRESS;
+
+#define ECC_MASK (ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK | \
+     ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK | \
+     ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK | \
+     ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK | \
+     ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK | \
+     ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK)
+
+static const u32 per0fpgamasks[] = {
+     ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK,
+     0, /* i2c0 per1mod */
+     0, /* i2c1 per1mod */
+     0, /* i2c0_emac */
+     0, /* i2c1_emac */
+     0, /* i2c2_emac */
+     ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_NAND_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_QSPI_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK |
+     ALT_RSTMGR_PER0MODRST_SDMMC_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_SPIM0_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_SPIM1_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_SPIS0_SET_MSK,
+     ALT_RSTMGR_PER0MODRST_SPIS1_SET_MSK,
+     0, /* uart0 per1mod */
+     0, /* uart1 per1mod */
+};
+
+static const u32 per1fpgamasks[] = {
+     0, /* emac0 per0mod */
+     0, /* emac1 per0mod */
+     0, /* emac2 per0mod */
+     ALT_RSTMGR_PER1MODRST_I2C0_SET_MSK,
+     ALT_RSTMGR_PER1MODRST_I2C1_SET_MSK,
+     ALT_RSTMGR_PER1MODRST_I2C2_SET_MSK, /* i2c0_emac */
+     ALT_RSTMGR_PER1MODRST_I2C3_SET_MSK, /* i2c1_emac */
+     ALT_RSTMGR_PER1MODRST_I2C4_SET_MSK, /* i2c2_emac */
+     0, /* nand per0mod */
+     0, /* qspi per0mod */
+     0, /* sdmmc per0mod */
+     0, /* spim0 per0mod */
+     0, /* spim1 per0mod */
+     0, /* spis0 per0mod */
+     0, /* spis1 per0mod */
+     ALT_RSTMGR_PER1MODRST_UART0_SET_MSK,
+     ALT_RSTMGR_PER1MODRST_UART1_SET_MSK,
+};
+
+struct bridge_cfg {
+     int compat_id;
+     u32  mask_noc;
+     u32  mask_rstmgr;
+};
+
+static const struct bridge_cfg bridge_cfg_tbl[] = {
+     {
+             COMPAT_ALTERA_SOCFPGA_H2F_BRG,
+             ALT_SYSMGR_NOC_H2F_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_H2F_SET_MSK,
+     },
+     {
+             COMPAT_ALTERA_SOCFPGA_LWH2F_BRG,
+             ALT_SYSMGR_NOC_LWH2F_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK,
+     },
+     {
+             COMPAT_ALTERA_SOCFPGA_F2H_BRG,
+             ALT_SYSMGR_NOC_F2H_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_F2H_SET_MSK,
+     },
+     {
+             COMPAT_ALTERA_SOCFPGA_F2SDR0,
+             ALT_SYSMGR_NOC_F2SDR0_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK,
+     },
+     {
+             COMPAT_ALTERA_SOCFPGA_F2SDR1,
+             ALT_SYSMGR_NOC_F2SDR1_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK,
+     },
+     {
+             COMPAT_ALTERA_SOCFPGA_F2SDR2,
+             ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+             ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK,
+     },
+};
+
+/* Disable the watchdog (toggle reset to watchdog) */
+void watchdog_disable(void)
+{
+     /* assert reset for watchdog */
+     setbits_le32(&reset_manager_base->per1modrst,
+                  ALT_RSTMGR_PER1MODRST_WD0_SET_MSK);
+}
+
+/* Release NOC ddr scheduler from reset */
+void reset_deassert_noc_ddr_scheduler(void)
+{
+     clrbits_le32(&reset_manager_base->brgmodrst,
+                  ALT_RSTMGR_BRGMODRST_DDRSCH_SET_MSK);
+}
+
+/* Check whether Watchdog in reset state? */
+int is_wdt_in_reset(void)
+{
+     u32 val;
+
+     val = readl(&reset_manager_base->per1modrst);
+     val &= ALT_RSTMGR_PER1MODRST_WD0_SET_MSK;
+
+     /* return 0x1 if watchdog in reset */
+     return val;
+}
+
+/* emacbase: base address of emac to enable/disable reset
+ * state: 0 - disable reset, !0 - enable reset
+ */
+void emac_manage_reset(ulong emacbase, uint state)
+{
+     ulong eccmask;
+     ulong emacmask;
+
+     switch (emacbase) {
+     case SOCFPGA_EMAC0_ADDRESS:
+             eccmask = ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK;
+             emacmask = ALT_RSTMGR_PER0MODRST_EMAC0_SET_MSK;
+             break;
+     case SOCFPGA_EMAC1_ADDRESS:
+             eccmask = ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK;
+             emacmask = ALT_RSTMGR_PER0MODRST_EMAC1_SET_MSK;
+             break;
+     case SOCFPGA_EMAC2_ADDRESS:
+             eccmask = ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK;
+             emacmask = ALT_RSTMGR_PER0MODRST_EMAC2_SET_MSK;
+             break;
+     default:
+             error("emac base address unexpected! %lx", emacbase);
+             hang();
+             break;
+     }
+
+     if (state) {
+             /* Enable ECC OCP first */
+             setbits_le32(&reset_manager_base->per0modrst, eccmask);
+             setbits_le32(&reset_manager_base->per0modrst, emacmask);
+     } else {
+             /* Disable ECC OCP first */
+             clrbits_le32(&reset_manager_base->per0modrst, emacmask);
+             clrbits_le32(&reset_manager_base->per0modrst, eccmask);
+     }
+}
+
+static int get_bridge_init_val(const void *blob, int compat_id)
+{
+     int node;
+
+     node = fdtdec_next_compatible(blob, 0, compat_id);
+     if (node < 0)
+             return 0;
+
+     return fdtdec_get_uint(blob, node, "init-val", 0);
+}
+
+/* Enable bridges (hps2fpga, lwhps2fpga, fpga2hps, fpga2sdram) per handoff */
+int reset_deassert_bridges_handoff(void)
+{
+     u32 mask_noc = 0, mask_rstmgr = 0;
+     int i;
+
+     for (i = 0; i < ARRAY_SIZE(bridge_cfg_tbl); i++) {
+             if (get_bridge_init_val(gd->fdt_blob,
+                                     bridge_cfg_tbl[i].compat_id)) {
+                     mask_noc |= bridge_cfg_tbl[i].mask_noc;
+                     mask_rstmgr |= bridge_cfg_tbl[i].mask_rstmgr;
+             }
+     }
+
+     /* clear idle request to all bridges */
+     setbits_le32(&sysmgr_regs->noc_idlereq_clr, mask_noc);
+
+     /* Release bridges from reset state per handoff value */
+     clrbits_le32(&reset_manager_base->brgmodrst, mask_rstmgr);
+
+     /* Poll until all idleack to 0, timeout at 1000ms */
+     return wait_for_bit(__func__, &sysmgr_regs->noc_idleack, mask_noc,
+                         false, 1000, false);
+}
+
+void reset_assert_fpga_connected_peripherals(void)
+{
+     u32 mask0 = 0;
+     u32 mask1 = 0;
+     u32 fpga_pinux_addr = SOCFPGA_PINMUX_FPGA_INTERFACE_ADDRESS;
+     int i;
+
+     for (i = 0; i < ARRAY_SIZE(per1fpgamasks); i++) {
+             if (readl(fpga_pinux_addr)) {
+                     mask0 |= per0fpgamasks[i];
+                     mask1 |= per1fpgamasks[i];
+             }
+             fpga_pinux_addr += sizeof(u32);
+     }
+
+     setbits_le32(&reset_manager_base->per0modrst, mask0 & ECC_MASK);
+     setbits_le32(&reset_manager_base->per1modrst, mask1);
+     setbits_le32(&reset_manager_base->per0modrst, mask0);
+}
+
+/* Release L4 OSC1 Watchdog Timer 0 from reset through reset manager */
+void reset_deassert_osc1wd0(void)
+{
+     clrbits_le32(&reset_manager_base->per1modrst,
+                  ALT_RSTMGR_PER1MODRST_WD0_SET_MSK);
+}
+
+/*
+ * 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->mpumodrst;
+             break;
+     case 1:
+             reg = &reset_manager_base->per0modrst;
+             break;
+     case 2:
+             reg = &reset_manager_base->per1modrst;
+             break;
+     case 3:
+             reg = &reset_manager_base->brgmodrst;
+             break;
+     case 4:
+             reg = &reset_manager_base->sysmodrst;
+             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
+ * and/or hangs.
+ * For the Arria10, we disable all the peripherals except L4 watchdog0,
+ * L4 Timer 0, and ECC.
+ */
+void socfpga_per_reset_all(void)
+{
+     const u32 l4wd0 = (1 << RSTMGR_RESET(SOCFPGA_RESET(L4WD0)) |
+                       (1 << RSTMGR_RESET(SOCFPGA_RESET(L4SYSTIMER0))));
+     unsigned mask_ecc_ocp =
+             ALT_RSTMGR_PER0MODRST_EMACECC0_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_EMACECC1_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_EMACECC2_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_USBECC0_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_USBECC1_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_NANDECC_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_QSPIECC_SET_MSK |
+             ALT_RSTMGR_PER0MODRST_SDMMCECC_SET_MSK;
+
+     /* disable all components except ECC_OCP, L4 Timer0 and L4 WD0 */
+     writel(~l4wd0, &reset_manager_base->per1modrst);
+     setbits_le32(&reset_manager_base->per0modrst, ~mask_ecc_ocp);
+
+     /* Finally disable the ECC_OCP */
+     setbits_le32(&reset_manager_base->per0modrst, mask_ecc_ocp);
+}
+
+#if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
+void socfpga_bridges_reset(int enable)
+{
+     /* For SoCFPGA-VT, this is NOP. */
+}
+#else
+void socfpga_bridges_reset(int enable)
+{
+     /* Disable all the bridges (hps2fpga, lwhps2fpga, fpga2hps,
+        fpga2sdram) */
+     /* set idle request to all bridges */
+     writel(ALT_SYSMGR_NOC_H2F_SET_MSK |
+             ALT_SYSMGR_NOC_LWH2F_SET_MSK |
+             ALT_SYSMGR_NOC_F2H_SET_MSK |
+             ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+             ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+             ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+             &sysmgr_regs->noc_idlereq_set);
+
+     /* Enable the NOC timeout */
+     writel(ALT_SYSMGR_NOC_TMO_EN_SET_MSK, &sysmgr_regs->noc_timeout);
+
+     /* Poll until all idleack to 1 */
+     wait_for_bit(__func__, &sysmgr_regs->noc_idleack,
+                  ALT_SYSMGR_NOC_H2F_SET_MSK |
+                  ALT_SYSMGR_NOC_LWH2F_SET_MSK |
Quoted 8 lines

arch/arm/mach-socfpga/reset_manager_arria10.c line 338

Quoted 5 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +5 -0
+                  ALT_SYSMGR_NOC_F2H_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+                  true, 10000, false);

You should check return value of all these wait_for_bit() calls, otherwise you might ignore errors.

Okay.

Quoted 23 lines
Quoted 23 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +22 -0
+     /* Poll until all idlestatus to 1 */
+     wait_for_bit(__func__, &sysmgr_regs->noc_idlestatus,
+                  ALT_SYSMGR_NOC_H2F_SET_MSK |
+                  ALT_SYSMGR_NOC_LWH2F_SET_MSK |
+                  ALT_SYSMGR_NOC_F2H_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR0_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR1_SET_MSK |
+                  ALT_SYSMGR_NOC_F2SDR2_SET_MSK,
+                  true, 10000, false);
+
+     /* Put all bridges (except NOR DDR scheduler) into reset state */
+     setbits_le32(&reset_manager_base->brgmodrst,
+                  (ALT_RSTMGR_BRGMODRST_H2F_SET_MSK |
+                  ALT_RSTMGR_BRGMODRST_LWH2F_SET_MSK |
+                  ALT_RSTMGR_BRGMODRST_F2H_SET_MSK |
+                  ALT_RSTMGR_BRGMODRST_F2SSDRAM0_SET_MSK |
+                  ALT_RSTMGR_BRGMODRST_F2SSDRAM1_SET_MSK |
+                  ALT_RSTMGR_BRGMODRST_F2SSDRAM2_SET_MSK));
+
+     /* Disable NOC timeout */
+     writel(0, &sysmgr_regs->noc_timeout);
+}
Quoted 8 lines

include/dt-bindings/reset/altr,rst-mgr-a10.h line 1

Quoted 8 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +1 -0
+#endif
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +1 -0
new file mode 100644
index 0000000..99875de
@@ -0,0 +1,103 @@
+/*

[..]

Regards
Ley Foon

#46 lore raw

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

In reply to Ley Foon Tan
Quoted 48 lines · Ley Foon Tan
Quoted 47 lines · Marek Vasut
Quoted 46 lines · Ley Foon Tan
Quoted 45 lines · Marek Vasut
Quoted 40 lines · Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
index 0000000..9554da7

drivers/ddr/altera/Kconfig line 2

Quoted 2 lines
drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+     bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

The existing DDR driver is for Gen5 only. We will have new DDR driver for Arria 10 in later patchset.

I was asking about the SDRAM support in Gen5 controller though :)

Yes, it support for double data rate 2 (DDR2), DDR3, and low-power DDR2 (LPDDR2) SDRAM.

Ah, so a misnomer . I'd prefer to have something like "SoCFPGA DRAM controller ... or SoCFPGA DDR SDRAM controller" in the Kconfig option to make it clear.

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

PATCH v2 17/20 arm: socfpga: Convert Altera ddr driver to use Kconfig

Quoted 52 lines · Marek Vasut
Quoted 51 lines · Ley Foon Tan
Quoted 50 lines · Marek Vasut
Quoted 48 lines · Ley Foon Tan
Quoted 37 lines · Marek Vasut
Quoted 36 lines · Ley Foon Tan

Convert Altera ddr driver to use Kconfig method. Enable ALTERA_SDRAM by default if it is on Gen5 target. Arria 10 will have different driver.

---
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 6 ++++++
 include/configs/socfpga_common.h | 5 -----
 4 files changed, 9 insertions(+), 5 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
drivers/Kconfig +2 -0
index 0e5d97d..3e6bbac 100644
@@ -14,6 +14,8 @@ source "drivers/cpu/Kconfig"
 
 source "drivers/crypto/Kconfig"
 
+source "drivers/ddr/Kconfig"
+
 source "drivers/demo/Kconfig"
 
 source "drivers/ddr/fsl/Kconfig"
drivers/ddr/Kconfig new file +1 -0
new file mode 100644
index 0000000..b764add
@@ -0,0 +1 @@
+source "drivers/ddr/altera/Kconfig"
drivers/ddr/altera/Kconfig new file +0 -0
new file mode 100644
Quoted 8 lines

drivers/ddr/altera/Kconfig line 2

Quoted 6 lines

index 0000000..9554da7

drivers/ddr/altera/Kconfig new file +2 -0
@@ -0,0 +1,6 @@
+config ALTERA_SDRAM
+     bool "SoCFPGA SDRAM for Arria5/Cyclone5 devices"

Does this controller even support SDRAM ? :)

The existing DDR driver is for Gen5 only. We will have new DDR driver for Arria 10 in later patchset.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

I was asking about the SDRAM support in Gen5 controller though :)

Yes, it support for double data rate 2 (DDR2), DDR3, and low-power DDR2 (LPDDR2) SDRAM.

Ah, so a misnomer . I'd prefer to have something like "SoCFPGA DRAM controller ... or SoCFPGA DDR SDRAM controller" in the Kconfig option to make it clear.

Okay, will change it to "SoCFPGA DDR SDRAM controller".

Thanks.

Regards
Ley Foon