Skip to contentSkip to conversation

Move Stratix 10 SDRAM driver to DM

PATCH Superseded Ley Foon Tan 3 participants 7 messages May 3, 2019 – May 6, 2019

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Move Stratix 10 SDRAM driver to DM

Compile ALTERA_SDRAM driver in SPL only and move Stratix 10 SDRAM driver to DM.

v3 -> v4:
- Add CONFIG_SPL_ALTERA_SDRAM to config_whitelist.txt in patch [1/3] and remove it in patch [3/3]
- Remove _remove().
- Update commit message in patch [2/3]

v2->v3:
-------
- Compile ALTERA_SDRAM driver in SPL only
- Separate dts change to new patch
- Change to use #if CONFIG_IS_ENABLED(ALTERA_SDRAM)
- Add _remove()
- Remove #ifdef CONFIG_SPL_BUILD checking in sdram_s10.c

History:
--------
[v1]: https://patchwork.ozlabs.org/patch/1066765/
[v2]: https://patchwork.ozlabs.org/patch/1089957/
[v3]: https://patchwork.ozlabs.org/cover/1093091/

Ley Foon Tan (3):
ddr: altera: Compile ALTERA SDRAM in SPL only
arm: dts: Stratix10: Add SDRAM node
arm: socfpga: Move Stratix 10 SDRAM driver to DM

 Makefile                                      |   2 +-
 arch/arm/dts/socfpga_stratix10.dtsi           |   9 +
 arch/arm/mach-socfpga/Kconfig                 |   4 +-
 arch/arm/mach-socfpga/spl_s10.c               |  16 +-
 configs/socfpga_stratix10_defconfig           |   1 +
 drivers/Makefile                              |   2 +-
 drivers/ddr/altera/Kconfig                    |  11 +-
 drivers/ddr/altera/Makefile                   |   2 +-
 drivers/ddr/altera/sdram_s10.c                | 243 ++++++++++++------
 .../mach => drivers/ddr/altera}/sdram_s10.h   |   4 -
 include/configs/socfpga_stratix10_socdk.h     |   5 -
 11 files changed, 200 insertions(+), 99 deletions(-)
 rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)
Signature · 1 line
2.19.0
#1 lore raw

PATCH v4 1/3 ddr: altera: Compile ALTERA SDRAM in SPL only

Compile ALTERA_SDRAM driver in SPL only.
Rename ALTERA_SDRAM to SPL_ALTERA_SDRAM.

---
 Makefile                                  | 2 +-
 arch/arm/mach-socfpga/Kconfig             | 4 ++--
 drivers/Makefile                          | 2 +-
 drivers/ddr/altera/Kconfig                | 5 +++--
 drivers/ddr/altera/Makefile               | 2 +-
 include/configs/socfpga_stratix10_socdk.h | 2 +-
 scripts/config_whitelist.txt              | 1 +
 7 files changed, 10 insertions(+), 8 deletions(-)
Makefile +1 -1
index 66a09ac900..53c7709d22 100644
@@ -713,7 +713,7 @@ libs-y += drivers/spi/
 libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
 libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
 libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/
-libs-$(CONFIG_ALTERA_SDRAM) += drivers/ddr/altera/
+libs-$(CONFIG_$(SPL_)ALTERA_SDRAM) += drivers/ddr/altera/
 libs-y += drivers/serial/
 libs-y += drivers/usb/dwc3/
 libs-y += drivers/usb/common/
arch/arm/mach-socfpga/Kconfig +2 -2
index 5e87371f8c..d4d878d3be 100644
@@ -9,7 +9,7 @@ config TARGET_SOCFPGA_ARRIA5
 
 config TARGET_SOCFPGA_ARRIA10
 	bool
-	select ALTERA_SDRAM
+	select SPL_ALTERA_SDRAM
 	select SPL_BOARD_INIT if SPL
 	select CLK
 	select SPL_CLK if SPL
@@ -28,7 +28,7 @@ config TARGET_SOCFPGA_CYCLONE5
 
 config TARGET_SOCFPGA_GEN5
 	bool
