Skip to contentSkip to conversation

Add Intel Arria 10 SoC support

PATCH Superseded Ley Foon Tan 6 participants 48 messages Apr 5, 2017 – Apr 15, 2017

Subsystems (7)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover Add Intel Arria 10 SoC support

This is the 4th version of patchset to adds support for Intel Arria 10 SoC. This version mainly resolved comments from Marek and Dinh in [v3]. Only patch #01, #14 and #16 have changes in this revision.

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

v3 -> v4 changes:
-----------------
- Check the return value from cm_write_with_phase() and cm_basic_init().
- Change debug() to printf() in arch/arm/mach-socfpga/spl.c.
- Select ALTERA_SDRAM in arch/arm/mach-socfpga/Kconfig.

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

Ley Foon Tan (19):
arm: socfpga: Restructure clock manager driver
arm: socfpga: Restructure reset manager driver
arm: socfpga: Restructure system manager
arm: socfpga: Restructure misc driver
arm: socfpga: Add A10 macros
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 SDRAM 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   |  481 +++++++++
 arch/arm/mach-socfpga/Kconfig                      |   11 +
 arch/arm/mach-socfpga/Makefile                     |   41 +-
 arch/arm/mach-socfpga/clock_manager.c              |  525 +---------
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1096 ++++++++++++++++++++
 .../{clock_manager.c => clock_manager_gen5.c}      |  137 +--
 arch/arm/mach-socfpga/include/mach/base_addr_a10.h |    8 +-
 arch/arm/mach-socfpga/include/mach/clock_manager.h |  317 +-----
 .../include/mach/clock_manager_arria10.h           |  224 ++++
 .../mach/{clock_manager.h => clock_manager_gen5.h} |  151 +--
 arch/arm/mach-socfpga/include/mach/misc.h          |   31 +
 arch/arm/mach-socfpga/include/mach/pinmux.h        |   15 +
 arch/arm/mach-socfpga/include/mach/reset_manager.h |   50 +-
 .../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 |  202 ++--
 .../include/mach/system_manager_arria10.h          |   81 ++
 .../{system_manager.h => system_manager_gen5.h}    |   39 +-
 arch/arm/mach-socfpga/misc.c                       |  361 +------
 arch/arm/mach-socfpga/misc_arria10.c               |  258 +++++
 arch/arm/mach-socfpga/{misc.c => misc_gen5.c}      |  149 +--
 arch/arm/mach-socfpga/pinmux_arria10.c             |   96 ++
 arch/arm/mach-socfpga/reset_manager.c              |   93 +-
 arch/arm/mach-socfpga/reset_manager_arria10.c      |  389 +++++++
 .../{reset_manager.c => reset_manager_gen5.c}      |   51 +-
 arch/arm/mach-socfpga/spl.c                        |   79 +-
 .../{system_manager.c => system_manager_gen5.c}    |    6 +-
 board/altera/arria10-socdk/Kconfig                 |   18 +
 board/altera/arria10-socdk/Makefile                |    7 +
 board/altera/arria10-socdk/socfpga.c               |    7 +
 configs/socfpga_arria10_defconfig                  |   28 +
 drivers/Kconfig                                    |    2 +
 drivers/ddr/Kconfig                                |    1 +
 drivers/ddr/altera/Kconfig                         |    5 +
 drivers/ddr/altera/Makefile                        |    4 +-
 drivers/fpga/socfpga.c                             |    6 +
 include/configs/socfpga_arria10_socdk.h            |   66 ++
 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, 4850 insertions(+), 1798 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
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (85%)
 create mode 100644 arch/arm/mach-socfpga/include/mach/clock_manager_arria10.h
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h => clock_manager_gen5.h} (79%)
 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
 copy arch/arm/mach-socfpga/include/mach/{system_manager.h => system_manager_gen5.h} (73%)
 create mode 100644 arch/arm/mach-socfpga/misc_arria10.c
 copy arch/arm/mach-socfpga/{misc.c => misc_gen5.c} (73%)
 create mode 100644 arch/arm/mach-socfpga/pinmux_arria10.c
 create mode 100644 arch/arm/mach-socfpga/reset_manager_arria10.c
 copy arch/arm/mach-socfpga/{reset_manager.c => reset_manager_gen5.c} (75%)
 rename arch/arm/mach-socfpga/{system_manager.c => system_manager_gen5.c} (94%)
 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 v4 1/19 arm: socfpga: Restructure clock manager driver

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

- Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.
- Check return value from wait_for_bit(). So change return type to int for cm_write_with_phase() and cm_basic_init().

---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 515 +--------------------
 .../{clock_manager.c => clock_manager_gen5.c}      | 137 ++----
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 316 +------------
 .../mach/{clock_manager.h => clock_manager_gen5.h} | 151 +++---
 arch/arm/mach-socfpga/spl.c                        |   5 +-
 6 files changed, 151 insertions(+), 976 deletions(-)
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (85%)
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h => clock_manager_gen5.h} (79%)
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 +8 -507

538 lines not on this page · raw message

arch/arm/mach-socfpga/clock_manager_gen5.c renamed from arch/arm/mach-socfpga/clock_manager.c +50 -87

268 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +9 -307

326 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager_gen5.h renamed from arch/arm/mach-socfpga/include/mach/clock_manager.h +78 -73

221 lines not on this page · raw message

arch/arm/mach-socfpga/spl.c +4 -1
index fec4c7a..69c433c 100644
@@ -127,7 +127,10 @@ void board_init_f(ulong dummy)
 
 	debug("Reconfigure Clock Manager\n");
 	/* reconfigure the PLLs */
-	cm_basic_init(cm_default_cfg);
+	if (cm_basic_init(cm_default_cfg)) {
+		puts("Clock setup failed.\n");
+		hang();
+	}
 
 	/* Enable bootrom to configure IOs. */
 	sysmgr_config_warmrstcfgio(1);
Signature · 1 line
1.8.2.3
#2 lore raw

PATCH v4 1/19 arm: socfpga: Restructure clock manager driver

Quoted 19 lines · Ley Foon Tan

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

- Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.
- Check return value from wait_for_bit(). So change return type to int for cm_write_with_phase() and cm_basic_init().

---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 515 +--------------------
 .../{clock_manager.c => clock_manager_gen5.c}      | 137 ++----
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 316 +------------
 .../mach/{clock_manager.h => clock_manager_gen5.h} | 151 +++---
 arch/arm/mach-socfpga/spl.c                        |   5 +-
 6 files changed, 151 insertions(+), 976 deletions(-)
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (85%)
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h => clock_manager_gen5.h} (79%)

[snip]

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

Quoted 5 lines
        debug("Reconfigure Clock Manager\n");
        /* reconfigure the PLLs */
arch/arm/mach-socfpga/spl.c +2 -1
-       cm_basic_init(cm_default_cfg);
+       if (cm_basic_init(cm_default_cfg)) {
+               puts("Clock setup failed.\n");

If the clock configuration has failed, would you be able to print anything to the uart?

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

Quoted 5 lines
arch/arm/mach-socfpga/spl.c +2 -0
+               hang();
+       }
 
        /* Enable bootrom to configure IOs. */
        sysmgr_config_warmrstcfgio(1);

Dinh

#3 lore raw

PATCH v4 1/19 arm: socfpga: Restructure clock manager driver

Quoted 23 lines · Dinh Nguyen
Quoted 19 lines · Ley Foon Tan

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

- Change all uint32_t to u32 and change to use macro BIT(n) for bit shift.
- Check return value from wait_for_bit(). So change return type to int for cm_write_with_phase() and cm_basic_init().

---
 arch/arm/mach-socfpga/Makefile                     |   3 +-
 arch/arm/mach-socfpga/clock_manager.c              | 515 +--------------------
 .../{clock_manager.c => clock_manager_gen5.c}      | 137 ++----
 arch/arm/mach-socfpga/include/mach/clock_manager.h | 316 +------------
 .../mach/{clock_manager.h => clock_manager_gen5.h} | 151 +++---
 arch/arm/mach-socfpga/spl.c                        |   5 +-
 6 files changed, 151 insertions(+), 976 deletions(-)
 copy arch/arm/mach-socfpga/{clock_manager.c => clock_manager_gen5.c} (85%)
 copy arch/arm/mach-socfpga/include/mach/{clock_manager.h => clock_manager_gen5.h} (79%)

