ddr.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright 2008-2011 Freescale Semiconductor, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * Version 2 as published by the Free Software Foundation.
  7. */
  8. #ifndef FSL_DDR_MAIN_H
  9. #define FSL_DDR_MAIN_H
  10. #include <asm/fsl_ddr_sdram.h>
  11. #include <asm/fsl_ddr_dimm_params.h>
  12. #include "common_timing_params.h"
  13. #if defined(CONFIG_DDR_SPD) || defined(CONFIG_SPD_EEPROM)
  14. /*
  15. * Bind the main DDR setup driver's generic names
  16. * to this specific DDR technology.
  17. */
  18. static __inline__ int
  19. compute_dimm_parameters(const generic_spd_eeprom_t *spd,
  20. dimm_params_t *pdimm,
  21. unsigned int dimm_number)
  22. {
  23. return ddr_compute_dimm_parameters(spd, pdimm, dimm_number);
  24. }
  25. #endif
  26. /*
  27. * Data Structures
  28. *
  29. * All data structures have to be on the stack
  30. */
  31. #define CONFIG_SYS_NUM_DDR_CTLRS CONFIG_NUM_DDR_CONTROLLERS
  32. #define CONFIG_SYS_DIMM_SLOTS_PER_CTLR CONFIG_DIMM_SLOTS_PER_CTLR
  33. typedef struct {
  34. generic_spd_eeprom_t
  35. spd_installed_dimms[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_SYS_DIMM_SLOTS_PER_CTLR];
  36. struct dimm_params_s
  37. dimm_params[CONFIG_SYS_NUM_DDR_CTLRS][CONFIG_SYS_DIMM_SLOTS_PER_CTLR];
  38. memctl_options_t memctl_opts[CONFIG_SYS_NUM_DDR_CTLRS];
  39. common_timing_params_t common_timing_params[CONFIG_SYS_NUM_DDR_CTLRS];
  40. fsl_ddr_cfg_regs_t fsl_ddr_config_reg[CONFIG_SYS_NUM_DDR_CTLRS];
  41. } fsl_ddr_info_t;
  42. /* Compute steps */
  43. #define STEP_GET_SPD (1 << 0)
  44. #define STEP_COMPUTE_DIMM_PARMS (1 << 1)
  45. #define STEP_COMPUTE_COMMON_PARMS (1 << 2)
  46. #define STEP_GATHER_OPTS (1 << 3)
  47. #define STEP_ASSIGN_ADDRESSES (1 << 4)
  48. #define STEP_COMPUTE_REGS (1 << 5)
  49. #define STEP_PROGRAM_REGS (1 << 6)
  50. #define STEP_ALL 0xFFF
  51. unsigned long long
  52. fsl_ddr_compute(fsl_ddr_info_t *pinfo, unsigned int start_step,
  53. unsigned int size_only);
  54. const char *step_to_string(unsigned int step);
  55. unsigned int compute_fsl_memctl_config_regs(const memctl_options_t *popts,
  56. fsl_ddr_cfg_regs_t *ddr,
  57. const common_timing_params_t *common_dimm,
  58. const dimm_params_t *dimm_parameters,
  59. unsigned int dbw_capacity_adjust,
  60. unsigned int size_only);
  61. unsigned int compute_lowest_common_dimm_parameters(
  62. const dimm_params_t *dimm_params,
  63. common_timing_params_t *outpdimm,
  64. unsigned int number_of_dimms);
  65. unsigned int populate_memctl_options(int all_DIMMs_registered,
  66. memctl_options_t *popts,
  67. dimm_params_t *pdimm,
  68. unsigned int ctrl_num);
  69. void check_interleaving_options(fsl_ddr_info_t *pinfo);
  70. unsigned int mclk_to_picos(unsigned int mclk);
  71. unsigned int get_memory_clk_period_ps(void);
  72. unsigned int picos_to_mclk(unsigned int picos);
  73. void fsl_ddr_set_lawbar(
  74. const common_timing_params_t *memctl_common_params,
  75. unsigned int memctl_interleaved,
  76. unsigned int ctrl_num);
  77. unsigned long long fsl_ddr_interactive(fsl_ddr_info_t *pinfo);
  78. void fsl_ddr_get_spd(generic_spd_eeprom_t *ctrl_dimms_spd,
  79. unsigned int ctrl_num);
  80. int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);
  81. unsigned int check_fsl_memctl_config_regs(const fsl_ddr_cfg_regs_t *ddr);
  82. /* processor specific function */
  83. void fsl_ddr_set_memctl_regs(const fsl_ddr_cfg_regs_t *regs,
  84. unsigned int ctrl_num);
  85. /* board specific function */
  86. int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
  87. unsigned int controller_number,
  88. unsigned int dimm_number);
  89. #endif