-	select ALTERA_SDRAM
+	select SPL_ALTERA_SDRAM
 
 config TARGET_SOCFPGA_STRATIX10
 	bool
drivers/Makefile +1 -1
index a7bba3ed56..e501ae8d04 100644
@@ -34,7 +34,7 @@ obj-$(CONFIG_SPL_CRYPTO_SUPPORT) += crypto/
 obj-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += ddr/fsl/
 obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/
 obj-$(CONFIG_ARMADA_XP) += ddr/marvell/axp/
-obj-$(CONFIG_ALTERA_SDRAM) += ddr/altera/
+obj-$(CONFIG_$(SPL_)ALTERA_SDRAM) += ddr/altera/
 obj-$(CONFIG_ARCH_IMX8M) += ddr/imx/imx8m/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/ power/pmic/
 obj-$(CONFIG_SPL_POWER_SUPPORT) += power/regulator/
drivers/ddr/altera/Kconfig +3 -2
index 8f60b56eb8..83c1ab5e07 100644
@@ -1,5 +1,6 @@
-config ALTERA_SDRAM
-	bool "SoCFPGA DDR SDRAM driver"
+config SPL_ALTERA_SDRAM
+	bool "SoCFPGA DDR SDRAM driver in SPL"
+	depends on SPL
 	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
 	select RAM if TARGET_SOCFPGA_GEN5
 	select SPL_RAM if TARGET_SOCFPGA_GEN5
drivers/ddr/altera/Makefile +1 -1
index 3615b617ec..341ac0d73b 100644
@@ -6,7 +6,7 @@
 # (C) Copyright 2010, Thomas Chou <[email protected]>
 # Copyright (C) 2014 Altera Corporation <www.altera.com>
 
-ifdef CONFIG_ALTERA_SDRAM
+ifdef CONFIG_$(SPL_)ALTERA_SDRAM
 obj-$(CONFIG_TARGET_SOCFPGA_GEN5) += sdram_gen5.o sequencer.o
 obj-$(CONFIG_TARGET_SOCFPGA_ARRIA10) += sdram_arria10.o
 obj-$(CONFIG_TARGET_SOCFPGA_STRATIX10) += sdram_s10.o
include/configs/socfpga_stratix10_socdk.h +1 -1
index 31c267f55d..9d1bc8e8d5 100644
@@ -132,7 +132,7 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 /*
  * SDRAM controller
  */
