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