1
2
3
4
5
6
7
8#include <common.h>
9#include <i2c.h>
10
11#include <fsl_ddr_sdram.h>
12#include <fsl_ddr_dimm_params.h>
13
14void get_spd(ddr3_spd_eeprom_t *spd, u8 i2c_address)
15{
16 i2c_read(i2c_address, SPD_EEPROM_OFFSET, 2, (uchar *)spd,
17 sizeof(ddr3_spd_eeprom_t));
18}
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41typedef struct {
42 unsigned short datarate_mhz_low;
43 unsigned short datarate_mhz_high;
44 unsigned char clk_adjust;
45 unsigned char cpo;
46} board_specific_parameters_t;
47
48const board_specific_parameters_t board_specific_parameters[][20] = {
49 {
50
51 {
52
53 .datarate_mhz_low = 500,
54 .datarate_mhz_high = 750,
55 .clk_adjust = 5,
56 .cpo = 31,
57 },
58 {
59
60 .datarate_mhz_low = 750,
61 .datarate_mhz_high = 850,
62 .clk_adjust = 5,
63 .cpo = 31,
64 },
65 },
66};
67
68void fsl_ddr_board_options(memctl_options_t *popts,
69 dimm_params_t *pdimm,
70 unsigned int ctrl_num)
71{
72 const board_specific_parameters_t *pbsp =
73 &(board_specific_parameters[ctrl_num][0]);
74 u32 num_params = sizeof(board_specific_parameters[ctrl_num]) /
75 sizeof(board_specific_parameters[0][0]);
76 u32 i;
77 ulong ddr_freq;
78
79
80
81
82
83
84
85 for (i = 0; i < CONFIG_CHIP_SELECTS_PER_CTRL; i++) {
86 if (i&1) {
87 popts->cs_local_opts[i].odt_rd_cfg = 0;
88 popts->cs_local_opts[i].odt_wr_cfg = 0;
89 } else {
90 if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) {
91 popts->cs_local_opts[i].odt_rd_cfg = 0;
92 popts->cs_local_opts[i].odt_wr_cfg = 4;
93 } else if (CONFIG_DIMM_SLOTS_PER_CTLR == 2) {
94 popts->cs_local_opts[i].odt_rd_cfg = 3;
95 popts->cs_local_opts[i].odt_wr_cfg = 3;
96 }
97 }
98 }
99
100
101
102
103
104 ddr_freq = get_ddr_freq(0) / 1000000;
105
106 for (i = 0; i < num_params; i++) {
107 if (ddr_freq >= pbsp->datarate_mhz_low &&
108 ddr_freq <= pbsp->datarate_mhz_high) {
109 popts->clk_adjust = pbsp->clk_adjust;
110 popts->cpo_override = pbsp->cpo;
111 popts->twot_en = 0;
112 break;
113 }
114 pbsp++;
115 }
116
117 if (i == num_params) {
118 printf("Warning: board specific timing not found "
119 "for data rate %lu MT/s!\n", ddr_freq);
120 }
121
122
123
124
125
126 popts->half_strength_driver_enable = 0;
127
128
129
130
131
132
133
134 popts->rtt_override = 1;
135 popts->rtt_override_value = 3;
136}
137