-#define CONFIG_ALTERA_SDRAM
+#define CONFIG_SPL_ALTERA_SDRAM
 
 /*
  * Serial / UART configurations
scripts/config_whitelist.txt +1 -0
index 421362d953..f0c755fc83 100644
@@ -1826,6 +1826,7 @@ CONFIG_SPLASH_SCREEN_ALIGN
 CONFIG_SPLASH_SOURCE
 CONFIG_SPLL_FREQ
 CONFIG_SPL_
+CONFIG_SPL_ALTERA_SDRAM
 CONFIG_SPL_ATMEL_SIZE
 CONFIG_SPL_BOARD_LOAD_IMAGE
 CONFIG_SPL_BOOTROM_SAVE
Signature · 1 line
2.19.0
#2 lore raw

PATCH v4 2/3 arm: dts: Stratix10: Add SDRAM node

In reply to Ley Foon Tan

Add SDRAM device tree node.

---
 arch/arm/dts/socfpga_stratix10.dtsi | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/arm/dts/socfpga_stratix10.dtsi +9 -0
index d1ae2fabae..bd68a78a37 100755
@@ -258,6 +258,15 @@
 			u-boot,dm-pre-reloc;
 		};
 
+		sdr: sdr at f8000400 {
+			 compatible = "altr,sdr-ctl-s10";
+			 reg = <0xf8000400 0x80>,
+			       <0xf8010000 0x190>,
+			       <0xf8011000 0x500>;
+			 resets = <&rst DDRSCH_RESET>;
+			 u-boot,dm-pre-reloc;
+		 };
+
 		spi0: spi at ffda4000 {
 			compatible = "snps,dw-apb-ssi";
 			#address-cells = <1>;
Signature · 1 line
2.19.0
#3 lore raw

PATCH v4 3/3 arm: socfpga: Move Stratix 10 SDRAM driver to DM

In reply to Ley Foon Tan

Convert Stratix 10 SDRAM driver to device model.

Get rid of call to socfpga_per_reset() and use reset framework.

SPL is changed from calling function in SDRAM driver directly to just probing UCLASS_RAM.

Move sdram_s10.h from arch to driver/ddr/altera directory.

---
 arch/arm/mach-socfpga/spl_s10.c               |  16 +-
 configs/socfpga_stratix10_defconfig           |   1 +
 drivers/ddr/altera/Kconfig                    |   6 +-
 drivers/ddr/altera/sdram_s10.c                | 243 ++++++++++++------
 .../mach => drivers/ddr/altera}/sdram_s10.h   |   4 -
 include/configs/socfpga_stratix10_socdk.h     |   5 -
 scripts/config_whitelist.txt                  |   1 -
 7 files changed, 183 insertions(+), 93 deletions(-)
 rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)
arch/arm/mach-socfpga/spl_s10.c +10 -6
index a141ffe82a..ec65e1ce64 100644
@@ -15,9 +15,9 @@
 #include <asm/arch/firewall_s10.h>
 #include <asm/arch/mailbox_s10.h>
 #include <asm/arch/reset_manager.h>
-#include <asm/arch/sdram_s10.h>
 #include <asm/arch/system_manager.h>
 #include <watchdog.h>
+#include <dm/uclass.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -175,11 +175,15 @@ void board_init_f(ulong dummy)
 	clrbits_le32(CCU_REG_ADDR(CCU_IOM_MPRT_ADMASK_MEM_RAM0),
 		     CCU_ADMASK_P_MASK | CCU_ADMASK_NS_MASK);
 
-	debug("DDR: Initializing Hard Memory Controller\n");
-	if (sdram_mmr_init_full(0)) {
-		puts("DDR: Initialization failed.\n");
-		hang();
-	}
+#if CONFIG_IS_ENABLED(ALTERA_SDRAM)
+		struct udevice *dev;
+
+		ret = uclass_get_device(UCLASS_RAM, 0, &dev);
+		if (ret) {
+			debug("DRAM init failed: %d\n", ret);
+			hang();
+		}
+#endif
 
 	mbox_init();
 
configs/socfpga_stratix10_defconfig +1 -0
index 4848013b21..c85a0f785a 100644
@@ -32,6 +32,7 @@ CONFIG_ENV_IS_IN_MMC=y
 CONFIG_NET_RANDOM_ETHADDR=y
 CONFIG_SPL_DM=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_ALTERA_SDRAM=y
 CONFIG_DM_GPIO=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_DM_I2C=y
drivers/ddr/altera/Kconfig +3 -3
index 83c1ab5e07..2b1c1be3b5 100644
@@ -1,8 +1,8 @@
 config SPL_ALTERA_SDRAM
 	bool "SoCFPGA DDR SDRAM driver in SPL"
 	depends on SPL
-	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10
-	select RAM if TARGET_SOCFPGA_GEN5
-	select SPL_RAM if TARGET_SOCFPGA_GEN5
+	depends on TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_ARRIA10 || TARGET_SOCFPGA_STRATIX10
+	select RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10
+	select SPL_RAM if TARGET_SOCFPGA_GEN5 || TARGET_SOCFPGA_STRATIX10
 	help
 	  Enable DDR SDRAM controller for the SoCFPGA devices.
drivers/ddr/altera/sdram_s10.c +169 -74

422 lines not on this page · raw message

drivers/ddr/altera/sdram_s10.h renamed from arch/arm/mach-socfpga/include/mach/sdram_s10.h +0 -4
similarity index 97%
rename from arch/arm/mach-socfpga/include/mach/sdram_s10.h
rename to drivers/ddr/altera/sdram_s10.h
index f39206ca1e..096c06cba2 100644
@@ -7,10 +7,6 @@
 #ifndef	_SDRAM_S10_H_
 #define	_SDRAM_S10_H_
 
-phys_size_t sdram_calculate_size(void);
-int sdram_mmr_init_full(unsigned int sdr_phy_reg);
-int sdram_calibration_full(void);
-
 #define DDR_TWR				15
 #define DDR_READ_LATENCY_DELAY		40
 #define DDR_ACTIVATE_FAWBANK		0x1
include/configs/socfpga_stratix10_socdk.h +0 -5
index 9d1bc8e8d5..2af808cadf 100644
@@ -129,11 +129,6 @@ unsigned int cm_get_qspi_controller_clk_hz(void);
 #define CONFIG_SYS_MEMTEST_START	0
 #define CONFIG_SYS_MEMTEST_END		PHYS_SDRAM_1_SIZE - 0x200000
 
-/*
- * SDRAM controller
- */
-#define CONFIG_SPL_ALTERA_SDRAM
-
 /*
  * Serial / UART configurations
  */
