2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2008-08-26 20:01:29 +00:00
|
|
|
/*
|
2014-03-28 00:54:47 +00:00
|
|
|
* Copyright 2008-2014 Freescale Semiconductor, Inc.
|
2008-08-26 20:01:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FSL_DDR_MAIN_H
|
|
|
|
#define FSL_DDR_MAIN_H
|
|
|
|
|
2014-03-28 00:54:47 +00:00
|
|
|
#include <fsl_ddrc_version.h>
|
2013-09-30 16:22:09 +00:00
|
|
|
#include <fsl_ddr_sdram.h>
|
|
|
|
#include <fsl_ddr_dimm_params.h>
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2013-09-30 16:22:09 +00:00
|
|
|
#include <common_timing_params.h>
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
struct cmd_tbl;
|
|
|
|
|
2014-02-10 21:59:42 +00:00
|
|
|
#ifdef CONFIG_SYS_FSL_DDR_LE
|
|
|
|
#define ddr_in32(a) in_le32(a)
|
|
|
|
#define ddr_out32(a, v) out_le32(a, v)
|
2014-12-08 23:30:55 +00:00
|
|
|
#define ddr_setbits32(a, v) setbits_le32(a, v)
|
|
|
|
#define ddr_clrbits32(a, v) clrbits_le32(a, v)
|
|
|
|
#define ddr_clrsetbits32(a, clear, set) clrsetbits_le32(a, clear, set)
|
2014-02-10 21:59:42 +00:00
|
|
|
#else
|
|
|
|
#define ddr_in32(a) in_be32(a)
|
|
|
|
#define ddr_out32(a, v) out_be32(a, v)
|
2014-12-08 23:30:55 +00:00
|
|
|
#define ddr_setbits32(a, v) setbits_be32(a, v)
|
|
|
|
#define ddr_clrbits32(a, v) clrbits_be32(a, v)
|
|
|
|
#define ddr_clrsetbits32(a, clear, set) clrsetbits_be32(a, clear, set)
|
2014-02-10 21:59:42 +00:00
|
|
|
#endif
|
|
|
|
|
2015-03-19 16:30:26 +00:00
|
|
|
u32 fsl_ddr_get_version(unsigned int ctrl_num);
|
2014-03-28 00:54:47 +00:00
|
|
|
|
2011-06-07 01:42:16 +00:00
|
|
|
#if defined(CONFIG_DDR_SPD) || defined(CONFIG_SPD_EEPROM)
|
2008-08-26 20:01:29 +00:00
|
|
|
/*
|
|
|
|
* Bind the main DDR setup driver's generic names
|
|
|
|
* to this specific DDR technology.
|
|
|
|
*/
|
|
|
|
static __inline__ int
|
2015-01-06 21:18:50 +00:00
|
|
|
compute_dimm_parameters(const unsigned int ctrl_num,
|
|
|
|
const generic_spd_eeprom_t *spd,
|
2008-08-26 20:01:29 +00:00
|
|
|
dimm_params_t *pdimm,
|
|
|
|
unsigned int dimm_number)
|
|
|
|
{
|
2015-01-06 21:18:50 +00:00
|
|
|
return ddr_compute_dimm_parameters(ctrl_num, spd, pdimm, dimm_number);
|
2008-08-26 20:01:29 +00:00
|
|
|
}
|
2011-06-07 01:42:16 +00:00
|
|
|
#endif
|
2008-08-26 20:01:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Data Structures
|
|
|
|
*
|
|
|
|
* All data structures have to be on the stack
|
|
|
|
*/
|
2008-10-16 13:01:15 +00:00
|
|
|
#define CONFIG_SYS_DIMM_SLOTS_PER_CTLR CONFIG_DIMM_SLOTS_PER_CTLR
|
2008-08-26 20:01:29 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
generic_spd_eeprom_t
|
2008-10-16 13:01:15 +00:00
|
|
|
spd_installed_dimms[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_SYS_DIMM_SLOTS_PER_CTLR];
|
2008-08-26 20:01:29 +00:00
|
|
|
struct dimm_params_s
|
2008-10-16 13:01:15 +00:00
|
|
|
dimm_params[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_SYS_DIMM_SLOTS_PER_CTLR];
|
|
|
|
memctl_options_t memctl_opts[CONFIG_SYS_NUM_DDR_CTLRS];
|
|
|
|
common_timing_params_t common_timing_params[CONFIG_SYS_NUM_DDR_CTLRS];
|
|
|
|
fsl_ddr_cfg_regs_t fsl_ddr_config_reg[CONFIG_SYS_NUM_DDR_CTLRS];
|
2014-08-01 22:51:00 +00:00
|
|
|
unsigned int first_ctrl;
|
|
|
|
unsigned int num_ctrls;
|
|
|
|
unsigned long long mem_base;
|
|
|
|
unsigned int dimm_slots_per_ctrl;
|
|
|
|
int (*board_need_mem_reset)(void);
|
|
|
|
void (*board_mem_reset)(void);
|
|
|
|
void (*board_mem_de_reset)(void);
|
2008-08-26 20:01:29 +00:00
|
|
|
} fsl_ddr_info_t;
|
|
|
|
|
|
|
|
/* Compute steps */
|
|
|
|
#define STEP_GET_SPD (1 << 0)
|
|
|
|
#define STEP_COMPUTE_DIMM_PARMS (1 << 1)
|
|
|
|
#define STEP_COMPUTE_COMMON_PARMS (1 << 2)
|
|
|
|
#define STEP_GATHER_OPTS (1 << 3)
|
|
|
|
#define STEP_ASSIGN_ADDRESSES (1 << 4)
|
|
|
|
#define STEP_COMPUTE_REGS (1 << 5)
|
|
|
|
#define STEP_PROGRAM_REGS (1 << 6)
|
|
|
|
#define STEP_ALL 0xFFF
|
|
|
|
|
2011-09-16 20:21:35 +00:00
|
|
|
unsigned long long
|
2010-12-01 15:35:31 +00:00
|
|
|
fsl_ddr_compute(fsl_ddr_info_t *pinfo, unsigned int start_step,
|
|
|
|
unsigned int size_only);
|
2011-09-16 20:21:35 +00:00
|
|
|
const char *step_to_string(unsigned int step);
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int compute_fsl_memctl_config_regs(const unsigned int ctrl_num,
|
|
|
|
const memctl_options_t *popts,
|
2008-08-26 20:01:29 +00:00
|
|
|
fsl_ddr_cfg_regs_t *ddr,
|
|
|
|
const common_timing_params_t *common_dimm,
|
|
|
|
const dimm_params_t *dimm_parameters,
|
2010-12-01 15:35:31 +00:00
|
|
|
unsigned int dbw_capacity_adjust,
|
|
|
|
unsigned int size_only);
|
2011-09-16 20:21:35 +00:00
|
|
|
unsigned int compute_lowest_common_dimm_parameters(
|
2015-01-06 21:18:50 +00:00
|
|
|
const unsigned int ctrl_num,
|
2011-09-16 20:21:35 +00:00
|
|
|
const dimm_params_t *dimm_params,
|
|
|
|
common_timing_params_t *outpdimm,
|
|
|
|
unsigned int number_of_dimms);
|
2015-07-23 21:04:48 +00:00
|
|
|
unsigned int populate_memctl_options(const common_timing_params_t *common_dimm,
|
2008-08-26 20:01:29 +00:00
|
|
|
memctl_options_t *popts,
|
2008-10-03 16:36:55 +00:00
|
|
|
dimm_params_t *pdimm,
|
2008-08-26 20:01:29 +00:00
|
|
|
unsigned int ctrl_num);
|
2011-09-16 20:21:35 +00:00
|
|
|
void check_interleaving_options(fsl_ddr_info_t *pinfo);
|
2008-08-26 20:01:29 +00:00
|
|
|
|
2015-01-06 21:18:50 +00:00
|
|
|
unsigned int mclk_to_picos(const unsigned int ctrl_num, unsigned int mclk);
|
|
|
|
unsigned int get_memory_clk_period_ps(const unsigned int ctrl_num);
|
|
|
|
unsigned int picos_to_mclk(const unsigned int ctrl_num, unsigned int picos);
|
2011-09-16 20:21:35 +00:00
|
|
|
void fsl_ddr_set_lawbar(
|
|
|
|
const common_timing_params_t *memctl_common_params,
|
|
|
|
unsigned int memctl_interleaved,
|
|
|
|
unsigned int ctrl_num);
|
2015-01-06 21:18:55 +00:00
|
|
|
void fsl_ddr_sync_memctl_refresh(unsigned int first_ctrl,
|
|
|
|
unsigned int last_ctrl);
|
2011-09-16 20:21:35 +00:00
|
|
|
|
2013-01-07 14:01:03 +00:00
|
|
|
int fsl_ddr_interactive_env_var_exists(void);
|
|
|
|
unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set);
|
2011-09-16 20:21:35 +00:00
|
|
|
void fsl_ddr_get_spd(generic_spd_eeprom_t *ctrl_dimms_spd,
|
2014-08-01 22:51:00 +00:00
|
|
|
unsigned int ctrl_num, unsigned int dimm_slots_per_ctrl);
|
2011-09-16 20:21:35 +00:00
|
|
|
|
2020-05-10 17:40:03 +00:00
|
|
|
int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);
|
2011-09-16 20:21:35 +00:00
|
|
|
unsigned int check_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr);
|
2014-02-10 21:59:42 +00:00
|
|
|
void board_add_ram_info(int use_default);
|
2011-09-16 20:21:35 +00:00
|
|
|
|
|
|
|
/* processor specific function */
|
|
|
|
void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
|
2013-06-25 18:37:48 +00:00
|
|
|
unsigned int ctrl_num, int step);
|
2015-11-04 17:53:10 +00:00
|
|
|
void remove_unused_controllers(fsl_ddr_info_t *info);
|
2011-06-07 01:42:16 +00:00
|
|
|
|
|
|
|
/* board specific function */
|
|
|
|
int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
|
|
|
|
unsigned int controller_number,
|
|
|
|
unsigned int dimm_number);
|
2015-05-28 09:24:08 +00:00
|
|
|
void update_spd_address(unsigned int ctrl_num,
|
|
|
|
unsigned int slot,
|
|
|
|
unsigned int *addr);
|
2016-11-21 03:36:48 +00:00
|
|
|
|
|
|
|
void erratum_a009942_check_cpo(void);
|
2008-08-26 20:01:29 +00:00
|
|
|
#endif
|