[snip]

Quoted 8 lines

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

Quoted 5 lines
        debug("Reconfigure Clock Manager\n");
        /* reconfigure the PLLs */
arch/arm/mach-socfpga/spl.c +2 -1
-       cm_basic_init(cm_default_cfg);
+       if (cm_basic_init(cm_default_cfg)) {
+               puts("Clock setup failed.\n");

If the clock configuration has failed, would you be able to print anything to the uart?

You are right. We can't print here when clock setup is failed. Will remove print.

Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/spl.c +2 -0
+               hang();
+       }
 
        /* Enable bootrom to configure IOs. */
        sysmgr_config_warmrstcfgio(1);

Regards
Ley Foon

#4 lore raw

PATCH v4 2/19 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. Change socfpga_per_reset() return type to int.

---
 arch/arm/mach-socfpga/Makefile                     |  2 +-
 arch/arm/mach-socfpga/include/mach/reset_manager.h | 48 ++---------
 .../mach-socfpga/include/mach/reset_manager_gen5.h | 47 +++++++++++
 arch/arm/mach-socfpga/reset_manager.c              | 93 +---------------------
 .../{reset_manager.c => reset_manager_gen5.c}      | 51 ++++++------
 5 files changed, 81 insertions(+), 160 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/reset_manager_gen5.h
 copy arch/arm/mach-socfpga/{reset_manager.c => reset_manager_gen5.c} (75%)
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 +8 -40

70 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 renamed from arch/arm/mach-socfpga/reset_manager.c +23 -28

101 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#5 lore raw

PATCH v4 3/19 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                     |   5 +-
 .../arm/mach-socfpga/include/mach/system_manager.h | 128 ++-------------------
 .../{system_manager.h => system_manager_gen5.h}    |  39 +------
 .../{system_manager.c => system_manager_gen5.c}    |   6 +-
 4 files changed, 22 insertions(+), 156 deletions(-)
 copy arch/arm/mach-socfpga/include/mach/{system_manager.h => system_manager_gen5.h} (73%)
 rename arch/arm/mach-socfpga/{system_manager.c => system_manager_gen5.c} (94%)
arch/arm/mach-socfpga/Makefile +3 -2
index 97819ac..4980e51 100644
@@ -7,14 +7,15 @@
 # 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
 
 # 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 \
+					   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 +10 -118

146 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/system_manager_gen5.h renamed from arch/arm/mach-socfpga/include/mach/system_manager.h +6 -33
similarity index 73%
copy from arch/arm/mach-socfpga/include/mach/system_manager.h
copy to arch/arm/mach-socfpga/include/mach/system_manager_gen5.h
index c45edea..285c1a2 100644
@@ -1,11 +1,11 @@
 /*
- * Copyright (C) 2013 Altera Corporation <www.altera.com>
+ * Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
 
-#ifndef	_SYSTEM_MANAGER_H_
-#define	_SYSTEM_MANAGER_H_
+#ifndef _SYSTEM_MANAGER_GEN5_H_
+#define _SYSTEM_MANAGER_GEN5_H_
 
 #ifndef __ASSEMBLY__
 
@@ -13,7 +13,6 @@ void sysmgr_pinmux_init(void);
 void sysmgr_config_warmrstcfgio(int enable);
 
 void sysmgr_get_pinmux_table(const u8 **table, unsigned int *table_len);
-#endif
 
 struct socfpga_system_manager {
 	/* System Manager Module */
@@ -115,35 +114,9 @@ struct socfpga_system_manager {
 	u32	_pad_0x734;
 	u32	spim0usefpga;			/* 0x738 */
 };
-
-#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	(1 << 0)
-#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	(1 << 1)
-#define SYSMGR_ECC_OCRAM_EN	(1 << 0)
-#define SYSMGR_ECC_OCRAM_SERR	(1 << 3)
-#define SYSMGR_ECC_OCRAM_DERR	(1 << 4)
-#define SYSMGR_FPGAINTF_USEFPGA	0x1
-#define SYSMGR_FPGAINTF_SPIM0	(1 << 0)
-#define SYSMGR_FPGAINTF_SPIM1	(1 << 1)
-#define SYSMGR_FPGAINTF_EMAC0	(1 << 2)
-#define SYSMGR_FPGAINTF_EMAC1	(1 << 3)
-#define SYSMGR_FPGAINTF_NAND	(1 << 4)
-#define SYSMGR_FPGAINTF_SDMMC	(1 << 5)
-
-#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
-#define SYSMGR_SDMMC_SMPLSEL_SHIFT	3
-#else
-#define SYSMGR_SDMMC_SMPLSEL_SHIFT	4
 #endif
 
-#define SYSMGR_SDMMC_DRVSEL_SHIFT	0
-
-/* EMAC Group Bit definitions */
-#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_GMII_MII	0x0
-#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII		0x1
-#define SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RMII		0x2
-
-#define SYSMGR_EMACGRP_CTRL_PHYSEL0_LSB			0
-#define SYSMGR_EMACGRP_CTRL_PHYSEL1_LSB			2
-#define SYSMGR_EMACGRP_CTRL_PHYSEL_MASK			0x3
+#define SYSMGR_SDMMC_SMPLSEL_SHIFT	3
+#define SYSMGR_BOOTINFO_BSEL_SHIFT	0
 
-#endif /* _SYSTEM_MANAGER_H_ */
+#endif /* _SYSTEM_MANAGER_GEN5_H_ */
arch/arm/mach-socfpga/system_manager_gen5.c renamed from arch/arm/mach-socfpga/system_manager.c +3 -3
similarity index 94%
rename from arch/arm/mach-socfpga/system_manager.c
rename to arch/arm/mach-socfpga/system_manager_gen5.c
index 75a65f3..3588a57 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Altera Corporation <www.altera.com>
+ * Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
  *
  * SPDX-License-Identifier:	GPL-2.0+
  */
