arm: socfpga: move gen5 SDR driver to DM
Subsystems (3)
PATCH v5 1/1 arm: socfpga: move gen5 SDR driver to DM
To clean up reset handling for socfpga gen5, port the DDR driver to DM using UCLASS_RAM and implement proper reset handling.
This gets us rid of one ad-hoc call to socfpga_per_reset().
The gen5 driver is implemented in 2 distinct files. One of it (containing the calibration training) is not touched much and is kept at using hard coded addresses since the code grows even more otherwise.
SPL is changed from calling hard into the DDR driver code to just probing UCLASS_RESET and UCLASS_RAM. It is happy after finding a RAM driver after that.
---
Changes in v5:
- fix Kconfig dependencies so that non-gen5 socfpga is fixed
Changes in v2:
- port DDR driver to DM UCLASS_RAM
- don't change DDR calibration training driver (code got too big)
- use reset.h code instead of socfpga_per_reset()
For v5, this is the only patch left with changes (all other patches are OK from v4, but this one needed changes). Being like that, this patch alone isn't applicable but needs all other patches from v4.
--- arch/arm/dts/socfpga.dtsi | 4 +- .../mach-socfpga/include/mach/sdram_gen5.h | 4 - arch/arm/mach-socfpga/spl_gen5.c | 29 ++-- drivers/ddr/altera/Kconfig | 2 + drivers/ddr/altera/sdram_gen5.c | 143 ++++++++++++++++-- drivers/ddr/altera/sequencer.c | 9 +- drivers/ddr/altera/sequencer.h | 35 +++++ 7 files changed, 184 insertions(+), 42 deletions(-)
arch/arm/dts/socfpga.dtsi +2 -2
@@ -791,9 +791,9 @@ reg = <0xfffec000 0x100>; }; - sdr: sdr at ffc25000 { + sdr: sdr at ffc20000 { compatible = "altr,sdr-ctl", "syscon"; - reg = <0xffc25000 0x1000>; + reg = <0xffc20000 0x6000>; resets = <&rst SDR_RESET>; };
arch/arm/mach-socfpga/include/mach/sdram_gen5.h +0 -4
@@ -7,10 +7,6 @@#ifndef __ASSEMBLY__ -unsigned long sdram_calculate_size (void ); -int sdram_mmr_init_full (unsigned int sdr_phy_reg); -int sdram_calibration_full (void ); -const struct socfpga_sdram_config *socfpga_get_sdram_config (void );void socfpga_get_seq_ac_init (const u32 **init,unsigned int *nelem);
arch/arm/mach-socfpga/spl_gen5.c +9 -20
@@ -21,6 +21,7 @@#include <debug_uart.h> #include <fdtdec.h> #include <watchdog.h> +#include <dm/uclass.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -123,9 +124,9 @@ static void socfpga_pl310_clear(void)void board_init_f (ulong dummy) {const struct cm_config *cm_default_cfg =cm_get_default_config (); -unsigned long sdram_size;unsigned long reg;int ret; +struct udevice *dev;/* * First C code to run. Clear fake OCRAM ECC first as SBE
@@ -156,7 +157,6 @@ void board_init_f(ulong dummy)socfpga_bridges_reset (1 ); } -socfpga_per_reset (SOCFPGA_RESET (SDR ),0 );socfpga_per_reset (SOCFPGA_RESET (UART0 ),0 );socfpga_per_reset (SOCFPGA_RESET (OSC1TIMER0 ),0 );
@@ -200,27 +200,16 @@ void board_init_f(ulong dummy)hang (); } + ret =uclass_get_device (UCLASS_RESET ,0 , &dev); +if (ret) +debug ("Reset init failed: %d\n" , ret); +/* enable console uart printing */ preloader_console_init (); -if (sdram_mmr_init_full (0xffffffff ) !=0 ) { -puts ("SDRAM init failed.\n" ); -hang (); - } - -debug ("SDRAM: Calibrating PHY\n" ); -/* SDRAM calibration */ -if (sdram_calibration_full () ==0 ) { -puts ("SDRAM calibration failed.\n" ); -hang (); - } - - sdram_size =sdram_calculate_size (); -debug ("SDRAM: %ld MiB\n" , sdram_size >>20 ); - -/* Sanity check ensure correct SDRAM size specified */ -if (get_ram_size (0 , sdram_size) != sdram_size) { -puts ("SDRAM size check failed!\n" ); + ret =uclass_get_device (UCLASS_RAM ,0 , &dev); +if (ret) { +debug ("DRAM init failed: %d\n" , ret);hang (); }
drivers/ddr/altera/Kconfig +2 -0
@@ -1,5 +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 help Enable DDR SDRAM controller for the SoCFPGA devices.
drivers/ddr/altera/sdram_gen5.c +128 -15
238 lines not on this page · raw message
drivers/ddr/altera/sequencer.c +8 -1
@@ -3705,12 +3705,19 @@ static void initialize_tracking(void) &sdr_reg_file->trk_rfsh); } -int sdram_calibration_full (void ) +int sdram_calibration_full (struct socfpga_sdr *sdr) {struct param_type my_param;struct gbl_type my_gbl;u32 pass; +/* +* For size reasons, this file uses hard coded addresses. +* Check if we are called with the correct address. +*/ +if (sdr != (struct socfpga_sdr *)SOCFPGA_SDR_ADDRESS ) +return -ENODEV ; +memset (&my_param,0 ,sizeof (my_param));memset (&my_gbl,0 ,sizeof (my_gbl));
drivers/ddr/altera/sequencer.h +35 -0
@@ -223,4 +223,39 @@ struct socfpga_data_mgr {u32 mem_t_add; u32 t_rl_add; }; + +/* This struct describes the controller @ SOCFPGA_SDR_ADDRESS */ +struct socfpga_sdr { +/* SDR_PHYGRP_SCCGRP_ADDRESS */ +u8 _align1[0xe00 ]; +/* SDR_PHYGRP_SCCGRP_ADDRESS | 0xe00 */ +struct socfpga_sdr_scc_mgr sdr_scc_mgr; +u8 _align2[0x1bc ]; +/* SDR_PHYGRP_PHYMGRGRP_ADDRESS */ +struct socfpga_phy_mgr_cmd phy_mgr_cmd; +u8 _align3[0x2c ]; +/* SDR_PHYGRP_PHYMGRGRP_ADDRESS | 0x40 */ +struct socfpga_phy_mgr_cfg phy_mgr_cfg; +u8 _align4[0xfa0 ]; +/* SDR_PHYGRP_RWMGRGRP_ADDRESS */ +u8 rwmgr_grp[0x800 ]; +/* SDR_PHYGRP_RWMGRGRP_ADDRESS | 0x800 */ +struct socfpga_sdr_rw_load_manager sdr_rw_load_mgr_regs; +u8 _align5[0x3f0 ]; +/* SDR_PHYGRP_RWMGRGRP_ADDRESS | 0xC00 */ +struct socfpga_sdr_rw_load_jump_manager sdr_rw_load_jump_mgr_regs; +u8 _align6[0x13f0 ]; +/* SDR_PHYGRP_DATAMGRGRP_ADDRESS */ +struct socfpga_data_mgr data_mgr; +u8 _align7[0x7f0 ]; +/* SDR_PHYGRP_REGFILEGRP_ADDRESS */ +struct socfpga_sdr_reg_file sdr_reg_file; +u8 _align8[0x7c8 ]; +/* SDR_CTRLGRP_ADDRESS */ +struct socfpga_sdr_ctrl sdr_ctrl; +u8 _align9[0xea4 ]; +}; + +int sdram_calibration_full (struct socfpga_sdr *sdr); +#endif /* _SEQUENCER_H_ */
Signature · 1 line
2.17.1
Marek Vasut
AppliedPATCH v5 1/1 arm: socfpga: move gen5 SDR driver to DM
Quoted 19 lines · Simon Goldschmidt
To clean up reset handling for socfpga gen5, port the DDR driver to DM using
UCLASS_RAMand implement proper reset handling.This gets us rid of one ad-hoc call to
socfpga_per_reset().The gen5 driver is implemented in 2 distinct files. One of it (containing the calibration training) is not touched much and is kept at using hard coded addresses since the code grows even more otherwise.
SPL is changed from calling hard into the DDR driver code to just probing
UCLASS_RESETandUCLASS_RAM. It is happy after finding a RAM driver after that.Signed-off-by Simon Goldschmidt <[email protected]>---
Changes in v5:
- fixKconfigdependencies so that non-gen5 socfpga is fixed
Quoted 8 lines
Changes in v2:
- port DDR driver to DMUCLASS_RAM
- don't change DDR calibration training driver (code got too big)
- usereset.hcode instead ofsocfpga_per_reset()For v5, this is the only patch left with changes (all other patches are OK from v4, but this one needed changes). Being like that, this patch alone isn't applicable but needs all other patches from v4.
Applied, thanks.
Signature · 2 lines
Best regards, Marek Vasut