Blame view

include/fsl_ddr.h 3.45 KB
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
1
  /*
fc0c2b6fc   Haiying Wang   8xxx/ddr: add sup...
2
   * Copyright 2008-2011 Freescale Semiconductor, Inc.
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
3
4
5
6
7
8
9
10
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * Version 2 as published by the Free Software Foundation.
   */
  
  #ifndef FSL_DDR_MAIN_H
  #define FSL_DDR_MAIN_H
5614e71b4   York Sun   Driver/DDR: Movin...
11
12
  #include <fsl_ddr_sdram.h>
  #include <fsl_ddr_dimm_params.h>
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
13

5614e71b4   York Sun   Driver/DDR: Movin...
14
  #include <common_timing_params.h>
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
15

1b3e3c4f2   York Sun   powerpc/mpc8xxx: ...
16
  #if defined(CONFIG_DDR_SPD) || defined(CONFIG_SPD_EEPROM)
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
17
18
19
20
21
22
23
24
25
26
27
  /*
   * Bind the main DDR setup driver's generic names
   * to this specific DDR technology.
   */
  static __inline__ int
  compute_dimm_parameters(const generic_spd_eeprom_t *spd,
  			dimm_params_t *pdimm,
  			unsigned int dimm_number)
  {
  	return ddr_compute_dimm_parameters(spd, pdimm, dimm_number);
  }
1b3e3c4f2   York Sun   powerpc/mpc8xxx: ...
28
  #endif
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
29
30
31
32
33
34
  
  /*
   * Data Structures
   *
   * All data structures have to be on the stack
   */
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
35
36
  #define CONFIG_SYS_NUM_DDR_CTLRS CONFIG_NUM_DDR_CONTROLLERS
  #define CONFIG_SYS_DIMM_SLOTS_PER_CTLR CONFIG_DIMM_SLOTS_PER_CTLR
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
37
38
39
  
  typedef struct {
  	generic_spd_eeprom_t
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
40
  	   spd_installed_dimms[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_SYS_DIMM_SLOTS_PER_CTLR];
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
41
  	struct dimm_params_s
6d0f6bcf3   Jean-Christophe PLAGNIOL-VILLARD   rename CFG_ macro...
42
43
44
45
  	   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];
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
46
47
48
49
50
51
52
53
54
55
56
  } 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
6f5e1dc53   York Sun   powerpc/8xxx: Add...
57
  unsigned long long
fc0c2b6fc   Haiying Wang   8xxx/ddr: add sup...
58
59
  fsl_ddr_compute(fsl_ddr_info_t *pinfo, unsigned int start_step,
  				       unsigned int size_only);
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
60

6f5e1dc53   York Sun   powerpc/8xxx: Add...
61
  const char *step_to_string(unsigned int step);
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
62

6f5e1dc53   York Sun   powerpc/8xxx: Add...
63
  unsigned int compute_fsl_memctl_config_regs(const memctl_options_t *popts,
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
64
65
66
  			       fsl_ddr_cfg_regs_t *ddr,
  			       const common_timing_params_t *common_dimm,
  			       const dimm_params_t *dimm_parameters,
fc0c2b6fc   Haiying Wang   8xxx/ddr: add sup...
67
68
  			       unsigned int dbw_capacity_adjust,
  			       unsigned int size_only);
6f5e1dc53   York Sun   powerpc/8xxx: Add...
69
70
71
72
  unsigned int compute_lowest_common_dimm_parameters(
  				const dimm_params_t *dimm_params,
  				common_timing_params_t *outpdimm,
  				unsigned int number_of_dimms);
0dd38a35f   Priyanka Jain   powerpc: Fix Came...
73
  unsigned int populate_memctl_options(int all_dimms_registered,
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
74
  				memctl_options_t *popts,
dfb49108e   Haiying Wang   Pass dimm paramet...
75
  				dimm_params_t *pdimm,
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
76
  				unsigned int ctrl_num);
6f5e1dc53   York Sun   powerpc/8xxx: Add...
77
  void check_interleaving_options(fsl_ddr_info_t *pinfo);
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
78

6f5e1dc53   York Sun   powerpc/8xxx: Add...
79
80
81
82
83
84
85
  unsigned int mclk_to_picos(unsigned int mclk);
  unsigned int get_memory_clk_period_ps(void);
  unsigned int picos_to_mclk(unsigned int picos);
  void fsl_ddr_set_lawbar(
  		const common_timing_params_t *memctl_common_params,
  		unsigned int memctl_interleaved,
  		unsigned int ctrl_num);
e8ba6c503   James Yang   powerpc/mpc8xxxx:...
86
87
  int fsl_ddr_interactive_env_var_exists(void);
  unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo, int var_is_set);
6f5e1dc53   York Sun   powerpc/8xxx: Add...
88
89
90
91
92
93
94
95
  void fsl_ddr_get_spd(generic_spd_eeprom_t *ctrl_dimms_spd,
  			   unsigned int ctrl_num);
  
  int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  unsigned int check_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr);
  
  /* processor specific function */
  void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
c63e13701   York Sun   powerpc/mpc8xxx: ...
96
  				   unsigned int ctrl_num, int step);
1b3e3c4f2   York Sun   powerpc/mpc8xxx: ...
97
98
99
100
101
  
  /* board specific function */
  int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
  			unsigned int controller_number,
  			unsigned int dimm_number);
58e5e9aff   Kumar Gala   FSL DDR: Rewrite ...
102
  #endif