ddr: marvell: a38x: Add support for DDR4 from Marvell mv-ddr-marvell repository
PATCH 1/1 ddr: marvell: a38x: Add support for DDR4 from Marvell mv-ddr-marvell repository
This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git
up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c
This patch was created by following steps:
1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.
2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files
3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.
After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.
The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c
Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460
---
drivers/ddr/marvell/a38x/Makefile | 8 + drivers/ddr/marvell/a38x/ddr3_debug.c | 120 + drivers/ddr/marvell/a38x/ddr3_init.c | 25 + drivers/ddr/marvell/a38x/ddr3_init.h | 14 + drivers/ddr/marvell/a38x/ddr3_logging_def.h | 29 +- drivers/ddr/marvell/a38x/ddr3_training.c | 135 + drivers/ddr/marvell/a38x/ddr3_training_bist.c | 12 + .../a38x/ddr3_training_centralization.c | 6 + drivers/ddr/marvell/a38x/ddr3_training_db.c | 278 ++ drivers/ddr/marvell/a38x/ddr3_training_ip.h | 17 + .../ddr/marvell/a38x/ddr3_training_ip_db.h | 156 +- .../marvell/a38x/ddr3_training_ip_engine.c | 147 +- .../ddr/marvell/a38x/ddr3_training_ip_flow.h | 7 +- .../ddr/marvell/a38x/ddr3_training_leveling.c | 139 +- drivers/ddr/marvell/a38x/ddr_init.c | 8 + drivers/ddr/marvell/a38x/ddr_mv_wrapper.h | 47 + drivers/ddr/marvell/a38x/dram_if.c | 31 + drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c | 674 +++++ drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h | 59 + drivers/ddr/marvell/a38x/mv_ddr4_training.c | 571 ++++ drivers/ddr/marvell/a38x/mv_ddr4_training.h | 32 + .../a38x/mv_ddr4_training_calibration.c | 2340 +++++++++++++++++ .../a38x/mv_ddr4_training_calibration.h | 26 + .../ddr/marvell/a38x/mv_ddr4_training_db.c | 545 ++++ .../marvell/a38x/mv_ddr4_training_leveling.c | 441 ++++ .../marvell/a38x/mv_ddr4_training_leveling.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_brd.c | 82 + drivers/ddr/marvell/a38x/mv_ddr_init.c | 60 + drivers/ddr/marvell/a38x/mv_ddr_init.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_mrs.c | 248 ++ drivers/ddr/marvell/a38x/mv_ddr_mrs.h | 83 + drivers/ddr/marvell/a38x/mv_ddr_plat.c | 257 ++ drivers/ddr/marvell/a38x/mv_ddr_plat.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_regs.h | 59 + drivers/ddr/marvell/a38x/mv_ddr_static.c | 12 + drivers/ddr/marvell/a38x/mv_ddr_static.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_sys_env_lib.h | 7 + drivers/ddr/marvell/a38x/mv_ddr_topology.h | 72 + 38 files changed, 6786 insertions(+), 5 deletions(-) create mode 100644 drivers/ddr/marvell/a38x/ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/ddr_mv_wrapper.h create mode 100644 drivers/ddr/marvell/a38x/dram_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_brd.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.h
drivers/ddr/marvell/a38x/Makefile +8 -0
@@ -1,7 +1,10 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_SPL_BUILD) += mv_ddr_plat.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr_brd.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr_static.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_sys_env_lib.o +obj-$(CONFIG_SPL_BUILD) += ddr_init.o obj-$(CONFIG_SPL_BUILD) += ddr3_debug.o obj-$(CONFIG_SPL_BUILD) += ddr3_init.o obj-$(CONFIG_SPL_BUILD) += ddr3_training.o
@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.o
drivers/ddr/marvell/a38x/ddr3_debug.c +120 -0
210 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr3_init.c +25 -0
@@ -6,7 +6,11 @@#include "ddr3_init.h" #include "mv_ddr_common.h" +#if defined(CONFIG_DDR4 ) +static char *ddr_type ="DDR4" ; +#else /* CONFIG_DDR4 */ static char *ddr_type ="DDR3" ; +#endif /* CONFIG_DDR4 */ /* * generic_init_controller controls D-unit configuration:
@@ -61,6 +65,13 @@ int ddr3_init(void)mv_ddr_mc_init ();if (!is_manual_cal_done) { +#if defined(CONFIG_DDR4 ) + status =mv_ddr4_calibration_adjust (0 ,1 ,0 ); +if (status !=MV_OK ) { +printf ("%s: failed (0x%x)\n" , __func__, status); +return status; + } +#endif }
@@ -120,6 +131,19 @@ static int mv_ddr_training_params_set(u8 dev_num) params.g_zpodt_ctrl =TUNE_TRAINING_PARAMS_P_ODT_CTRL ; params.g_znodt_ctrl =TUNE_TRAINING_PARAMS_N_ODT_CTRL ; +#if defined(CONFIG_DDR4 ) + params.g_zpodt_data =TUNE_TRAINING_PARAMS_P_ODT_DATA_DDR4 ; + params.g_odt_config =TUNE_TRAINING_PARAMS_ODT_CONFIG_DDR4 ; + params.g_rtt_nom =TUNE_TRAINING_PARAMS_RTT_NOM_DDR4 ; + params.g_dic =TUNE_TRAINING_PARAMS_DIC_DDR4 ; +if (cs_num ==1 ) { + params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_1CS ; + params.g_rtt_park =TUNE_TRAINING_PARAMS_RTT_PARK_1CS ; + }else { + params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_2CS ; + params.g_rtt_park =TUNE_TRAINING_PARAMS_RTT_PARK_2CS ; + } +#else /* CONFIG_DDR4 */ params.g_zpodt_data =TUNE_TRAINING_PARAMS_P_ODT_DATA ; params.g_dic =TUNE_TRAINING_PARAMS_DIC ; params.g_rtt_nom =TUNE_TRAINING_PARAMS_RTT_NOM ;
@@ -130,6 +154,7 @@ static int mv_ddr_training_params_set(u8 dev_num) params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_2CS ; params.g_odt_config = TUNE_TRAINING_PARAMS_ODT_CONFIG_2CS; } +#endif /* CONFIG_DDR4 */ if (ck_delay >0 ) params.ck_delay = ck_delay;
drivers/ddr/marvell/a38x/ddr3_init.h +14 -0
@@ -137,6 +137,10 @@ extern u32 dfs_low_freq;extern u32 nominal_avs;extern u32 extension_avs; +#if defined(CONFIG_DDR4 ) +/* if 1, SSTL & POD have same Vref and workaround is required */ +extern u8 vref_calibration_wa; +#endif /* CONFIG_DDR4 */ /* Prototypes */ int ddr3_init (void );
@@ -152,6 +156,13 @@ void ddr3_new_tip_ecc_scrub(void);int ddr3_tip_reg_write (u32 dev_num,u32 reg_addr,u32 data);int ddr3_tip_reg_read (u32 dev_num,u32 reg_addr,u32 *data,u32 reg_mask);int ddr3_silicon_get_ddr_target_freq (u32 *ddr_freq); +#if defined(CONFIG_DDR4 ) +int mv_ddr4_mode_regs_init (u8 dev_num); +int mv_ddr4_sdram_config (u32 dev_num); +int mv_ddr4_phy_config (u32 dev_num); +int mv_ddr4_calibration_adjust (u32 dev_num,u8 vref_en,u8 pod_only); +int mv_ddr4_training_main_flow (u32 dev_num); +#endif /* CONFIG_DDR4 */ int print_adll (u32 dev_num,u32 adll[MAX_INTERFACE_NUM *MAX_BUS_NUM ]);int print_ph (u32 dev_num,u32 adll[MAX_INTERFACE_NUM *MAX_BUS_NUM ]);
@@ -188,5 +199,8 @@ unsigned int mv_ddr_misl_phy_drv_ctrl_p_get(void);unsigned int mv_ddr_misl_phy_drv_ctrl_n_get (void );unsigned int mv_ddr_misl_phy_odt_p_get (void );unsigned int mv_ddr_misl_phy_odt_n_get (void ); +#if defined(CONFIG_DDR4 ) +void refresh (void ); +#endif #endif /* _DDR3_INIT_H */
drivers/ddr/marvell/a38x/ddr3_logging_def.h +28 -1
@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) Marvell International Ltd. and its affiliates */
@@ -73,6 +73,27 @@#endif #endif +#ifdef CONFIG_DDR4 +#ifdef SILENT_LIB +#define DEBUG_TAP_TUNING_ENGINE (level, s) +#define DEBUG_CALIBRATION (level, s) +#define DEBUG_DDR4_CENTRALIZATION (level, s) +#define DEBUG_DM_TUNING (level, s) +#else /* SILENT_LIB */ +#define DEBUG_TAP_TUNING_ENGINE (level, s) \ + if (level >= debug_tap_tuning) \ + printf s +#define DEBUG_CALIBRATION (level, s) \ + if (level >= debug_calibration) \ + printf s +#define DEBUG_DDR4_CENTRALIZATION (level, s) \ + if (level >= debug_ddr4_centralization) \ + printf s +#define DEBUG_DM_TUNING (level, s) \ + if (level >= debug_dm_tuning) \ + printf s +#endif /* SILENT_LIB */ +#endif /* CONFIG_DDR4 */ /* Logging defines */ enum mv_ddr_debug_level {
@@ -94,6 +115,12 @@ enum ddr_lib_debug_block { DEBUG_BLOCK_DEVICE,DEBUG_BLOCK_ACCESS ,DEBUG_STAGES_REG_DUMP , +#if defined(CONFIG_DDR4) +DEBUG_TAP_TUNING_ENGINE , +DEBUG_BLOCK_CALIBRATION , +DEBUG_BLOCK_DDR4_CENTRALIZATION , +DEBUG_DM_TUNING , +#endif /* CONFIG_DDR4 *//* All excluding IP and REG_DUMP, should be enabled separatelly */ DEBUG_BLOCK_ALL };
drivers/ddr/marvell/a38x/ddr3_training.c +135 -0
255 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr3_training_bist.c +12 -0
@@ -459,7 +459,11 @@ static int mv_ddr_odpg_bist_prepare(enum hws_pattern pattern, enum hws_access_ty (ODPG_WRBUF_RD_CTRL_DIS <<ODPG_WRBUF_RD_CTRL_OFFS ), (ODPG_WRBUF_RD_CTRL_MASK << ODPG_WRBUF_RD_CTRL_OFFS)); +#if defined(CONFIG_DDR4 ) +if (pattern ==PATTERN_ZERO || pattern ==PATTERN_ONE ) +#else if (pattern == PATTERN_00 || pattern == PATTERN_FF) +#endif ddr3_tip_load_pattern_to_odpg (0 , access_type,0 , pattern, offset); elsemv_ddr_load_dm_pattern_to_odpg (access_type ,pattern ,dm_dir );
@@ -507,7 +511,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,ODPG_DATA_CTRL_REG ,0 ,MASK_ALL_BITS );mv_ddr_odpg_bist_prepare (pattern,ACCESS_TYPE_UNICAST ,OPER_WRITE ,STRESS_NONE ,DURATION_SINGLE , bist_offset, cs, pattern_table[pattern].num_of_phases_tx, +#if defined(CONFIG_DDR4) + (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#else (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#endif for (adll_tap =0 ; adll_tap <ADLL_TAPS_PER_PERIOD ; adll_tap++) {/* change target odpg address */
@@ -539,7 +547,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)/* fill memory with vref pattern to increment addr using odpg bist */ mv_ddr_odpg_bist_prepare (PATTERN_VREF ,ACCESS_TYPE_UNICAST ,OPER_WRITE ,STRESS_NONE ,DURATION_SINGLE , bist_offset, cs, pattern_table[pattern].num_of_phases_tx, +#if defined(CONFIG_DDR4) + (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#else (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#endif for (adll_tap =0 ; adll_tap <ADLL_TAPS_PER_PERIOD ; adll_tap++) { ddr3_tip_bus_write(0, ACCESS_TYPE_UNICAST, 0, ACCESS_TYPE_MULTICAST, 0,
drivers/ddr/marvell/a38x/ddr3_training_centralization.c +6 -0
@@ -16,7 +16,13 @@#define CENTRAL_RX 1#define NUM_OF_CENTRAL_TYPES 2 +#if defined(CONFIG_64BIT )/* DDR3/4 64-bit */ +u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7_INV_64 ; +#elif defined(CONFIG_DDR4 )/* DDR4 16/32-bit */ +u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7_INV ; +#else /* DDR3 16/32-bit */ u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7 ; +#endif /* CONFIG_64BIT */ u32 start_if =0 , end_if = (MAX_INTERFACE_NUM -1 );u8 bus_end_window[NUM_OF_CENTRAL_TYPES ][MAX_INTERFACE_NUM ][MAX_BUS_NUM ];
drivers/ddr/marvell/a38x/ddr3_training_db.c +278 -0
422 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr3_training_ip.h +17 -0
@@ -42,6 +42,13 @@#define WRITE_LEVELING_LF_MASK_BIT 0x02000000/* DDR4 Specific Training Mask bits */ +#if defined (CONFIG_DDR4 ) +#define RECEIVER_CALIBRATION_MASK_BIT 0x04000000 +#define WL_PHASE_CORRECTION_MASK_BIT 0x08000000 +#define DQ_VREF_CALIBRATION_MASK_BIT 0x10000000 +#define DQ_MAPPING_MASK_BIT 0x20000000 +#define DM_TUNING_MASK_BIT 0x40000000 +#endif /* CONFIG_DDR4 */ enum hws_result {TEST_FAILED =0 ,
@@ -63,6 +70,9 @@ enum auto_tune_stage { WRITE_LEVELING, LOAD_PATTERN_2, READ_LEVELING, +#if defined(CONFIG_DDR4 ) +SW_READ_LEVELING , +#endif /* CONFIG_DDR4 */WRITE_LEVELING_SUPP ,PBS_RX , PBS_TX,
@@ -78,6 +88,13 @@ enum auto_tune_stage { TX_EMPHASIS,LOAD_PATTERN_HIGH ,PER_BIT_READ_LEVELING_TF , +#if defined(CONFIG_DDR4) +RECEIVER_CALIBRATION , +WL_PHASE_CORRECTION , +DQ_VREF_CALIBRATION , +DM_TUNING , +DQ_MAPPING , +#endif /* CONFIG_DDR4 */WRITE_LEVELING_LF ,MAX_STAGE_LIMIT };
drivers/ddr/marvell/a38x/ddr3_training_ip_db.h +155 -1
171 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr3_training_ip_engine.c +146 -1
181 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr3_training_ip_flow.h +6 -1
@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) Marvell International Ltd. and its affiliates */
@@ -46,6 +46,11 @@ enum mr_number { MR_CMD1, MR_CMD2, MR_CMD3, +#if defined(CONFIG_DDR4 ) +MR_CMD4 , +MR_CMD5 , +MR_CMD6 , +#endifMR_LAST };
drivers/ddr/marvell/a38x/ddr3_training_leveling.c +138 -1
174 lines not on this page · raw message
drivers/ddr/marvell/a38x/ddr_init.c new file +8 -0
@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr3_init.h" + +/* U-BOOT MARVELL 2013.01 SUPPORT */
drivers/ddr/marvell/a38x/ddr_mv_wrapper.h new file +47 -0
47 lines not on this page · raw message
drivers/ddr/marvell/a38x/dram_if.c new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr_ml_wrapper.h" + +#include "mv_ddr_init.h" +#include "mv_ddr_plat.h" +#include "mv_ddr_topology.h" + +int dram_init (void ) +{ +return mv_ddr_init (); +} + +void dram_mmap_config (void ) +{ +mv_ddr_mmap_config (); +} + +unsigned long long dram_iface_mem_sz_get (void ) +{ +/* +* call mv_ddr_pre_config to update topology +* prior to mv_ddr_mem_sz_get call +*/ +mv_ddr_pre_config (); + +return mv_ddr_mem_sz_get (); +}
drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c new file +674 -0
674 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h new file +59 -0
59 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_training.c new file +571 -0
527 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_training.h new file +32 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c new file +2340 -0
2,340 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h new file +26 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_db.c new file +545 -0
545 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c new file +441 -0
441 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h new file +11 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_brd.c new file +82 -0
82 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_init.c new file +60 -0
60 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_init.h new file +11 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_mrs.c new file +248 -0
248 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_mrs.h new file +83 -0
83 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_plat.c +257 -0
257 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_plat.h +11 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_regs.h +59 -0
59 lines not on this page · raw message
drivers/ddr/marvell/a38x/mv_ddr_static.c new file +12 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_static.h new file +11 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_sys_env_lib.h +7 -0
Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_topology.h +72 -0
72 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.2
Part of the diff is not shown here. View the raw message.
All,
I should have mentioned in the patch description that the board test was done with the Thecus N2350 (Armada 385, 1GB DDR4) and also a regression test was done with Synology DS116 (Armada 385, 1GB DDR3).
Thanks,
Tony
Quoted 7,960 lines · Tony Dinh
This syncs
drivers/ddr/marvell/a38x/with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.gitup to the commit "
mv_ddr: a3700: Use the right size for memset to not overflow"d5acc10c287e40cc2feeb28710b92e45c93c702cThis patch was created by following steps:
1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.
2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:
files=drivers/ddr/marvell/a38x/*
sed 's/#ifdefined(CONFIG_ARMADA_38X)|| defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.
After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.
The only change in this patch are:
- Removal of commonboard_topology_mapcode using ifdefs inmv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) inmv_ddr_plat.cReference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460Signed-off-by Tony Dinh <[email protected]>---
drivers/ddr/marvell/a38x/Makefile | 8 + drivers/ddr/marvell/a38x/ddr3_debug.c | 120 + drivers/ddr/marvell/a38x/ddr3_init.c | 25 + drivers/ddr/marvell/a38x/ddr3_init.h | 14 + drivers/ddr/marvell/a38x/ddr3_logging_def.h | 29 +- drivers/ddr/marvell/a38x/ddr3_training.c | 135 + drivers/ddr/marvell/a38x/ddr3_training_bist.c | 12 + .../a38x/ddr3_training_centralization.c | 6 + drivers/ddr/marvell/a38x/ddr3_training_db.c | 278 ++ drivers/ddr/marvell/a38x/ddr3_training_ip.h | 17 + .../ddr/marvell/a38x/ddr3_training_ip_db.h | 156 +- .../marvell/a38x/ddr3_training_ip_engine.c | 147 +- .../ddr/marvell/a38x/ddr3_training_ip_flow.h | 7 +- .../ddr/marvell/a38x/ddr3_training_leveling.c | 139 +- drivers/ddr/marvell/a38x/ddr_init.c | 8 + drivers/ddr/marvell/a38x/ddr_mv_wrapper.h | 47 + drivers/ddr/marvell/a38x/dram_if.c | 31 + drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c | 674 +++++ drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h | 59 + drivers/ddr/marvell/a38x/mv_ddr4_training.c | 571 ++++ drivers/ddr/marvell/a38x/mv_ddr4_training.h | 32 + .../a38x/mv_ddr4_training_calibration.c | 2340 +++++++++++++++++ .../a38x/mv_ddr4_training_calibration.h | 26 + .../ddr/marvell/a38x/mv_ddr4_training_db.c | 545 ++++ .../marvell/a38x/mv_ddr4_training_leveling.c | 441 ++++ .../marvell/a38x/mv_ddr4_training_leveling.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_brd.c | 82 + drivers/ddr/marvell/a38x/mv_ddr_init.c | 60 + drivers/ddr/marvell/a38x/mv_ddr_init.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_mrs.c | 248 ++ drivers/ddr/marvell/a38x/mv_ddr_mrs.h | 83 + drivers/ddr/marvell/a38x/mv_ddr_plat.c | 257 ++ drivers/ddr/marvell/a38x/mv_ddr_plat.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_regs.h | 59 + drivers/ddr/marvell/a38x/mv_ddr_static.c | 12 + drivers/ddr/marvell/a38x/mv_ddr_static.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_sys_env_lib.h | 7 + drivers/ddr/marvell/a38x/mv_ddr_topology.h | 72 + 38 files changed, 6786 insertions(+), 5 deletions(-) create mode 100644 drivers/ddr/marvell/a38x/ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/ddr_mv_wrapper.h create mode 100644 drivers/ddr/marvell/a38x/dram_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_brd.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.hdrivers/ddr/marvell/a38x/Makefile +8
-0@@ -1,7 +1,10 @@ # SPDX-License-Identifier: GPL-2.0+ obj-$(CONFIG_SPL_BUILD) += mv_ddr_plat.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr_brd.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr_static.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_sys_env_lib.o +obj-$(CONFIG_SPL_BUILD) += ddr_init.o obj-$(CONFIG_SPL_BUILD) += ddr3_debug.o obj-$(CONFIG_SPL_BUILD) += ddr3_init.o obj-$(CONFIG_SPL_BUILD) += ddr3_training.o@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.odrivers/ddr/marvell/a38x/ddr3_debug.c +120
-0@@ -30,6 +30,12 @@ u8 debug_training_hw_alg = DEBUG_LEVEL_ERROR;u8 debug_training_access =DEBUG_LEVEL_ERROR ;u8 debug_training_device =DEBUG_LEVEL_ERROR ; +#if defined(CONFIG_DDR4 ) +u8 debug_tap_tuning =DEBUG_LEVEL_ERROR ; +u8 debug_calibration =DEBUG_LEVEL_ERROR ; +u8 debug_ddr4_centralization =DEBUG_LEVEL_ERROR ; +u8 debug_dm_tuning =DEBUG_LEVEL_ERROR ; +#endif /* CONFIG_DDR4 */ void mv_ddr_user_log_level_set (enum ddr_lib_debug_block block) {@@ -70,6 +76,17 @@ void ddr3_hws_set_log_level(enum ddr_lib_debug_block block, u8 level)else is_reg_dump =0 ;break ; +#if defined(CONFIG_DDR4 ) +case DEBUG_TAP_TUNING_ENGINE : + debug_tap_tuning = level; +break ; +case DEBUG_BLOCK_CALIBRATION : + debug_calibration = level; +break ; +case DEBUG_BLOCK_DDR4_CENTRALIZATION : + debug_ddr4_centralization = level; +break ; +#endif /* CONFIG_DDR4 */ case DEBUG_BLOCK_ALL :default : debug_training_static = level;@@ -80,6 +97,11 @@ void ddr3_hws_set_log_level(enum ddr_lib_debug_block block, u8 level) debug_training_hw_alg = level; debug_training_access = level; debug_training_device = level; +#if defined(CONFIG_DDR4 ) + debug_tap_tuning = level; + debug_calibration = level; + debug_ddr4_centralization = level; +#endif /* CONFIG_DDR4 */ } }#endif /* SILENT_LIB */ @@ -209,11 +231,13 @@ static char *convert_freq(enum mv_ddr_freq freq)case MV_DDR_FREQ_LOW_FREQ :return "MV_DDR_FREQ_LOW_FREQ" ; +#if !defined(CONFIG_DDR4 )case MV_DDR_FREQ_400 :return "400" ;case MV_DDR_FREQ_533 :return "533" ; +#endif /* CONFIG_DDR4 */ case MV_DDR_FREQ_667 :return "667" ;@@ -227,6 +251,7 @@ static char *convert_freq(enum mv_ddr_freq freq)case MV_DDR_FREQ_1066 :return "1066" ; +#if !defined(CONFIG_DDR4 )case MV_DDR_FREQ_311 :return "311" ;@@ -247,6 +272,7 @@ static char *convert_freq(enum mv_ddr_freq freq)case MV_DDR_FREQ_1000 :return "MV_DDR_FREQ_1000" ; +#endif /* CONFIG_DDR4 */ default :return "Unknown Frequency" ;@@ -463,6 +489,7 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr) (training_result[WRITE_LEVELING_TF ] [if_id]))); } +#if !defined(CONFIG_DDR4 )if (mask_tune_func &READ_LEVELING_TF_MASK_BIT ) { DEBUG_TRAINING_IP(DEBUG_LEVEL_INFO, ("\tRL TF: %s\n",@@ -470,6 +497,7 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr) (training_result[READ_LEVELING_TF ] [if_id]))); } +#endif /* CONFIG_DDR4 */ if (mask_tune_func &WRITE_LEVELING_SUPP_TF_MASK_BIT ) { DEBUG_TRAINING_IP(DEBUG_LEVEL_INFO, ("\tWL TF Supp: %s\n",@@ -499,6 +527,43 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr) (training_result[CENTRALIZATION_TX ] [if_id]))); } +#if defined(CONFIG_DDR4 ) +if (mask_tune_func &SW_READ_LEVELING_MASK_BIT ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("\tSW RL TF: %s\n" , +ddr3_tip_convert_tune_result + (training_result[SW_READ_LEVELING ] + [if_id]))); + } +if (mask_tune_func &RECEIVER_CALIBRATION_MASK_BIT ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("\tRX CAL: %s\n" , +ddr3_tip_convert_tune_result + (training_result[RECEIVER_CALIBRATION ] + [if_id]))); + } +if (mask_tune_func &WL_PHASE_CORRECTION_MASK_BIT ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("\tWL PHASE CORRECT: %s\n" , +ddr3_tip_convert_tune_result + (training_result[WL_PHASE_CORRECTION ] + [if_id]))); + } +if (mask_tune_func &DQ_VREF_CALIBRATION_MASK_BIT ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("\tDQ VREF CAL: %s\n" , +ddr3_tip_convert_tune_result + (training_result[DQ_VREF_CALIBRATION ] + [if_id]))); + } +if (mask_tune_func &DQ_MAPPING_MASK_BIT ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("\tDQ MAP: %s\n" , +ddr3_tip_convert_tune_result + (training_result[DQ_MAPPING ] + [if_id]))); + } +#endif /* CONFIG_DDR4 */ }return MV_OK ;@@ -512,6 +577,9 @@ int ddr3_tip_print_stability_log(u32 dev_num) {u8 if_id =0 , csindex =0 , bus_id =0 , idx =0 ;u32 reg_data; +#if defined(CONFIG_DDR4 ) +u32 reg_data1; +#endif /* CONFIG_DDR4 */ u32 read_data[MAX_INTERFACE_NUM ];unsigned int max_cs =mv_ddr_cs_num_get ();struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get ();@@ -524,7 +592,13 @@ int ddr3_tip_print_stability_log(u32 dev_num)printf ("CS%d , " , csindex);printf ("\n" );VALIDATE_BUS_ACTIVE (tm->bus_act_mask, bus_id); +#if defined(CONFIG_DDR4 ) +printf ("DminTx, AreaTx, DminRx, AreaRx, WL_tot, WL_ADLL, WL_PH, RL_Tot, RL_ADLL, RL_PH, RL_Smp, CenTx, CenRx, Vref, DQVref," ); +for (idx =0 ; idx <11 ; idx++) +printf ("DC-Pad%d," , idx); +#else /* CONFIG_DDR4 */ printf ("VWTx, VWRx, WL_tot, WL_ADLL, WL_PH, RL_Tot, RL_ADLL, RL_PH, RL_Smp, Cen_tx, Cen_rx, Vref, DQVref," ); +#endif /* CONFIG_DDR4 */ printf ("\t\t" );for (idx =0 ; idx <11 ; idx++)printf ("PBSTx-Pad%d," , idx);@@ -565,6 +639,40 @@ int ddr3_tip_print_stability_log(u32 dev_num)for (bus_id =0 ; bus_id <MAX_BUS_NUM ; bus_id++) {printf ("\n" );VALIDATE_BUS_ACTIVE (tm->bus_act_mask, bus_id); +#if defined(CONFIG_DDR4 ) +/* DminTx, areaTX */ +ddr3_tip_bus_read (dev_num, if_id, +ACCESS_TYPE_UNICAST , + bus_id,DDR_PHY_DATA , +RESULT_PHY_REG + + csindex, ®_data); +ddr3_tip_bus_read (dev_num, if_id, +ACCESS_TYPE_UNICAST , + dmin_phy_reg_table + [csindex *5 + bus_id][0 ], +DDR_PHY_CONTROL , + dmin_phy_reg_table + [csindex *5 + bus_id][1 ], + ®_data1); +printf ("%d,%d," ,2 * (reg_data1 &0xFF ), + reg_data); +/* DminRx, areaRX */ +ddr3_tip_bus_read (dev_num, if_id, +ACCESS_TYPE_UNICAST , + bus_id,DDR_PHY_DATA , +RESULT_PHY_REG + + csindex +4 , ®_data); +ddr3_tip_bus_read (dev_num, if_id, +ACCESS_TYPE_UNICAST , + dmin_phy_reg_table + [csindex *5 + bus_id][0 ], +DDR_PHY_CONTROL , + dmin_phy_reg_table + [csindex *5 + bus_id][1 ], + ®_data1); +printf ("%d,%d," ,2 * (reg_data1 >>8 ), + reg_data); +#else /* CONFIG_DDR4 */ ddr3_tip_bus_read(dev_num, if_id, ACCESS_TYPE_UNICAST, bus_id, DDR_PHY_DATA,@@ -572,6 +680,7 @@ int ddr3_tip_print_stability_log(u32 dev_num) csindex, ®_data);printf ("%d,%d," , (reg_data &0x1f ), ((reg_data &0x3e0 ) >>5 )); +#endif /* CONFIG_DDR4 */ /* WL */ ddr3_tip_bus_read(dev_num, if_id, ACCESS_TYPE_UNICAST,@@ -628,6 +737,17 @@ int ddr3_tip_print_stability_log(u32 dev_num)/* DQVref */ /* Need to add the Read Function from device */ printf ("%d," ,0 ); +#if defined(CONFIG_DDR4 ) +printf ("\t\t" ); +for (idx =0 ; idx <11 ; idx++) { +ddr3_tip_bus_read (dev_num, if_id, +ACCESS_TYPE_UNICAST , + bus_id,DDR_PHY_DATA , +0xd0 +12 * csindex + + idx, ®_data); +printf ("%d," , (reg_data &0x3f )); + } +#endif /* CONFIG_DDR4 */ printf ("\t\t" );for (idx =0 ; idx <11 ; idx++) { ddr3_tip_bus_read(dev_num, if_id,drivers/ddr/marvell/a38x/ddr3_init.c +25
-0@@ -6,7 +6,11 @@#include "ddr3_init.h" #include "mv_ddr_common.h" +#if defined(CONFIG_DDR4 ) +static char *ddr_type ="DDR4" ; +#else /* CONFIG_DDR4 */ static char *ddr_type ="DDR3" ; +#endif /* CONFIG_DDR4 */ /* * generic_init_controller controls D-unit configuration: @@ -61,6 +65,13 @@ int ddr3_init(void)mv_ddr_mc_init ();if (!is_manual_cal_done) { +#if defined(CONFIG_DDR4 ) + status =mv_ddr4_calibration_adjust (0 ,1 ,0 ); +if (status !=MV_OK ) { +printf ("%s: failed (0x%x)\n" , __func__, status); +return status; + } +#endif }@@ -120,6 +131,19 @@ static int mv_ddr_training_params_set(u8 dev_num) params.g_zpodt_ctrl =TUNE_TRAINING_PARAMS_P_ODT_CTRL ; params.g_znodt_ctrl =TUNE_TRAINING_PARAMS_N_ODT_CTRL ; +#if defined(CONFIG_DDR4 ) + params.g_zpodt_data =TUNE_TRAINING_PARAMS_P_ODT_DATA_DDR4 ; + params.g_odt_config =TUNE_TRAINING_PARAMS_ODT_CONFIG_DDR4 ; + params.g_rtt_nom =TUNE_TRAINING_PARAMS_RTT_NOM_DDR4 ; + params.g_dic =TUNE_TRAINING_PARAMS_DIC_DDR4 ; +if (cs_num ==1 ) { + params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_1CS ; + params.g_rtt_park =TUNE_TRAINING_PARAMS_RTT_PARK_1CS ; + }else { + params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_2CS ; + params.g_rtt_park =TUNE_TRAINING_PARAMS_RTT_PARK_2CS ; + } +#else /* CONFIG_DDR4 */ params.g_zpodt_data =TUNE_TRAINING_PARAMS_P_ODT_DATA ; params.g_dic =TUNE_TRAINING_PARAMS_DIC ; params.g_rtt_nom =TUNE_TRAINING_PARAMS_RTT_NOM ;@@ -130,6 +154,7 @@ static int mv_ddr_training_params_set(u8 dev_num) params.g_rtt_wr =TUNE_TRAINING_PARAMS_RTT_WR_2CS ; params.g_odt_config = TUNE_TRAINING_PARAMS_ODT_CONFIG_2CS; } +#endif /* CONFIG_DDR4 */ if (ck_delay >0 ) params.ck_delay = ck_delay;drivers/ddr/marvell/a38x/ddr3_init.h +14
-0@@ -137,6 +137,10 @@ extern u32 dfs_low_freq;extern u32 nominal_avs;extern u32 extension_avs; +#if defined(CONFIG_DDR4 ) +/* if 1, SSTL & POD have same Vref and workaround is required */ +extern u8 vref_calibration_wa; +#endif /* CONFIG_DDR4 */ /* Prototypes */ int ddr3_init (void );@@ -152,6 +156,13 @@ void ddr3_new_tip_ecc_scrub(void);int ddr3_tip_reg_write (u32 dev_num,u32 reg_addr,u32 data);int ddr3_tip_reg_read (u32 dev_num,u32 reg_addr,u32 *data,u32 reg_mask);int ddr3_silicon_get_ddr_target_freq (u32 *ddr_freq); +#if defined(CONFIG_DDR4 ) +int mv_ddr4_mode_regs_init (u8 dev_num); +int mv_ddr4_sdram_config (u32 dev_num); +int mv_ddr4_phy_config (u32 dev_num); +int mv_ddr4_calibration_adjust (u32 dev_num,u8 vref_en,u8 pod_only); +int mv_ddr4_training_main_flow (u32 dev_num); +#endif /* CONFIG_DDR4 */ int print_adll (u32 dev_num,u32 adll[MAX_INTERFACE_NUM *MAX_BUS_NUM ]);int print_ph (u32 dev_num,u32 adll[MAX_INTERFACE_NUM *MAX_BUS_NUM ]);@@ -188,5 +199,8 @@ unsigned int mv_ddr_misl_phy_drv_ctrl_p_get(void);unsigned int mv_ddr_misl_phy_drv_ctrl_n_get (void );unsigned int mv_ddr_misl_phy_odt_p_get (void );unsigned int mv_ddr_misl_phy_odt_n_get (void ); +#if defined(CONFIG_DDR4 ) +void refresh (void ); +#endif #endif /* _DDR3_INIT_H */ drivers/ddr/marvell/a38x/ddr3_logging_def.h +28
-1@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) Marvell International Ltd. and its affiliates */ @@ -73,6 +73,27 @@#endif #endif +#ifdef CONFIG_DDR4 +#ifdef SILENT_LIB +#define DEBUG_TAP_TUNING_ENGINE (level, s) +#define DEBUG_CALIBRATION (level, s) +#define DEBUG_DDR4_CENTRALIZATION (level, s) +#define DEBUG_DM_TUNING (level, s) +#else /* SILENT_LIB */ +#define DEBUG_TAP_TUNING_ENGINE (level, s) \ + if (level >= debug_tap_tuning) \ + printf s +#define DEBUG_CALIBRATION (level, s) \ + if (level >= debug_calibration) \ + printf s +#define DEBUG_DDR4_CENTRALIZATION (level, s) \ + if (level >= debug_ddr4_centralization) \ + printf s +#define DEBUG_DM_TUNING (level, s) \ + if (level >= debug_dm_tuning) \ + printf s +#endif /* SILENT_LIB */ +#endif /* CONFIG_DDR4 */ /* Logging defines */ enum mv_ddr_debug_level {@@ -94,6 +115,12 @@ enum ddr_lib_debug_block { DEBUG_BLOCK_DEVICE,DEBUG_BLOCK_ACCESS ,DEBUG_STAGES_REG_DUMP , +#if defined(CONFIG_DDR4) +DEBUG_TAP_TUNING_ENGINE , +DEBUG_BLOCK_CALIBRATION , +DEBUG_BLOCK_DDR4_CENTRALIZATION , +DEBUG_DM_TUNING , +#endif /* CONFIG_DDR4 *//* All excluding IP and REG_DUMP, should be enabled separatelly */ DEBUG_BLOCK_ALL };drivers/ddr/marvell/a38x/ddr3_training.c +135
-0@@ -25,7 +25,11 @@ u32 *dq_map_table = NULL;/* in case of ddr4 do not run ddr3_tip_write_additional_odt_setting function - mc odt always 'on' * in ddr4 case the terminations are rttWR and rttPARK and the odt must be always 'on' 0x1498 = 0xf */ +#if defined(CONFIG_DDR4 ) +u32 odt_config =0 ; +#else u32 odt_config =1 ; +#endif u32 nominal_avs;u32 extension_avs;@@ -85,7 +89,11 @@ u32 mask_tune_func = (SET_MEDIUM_FREQ_MASK_BIT | READ_LEVELING_MASK_BIT | SET_TARGET_FREQ_MASK_BIT | WRITE_LEVELING_TF_MASK_BIT | +#if defined(CONFIG_DDR4 ) +SW_READ_LEVELING_MASK_BIT | +#else /* CONFIG_DDR4 */READ_LEVELING_TF_MASK_BIT | +#endif /* CONFIG_DDR4 */CENTRALIZATION_RX_MASK_BIT | CENTRALIZATION_TX_MASK_BIT);@@ -102,6 +110,10 @@ int adll_calibration(u32 dev_num, enum hws_access_type access_type, u32 if_id, enum mv_ddr_freq frequency);static int ddr3_tip_set_timing (u32 dev_num,enum hws_access_type access_type,u32 if_id,enum mv_ddr_freq frequency); +#if defined(CONFIG_DDR4 ) +static int ddr4_tip_set_timing (u32 dev_num,enum hws_access_type access_type, +u32 if_id,enum mv_ddr_freq frequency); +#endif /* CONFIG_DDR4 */ static u8 mem_size_config[MV_DDR_DIE_CAP_LAST ] = {0x2 ,/* 512Mbit */ @@ -173,12 +185,24 @@ static struct reg_data odpg_default_value[] = { };/* MR cmd and addr definitions */ +#if defined(CONFIG_DDR4 ) +struct mv_ddr_mr_data mr_data[] = { + {MRS0_CMD ,DDR4_MR0_REG }, + {MRS1_CMD ,DDR4_MR1_REG }, + {MRS2_CMD ,DDR4_MR2_REG }, + {MRS3_CMD ,DDR4_MR3_REG }, + {MRS4_CMD ,DDR4_MR4_REG }, + {MRS5_CMD ,DDR4_MR5_REG }, + {MRS6_CMD ,DDR4_MR6_REG } +}; +#else struct mv_ddr_mr_data mr_data[] = { {MRS0_CMD ,MR0_REG }, {MRS1_CMD ,MR1_REG }, {MRS2_CMD ,MR2_REG }, {MRS3_CMD ,MR3_REG } }; +#endif /* inverse pads */ static int ddr3_tip_pad_inv (void )@@ -664,6 +688,11 @@ int hws_ddr3_tip_init_controller(u32 dev_num, struct init_cntr_param *init_cntr_ calibration_update_control << 3, 0x3 << 3)); } +#if defined(CONFIG_DDR4 ) +/* dev_num, vref_en, pod_only */ +CHECK_STATUS (mv_ddr4_mode_regs_init (dev_num)); +CHECK_STATUS (mv_ddr4_sdram_config (dev_num)); +#endif /* CONFIG_DDR4 */ if (delay_enable !=0 ) { adll_tap =MEGA / (mv_ddr_freq_get (freq) *64 );@@ -1325,6 +1354,20 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type access_type,/* disable ODT in case of dll off */ if (is_dll_off ==1 ) { +#if defined(CONFIG_DDR4 ) +CHECK_STATUS (ddr3_tip_if_read + (dev_num, access_type,PARAM_NOT_CARE , +0x1974 , &g_rtt_nom_cs0,MASK_ALL_BITS )); +CHECK_STATUS (ddr3_tip_if_write + (dev_num, access_type, if_id, +0x1974 ,0 , (0x7 <<8 ))); +CHECK_STATUS (ddr3_tip_if_read + (dev_num, access_type,PARAM_NOT_CARE , +0x1A74 , &g_rtt_nom_cs1,MASK_ALL_BITS )); +CHECK_STATUS (ddr3_tip_if_write + (dev_num, access_type, if_id, +0x1A74 ,0 , (0x7 <<8 ))); +#else /* CONFIG_DDR4 */ CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id,0x1874 ,0 ,0x244 ));@@ -1337,6 +1380,7 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type access_type,CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id,0x18a4 ,0 ,0x244 )); +#endif /* CONFIG_DDR4 */ }/* DFS - Enter Self-Refresh */ @@ -1404,6 +1448,16 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type access_type,/* Restore original RTT values if returning from DLL OFF mode */ if (is_dll_off ==1 ) { +#if defined(CONFIG_DDR4 ) +CHECK_STATUS (ddr3_tip_if_write + (dev_num, access_type, if_id, +0x1974 , g_rtt_nom_cs0, (0x7 <<8 ))); +CHECK_STATUS (ddr3_tip_if_write + (dev_num, access_type, if_id, +0x1A74 , g_rtt_nom_cs1, (0x7 <<8 ))); + +mv_ddr4_mode_regs_init (dev_num); +#else /* CONFIG_DDR4 */ CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id,0x1874 , g_dic | g_rtt_nom,0x266 ));@@ -1416,6 +1470,7 @@ int ddr3_tip_freq_set(u32 dev_num, enum hws_access_type access_type,CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id,0x18a4 , g_dic | g_rtt_nom,0x266 )); +#endif /* CONFIG_DDR4 */ }/* Reset divider_b assert -> de-assert */ @@ -1669,8 +1724,13 @@ static int ddr3_tip_set_timing(u32 dev_num, enum hws_access_type access_type, t_rtp =GET_MAX_VALUE (t_ckclk *4 ,mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TRTP )); t_mod =GET_MAX_VALUE (t_ckclk *12 ,15000 ); +#if defined(CONFIG_DDR4 ) + t_wtr =GET_MAX_VALUE (t_ckclk *2 ,mv_ddr_speed_bin_timing_get (speed_bin_index, +SPEED_BIN_TWTR )); +#else /* CONFIG_DDR4 */ t_wtr =GET_MAX_VALUE (t_ckclk *4 ,mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TWTR )); +#endif /* CONFIG_DDR4 */ t_ras =time_to_nclk (mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TRAS ), t_ckclk);@@ -1758,10 +1818,74 @@ static int ddr3_tip_set_timing(u32 dev_num, enum hws_access_type access_type,DDR_TIMING_TPD_MASK <<DDR_TIMING_TPD_OFFS | DDR_TIMING_TXPDLL_MASK << DDR_TIMING_TXPDLL_OFFS)); +#if defined(CONFIG_DDR4 ) +ddr4_tip_set_timing (dev_num, access_type, if_id, frequency); +#endif /* CONFIG_DDR4 */ return MV_OK ; } +#if defined(CONFIG_DDR4 ) +static int ddr4_tip_set_timing (u32 dev_num,enum hws_access_type access_type, +u32 if_id,enum mv_ddr_freq frequency) +{ +u32 t_rrd_l =0 , t_wtr_l =0 , t_ckclk =0 , t_mod =0 , t_ccd =0 ; +u32 page_size =0 , val =0 , mask =0 ; +enum mv_ddr_speed_bin speed_bin_index; +enum mv_ddr_die_capacity memory_size; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +u32 freq =mv_ddr_freq_get (frequency); + + speed_bin_index = tm->interface_params[if_id].speed_bin_index; + memory_size = tm->interface_params[if_id].memory_size; + page_size =mv_ddr_page_size_get (tm->interface_params[if_id].bus_width, memory_size); + + t_ckclk = (MEGA / freq); + + t_rrd_l = (page_size ==1 ) ?mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TRRDL1K ) : +mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TRRDL2K ); + t_rrd_l =GET_MAX_VALUE (t_ckclk *4 , t_rrd_l); + + t_wtr_l =mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TWTRL ); + t_wtr_l =GET_MAX_VALUE (t_ckclk *4 , t_wtr_l); + + t_rrd_l =time_to_nclk (t_rrd_l, t_ckclk); + t_wtr_l =time_to_nclk (t_wtr_l, t_ckclk); + + val = (((t_rrd_l -1 ) &DDR4_TRRD_L_MASK ) <<DDR4_TRRD_L_OFFS ) | + (((t_wtr_l -1 ) &DDR4_TWTR_L_MASK ) <<DDR4_TWTR_L_OFFS ); + mask = (DDR4_TRRD_L_MASK <<DDR4_TRRD_L_OFFS ) | + (DDR4_TWTR_L_MASK <<DDR4_TWTR_L_OFFS ); +CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id, +DRAM_LONG_TIMING_REG , val, mask)); + + val =0 ; + mask =0 ; + t_mod =mv_ddr_speed_bin_timing_get (speed_bin_index,SPEED_BIN_TMOD ); + t_mod =GET_MAX_VALUE (t_ckclk *24 , t_mod); + t_mod =time_to_nclk (t_mod, t_ckclk); + + val = (((t_mod -1 ) &SDRAM_TIMING_HIGH_TMOD_MASK ) <<SDRAM_TIMING_HIGH_TMOD_OFFS ) | + ((((t_mod -1 ) >>4 ) &SDRAM_TIMING_HIGH_TMOD_HIGH_MASK ) <<SDRAM_TIMING_HIGH_TMOD_HIGH_OFFS ); + mask = (SDRAM_TIMING_HIGH_TMOD_MASK <<SDRAM_TIMING_HIGH_TMOD_OFFS ) | + (SDRAM_TIMING_HIGH_TMOD_HIGH_MASK <<SDRAM_TIMING_HIGH_TMOD_HIGH_OFFS ); +CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id, +SDRAM_TIMING_HIGH_REG , val, mask)); + +#ifdef CONFIG_ARMADA_38X + t_ccd =6 ; +#else + t_ccd =4 ; +#endif + +CHECK_STATUS (ddr3_tip_if_write (dev_num, access_type, if_id, +DDR_TIMING_REG , + ((t_ccd -1 ) &DDR_TIMING_TCCD_MASK ) <<DDR_TIMING_TCCD_OFFS , +DDR_TIMING_TCCD_MASK <<DDR_TIMING_TCCD_OFFS )); + +return MV_OK ; +} +#endif /* CONFIG_DDR4 */ /* * Write CS Result @@ -2245,6 +2369,7 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num) } } +#if !defined(CONFIG_DDR4 )for (effective_cs =0 ; effective_cs < max_cs; effective_cs++) {if (mask_tune_func &PBS_RX_MASK_BIT ) { training_stage =PBS_RX ;@@ -2284,6 +2409,7 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num) }/* Set to 0 after each loop to avoid illegal value may be used */ effective_cs =0 ; +#endif /* CONFIG_DDR4 */ if (mask_tune_func &SET_TARGET_FREQ_MASK_BIT ) { training_stage =SET_TARGET_FREQ ;@@ -2367,6 +2493,7 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num) } } +#if !defined(CONFIG_DDR4 )if (mask_tune_func &DM_PBS_TX_MASK_BIT ) {DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("DM_PBS_TX_MASK_BIT\n" )); }@@ -2412,6 +2539,7 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num) }/* Set to 0 after each loop to avoid illegal value may be used */ effective_cs =0 ; +#endif /* CONFIG_DDR4 */ for (effective_cs =0 ; effective_cs < max_cs; effective_cs++) {if (mask_tune_func &WRITE_LEVELING_SUPP_TF_MASK_BIT ) {@@ -2434,7 +2562,12 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num)/* Set to 0 after each loop to avoid illegal value may be used */ effective_cs =0 ; +#if defined(CONFIG_DDR4 ) +for (effective_cs =0 ; effective_cs < max_cs; effective_cs++) +CHECK_STATUS (mv_ddr4_training_main_flow (dev_num)); +#endif /* CONFIG_DDR4 */ +#if !defined(CONFIG_DDR4 )for (effective_cs =0 ; effective_cs < max_cs; effective_cs++) {if (mask_tune_func &CENTRALIZATION_TX_MASK_BIT ) { training_stage =CENTRALIZATION_TX ;@@ -2455,6 +2588,7 @@ static int ddr3_tip_ddr3_training_main_flow(u32 dev_num) }/* Set to 0 after each loop to avoid illegal value may be used */ effective_cs =0 ; +#endif /* CONFIG_DDR4 */ DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("restore registers to default\n" ));/* restore register values */ @@ -2895,3 +3029,4 @@ unsigned int mv_ddr_misl_phy_odt_n_get(void)return odt_n; } +drivers/ddr/marvell/a38x/ddr3_training_bist.c +12
-0@@ -459,7 +459,11 @@ static int mv_ddr_odpg_bist_prepare(enum hws_pattern pattern, enum hws_access_ty (ODPG_WRBUF_RD_CTRL_DIS <<ODPG_WRBUF_RD_CTRL_OFFS ), (ODPG_WRBUF_RD_CTRL_MASK << ODPG_WRBUF_RD_CTRL_OFFS)); +#if defined(CONFIG_DDR4 ) +if (pattern ==PATTERN_ZERO || pattern ==PATTERN_ONE ) +#else if (pattern == PATTERN_00 || pattern == PATTERN_FF) +#endif ddr3_tip_load_pattern_to_odpg (0 , access_type,0 , pattern, offset); elsemv_ddr_load_dm_pattern_to_odpg (access_type ,pattern ,dm_dir );@@ -507,7 +511,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,ODPG_DATA_CTRL_REG ,0 ,MASK_ALL_BITS );mv_ddr_odpg_bist_prepare (pattern,ACCESS_TYPE_UNICAST ,OPER_WRITE ,STRESS_NONE ,DURATION_SINGLE , bist_offset, cs, pattern_table[pattern].num_of_phases_tx, +#if defined(CONFIG_DDR4) + (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#else (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#endif for (adll_tap =0 ; adll_tap <ADLL_TAPS_PER_PERIOD ; adll_tap++) {/* change target odpg address */ @@ -539,7 +547,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)/* fill memory with vref pattern to increment addr using odpg bist */ mv_ddr_odpg_bist_prepare (PATTERN_VREF ,ACCESS_TYPE_UNICAST ,OPER_WRITE ,STRESS_NONE ,DURATION_SINGLE , bist_offset, cs, pattern_table[pattern].num_of_phases_tx, +#if defined(CONFIG_DDR4) + (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#else (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE); +#endif for (adll_tap =0 ; adll_tap <ADLL_TAPS_PER_PERIOD ; adll_tap++) { ddr3_tip_bus_write(0, ACCESS_TYPE_UNICAST, 0, ACCESS_TYPE_MULTICAST, 0,drivers/ddr/marvell/a38x/ddr3_training_centralization.c +6
-0@@ -16,7 +16,13 @@#define CENTRAL_RX 1#define NUM_OF_CENTRAL_TYPES 2 +#if defined(CONFIG_64BIT )/* DDR3/4 64-bit */ +u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7_INV_64 ; +#elif defined(CONFIG_DDR4 )/* DDR4 16/32-bit */ +u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7_INV ; +#else /* DDR3 16/32-bit */ u32 start_pattern =PATTERN_KILLER_DQ0 , end_pattern =PATTERN_KILLER_DQ7 ; +#endif /* CONFIG_64BIT */ u32 start_if =0 , end_if = (MAX_INTERFACE_NUM -1 );u8 bus_end_window[NUM_OF_CENTRAL_TYPES ][MAX_INTERFACE_NUM ][MAX_BUS_NUM ];drivers/ddr/marvell/a38x/ddr3_training_db.c +278
-0@@ -25,6 +25,98 @@ static inline u32 pattern_table_get_sso_xtalk_free_word16(u8 bit, u8 index);static inline u32 pattern_table_get_isi_word (u8 index);static inline u32 pattern_table_get_isi_word16 (u8 index); +#if defined(CONFIG_DDR4 ) +u8 pattern_killer_map[KILLER_PATTERN_LENGTH *2 ] = { +0x01 , +0x00 , +0x01 , +0xff , +0xfe , +0xfe , +0x01 , +0xfe , +0x01 , +0xfe , +0x01 , +0x01 , +0xfe , +0x01 , +0xfe , +0x00 , +0xff , +0x00 , +0xff , +0x00 , +0xff , +0x00 , +0xff , +0x01 , +0x00 , +0xff , +0x00 , +0xff , +0x00 , +0x00 , +0x00 , +0xfe , +0xfe , +0xff , +0x00 , +0x00 , +0xff , +0xff , +0x00 , +0xff , +0x00 , +0xff , +0xff , +0x00 , +0x00 , +0xff , +0x00 , +0xff , +0xfe , +0x00 , +0xfe , +0xfe , +0x00 , +0xff , +0xff , +0x01 , +0x01 , +0xff , +0xff , +0x00 , +0x00 , +0x00 , +0x00 , +0xff +}; +static inline u32 pattern_table_get_killer_word_4 (u8 dqs,u8 index) +{ +u8 byte; + +if (index >= (KILLER_PATTERN_LENGTH *2 )) { +printf ("error: %s: invalid index [%u] found\n" , __func__, index); +return 0 ; + } + + byte = pattern_killer_map[index]; + +switch (byte) { +case 0x01 : + byte =1 << dqs; +break ; +case 0xfe : + byte =0xff & ~(1 << dqs); +break ; +default : +break ; + } + +return byte | (byte <<8 ) | (byte <<16 ) | (byte <<24 ); +} +#else /* !CONFIG_DDR4 */ /* List of allowed frequency listed in order of enum mv_ddr_freq */ static unsigned int freq_val[MV_DDR_FREQ_LAST ] = { 0, /*MV_DDR_FREQ_LOW_FREQ */@@ -302,6 +394,7 @@ u32 speed_bin_table_t_rcd_t_rp[] = {12155 , 13090, }; +#endif /* CONFIG_DDR4 */ enum {PATTERN_KILLER_PATTERN_TABLE_MAP_ROLE_AGGRESSOR =0 ,@@ -388,6 +481,7 @@ static u8 pattern_vref_pattern_table_map[] = {0xfe }; +#if !defined(CONFIG_DDR4 )static struct mv_ddr_page_element page_tbl[] = {/* 8-bit, 16-bit page size */ {MV_DDR_PAGE_SIZE_1K, MV_DDR_PAGE_SIZE_2K}, /* 512M */@@ -521,6 +615,7 @@ static inline u32 pattern_table_get_killer_word(u8 dqs, u8 index) return byte | (byte << 8) | (byte << 16) | (byte << 24); } +#endif /* !CONFIG_DDR4 */ static inline u32 pattern_table_get_killer_word16 (u8 dqs,u8 index) {@@ -651,6 +746,7 @@ static inline u32 pattern_table_get_vref_word16(u8 index)return 0xffffffff ; } +#if !defined(CONFIG_DDR4 )static inline u32 pattern_table_get_static_pbs_word (u8 index) {u16 temp;@@ -659,6 +755,7 @@ static inline u32 pattern_table_get_static_pbs_word(u8 index) return temp | (temp << 8) | (temp << 16) | (temp << 24); } +#endif /* !CONFIG_DDR4 */ u32 pattern_table_get_word (u32 dev_num,enum hws_pattern type,u8 index) {@@ -670,26 +767,36 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index)switch (type) {case PATTERN_PBS1 :case PATTERN_PBS2 : +#if !defined(CONFIG_DDR4 )if (index ==0 || index ==2 || index ==5 || index ==7 ) pattern =PATTERN_55 ;else pattern =PATTERN_AA ;break ; +#endif /* !CONFIG_DDR4 */ case PATTERN_PBS3 : +#if !defined(CONFIG_DDR4 )if (0 == (index &1 )) pattern =PATTERN_55 ;else pattern =PATTERN_AA ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_RL : +#if !defined(CONFIG_DDR4 )if (index <6 ) pattern =PATTERN_00 ;else pattern =PATTERN_80 ; +#else /* CONFIG_DDR4 */ + pattern =PATTERN_00 ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_STATIC_PBS : +#if !defined(CONFIG_DDR4 ) pattern =pattern_table_get_static_pbs_word (index); +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_KILLER_DQ0 :case PATTERN_KILLER_DQ1 :@@ -699,14 +806,39 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index)case PATTERN_KILLER_DQ5 :case PATTERN_KILLER_DQ6 :case PATTERN_KILLER_DQ7 : +#if !defined(CONFIG_DDR4) pattern = pattern_table_get_killer_word( +#else /* CONFIG_DDR4 */ + pattern = pattern_table_get_killer_word_4( +#endif /* !CONFIG_DDR4 */ (u8)(type - PATTERN_KILLER_DQ0), index); break; +#if defined(CONFIG_64BIT) + case PATTERN_KILLER_DQ0_64: + case PATTERN_KILLER_DQ1_64: + case PATTERN_KILLER_DQ2_64: + case PATTERN_KILLER_DQ3_64: + case PATTERN_KILLER_DQ4_64: + case PATTERN_KILLER_DQ5_64: + case PATTERN_KILLER_DQ6_64: + case PATTERN_KILLER_DQ7_64: +#if !defined(CONFIG_DDR4) + pattern = pattern_table_get_killer_word( +#else /* CONFIG_DDR4 */ + pattern = pattern_table_get_killer_word_4( +#endif /* !CONFIG_DDR4 */ + (u8)(type - PATTERN_KILLER_DQ0_64), index + 32); + break; +#endif /* CONFIG_64BIT */ case PATTERN_RL2: +#if !defined(CONFIG_DDR4) if (index < 6) pattern = PATTERN_00; else pattern = PATTERN_01; +#else /* !CONFIG_DDR4 */ + pattern = PATTERN_FF; +#endif /* CONFIG_DDR4 */ break; case PATTERN_TEST: if (index > 1 && index < 6)@@ -724,6 +856,11 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index)case PATTERN_VREF : pattern =pattern_table_get_vref_word (index);break ; +#if defined(CONFIG_64BIT ) +case PATTERN_VREF_64 : + pattern =pattern_table_get_vref_word (index +32 ); +break ; +#endif /* CONFIG_64BIT */ case PATTERN_SSO_FULL_XTALK_DQ0 :case PATTERN_SSO_FULL_XTALK_DQ1 :case PATTERN_SSO_FULL_XTALK_DQ2 :@@ -735,6 +872,19 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index) pattern =pattern_table_get_sso_full_xtalk_word ( (u8)(type -PATTERN_SSO_FULL_XTALK_DQ0 ), index);break ; +#if defined(CONFIG_64BIT ) +case PATTERN_SSO_FULL_XTALK_DQ0_64 : +case PATTERN_SSO_FULL_XTALK_DQ1_64 : +case PATTERN_SSO_FULL_XTALK_DQ2_64 : +case PATTERN_SSO_FULL_XTALK_DQ3_64 : +case PATTERN_SSO_FULL_XTALK_DQ4_64 : +case PATTERN_SSO_FULL_XTALK_DQ5_64 : +case PATTERN_SSO_FULL_XTALK_DQ6_64 : +case PATTERN_SSO_FULL_XTALK_DQ7_64 : + pattern =pattern_table_get_sso_full_xtalk_word ( + (u8)(type -PATTERN_SSO_FULL_XTALK_DQ0_64 ), index +32 ); +break ; +#endif /* CONFIG_64BIT */ case PATTERN_SSO_XTALK_FREE_DQ0 :case PATTERN_SSO_XTALK_FREE_DQ1 :case PATTERN_SSO_XTALK_FREE_DQ2 :@@ -746,9 +896,80 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index) pattern =pattern_table_get_sso_xtalk_free_word ( (u8)(type -PATTERN_SSO_XTALK_FREE_DQ0 ), index);break ; +#if defined(CONFIG_64BIT ) +case PATTERN_SSO_XTALK_FREE_DQ0_64 : +case PATTERN_SSO_XTALK_FREE_DQ1_64 : +case PATTERN_SSO_XTALK_FREE_DQ2_64 : +case PATTERN_SSO_XTALK_FREE_DQ3_64 : +case PATTERN_SSO_XTALK_FREE_DQ4_64 : +case PATTERN_SSO_XTALK_FREE_DQ5_64 : +case PATTERN_SSO_XTALK_FREE_DQ6_64 : +case PATTERN_SSO_XTALK_FREE_DQ7_64 : + pattern =pattern_table_get_sso_xtalk_free_word ( + (u8)(type -PATTERN_SSO_XTALK_FREE_DQ0_64 ), index +32 ); +break ; +#endif /* CONFIG_64BIT */ case PATTERN_ISI_XTALK_FREE : pattern =pattern_table_get_isi_word (index);break ; +#if defined(CONFIG_64BIT ) +case PATTERN_ISI_XTALK_FREE_64 : + pattern =pattern_table_get_isi_word (index +32 ); +break ; +#endif /* CONFIG_64BIT */ +#if defined(CONFIG_DDR4 ) +case PATTERN_KILLER_DQ0_INV : +case PATTERN_KILLER_DQ1_INV : +case PATTERN_KILLER_DQ2_INV : +case PATTERN_KILLER_DQ3_INV : +case PATTERN_KILLER_DQ4_INV : +case PATTERN_KILLER_DQ5_INV : +case PATTERN_KILLER_DQ6_INV : +case PATTERN_KILLER_DQ7_INV : + pattern = ~pattern_table_get_killer_word_4 ( + (u8)(type -PATTERN_KILLER_DQ0_INV ), index); +break ; +#if defined(CONFIG_64BIT ) +case PATTERN_KILLER_DQ0_INV_64 : +case PATTERN_KILLER_DQ1_INV_64 : +case PATTERN_KILLER_DQ2_INV_64 : +case PATTERN_KILLER_DQ3_INV_64 : +case PATTERN_KILLER_DQ4_INV_64 : +case PATTERN_KILLER_DQ5_INV_64 : +case PATTERN_KILLER_DQ6_INV_64 : +case PATTERN_KILLER_DQ7_INV_64 : + pattern = ~pattern_table_get_killer_word_4 ( + (u8)(type -PATTERN_KILLER_DQ0_INV_64 ), index +32 ); +break ; +#endif /* CONFIG_64BIT */ +case PATTERN_RESONANCE_1T : +case PATTERN_RESONANCE_2T : +case PATTERN_RESONANCE_3T : +case PATTERN_RESONANCE_4T : +case PATTERN_RESONANCE_5T : +case PATTERN_RESONANCE_6T : +case PATTERN_RESONANCE_7T : +case PATTERN_RESONANCE_8T : +case PATTERN_RESONANCE_9T : + { +u8 t_num = (u8)(type -PATTERN_RESONANCE_1T ); +u8 t_end = (59 / t_num) * t_num; +if (index < t_end) + pattern = ((index % (t_num *2 )) >= t_num) ?0xffffffff :0x00000000 ; +else + pattern = ((index %2 ) ==0 ) ?0xffffffff :0x00000000 ; + } +break ; +case PATTERN_ZERO : + pattern =PATTERN_00 ; +break ; +case PATTERN_ONE : + pattern =PATTERN_FF ; +break ; +case PATTERN_VREF_INV : + pattern = ~pattern_table_get_vref_word (index); +break ; +#endif /* CONFIG_DDR4 */ default :printf ("error: %s: unsupported pattern type [%d] found\n" , __func__, (int )type);@@ -761,16 +982,24 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index)case PATTERN_PBS1 :case PATTERN_PBS2 :case PATTERN_PBS3 : +#if !defined(CONFIG_DDR4 ) pattern =PATTERN_55AA ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_RL : +#if !defined(CONFIG_DDR4 )if (index <3 ) pattern =PATTERN_00 ;else pattern =PATTERN_80 ; +#else /* CONFIG_DDR4 */ + pattern =PATTERN_00 ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_STATIC_PBS : +#if !defined(CONFIG_DDR4 ) pattern =PATTERN_00FF ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_KILLER_DQ0 :case PATTERN_KILLER_DQ1 :@@ -784,25 +1013,40 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index) (u8)(type - PATTERN_KILLER_DQ0), index);break ;case PATTERN_RL2 : +#if !defined(CONFIG_DDR4 )if (index <3 ) pattern =PATTERN_00 ;else pattern =PATTERN_01 ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_TEST : +#if !defined(CONFIG_DDR4 )if ((index ==0 ) || (index ==3 )) pattern =0x00000000 ;else pattern =0xFFFFFFFF ; +#else /* CONFIG_DDR4 */ +if ((index >1 ) && (index <6 )) + pattern =PATTERN_20 ; +else + pattern =PATTERN_00 ; +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_FULL_SSO0 : +#if !defined(CONFIG_DDR4 ) pattern =0x0000ffff ;break ; +#endif /* !CONFIG_DDR4 */ case PATTERN_FULL_SSO1 :case PATTERN_FULL_SSO2 :case PATTERN_FULL_SSO3 : pattern =pattern_table_get_sso_word ( +#if !defined(CONFIG_DDR4) (u8)(type -PATTERN_FULL_SSO1 ), index); +#else /* CONFIG_DDR4 */ + (u8)(type - PATTERN_FULL_SSO0), index); +#endif /* !CONFIG_DDR4 */ break ;case PATTERN_VREF : pattern =pattern_table_get_vref_word16 (index);@@ -832,6 +1076,40 @@ u32 pattern_table_get_word(u32 dev_num, enum hws_pattern type, u8 index)case PATTERN_ISI_XTALK_FREE : pattern =pattern_table_get_isi_word16 (index);break ; +#if defined(CONFIG_DDR4 ) +case PATTERN_KILLER_DQ0_INV : +case PATTERN_KILLER_DQ1_INV : +case PATTERN_KILLER_DQ2_INV : +case PATTERN_KILLER_DQ3_INV : +case PATTERN_KILLER_DQ4_INV : +case PATTERN_KILLER_DQ5_INV : +case PATTERN_KILLER_DQ6_INV : +case PATTERN_KILLER_DQ7_INV : + pattern = ~pattern_table_get_killer_word16 ( + (u8)(type -PATTERN_KILLER_DQ0_INV ), index); +break ; +case PATTERN_RESONANCE_1T : +case PATTERN_RESONANCE_2T : +case PATTERN_RESONANCE_3T : +case PATTERN_RESONANCE_4T : +case PATTERN_RESONANCE_5T : +case PATTERN_RESONANCE_6T : +case PATTERN_RESONANCE_7T : +case PATTERN_RESONANCE_8T : +case PATTERN_RESONANCE_9T : + { +u8 t_num = (u8)(type -PATTERN_RESONANCE_1T ); +u8 t_end = (59 / t_num) * t_num; +if (index < t_end) + pattern = ((index % (t_num *2 )) >= t_num) ?0xffffffff :0x00000000 ; +else + pattern = ((index %2 ) ==0 ) ?0xffffffff :0x00000000 ; + } +break ; +case PATTERN_VREF_INV : + pattern = ~pattern_table_get_vref_word16 (index); +break ; +#endif /* CONFIG_DDR4 */ default :if (((int )type ==29 ) || ((int )type ==30 ))break ;drivers/ddr/marvell/a38x/ddr3_training_ip.h +17
-0@@ -42,6 +42,13 @@#define WRITE_LEVELING_LF_MASK_BIT 0x02000000/* DDR4 Specific Training Mask bits */ +#if defined (CONFIG_DDR4 ) +#define RECEIVER_CALIBRATION_MASK_BIT 0x04000000 +#define WL_PHASE_CORRECTION_MASK_BIT 0x08000000 +#define DQ_VREF_CALIBRATION_MASK_BIT 0x10000000 +#define DQ_MAPPING_MASK_BIT 0x20000000 +#define DM_TUNING_MASK_BIT 0x40000000 +#endif /* CONFIG_DDR4 */ enum hws_result {TEST_FAILED =0 ,@@ -63,6 +70,9 @@ enum auto_tune_stage { WRITE_LEVELING,LOAD_PATTERN_2 ,READ_LEVELING , +#if defined(CONFIG_DDR4) +SW_READ_LEVELING , +#endif /* CONFIG_DDR4 */WRITE_LEVELING_SUPP ,PBS_RX , PBS_TX,@@ -78,6 +88,13 @@ enum auto_tune_stage { TX_EMPHASIS,LOAD_PATTERN_HIGH ,PER_BIT_READ_LEVELING_TF , +#if defined(CONFIG_DDR4) +RECEIVER_CALIBRATION , +WL_PHASE_CORRECTION , +DQ_VREF_CALIBRATION , +DM_TUNING , +DQ_MAPPING , +#endif /* CONFIG_DDR4 */WRITE_LEVELING_LF ,MAX_STAGE_LIMIT };drivers/ddr/marvell/a38x/ddr3_training_ip_db.h +155
-1@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) Marvell International Ltd. and its affiliates */ @@ -7,6 +7,159 @@#define _DDR3_TRAINING_IP_DB_H_enum hws_pattern { +#if defined(CONFIG_64BIT )/* DDR3/4 64-bit */ +PATTERN_PBS1 , +PATTERN_PBS2 , +PATTERN_PBS3 , +PATTERN_TEST , +PATTERN_RL , +PATTERN_RL2 , +PATTERN_STATIC_PBS , +PATTERN_KILLER_DQ0 , +PATTERN_KILLER_DQ1 , +PATTERN_KILLER_DQ2 , +PATTERN_KILLER_DQ3 , +PATTERN_KILLER_DQ4 , +PATTERN_KILLER_DQ5 , +PATTERN_KILLER_DQ6 , +PATTERN_KILLER_DQ7 , +PATTERN_KILLER_DQ0_64 , +PATTERN_KILLER_DQ1_64 , +PATTERN_KILLER_DQ2_64 , +PATTERN_KILLER_DQ3_64 , +PATTERN_KILLER_DQ4_64 , +PATTERN_KILLER_DQ5_64 , +PATTERN_KILLER_DQ6_64 , +PATTERN_KILLER_DQ7_64 , +PATTERN_KILLER_DQ0_INV , +PATTERN_KILLER_DQ1_INV , +PATTERN_KILLER_DQ2_INV , +PATTERN_KILLER_DQ3_INV , +PATTERN_KILLER_DQ4_INV , +PATTERN_KILLER_DQ5_INV , +PATTERN_KILLER_DQ6_INV , +PATTERN_KILLER_DQ7_INV , +PATTERN_KILLER_DQ0_INV_64 , +PATTERN_KILLER_DQ1_INV_64 , +PATTERN_KILLER_DQ2_INV_64 , +PATTERN_KILLER_DQ3_INV_64 , +PATTERN_KILLER_DQ4_INV_64 , +PATTERN_KILLER_DQ5_INV_64 , +PATTERN_KILLER_DQ6_INV_64 , +PATTERN_KILLER_DQ7_INV_64 , +PATTERN_SSO_FULL_XTALK_DQ0 , +PATTERN_SSO_FULL_XTALK_DQ1 , +PATTERN_SSO_FULL_XTALK_DQ2 , +PATTERN_SSO_FULL_XTALK_DQ3 , +PATTERN_SSO_FULL_XTALK_DQ4 , +PATTERN_SSO_FULL_XTALK_DQ5 , +PATTERN_SSO_FULL_XTALK_DQ6 , +PATTERN_SSO_FULL_XTALK_DQ7 , +PATTERN_SSO_FULL_XTALK_DQ0_64 , +PATTERN_SSO_FULL_XTALK_DQ1_64 , +PATTERN_SSO_FULL_XTALK_DQ2_64 , +PATTERN_SSO_FULL_XTALK_DQ3_64 , +PATTERN_SSO_FULL_XTALK_DQ4_64 , +PATTERN_SSO_FULL_XTALK_DQ5_64 , +PATTERN_SSO_FULL_XTALK_DQ6_64 , +PATTERN_SSO_FULL_XTALK_DQ7_64 , +PATTERN_SSO_XTALK_FREE_DQ0 , +PATTERN_SSO_XTALK_FREE_DQ1 , +PATTERN_SSO_XTALK_FREE_DQ2 , +PATTERN_SSO_XTALK_FREE_DQ3 , +PATTERN_SSO_XTALK_FREE_DQ4 , +PATTERN_SSO_XTALK_FREE_DQ5 , +PATTERN_SSO_XTALK_FREE_DQ6 , +PATTERN_SSO_XTALK_FREE_DQ7 , +PATTERN_SSO_XTALK_FREE_DQ0_64 , +PATTERN_SSO_XTALK_FREE_DQ1_64 , +PATTERN_SSO_XTALK_FREE_DQ2_64 , +PATTERN_SSO_XTALK_FREE_DQ3_64 , +PATTERN_SSO_XTALK_FREE_DQ4_64 , +PATTERN_SSO_XTALK_FREE_DQ5_64 , +PATTERN_SSO_XTALK_FREE_DQ6_64 , +PATTERN_SSO_XTALK_FREE_DQ7_64 , +PATTERN_ISI_XTALK_FREE , +PATTERN_ISI_XTALK_FREE_64 , +PATTERN_VREF , +PATTERN_VREF_64 , +PATTERN_VREF_INV , +PATTERN_FULL_SSO0 , +PATTERN_FULL_SSO1 , +PATTERN_FULL_SSO2 , +PATTERN_FULL_SSO3 , +PATTERN_RESONANCE_1T , +PATTERN_RESONANCE_2T , +PATTERN_RESONANCE_3T , +PATTERN_RESONANCE_4T , +PATTERN_RESONANCE_5T , +PATTERN_RESONANCE_6T , +PATTERN_RESONANCE_7T , +PATTERN_RESONANCE_8T , +PATTERN_RESONANCE_9T , +PATTERN_ZERO , +PATTERN_ONE , + PATTERN_LAST +#elif defined(CONFIG_DDR4 )/* DDR4 16/32-bit */ +PATTERN_PBS1 ,/*0*/ +PATTERN_PBS2 , +PATTERN_PBS3 , +PATTERN_TEST , +PATTERN_RL , +PATTERN_RL2 , +PATTERN_STATIC_PBS , +PATTERN_KILLER_DQ0 , +PATTERN_KILLER_DQ1 , +PATTERN_KILLER_DQ2 , +PATTERN_KILLER_DQ3 ,/*10*/ +PATTERN_KILLER_DQ4 , +PATTERN_KILLER_DQ5 , +PATTERN_KILLER_DQ6 , +PATTERN_KILLER_DQ7 , +PATTERN_KILLER_DQ0_INV , +PATTERN_KILLER_DQ1_INV , +PATTERN_KILLER_DQ2_INV , +PATTERN_KILLER_DQ3_INV , +PATTERN_KILLER_DQ4_INV , +PATTERN_KILLER_DQ5_INV ,/*20*/ +PATTERN_KILLER_DQ6_INV , +PATTERN_KILLER_DQ7_INV , +PATTERN_VREF , +PATTERN_VREF_INV , +PATTERN_FULL_SSO0 , +PATTERN_FULL_SSO1 , +PATTERN_FULL_SSO2 , +PATTERN_FULL_SSO3 , +PATTERN_ZERO , +PATTERN_ONE , +PATTERN_LAST , +PATTERN_SSO_FULL_XTALK_DQ0 , +PATTERN_SSO_FULL_XTALK_DQ1 ,/*30*/ +PATTERN_SSO_FULL_XTALK_DQ2 , +PATTERN_SSO_FULL_XTALK_DQ3 , +PATTERN_SSO_FULL_XTALK_DQ4 , +PATTERN_SSO_FULL_XTALK_DQ5 , +PATTERN_SSO_FULL_XTALK_DQ6 , +PATTERN_SSO_FULL_XTALK_DQ7 , +PATTERN_SSO_XTALK_FREE_DQ0 , +PATTERN_SSO_XTALK_FREE_DQ1 , +PATTERN_SSO_XTALK_FREE_DQ2 , +PATTERN_SSO_XTALK_FREE_DQ3 ,/*40*/ +PATTERN_SSO_XTALK_FREE_DQ4 , +PATTERN_SSO_XTALK_FREE_DQ5 , +PATTERN_SSO_XTALK_FREE_DQ6 , +PATTERN_SSO_XTALK_FREE_DQ7 , +PATTERN_ISI_XTALK_FREE , +PATTERN_RESONANCE_1T , +PATTERN_RESONANCE_2T , +PATTERN_RESONANCE_3T , +PATTERN_RESONANCE_4T , +PATTERN_RESONANCE_5T ,/*50*/ +PATTERN_RESONANCE_6T , +PATTERN_RESONANCE_7T , +PATTERN_RESONANCE_8T , + PATTERN_RESONANCE_9T +#else /* DDR3 16/32-bit */ PATTERN_PBS1 ,PATTERN_PBS2 ,PATTERN_PBS3 ,@@ -45,6 +198,7 @@ enum hws_pattern {PATTERN_SSO_XTALK_FREE_DQ6 ,PATTERN_SSO_XTALK_FREE_DQ7 , PATTERN_ISI_XTALK_FREE +#endif /* CONFIG_64BIT */ };enum mv_wl_supp_mode {drivers/ddr/marvell/a38x/ddr3_training_ip_engine.c +146
-1@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) Marvell International Ltd. and its affiliates */ @@ -205,6 +205,137 @@ struct pattern_info pattern_table_64[] = {/* Note: actual start_address is "<< 3" of defined address */ }; +#if defined(CONFIG_DDR4 ) +struct pattern_info pattern_table_16[] = { +/* +* num tx phases, tx burst, delay between, rx pattern, +* start_address, pattern_len +*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0000 ,2 },/* PATTERN_PBS1*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0080 ,2 },/* PATTERN_PBS2*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0100 ,2 },/* PATTERN_PBS3*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0180 ,2 },/* PATTERN_TEST*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0200 ,2 },/* PATTERN_RL*/ + {0x1 ,0x1 ,2 ,0x1 ,0x0280 ,2 },/* PATTERN_RL2*/ + {0xf ,0x7 ,2 ,0x7 ,0x0680 ,16 },/* PATTERN_STATIC_PBS*/ + {0xf ,0x7 ,2 ,0x7 ,0x0A80 ,16 },/* PATTERN_KILLER_DQ0*/ + {0xf ,0x7 ,2 ,0x7 ,0x0E80 ,16 },/* PATTERN_KILLER_DQ1*/ + {0xf ,0x7 ,2 ,0x7 ,0x1280 ,16 },/* PATTERN_KILLER_DQ2*/ + {0xf ,0x7 ,2 ,0x7 ,0x1680 ,16 },/* PATTERN_KILLER_DQ3*/ + {0xf ,0x7 ,2 ,0x7 ,0x1A80 ,16 },/* PATTERN_KILLER_DQ4*/ + {0xf ,0x7 ,2 ,0x7 ,0x1E80 ,16 },/* PATTERN_KILLER_DQ5*/ + {0xf ,0x7 ,2 ,0x7 ,0x2280 ,16 },/* PATTERN_KILLER_DQ6*/ + {0xf ,0x7 ,2 ,0x7 ,0x2680 ,16 },/* PATTERN_KILLER_DQ7*/ + {0xf ,0x7 ,2 ,0x7 ,0x2A80 ,16 },/* PATTERN_KILLER_DQ0_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x2E80 ,16 },/* PATTERN_KILLER_DQ1_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x3280 ,16 },/* PATTERN_KILLER_DQ2_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x3680 ,16 },/* PATTERN_KILLER_DQ3_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x3A80 ,16 },/* PATTERN_KILLER_DQ4_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x3E80 ,16 },/* PATTERN_KILLER_DQ5_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x4280 ,16 },/* PATTERN_KILLER_DQ6_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x4680 ,16 },/* PATTERN_KILLER_DQ7_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x4A80 ,16 },/* PATTERN_VREF*/ + {0xf ,0x7 ,2 ,0x7 ,0x4E80 ,16 },/* PATTERN_VREF_INV*/ + {0xf ,0x7 ,2 ,0x7 ,0x5280 ,16 },/* PATTERN_FULL_SSO_0T*/ + {0xf ,0x7 ,2 ,0x7 ,0x5680 ,16 },/* PATTERN_FULL_SSO_1T*/ + {0xf ,0x7 ,2 ,0x7 ,0x5A80 ,16 },/* PATTERN_FULL_SSO_2T*/ + {0xf ,0x7 ,2 ,0x7 ,0x5E80 ,16 },/* PATTERN_FULL_SSO_3T*/ + {0xf ,0x7 ,2 ,0x7 ,0x6280 ,16 },/* PATTERN_ZERO */ + {0xf ,0x7 ,2 ,0x7 ,0x6680 ,16 },/* PATTERN_ONE */ + {0xf ,0x7 ,2 ,0x7 ,0x6A80 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ0*/ + {0xf ,0x7 ,2 ,0x7 ,0x6E80 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ1*/ + {0xf ,0x7 ,2 ,0x7 ,0x7280 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ2*/ + {0xf ,0x7 ,2 ,0x7 ,0x7680 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ3*/ + {0xf ,0x7 ,2 ,0x7 ,0x7A80 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ4*/ + {0xf ,0x7 ,2 ,0x7 ,0x7E80 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ5*/ + {0xf ,0x7 ,2 ,0x7 ,0x8280 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ6*/ + {0xf ,0x7 ,2 ,0x7 ,0x8680 ,16 },/* PATTERN_SSO_FULL_XTALK_DQ7*/ + {0xf ,0x7 ,2 ,0x7 ,0x8A80 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ0*/ + {0xf ,0x7 ,2 ,0x7 ,0x8E80 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ1*/ + {0xf ,0x7 ,2 ,0x7 ,0x9280 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ2*/ + {0xf ,0x7 ,2 ,0x7 ,0x9680 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ3*/ + {0xf ,0x7 ,2 ,0x7 ,0x9A80 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ4*/ + {0xf ,0x7 ,2 ,0x7 ,0x9E80 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ5*/ + {0xf ,0x7 ,2 ,0x7 ,0xA280 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ6*/ + {0xf ,0x7 ,2 ,0x7 ,0xA680 ,16 },/* PATTERN_SSO_XTALK_FREE_DQ7*/ + {0xf ,0x7 ,2 ,0x7 ,0xAA80 ,16 },/* PATTERN_ISI_XTALK_FREE*/ + {0xf ,0x7 ,2 ,0x7 ,0xAE80 ,16 },/* PATTERN_RESONANCE_1T*/ + {0xf ,0x7 ,2 ,0x7 ,0xB280 ,16 },/* PATTERN_RESONANCE_2T*/ + {0xf ,0x7 ,2 ,0x7 ,0xB680 ,16 },/* PATTERN_RESONANCE_3T*/ + {0xf ,0x7 ,2 ,0x7 ,0xBA80 ,16 },/* PATTERN_RESONANCE_4T*/ + {0xf ,0x7 ,2 ,0x7 ,0xBE80 ,16 },/* PATTERN_RESONANCE_5T*/ + {0xf ,0x7 ,2 ,0x7 ,0xC280 ,16 },/* PATTERN_RESONANCE_6T*/ + {0xf ,0x7 ,2 ,0x7 ,0xC680 ,16 },/* PATTERN_RESONANCE_7T*/ + {0xf ,0x7 ,2 ,0x7 ,0xca80 ,16 },/* PATTERN_RESONANCE_8T*/ + {0xf ,0x7 ,2 ,0x7 ,0xce80 ,16 }/* PATTERN_RESONANCE_9T*/ +/* Note: actual start_address is "<< 3" of defined address */ +}; + +struct pattern_info pattern_table_32[] = { +/* +* num tx phases, tx burst, delay between, rx pattern, +* start_address, pattern_len +*/ + {0x3 ,0x3 ,2 ,0x3 ,0x0000 ,4 },/* PATTERN_PBS1*/ + {0x3 ,0x3 ,2 ,0x3 ,0x0020 ,4 },/* PATTERN_PBS2*/ + {0x3 ,0x3 ,2 ,0x3 ,0x0040 ,4 },/* PATTERN_PBS3*/ + {0x3 ,0x3 ,2 ,0x3 ,0x0060 ,4 },/* PATTERN_TEST*/ + {0x3 ,0x3 ,2 ,0x3 ,0x0080 ,4 },/* PATTERN_RL*/ + {0x3 ,0x3 ,2 ,0x3 ,0x00a0 ,4 },/* PATTERN_RL2*/ + {0x1f ,0xf ,2 ,0xf ,0x00c0 ,32 },/* PATTERN_STATIC_PBS*/ + {0x1f ,0xf ,2 ,0xf ,0x00e0 ,32 },/* PATTERN_KILLER_DQ0*/ + {0x1f ,0xf ,2 ,0xf ,0x0100 ,32 },/* PATTERN_KILLER_DQ1*/ + {0x1f ,0xf ,2 ,0xf ,0x0120 ,32 },/* PATTERN_KILLER_DQ2*/ + {0x1f ,0xf ,2 ,0xf ,0x0140 ,32 },/* PATTERN_KILLER_DQ3*/ + {0x1f ,0xf ,2 ,0xf ,0x0160 ,32 },/* PATTERN_KILLER_DQ4*/ + {0x1f ,0xf ,2 ,0xf ,0x0180 ,32 },/* PATTERN_KILLER_DQ5*/ + {0x1f ,0xf ,2 ,0xf ,0x01a0 ,32 },/* PATTERN_KILLER_DQ6*/ + {0x1f ,0xf ,2 ,0xf ,0x01c0 ,32 },/* PATTERN_KILLER_DQ7*/ + {0x1f ,0xf ,2 ,0xf ,0x01e0 ,32 },/* PATTERN_KILLER_DQ0_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0200 ,32 },/* PATTERN_KILLER_DQ1_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0220 ,32 },/* PATTERN_KILLER_DQ2_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0240 ,32 },/* PATTERN_KILLER_DQ3_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0260 ,32 },/* PATTERN_KILLER_DQ4_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0280 ,32 },/* PATTERN_KILLER_DQ5_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x02a0 ,32 },/* PATTERN_KILLER_DQ6_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x02c0 ,32 },/* PATTERN_KILLER_DQ7_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x02e0 ,32 },/* PATTERN_VREF*/ + {0x1f ,0xf ,2 ,0xf ,0x0300 ,32 },/* PATTERN_VREF_INV*/ + {0x1f ,0xf ,2 ,0xf ,0x0320 ,32 },/* PATTERN_FULL_SSO_0T*/ + {0x1f ,0xf ,2 ,0xf ,0x0340 ,32 },/* PATTERN_FULL_SSO_1T*/ + {0x1f ,0xf ,2 ,0xf ,0x0360 ,32 },/* PATTERN_FULL_SSO_2T*/ + {0x1f ,0xf ,2 ,0xf ,0x0380 ,32 },/* PATTERN_FULL_SSO_3T*/ + {0x1f ,0xf ,2 ,0xf ,0x6280 ,32 },/* PATTERN_ZERO */ + {0x1f ,0xf ,2 ,0xf ,0x6680 ,32 },/* PATTERN_ONE */ + {0x1f ,0xf ,2 ,0xf ,0x6A80 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ0*/ + {0x1f ,0xf ,2 ,0xf ,0x6E80 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ1*/ + {0x1f ,0xf ,2 ,0xf ,0x7280 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ2*/ + {0x1f ,0xf ,2 ,0xf ,0x7680 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ3*/ + {0x1f ,0xf ,2 ,0xf ,0x7A80 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ4*/ + {0x1f ,0xf ,2 ,0xf ,0x7E80 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ5*/ + {0x1f ,0xf ,2 ,0xf ,0x8280 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ6*/ + {0x1f ,0xf ,2 ,0xf ,0x8680 ,32 },/* PATTERN_SSO_FULL_XTALK_DQ7*/ + {0x1f ,0xf ,2 ,0xf ,0x8A80 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ0*/ + {0x1f ,0xf ,2 ,0xf ,0x8E80 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ1*/ + {0x1f ,0xf ,2 ,0xf ,0x9280 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ2*/ + {0x1f ,0xf ,2 ,0xf ,0x9680 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ3*/ + {0x1f ,0xf ,2 ,0xf ,0x9A80 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ4*/ + {0x1f ,0xf ,2 ,0xf ,0x9E80 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ5*/ + {0x1f ,0xf ,2 ,0xf ,0xA280 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ6*/ + {0x1f ,0xf ,2 ,0xf ,0xA680 ,32 },/* PATTERN_SSO_XTALK_FREE_DQ7*/ + {0x1f ,0xf ,2 ,0xf ,0xAA80 ,32 },/* PATTERN_ISI_XTALK_FREE*/ + {0x1f ,0xf ,2 ,0xf ,0xAE80 ,32 },/* PATTERN_RESONANCE_1T*/ + {0x1f ,0xf ,2 ,0xf ,0xB280 ,32 },/* PATTERN_RESONANCE_2T*/ + {0x1f ,0xf ,2 ,0xf ,0xB680 ,32 },/* PATTERN_RESONANCE_3T*/ + {0x1f ,0xf ,2 ,0xf ,0xBA80 ,32 },/* PATTERN_RESONANCE_4T*/ + {0x1f ,0xf ,2 ,0xf ,0xBE80 ,32 },/* PATTERN_RESONANCE_5T*/ + {0x1f ,0xf ,2 ,0xf ,0xC280 ,32 },/* PATTERN_RESONANCE_6T*/ + {0x1f ,0xf ,2 ,0xf ,0xC680 ,32 },/* PATTERN_RESONANCE_7T*/ + {0x1f ,0xf ,2 ,0xf ,0xca80 ,32 },/* PATTERN_RESONANCE_8T*/ + {0x1f ,0xf ,2 ,0xf ,0xce80 ,32 }/* PATTERN_RESONANCE_9T*/ +/* Note: actual start_address is "<< 3" of defined address */ +}; +#else /* CONFIG_DDR4 */ struct pattern_info pattern_table_16[] = {/* * num tx phases, tx burst, delay between, rx pattern, @@ -294,6 +425,7 @@ struct pattern_info pattern_table_32[] = { {0x1f, 0xF, 2, 0xf, 0xA280, 32} /* PATTERN_ISI_XTALK_FREE *//* Note: actual start_address is "<< 3" of defined address */ }; +#endif /* CONFIG_DDR4 */ u32 train_dev_num;enum hws_ddr_cs traintrain_cs_type;@@ -309,7 +441,12 @@ enum hws_pattern train_pattern;enum hws_edge_compare train_edge_compare;u32 train_cs_num;u32 train_if_acess, train_if_id, train_pup_access; +#if defined(CONFIG_DDR4 ) +/* The counter was increased for DDR4 because of A390 DB-GP DDR4 failure */ +u32 max_polling_for_done =100000000 ; +#else /* CONFIG_DDR4 */ u32 max_polling_for_done =1000000 ; +#endif /* CONFIG_DDR4 */ u32 *ddr3_tip_get_buf_ptr(u32 dev_num, enum hws_search_dir search, enum hws_training_result result_type,@@ -561,6 +698,10 @@ int ddr3_tip_ip_training(u32 dev_num, enum hws_access_type access_type,ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ODPG_DATA_CTRL_REG ,0 ,MASK_ALL_BITS ); +#if defined(CONFIG_DDR4 ) +if (tm->debug_level !=DEBUG_LEVEL_ERROR ) +refresh (); +#endif return MV_OK ; }@@ -837,6 +978,10 @@ int ddr3_tip_read_training_result(u32 dev_num, u32 if_id, } } } +#if defined(CONFIG_DDR4 ) +if (tm->debug_level !=DEBUG_LEVEL_ERROR ) +refresh (); +#endif return MV_OK ; }drivers/ddr/marvell/a38x/ddr3_training_ip_flow.h +6
-1@@ -1,4 +1,4 @@ -/* SPDX-License-Identifier: GPL-2.0 */ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) Marvell International Ltd. and its affiliates */ @@ -46,6 +46,11 @@ enum mr_number { MR_CMD1, MR_CMD2, MR_CMD3, +#if defined(CONFIG_DDR4 ) +MR_CMD4 , +MR_CMD5 , +MR_CMD6 , +#endifMR_LAST };drivers/ddr/marvell/a38x/ddr3_training_leveling.c +138
-1@@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) Marvell International Ltd. and its affiliates */ @@ -915,8 +915,10 @@ int ddr3_tip_dynamic_write_leveling(u32 dev_num, int phase_remove)DEBUG_LEVELING (DEBUG_LEVEL_ERROR , ("training done failed\n" )); }else {/* check for training pass */ reg_data = data_read[0 ]; +#if defined(CONFIG_ARMADA_38X )/* JIRA #1498 for 16 bit with ECC */ if (tm->bus_act_mask ==0xb )/* set to data to 0 to skip the check */ reg_data =0 ; +#endif if (reg_data !=PASS )DEBUG_LEVELING (DEBUG_LEVEL_INFO , ("training result failed\n" ));@@ -1667,6 +1669,59 @@ enum rl_dqs_burst_state {RL_BEHIND }; +#if defined(CONFIG_DDR4 ) +static int mpr_rd_frmt_config ( +enum mv_ddr_mpr_ps ps, +enum mv_ddr_mpr_op op, +enum mv_ddr_mpr_rd_frmt rd_frmt, +u8 cs_bitmask,u8 dis_auto_refresh) +{ +u32 val, mask; +u8 cs_bitmask_inv; + + +if (dis_auto_refresh ==1 ) { +ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,ODPG_CTRL_CTRL_REG , +ODPG_CTRL_AUTO_REFRESH_DIS <<ODPG_CTRL_AUTO_REFRESH_OFFS , +ODPG_CTRL_AUTO_REFRESH_MASK <<ODPG_CTRL_AUTO_REFRESH_OFFS ); + }else { +ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,ODPG_CTRL_CTRL_REG , +ODPG_CTRL_AUTO_REFRESH_ENA <<ODPG_CTRL_AUTO_REFRESH_OFFS , +ODPG_CTRL_AUTO_REFRESH_MASK <<ODPG_CTRL_AUTO_REFRESH_OFFS ); + } + +/* configure MPR Location for MPR write and read accesses within the selected page */ +ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,DDR4_MPR_WR_REG , +DDR4_MPR_LOC3 <<DDR4_MPR_LOC_OFFS , +DDR4_MPR_LOC_MASK <<DDR4_MPR_LOC_OFFS ); + +/* configure MPR page selection, operation and read format */ + val = ps <<DDR4_MPR_PS_OFFS | + op <<DDR4_MPR_OP_OFFS | + rd_frmt <<DDR4_MPR_RF_OFFS ; + mask =DDR4_MPR_PS_MASK <<DDR4_MPR_PS_OFFS | +DDR4_MPR_OP_MASK <<DDR4_MPR_OP_OFFS | +DDR4_MPR_RF_MASK <<DDR4_MPR_RF_OFFS ; +ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,DDR4_MR3_REG , val, mask); + +/* prepare cs bitmask in active low format */ + cs_bitmask_inv = ~cs_bitmask &SDRAM_OP_CMD_ALL_CS_MASK ; +ddr3_tip_if_write (0 ,ACCESS_TYPE_UNICAST ,0 ,SDRAM_OP_REG , +CMD_DDR3_DDR4_MR3 <<SDRAM_OP_CMD_OFFS | + cs_bitmask_inv <<SDRAM_OP_CMD_CS_OFFS (0 ), +SDRAM_OP_CMD_MASK <<SDRAM_OP_CMD_OFFS | +SDRAM_OP_CMD_ALL_CS_MASK <<SDRAM_OP_CMD_CS_OFFS (0 )); + +if (ddr3_tip_if_polling (0 ,ACCESS_TYPE_UNICAST ,0 , +CMD_NORMAL ,SDRAM_OP_CMD_MASK ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS )) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +return 0 ; +} +#endif /* CONFIG_DDR4 */ int mv_ddr_rl_dqs_burst (u32 dev_num,u32 if_id,u32 freq) {@@ -1690,6 +1745,19 @@ int mv_ddr_rl_dqs_burst(u32 dev_num, u32 if_id, u32 freq)u32 reg_val, reg_mask;uintptr_t test_addr =TEST_ADDR ; +#if defined(CONFIG_DDR4 ) +int status; +u8 cs_bitmask = tm->interface_params[0 ].as_bus_params[0 ].cs_bitmask; +u8 curr_cs_bitmask_inv; + +/* enable MPR for all existing chip-selects */ + status =mpr_rd_frmt_config (DDR4_MPR_PAGE0 , +DDR4_MPR_OP_ENA , +DDR4_MPR_RF_SERIAL , + cs_bitmask,1 ); +if (status) +return status; +#endif /* CONFIG_DDR4 */ /* initialization */ if (mv_ddr_is_ecc_ena ()) {@@ -1728,6 +1796,48 @@ int mv_ddr_rl_dqs_burst(u32 dev_num, u32 if_id, u32 freq)/* search for dqs edges per subphy */ if_id =0 ;for (effective_cs =0 ; effective_cs < max_cs; effective_cs++) { +#if defined(CONFIG_DDR4 ) +/* enable read preamble training mode for chip-select under test */ +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +DDR4_MR4_REG , +DDR4_RPT_ENA <<DDR4_RPT_OFFS , +DDR4_RPT_MASK <<DDR4_RPT_OFFS ); +/* prepare current cs bitmask in active low format */ + curr_cs_bitmask_inv = ~(1 << effective_cs) &SDRAM_OP_CMD_ALL_CS_MASK ; + reg_val = curr_cs_bitmask_inv <<SDRAM_OP_CMD_CS_OFFS (0 ) | +CMD_DDR4_MR4 <<SDRAM_OP_CMD_OFFS ; + reg_mask =SDRAM_OP_CMD_ALL_CS_MASK <<SDRAM_OP_CMD_CS_OFFS (0 ) | +SDRAM_OP_CMD_MASK <<SDRAM_OP_CMD_OFFS ; +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +SDRAM_OP_REG , reg_val, reg_mask); +if (ddr3_tip_if_polling (0 ,ACCESS_TYPE_UNICAST ,0 , +CMD_NORMAL ,SDRAM_OP_CMD_MASK ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS )) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +/* disable preamble training mode for existing chip-selects not under test */ +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +DDR4_MR4_REG , +DDR4_RPT_DIS <<DDR4_RPT_OFFS , +DDR4_RPT_MASK <<DDR4_RPT_OFFS ); +/* prepare bitmask for existing chip-selects not under test in active low format */ + reg_val = ((~(curr_cs_bitmask_inv & cs_bitmask) &SDRAM_OP_CMD_ALL_CS_MASK ) << +SDRAM_OP_CMD_CS_OFFS (0 )) | +CMD_DDR4_MR4 <<SDRAM_OP_CMD_OFFS ; + reg_mask =SDRAM_OP_CMD_ALL_CS_MASK <<SDRAM_OP_CMD_CS_OFFS (0 ) | +SDRAM_OP_CMD_MASK <<SDRAM_OP_CMD_OFFS ; +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +SDRAM_OP_REG , reg_val, reg_mask); +if (ddr3_tip_if_polling (0 ,ACCESS_TYPE_UNICAST ,0 , +CMD_NORMAL ,SDRAM_OP_CMD_MASK ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS )) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +#endif /* CONFIG_DDR4 */ pass_lock_num = init_pass_lock_num; ddr3_tip_if_write(0, ACCESS_TYPE_MULTICAST, PARAM_NOT_CARE, ODPG_DATA_CTRL_REG,@@ -1948,6 +2058,33 @@ int mv_ddr_rl_dqs_burst(u32 dev_num, u32 if_id, u32 freq)CHECK_STATUS (ddr3_tip_write_additional_odt_setting (dev_num, if_id)); } +#if defined(CONFIG_DDR4 ) +/* disable read preamble training mode for all existing chip-selects */ +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +DDR4_MR4_REG , +DDR4_RPT_DIS <<DDR4_RPT_OFFS , +DDR4_RPT_MASK <<DDR4_RPT_OFFS ); + reg_val = (~cs_bitmask &SDRAM_OP_CMD_ALL_CS_MASK ) <<SDRAM_OP_CMD_CS_OFFS (0 ) | +CMD_DDR4_MR4 <<SDRAM_OP_CMD_OFFS ; + reg_mask =SDRAM_OP_CMD_ALL_CS_MASK <<SDRAM_OP_CMD_CS_OFFS (0 ) | +SDRAM_OP_CMD_MASK <<SDRAM_OP_CMD_OFFS ; +ddr3_tip_if_write (0 ,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +SDRAM_OP_REG , reg_val, reg_mask); +if (ddr3_tip_if_polling (0 ,ACCESS_TYPE_UNICAST ,0 , +CMD_NORMAL ,SDRAM_OP_CMD_MASK ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS )) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +/* disable MPR for all existing chip-selects */ + status =mpr_rd_frmt_config (DDR4_MPR_PAGE0 , +DDR4_MPR_OP_DIS , +DDR4_MPR_RF_SERIAL , + cs_bitmask,0 ); +if (status) +return status; +#endif /* CONFIG_DDR4 */ /* reset read fifo assertion */ ddr3_tip_if_write(dev_num, ACCESS_TYPE_MULTICAST, if_id, SDRAM_CFG_REG,drivers/ddr/marvell/a38x/ddr_init.c new file +8
-0@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr3_init.h" + +/* U-BOOT MARVELL 2013.01 SUPPORT */ drivers/ddr/marvell/a38x/ddr_mv_wrapper.h new file +47
-0@@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _DDR_MV_WRAPPER_H +#define _DDR_MV_WRAPPER_H + +#define INTER_REGS_BASE 0xd0000000 + +#include "mv_os.h" +#include "printf.h" +#include "mvUart.h" +#include "util.h" + +typedef unsigned long long uint64_t ; +typedef uint64_t uintptr_t ; + +static inline void mmio_write_64 (uintptr_t addr,uint64_t value) +{ +} + +static inline uint64_t mmio_read_64 (uintptr_t addr) +{ +return (uint64_t )0 ; +} + +/* u-boot/tools/marvell/bin_hdr/platform/utils/printf.c */ +#define printf mvPrintf + +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) +#define reg_write MV_REG_WRITE +#define reg_read MV_REG_READ +#define reg_bit_set MV_REG_BIT_SET + +/* uboot/tools/marvell/bin_hdr/platform/drivers/mv_time.c */ +void mdelay (unsigned long ); + +/* TODO: Check if LE/BE support is needed */ +#define MV_MEMIO_LE32_WRITE2 (data,addr) \ + MV_MEMIO32_WRITE(addr, MV_32BIT_LE_FAST(data)) +#define writel MV_MEMIO_LE32_WRITE2 +#define readl MV_MEMIO_LE32_READ +#define writeq mmio_write_64 +#define readq mmio_read_64 + +#endif /* _DDR_MV_WRAPPER_H */ drivers/ddr/marvell/a38x/dram_if.c new file +31
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr_ml_wrapper.h" + +#include "mv_ddr_init.h" +#include "mv_ddr_plat.h" +#include "mv_ddr_topology.h" + +int dram_init (void ) +{ +return mv_ddr_init (); +} + +void dram_mmap_config (void ) +{ +mv_ddr_mmap_config (); +} + +unsigned long long dram_iface_mem_sz_get (void ) +{ +/* +* call mv_ddr_pre_config to update topology +* prior to mv_ddr_mem_sz_get call +*/ +mv_ddr_pre_config (); + +return mv_ddr_mem_sz_get (); +}drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c new file +674
-0@@ -0,0 +1,674 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#if defined(CONFIG_DDR4 ) + +/* DDR4 MPR/PDA Interface */ +#include "ddr3_init.h" +#include "mv_ddr4_mpr_pda_if.h" +#include "mv_ddr4_training.h" +#include "mv_ddr_training_db.h" +#include "mv_ddr_common.h" +#include "mv_ddr_regs.h" + +static u8 dram_to_mc_dq_map[MAX_BUS_NUM ][BUS_WIDTH_IN_BITS ]; +static int dq_map_enable; + +static u32 mv_ddr4_tx_odt_get (void ) +{ +u16 odt =0xffff , rtt =0xffff ; + +if (g_odt_config &0xe0000 ) + rtt =mv_ddr4_rtt_nom_to_odt (g_rtt_nom); +else if (g_odt_config &0x10000 ) + rtt =mv_ddr4_rtt_wr_to_odt (g_rtt_wr); +else +return odt; + +return (odt * rtt) / (odt + rtt); +} + +/* +* mode registers initialization function +* replaces all MR writes in DDR3 init function +*/ +int mv_ddr4_mode_regs_init (u8 dev_num) +{ +int status; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +enum hws_access_type access_type =ACCESS_TYPE_UNICAST ; +u32 if_id; +u32 cl, cwl; +u32 val, mask; +u32 t_wr, t_ckclk; +/* design GL params to be set outside */ +u32 dic =0 ; +u32 ron =30 ;/* znri */ +u32 rodt =mv_ddr4_tx_odt_get ();/* effective rtt */ +/* vref percentage presented as 100 x percentage value (e.g., 6000 = 100 x 60%) */ +u32 vref = ((ron + rodt /2 ) *10000 ) / (ron + rodt); +u32 range = (vref >=6000 ) ?0 :1 ;/* if vref is >= 60%, use upper range */ +u32 tap; +u32 refresh_mode; + +if (range ==0 ) + tap = (vref -6000 ) /65 ; +else + tap = (vref -4500 ) /65 ; + +for (if_id =0 ; if_id <MAX_INTERFACE_NUM ; if_id++) { +VALIDATE_IF_ACTIVE (tm->if_act_mask, if_id); + cl = tm->interface_params[if_id].cas_l; + cwl = tm->interface_params[if_id].cas_wl; + t_ckclk =MEGA /mv_ddr_freq_get (tm->interface_params[if_id].memory_freq); + t_wr =time_to_nclk (mv_ddr_speed_bin_timing_get (tm->interface_params[if_id].speed_bin_index, +SPEED_BIN_TWR ), t_ckclk) -1 ; + +/* TODO: replace hard-coded values with appropriate defines */ +/* DDR4 MR0 */ +/* +* [6:4,2] bits to be taken from S@R frequency and speed bin +* rtt_nom to be taken from the algorithm definition +* dic to be taken fro the algorithm definition - +* set to 0x1 (for driver rzq/5 = 48 ohm) or +* set to 0x0 (for driver rzq/7 = 34 ohm) +*/ +/* set dll reset, 0x1900[8] to 0x1 */ +/* set tm, 0x1900[7] to 0x0 */ +/* set rbt, 0x1900[3] to 0x0 */ +/* set bl, 0x1900[1:0] to 0x0 */ + val = ((cl_mask_table[cl] &0x1 ) <<2 ) | + (((cl_mask_table[cl] &0xe ) >>1 ) <<4 ) | + (twr_mask_table[t_wr +1 ] <<9 ) | + (0x1 <<8 ) | (0x0 <<7 ) | (0x0 <<3 ) |0x0 ; + mask = (0x1 <<2 ) | (0x7 <<4 ) | (0x7 <<9 ) | + (0x1 <<8 ) | (0x1 <<7 ) | (0x1 <<3 ) |0x3 ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR0_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR1 */ +/* set rtt nom to 0 if rtt park is activated (not zero) */ +if ((g_rtt_park >>6 ) !=0x0 ) + g_rtt_nom =0 ; +/* set tdqs, 0x1904[11] to 0x0 */ +/* set al, 0x1904[4:3] to 0x0 */ +/* dic, 0x1904[2:1] */ +/* dll enable */ + val = g_rtt_nom | (0x0 <<11 ) | (0x0 <<3 ) | (dic <<1 ) |0x1 ; + mask = (0x7 <<8 ) | (0x1 <<11 ) | (0x3 <<3 ) | (0x3 <<1 ) |0x1 ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR1_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR2 */ +/* set rtt wr, 0x1908[10,9] to 0x0 */ +/* set wr crc, 0x1908[12] to 0x0 */ +/* cwl */ + val = g_rtt_wr | (0x0 <<12 ) | (cwl_mask_table[cwl] <<3 ); + mask = (0x3 <<9 ) | (0x1 <<12 ) | (0x7 <<3 ); + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR2_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR3 */ +/* set fgrm, 0x190C[8:6] to 0x0 */ +/* set gd, 0x190C[3] to 0x0 */ + refresh_mode = (tm->interface_params[if_id].interface_temp ==MV_DDR_TEMP_HIGH ) ?1 :0 ; + + val = (refresh_mode <<6 ) | (0x0 <<3 ); + mask = (0x7 <<6 ) | (0x1 <<3 ); + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR3_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR4 */ +/* +* set wp, 0x1910[12] to 0x0 +* set rp, 0x1910[11] to 0x0 +* set rp training, 0x1910[10] to 0x0 +* set sra, 0x1910[9] to 0x0 +* set cs2cmd, 0x1910[8:6] to 0x0 +* set mpd, 0x1910[1] to 0x0 +*/ + mask = (0x1 <<12 ) | (0x1 <<11 ) | (0x1 <<10 ) | (0x1 <<9 ) | (0x7 <<6 ) | (0x1 <<1 ); + val = (0x0 <<12 ) | (0x1 <<11 ) | (0x0 <<10 ) | (0x0 <<9 ) | (0x0 <<6 ) | (0x0 <<1 ); + + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR4_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR5 */ +/* +* set rdbi, 0x1914[12] to 0x0 during init sequence (may be enabled with +* op cmd mrs - bug in z1, to be fixed in a0) +* set wdbi, 0x1914[11] to 0x0 +* set dm, 0x1914[10] to 0x1 +* set ca_pl, 0x1914[2:0] to 0x0 +* set odt input buffer during power down mode, 0x1914[5] to 0x1 +*/ + mask = (0x1 <<12 ) | (0x1 <<11 ) | (0x1 <<10 ) | (0x7 <<6 ) | (0x1 <<5 ) |0x7 ; + val = (0x0 <<12 ) | (0x0 <<11 ) | (0x1 <<10 ) | g_rtt_park | (0x1 <<5 ) |0x0 ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR5_REG , + val, mask); +if (status !=MV_OK ) +return status; + +/* DDR4 MR6 */ +/* +* set t_ccd_l, 0x1918[12:10] to 0x0, 0x2, or 0x4 (z1 supports only even +* values, to be fixed in a0) +* set vdq te, 0x1918[7] to 0x0 +* set vdq tv, 0x1918[5:0] to vref training value +*/ + mask = (0x7 <<10 ) | (0x1 <<7 ) | (0x1 <<6 ) |0x3f ; + val = (0x2 <<10 ) | (0x0 <<7 ) | (range <<6 ) | tap; + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR6_REG , + val, mask); +if (status !=MV_OK ) +return status; + } + +return MV_OK ; +} + +/* enter mpr read mode */ +static int mv_ddr4_mpr_read_mode_enable (u8 dev_num,u32 mpr_num,u32 page_num, +enum mv_ddr4_mpr_read_format read_format) +{ +/* +* enable MPR page 2 mpr mode in DDR4 MR3 +* read_format: 0 for serial, 1 for parallel, and 2 for staggered +* TODO: add support for cs, multicast or unicast, and if id +*/ +int status; +u32 val, mask, if_id =0 ; + +if (page_num !=0 ) { +/* serial is the only read format if the page is other than 0 */ + read_format =MV_DDR4_MPR_READ_SERIAL ; + } + + val = (page_num <<0 ) | (0x1 <<2 ) | (read_format <<11 ); + mask = (0x3 <<0 ) | (0x1 <<2 ) | (0x3 <<11 ); + +/* cs0 */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DDR4_MR3_REG , val, mask); +if (status !=MV_OK ) +return status; + +/* op cmd: cs0, cs1 are on, cs2, cs3 are off */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,SDRAM_OP_REG , + (0x9 | (0xc <<8 )) , (0x1f | (0xf <<8 ))); +if (status !=MV_OK ) +return status; + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1f ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_mpr_read_mode_enable: DDR3 poll failed(MPR3)\n" )); + } + +return MV_OK ; +} + +/* exit mpr read or write mode */ +static int mv_ddr4_mpr_mode_disable (u8 dev_num) +{ +/* TODO: add support for cs, multicast or unicast, and if id */ +int status; +u32 val, mask, if_id =0 ; + +/* exit mpr */ + val =0x0 <<2 ; + mask =0x1 <<2 ; +/* cs0 */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DDR4_MR3_REG , val, mask); +if (status !=MV_OK ) +return status; + +/* op cmd: cs0, cs1 are on, cs2, cs3 are off */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,SDRAM_OP_REG , + (0x9 | (0xc <<8 )) , (0x1f | (0xf <<8 ))); +if (status !=MV_OK ) +return status; + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1f ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_mpr_mode_disable: DDR3 poll failed(MPR3)\n" )); + } + +return MV_OK ; +} + +/* translate dq read value per dram dq pin */ +static int mv_ddr4_dq_decode (u8 dev_num,u32 *data) +{ +u32 subphy_num, dq_num; +u32 dq_val =0 , raw_data, idx; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +u32 subphy_max =ddr3_tip_dev_attr_get (dev_num,MV_ATTR_OCTET_PER_INTERFACE ); + +/* suppose the third word is stable */ + raw_data = data[2 ]; + +/* skip ecc supbhy; TODO: check to add support for ecc */ +if (subphy_max %2 ) + subphy_max -=1 ; + +for (subphy_num =0 ; subphy_num < subphy_max; subphy_num++) { +VALIDATE_BUS_ACTIVE (tm->bus_act_mask, subphy_num); +for (dq_num =0 ; dq_num <BUS_WIDTH_IN_BITS ; dq_num++) { + idx = (dram_to_mc_dq_map[subphy_num][dq_num] + (subphy_num *BUS_WIDTH_IN_BITS )); + dq_val |= (((raw_data & (1 << idx)) >> idx) << ((subphy_num *BUS_WIDTH_IN_BITS ) + dq_num)); + } + } + +/* update burst words[0..7] with correct mapping */ +for (idx =0 ; idx <EXT_ACCESS_BURST_LENGTH ; idx++) + data[idx] = dq_val; + +return MV_OK ; +} + +/* +* read mpr value per requested format and type +* note: for parallel decoded read, data is presented as stored in mpr on dram side, +* for all others, data to be presneted "as is" (i.e. per dq order from high to low +* and bus pins connectivity). +*/ +int mv_ddr4_mpr_read (u8 dev_num,u32 mpr_num,u32 page_num, +enum mv_ddr4_mpr_read_format read_format, +enum mv_ddr4_mpr_read_type read_type, +u32 *data) +{ +/* TODO: add support for multiple if_id, dev num, and cs */ +u32 word_idx, if_id =0 ; +volatile unsigned long *addr =NULL ; + +/* enter mpr read mode */ +mv_ddr4_mpr_read_mode_enable (dev_num, mpr_num, page_num, read_format); + +/* set pattern type*/ +ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DDR4_MPR_WR_REG , + mpr_num <<8 ,0x3 <<8 ); + +for (word_idx =0 ; word_idx <EXT_ACCESS_BURST_LENGTH ; word_idx++) { + data[word_idx] = *addr; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("mv_ddr4_mpr_read: addr 0x%08lx, data 0x%08x\n" , + (unsigned long )addr, data[word_idx])); + addr++; + } + +/* exit mpr read mode */ +mv_ddr4_mpr_mode_disable (dev_num); + +/* decode mpr read value (only parallel mode supported) */ +if ((read_type ==MV_DDR4_MPR_READ_DECODED ) && (read_format ==MV_DDR4_MPR_READ_PARALLEL )) { +if (dq_map_enable ==1 ) { +mv_ddr4_dq_decode (dev_num, data); + }else { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_mpr_read: run mv_ddr4_dq_pins_mapping()\n" )); +return MV_FAIL ; + } + } + +return MV_OK ; +} + +/* enter mpr write mode */ +static int mv_ddr4_mpr_write_mode_enable (u8 dev_num,u32 mpr_location,u32 page_num,u32 data) +{ +/* +* enable MPR page 2 mpr mode in DDR4 MR3 +* TODO: add support for cs, multicast or unicast, and if id +*/ +int status; +u32 if_id =0 , val =0 , mask; + + val = (page_num <<0 ) | (0x1 <<2 ); + mask = (0x3 <<0 ) | (0x1 <<2 ); +/* cs0 */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DDR4_MR3_REG , val, mask); +if (status !=MV_OK ) +return status; + +/* cs0 */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DDR4_MPR_WR_REG , + (mpr_location <<8 ) | data,0x3ff ); +if (status !=MV_OK ) +return status; + +/* op cmd: cs0, cs1 are on, cs2, cs3 are off */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,SDRAM_OP_REG , + (0x13 |0xc <<8 ) , (0x1f | (0xf <<8 ))); +if (status !=MV_OK ) +return status; + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1f ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_mpr_write_mode_enable: DDR3 poll failed(MPR3)\n" )); + } + +return MV_OK ; +} + +/* write mpr value */ +int mv_ddr4_mpr_write (u8 dev_num,u32 mpr_location,u32 mpr_num,u32 page_num,u32 data) +{ +/* enter mpr write mode */ +mv_ddr4_mpr_write_mode_enable (dev_num, mpr_location, page_num, data); + +/* TODO: implement this function */ + +/* TODO: exit mpr write mode */ + +return MV_OK ; +} + +/* +* map physical on-board connection of dram dq pins to ddr4 controller pins +* note: supports only 32b width +* TODO: add support for 64-bit bus width and ecc subphy +*/ +int mv_ddr4_dq_pins_mapping (u8 dev_num) +{ +static int run_once; +u8 dq_val[MAX_BUS_NUM ][BUS_WIDTH_IN_BITS ] = { {0 } }; +u32 mpr_pattern[MV_DDR4_MPR_READ_PATTERN_NUM ][EXT_ACCESS_BURST_LENGTH ] = { {0 } }; +u32 subphy_num, dq_num, mpr_type; +u8 subphy_pattern[3 ]; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +u32 subphy_max =ddr3_tip_dev_attr_get (dev_num,MV_ATTR_OCTET_PER_INTERFACE ); + +if (run_once) +return MV_OK ; +else + run_once++; + +/* clear dq mapping */ +memset (dram_to_mc_dq_map,0 ,sizeof (dram_to_mc_dq_map)); + +/* stage 1: read page 0 mpr0..2 raw patterns */ +for (mpr_type =0 ; mpr_type <MV_DDR4_MPR_READ_PATTERN_NUM ; mpr_type++) +mv_ddr4_mpr_read (dev_num, mpr_type,0 ,MV_DDR4_MPR_READ_PARALLEL , +MV_DDR4_MPR_READ_RAW , mpr_pattern[mpr_type]); + +/* stage 2: map every dq for each subphy to 3-bit value, create local database */ +/* skip ecc supbhy; TODO: check to add support for ecc */ +if (subphy_max %2 ) + subphy_max -=1 ; + +for (subphy_num =0 ; subphy_num < subphy_max; subphy_num++) { +VALIDATE_BUS_ACTIVE (tm->bus_act_mask, subphy_num); +/* extract pattern for each subphy */ +for (mpr_type =0 ; mpr_type <MV_DDR4_MPR_READ_PATTERN_NUM ; mpr_type++) + subphy_pattern[mpr_type] = ((mpr_pattern[mpr_type][2 ] >> (subphy_num *8 )) &0xff ); + +for (dq_num =0 ; dq_num <BUS_WIDTH_IN_BITS ; dq_num++) +for (mpr_type =0 ; mpr_type <MV_DDR4_MPR_READ_PATTERN_NUM ; mpr_type++) + dq_val[subphy_num][dq_num] += (((subphy_pattern[mpr_type] >> dq_num) &1 ) * + (1 << mpr_type)); + } + +/* stage 3: map dram dq to mc dq and update database */ +for (subphy_num =0 ; subphy_num < subphy_max; subphy_num++) { +VALIDATE_BUS_ACTIVE (tm->bus_act_mask, subphy_num); +for (dq_num =0 ; dq_num <BUS_WIDTH_IN_BITS ; dq_num++) + dram_to_mc_dq_map[subphy_num][7 - dq_val[subphy_num][dq_num]] = dq_num; + } + +/* set dq_map_enable */ + dq_map_enable =1 ; + +return MV_OK ; +} + +/* enter to or exit from dram vref training mode */ +int mv_ddr4_vref_training_mode_ctrl (u8 dev_num,u8 if_id,enum hws_access_type access_type,int enable) +{ +int status; +u32 val, mask; + +/* DDR4 MR6 */ +/* +* set t_ccd_l, 0x1918[12:10] to 0x0, 0x2, or 0x4 (z1 supports only even +* values, to be fixed in a0) +* set vdq te, 0x1918[7] to 0x0 +* set vdq tv, 0x1918[5:0] to vref training value +*/ + + val = (((enable ==1 ) ?1 :0 ) <<7 ); + mask = (0x1 <<7 ); + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR6_REG , val, mask); +if (status !=MV_OK ) +return status; + +/* write DDR4 MR6 cs configuration; only cs0, cs1 supported */ +if (effective_cs ==0 ) + val =0xe ; +else + val =0xd ; + val <<=8 ; +/* write DDR4 MR6 command */ + val |=0x12 ; + mask = (0xf <<8 ) |0x1f ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,SDRAM_OP_REG , val, mask); +if (status !=MV_OK ) +return status; + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1f ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_vref_training_mode_ctrl: Polling command failed\n" )); + } + +return MV_OK ; +} + +/* set dram vref tap value */ +int mv_ddr4_vref_tap_set (u8 dev_num,u8 if_id,enum hws_access_type access_type, +u32 taps_num,enum mv_ddr4_vref_tap_state state) +{ +int status; +u32 range, vdq_tv; + +/* disable and then enable the training with a new range */ +if ((state ==MV_DDR4_VREF_TAP_BUSY ) && ((taps_num +MV_DDR4_VREF_STEP_SIZE ) >=23 ) && + (taps_num <23 )) + state =MV_DDR4_VREF_TAP_FLIP ; + +if (taps_num <23 ) { + range =1 ; + vdq_tv = taps_num; + }else { + range =0 ; + vdq_tv = taps_num -23 ; + } + +if ((state ==MV_DDR4_VREF_TAP_FLIP ) | (state ==MV_DDR4_VREF_TAP_START )) { +/* 0 to disable */ + status =mv_ddr4_vref_set (dev_num, if_id, access_type, range, vdq_tv,0 ); +if (status !=MV_OK ) +return status; +/* 1 to enable */ + status = (mv_ddr4_vref_set (dev_num, if_id, access_type, range, vdq_tv,1 )); +if (status !=MV_OK ) +return status; + }else if (state ==MV_DDR4_VREF_TAP_END ) { +/* 1 to enable */ + status = (mv_ddr4_vref_set (dev_num, if_id, access_type, range, vdq_tv,1 )); +if (status !=MV_OK ) +return status; +/* 0 to disable */ + status =mv_ddr4_vref_set (dev_num, if_id, access_type, range, vdq_tv,0 ); +if (status !=MV_OK ) +return status; + }else { +/* 1 to enable */ + status = (mv_ddr4_vref_set (dev_num, if_id, access_type, range, vdq_tv,1 )); +if (status !=MV_OK ) +return status; + } + +return MV_OK ; +} + +/* set dram vref value */ +int mv_ddr4_vref_set (u8 dev_num,u8 if_id,enum hws_access_type access_type, +u32 range,u32 vdq_tv,u8 vdq_training_ena) +{ +int status; +u32 read_data; +u32 val, mask; + +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("mv_ddr4_vref_set: range %d, vdq_tv %d\n" , range, vdq_tv)); + +/* DDR4 MR6 */ +/* +* set t_ccd_l, 0x1918[12:10] to 0x0, 0x2, or 0x4 (z1 supports only even +* values, to be fixed in a0) +* set vdq te, 0x1918[7] to 0x0 +* set vdq tr, 0x1918[6] to 0x0 to disable or 0x1 to enable +* set vdq tv, 0x1918[5:0] to vref training value +*/ + val = (vdq_training_ena <<7 ) | (range <<6 ) | vdq_tv; + mask = (0x0 <<7 ) | (0x1 <<6 ) |0x3f ; + + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR6_REG , val, mask); +if (status !=MV_OK ) +return status; + +ddr3_tip_if_read (dev_num, access_type, if_id,DDR4_MR6_REG , &read_data,0xffffffff ); +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("mv_ddr4_vref_set: MR6 = 0x%x\n" , read_data)); + +/* write DDR4 MR6 cs configuration; only cs0, cs1 supported */ +if (effective_cs ==0 ) + val =0xe ; +else + val =0xd ; + val <<=8 ; +/* write DDR4 MR6 command */ + val |=0x12 ; + mask = (0xf <<8 ) |0x1f ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,SDRAM_OP_REG , val, mask); +if (status !=MV_OK ) +return status; + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1F ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_vref_set: Polling command failed\n" )); + } + +return MV_OK ; +} + +/* pda - load pattern to odpg */ +int mv_ddr4_pda_pattern_odpg_load (u32 dev_num,enum hws_access_type access_type, +u32 if_id,u32 subphy_mask,u32 cs_num) +{ +int status; +u32 pattern_len_count =0 ; +u32 data_low[KILLER_PATTERN_LENGTH ] = {0 }; +u32 data_high[KILLER_PATTERN_LENGTH ] = {0 }; +u32 val, mask, subphy_num; + +/* +* set 0x1630[10:5] bits to 0x3 (0x1 for 16-bit bus width) +* set 0x1630[14:11] bits to 0x3 (0x1 for 16-bit bus width) +*/ + val = (cs_num <<26 ) | (0x1 <<25 ) | (0x3 <<11 ) | (0x3 <<5 ) |0x1 ; + mask = (0x3 <<26 ) | (0x1 <<25 ) | (0x3f <<11 ) | (0x3f <<5 ) |0x1 ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,ODPG_DATA_CTRL_REG , val, mask); +if (status !=MV_OK ) +return status; + +if (subphy_mask !=0xf ) { +for (subphy_num =0 ; subphy_num <4 ; subphy_num++) +if (((subphy_mask >> subphy_num) &0x1 ) ==0 ) + data_low[0 ] = (data_low[0 ] | (0xff << (subphy_num *8 ))); + }else + data_low[0 ] =0 ; + +for (pattern_len_count =0 ; pattern_len_count <4 ; pattern_len_count++) { + data_low[pattern_len_count] = data_low[0 ]; + data_high[pattern_len_count] = data_low[0 ]; + } + +for (pattern_len_count =0 ; pattern_len_count <4 ; pattern_len_count++) { + status =ddr3_tip_if_write (dev_num, access_type, if_id,ODPG_DATA_WR_DATA_LOW_REG , + data_low[pattern_len_count],MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_if_write (dev_num, access_type, if_id,ODPG_DATA_WR_DATA_HIGH_REG , + data_high[pattern_len_count],MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_if_write (dev_num, access_type, if_id,ODPG_DATA_WR_ADDR_REG , + pattern_len_count,MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + } + + status =ddr3_tip_if_write (dev_num, access_type, if_id,ODPG_DATA_BUFFER_OFFS_REG , +0x0 ,MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + +return MV_OK ; +} + +/* enable or disable pda */ +int mv_ddr4_pda_ctrl (u8 dev_num,u8 if_id,u8 cs_num,int enable) +{ +/* +* if enable is 0, exit +* mrs to be directed to all dram devices +* a calling function responsible to change odpg to 0x0 +*/ + +int status; +enum hws_access_type access_type =ACCESS_TYPE_UNICAST ; +u32 val, mask; + +/* per dram addressability enable */ + val = ((enable ==1 ) ?1 :0 ); + val <<=4 ; + mask =0x1 <<4 ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,DDR4_MR3_REG , val, mask); +if (status !=MV_OK ) +return status; + +/* write DDR4 MR3 cs configuration; only cs0, cs1 supported */ +if (cs_num ==0 ) + val =0xe ; +else + val =0xd ; + val <<=8 ; +/* write DDR4 MR3 command */ + val |=0x9 ; + mask = (0xf <<8 ) |0x1f ; + status =ddr3_tip_if_write (dev_num, access_type, if_id,SDRAM_OP_REG , val, mask); +if (status !=MV_OK ) +return status; + +if (enable ==0 ) { +/* check odpg access is done */ +if (mv_ddr_is_odpg_done (MAX_POLLING_ITERATIONS ) !=MV_OK ) +return MV_FAIL ; + } + +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0 ,0x1f ,SDRAM_OP_REG , +MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_pda_ctrl: Polling command failed\n" )); + +return MV_OK ; +} +#endif /* CONFIG_DDR4 */ drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h new file +59
-0@@ -0,0 +1,59 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _MV_DDR4_MPR_PDA_IF_H +#define _MV_DDR4_MPR_PDA_IF_H + +#include "ddr3_init.h" +#include "mv_ddr_common.h" + +#define MV_DDR4_VREF_STEP_SIZE 3 +#define MV_DDR4_VREF_MIN_RANGE 1 +#define MV_DDR4_VREF_MAX_RANGE 73 +#define MV_DDR4_VREF_MAX_COUNT (((MV_DDR4_VREF_MAX_RANGE - MV_DDR4_VREF_MIN_RANGE) / MV_DDR4_VREF_STEP_SIZE) + 2) + +#define MV_DDR4_MPR_READ_PATTERN_NUM 3 + +enum mv_ddr4_mpr_read_format { +MV_DDR4_MPR_READ_SERIAL , +MV_DDR4_MPR_READ_PARALLEL , +MV_DDR4_MPR_READ_STAGGERED , +MV_DDR4_MPR_READ_RSVD_TEMP +}; + +enum mv_ddr4_mpr_read_type { +MV_DDR4_MPR_READ_RAW , +MV_DDR4_MPR_READ_DECODED +}; + +enum mv_ddr4_vref_tap_state { +MV_DDR4_VREF_TAP_START , +MV_DDR4_VREF_TAP_BUSY , +MV_DDR4_VREF_TAP_FLIP , +MV_DDR4_VREF_TAP_END +}; + +int mv_ddr4_mode_regs_init (u8 dev_num); +int mv_ddr4_mpr_read (u8 dev_num,u32 mpr_num,u32 page_num, +enum mv_ddr4_mpr_read_format read_format, +enum mv_ddr4_mpr_read_type read_type, +u32 *data); +int mv_ddr4_mpr_write (u8 dev_num,u32 mpr_location,u32 mpr_num, +u32 page_num,u32 data); +int mv_ddr4_dq_pins_mapping (u8 dev_num); +int mv_ddr4_vref_training_mode_ctrl (u8 dev_num,u8 if_id, +enum hws_access_type access_type, +int enable); +int mv_ddr4_vref_tap_set (u8 dev_num,u8 if_id, +enum hws_access_type access_type, +u32 taps_num, +enum mv_ddr4_vref_tap_state state); +int mv_ddr4_vref_set (u8 dev_num,u8 if_id,enum hws_access_type access_type, +u32 range,u32 vdq_tv,u8 vdq_training_ena); +int mv_ddr4_pda_pattern_odpg_load (u32 dev_num,enum hws_access_type access_type, +u32 if_id,u32 subphy_mask,u32 cs_num); +int mv_ddr4_pda_ctrl (u8 dev_num,u8 if_id,u8 cs_num,int enable); + +#endif /* _MV_DDR4_MPR_PDA_IF_H */ drivers/ddr/marvell/a38x/mv_ddr4_training.c new file +571
-0@@ -0,0 +1,571 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#if defined(CONFIG_DDR4 ) + +/* DDR4 training service API and data structures */ + +#include "ddr3_init.h" +#include "mv_ddr4_training.h" +#include "mv_ddr4_mpr_pda_if.h" +#include "mv_ddr4_training_leveling.h" +#include "mv_ddr4_training_calibration.h" +#include "mv_ddr_regs.h" + +/* 1 for wa and sstl and pod to get the same vref value */ +u8 vref_calibration_wa =1 ; + +#if defined(CONFIG_ARMADA_39X ) || defined(CONFIG_ARMADA_38X ) +static int a39x_z1_config (u32 dev_num); +#endif + +/* vref values for vcommon */ +static u16 vref_val[] = { +746 , +654 , +671 , +686 , +701 , +713 , +725 , +736 +}; + +static u32 mv_ddr4_config_phy_vref_tap; + +/* configure DDR4 SDRAM */ +int mv_ddr4_sdram_config (u32 dev_num) +{ +/* TODO: zq params to be frequency dependent */ +u32 zq_init =1023 ; +u32 zq_oper =511 ; +u32 zq_cs =127 ; +u32 if_id; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +int status; + +for (if_id =0 ; if_id <MAX_INTERFACE_NUM ; if_id++) { +VALIDATE_IF_ACTIVE (tm->if_act_mask, if_id); + +/* dtype: 0x3 for DDR4, 0x1 for DDR3 */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,SDRAM_CFG_REG , + (0x1 <<14 ) | (0x1 <<20 ), (0x1 <<14 ) | (0x1 <<20 )); +if (status !=MV_OK ) +return status; + +/* cpm */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DRAM_PINS_MUX_REG , +0x2 ,0x3 ); +if (status !=MV_OK ) +return status; + +/* +* set t_dllk to 1024 to the maximum of minimum for high speed bin +* TODO: may change for future speed bins +*/ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DRAM_DLL_TIMING_REG , +0x400 ,0xfff ); +if (status !=MV_OK ) +return status; + +/* set zq_init */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DRAM_ZQ_INIT_TIMIMG_REG , + zq_init,0xfff ); +if (status !=MV_OK ) +return status; + +/* set zq_oper */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DRAM_ZQ_TIMING_REG , + zq_oper,0x7ff ); +if (status !=MV_OK ) +return status; + +/* set zq_cs */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,DRAM_ZQ_TIMING_REG , + zq_cs <<16 ,0x3ff0000 ); +if (status !=MV_OK ) +return status; + +/* +* set registered dimm to unbuffered dimm +* TODO: support registered dimm +*/ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,SDRAM_CFG_REG , +0x0 ,0x1 <<17 ); +if (status !=MV_OK ) +return status; + } + +#if defined(CONFIG_ARMADA_39X ) || defined(CONFIG_ARMADA_38X ) +a39x_z1_config (dev_num); +#endif + +return MV_OK ; +} + +u16 mv_ddr4_rtt_nom_to_odt (u16 rtt_nom) +{ +u8 odt; + +if (rtt_nom ==0 ) + odt =0xff ; +else if (rtt_nom == (1 <<8 )) + odt =60 ;/* 240 / 4 */ +else if (rtt_nom == (2 <<8 )) + odt =120 ;/* 240 / 2 */ +else if (rtt_nom == (3 <<8 )) + odt =40 ;/* 240 / 6 */ +else if (rtt_nom == (4 <<8 )) + odt =240 ;/* 240 / 1 */ +else if (rtt_nom == (5 <<8 )) + odt =48 ;/* 240 / 5 */ +else if (rtt_nom == (6 <<8 )) + odt =80 ;/* 240 / 3 */ +else if (rtt_nom == (7 <<8 )) + odt =34 ;/* 240 / 7 */ +else + odt =1 ; + +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("mv_ddr4_rtt_nom_to_odt: rtt_nom = %d, odt = %d\n" , rtt_nom, odt)); + +return odt; +} + +u16 mv_ddr4_rtt_wr_to_odt (u16 rtt_wr) +{ +u8 odt; + +if (rtt_wr ==0 ) + odt =0xff ; +else if (rtt_wr == (1 <<9 )) + odt =120 ;/* 240 / 2 */ +else if (rtt_wr == (2 <<9 )) + odt =240 ;/* 240 / 1 */ +else + odt =1 ; + +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("mv_ddr4_rtt_wr_to_odt rtt_wr = %d, odt = %d\n" , rtt_wr, odt)); + +return odt; +} + +static u32 mv_ddr4_rx_odt_get (void ) +{ +u16 odt = odt_intercept[(int )g_zpodt_data /8 ] - (g_zpodt_data * odt_slope[(int )g_zpodt_data /8 ]) /100 ; +u16 rtt; + +if (g_odt_config &0xf ) { + rtt =mv_ddr4_rtt_nom_to_odt (g_rtt_nom); + odt = (odt * rtt) / (odt + rtt); + } + +return odt; +} + +static u8 mv_ddr4_vcommon_to_vref (u16 vcommon) +{ +u8 vref_tap; + +if ((vcommon >600 ) && (vcommon <=662 )) { + vref_tap =1 ; + }else if ((vcommon >662 ) && (vcommon <=679 )) { + vref_tap =2 ; + }else if ((vcommon >679 ) && (vcommon <=693 )) { + vref_tap =3 ; + }else if ((vcommon >693 ) && (vcommon <=707 )) { + vref_tap =4 ; + }else if ((vcommon >707 ) && (vcommon <=719 )) { + vref_tap =5 ; + }else if ((vcommon >719 ) && (vcommon <=725 )) { + vref_tap =6 ; + }else if ((vcommon >725 ) && (vcommon <=731 )) { + vref_tap =7 ; + }else if ((vcommon >731 ) && (vcommon <=800 )) { + vref_tap =0 ; + }else if (vcommon >800 ) { + vref_tap =0 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_vcommon_to_vref: warning: vcommon value too high: %d\n" , vcommon)); + }else if (vcommon <600 ) { + vref_tap =1 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_vcommon_to_vref: warning: vcommon value too low: %d\n" , vcommon)); + }else { + vref_tap =1 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_vcommon_to_vref: warning: vcommon out of range: %d\n" , vcommon)); + } + +return vref_tap; +} + +/* configure phy */ +int mv_ddr4_phy_config (u32 dev_num) +{ +u8 cs, i, pod_val; +u32 upper_pcal, left_pcal, upper_ncal; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +/* design GL params to be set outside */ +u32 ron =34 ;/* dic - rzq / 6 or rzq / 7 */ +u32 rodt =mv_ddr4_rx_odt_get ();/* effective odt per DGL */ +u32 vcommon = (1000 * (ron + rodt /2 )) / (ron + rodt); +u32 vref_idx; +u8 rc_tap; +u8 subphy_max =ddr3_tip_dev_attr_get (dev_num,MV_ATTR_OCTET_PER_INTERFACE ); +int status; + + mv_ddr4_config_phy_vref_tap =mv_ddr4_vcommon_to_vref (vcommon); + +/* change calculation for 1GHz frequency */ +if (tm->interface_params[0 ].memory_freq ==MV_DDR_FREQ_1000 ) + mv_ddr4_config_phy_vref_tap +=2 ; + + vref_idx = (mv_ddr4_config_phy_vref_tap <8 ) ? mv_ddr4_config_phy_vref_tap :0 ; + rc_tap = (430 * (vref_val[vref_idx] - vcommon)) /1000 +33 ; +/* 0x1 for pod mode */ + pod_val = (vref_calibration_wa ==1 ) ?0x0 :0x1 ; + upper_pcal = pod_val; + left_pcal = pod_val; + upper_ncal =0 ; + + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_DATA ,TEST_ADLL_PHY_REG , pod_val); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,GP_RSVD0_REG , + (upper_pcal <<12 ) | (left_pcal <<6 ) | (upper_ncal <<5 ),0x1060 ); +if (status !=MV_OK ) +return status; + +/* +* phy register 0xbf, bit 0 - configure to pod mode (0x1) +* phy register 0xa8, bits [6:4] - configure to clamp (0x0) +* subphys (broadcast) register 0xa8, bits [2:0] - configure to int ref m (0x4), +* TODO: need to write it to control subphys too +* vref tap - configure to SSTL calibration only (4) +* enhanced vref value - set to no clamp (0) +*/ +for (i =0 ; i < subphy_max; i++) { +VALIDATE_BUS_ACTIVE (tm->bus_act_mask, i); +ddr3_tip_bus_read_modify_write (dev_num,ACCESS_TYPE_UNICAST ,0 , i,DDR_PHY_DATA ,PAD_CFG_PHY_REG , + (0 <<4 ) |4 , ((0x7 <<4 ) |0x7 )); + } + +for (i =0 ; i <3 ; i++) +ddr3_tip_bus_read_modify_write (dev_num,ACCESS_TYPE_UNICAST ,0 , i,DDR_PHY_CONTROL ,PAD_CFG_PHY_REG , + (0 <<4 ) |4 , ((0x7 <<4 ) |0x7 )); + +/* phy register 0xa4, bits [13:7] - configure to 0x7c zpri /znri */ + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_DATA ,PAD_ZRI_CAL_PHY_REG , + ((0x7f & g_zpri_data) <<7 ) | (0x7f & g_znri_data)); +if (status !=MV_OK ) +return status; + +/* +* phy register 0xa6, bits [5:0] - configure to znodt (0x0) +* phy register 0xa6 bits [11:6] - configure to zpodt (60Ohm, 0x1d) +*/ + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_DATA ,PAD_ODT_CAL_PHY_REG , g_zpodt_data <<6 ); +if (status !=MV_OK ) +return status; + +/* update for all active cs */ +for (cs =0 ; cs <MAX_CS_NUM ; cs++) { +/* +* writes to present cs only +* phy register 0xdb, bits [5:0] - configure to rcvr cal for 50% duty cycle, +* broadcast to all bits cs0 (0x26) +*/ + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_DATA ,VREF_BCAST_PHY_REG (cs), rc_tap); +if (status !=MV_OK ) +return status; + } + +return MV_OK ; +} + +/* +* configure sstl for manual calibration and pod for automatic one +* assumes subphy configured to pod ealier +*/ +int mv_ddr4_calibration_adjust (u32 dev_num,u8 vref_en,u8 pod_only) +{ +u8 i, if_id =0 ; +u32 read_data[MAX_INTERFACE_NUM ]; +u32 ncal =0 , pcal =0 ; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +int status =MV_OK ; +u8 subphy_max =ddr3_tip_dev_attr_get (dev_num,MV_ATTR_OCTET_PER_INTERFACE ); +u8 vref_tap = mv_ddr4_config_phy_vref_tap; +u32 vref_idx = (vref_tap <8 ) ? vref_tap :0 ; + +if (vref_calibration_wa ==0 ) +return mv_ddr4_calibration_validate (dev_num); + +if (vref_en ==1 ) { +/* enhanced vref value set to no clamp (0) */ +for (i =0 ; i < subphy_max; i++) { +VALIDATE_BUS_ACTIVE (tm->bus_act_mask, i); +ddr3_tip_bus_read_modify_write (dev_num,ACCESS_TYPE_UNICAST ,0 , i,DDR_PHY_DATA , +PAD_CFG_PHY_REG , (0 <<4 ) | vref_idx, ((0x7 <<4 ) |0x7 )); + } + +for (i =0 ; i <3 ; i++) +ddr3_tip_bus_read_modify_write (dev_num,ACCESS_TYPE_UNICAST ,0 , i,DDR_PHY_CONTROL , +PAD_CFG_PHY_REG , (0 <<4 ) | vref_idx, ((0x7 <<4 ) |0x7 )); + } + +/* pad calibration control - enable */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,MAIN_PADS_CAL_MACH_CTRL_REG , + (calibration_update_control <<3 ) |0x1 , (0x3 <<3 ) |0x1 ); +if (status !=MV_OK ) +return status; + +/* calibration update external */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id, +MAIN_PADS_CAL_MACH_CTRL_REG ,0x2 <<3 ,0x3 <<3 ); +if (status !=MV_OK ) +return status; + +/* poll init calibration done */ +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0x80000000 ,0x80000000 , +MAIN_PADS_CAL_MACH_CTRL_REG ,MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: calibration polling failed (0)\n" )); + +/* poll calibration propogated to io */ +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0x3ffffff ,0x3ffffff ,0x1674 , +MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: calibration polling failed (1)\n" )); + +mdelay (10 );/* TODO: check it */ + +/* disable dynamic */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,MAIN_PADS_CAL_MACH_CTRL_REG ,0 ,0x1 ); +if (status !=MV_OK ) +return status; + +/* poll initial calibration done*/ +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0x80000000 ,0x80000000 , +MAIN_PADS_CAL_MACH_CTRL_REG ,MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: calibration polling failed (2)\n" )); + +/* poll calibration propogated to io */ +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0x3ffffff ,0x3ffffff ,0x1674 , +MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: calibration polling failed (3)\n" )); + +mdelay (10 );/* TODO: check why polling insufficient */ + +/* read calibration value and set it manually */ + status =ddr3_tip_if_read (dev_num,ACCESS_TYPE_UNICAST , if_id,0x1dc8 , read_data,MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + + ncal = (read_data[if_id] & (0x3f <<10 )) >>10 ; + pcal = (read_data[if_id] & (0x3f <<4 )) >>4 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("mv_ddr4_calibration_adjust: sstl pcal = 0x%x, ncal = 0x%x\n" , + pcal, ncal)); +if ((ncal >=56 ) || (ncal <=6 ) || (pcal >=59 ) || (pcal <=7 )) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: error: sstl pcal = 0x%x, ncal = 0x%x out of range\n" , + pcal, ncal)); + status =MV_FAIL ; + } + +if (pod_only ==0 ) { + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,0x1dc8 ,0x1 <<3 ,0x1 <<3 ); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,0x1dc8 , + (ncal <<22 ) | (pcal <<16 ), (0x3f <<22 ) | (0x3f <<16 )); +if (status !=MV_OK ) +return status; + +/* configure to pod mode (0x1) */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE , +GP_RSVD0_REG , + (0x1 <<12 ) | (0x1 <<6 ) | (0x1 <<5 ),0x1060 ); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_DATA ,TEST_ADLL_PHY_REG ,0x1 ); +if (status !=MV_OK ) +return status; + + status =ddr3_tip_bus_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,ACCESS_TYPE_MULTICAST , +PARAM_NOT_CARE ,DDR_PHY_CONTROL ,TEST_ADLL_PHY_REG ,0x1 ); +if (status !=MV_OK ) +return status; + +/* pad calibration control - enable */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,MAIN_PADS_CAL_MACH_CTRL_REG , +0x1 ,0x1 ); +if (status !=MV_OK ) +return status; + +/* poll initial calibration done*/ +if (ddr3_tip_if_polling (dev_num,ACCESS_TYPE_UNICAST , if_id,0x80000000 ,0x80000000 , +MAIN_PADS_CAL_MACH_CTRL_REG ,MAX_POLLING_ITERATIONS ) !=MV_OK ) +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: calibration polling failed (4)\n" )); + } + +/* calibration update internal */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,MAIN_PADS_CAL_MACH_CTRL_REG , + calibration_update_control <<3 ,0x3 <<3 ); +if (status !=MV_OK ) +return status; + +/* vertical */ + status =ddr3_tip_if_read (dev_num,ACCESS_TYPE_UNICAST , if_id,0x14c8 , read_data,MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + ncal = (read_data[if_id] & (0x3f <<10 )) >>10 ; + pcal = (read_data[if_id] & (0x3f <<4 )) >>4 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("mv_ddr4_calibration_adjust: pod-v pcal = 0x%x, ncal = 0x%x\n" , + pcal, ncal)); +if ((ncal >=56 ) || (ncal <=6 ) || (pcal >=59 ) || (pcal <=7 )) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: error: pod-v pcal = 0x%x, ncal = 0x%x out of range\n" , + pcal, ncal)); + status =MV_FAIL ; + } + +/* horizontal */ + status =ddr3_tip_if_read (dev_num,ACCESS_TYPE_UNICAST , if_id,0x17c8 , read_data,MASK_ALL_BITS ); +if (status !=MV_OK ) +return status; + ncal = (read_data[if_id] & (0x3f <<10 )) >>10 ; + pcal = (read_data[if_id] & (0x3F <<4 )) >>4 ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , + ("mv_ddr4_calibration_adjust: pod-h pcal = 0x%x, ncal = 0x%x\n" , + pcal, ncal)); +if ((ncal >=56 ) || (ncal <=6 ) || (pcal >=59 ) || (pcal <=7 )) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , + ("mv_ddr4_calibration_adjust: error: pod-h pcal = 0x%x, ncal = 0x%x out of range\n" , + pcal, ncal)); + status =MV_FAIL ; + } +/* pad calibration control - disable */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_MULTICAST ,PARAM_NOT_CARE ,MAIN_PADS_CAL_MACH_CTRL_REG , + (calibration_update_control <<3 ) |0x0 , (0x3 <<3 ) |0x1 ); +if (status !=MV_OK ) +return status; + +return status; +} + +#if defined(CONFIG_ARMADA_39X ) || defined(CONFIG_ARMADA_38X ) +static int a39x_z1_config (u32 dev_num) +{ +u32 if_id; +struct mv_ddr_topology_map *tm =mv_ddr_topology_map_get (); +int status; + +for (if_id =0 ; if_id <MAX_INTERFACE_NUM ; if_id++) { +VALIDATE_IF_ACTIVE (tm->if_act_mask, if_id); +/* +* xbar split bypass - dlb is off, +* when enabled, set to 0x1 +*/ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,0x1424 ,0x0 <<3 ,0x1 <<3 ); +if (status !=MV_OK ) +return status; + +/* auto power save option */ + status =ddr3_tip_if_write (dev_num,ACCESS_TYPE_UNICAST , if_id,0x1474 ,0x0 ,0xffffffff ); +if (status !=MV_OK ) +return status; + } + +return MV_OK ; +} +#endif + +int mv_ddr4_training_main_flow (u32 dev_num) +{ +int status =MV_OK ; +u16 pbs_tap_factor[MAX_INTERFACE_NUM ][MAX_BUS_NUM ][BUS_WIDTH_IN_BITS ] = {0 }; + +if (mask_tune_func &RECEIVER_CALIBRATION_MASK_BIT ) { + training_stage =RECEIVER_CALIBRATION ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("RECEIVER_CALIBRATION_MASK_BIT #%d\n" , effective_cs)); + status =mv_ddr4_receiver_calibration (dev_num); +if (is_reg_dump !=0 ) +ddr3_tip_reg_dump (dev_num); +if (status !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_receiver_calibrate failure\n" )); +if (debug_mode ==0 ) +return status; + } + } + +if (mask_tune_func &WL_PHASE_CORRECTION_MASK_BIT ) { + training_stage =WL_PHASE_CORRECTION ; +DEBUG_TRAINING_IP (DEBUG_LEVEL_INFO , ("WL_PHASE_CORRECTION_MASK_BIT #%d\n" , effective_cs)); + status =mv_ddr4_dynamic_wl_supp (dev_num); +if (is_reg_dump !=0 ) +ddr3_tip_reg_dump (dev_num); +if (status !=MV_OK ) { +DEBUG_TRAINING_IP (DEBUG_LEVEL_ERROR , ("mv_ddr4_dynamic_wl_supp failure\n" )); +if (debug_mode ==0 ) +return status; + }Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training.h new file +32
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c new file +2340
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h new file +26
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_db.c new file +545
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c new file +441
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h new file +11
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_brd.c new file +82
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_init.c new file +60
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_init.h new file +11
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_mrs.c new file +248
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_mrs.h new file +83
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_plat.c +257
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_plat.h +11
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_regs.h +59
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_static.c new file +12
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_static.h new file +11
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_sys_env_lib.h +7
-0Lines of this file are not shown. View the raw message.
drivers/ddr/marvell/a38x/mv_ddr_topology.h +72
-1Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
2.30.2
Part of the diff is not shown here. View the raw message.
Hello! Thanks for this DDR4 patch.
I have a few comments below, mostly about adding dead/removed code.
Quoted 11 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
This syncs
drivers/ddr/marvell/a38x/with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.gitup to the commit "
mv_ddr: a3700: Use the right size for memset to not overflow"d5acc10c287e40cc2feeb28710b92e45c93c702cThis patch was created by following steps:
1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.
Quoted 8 lines
2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:
files=drivers/ddr/marvell/a38x/*
sed 's/#ifdefined(CONFIG_ARMADA_38X)|| defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files
marvell/a38x/ subdir contains only a38x code. Moreover all a39x stubs were already removed from u-boot (it was never complete):
https://source.denx.de/u-boot/u-boot/-/commit/15942805b7efe47e186d8b30ec378666561ad1f9
So do not re-introduce CONFIG_ARMADA_39X code. Instead run unifdef with additional args: -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X
And with that, additional 'sed' and -DTRUE is not needed at all. It was needed only as a hack for simulating logical OR: defined(A) || defined(B)
Also I see there CONFIG_64BIT checks. I think that CONFIG_64BIT code is not relevant for 32-bit A38x, so I would suggest to eliminate it with unifdef -UCONFIG_64BIT.
Quoted 3 lines
3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.
There are still some license comment style changes (// vs /* ... */).
Quoted 75 lines
After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.
The only change in this patch are:
- Removal of commonboard_topology_mapcode using ifdefs inmv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) inmv_ddr_plat.cReference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460Signed-off-by Tony Dinh <[email protected]>---
drivers/ddr/marvell/a38x/Makefile | 8 + drivers/ddr/marvell/a38x/ddr3_debug.c | 120 + drivers/ddr/marvell/a38x/ddr3_init.c | 25 + drivers/ddr/marvell/a38x/ddr3_init.h | 14 + drivers/ddr/marvell/a38x/ddr3_logging_def.h | 29 +- drivers/ddr/marvell/a38x/ddr3_training.c | 135 + drivers/ddr/marvell/a38x/ddr3_training_bist.c | 12 + .../a38x/ddr3_training_centralization.c | 6 + drivers/ddr/marvell/a38x/ddr3_training_db.c | 278 ++ drivers/ddr/marvell/a38x/ddr3_training_ip.h | 17 + .../ddr/marvell/a38x/ddr3_training_ip_db.h | 156 +- .../marvell/a38x/ddr3_training_ip_engine.c | 147 +- .../ddr/marvell/a38x/ddr3_training_ip_flow.h | 7 +- .../ddr/marvell/a38x/ddr3_training_leveling.c | 139 +- drivers/ddr/marvell/a38x/ddr_init.c | 8 + drivers/ddr/marvell/a38x/ddr_mv_wrapper.h | 47 + drivers/ddr/marvell/a38x/dram_if.c | 31 + drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c | 674 +++++ drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h | 59 + drivers/ddr/marvell/a38x/mv_ddr4_training.c | 571 ++++ drivers/ddr/marvell/a38x/mv_ddr4_training.h | 32 + .../a38x/mv_ddr4_training_calibration.c | 2340 +++++++++++++++++ .../a38x/mv_ddr4_training_calibration.h | 26 + .../ddr/marvell/a38x/mv_ddr4_training_db.c | 545 ++++ .../marvell/a38x/mv_ddr4_training_leveling.c | 441 ++++ .../marvell/a38x/mv_ddr4_training_leveling.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_brd.c | 82 + drivers/ddr/marvell/a38x/mv_ddr_init.c | 60 + drivers/ddr/marvell/a38x/mv_ddr_init.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_mrs.c | 248 ++ drivers/ddr/marvell/a38x/mv_ddr_mrs.h | 83 + drivers/ddr/marvell/a38x/mv_ddr_plat.c | 257 ++ drivers/ddr/marvell/a38x/mv_ddr_plat.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_regs.h | 59 + drivers/ddr/marvell/a38x/mv_ddr_static.c | 12 + drivers/ddr/marvell/a38x/mv_ddr_static.h | 11 + drivers/ddr/marvell/a38x/mv_ddr_sys_env_lib.h | 7 + drivers/ddr/marvell/a38x/mv_ddr_topology.h | 72 + 38 files changed, 6786 insertions(+), 5 deletions(-) create mode 100644 drivers/ddr/marvell/a38x/ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/ddr_mv_wrapper.h create mode 100644 drivers/ddr/marvell/a38x/dram_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_brd.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_init.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_mrs.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr_static.h
...
Quoted 6 lines
drivers/ddr/marvell/a38x/ddr_init.c new file +0
-0
drivers/ddr/marvell/a38x/ddr_init.c line 8
Quoted 8 lines
drivers/ddr/marvell/a38x/ddr_init.c new file +8
-0@@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr3_init.h" + +/* U-BOOT MARVELL 2013.01 SUPPORT */
For sure this ddr_init.c file is not needed as it is empty.
Quoted 43 lines
drivers/ddr/marvell/a38x/ddr_mv_wrapper.h new file +37
-0@@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _DDR_MV_WRAPPER_H +#define _DDR_MV_WRAPPER_H + +#define INTER_REGS_BASE 0xd0000000 + +#include "mv_os.h" +#include "printf.h" +#include "mvUart.h" +#include "util.h" + +typedef unsigned long long uint64_t ; +typedef uint64_t uintptr_t ; + +static inline void mmio_write_64 (uintptr_t addr,uint64_t value) +{ +} + +static inline uint64_t mmio_read_64 (uintptr_t addr) +{ +return (uint64_t )0 ; +} + +/* u-boot/tools/marvell/bin_hdr/platform/utils/printf.c */ +#define printf mvPrintf + +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) +#define reg_write MV_REG_WRITE +#define reg_read MV_REG_READ +#define reg_bit_set MV_REG_BIT_SET + +/* uboot/tools/marvell/bin_hdr/platform/drivers/mv_time.c */ +void mdelay (unsigned long );
drivers/ddr/marvell/a38x/ddr_mv_wrapper.h line 47
Quoted 10 lines
drivers/ddr/marvell/a38x/ddr_mv_wrapper.h new file +10
-0+ +/* TODO: Check if LE/BE support is needed */ +#define MV_MEMIO_LE32_WRITE2 (data,addr) \ + MV_MEMIO32_WRITE(addr, MV_32BIT_LE_FAST(data)) +#define writel MV_MEMIO_LE32_WRITE2 +#define readl MV_MEMIO_LE32_READ +#define writeq mmio_write_64 +#define readq mmio_read_64 + +#endif /* _DDR_MV_WRAPPER_H */
This file looks unusable as both mmio_write_64() and mmio_read_64() are unimplemented. Instead ddr_ml_wrapper.h should be used.
Quoted 27 lines
drivers/ddr/marvell/a38x/dram_if.c new file +21
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr_ml_wrapper.h" + +#include "mv_ddr_init.h" +#include "mv_ddr_plat.h" +#include "mv_ddr_topology.h" + +int dram_init (void ) +{ +return mv_ddr_init (); +} + +void dram_mmap_config (void ) +{ +mv_ddr_mmap_config (); +} +
drivers/ddr/marvell/a38x/dram_if.c line 31
Quoted 10 lines
drivers/ddr/marvell/a38x/dram_if.c new file +10
-0+unsigned long long dram_iface_mem_sz_get (void ) +{ +/* +* call mv_ddr_pre_config to update topology +* prior to mv_ddr_mem_sz_get call +*/ +mv_ddr_pre_config (); + +return mv_ddr_mem_sz_get (); +}
This file seems to not be needed too as none of these functions are called.
...
Quoted 78 lines
drivers/ddr/marvell/a38x/mv_ddr_brd.c new file +72
-0@@ -0,0 +1,82 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr3_init.h" + +/* +* Define the DDR layout / topology here in the board file. This will +* be used by the DDR3 init code in the SPL U-Boot version to configure +* the DDR3 controller. +*/ + +#if defined(CONFIG_DDR4 ) +#define SPEED_BIN_DDR_DB_68XX SPEED_BIN_DDR_2400R +#define BUS_WIDTH_DB_68XX MV_DDR_DEV_WIDTH_16BIT +#else /* CONFIG_DDR4 */ +#define SPEED_BIN_DDR_DB_68XX SPEED_BIN_DDR_1866L +#define BUS_WIDTH_DB_68XX MV_DDR_DEV_WIDTH_8BIT +#endif /* CONFIG_DDR4 */ + +/* +* board_topology_map and mv_ddr_topology_map_get() +* should be defined in each board file. +* +*/ + +#if 0 +/* Marvell board - Board_ID = DB_68XX_ID = 1 (DDR3/4)*/ +static struct mv_ddr_topology_map board_topology_map = { +DEBUG_LEVEL_ERROR , +0x1 ,/* active interfaces */ +/* cs_mask, mirror, dqs_swap, ck_swap X PUPs */ + { { { {0x3 ,0x2 ,0 ,0 }, + {0x3 ,0x2 ,0 ,0 }, + {0x3 ,0x2 ,0 ,0 }, + {0x3 ,0x2 ,0 ,0 }, + {0x3 ,0x2 ,0 ,0 } }, +SPEED_BIN_DDR_DB_68XX ,/* speed_bin */ +BUS_WIDTH_DB_68XX ,/* sdram device width */ +MV_DDR_DIE_CAP_4GBIT ,/* die capacity */ +MV_DDR_FREQ_SAR ,/* frequency */ +0 ,0 ,/* cas_l, cas_wl */ +MV_DDR_TEMP_LOW } },/* temperature */ +BUS_MASK_32BIT ,/* subphys mask */ +MV_DDR_CFG_DEFAULT ,/* ddr configuration data source */ + { {0 } },/* raw spd data */ + {0 }/* timing parameters */ +}; +/* #else */ + +/* Marvell board - Board_ID = DB_GP_68XX_ID = 4 */ +static struct mv_ddr_topology_map board_topology_map = { +DEBUG_LEVEL_ERROR , +0x1 ,/* active interfaces */ +/* cs_mask, mirror, dqs_swap, ck_swap X PUPs */ + { { { {0x1 ,0 ,0 ,0 }, + {0x1 ,0 ,0 ,0 }, + {0x1 ,0 ,0 ,0 }, + {0x1 ,0 ,0 ,0 }, + {0x1 ,0 ,0 ,0 } }, +SPEED_BIN_DDR_DB_68XX ,/* speed_bin */ +BUS_WIDTH_DB_68XX ,/* sdram device width */ +MV_DDR_DIE_CAP_4GBIT ,/* die capacity */ +MV_DDR_FREQ_SAR ,/* frequency */ +0 ,0 ,/* cas_l cas_wl */ +MV_DDR_TEMP_LOW } },/* temperature */ +BUS_MASK_32BIT ,/* subphys mask */ +MV_DDR_CFG_DEFAULT ,/* ddr configuration data source */ +NOT_COMBINED ,/* ddr twin-die combined*/ + { {0 } },/* raw spd data */ + {0} /* timing parameters */
drivers/ddr/marvell/a38x/mv_ddr_brd.c line 82
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_brd.c new file +10
-0+}; +#endif /* 0 */ + +#if 0 +struct mv_ddr_topology_map *mv_ddr_topology_map_get (void ) +{ +/* Return the board topology as defined in the board code */ +return &board_topology_map; +} +#endif
This file has all code commented. Also topology file is defined in u-boot board directory. So file seems to not be needed too.
Quoted 56 lines
drivers/ddr/marvell/a38x/mv_ddr_init.c new file +50
-0@@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +/* TODO: need this wrapper block for ddr_topology_def.h resolution */ +#include "ddr_ml_wrapper.h" + +#include "mv_ddr_common.h" +#include "mv_ddr_topology.h" +#include "mv_ddr_plat.h" +#include "ddr_topology_def.h" +#include "dram_if.h" + +int mv_ddr_init (void ) +{ +/* print mv_ddr version */ +mv_ddr_ver_print (); + +/* preliminary mv_ddr configuration */ +if (mv_ddr_pre_config ()) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +/* remap overlapping dram region to the top */ +if (mv_ddr_mc_remap () !=0 ) +return -1 ; + +/* mv_ddr_mc */ +if (mv_ddr_mc_config ()) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + + +if (mv_ddr_phy_config ()) { +printf ("error: %s failed\n" , __func__); +#if defined(T9130 ) +reg_write (0x6f0084 ,0x0 ); +#endif +return -1 ; + } + + +if (mv_ddr_mc_ena ()) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } +
drivers/ddr/marvell/a38x/mv_ddr_init.c line 60
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_init.c new file +10
-0+/* post mv_ddr configuration */ +if (mv_ddr_post_config ()) { +printf ("error: %s failed\n" , __func__); +return -1 ; + } + +printf ("mv_ddr: completed successfully\n" ); + +return 0 ; +}
Function mv_ddr_init() is not called, so whole mv_ddr_init.c file is not needed.
Quoted 7 lines
drivers/ddr/marvell/a38x/mv_ddr_init.h new file +1
-0@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */
drivers/ddr/marvell/a38x/mv_ddr_init.h line 11
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_init.h new file +10
-0+/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _MV_DDR_INIT_H +#define _MV_DDR_INIT_H + +int mv_ddr_init (void ); + +#endif /* _MV_DDR_INIT_H */
Same for header file.
Quoted 244 lines
drivers/ddr/marvell/a38x/mv_ddr_mrs.c new file +238
-0@@ -0,0 +1,248 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "ddr_ml_wrapper.h" +#include "mv_ddr_plat.h" + +/* +* Based on Proposed DDR4 Full spec update (79-4B), Item No. 1716.78C +*/ + +/* MR0 WR (Write Recovery) and RTP (read to precharge), [13, 11:9] bits */ +#define MV_DDR_MR0_WR10_RTP5 0x0/* 0b00_0000_0000_0000 */ +#define MV_DDR_MR0_WR12_RTP6 0x200/* 0b00_0010_0000_0000 */ +#define MV_DDR_MR0_WR14_RTP7 0x400/* 0b00_0100_0000_0000 */ +#define MV_DDR_MR0_WR16_RTP8 0x600/* 0b00_0110_0000_0000 */ +#define MV_DDR_MR0_WR18_RTP9 0x800/* 0b00_1000_0000_0000 */ +#define MV_DDR_MR0_WR20_RTP10 0xa00/* 0b00_1010_0000_0000 */ +#define MV_DDR_MR0_WR24_RTP12 0xc00/* 0b00_1100_0000_0000 */ +#define MV_DDR_MR0_WR22_RTP11 0xe00/* 0b00_1110_0000_0000 */ +#define MV_DDR_MR0_WR26_RTP13 0x2000/* 0b10_0000_0000_0000 */ + +int mv_ddr_mr0_wr_get (unsigned int wr,unsigned int *mr0_wr) +{ +switch (wr) { +case 10 : + *mr0_wr =MV_DDR_MR0_WR10_RTP5 ; +break ; +case 12 : + *mr0_wr =MV_DDR_MR0_WR12_RTP6 ; +break ; +case 14 : + *mr0_wr =MV_DDR_MR0_WR14_RTP7 ; +break ; +case 16 : + *mr0_wr =MV_DDR_MR0_WR16_RTP8 ; +break ; +case 18 : + *mr0_wr =MV_DDR_MR0_WR18_RTP9 ; +break ; +case 20 : + *mr0_wr =MV_DDR_MR0_WR20_RTP10 ; +break ; +case 24 : + *mr0_wr =MV_DDR_MR0_WR24_RTP12 ; +break ; +case 22 : + *mr0_wr =MV_DDR_MR0_WR22_RTP11 ; +break ; +case 26 : + *mr0_wr =MV_DDR_MR0_WR26_RTP13 ; +break ; +default : +printf ("error: %s: unsupported t_wr value found\n" , __func__); +return -1 ; + } + +return 0 ; +} + +/* MR0 CL, [12, 6:4, 2] bits */ +#define MV_DDR_MR0_CL9 0x0/* 0b0_0000_0000_0000 */ +#define MV_DDR_MR0_CL10 0x4/* 0b0_0000_0000_0100 */ +#define MV_DDR_MR0_CL11 0x10/* 0b0_0000_0001_0000 */ +#define MV_DDR_MR0_CL12 0x14/* 0b0_0000_0001_0100 */ +#define MV_DDR_MR0_CL13 0x20/* 0b0_0000_0010_0000 */ +#define MV_DDR_MR0_CL14 0x24/* 0b0_0000_0010_0100 */ +#define MV_DDR_MR0_CL15 0x30/* 0b0_0000_0011_0000 */ +#define MV_DDR_MR0_CL16 0x34/* 0b0_0000_0011_0100 */ +#define MV_DDR_MR0_CL18 0x40/* 0b0_0000_0100_0000 */ +#define MV_DDR_MR0_CL20 0x44/* 0b0_0000_0100_0100 */ +#define MV_DDR_MR0_CL22 0x50/* 0b0_0000_0101_0000 */ +#define MV_DDR_MR0_CL24 0x54/* 0b0_0000_0101_0100 */ +#define MV_DDR_MR0_CL23 0x60/* 0b0_0000_0110_0000 */ +#define MV_DDR_MR0_CL17 0x64/* 0b0_0000_0110_0100 */ +#define MV_DDR_MR0_CL19 0x70/* 0b0_0000_0111_0000 */ +#define MV_DDR_MR0_CL21 0x74/* 0b0_0000_0111_0100 */ +#define MV_DDR_MR0_CL25 0x1000/* 0b1_0000_0000_0000 */ +#define MV_DDR_MR0_CL26 0x1004/* 0b1_0000_0000_0100 */ +#define MV_DDR_MR0_CL27 0x1010/* 0b1_0000_0001_0000 */ +#define MV_DDR_MR0_CL28 0x1014/* 0b1_0000_0001_0100 */ +#define MV_DDR_MR0_CL29 0x1020/* 0b1_0000_0010_0000 */ +#define MV_DDR_MR0_CL30 0x1024/* 0b1_0000_0010_0100 */ +#define MV_DDR_MR0_CL31 0x1030/* 0b1_0000_0011_0000 */ +#define MV_DDR_MR0_CL32 0x1034/* 0b1_0000_0011_0100 */ + +int mv_ddr_mr0_cl_get (unsigned int cl,unsigned int *mr0_cl) +{ +switch (cl) { +case 9 : + *mr0_cl =MV_DDR_MR0_CL9 ; +break ; +case 10 : + *mr0_cl =MV_DDR_MR0_CL10 ; +break ; +case 11 : + *mr0_cl =MV_DDR_MR0_CL11 ; +break ; +case 12 : + *mr0_cl =MV_DDR_MR0_CL12 ; +break ; +case 13 : + *mr0_cl =MV_DDR_MR0_CL13 ; +break ; +case 14 : + *mr0_cl =MV_DDR_MR0_CL14 ; +break ; +case 15 : + *mr0_cl =MV_DDR_MR0_CL15 ; +break ; +case 16 : + *mr0_cl =MV_DDR_MR0_CL16 ; +break ; +case 18 : + *mr0_cl =MV_DDR_MR0_CL18 ; +break ; +case 20 : + *mr0_cl =MV_DDR_MR0_CL20 ; +break ; +case 22 : + *mr0_cl =MV_DDR_MR0_CL22 ; +break ; +case 24 : + *mr0_cl =MV_DDR_MR0_CL24 ; +break ; +case 23 : + *mr0_cl =MV_DDR_MR0_CL23 ; +break ; +case 17 : + *mr0_cl =MV_DDR_MR0_CL17 ; +break ; +case 19 : + *mr0_cl =MV_DDR_MR0_CL19 ; +break ; +case 21 : + *mr0_cl =MV_DDR_MR0_CL21 ; +break ; +case 25 : + *mr0_cl =MV_DDR_MR0_CL25 ; +break ; +case 26 : + *mr0_cl =MV_DDR_MR0_CL26 ; +break ; +case 27 : + *mr0_cl =MV_DDR_MR0_CL27 ; +break ; +case 28 : + *mr0_cl =MV_DDR_MR0_CL28 ; +break ; +case 29 : + *mr0_cl =MV_DDR_MR0_CL29 ; +break ; +case 30 : + *mr0_cl =MV_DDR_MR0_CL30 ; +break ; +case 31 : + *mr0_cl =MV_DDR_MR0_CL31 ; +break ; +case 32 : + *mr0_cl =MV_DDR_MR0_CL32 ; +break ; +default : +printf ("error: %s: unsupported cl value found\n" , __func__); +return -1 ; + } + +return 0 ; +} + +/* MR2 CWL, [5:3] bits */ +#define MV_DDR_MR2_CWL9 0x0/* 0b0000_0000 */ +#define MV_DDR_MR2_CWL10 0x8/* 0b0000_1000 */ +#define MV_DDR_MR2_CWL11 0x10/* 0b0001_0000 */ +#define MV_DDR_MR2_CWL12 0x18/* 0b0001_1000 */ +#define MV_DDR_MR2_CWL14 0x20/* 0b0010_0000 */ +#define MV_DDR_MR2_CWL16 0x28/* 0b0010_1000 */ +#define MV_DDR_MR2_CWL18 0x30/* 0b0011_0000 */ +#define MV_DDR_MR2_CWL20 0x38/* 0b0011_1000 */ + +int mv_ddr_mr2_cwl_get (unsigned int cwl,unsigned int *mr2_cwl) +{ +switch (cwl) { +case 9 : + *mr2_cwl =MV_DDR_MR2_CWL9 ; +break ; +case 10 : + *mr2_cwl =MV_DDR_MR2_CWL10 ; +break ; +case 11 : + *mr2_cwl =MV_DDR_MR2_CWL11 ; +break ; +case 12 : + *mr2_cwl =MV_DDR_MR2_CWL12 ; +break ; +case 14 : + *mr2_cwl =MV_DDR_MR2_CWL14 ; +break ; +case 16 : + *mr2_cwl =MV_DDR_MR2_CWL16 ; +break ; +case 18 : + *mr2_cwl =MV_DDR_MR2_CWL18 ; +break ; +case 20 : + *mr2_cwl =MV_DDR_MR2_CWL20 ; +break ; +default : +printf ("error: %s: unsupported cwl value found\n" , __func__); +return -1 ; + } + +return 0 ; +} + +/* MR6 tCCD_L, [12:10] bits */ +#define MV_DDR_MR6_TCCDL_OFFS 10 +#define MV_DDR_MR6_TCCDL_MASK 0x7 +#define MV_DDR_MR6_TCCDL4 0x0 +#define MV_DDR_MR6_TCCDL5 0x1 +#define MV_DDR_MR6_TCCDL6 0x2 +#define MV_DDR_MR6_TCCDL7 0x3 +#define MV_DDR_MR6_TCCDL8 0x4 +int mv_ddr_mr6_tccdl_get (unsigned int tccdl,unsigned int *mr6_tccdl) +{ +switch (tccdl) { +case 4 : + *mr6_tccdl =MV_DDR_MR6_TCCDL4 <<MV_DDR_MR6_TCCDL_OFFS ; +break ; +case 5 : + *mr6_tccdl =MV_DDR_MR6_TCCDL5 <<MV_DDR_MR6_TCCDL_OFFS ; +break ; +case 6 : + *mr6_tccdl =MV_DDR_MR6_TCCDL6 <<MV_DDR_MR6_TCCDL_OFFS ; +break ; +case 7 : + *mr6_tccdl =MV_DDR_MR6_TCCDL7 <<MV_DDR_MR6_TCCDL_OFFS ; +break ;
drivers/ddr/marvell/a38x/mv_ddr_mrs.c line 248
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_mrs.c new file +10
-0+case 8 : + *mr6_tccdl =MV_DDR_MR6_TCCDL8 <<MV_DDR_MR6_TCCDL_OFFS ; +break ; +default : +printf ("error: %s: unsupported t_ccd_l value found\n" , __func__); +return -1 ; + } + +return 0 ; +}
This file seems to be unused for a38x too.
Quoted 79 lines
drivers/ddr/marvell/a38x/mv_ddr_mrs.h new file +73
-0@@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _MV_DDR_MRS_H +#define _MV_DDR_MRS_H + +/* +* Based on Proposed DDR4 Full spec update (79-4B), Item No. 1716.78C +*/ + +/* MR1 DIC, [2:1] bits */ +#define MV_DDR_MR1_DIC_OFFS 1 + +/* MR1 RTT_NOM, [10:8] bits */ +#define MV_DDR_MR1_RTT_NOM_OFFS 8 +#define MV_DDR_MR1_RTT_NOM_MASK 0x7 +#define MV_DDR_MR1_RTT_NOM_DISABLE 0x0/* 0b000_0000_0000 */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV4 0x100/* 0b001_0000_0000; 60-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV2 0x200/* 0b010_0000_0000; 120-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV6 0x300/* 0b011_0000_0000; 40-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV1 0x400/* 0b100_0000_0000; 240-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV5 0x500/* 0b101_0000_0000; 48-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV3 0x600/* 0b110_0000_0000; 80-Ohm */ +#define MV_DDR_MR1_RTT_NOM_RZQ_DIV7 0x700/* 0b111_0000_0000; 34-Ohm */ + +/* MR2 RTT_WR, [11:9] bits */ +#define MV_DDR_MR2_RTT_WR_OFFS 9 +#define MV_DDR_MR2_RTT_WR_MASK 0x7 +#define MV_DDR_MR2_RTT_WR_DYN_ODT_OFF 0x0/* 0b0000_0000_0000 */ +#define MV_DDR_MR2_RTT_WR_RZQ_DIV2 0x200/* 0b0010_0000_0000; 120-Ohm */ +#define MV_DDR_MR2_RTT_WR_RZQ_DIV1 0x400/* 0b0100_0000_0000; 240-Ohm */ +#define MV_DDR_MR2_RTT_WR_HIZ 0x600/* 0b0110_0000_0000 */ +#define MV_DDR_MR2_RTT_WR_RZQ_DIV3 0x800/* 0b1000_0000_0000; 80-Ohm */ + +/* MR5 ODT Input Buffer during Power Down mode, bit 5 */ +#define MV_DDR_MR5_PD_ODT_IBUF_OFFS 5 +#define MV_DDR_MR5_PD_ODT_IBUF_MASK 0x1 +#define MV_DDR_MR5_PD_ODT_IBUF_ENA 0 +#define MV_DDR_MR5_PD_ODT_IBUF_DIS 1 + +/* MR5 Data Mask, bit 10 */ +#define MV_DDR_MR5_DM_OFFS 10 +#define MV_DDR_MR5_DM_MASK 0x1 +#define MV_DDR_MR5_DM_ENA 1 +#define MV_DDR_MR5_DM_DIS 0 + +/* MR5 RTT_PARK, [8:6] bits */ +#define MV_DDR_MR5_RTT_PARK_OFFS 6 +#define MV_DDR_MR5_RTT_PARK_MASK 0x7 +#define MV_DDR_MR5_RTT_PARK_DISABLE 0x0/* 0b0_0000_0000 */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV4 0x40/* 0b0_0100_0000; 60-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV2 0x80/* 0b0_1000_0000; 120-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV6 0xc0/* 0b0_1100_0000; 40-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV1 0x100/* 0b1_0000_0000; 240-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV5 0x140/* 0b1_0100_0000; 48-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV3 0x180/* 0b1_1000_0000; 80-Ohm */ +#define MV_DDR_MR5_RTT_PARK_RZQ_DIV7 0x1c0/* 0b1_1100_0000; 34-Ohm */ + +/* MR6 VrefDQ Training Enable, bit 7 */ +#define MV_DDR_MR6_VREFDQ_TRNG_ENA_OFFS 7 +#define MV_DDR_MR6_VREFDQ_TRNG_ENA_MASK 0x1 +#define MV_DDR_MR6_VREFDQ_TRNG_ENA 1/* training mode */ +#define MV_DDR_MR6_VREFDQ_TRNG_DIS 0/* normal operation mode */ + +/* MR6 VrefDQ Training Range, bit 6 */ +#define MV_DDR_MR6_VREFDQ_TRNG_RNG_OFFS 6 +#define MV_DDR_MR6_VREFDQ_TRNG_RNG_MASK 0x1 +#define MV_DDR_MR6_VREFDQ_TRNG_RNG1 0/* range 1 */ +#define MV_DDR_MR6_VREFDQ_TRNG_RNG2 1/* range 2 */ + +/* MR6 VrefDQ Training Range Values, [5:0] bits */
drivers/ddr/marvell/a38x/mv_ddr_mrs.h line 83
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_mrs.h new file +10
-0+#define MV_DDR_MR6_VREFDQ_TRNG_VAL_OFFS 0 +#define MV_DDR_MR6_VREFDQ_TRNG_VAL_MASK 0x3f +#define MV_DDR_MR6_VREFDQ_TRNG_VAL 0x9/* range 1: 65.85%; range 2: 50.85% */ + +int mv_ddr_mr0_wr_get (unsigned int wr,unsigned int *mr0_wr); +int mv_ddr_mr0_cl_get (unsigned int cl,unsigned int *mr0_cl); +int mv_ddr_mr2_cwl_get (unsigned int cwl,unsigned int *mr2_cwl); +int mv_ddr_mr6_tccdl_get (unsigned int tccdl,unsigned int *mr6_tccdl); + +#endif /* _MV_DDR_MRS_H */
And also header file.
...
Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_static.c new file +2
-0@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/*
drivers/ddr/marvell/a38x/mv_ddr_static.c line 12
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_static.c new file +10
-0+* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#include "mv_ddr_static.h" +#include "ddr3_training_ip_def.h" + + + + +
This file is empty.
Quoted 7 lines
drivers/ddr/marvell/a38x/mv_ddr_static.h new file +1
-0@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */
drivers/ddr/marvell/a38x/mv_ddr_static.h line 11
Quoted 10 lines
drivers/ddr/marvell/a38x/mv_ddr_static.h new file +10
-0+/* +* Copyright (C) Marvell International Ltd. and its affiliates +*/ + +#ifndef _MV_DDR_STATIC_H +#define _MV_DDR_STATIC_H + + + +#endif /* _MV_DDR_STATIC_H */
And header file too.
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.o
And all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdef CONFIG_DDR4
Quoted 14 lines · Pali Rohár
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4
Looking at the Makefile in question, I think we might want to make the whole thing ifdef CONFIG_SPL_BUILD ... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?
Signature · 1 line
Tom
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4
Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?
Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4
Quoted 8 lines
Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
Signature · 1 line
Tom
Quoted 24 lines · On Saturday 14 January 2023 15:03:41 Tom Rini wrote:
Quoted 23 lines · Pali Rohár
Quoted 21 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?
Quoted 7 lines
Quoted 2 lines
Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
I can look at it _after_ all other stuff is done and merged.
Hi Pali & Tom,
Quoted 29 lines · Pali Rohár
Quoted 27 lines · On Saturday 14 January 2023 15:03:41 Tom Rini wrote:
Quoted 25 lines · Pali Rohár
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
drivers/ddr/marvell/a38x/Makefile obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
drivers/ddr/marvell/a38x/Makefile +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
Quoted 6 lines
Quoted 4 lines
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
I can look at it _after_ all other stuff is done and merged.
Thanks for the review and comments! and thanks Pali in advance for the Makefile improvement after. I will submit the V2 patches to fix the dead code and other editorial issues per Pali's review.
All the best,
Tony
Hi all,
Quoted 38 lines · Tony Dinh
Hi Pali & Tom,
Quoted 34 lines · Pali Rohár
Quoted 31 lines · On Saturday 14 January 2023 15:03:41 Tom Rini wrote:
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
Review obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
(quoted diff) +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4Quoted 8 lines
Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
Quoted 5 lines
Quoted 1 line
I can look at it _after_ all other stuff is done and merged.
Thanks for the review and comments! and thanks Pali in advance for the
Makefileimprovement after. I will submit the V2 patches to fix the dead code and other editorial issues per Pali's review.
Am I correct in assuming that the preferred license header is // SPDX-License-Identifier: GPL-2.0
and _not_
/* SPDX-License-Identifier: GPL-2.0 */
Or does it not matter which form we use as long as it is consistent in an area?
Thanks,
Tony
Quoted 48 lines · Tony Dinh
Hi all,
Quoted 38 lines · Tony Dinh
Hi Pali & Tom,
Quoted 34 lines · Pali Rohár
Quoted 31 lines · On Saturday 14 January 2023 15:03:41 Tom Rini wrote:
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
Review obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
(quoted diff) +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4Quoted 8 lines
Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
Quoted 5 lines
Quoted 1 line
I can look at it _after_ all other stuff is done and merged.
Thanks for the review and comments! and thanks Pali in advance for the
Makefileimprovement after. I will submit the V2 patches to fix the dead code and other editorial issues per Pali's review.
Quoted 7 lines
Am I correct in assuming that the preferred license header is // SPDX-License-Identifier: GPL-2.0
and _not_
/* SPDX-License-Identifier: GPL-2.0 */Or does it not matter which form we use as long as it is consistent in an area?
NVM, I was scratching my head why patman kept warning me for using one form or the others!
/Licenses/README
The SPDX license identifier is added in the form of a comment. The comment style depends on the file type::
C source: // SPDX-License-Identifier: <SPDX License Expression> C header: /* SPDX-License-Identifier: <SPDX License Expression> */
ASM: /* SPDX-License-Identifier: <SPDX License Expression> */
scripts: # SPDX-License-Identifier: <SPDX License Expression>
.rst: .. SPDX-License-Identifier: <SPDX License Expression>
.dts{i}: // SPDX-License-Identifier: <SPDX License Expression>
All the best,
Tony
Quoted 50 lines · On Monday 16 January 2023 16:33:09 Tony Dinh wrote:
Hi all,
Quoted 38 lines · Tony Dinh
Hi Pali & Tom,
Quoted 34 lines · Pali Rohár
Quoted 31 lines · On Saturday 14 January 2023 15:03:41 Tom Rini wrote:
Quoted 17 lines · Pali Rohár
Quoted 16 lines · On Friday 13 January 2023 21:00:21 Tom Rini wrote:
Quoted 14 lines · Pali Rohár
Review obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o · line 27
Quoted 10 lines · On Friday 13 January 2023 16:38:55 Tony Dinh wrote:
(quoted diff) +5
-0@@ -16,4 +19,9 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_build_message.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o +obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o obj-$(CONFIG_SPL_BUILD) += xor.oAnd all these new files are ddr4 specific, so should be wrapped in makefile section:
ifdefCONFIG_DDR4Quoted 8 lines
Quoted 5 lines
Looking at the
Makefilein question, I think we might want to make the whole thing ifdefCONFIG_SPL_BUILD... endif and then more finely control building of what objects are built. Perhaps:
drivers/Makefile:obj-$(CONFIG_ARMADA_38X) += ddr/marvell/a38x/ should only be for SPL instead, even?Some cleanup like this can be done. But it is related to DDR4 support and is mostly independent of it. So lets do it after having DDR4 there.
We're going to also want to not build the DDR3 code on the DDR4 platforms, right? A little clean up would make adding the DDR4 code a bit cleaner for both cases. It's not a hard no, if someone really wants to do the clean-up after.
Quoted 5 lines
Quoted 1 line
I can look at it _after_ all other stuff is done and merged.
Thanks for the review and comments! and thanks Pali in advance for the
Makefileimprovement after. I will submit the V2 patches to fix the dead code and other editorial issues per Pali's review.Am I correct in assuming that the preferred license header is // SPDX-License-Identifier: GPL-2.0
Quoted 7 lines
and _not_
/* SPDX-License-Identifier: GPL-2.0 */Or does it not matter which form we use as long as it is consistent in an area?
Thanks,
Tony
Well, the best is to not change licence headers in existing u-boot files.