1
2
3
4
5
6
7
8
9#include <common.h>
10
11#include <fsl_ddr_sdram.h>
12#include <fsl_ddr_dimm_params.h>
13
14struct board_specific_parameters {
15 u32 n_ranks;
16 u32 datarate_mhz_high;
17 u32 clk_adjust;
18 u32 cpo;
19 u32 write_data_delay;
20 u32 force_2t;
21};
22
23
24
25
26
27
28static const struct board_specific_parameters dimm0[] = {
29
30
31
32
33
34 {1, 549, 5, 31, 3, 0},
35 {1, 850, 5, 31, 5, 0},
36 {2, 549, 5, 31, 3, 0},
37 {2, 850, 5, 31, 5, 0},
38 {}
39};
40
41void fsl_ddr_board_options(memctl_options_t *popts, dimm_params_t *pdimm,
42 unsigned int ctrl_num)
43{
44 const struct board_specific_parameters *pbsp, *pbsp_highest = NULL;
45 unsigned long ddr_freq;
46 unsigned int i;
47
48
49 if (ctrl_num) {
50 printf("Wrong parameter for controller number %d", ctrl_num);
51 return;
52 }
53 if (!pdimm->n_ranks)
54 return;
55
56
57 for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
58 popts->cs_local_opts[i].odt_rd_cfg = 0;
59 popts->cs_local_opts[i].odt_wr_cfg = 1;
60 }
61
62 pbsp = dimm0;
63
64
65
66
67 ddr_freq = get_ddr_freq(0) / 1000000;
68 while (pbsp->datarate_mhz_high) {
69 if (pbsp->n_ranks == pdimm->n_ranks) {
70 if (ddr_freq <= pbsp->datarate_mhz_high) {
71 popts->clk_adjust = pbsp->clk_adjust;
72 popts->cpo_override = pbsp->cpo;
73 popts->write_data_delay =
74 pbsp->write_data_delay;
75 popts->twot_en = pbsp->force_2t;
76 goto found;
77 }
78 pbsp_highest = pbsp;
79 }
80 pbsp++;
81 }
82
83 if (pbsp_highest) {
84 printf("Error: board specific timing not found "
85 "for data rate %lu MT/s!\n"
86 "Trying to use the highest speed (%u) parameters\n",
87 ddr_freq, pbsp_highest->datarate_mhz_high);
88 popts->clk_adjust = pbsp->clk_adjust;
89 popts->cpo_override = pbsp->cpo;
90 popts->write_data_delay = pbsp->write_data_delay;
91 popts->twot_en = pbsp->force_2t;
92 } else {
93 panic("DIMM is not supported by this board");
94 }
95
96found:
97 popts->half_strength_driver_enable = 1;
98
99
100 popts->zq_en = 1;
101
102
103
104
105 popts->auto_self_refresh_en = 1;
106 popts->sr_it = 0xb;
107}
108