@@ -21,7 +21,7 @@ static struct socfpga_system_manager *sysmgr_regs =
  */
 static void populate_sysmgr_fpgaintf_module(void)
 {
-	uint32_t handoff_val = 0;
+	u32 handoff_val = 0;
 
 	/* ISWGRP_HANDOFF_FPGAINTF */
 	writel(0, &sysmgr_regs->iswgrp_handoff[2]);
@@ -56,7 +56,7 @@ static void populate_sysmgr_fpgaintf_module(void)
  */
 void sysmgr_pinmux_init(void)
 {
-	uint32_t regs = (uint32_t)&sysmgr_regs->emacio[0];
+	u32 regs = (u32)&sysmgr_regs->emacio[0];
 	const u8 *sys_mgr_init_table;
 	unsigned int len;
 	int i;
Signature · 1 line
1.8.2.3
#6 lore raw

PATCH v4 4/19 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.

Change all uint32_t_to u32 and check return value from socfpga_bridges_reset.

---
 arch/arm/mach-socfpga/Makefile                |   2 +-
 arch/arm/mach-socfpga/include/mach/misc.h     |  25 ++
 arch/arm/mach-socfpga/misc.c                  | 361 ++------------------------
 arch/arm/mach-socfpga/{misc.c => misc_gen5.c} | 149 ++---------
 4 files changed, 60 insertions(+), 477 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/misc.h
 copy arch/arm/mach-socfpga/{misc.c => misc_gen5.c} (73%)
arch/arm/mach-socfpga/Makefile +1 -1
index 4980e51..e83da2e 100644
@@ -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 \
-					   system_manager_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/misc.h new file +25 -0
new file mode 100644
index 0000000..f344749
@@ -0,0 +1,25 @@
+/*
+ * 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
+static 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 renamed from arch/arm/mach-socfpga/misc.c +19 -130

218 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#7 lore raw

PATCH v4 4/19 arm: socfpga: Restructure misc driver

Quoted 7 lines · Ley Foon Tan

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to gen5 file.

Change all uint32_t_to u32 and check return value from socfpga_bridges_reset.

[...]

arch/arm/mach-socfpga/misc_gen5.c int arch_early_init_r(void) · line 297

Quoted 6 lines

static void socfpga_sdram_apply_static_cfg(void)
{

arch/arm/mach-socfpga/misc_gen5.c renamed from arch/arm/mach-socfpga/misc.c +1 -3
-	const uint32_t staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;
-	const uint32_t applymask = 0x8;
-	uint32_t val = readl(staticcfg) | applymask;
+	const u32 staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;

We should fix this, this is actually

static struct socfpga_sdr_ctrl *sdr_ctrl =

        (struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS;

...

readl(&sdr_ctl->static_cfg) | applymask;

And we should fix this SOCFPGA_SDR_ADDRESS + 0x50xx; all over .

Quoted 6 lines
arch/arm/mach-socfpga/misc_gen5.c renamed from arch/arm/mach-socfpga/misc.c +2 -0
+	const u32 applymask = 0x8;
+	u32 val = readl(staticcfg) | applymask;
 
 	/*
 	 * SDRAM staticcfg register specific:
Signature · 2 lines
Best regards,
Marek Vasut
#8 lore raw

PATCH v4 4/19 arm: socfpga: Restructure misc driver

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

Restructure misc driver in the preparation to support A10. Move the Gen5 specific code to gen5 file.

Change all uint32_t_to u32 and check return value from socfpga_bridges_reset.

[...]

arch/arm/mach-socfpga/misc_gen5.c int arch_early_init_r(void) · line 297

Quoted 6 lines

static void socfpga_sdram_apply_static_cfg(void)
{

arch/arm/mach-socfpga/misc_gen5.c renamed from arch/arm/mach-socfpga/misc.c +1 -3
-     const uint32_t staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;
-     const uint32_t applymask = 0x8;
-     uint32_t val = readl(staticcfg) | applymask;
+     const u32 staticcfg = SOCFPGA_SDR_ADDRESS + 0x505c;

We should fix this, this is actually

Quoted 8 lines

static struct socfpga_sdr_ctrl *sdr_ctrl =

        (struct socfpga_sdr_ctrl *)SDR_CTRLGRP_ADDRESS;

...

readl(&sdr_ctl->static_cfg) | applymask;

And we should fix this SOCFPGA_SDR_ADDRESS + 0x50xx; all over .

Okay, will change it.

Quoted 8 lines

arch/arm/mach-socfpga/misc_gen5.c int arch_early_init_r(void) · line 302

Quoted 7 lines
arch/arm/mach-socfpga/misc_gen5.c renamed from arch/arm/mach-socfpga/misc.c +2 -0
+     const u32 applymask = 0x8;
+     u32 val = readl(staticcfg) | applymask;
 
      /*
       * SDRAM staticcfg register specific:

Regards
Ley Foon

#9 lore raw

PATCH v4 5/19 arm: socfpga: Add A10 macros

In reply to Ley Foon Tan

Add i2c, timer and other A10 macros.

---
 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
#10 lore raw

PATCH v4 5/19 arm: socfpga: Add A10 macros

Quoted 19 lines · Ley Foon Tan

Add i2c, timer and other A10 macros.

---
 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 +1 -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+
  */

arch/arm/mach-socfpga/include/mach/base_addr_a10.h line 34

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/base_addr_a10.h +3 -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

I made this comment in V3, and I'll make it again. Do we need to add these when we can use DTS for the I2C driver?

Dinh

#11 lore raw

PATCH v4 5/19 arm: socfpga: Add A10 macros

Quoted 21 lines · Dinh Nguyen
Quoted 20 lines · Ley Foon Tan

Add i2c, timer and other A10 macros.

---
 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 +1 -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
Quoted 9 lines

arch/arm/mach-socfpga/include/mach/base_addr_a10.h line 34

Quoted 5 lines
arch/arm/mach-socfpga/include/mach/base_addr_a10.h +3 -0
 #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

I made this comment in V3, and I'll make it again. Do we need to add these when we can use DTS for the I2C driver?

We haven't enable CONFIG_DM_I2C for i2c in this patch series, so it still using older device model and these macros are still required in socfpga_common.h (#define CONFIG_SYS_I2C_BASE SOCFPGA_I2C0_ADDRESS).

Regards
Ley Foon

#12 lore raw

PATCH v4 6/19 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           | 144 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 389 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 640 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 c99efa7..a0d611b 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 +144 -0

144 lines not on this page · raw message

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

389 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
#13 lore raw

PATCH v4 6/19 arm: socfpga: Add reset driver support for Arria 10

Quoted 116 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           | 144 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 389 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 640 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 c99efa7..a0d611b 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 +69 -0
new file mode 100644
index 0000000..878c1b6
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _RESET_MANAGER_ARRIA10_H_
+#define _RESET_MANAGER_ARRIA10_H_
+
+void socfpga_watchdog_disable(void);
+void socfpga_reset_deassert_noc_ddr_scheduler(void);
+int socfpga_is_wdt_in_reset(void);
+void socfpga_emac_manage_reset(ulong emacbase, u32 state);
+int socfpga_reset_deassert_bridges_handoff(void);
+void socfpga_reset_assert_fpga_connected_peripherals(void);
+void socfpga_reset_deassert_osc1wd0(void);
+void socfpga_reset_uart(int assert);
+
+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)

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

Quoted 10 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +10 -0
+#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)

Are the above MACRO's still needed if we're using the dt-bindings?

Quoted 108 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +65 -0
+
+#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 +37 -0
new file mode 100644
index 0000000..e24f2f2
@@ -0,0 +1,389 @@
+/*
+ * 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)
+
+void socfpga_reset_uart(int assert)
+{
+       u32 mask = 0;
+       unsigned int com_port;
+
+       com_port = uart_com_port(gd->fdt_blob);
+

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

Quoted 10 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +10 -0
+       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);
+}

Why do you need the above function? Couldn't you just used:

socfpga_per_reset(SOCFPGA_RESET(UART<#>));

Quoted 348 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +342 -0
+
+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 socfpga_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 socfpga_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 socfpga_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 socfpga_emac_manage_reset(ulong emacbase, u32 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 socfpga_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 socfpga_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 socfpga_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)
+int socfpga_bridges_reset(int enable)
+{
+       /* For SoCFPGA-VT, this is NOP. */
+       return 0;
+}
+#else
+int socfpga_bridges_reset(int enable)
+{
+       int ret;
+
+       /* 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 */
+       ret = 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);
+       if (ret)
+               return ret;
+
+       /* Poll until all idlestatus to 1 */
+       ret = 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);
+       if (ret)
+               return ret;
+
+       /* 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);
+
+       return 0;
+}
+#endif
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +0 -0
new file mode 100644
index 0000000..99875de

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

Quoted 5 lines
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +5 -0
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */

Hmm...did you by chance copy this file from the Linux kernel? It looks awfully the same, and if so, please keep the Copyright from the original.

Dinh

#14 lore raw

PATCH v4 6/19 arm: socfpga: Add reset driver support for Arria 10

Quoted 121 lines · Dinh Nguyen
Quoted 120 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           | 144 ++++++++
 arch/arm/mach-socfpga/reset_manager_arria10.c      | 389 +++++++++++++++++++++
 include/dt-bindings/reset/altr,rst-mgr-a10.h       | 103 ++++++
 5 files changed, 640 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 c99efa7..a0d611b 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 +73 -0
new file mode 100644
index 0000000..878c1b6
@@ -0,0 +1,144 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */
+
+#ifndef _RESET_MANAGER_ARRIA10_H_
+#define _RESET_MANAGER_ARRIA10_H_
+
+void socfpga_watchdog_disable(void);
+void socfpga_reset_deassert_noc_ddr_scheduler(void);
+int socfpga_is_wdt_in_reset(void);
+void socfpga_emac_manage_reset(ulong emacbase, u32 state);
+int socfpga_reset_deassert_bridges_handoff(void);
+void socfpga_reset_assert_fpga_connected_peripherals(void);
+void socfpga_reset_deassert_osc1wd0(void);
+void socfpga_reset_uart(int assert);
+
+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)
Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +6 -0
+#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)

Are the above MACRO's still needed if we're using the dt-bindings?

We still need them now. The reset function framework also used for Gen5, so it is massive change if we change it now. But, we can consider to convert them later.

