arm: socfpga: Move Stratix 10 SDRAM driver to DM
Subsystems (3)
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
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.
---v1->v2:
- Change sdr device tree node enabled by default.
- Probe UCLASS_RAM only if CONFIG_ALTERA_SDRAM is enabled.
---
arch/arm/dts/socfpga_stratix10.dtsi | 9 +
arch/arm/mach-socfpga/spl_s10.c | 11 +-
configs/socfpga_stratix10_defconfig | 1 +
drivers/ddr/altera/Kconfig | 6 +-
drivers/ddr/altera/sdram_s10.c | 246 ++++++++++++------
.../mach => drivers/ddr/altera}/sdram_s10.h | 4 -
include/configs/socfpga_stratix10_socdk.h | 5 -
7 files changed, 192 insertions(+), 90 deletions(-)
rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)arch/arm/dts/socfpga_stratix10.dtsi +9 -0
@@ -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>;
arch/arm/mach-socfpga/spl_s10.c +7 -4
@@ -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 ;
@@ -119,6 +119,7 @@ void board_init_f(ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; +struct udevice *dev;#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */
@@ -175,11 +176,13 @@ 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" ); +#ifdef CONFIG_ALTERA_SDRAM + ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); } +#endif /* CONFIG_ALTERA_SDRAM */ mbox_init ();
configs/socfpga_stratix10_defconfig +1 -0
@@ -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_ALTERA_SDRAM=y CONFIG_DM_GPIO=y CONFIG_DWAPB_GPIO=y CONFIG_DM_I2C=y
drivers/ddr/altera/Kconfig +3 -3
@@ -1,7 +1,7 @@ config ALTERA_SDRAM bool "SoCFPGA DDR SDRAM driver" - 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 +172 -74
425 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
@@ -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
@@ -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_ALTERA_SDRAM -/* * Serial / UART configurations */
Signature · 1 line
2.19.0
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 36 lines · 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.hfrom arch to driver/ddr/altera directory.Signed-off-by Ley Foon Tan <[email protected]>---
v1->v2:
- Change sdr device tree node enabled by default.
- ProbeUCLASS_RAMonly ifCONFIG_ALTERA_SDRAMis enabled.--- arch/arm/dts/socfpga_stratix10.dtsi | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 +- configs/socfpga_stratix10_defconfig | 1 + drivers/ddr/altera/Kconfig | 6 +- drivers/ddr/altera/sdram_s10.c | 246 ++++++++++++------ .../mach => drivers/ddr/altera}/sdram_s10.h | 4 - include/configs/socfpga_stratix10_socdk.h | 5 - 7 files changed, 192 insertions(+), 90 deletions(-) rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)arch/arm/dts/socfpga_stratix10.dtsi +2
-0@@ -258,6 +258,15 @@ u-boot,dm-pre-reloc; }; + sdr: sdr at f8000400 { + compatible = "altr,sdr-ctl-s10";
arch/arm/dts/socfpga_stratix10.dtsi line 272
Quoted 10 lines
arch/arm/dts/socfpga_stratix10.dtsi +7
-0+ 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>;
Separate patch please
Quoted 24 lines
arch/arm/mach-socfpga/spl_s10.c +2
-1@@ -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 ;@@ -119,6 +119,7 @@ void board_init_f(ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; +struct udevice *dev;#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 179
Quoted 7 lines
arch/arm/mach-socfpga/spl_s10.c +1
-3@@ -175,11 +176,13 @@ 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" ); +#ifdef CONFIG_ALTERA_SDRAM
#if CONFIG_IS_ENABLED(ALTERA_SDRAM) (really, altera sdram ? How will this work with other SDRAM controllers in the FPGA ? I thought that was already discussed too)
Quoted 51 lines
arch/arm/mach-socfpga/spl_s10.c +4
-0+ ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); } +#endif /* CONFIG_ALTERA_SDRAM */ mbox_init ();configs/socfpga_stratix10_defconfig +1
-0@@ -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_ALTERA_SDRAM=y CONFIG_DM_GPIO=y CONFIG_DWAPB_GPIO=y CONFIG_DM_I2C=ydrivers/ddr/altera/Kconfig +3
-3@@ -1,7 +1,7 @@ config ALTERA_SDRAM bool "SoCFPGA DDR SDRAM driver" - 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 +3
-1@@ -5,17 +5,32 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <div64.h> #include <fdtdec.h> -#include <asm/io.h> +#include <ram.h> +#include <reset.h>
drivers/ddr/altera/sdram_s10.c line 22
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +3
-1+#include "sdram_s10.h" #include <wait_bit.h> #include <asm/arch/firewall_s10.h> -#include <asm/arch/sdram_s10.h> #include <asm/arch/system_manager.h> #include <asm/arch/reset_manager.h> +#include <asm/io.h> #include <linux/sizes.h> +#ifdef CONFIG_SPL_BUILD
Is this ifdef really needed ?
Quoted 14 lines
drivers/ddr/altera/sdram_s10.c +10
-0+struct altera_sdram_priv { +struct ram_info info; +}; + +struct altera_sdram_platdata { +void __iomem *hmc; +void __iomem *ddr_sch; +void __iomem *iomhc; +}; +DECLARE_GLOBAL_DATA_PTR ; static const struct socfpga_system_manager *sysmgr_regs =
drivers/ddr/altera/sdram_s10.c u32 ddr_config[] = { · line 71
Quoted 8 lines
drivers/ddr/altera/sdram_s10.c +2
-2@@ -51,25 +66,26 @@ u32 ddr_config[] = { DDR_CONFIG(1, 4, 10, 17), }; -static u32 hmc_readl (u32 reg) +static u32 hmc_readl (struct altera_sdram_platdata *plat,u32 reg) { -return readl (((void __iomem *)SOCFPGA_HMC_MMR_IO48_ADDRESS + (reg))); +return readl (plat->iomhc + (reg));
Superfluous parenthesis around (reg) , drop them, fix globally.
[...]
drivers/ddr/altera/sdram_s10.c static void sdram_size_check(bd_t *bd) · line 268
Quoted 9 lines
drivers/ddr/altera/sdram_s10.c +9
-0+/** +* sdram_calculate_size() - Calculate SDRAM size +* +* Calculate SDRAM device size based on SDRAM controller parameters. +* Size is specified in bytes. +*/ +static phys_size_t sdram_calculate_size (struct altera_sdram_platdata *plat) +{ +u32 dramaddrw =hmc_readl (plat,DRAMADDRW );
Is this a new piece of code ?
Quoted 12 lines
drivers/ddr/altera/sdram_s10.c +12
-0+phys_size_t size =1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_ROW_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_COL_ADDR_WIDTH (dramaddrw)); + + size *= (2 << (hmc_ecc_readl (plat,DDRIOCTRL ) & +DDR_HMC_DDRIOCTRL_IOSIZE_MSK )); + +return size; +} +
[...]
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +13
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) {
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +9
-0+puts ("SDRAM init failed.\n" ); + goto failed; + } + +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }
Are you missing altera_sdram_remove() , which would assert reset here ?
[...]
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 36 lines · Marek Vasut
Quoted 34 lines · 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.hfrom arch to driver/ddr/altera directory.Signed-off-by Ley Foon Tan <[email protected]>---
v1->v2:
- Change sdr device tree node enabled by default.
- ProbeUCLASS_RAMonly ifCONFIG_ALTERA_SDRAMis enabled.--- arch/arm/dts/socfpga_stratix10.dtsi | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 +- configs/socfpga_stratix10_defconfig | 1 + drivers/ddr/altera/Kconfig | 6 +- drivers/ddr/altera/sdram_s10.c | 246 ++++++++++++------ .../mach => drivers/ddr/altera}/sdram_s10.h | 4 - include/configs/socfpga_stratix10_socdk.h | 5 - 7 files changed, 192 insertions(+), 90 deletions(-) rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)arch/arm/dts/socfpga_stratix10.dtsi +0
-0@@ -258,6 +258,15 @@ u-boot,dm-pre-reloc; };
Quoted 14 lines
arch/arm/dts/socfpga_stratix10.dtsi line 272
Quoted 12 lines
arch/arm/dts/socfpga_stratix10.dtsi +9
-0+ 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>;Separate patch please
Okay.
Quoted 28 lines
Quoted 28 lines
arch/arm/mach-socfpga/spl_s10.c +2
-1@@ -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 ;@@ -119,6 +119,7 @@ void board_init_f(ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; +struct udevice *dev;#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ @@ -175,11 +176,13 @@ 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 );
Quoted 8 lines
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 179
Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c +1
-3-debug ("DDR: Initializing Hard Memory Controller\n" ); -if (sdram_mmr_init_full (0 )) { -puts ("DDR: Initialization failed.\n" ); +#ifdef CONFIG_ALTERA_SDRAM #if
CONFIG_IS_ENABLED(ALTERA_SDRAM)(really, altera sdram ? How will this work with other SDRAM controllers in the FPGA ? I thought that was already discussed too)
Tried change to #if CONFIG_IS_ENABLED(ALTERA_SDRAM), but it is not get compiled in SPL.
Found that it is only working if CONFIG consist of _SPL_ keyword, i.e:CONFIG_SPL_ALTERA_SDRAM.
FPGA SDRAM doesn't really need a driver. So, we don't need to probe UCLASS_RAM here.
Quoted 61 lines
Quoted 61 lines
arch/arm/mach-socfpga/spl_s10.c +4
-0+ ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); } +#endif /* CONFIG_ALTERA_SDRAM */ mbox_init ();configs/socfpga_stratix10_defconfig +1
-0@@ -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_ALTERA_SDRAM=y CONFIG_DM_GPIO=y CONFIG_DWAPB_GPIO=y CONFIG_DM_I2C=ydrivers/ddr/altera/Kconfig +3
-3@@ -1,7 +1,7 @@ config ALTERA_SDRAM bool "SoCFPGA DDR SDRAM driver" - 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 +5
-2@@ -5,17 +5,32 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <div64.h> #include <fdtdec.h> -#include <asm/io.h> +#include <ram.h> +#include <reset.h> +#include "sdram_s10.h" #include <wait_bit.h> #include <asm/arch/firewall_s10.h> -#include <asm/arch/sdram_s10.h> #include <asm/arch/system_manager.h> #include <asm/arch/reset_manager.h> +#include <asm/io.h> #include <linux/sizes.h>
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c line 22
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+#ifdef CONFIG_SPL_BUILD Is this ifdef really needed ?
Yes, these code will compile into Uboot image as well.
Quoted 18 lines
Quoted 18 lines
drivers/ddr/altera/sdram_s10.c +10
-0+struct altera_sdram_priv { +struct ram_info info; +}; + +struct altera_sdram_platdata { +void __iomem *hmc; +void __iomem *ddr_sch; +void __iomem *iomhc; +}; +DECLARE_GLOBAL_DATA_PTR ; static const struct socfpga_system_manager *sysmgr_regs =@@ -51,25 +66,26 @@ u32 ddr_config[] = { DDR_CONFIG(1, 4, 10, 17), };
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c u32 ddr_config[] = { · line 71
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c +2
-2-static u32 hmc_readl (u32 reg) +static u32 hmc_readl (struct altera_sdram_platdata *plat,u32 reg) { -return readl (((void __iomem *)SOCFPGA_HMC_MMR_IO48_ADDRESS + (reg))); +return readl (plat->iomhc + (reg));Superfluous parenthesis around (reg) , drop them, fix globally.
Okay.
Quoted 14 lines
[...]
drivers/ddr/altera/sdram_s10.c static void sdram_size_check(bd_t *bd) · line 268
Quoted 9 lines
drivers/ddr/altera/sdram_s10.c +9
-0+/** +* sdram_calculate_size() - Calculate SDRAM size +* +* Calculate SDRAM device size based on SDRAM controller parameters. +* Size is specified in bytes. +*/ +static phys_size_t sdram_calculate_size (struct altera_sdram_platdata *plat) +{ +u32 dramaddrw =hmc_readl (plat,DRAMADDRW );Is this a new piece of code ?
Not new. Just move this function to earlier of the file, before call to this function.
Quoted 32 lines
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +12
-0+phys_size_t size =1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_ROW_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_COL_ADDR_WIDTH (dramaddrw)); + + size *= (2 << (hmc_ecc_readl (plat,DDRIOCTRL ) & +DDR_HMC_DDRIOCTRL_IOSIZE_MSK )); + +return size; +} +[...]
Quoted 16 lines
drivers/ddr/altera/sdram_s10.c +16
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) { +puts ("SDRAM init failed.\n" ); + goto failed; + }
Quoted 8 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c +6
-0+ +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }Are you missing
altera_sdram_remove(), which would assert reset here ?
Will add it.
Quoted 4 lines
[...]
--
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 88 lines · Ley Foon Tan
Quoted 36 lines · Marek Vasut
Quoted 34 lines · 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.hfrom arch to driver/ddr/altera directory.Signed-off-by Ley Foon Tan <[email protected]>---
v1->v2:
- Change sdr device tree node enabled by default.
- ProbeUCLASS_RAMonly ifCONFIG_ALTERA_SDRAMis enabled.--- arch/arm/dts/socfpga_stratix10.dtsi | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 +- configs/socfpga_stratix10_defconfig | 1 + drivers/ddr/altera/Kconfig | 6 +- drivers/ddr/altera/sdram_s10.c | 246 ++++++++++++------ .../mach => drivers/ddr/altera}/sdram_s10.h | 4 - include/configs/socfpga_stratix10_socdk.h | 5 - 7 files changed, 192 insertions(+), 90 deletions(-) rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)arch/arm/dts/socfpga_stratix10.dtsi +0
-0@@ -258,6 +258,15 @@ u-boot,dm-pre-reloc; };Quoted 14 lines
arch/arm/dts/socfpga_stratix10.dtsi line 272
Quoted 12 lines
arch/arm/dts/socfpga_stratix10.dtsi +9
-0+ 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>;Separate patch please
Okay.
Quoted 28 lines
Quoted 28 lines
arch/arm/mach-socfpga/spl_s10.c +2
-1@@ -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 ;@@ -119,6 +119,7 @@ void board_init_f(ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; +struct udevice *dev;#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ @@ -175,11 +176,13 @@ 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 );Quoted 8 lines
arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 179
Quoted 4 lines
arch/arm/mach-socfpga/spl_s10.c +1
-3-debug ("DDR: Initializing Hard Memory Controller\n" ); -if (sdram_mmr_init_full (0 )) { -puts ("DDR: Initialization failed.\n" ); +#ifdef CONFIG_ALTERA_SDRAM #if
CONFIG_IS_ENABLED(ALTERA_SDRAM)(really, altera sdram ? How will this work with other SDRAM controllers in the FPGA ? I thought that was already discussed too)
Quoted 4 lines
Tried change to #if
CONFIG_IS_ENABLED(ALTERA_SDRAM), but it is not get compiled in SPL.
Found that it is only working if CONFIG consist of _SPL_ keyword, i.e:CONFIG_SPL_ALTERA_SDRAM.
Isn't that exactly what you want -- compile the DRAM driver only into SPL ?
Quoted 64 lines
FPGA SDRAM doesn't really need a driver. So, we don't need to probe
UCLASS_RAMhere.Quoted 61 lines
Quoted 61 lines
arch/arm/mach-socfpga/spl_s10.c +4
-0+ ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); } +#endif /* CONFIG_ALTERA_SDRAM */ mbox_init ();configs/socfpga_stratix10_defconfig +1
-0@@ -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_ALTERA_SDRAM=y CONFIG_DM_GPIO=y CONFIG_DWAPB_GPIO=y CONFIG_DM_I2C=ydrivers/ddr/altera/Kconfig +3
-3@@ -1,7 +1,7 @@ config ALTERA_SDRAM bool "SoCFPGA DDR SDRAM driver" - 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 +5
-2@@ -5,17 +5,32 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <div64.h> #include <fdtdec.h> -#include <asm/io.h> +#include <ram.h> +#include <reset.h> +#include "sdram_s10.h" #include <wait_bit.h> #include <asm/arch/firewall_s10.h> -#include <asm/arch/sdram_s10.h> #include <asm/arch/system_manager.h> #include <asm/arch/reset_manager.h> +#include <asm/io.h> #include <linux/sizes.h>
Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c line 22
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+#ifdef CONFIG_SPL_BUILD Is this ifdef really needed ?
Yes, these code will compile into Uboot image as well.
No, it won't, the code will only be compiled into the SPL with this ifdef. But that's something you should solve on the Kconfig/Kbuild level.
The way forward here is to create a new Kconfig symbol, some CONFIG_SPL_ALTERA_STRATIX10_DRAM or somesuch and then add a new entry into drivers/ddr/altera/Makefile to only compile this entire code when that symbol is enabled.
Quoted 40 lines
Quoted 18 lines
Quoted 18 lines
drivers/ddr/altera/sdram_s10.c +10
-0+struct altera_sdram_priv { +struct ram_info info; +}; + +struct altera_sdram_platdata { +void __iomem *hmc; +void __iomem *ddr_sch; +void __iomem *iomhc; +}; +DECLARE_GLOBAL_DATA_PTR ; static const struct socfpga_system_manager *sysmgr_regs =@@ -51,25 +66,26 @@ u32 ddr_config[] = { DDR_CONFIG(1, 4, 10, 17), };Quoted 7 lines
drivers/ddr/altera/sdram_s10.c u32 ddr_config[] = { · line 71
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c +2
-2-static u32 hmc_readl (u32 reg) +static u32 hmc_readl (struct altera_sdram_platdata *plat,u32 reg) { -return readl (((void __iomem *)SOCFPGA_HMC_MMR_IO48_ADDRESS + (reg))); +return readl (plat->iomhc + (reg));Superfluous parenthesis around (reg) , drop them, fix globally.
Okay.
Quoted 14 lines
[...]
drivers/ddr/altera/sdram_s10.c static void sdram_size_check(bd_t *bd) · line 268
Quoted 9 lines
drivers/ddr/altera/sdram_s10.c +9
-0+/** +* sdram_calculate_size() - Calculate SDRAM size +* +* Calculate SDRAM device size based on SDRAM controller parameters. +* Size is specified in bytes. +*/ +static phys_size_t sdram_calculate_size (struct altera_sdram_platdata *plat) +{ +u32 dramaddrw =hmc_readl (plat,DRAMADDRW );Is this a new piece of code ?
Quoted 2 lines
Not new. Just move this function to earlier of the file, before call to this function.
OK
Quoted 39 lines
Quoted 31 lines
Quoted 12 lines
drivers/ddr/altera/sdram_s10.c +12
-0+phys_size_t size =1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_ROW_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_COL_ADDR_WIDTH (dramaddrw)); + + size *= (2 << (hmc_ecc_readl (plat,DDRIOCTRL ) & +DDR_HMC_DDRIOCTRL_IOSIZE_MSK )); + +return size; +} +[...]
Quoted 16 lines
drivers/ddr/altera/sdram_s10.c +16
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) { +puts ("SDRAM init failed.\n" ); + goto failed; + }Quoted 8 lines
drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 7 lines
drivers/ddr/altera/sdram_s10.c +6
-0+ +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }Are you missing
altera_sdram_remove(), which would assert reset here ?
Quoted 1 line
Will add it.
But won't that prevent the DRAM controller from working ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 90 lines · Marek Vasut
Quoted 88 lines · Ley Foon Tan
Quoted 36 lines · Marek Vasut
Quoted 34 lines · 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.hfrom arch to driver/ddr/altera directory.Signed-off-by Ley Foon Tan <[email protected]>---
v1->v2:
- Change sdr device tree node enabled by default.
- ProbeUCLASS_RAMonly ifCONFIG_ALTERA_SDRAMis enabled.--- arch/arm/dts/socfpga_stratix10.dtsi | 9 + arch/arm/mach-socfpga/spl_s10.c | 11 +- configs/socfpga_stratix10_defconfig | 1 + drivers/ddr/altera/Kconfig | 6 +- drivers/ddr/altera/sdram_s10.c | 246 ++++++++++++------ .../mach => drivers/ddr/altera}/sdram_s10.h | 4 - include/configs/socfpga_stratix10_socdk.h | 5 - 7 files changed, 192 insertions(+), 90 deletions(-) rename {arch/arm/mach-socfpga/include/mach => drivers/ddr/altera}/sdram_s10.h (97%)arch/arm/dts/socfpga_stratix10.dtsi +0
-0@@ -258,6 +258,15 @@ u-boot,dm-pre-reloc; };Quoted 14 lines
arch/arm/dts/socfpga_stratix10.dtsi line 272
Quoted 12 lines
arch/arm/dts/socfpga_stratix10.dtsi +9
-0+ 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>;Separate patch please
Okay.
Quoted 36 lines
Quoted 25 lines
arch/arm/mach-socfpga/spl_s10.c +2
-1@@ -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 ;@@ -119,6 +119,7 @@ void board_init_f(ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config ();int ret; +struct udevice *dev;#ifdef CONFIG_HW_WATCHDOG /* Ensure watchdog is paused when debugging is happening */ arch/arm/mach-socfpga/spl_s10.c void board_init_f(ulong dummy) · line 179
Quoted 7 lines
arch/arm/mach-socfpga/spl_s10.c +1
-3@@ -175,11 +176,13 @@ 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" ); +#ifdef CONFIG_ALTERA_SDRAM #if
CONFIG_IS_ENABLED(ALTERA_SDRAM)(really, altera sdram ? How will this work with other SDRAM controllers in the FPGA ? I thought that was already discussed too)
Quoted 6 lines
Quoted 4 lines
Tried change to #if
CONFIG_IS_ENABLED(ALTERA_SDRAM), but it is not get compiled in SPL.
Found that it is only working if CONFIG consist of _SPL_ keyword, i.e:CONFIG_SPL_ALTERA_SDRAM.Isn't that exactly what you want -- compile the DRAM driver only into SPL ?
Yes. Will change to CONFIG_SPL_ALTERA_SDRAM.
Quoted 70 lines
Quoted 65 lines
FPGA SDRAM doesn't really need a driver. So, we don't need to probe
UCLASS_RAMhere.Quoted 61 lines
Quoted 61 lines
arch/arm/mach-socfpga/spl_s10.c +4
-0+ ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); } +#endif /* CONFIG_ALTERA_SDRAM */ mbox_init ();configs/socfpga_stratix10_defconfig +1
-0@@ -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_ALTERA_SDRAM=y CONFIG_DM_GPIO=y CONFIG_DWAPB_GPIO=y CONFIG_DM_I2C=ydrivers/ddr/altera/Kconfig +3
-3@@ -1,7 +1,7 @@ config ALTERA_SDRAM bool "SoCFPGA DDR SDRAM driver" - 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 +5
-2@@ -5,17 +5,32 @@*/ #include <common.h> +#include <dm.h> #include <errno.h> #include <div64.h> #include <fdtdec.h> -#include <asm/io.h> +#include <ram.h> +#include <reset.h> +#include "sdram_s10.h" #include <wait_bit.h> #include <asm/arch/firewall_s10.h> -#include <asm/arch/sdram_s10.h> #include <asm/arch/system_manager.h> #include <asm/arch/reset_manager.h> +#include <asm/io.h> #include <linux/sizes.h> Quoted 4 lines
Quoted 3 lines
drivers/ddr/altera/sdram_s10.c line 22
Quoted 1 line
drivers/ddr/altera/sdram_s10.c +1
-0+#ifdef CONFIG_SPL_BUILD Is this ifdef really needed ?
Yes, these code will compile into Uboot image as well.
Quoted 7 lines
No, it won't, the code will only be compiled into the SPL with this ifdef. But that's something you should solve on the Kconfig/Kbuild level.
The way forward here is to create a new
Kconfigsymbol, someCONFIG_SPL_ALTERA_STRATIX10_DRAMor somesuch and then add a new entry intodrivers/ddr/altera/Makefileto only compile this entire code when that symbol is enabled.
Will change ALTERA_SDRAM to SPL_ALTERA_SDRAM and compile in SPL only.
Quoted 85 lines
Quoted 41 lines
Quoted 19 lines
Quoted 19 lines
drivers/ddr/altera/sdram_s10.c +10
-0+struct altera_sdram_priv { +struct ram_info info; +}; + +struct altera_sdram_platdata { +void __iomem *hmc; +void __iomem *ddr_sch; +void __iomem *iomhc; +}; +DECLARE_GLOBAL_DATA_PTR ; static const struct socfpga_system_manager *sysmgr_regs =@@ -51,25 +66,26 @@ u32 ddr_config[] = { DDR_CONFIG(1, 4, 10, 17), };Quoted 7 lines
drivers/ddr/altera/sdram_s10.c u32 ddr_config[] = { · line 71
Quoted 5 lines
drivers/ddr/altera/sdram_s10.c +2
-2-static u32 hmc_readl (u32 reg) +static u32 hmc_readl (struct altera_sdram_platdata *plat,u32 reg) { -return readl (((void __iomem *)SOCFPGA_HMC_MMR_IO48_ADDRESS + (reg))); +return readl (plat->iomhc + (reg));Superfluous parenthesis around (reg) , drop them, fix globally.
Okay.
Quoted 14 lines
[...]
drivers/ddr/altera/sdram_s10.c static void sdram_size_check(bd_t *bd) · line 268
Quoted 9 lines
drivers/ddr/altera/sdram_s10.c +9
-0+/** +* sdram_calculate_size() - Calculate SDRAM size +* +* Calculate SDRAM device size based on SDRAM controller parameters. +* Size is specified in bytes. +*/ +static phys_size_t sdram_calculate_size (struct altera_sdram_platdata *plat) +{ +u32 dramaddrw =hmc_readl (plat,DRAMADDRW );Is this a new piece of code ?
Quoted 2 lines
Not new. Just move this function to earlier of the file, before call to this function.
OK
Quoted 39 lines
Quoted 39 lines
Quoted 12 lines
drivers/ddr/altera/sdram_s10.c +12
-0+phys_size_t size =1 << (DRAMADDRW_CFG_CS_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_GRP_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_BANK_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_ROW_ADDR_WIDTH (dramaddrw) + +DRAMADDRW_CFG_COL_ADDR_WIDTH (dramaddrw)); + + size *= (2 << (hmc_ecc_readl (plat,DDRIOCTRL ) & +DDR_HMC_DDRIOCTRL_IOSIZE_MSK )); + +return size; +} +[...]
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +13
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) {drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +9
-0+puts ("SDRAM init failed.\n" ); + goto failed; + } + +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }Are you missing
altera_sdram_remove(), which would assert reset here ?
Quoted 3 lines
Quoted 1 line
Will add it.
But won't that prevent the DRAM controller from working ?
Added assert reset in _remove, SDRAM controller still can work after boot to Uboot.
Seem _remove is not called when boot to Uboot.
Regards
Ley Foon
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
On 4/30/19 9:40 AM, Ley Foon Tan wrote:
[...]
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +13
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) {drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +9
-0+puts ("SDRAM init failed.\n" ); + goto failed; + } + +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }Are you missing
altera_sdram_remove(), which would assert reset here ?
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Will add it.
But won't that prevent the DRAM controller from working ?
Added assert reset in
_remove, SDRAM controller still can work after boot to Uboot.
Seem_removeis not called when boot to Uboot.
Look at DM_FLAG_OS_PREPARE
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 27 lines · Marek Vasut
On 4/30/19 9:40 AM, Ley Foon Tan wrote:
[...]Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
drivers/ddr/altera/sdram_s10.c +13
-0+static int altera_sdram_probe (struct udevice *dev) +{ +int ret; +struct reset_ctl_bulk resets; + + ret =reset_get_bulk (dev, &resets); +if (ret) { +dev_err (dev,"Can't get reset: %d\n" , ret); +return -ENODEV ; + } +reset_deassert_bulk (&resets); + +if (sdram_mmr_init_full (dev) !=0 ) {drivers/ddr/altera/sdram_s10.c int sdram_mmr_init_full(unsigned int unused) · line 585
Quoted 10 lines
drivers/ddr/altera/sdram_s10.c +9
-0+puts ("SDRAM init failed.\n" ); + goto failed; + } + +return 0 ; + +failed: +reset_release_bulk (&resets); +return -ENODEV ; }Are you missing
altera_sdram_remove(), which would assert reset here ?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Will add it.
But won't that prevent the DRAM controller from working ?
Added assert reset in
_remove, SDRAM controller still can work after boot to Uboot.
Seem_removeis not called when boot to Uboot.Look at
DM_FLAG_OS_PREPARE
Tested add DM_FLAG_OS_PREPARE flag, but still didn't see it call to _remove().
BTW, I think we shouldn't assert SDRAM controller. Otherwise, SDRAM is not working in next boot stage.
Regards
Ley Foon
PATCH v2 1/1 arm: socfpga: Move Stratix 10 SDRAM driver to DM
Quoted 35 lines · Ley Foon Tan
Quoted 34 lines · Marek Vasut
On 4/30/19 9:40 AM, Ley Foon Tan wrote:
[...]Quoted 30 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 13 lines
(quoted diff) +13
-0+static int altera_sdram_probe(struct udevice *dev) +{ + int ret; + struct reset_ctl_bulk resets; + + ret = reset_get_bulk(dev, &resets); + if (ret) { + dev_err(dev, "Can't get reset: %d\n", ret); + return -ENODEV; + } + reset_deassert_bulk(&resets); + + if (sdram_mmr_init_full(dev) != 0) {Review
Quoted 10 lines
(quoted diff) +9
-0+ puts("SDRAM init failed.\n"); + goto failed; + } + + return 0; + +failed: + reset_release_bulk(&resets); + return -ENODEV; }Are you missing
altera_sdram_remove(), which would assert reset here ?Quoted 3 lines
Quoted 1 line
Will add it.
But won't that prevent the DRAM controller from working ?
Added assert reset in
_remove, SDRAM controller still can work after boot to Uboot.
Seem_removeis not called when boot to Uboot.
Quoted 5 lines
Quoted 1 line
Look at
DM_FLAG_OS_PREPARETested add
DM_FLAG_OS_PREPAREflag, but still didn't see it call to_remove().BTW, I think we shouldn't assert SDRAM controller. Otherwise, SDRAM is not working in next boot stage.
Hence my question above -- "But won't that prevent the DRAM controller from working ?"
I think you're right.
Signature · 2 lines
Best regards, Marek Vasut