scripts/config_whitelist.txt +0 -1
index f0c755fc83..421362d953 100644
@@ -1826,7 +1826,6 @@ CONFIG_SPLASH_SCREEN_ALIGN
 CONFIG_SPLASH_SOURCE
 CONFIG_SPLL_FREQ
 CONFIG_SPL_
-CONFIG_SPL_ALTERA_SDRAM
 CONFIG_SPL_ATMEL_SIZE
 CONFIG_SPL_BOARD_LOAD_IMAGE
 CONFIG_SPL_BOOTROM_SAVE
Signature · 1 line
2.19.0
#4 lore raw

v4 cover Move Stratix 10 SDRAM driver to DM

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

Compile ALTERA_SDRAM driver in SPL only and move Stratix 10 SDRAM driver to DM.

v3 -> v4:
- Add CONFIG_SPL_ALTERA_SDRAM to config_whitelist.txt in patch [1/3] and remove it in patch [3/3]
- Remove _remove().
- Update commit message in patch [2/3]

v2->v3:
-------
- Compile ALTERA_SDRAM driver in SPL only
- Separate dts change to new patch
- Change to use #if CONFIG_IS_ENABLED(ALTERA_SDRAM)
- Add _remove()
- Remove #ifdef CONFIG_SPL_BUILD checking in sdram_s10.c

History:
--------
[v1]: https://patchwork.ozlabs.org/patch/1066765/
[v2]: https://patchwork.ozlabs.org/patch/1089957/
[v3]: https://patchwork.ozlabs.org/cover/1093091/

Ley Foon Tan (3):
ddr: altera: Compile ALTERA SDRAM in SPL only
arm: dts: Stratix10: Add SDRAM node
arm: socfpga: Move Stratix 10 SDRAM driver to DM

Quoted 14 lines
 Makefile                                      |   2 +-
 arch/arm/dts/socfpga_stratix10.dtsi           |   9 +
 arch/arm/mach-socfpga/Kconfig                 |   4 +-
 arch/arm/mach-socfpga/spl_s10.c               |  16 +-
 configs/socfpga_stratix10_defconfig           |   1 +
 drivers/Makefile                              |   2 +-
 drivers/ddr/altera/Kconfig                    |  11 +-
 drivers/ddr/altera/Makefile                   |   2 +-
 drivers/ddr/altera/sdram_s10.c                | 243 ++++++++++++------
 .../mach => drivers/ddr/altera}/sdram_s10.h   |   4 -
 include/configs/socfpga_stratix10_socdk.h     |   5 -
 11 files changed, 200 insertions(+), 99 deletions(-)
 rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)

I wanted to pick them, but they don't apply to u-boot/master ?

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

v4 cover Move Stratix 10 SDRAM driver to DM

Quoted 42 lines · Marek Vasut
Quoted 26 lines · Ley Foon Tan

Compile ALTERA_SDRAM driver in SPL only and move Stratix 10 SDRAM driver to DM.

v3 -> v4:
- Add CONFIG_SPL_ALTERA_SDRAM to config_whitelist.txt in patch [1/3] and remove it in patch [3/3]
- Remove _remove().
- Update commit message in patch [2/3]