Quoted 122 lines
Quoted 109 lines
arch/arm/mach-socfpga/include/mach/reset_manager_arria10.h new file +65 -0
+
+#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 +37 -0
new file mode 100644
index 0000000..e24f2f2
@@ -0,0 +1,389 @@
+/*
+ * 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)
+
+void socfpga_reset_uart(int assert)
+{
+       u32 mask = 0;
+       unsigned int com_port;
+
+       com_port = uart_com_port(gd->fdt_blob);
+

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

Quoted 10 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +10 -0
+       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);
+}

Why do you need the above function? Couldn't you just used:

Quoted 1 line

socfpga_per_reset(SOCFPGA_RESET(UART<#>));

Okay, will refactor this function to something like this:

void socfpga_reset_uart(int assert)

{
      unsigned int com_port;

     com_port = uart_com_port(gd->fdt_blob);

    if (com_port == SOCFPGA_UART1_ADDRESS)
            socfpga_per_reset(SOCFPGA_RESET(UART1), assert);
    else if (com_port == SOCFPGA_UART0_ADDRESS)
            socfpga_per_reset(SOCFPGA_RESET(UART0), assert);
}
Quoted 350 lines
Quoted 350 lines
arch/arm/mach-socfpga/reset_manager_arria10.c new file +342 -0
+
+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 socfpga_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 socfpga_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 socfpga_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 socfpga_emac_manage_reset(ulong emacbase, u32 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 socfpga_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 socfpga_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 socfpga_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)
+int socfpga_bridges_reset(int enable)
+{
+       /* For SoCFPGA-VT, this is NOP. */
+       return 0;
+}
+#else
+int socfpga_bridges_reset(int enable)
+{
+       int ret;
+
+       /* 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 */
+       ret = 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);
+       if (ret)
+               return ret;
+
+       /* Poll until all idlestatus to 1 */
+       ret = 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);
+       if (ret)
+               return ret;
+
+       /* 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);
+
+       return 0;
+}
+#endif
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +0 -0
new file mode 100644
index 0000000..99875de
@@ -0,0 +1,103 @@
Quoted 9 lines

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

Quoted 5 lines
include/dt-bindings/reset/altr,rst-mgr-a10.h new file +5 -0
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:    GPL-2.0
+ */

Hmm...did you by chance copy this file from the Linux kernel? It looks awfully the same, and if so, please keep the Copyright from the original.

Okay, will copy its original copyright header.

Regards
Ley Foon

#15 lore raw

PATCH v4 7/19 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              |   10 +
 arch/arm/mach-socfpga/clock_manager_arria10.c      | 1096 ++++++++++++++++++++
 arch/arm/mach-socfpga/include/mach/clock_manager.h |    3 +
 .../include/mach/clock_manager_arria10.h           |  224 ++++
 5 files changed, 1335 insertions(+), 1 deletion(-)
 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 +10 -0
index 8051995..cb6ae03 100644
@@ -19,7 +19,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
@@ -44,7 +49,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 +1096 -0

1,096 lines not on this page · raw message

arch/arm/mach-socfpga/include/mach/clock_manager.h +3 -0
index b076497..4c6b1f8 100644
@@ -15,5 +15,8 @@ void cm_print_clock_quick_summary(void);
 
 #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 +224 -0

224 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#16 lore raw

PATCH v4 8/19 arm: socfpga: Add system manager for Arria 10

In reply to Ley Foon Tan

Add system manager register struct and macros for Arria 10.

---
 .../arm/mach-socfpga/include/mach/system_manager.h | 74 +++++++++++++++++---
 .../include/mach/system_manager_arria10.h          | 81 ++++++++++++++++++++++
 2 files changed, 144 insertions(+), 11 deletions(-)
 create mode 100644 arch/arm/mach-socfpga/include/mach/system_manager_arria10.h
arch/arm/mach-socfpga/include/mach/system_manager.h +63 -11
index 30f0bbe..e6d4280 100644
@@ -7,18 +7,18 @@
 #ifndef _SYSTEM_MANAGER_H_
 #define _SYSTEM_MANAGER_H_
 
-#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	(1 << 0)
-#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	(1 << 1)
-#define SYSMGR_ECC_OCRAM_EN	(1 << 0)
-#define SYSMGR_ECC_OCRAM_SERR	(1 << 3)
-#define SYSMGR_ECC_OCRAM_DERR	(1 << 4)
+#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGPINMUX	BIT(0)
+#define SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO	BIT(1)
+#define SYSMGR_ECC_OCRAM_EN	BIT(0)
+#define SYSMGR_ECC_OCRAM_SERR	BIT(3)
+#define SYSMGR_ECC_OCRAM_DERR	BIT(4)
 #define SYSMGR_FPGAINTF_USEFPGA	0x1
-#define SYSMGR_FPGAINTF_SPIM0	(1 << 0)
-#define SYSMGR_FPGAINTF_SPIM1	(1 << 1)
-#define SYSMGR_FPGAINTF_EMAC0	(1 << 2)
-#define SYSMGR_FPGAINTF_EMAC1	(1 << 3)
-#define SYSMGR_FPGAINTF_NAND	(1 << 4)
-#define SYSMGR_FPGAINTF_SDMMC	(1 << 5)
+#define SYSMGR_FPGAINTF_SPIM0	BIT(0)
+#define SYSMGR_FPGAINTF_SPIM1	BIT(1)
+#define SYSMGR_FPGAINTF_EMAC0	BIT(2)
+#define SYSMGR_FPGAINTF_EMAC1	BIT(3)
+#define SYSMGR_FPGAINTF_NAND	BIT(4)
+#define SYSMGR_FPGAINTF_SDMMC	BIT(5)
 
 #define SYSMGR_SDMMC_DRVSEL_SHIFT	0
 
@@ -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	BIT(0)
+#define ALT_SYSMGR_NOC_LWH2F_SET_MSK	BIT(4)
+#define ALT_SYSMGR_NOC_F2H_SET_MSK	BIT(8)
+#define ALT_SYSMGR_NOC_F2SDR0_SET_MSK	BIT(16)
+#define ALT_SYSMGR_NOC_F2SDR1_SET_MSK	BIT(20)
+#define ALT_SYSMGR_NOC_F2SDR2_SET_MSK	BIT(24)
+#define ALT_SYSMGR_NOC_TMO_EN_SET_MSK	BIT(0)
+
+#define ALT_SYSMGR_ECC_INTSTAT_SERR_OCRAM_SET_MSK	BIT(1)
+#define ALT_SYSMGR_ECC_INTSTAT_DERR_OCRAM_SET_MSK	BIT(1)
+
 #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
 
 #define SYSMGR_GET_BOOTINFO_BSEL(bsel)		\
arch/arm/mach-socfpga/include/mach/system_manager_arria10.h new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#17 lore raw

PATCH v4 9/19 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
#18 lore raw

PATCH v4 10/19 arm: socfpga: Add misc support for Arria 10

In reply to Ley Foon Tan

Add misc support for Arria 10.

---
 arch/arm/mach-socfpga/Makefile            |   1 +
 arch/arm/mach-socfpga/include/mach/misc.h |   6 +
 arch/arm/mach-socfpga/misc_arria10.c      | 258 ++++++++++++++++++++++++++++++
 3 files changed, 265 insertions(+)
 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 f344749..0b65783 100644
@@ -22,4 +22,10 @@ void socfpga_fpga_add(void);
 static 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 +258 -0

258 lines not on this page · raw message

Signature · 1 line
1.8.2.3
#19 lore raw

PATCH v4 10/19 arm: socfpga: Add misc support for Arria 10

Quoted 4 lines · Ley Foon Tan

Add misc support for Arria 10.

[...]

Quoted 9 lines
arch/arm/mach-socfpga/misc_arria10.c new file +9 -0
+static int find_peripheral_uart(const void *blob,
+	int child, const char *node_name)
+{
+	int len;
+	fdt_addr_t base_addr = 0;
+	fdt_size_t size;
+	const u32 *cell;
+	u32 value, offset = 0;
+

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

Quoted 10 lines
arch/arm/mach-socfpga/misc_arria10.c new file +10 -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) {
+			for (; len > 0; len -= (2 * sizeof(u32))) {
+				offset = fdt32_to_cpu(*cell++);
+				value = fdt32_to_cpu(*cell++);
+				/* Found UART peripheral */
+				if (value == 0x0D)

What does 0x0d mean ?

Quoted 6 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+					return offset;
+			}
+		}
+	}
+	return -EINVAL;
+}

