1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <i2c.h>
26#include <asm/fsl_ddr_sdram.h>
27#include <asm/fsl_ddr_dimm_params.h>
28
29void get_spd(ddr2_spd_eeprom_t *spd, u8 i2c_address)
30{
31 i2c_read(i2c_address, SPD_EEPROM_OFFSET, 2, (uchar *)spd,
32 sizeof(ddr2_spd_eeprom_t));
33}
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60typedef struct board_memctl_options {
61 uint16_t datarate_mhz_low;
62 uint16_t datarate_mhz_high;
63 uint8_t clk_adjust;
64 uint8_t cpo_override;
65 uint8_t write_data_delay;
66} board_memctl_options_t;
67
68static struct board_memctl_options bopts_ctrl[][2] = {
69 {
70
71 {
72
73 .datarate_mhz_low = 500,
74 .datarate_mhz_high = 750,
75 .clk_adjust = 5,
76 .cpo_override = 8,
77 .write_data_delay = 2,
78 },
79 {
80
81 .datarate_mhz_low = 750,
82 .datarate_mhz_high = 850,
83 .clk_adjust = 5,
84 .cpo_override = 9,
85 .write_data_delay = 2,
86 },
87 },
88 {
89
90 {
91
92 .datarate_mhz_low = 500,
93 .datarate_mhz_high = 750,
94 .clk_adjust = 5,
95 .cpo_override = 7,
96 .write_data_delay = 2,
97 },
98 {
99
100 .datarate_mhz_low = 750,
101 .datarate_mhz_high = 850,
102 .clk_adjust = 5,
103 .cpo_override = 8,
104 .write_data_delay = 2,
105 },
106 },
107};
108
109void fsl_ddr_board_options(memctl_options_t *popts,
110 dimm_params_t *pdimm,
111 unsigned int ctrl_num)
112{
113 struct board_memctl_options *bopts = bopts_ctrl[ctrl_num];
114 sys_info_t sysinfo;
115 int i;
116 unsigned int datarate;
117
118 get_sys_info(&sysinfo);
119 datarate = get_ddr_freq(0) / 1000000;
120
121 for (i = 0; i < ARRAY_SIZE(bopts_ctrl[ctrl_num]); i++) {
122 if ((bopts[i].datarate_mhz_low <= datarate) &&
123 (bopts[i].datarate_mhz_high >= datarate)) {
124 debug("controller %d:\n", ctrl_num);
125 debug(" clk_adjust = %d\n", bopts[i].clk_adjust);
126 debug(" cpo = %d\n", bopts[i].cpo_override);
127 debug(" write_data_delay = %d\n",
128 bopts[i].write_data_delay);
129 popts->clk_adjust = bopts[i].clk_adjust;
130 popts->cpo_override = bopts[i].cpo_override;
131 popts->write_data_delay = bopts[i].write_data_delay;
132 }
133 }
134
135
136
137
138
139 popts->half_strength_driver_enable = 0;
140}
141