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, 3, 3, 3, 9, 10 },
50 { 16, 14, 3, 3, 3, 3, 9, 11 },
51 { 18, 16, 3, 3, 3, 3, 10, 12 },
52 { 20, 18, 4, 3, 4, 4, 10, 12 },
53 { 22, 22, 4, 4, 4, 4, 11, 12 },
54 { 24, 24, 4, 4, 4, 4, 11, 12 },
55 { 28, 26, 4, 4, 4, 4, 12, 12 },
56 { 32, 28, 5, 4, 5, 5, 12, 12 },
57 { 36, 32, 5, 5, 5, 5, 13, 13 },
58 { 40, 36, 5, 5, 5, 5, 14, 13 },
59 { 43, 40, 5, 5, 5, 5, 15, 14 },
60 { 43, 43, 5, 5, 6, 5, 15, 14 },
61 { 43, 43, 6, 5, 6, 5, 15, 15 },
62 { 43, 43, 6, 5, 6, 6, 15, 15 },
63 { 43, 43, 6, 6, 6, 6, 15, 15 },
64 { 43, 43, 6, 6, 7, 6, 15, 15 },
65 { 43, 43, 7, 6, 7, 6, 15, 15 },
66 { 43, 43, 7, 7, 7, 7, 15, 15 },
67 { 43, 43, 7, 7, 7, 7, 15, 15 },
68 { 43, 43, 7, 7, 7, 7, 15, 15 },
69 { 43, 43, 8, 7, 8, 7, 15, 15 },
70 { 43, 43, 8, 8, 8, 8, 15, 15 },
71 { 43, 43, 8, 8, 8, 8, 15, 15 },
72 { 43, 43, 8, 8, 8, 8, 15, 15 },
73 { 43, 43, 8, 8, 8, 8, 15, 15 },
74 { 43, 43, 8, 8, 8, 8, 15, 15 },
75 { 43, 43, 8, 8, 8, 8, 15, 15 },
76 { 43, 43, 8, 8, 8, 8, 15, 15 },
77 { 43, 43, 8, 8, 8, 8, 15, 15 },
78 { 43, 43, 8, 8, 8, 8, 15, 15 },
79 { 43, 43, 8, 8, 8, 8, 15, 15 },
82 { 8, 8, 3, 3, 3, 3, 5, 5 },
83 { 8, 8, 3, 3, 3, 3, 5, 5 },
84 { 8, 8, 3, 3, 3, 3, 5, 5 },
85 { 8, 8, 3, 3, 3, 3, 5, 5 },
86 { 8, 8, 3, 3, 3, 3, 5, 5 },
87 { 8, 8, 3, 3, 3, 3, 5, 5 },
88 { 8, 8, 3, 3, 3, 3, 5, 5 },
89 { 8, 8, 3, 3, 3, 3, 5, 5 },
90 { 8, 8, 3, 3, 3, 3, 5, 5 },
91 { 8, 8, 3, 3, 3, 3, 5, 5 },
92 { 8, 8, 3, 3, 3, 3, 5, 5 },
93 { 8, 8, 3, 3, 3, 3, 5, 5 },
94 { 8, 8, 3, 3, 3, 3, 5, 5 },
95 { 8, 8, 3, 3, 3, 3, 5, 5 },
96 { 8, 8, 3, 3, 3, 3, 5, 5 },
97 { 8, 8, 3, 3, 3, 3, 5, 5 },
98 { 8, 8, 3, 3, 3, 3, 5, 5 },
99 { 8, 8, 3, 3, 3, 3, 5, 5 },
100 { 8, 8, 3, 3, 3, 3, 5, 5 },
101 { 8, 8, 3, 3, 3, 3, 5, 5 },
102 { 8, 8, 3, 3, 3, 3, 5, 5 },
103 { 8, 8, 3, 3, 3, 3, 5, 5 },
104 { 8, 8, 3, 3, 3, 3, 5, 5 },
105 { 8, 8, 3, 3, 3, 3, 5, 5 },
106 { 8, 8, 3, 3, 3, 3, 5, 5 },
107 { 8, 8, 3, 3, 3, 3, 5, 5 },
108 { 9, 9, 3, 3, 3, 3, 6, 6 },
109 { 9, 9, 3, 3, 3, 3, 6, 6 },
110 { 10, 10, 3, 3, 3, 3, 7, 7 },
111 { 10, 10, 3, 3, 3, 3, 7, 7 },
112 { 12, 11, 3, 3, 3, 3, 8, 8 },
113 { 13, 11, 3, 3, 3, 3, 9, 9 },
114 { 14, 12, 3, 3, 3, 3, 9, 9 },
115 { 15, 13, 3, 3, 3, 3, 9, 9 },
116 { 16, 14, 3, 3, 3, 3, 9, 9 },
117 { 18, 16, 3, 3, 3, 3, 10, 10 },
118 { 20, 18, 4, 3, 4, 4, 10, 10 },
119 { 22, 22, 4, 4, 4, 4, 11, 11 },
120 { 24, 24, 4, 4, 4, 4, 11, 11 },
121 { 28, 26, 4, 4, 4, 4, 12, 12 },
122 { 32, 28, 5, 4, 5, 5, 12, 12 },
123 { 36, 32, 5, 5, 5, 5, 13, 13 },
124 { 40, 36, 5, 5, 5, 5, 14, 14 },
125 { 43, 40, 5, 5, 5, 5, 15, 15 },
126 { 43, 43, 5, 5, 6, 5, 15, 15 },
127 { 43, 43, 6, 5, 6, 5, 15, 15 },
128 { 43, 43, 6, 5, 6, 6, 15, 15 },
129 { 43, 43, 6, 6, 6, 6, 15, 15 },
130 { 43, 43, 6, 6, 7, 6, 15, 15 },
131 { 43, 43, 7, 6, 7, 6, 15, 15 },
132 { 43, 43, 7, 7, 7, 7, 15, 15 },
133 { 43, 43, 7, 7, 7, 7, 15, 15 },
134 { 43, 43, 7, 7, 7, 7, 15, 15 },
135 { 43, 43, 8, 7, 8, 7, 15, 15 },
136 { 43, 43, 8, 8, 8, 8, 15, 15 },
137 { 43, 43, 8, 8, 8, 8, 15, 15 },
138 { 43, 43, 8, 8, 8, 8, 15, 15 },
139 { 43, 43, 8, 8, 8, 8, 15, 15 },
140 { 43, 43, 8, 8, 8, 8, 15, 15 },
141 { 43, 43, 8, 8, 8, 8, 15, 15 },
142 { 43, 43, 8, 8, 8, 8, 15, 15 },
143 { 43, 43, 8, 8, 8, 8, 15, 15 },
144 { 43, 43, 8, 8, 8, 8, 15, 15 },
145 { 43, 43, 8, 8, 8, 8, 15, 15 },
149 const int row,
const int col,
155 for (i = row; i < row + 16; i += 4) {
157 (
ddr3_lut[a1step][i + 0][col] & 0x3f) << 0 |
158 (
ddr3_lut[a1step][i + 1][col] & 0x3f) << 8 |
159 (
ddr3_lut[a1step][i + 2][col] & 0x3f) << 16 |
160 (
ddr3_lut[a1step][i + 3][col] & 0x3f) << 24);
174 char lut_idx[2][6][2];
175 for (i = 0; i < 2 * 6 * 2; ++i)
176 ((
char *)lut_idx)[i] = -1;
185 for (i = 0; i < 12; ++i) {
192 const unsigned int group = (reg >> 13) & 0x7;
193 const unsigned int channel = (reg >> 12) & 0x1;
197 lut_idx[channel][group][
PULL_UP] = (reg >> 24) & 0x7f;
198 lut_idx[channel][group][
PULL_DOWN] = (reg >> 16) & 0x7f;
207 for (i = 0; i < 2 * 6 * 2; ++i) {
208 const char idx = ((
char *)lut_idx)[i];
209 if ((idx < 7) || (idx > 55))
210 die(
"Bad RCOMP calibration lookup index.\n");
214 int channel, group, pu_pd;
215 unsigned int mchbar = 0x0680;
216 for (channel = 0; channel < 2; ++channel) {
217 for (group = 0; group < 6; ++group) {
221 lut_idx[channel][group][pu_pd] - 7,
228 if ((1 == channel) && (1 == group))
void __noreturn die(const char *fmt,...)
#define mchbar_setbits32(addr, set)
static __always_inline void mchbar_write32(const uintptr_t offset, const uint32_t value)
static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
#define mchbar_clrbits32(addr, clear)
static void lookup_and_write(const int a1step, const int row, const int col, unsigned int mchbar)
static const int ddr3_lookup_schedule[6][2]
void raminit_rcomp_calibration(const stepping_t stepping)
static const u8 ddr3_lut[2][64][8]