[...]

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

PATCH v4 10/19 arm: socfpga: Add misc support for Arria 10

Quoted 21 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan

Add misc support for Arria 10.

[...]

Quoted 13 lines
arch/arm/mach-socfpga/misc_arria10.c new file +13 -0
+static int find_peripheral_uart(const void *blob,
+     int child, const char *node_name)
+{
+     int len;
+     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);
Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+             if (cell != NULL) {
+                     for (; len > 0; len -= (2 * sizeof(u32))) {
+                             offset = fdt32_to_cpu(*cell++);
+                             value = fdt32_to_cpu(*cell++);
+                             /* Found UART peripheral */
+                             if (value == 0x0D)

What does 0x0d mean ?

0x0D is dedicated pin mux number for UART. I can update the comment here.

Quoted 10 lines
Quoted 7 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+                                     return offset;
+                     }
+             }
+     }
+     return -EINVAL;
+}

[...]

Regards
LeyFoon

#21 lore raw

PATCH v4 10/19 arm: socfpga: Add misc support for Arria 10

Quoted 30 lines · Ley Foon Tan
Quoted 21 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan

Add misc support for Arria 10.

[...]

Quoted 13 lines
arch/arm/mach-socfpga/misc_arria10.c new file +13 -0
+static int find_peripheral_uart(const void *blob,
+     int child, const char *node_name)
+{
+     int len;
+     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);
Quoted 8 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+             if (cell != NULL) {
+                     for (; len > 0; len -= (2 * sizeof(u32))) {
+                             offset = fdt32_to_cpu(*cell++);
+                             value = fdt32_to_cpu(*cell++);
+                             /* Found UART peripheral */
+                             if (value == 0x0D)

What does 0x0d mean ?

Quoted 1 line

0x0D is dedicated pin mux number for UART. I can update the comment here.

Even better, use a macro instead of an ad-hoc constant.

Quoted 12 lines
Quoted 9 lines
Quoted 6 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+                                     return offset;
+                     }
+             }
+     }
+     return -EINVAL;
+}

[...]

Regards
LeyFoon

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

PATCH v4 10/19 arm: socfpga: Add misc support for Arria 10

Quoted 31 lines · Marek Vasut
Quoted 30 lines · Ley Foon Tan
Quoted 29 lines · Marek Vasut
Quoted 4 lines · Ley Foon Tan

Add misc support for Arria 10.

[...]

Quoted 9 lines
arch/arm/mach-socfpga/misc_arria10.c new file +9 -0
+static int find_peripheral_uart(const void *blob,
+     int child, const char *node_name)
+{
+     int len;
+     fdt_addr_t base_addr = 0;
+     fdt_size_t size;
+     const u32 *cell;
+     u32 value, offset = 0;
+

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

Quoted 10 lines
arch/arm/mach-socfpga/misc_arria10.c new file +10 -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) {
+                     for (; len > 0; len -= (2 * sizeof(u32))) {
+                             offset = fdt32_to_cpu(*cell++);
+                             value = fdt32_to_cpu(*cell++);
+                             /* Found UART peripheral */
+                             if (value == 0x0D)

What does 0x0d mean ?

Quoted 3 lines
Quoted 1 line

0x0D is dedicated pin mux number for UART. I can update the comment here.

Even better, use a macro instead of an ad-hoc constant.

Okay, will use macro instead.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-socfpga/misc_arria10.c new file +6 -0
+                                     return offset;
+                     }
+             }
+     }
+     return -EINVAL;
+}
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

[...]

Regards
LeyFoon

Thanks.

Regards
Ley Foon

#23 lore raw

PATCH v4 11/19 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..ba51d45
@@ -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
#24 lore raw

PATCH v4 12/19 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 1edfbf2..94372cc 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
#26 lore raw

PATCH v4 12/19 fdt: Add compatible strings for Arria 10

In reply to Ley Foon Tan

Hi,

Quoted 15 lines · 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 +0 -0
index d074478..2134701 100644
@@ -155,6 +155,14 @@ enum fdt_compat_id {
        COMPAT_INTEL_BAYTRAIL_FSP_MDP,  /* Intel FSP memory-down params */

include/fdtdec.h enum fdt_compat_id { · line 165

Quoted 10 lines
include/fdtdec.h +8 -0
        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 */

You should not be adding strings here. Instead you should be creating a driver-model driver and put the compatible strings in there.

See the comment at the top of the C file for details.

Quoted 10 lines
include/fdtdec.h +0 -0
        COMPAT_COUNT,
 };
lib/fdtdec.c +0 -0
index 1edfbf2..94372cc 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"),

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

Quoted 10 lines
lib/fdtdec.c +8 -0
        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"),
 };

Regards,
Simon

#27 lore raw

PATCH v4 13/19 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   | 481 ++++++++++++
 4 files changed, 1371 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 462c690..f0c464d 100644
@@ -144,6 +144,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 +481 -0

481 lines not on this page · raw message

Signature · 1 line
1.8.2.3
maintainer
#28 lore raw

PATCH v4 13/19 arm: dts: Add dts and dtsi for Arria 10

Quoted 55 lines · 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   | 481 ++++++++++++
 4 files changed, 1371 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 462c690..f0c464d 100644
@@ -144,6 +144,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 +23 -0
new file mode 100644
index 0000000..52ab7fe
@@ -0,0 +1,859 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0        X11
+ */
+
+#include "skeleton.dtsi"
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/reset/altr,rst-mgr-a10.h>
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	aliases {
+		ethernet0 = &gmac0;
+		ethernet1 = &gmac1;
+		ethernet2 = &gmac2;
+		serial0 = &uart0;
+		serial1 = &uart1;
+		timer0 = &timer0;
+		timer1 = &timer1;
+		timer2 = &timer2;

arch/arm/dts/socfpga_arria10.dtsi line 33

Quoted 10 lines
arch/arm/dts/socfpga_arria10.dtsi new file +10 -0
+		timer3 = &timer3;
+		spi0 = &spi0;
+		spi1 = &spi1;
+	};
+
+	memory {
+		name = "memory";
+		device_type = "memory";
+		reg = <0x0 0x40000000>; /* 1GB */
+	};

This belongs in the board dts file. And again, please keep the original copyright from where you copied this file from.

[snip]

Quoted 26 lines
arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts new file +20 -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";
+};
+

arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts line 30

Quoted 10 lines
arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts new file +10 -0
+&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>;
+};

I don't think "altr,dw-mshc-ciu-div" and "altr,dw-mshc-sdr-timing" support has been added to U-Boot yet.

Dinh

#29 lore raw

PATCH v4 13/19 arm: dts: Add dts and dtsi for Arria 10

Quoted 63 lines · Dinh Nguyen
Quoted 60 lines · 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   | 481 ++++++++++++
 4 files changed, 1371 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 462c690..f0c464d 100644
@@ -144,6 +144,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 +28 -0
new file mode 100644
index 0000000..52ab7fe
@@ -0,0 +1,859 @@
+/*
+ * Copyright (C) 2016-2017 Intel Corporation
+ *
+ * SPDX-License-Identifier:  GPL-2.0        X11
+ */
+
+#include "skeleton.dtsi"
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/reset/altr,rst-mgr-a10.h>
+
+/ {
+     #address-cells = <1>;
+     #size-cells = <1>;
+
+     aliases {
+             ethernet0 = &gmac0;
+             ethernet1 = &gmac1;
+             ethernet2 = &gmac2;
+             serial0 = &uart0;
+             serial1 = &uart1;
+             timer0 = &timer0;
+             timer1 = &timer1;
+             timer2 = &timer2;
+             timer3 = &timer3;
+             spi0 = &spi0;
+             spi1 = &spi1;
+     };
+
Quoted 8 lines

arch/arm/dts/socfpga_arria10.dtsi line 33

Quoted 5 lines
arch/arm/dts/socfpga_arria10.dtsi new file +5 -0
+     memory {
+             name = "memory";
+             device_type = "memory";
+             reg = <0x0 0x40000000>; /* 1GB */
+     };

This belongs in the board dts file. And again, please keep the original copyright from where you copied this file from.

Yes, it is copied from kernel tree. Will keep the original copyright.

Quoted 35 lines

[snip]

Quoted 31 lines
arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts new file +25 -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;
Quoted 8 lines

arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts line 30

Quoted 5 lines
arch/arm/dts/socfpga_arria10_socdk_sdmmc.dts new file +5 -0
+     broken-cd;
+     bus-width = <4>;
+     altr,dw-mshc-ciu-div = <3>;
+     altr,dw-mshc-sdr-timing = <0 3>;
+};

