ddr.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. extern unsigned long long
  52. fsl_ddr_compute(fsl_ddr_info_t *pinfo, unsigned int start_step,
  53. unsigned int size_only);
  54. extern const char * step_to_string(unsigned int step);
  55. extern unsigned int
  56. compute_fsl_memctl_config_regs(const memctl_options_t *popts,
  57. fsl_ddr_cfg_regs_t *ddr,
  58. const common_timing_params_t *common_dimm,
  59. const dimm_params_t *dimm_parameters,
  60. unsigned int dbw_capacity_adjust,
  61. unsigned int size_only);
  62. extern unsigned int
  63. compute_lowest_common_dimm_parameters(const dimm_params_t *dimm_params,
  64. common_timing_params_t *outpdimm,
  65. unsigned int number_of_dimms);
  66. extern unsigned int populate_memctl_options(int all_DIMMs_registered,
  67. memctl_options_t *popts,
  68. dimm_params_t *pdimm,
  69. unsigned int ctrl_num);
  70. extern void check_interleaving_options(fsl_ddr_info_t *pinfo);
  71. extern unsigned int mclk_to_picos(unsigned int mclk);
  72. extern unsigned int get_memory_clk_period_ps(void);
  73. extern unsigned int picos_to_mclk(unsigned int picos);
  74. /* board specific function */
  75. int fsl_ddr_get_dimm_params(dimm_params_t *pdimm,
  76. unsigned int controller_number,
  77. unsigned int dimm_number);
  78. #endif