v2->v3:
-------
- Compile ALTERA_SDRAM driver in SPL only
- Separate dts change to new patch
- Change to use #if CONFIG_IS_ENABLED(ALTERA_SDRAM)
- Add _remove()
- Remove #ifdef CONFIG_SPL_BUILD checking in sdram_s10.c

History:
--------
[v1]: https://patchwork.ozlabs.org/patch/1066765/
[v2]: https://patchwork.ozlabs.org/patch/1089957/
[v3]: https://patchwork.ozlabs.org/cover/1093091/

Ley Foon Tan (3):
ddr: altera: Compile ALTERA SDRAM in SPL only
arm: dts: Stratix10: Add SDRAM node
arm: socfpga: Move Stratix 10 SDRAM driver to DM

Quoted 14 lines
 Makefile                                      |   2 +-
 arch/arm/dts/socfpga_stratix10.dtsi           |   9 +
 arch/arm/mach-socfpga/Kconfig                 |   4 +-
 arch/arm/mach-socfpga/spl_s10.c               |  16 +-
 configs/socfpga_stratix10_defconfig           |   1 +
 drivers/Makefile                              |   2 +-
 drivers/ddr/altera/Kconfig                    |  11 +-
 drivers/ddr/altera/Makefile                   |   2 +-
 drivers/ddr/altera/sdram_s10.c                | 243 ++++++++++++------
 .../mach => drivers/ddr/altera}/sdram_s10.h   |   4 -
 include/configs/socfpga_stratix10_socdk.h     |   5 -
 11 files changed, 200 insertions(+), 99 deletions(-)
 rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)
Quoted 1 line

I wanted to pick them, but they don't apply to u-boot/master ?

I will rebase them to u-boot/master and resend again.

Thanks.

Regards
Ley Foon

#6 lore raw

v4 cover Move Stratix 10 SDRAM driver to DM

Quoted 43 lines · Ley Foon Tan
Quoted 42 lines · Marek Vasut
Quoted 40 lines · Ley Foon Tan

Compile ALTERA_SDRAM driver in SPL only and move Stratix 10 SDRAM driver to DM.

v3 -> v4:
- Add CONFIG_SPL_ALTERA_SDRAM to config_whitelist.txt in patch [1/3] and remove it in patch [3/3]
- Remove _remove().
- Update commit message in patch [2/3]

v2->v3:
-------
- Compile ALTERA_SDRAM driver in SPL only
- Separate dts change to new patch
- Change to use #if CONFIG_IS_ENABLED(ALTERA_SDRAM)
- Add _remove()
- Remove #ifdef CONFIG_SPL_BUILD checking in sdram_s10.c

History:
--------
[v1]: https://patchwork.ozlabs.org/patch/1066765/
[v2]: https://patchwork.ozlabs.org/patch/1089957/
[v3]: https://patchwork.ozlabs.org/cover/1093091/

Ley Foon Tan (3):
ddr: altera: Compile ALTERA SDRAM in SPL only
arm: dts: Stratix10: Add SDRAM node
arm: socfpga: Move Stratix 10 SDRAM driver to DM

 Makefile                                      |   2 +-
 arch/arm/dts/socfpga_stratix10.dtsi           |   9 +
 arch/arm/mach-socfpga/Kconfig                 |   4 +-
 arch/arm/mach-socfpga/spl_s10.c               |  16 +-
 configs/socfpga_stratix10_defconfig           |   1 +
 drivers/Makefile                              |   2 +-
 drivers/ddr/altera/Kconfig                    |  11 +-
 drivers/ddr/altera/Makefile                   |   2 +-
 drivers/ddr/altera/sdram_s10.c                | 243 ++++++++++++------
 .../mach => drivers/ddr/altera}/sdram_s10.h   |   4 -
 include/configs/socfpga_stratix10_socdk.h     |   5 -
 11 files changed, 200 insertions(+), 99 deletions(-)
 rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)
Quoted 2 lines
Quoted 1 line

I wanted to pick them, but they don't apply to u-boot/master ?

I will rebase them to u-boot/master and resend again.

Thanks!

Signature · 2 lines
Best regards,
Marek Vasut