I don't think "altr,dw-mshc-ciu-div" and "altr,dw-mshc-sdr-timing" support has been added to U-Boot yet.

Yes, these 2 dts parameters is not in U-boot yet. Will remove them.

Regards
Ley Foon

#30 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

In reply to Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +69 -5
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
 	unsigned long sdram_size;
 	unsigned long reg;
+	int ret;
 
 	/*
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
 	/* Put everything into reset but L4WD0. */
 	socfpga_per_reset_all();
 	/* Put FPGA bridges into reset too. */
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
 	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
 	/* De-assert reset for peripherals and bridges based on handoff */
 	reset_deassert_peripherals_handoff();
-	socfpga_bridges_reset(0);
+	ret = socfpga_bridges_reset(0);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	debug("Unfreezing/Thaw all I/O banks\n");
 	/* unfreeze / thaw all IO banks */
@@ -180,8 +199,53 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	/* 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 */
+	socfpga_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();
+
+	socfpga_watchdog_disable();
+
+	arch_early_init_r();
+
+#ifdef CONFIG_HW_WATCHDOG
+	/* release osc1 watchdog timer 0 from reset */
+	socfpga_reset_deassert_osc1wd0();
+
+	/* reconfigure and enable the watchdog */
+	hw_watchdog_init();
+	WATCHDOG_RESET();
+#endif /* CONFIG_HW_WATCHDOG */
+}
+#endif
Signature · 1 line
1.8.2.3
maintainer
#31 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

Quoted 96 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +25 -5
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
 	unsigned long sdram_size;
 	unsigned long reg;
+	int ret;
 
 	/*
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
 	/* Put everything into reset but L4WD0. */
 	socfpga_per_reset_all();
 	/* Put FPGA bridges into reset too. */
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
 	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
 	/* De-assert reset for peripherals and bridges based on handoff */
 	reset_deassert_peripherals_handoff();
-	socfpga_bridges_reset(0);
+	ret = socfpga_bridges_reset(0);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	debug("Unfreezing/Thaw all I/O banks\n");
 	/* unfreeze / thaw all IO banks */
@@ -180,8 +199,53 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {

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

Quoted 10 lines
arch/arm/mach-socfpga/spl.c +6 -0
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	/* 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)

Don't need to add another check for SPL_BOARD_INIT, it's already defined for CONFIG_TARGET_SOCFPGA_ARRIA10.

Dinh

maintainer
#32 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

Quoted 103 lines · Dinh Nguyen
Quoted 100 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +28 -5
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
 	unsigned long sdram_size;
 	unsigned long reg;
+	int ret;
 
 	/*
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
 	/* Put everything into reset but L4WD0. */
 	socfpga_per_reset_all();
 	/* Put FPGA bridges into reset too. */
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
 	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
 	/* De-assert reset for peripherals and bridges based on handoff */
 	reset_deassert_peripherals_handoff();
-	socfpga_bridges_reset(0);
+	ret = socfpga_bridges_reset(0);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	debug("Unfreezing/Thaw all I/O banks\n");
 	/* unfreeze / thaw all IO banks */
@@ -180,8 +199,53 @@ void board_init_f(ulong dummy)
 		hang();
 	}
 
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
Quoted 10 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/spl.c +3 -0
 	/* 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)

Don't need to add another check for SPL_BOARD_INIT, it's already defined for CONFIG_TARGET_SOCFPGA_ARRIA10.

Also, this patch is causing the DE0-NANO/Atlas board to no longer boot!

Dinh

maintainer
#33 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

Quoted 84 lines · Dinh Nguyen
Quoted 81 lines · Dinh Nguyen
Quoted 78 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +18 -3
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
 	unsigned long sdram_size;
 	unsigned long reg;
+	int ret;
 
 	/*
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
 	/* Put everything into reset but L4WD0. */
 	socfpga_per_reset_all();
 	/* Put FPGA bridges into reset too. */
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
 	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
arch/arm/mach-socfpga/spl.c +5 -1
 	/* De-assert reset for peripherals and bridges based on handoff */
 	reset_deassert_peripherals_handoff();
-	socfpga_bridges_reset(0);
+	ret = socfpga_bridges_reset(0);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}

I managed to debug the hang of the Atlas board to this function call. socfpga_bridges_reset is indeed returning an error from the FPGA, just the hang() is called.

The error is not caused by this patch, but is exposed by this patch. Will have to debug why the fpgamgr_test_fpga_ready() call from socfpga_bridges_reset(0) is returning an error.

Dinh

#34 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

Quoted 100 lines · Dinh Nguyen
Quoted 84 lines · Dinh Nguyen
Quoted 81 lines · Dinh Nguyen
Quoted 78 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +18 -3
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
    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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
    unsigned long sdram_size;
    unsigned long reg;
+   int ret;
 
    /*
     * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
    /* Put everything into reset but L4WD0. */
    socfpga_per_reset_all();
    /* Put FPGA bridges into reset too. */
-   socfpga_bridges_reset(1);
+   ret = socfpga_bridges_reset(1);
+   if (ret) {
+           printf("socfpga_bridges_reset() failed: %d\n", ret);
+           hang();
+   }
 
    socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
    socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
arch/arm/mach-socfpga/spl.c +5 -1
    /* De-assert reset for peripherals and bridges based on handoff */
    reset_deassert_peripherals_handoff();
-   socfpga_bridges_reset(0);
+   ret = socfpga_bridges_reset(0);
+   if (ret) {
+           printf("socfpga_bridges_reset() failed: %d\n", ret);
+           hang();
+   }

I managed to debug the hang of the Atlas board to this function call. socfpga_bridges_reset is indeed returning an error from the FPGA, just the hang() is called.

Quoted 4 lines

The error is not caused by this patch, but is exposed by this patch. Will have to debug why the fpgamgr_test_fpga_ready() call from socfpga_bridges_reset(0) is returning an error.

I've tested with our CV SoC devkit, it can bootup to U-boot stage. Thanks help to debug.

Regards
Ley Foon

#35 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

Quoted 101 lines · Ley Foon Tan
Quoted 100 lines · Dinh Nguyen
Quoted 84 lines · Dinh Nguyen
Quoted 81 lines · Dinh Nguyen
Quoted 78 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +18 -3
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
    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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
    unsigned long sdram_size;
    unsigned long reg;
+   int ret;
 
    /*
     * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
    /* Put everything into reset but L4WD0. */
    socfpga_per_reset_all();
    /* Put FPGA bridges into reset too. */
-   socfpga_bridges_reset(1);
+   ret = socfpga_bridges_reset(1);
+   if (ret) {
+           printf("socfpga_bridges_reset() failed: %d\n", ret);
+           hang();
+   }
 
    socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
    socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
arch/arm/mach-socfpga/spl.c +5 -1
    /* De-assert reset for peripherals and bridges based on handoff */
    reset_deassert_peripherals_handoff();
-   socfpga_bridges_reset(0);
+   ret = socfpga_bridges_reset(0);
+   if (ret) {
+           printf("socfpga_bridges_reset() failed: %d\n", ret);
+           hang();
+   }

I managed to debug the hang of the Atlas board to this function call. socfpga_bridges_reset is indeed returning an error from the FPGA, just the hang() is called.

Quoted 7 lines
Quoted 4 lines

The error is not caused by this patch, but is exposed by this patch. Will have to debug why the fpgamgr_test_fpga_ready() call from socfpga_bridges_reset(0) is returning an error.

I've tested with our CV SoC devkit, it can bootup to U-boot stage. Thanks help to debug.

I also tested on the CV devkit. It was fine. Make sure you test this series on as many variations of HW as you can.

Dinh

#36 lore raw

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

In reply to Dinh Nguyen
Quoted 100 lines · Dinh Nguyen
Quoted 84 lines · Dinh Nguyen
Quoted 81 lines · Dinh Nguyen
Quoted 78 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +18 -3
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
 	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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
 	unsigned long sdram_size;
 	unsigned long reg;
+	int ret;
 
 	/*
 	 * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
 	/* Put everything into reset but L4WD0. */
 	socfpga_per_reset_all();
 	/* Put FPGA bridges into reset too. */
-	socfpga_bridges_reset(1);
+	ret = socfpga_bridges_reset(1);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}
 
 	socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
 	socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
Quoted 8 lines
Quoted 8 lines

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

Quoted 8 lines
arch/arm/mach-socfpga/spl.c +5 -1
 	/* De-assert reset for peripherals and bridges based on handoff */
 	reset_deassert_peripherals_handoff();
-	socfpga_bridges_reset(0);
+	ret = socfpga_bridges_reset(0);
+	if (ret) {
+		printf("socfpga_bridges_reset() failed: %d\n", ret);
+		hang();
+	}

I managed to debug the hang of the Atlas board to this function call. socfpga_bridges_reset is indeed returning an error from the FPGA, just the hang() is called.

Quoted 3 lines

The error is not caused by this patch, but is exposed by this patch. Will have to debug why the fpgamgr_test_fpga_ready() call from socfpga_bridges_reset(0) is returning an error.

Super, thanks !

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

PATCH v4 14/19 arm: socfpga: Add SPL support for Arria 10

In reply to Dinh Nguyen
Quoted 103 lines · Dinh Nguyen
Quoted 100 lines · Ley Foon Tan

Add SPL support for Arria 10.

---
 arch/arm/mach-socfpga/spl.c | 74 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 69 insertions(+), 5 deletions(-)
arch/arm/mach-socfpga/spl.c +28 -5
index 69c433c..e1e62c2 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 (SYSMGR_GET_BOOTINFO_BSEL(bsel)) {
      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);
@@ -85,6 +95,7 @@ void board_init_f(ulong dummy)
 #endif
      unsigned long sdram_size;
      unsigned long reg;
+     int ret;
 
      /*
       * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -117,7 +128,11 @@ void board_init_f(ulong dummy)
      /* Put everything into reset but L4WD0. */
      socfpga_per_reset_all();
      /* Put FPGA bridges into reset too. */
-     socfpga_bridges_reset(1);
+     ret = socfpga_bridges_reset(1);
+     if (ret) {
+             printf("socfpga_bridges_reset() failed: %d\n", ret);
+             hang();
+     }
 
      socfpga_per_reset(SOCFPGA_RESET(SDR), 0);
      socfpga_per_reset(SOCFPGA_RESET(UART0), 0);
@@ -150,7 +165,11 @@ void board_init_f(ulong dummy)
 
      /* De-assert reset for peripherals and bridges based on handoff */
      reset_deassert_peripherals_handoff();
-     socfpga_bridges_reset(0);
+     ret = socfpga_bridges_reset(0);
+     if (ret) {
+             printf("socfpga_bridges_reset() failed: %d\n", ret);
+             hang();
+     }
 
      debug("Unfreezing/Thaw all I/O banks\n");
      /* unfreeze / thaw all IO banks */
@@ -180,8 +199,53 @@ void board_init_f(ulong dummy)
              hang();
      }
 
-     socfpga_bridges_reset(1);
+     ret = socfpga_bridges_reset(1);
+     if (ret) {
+             printf("socfpga_bridges_reset() failed: %d\n", ret);
+             hang();
+     }
 
Quoted 9 lines

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

Quoted 6 lines
arch/arm/mach-socfpga/spl.c +3 -0
      /* 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)

Don't need to add another check for SPL_BOARD_INIT, it's already defined for CONFIG_TARGET_SOCFPGA_ARRIA10.

Okay, will remove it.

Thanks.

Regards
Ley Foon

#38 lore raw

PATCH v4 15/19 drivers: fpga: Add compile switch for Gen5 only registers

In reply to Ley Foon Tan

These registers only available for Gen5 device, exclude them from 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
#39 lore raw

PATCH v4 15/19 drivers: fpga: Add compile switch for Gen5 only registers

Quoted 14 lines · Ley Foon Tan

These registers only available for Gen5 device, exclude them from Arria 10 build.

---
 drivers/fpga/socfpga.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/fpga/socfpga.c +0 -0
index f1b2f2c..3751574 100644

drivers/fpga/socfpga.c DECLARE_GLOBAL_DATA_PTR; · line 25

Quoted 7 lines
drivers/fpga/socfpga.c +2 -0
@@ -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

The ordering of the patches is important. You shouldn't need this patch because in patch #17, you wrapped the CONFIG_FPGA_SOCFPGA define by a GEN5 build. So this shouldn't get compiled at all.

But then I had a comment as to why the need to remove the FPGA build for A10.

Dinh

#40 lore raw

PATCH v4 15/19 drivers: fpga: Add compile switch for Gen5 only registers

Quoted 27 lines · Dinh Nguyen
Quoted 14 lines · Ley Foon Tan

These registers only available for Gen5 device, exclude them from Arria 10 build.

---
 drivers/fpga/socfpga.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/fpga/socfpga.c +0 -0
index f1b2f2c..3751574 100644

drivers/fpga/socfpga.c DECLARE_GLOBAL_DATA_PTR; · line 25

Quoted 7 lines
drivers/fpga/socfpga.c +2 -0
@@ -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

The ordering of the patches is important. You shouldn't need this patch because in patch #17, you wrapped the CONFIG_FPGA_SOCFPGA define by a GEN5 build. So this shouldn't get compiled at all.

Quoted 3 lines

But then I had a comment as to why the need to remove the FPGA build for A10.

Yes, we can remove this patch since CONFIG_FPGA_SOCFPGA is not enable for A10. As explained in another comment, A10 FPGA support will be in coming patch. Not including in this patch series.

Thanks.

Regards
Ley Foon

#41 lore raw

PATCH v4 16/19 arm: socfpga: Convert Altera DDR SDRAM driver to use Kconfig

In reply to Ley Foon Tan

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

---
 arch/arm/mach-socfpga/Kconfig    | 1 +
 drivers/Kconfig                  | 2 ++
 drivers/ddr/Kconfig              | 1 +
 drivers/ddr/altera/Kconfig       | 5 +++++
 drivers/ddr/altera/Makefile      | 4 +++-
 include/configs/socfpga_common.h | 5 -----
 6 files changed, 12 insertions(+), 6 deletions(-)
 create mode 100644 drivers/ddr/Kconfig
 create mode 100644 drivers/ddr/altera/Kconfig
arch/arm/mach-socfpga/Kconfig +1 -0
index e56b3db..e8c14f4 100644
@@ -43,6 +43,7 @@ config TARGET_SOCFPGA_CYCLONE5
 
 config TARGET_SOCFPGA_GEN5
 	bool
+	select ALTERA_SDRAM
 
 choice
 	prompt "Altera SOCFPGA board select"
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 +5 -0
new file mode 100644
index 0000000..021ec1d
@@ -0,0 +1,5 @@
+config ALTERA_SDRAM
+	bool "SoCFPGA DDR SDRAM driver"
+	depends on TARGET_SOCFPGA_GEN5
+	help
+	  Enable DDR SDRAM controller for the SoCFPGA devices.
drivers/ddr/altera/Makefile +3 -1
index 1ca7058..bdd2872 100644
@@ -8,4 +8,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_ALTERA_SDRAM) += sdram.o sequencer.o
+ifdef CONFIG_ALTERA_SDRAM
+obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram.o sequencer.o
+endif
include/configs/socfpga_common.h +0 -5
index 5fd178a..f93cd2e 100644
@@ -75,11 +75,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
Applied
#42 lore raw

PATCH v4 16/19 arm: socfpga: Convert Altera DDR SDRAM driver to use Kconfig

Quoted 7 lines · Ley Foon Tan

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

---

Applied, thanks.

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

PATCH v4 17/19 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       | 28 ++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 66 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 +++++++++++---
 3 files changed, 117 insertions(+), 5 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
configs/socfpga_arria10_defconfig new file +28 -0
new file mode 100644
index 0000000..e1f5929
@@ -0,0 +1,28 @@
+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
include/configs/socfpga_arria10_socdk.h new file +66 -0

66 lines not on this page · raw message

include/configs/socfpga_common.h +23 -5
index f93cd2e..85f8d62 100644
@@ -32,9 +32,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			\
@@ -65,8 +69,10 @@
 #define CONFIG_SYS_HOSTNAME	CONFIG_SYS_BOARD
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif
 
 /*
  * Cache
@@ -101,13 +107,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
  */
@@ -207,11 +214,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
 
@@ -298,7 +308,10 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE		CONFIG_SYS_INIT_RAM_ADDR
-#define CONFIG_SPL_MAX_SIZE		(64 * 1024)
+#define CONFIG_SPL_MAX_SIZE		CONFIG_SYS_INIT_RAM_SIZE
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_BOARD_INIT
+#endif
 
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -346,10 +359,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
#44 lore raw

PATCH v4 17/19 arm: socfpga: Add config and defconfig for Arria 10

Quoted 12 lines · Ley Foon Tan

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

---
 configs/socfpga_arria10_defconfig       | 28 ++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 66 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 +++++++++++---
 3 files changed, 117 insertions(+), 5 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h

[snip]

include/configs/socfpga_arria10_socdk.h line 26

Quoted 3 lines
include/configs/socfpga_arria10_socdk.h new file +3 -0
+
+/* Memory configurations  */
+#define PHYS_SDRAM_1_SIZE              0x80000000

For the HPS side, there's only 1GB on the devkit right?

Quoted 60 lines
include/configs/socfpga_arria10_socdk.h new file +40 -0
+
+/* 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 +5 -1
index f93cd2e..85f8d62 100644
@@ -32,9 +32,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                        \

include/configs/socfpga_common.h line 75

Quoted 7 lines
include/configs/socfpga_common.h +2 -0
@@ -65,8 +69,10 @@
 #define CONFIG_SYS_HOSTNAME    CONFIG_SYS_BOARD
 #endif
 
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif

Why doesn't A10 support CMD_PXE and MENU?

Quoted 6 lines
include/configs/socfpga_common.h +0 -0
 /*
  * Cache
@@ -101,13 +107,14 @@
 /*
  * FPGA Driver

include/configs/socfpga_common.h line 117

Quoted 10 lines
include/configs/socfpga_common.h +2 -1
  */
+#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

Wouldn't you also need to include these for the A10?

Quoted 21 lines
include/configs/socfpga_common.h +5 -2
 /*
  * L4 OSC1 Timer 0
  */
@@ -207,11 +214,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
 

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

Quoted 8 lines
include/configs/socfpga_common.h +4 -1
@@ -298,7 +308,10 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE           CONFIG_SYS_INIT_RAM_ADDR
-#define CONFIG_SPL_MAX_SIZE            (64 * 1024)
+#define CONFIG_SPL_MAX_SIZE            CONFIG_SYS_INIT_RAM_SIZE
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_BOARD_INIT
+#endif

SPL_BOARD_INIT is defined in socfpga_common.h

Quoted 7 lines
include/configs/socfpga_common.h +0 -0
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -346,10 +359,15 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 

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

Quoted 10 lines
include/configs/socfpga_common.h +5 -0
+#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
 

Why doesn't A10 support PXE?

Dinh

#45 lore raw

PATCH v4 17/19 arm: socfpga: Add config and defconfig for Arria 10

Quoted 14 lines · Dinh Nguyen
Quoted 4 lines · Ley Foon Tan

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

Quoted 8 lines
---
 configs/socfpga_arria10_defconfig       | 28 ++++++++++++++
 include/configs/socfpga_arria10_socdk.h | 66 +++++++++++++++++++++++++++++++++
 include/configs/socfpga_common.h        | 28 +++++++++++---
 3 files changed, 117 insertions(+), 5 deletions(-)
 create mode 100644 configs/socfpga_arria10_defconfig
 create mode 100644 include/configs/socfpga_arria10_socdk.h
Quoted 7 lines

[snip]

include/configs/socfpga_arria10_socdk.h line 26

Quoted 3 lines
include/configs/socfpga_arria10_socdk.h new file +3 -0
+
+/* Memory configurations  */
+#define PHYS_SDRAM_1_SIZE              0x80000000

For the HPS side, there's only 1GB on the devkit right?

Yes, will change to 1GB.

Quoted 64 lines
Quoted 64 lines
include/configs/socfpga_arria10_socdk.h new file +40 -0
+
+/* 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 +5 -1
index f93cd2e..85f8d62 100644
@@ -32,9 +32,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                        \
@@ -65,8 +69,10 @@
 #define CONFIG_SYS_HOSTNAME    CONFIG_SYS_BOARD
 #endif
 
Quoted 6 lines

include/configs/socfpga_common.h line 75

Quoted 4 lines
include/configs/socfpga_common.h +2 -0
+#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 #define CONFIG_CMD_PXE
 #define CONFIG_MENU
+#endif

Why doesn't A10 support CMD_PXE and MENU?

There was compilation error in A10 previously when enable PXE. I found it is due to missing CONFIG_CMD_DHCP. So, I will remove _GEN5 switch here.

Quoted 11 lines
Quoted 11 lines
include/configs/socfpga_common.h +1 -0
 /*
  * Cache
@@ -101,13 +107,14 @@
 /*
  * FPGA Driver
  */
+#ifdef CONFIG_TARGET_SOCFPGA_GEN5
 #ifdef CONFIG_CMD_FPGA
 #define CONFIG_FPGA
Quoted 8 lines

include/configs/socfpga_common.h line 117

Quoted 6 lines
include/configs/socfpga_common.h +1 -1
 #define CONFIG_FPGA_ALTERA
 #define CONFIG_FPGA_SOCFPGA
 #define CONFIG_FPGA_COUNT              1
 #endif
-
+#endif

Wouldn't you also need to include these for the A10?

This patchset doesn't include FPGA driver. So, disable for A10 as for now. We will enable this in coming upstream.

Quoted 21 lines
Quoted 21 lines
include/configs/socfpga_common.h +5 -2
 /*
  * L4 OSC1 Timer 0
  */
@@ -207,11 +214,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
 
Quoted 11 lines

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

Quoted 9 lines
include/configs/socfpga_common.h +4 -1
@@ -298,7 +308,10 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
  */
 #define CONFIG_SPL_FRAMEWORK
 #define CONFIG_SPL_TEXT_BASE           CONFIG_SYS_INIT_RAM_ADDR
-#define CONFIG_SPL_MAX_SIZE            (64 * 1024)
+#define CONFIG_SPL_MAX_SIZE            CONFIG_SYS_INIT_RAM_SIZE
+#if defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
+#define CONFIG_SPL_BOARD_INIT
+#endif

SPL_BOARD_INIT is defined in socfpga_common.h

This file is socfpga_common.h.

Quoted 8 lines
Quoted 8 lines
include/configs/socfpga_common.h +0 -0
 /* SPL SDMMC boot support */
 #ifdef CONFIG_SPL_MMC_SUPPORT
@@ -346,10 +359,15 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define BOOT_TARGET_DEVICES_MMC(func)
 #endif
 
Quoted 12 lines

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

Quoted 10 lines
include/configs/socfpga_common.h +5 -0
+#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
 

Why doesn't A10 support PXE?

Same here, will remove switch for GEN5 and ARRIA10. All will use same BOOT_TARGET_DEVICES().

Thanks.

Regards
Ley Foon

#46 lore raw

PATCH v4 18/19 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
#47 lore raw

PATCH v4 19/19 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 e8c14f4..f9f6871 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
@@ -49,6 +52,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
@@ -94,6 +101,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
@@ -106,6 +114,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
@@ -119,6 +128,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