]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | Commit-Id: 1e8820256f9921370cd7423396871e2d850e0323 |
2 | From: Divy Le Ray <divy@chelsio.com> | |
3 | Date: Wed, 8 Oct 2008 17:40:07 -0700 | |
4 | Acked-by: Karsten Keil <kkeil@novell.com> | |
5 | Subject: [PATCH] cxgb3: Support for Aeluros 2005 PHY | |
6 | Reference: bnc#446739 | |
7 | ||
8 | ||
9 | Add support for SR PHY. | |
10 | Auto-detect phy module type, and report type changes. | |
11 | ||
12 | Signed-off-by: Divy Le Ray <divy@chelsio.com> | |
13 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
14 | ||
15 | Index: linux-2.6.27/drivers/net/cxgb3/ael1002.c | |
16 | =================================================================== | |
17 | --- linux-2.6.27.orig/drivers/net/cxgb3/ael1002.c | |
18 | +++ linux-2.6.27/drivers/net/cxgb3/ael1002.c | |
19 | @@ -33,14 +33,57 @@ | |
20 | #include "regs.h" | |
21 | ||
22 | enum { | |
23 | + PMD_RSD = 10, /* PMA/PMD receive signal detect register */ | |
24 | + PCS_STAT1_X = 24, /* 10GBASE-X PCS status 1 register */ | |
25 | + PCS_STAT1_R = 32, /* 10GBASE-R PCS status 1 register */ | |
26 | + XS_LN_STAT = 24 /* XS lane status register */ | |
27 | +}; | |
28 | + | |
29 | +enum { | |
30 | AEL100X_TX_DISABLE = 9, | |
31 | AEL100X_TX_CONFIG1 = 0xc002, | |
32 | AEL1002_PWR_DOWN_HI = 0xc011, | |
33 | AEL1002_PWR_DOWN_LO = 0xc012, | |
34 | AEL1002_XFI_EQL = 0xc015, | |
35 | AEL1002_LB_EN = 0xc017, | |
36 | + AEL_OPT_SETTINGS = 0xc017, | |
37 | + AEL_I2C_CTRL = 0xc30a, | |
38 | + AEL_I2C_DATA = 0xc30b, | |
39 | + AEL_I2C_STAT = 0xc30c, | |
40 | + AEL2005_GPIO_CTRL = 0xc214, | |
41 | + AEL2005_GPIO_STAT = 0xc215, | |
42 | }; | |
43 | ||
44 | +enum { edc_none, edc_sr, edc_twinax }; | |
45 | + | |
46 | +/* PHY module I2C device address */ | |
47 | +#define MODULE_DEV_ADDR 0xa0 | |
48 | + | |
49 | +#define AEL2005_MODDET_IRQ 4 | |
50 | + | |
51 | +struct reg_val { | |
52 | + unsigned short mmd_addr; | |
53 | + unsigned short reg_addr; | |
54 | + unsigned short clear_bits; | |
55 | + unsigned short set_bits; | |
56 | +}; | |
57 | + | |
58 | +static int set_phy_regs(struct cphy *phy, const struct reg_val *rv) | |
59 | +{ | |
60 | + int err; | |
61 | + | |
62 | + for (err = 0; rv->mmd_addr && !err; rv++) { | |
63 | + if (rv->clear_bits == 0xffff) | |
64 | + err = mdio_write(phy, rv->mmd_addr, rv->reg_addr, | |
65 | + rv->set_bits); | |
66 | + else | |
67 | + err = t3_mdio_change_bits(phy, rv->mmd_addr, | |
68 | + rv->reg_addr, rv->clear_bits, | |
69 | + rv->set_bits); | |
70 | + } | |
71 | + return err; | |
72 | +} | |
73 | + | |
74 | static void ael100x_txon(struct cphy *phy) | |
75 | { | |
76 | int tx_on_gpio = phy->addr == 0 ? F_GPIO7_OUT_VAL : F_GPIO2_OUT_VAL; | |
77 | @@ -81,23 +124,23 @@ static int ael1002_intr_noop(struct cphy | |
78 | return 0; | |
79 | } | |
80 | ||
81 | -static int ael100x_get_link_status(struct cphy *phy, int *link_ok, | |
82 | - int *speed, int *duplex, int *fc) | |
83 | +/* | |
84 | + * Get link status for a 10GBASE-R device. | |
85 | + */ | |
86 | +static int get_link_status_r(struct cphy *phy, int *link_ok, int *speed, | |
87 | + int *duplex, int *fc) | |
88 | { | |
89 | if (link_ok) { | |
90 | - unsigned int status; | |
91 | - int err = mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, &status); | |
92 | + unsigned int stat0, stat1, stat2; | |
93 | + int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); | |
94 | ||
95 | - /* | |
96 | - * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it | |
97 | - * once more to get the current link state. | |
98 | - */ | |
99 | - if (!err && !(status & BMSR_LSTATUS)) | |
100 | - err = mdio_read(phy, MDIO_DEV_PMA_PMD, MII_BMSR, | |
101 | - &status); | |
102 | + if (!err) | |
103 | + err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_R, &stat1); | |
104 | + if (!err) | |
105 | + err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); | |
106 | if (err) | |
107 | return err; | |
108 | - *link_ok = !!(status & BMSR_LSTATUS); | |
109 | + *link_ok = (stat0 & stat1 & (stat2 >> 12)) & 1; | |
110 | } | |
111 | if (speed) | |
112 | *speed = SPEED_10000; | |
113 | @@ -112,7 +155,7 @@ static struct cphy_ops ael1002_ops = { | |
114 | .intr_disable = ael1002_intr_noop, | |
115 | .intr_clear = ael1002_intr_noop, | |
116 | .intr_handler = ael1002_intr_noop, | |
117 | - .get_link_status = ael100x_get_link_status, | |
118 | + .get_link_status = get_link_status_r, | |
119 | .power_down = ael1002_power_down, | |
120 | }; | |
121 | ||
122 | @@ -143,7 +186,7 @@ static struct cphy_ops ael1006_ops = { | |
123 | .intr_disable = t3_phy_lasi_intr_disable, | |
124 | .intr_clear = t3_phy_lasi_intr_clear, | |
125 | .intr_handler = t3_phy_lasi_intr_handler, | |
126 | - .get_link_status = ael100x_get_link_status, | |
127 | + .get_link_status = get_link_status_r, | |
128 | .power_down = ael1006_power_down, | |
129 | }; | |
130 | ||
131 | @@ -157,13 +200,948 @@ int t3_ael1006_phy_prep(struct cphy *phy | |
132 | return 0; | |
133 | } | |
134 | ||
135 | +static int ael2005_setup_sr_edc(struct cphy *phy) | |
136 | +{ | |
137 | + static struct reg_val regs[] = { | |
138 | + { MDIO_DEV_PMA_PMD, 0xc003, 0xffff, 0x181 }, | |
139 | + { MDIO_DEV_PMA_PMD, 0xc010, 0xffff, 0x448a }, | |
140 | + { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5200 }, | |
141 | + { 0, 0, 0, 0 } | |
142 | + }; | |
143 | + static u16 sr_edc[] = { | |
144 | + 0xcc00, 0x2ff4, | |
145 | + 0xcc01, 0x3cd4, | |
146 | + 0xcc02, 0x2015, | |
147 | + 0xcc03, 0x3105, | |
148 | + 0xcc04, 0x6524, | |
149 | + 0xcc05, 0x27ff, | |
150 | + 0xcc06, 0x300f, | |
151 | + 0xcc07, 0x2c8b, | |
152 | + 0xcc08, 0x300b, | |
153 | + 0xcc09, 0x4009, | |
154 | + 0xcc0a, 0x400e, | |
155 | + 0xcc0b, 0x2f72, | |
156 | + 0xcc0c, 0x3002, | |
157 | + 0xcc0d, 0x1002, | |
158 | + 0xcc0e, 0x2172, | |
159 | + 0xcc0f, 0x3012, | |
160 | + 0xcc10, 0x1002, | |
161 | + 0xcc11, 0x25d2, | |
162 | + 0xcc12, 0x3012, | |
163 | + 0xcc13, 0x1002, | |
164 | + 0xcc14, 0xd01e, | |
165 | + 0xcc15, 0x27d2, | |
166 | + 0xcc16, 0x3012, | |
167 | + 0xcc17, 0x1002, | |
168 | + 0xcc18, 0x2004, | |
169 | + 0xcc19, 0x3c84, | |
170 | + 0xcc1a, 0x6436, | |
171 | + 0xcc1b, 0x2007, | |
172 | + 0xcc1c, 0x3f87, | |
173 | + 0xcc1d, 0x8676, | |
174 | + 0xcc1e, 0x40b7, | |
175 | + 0xcc1f, 0xa746, | |
176 | + 0xcc20, 0x4047, | |
177 | + 0xcc21, 0x5673, | |
178 | + 0xcc22, 0x2982, | |
179 | + 0xcc23, 0x3002, | |
180 | + 0xcc24, 0x13d2, | |
181 | + 0xcc25, 0x8bbd, | |
182 | + 0xcc26, 0x2862, | |
183 | + 0xcc27, 0x3012, | |
184 | + 0xcc28, 0x1002, | |
185 | + 0xcc29, 0x2092, | |
186 | + 0xcc2a, 0x3012, | |
187 | + 0xcc2b, 0x1002, | |
188 | + 0xcc2c, 0x5cc3, | |
189 | + 0xcc2d, 0x314, | |
190 | + 0xcc2e, 0x2942, | |
191 | + 0xcc2f, 0x3002, | |
192 | + 0xcc30, 0x1002, | |
193 | + 0xcc31, 0xd019, | |
194 | + 0xcc32, 0x2032, | |
195 | + 0xcc33, 0x3012, | |
196 | + 0xcc34, 0x1002, | |
197 | + 0xcc35, 0x2a04, | |
198 | + 0xcc36, 0x3c74, | |
199 | + 0xcc37, 0x6435, | |
200 | + 0xcc38, 0x2fa4, | |
201 | + 0xcc39, 0x3cd4, | |
202 | + 0xcc3a, 0x6624, | |
203 | + 0xcc3b, 0x5563, | |
204 | + 0xcc3c, 0x2d42, | |
205 | + 0xcc3d, 0x3002, | |
206 | + 0xcc3e, 0x13d2, | |
207 | + 0xcc3f, 0x464d, | |
208 | + 0xcc40, 0x2862, | |
209 | + 0xcc41, 0x3012, | |
210 | + 0xcc42, 0x1002, | |
211 | + 0xcc43, 0x2032, | |
212 | + 0xcc44, 0x3012, | |
213 | + 0xcc45, 0x1002, | |
214 | + 0xcc46, 0x2fb4, | |
215 | + 0xcc47, 0x3cd4, | |
216 | + 0xcc48, 0x6624, | |
217 | + 0xcc49, 0x5563, | |
218 | + 0xcc4a, 0x2d42, | |
219 | + 0xcc4b, 0x3002, | |
220 | + 0xcc4c, 0x13d2, | |
221 | + 0xcc4d, 0x2ed2, | |
222 | + 0xcc4e, 0x3002, | |
223 | + 0xcc4f, 0x1002, | |
224 | + 0xcc50, 0x2fd2, | |
225 | + 0xcc51, 0x3002, | |
226 | + 0xcc52, 0x1002, | |
227 | + 0xcc53, 0x004, | |
228 | + 0xcc54, 0x2942, | |
229 | + 0xcc55, 0x3002, | |
230 | + 0xcc56, 0x1002, | |
231 | + 0xcc57, 0x2092, | |
232 | + 0xcc58, 0x3012, | |
233 | + 0xcc59, 0x1002, | |
234 | + 0xcc5a, 0x5cc3, | |
235 | + 0xcc5b, 0x317, | |
236 | + 0xcc5c, 0x2f72, | |
237 | + 0xcc5d, 0x3002, | |
238 | + 0xcc5e, 0x1002, | |
239 | + 0xcc5f, 0x2942, | |
240 | + 0xcc60, 0x3002, | |
241 | + 0xcc61, 0x1002, | |
242 | + 0xcc62, 0x22cd, | |
243 | + 0xcc63, 0x301d, | |
244 | + 0xcc64, 0x2862, | |
245 | + 0xcc65, 0x3012, | |
246 | + 0xcc66, 0x1002, | |
247 | + 0xcc67, 0x2ed2, | |
248 | + 0xcc68, 0x3002, | |
249 | + 0xcc69, 0x1002, | |
250 | + 0xcc6a, 0x2d72, | |
251 | + 0xcc6b, 0x3002, | |
252 | + 0xcc6c, 0x1002, | |
253 | + 0xcc6d, 0x628f, | |
254 | + 0xcc6e, 0x2112, | |
255 | + 0xcc6f, 0x3012, | |
256 | + 0xcc70, 0x1002, | |
257 | + 0xcc71, 0x5aa3, | |
258 | + 0xcc72, 0x2dc2, | |
259 | + 0xcc73, 0x3002, | |
260 | + 0xcc74, 0x1312, | |
261 | + 0xcc75, 0x6f72, | |
262 | + 0xcc76, 0x1002, | |
263 | + 0xcc77, 0x2807, | |
264 | + 0xcc78, 0x31a7, | |
265 | + 0xcc79, 0x20c4, | |
266 | + 0xcc7a, 0x3c24, | |
267 | + 0xcc7b, 0x6724, | |
268 | + 0xcc7c, 0x1002, | |
269 | + 0xcc7d, 0x2807, | |
270 | + 0xcc7e, 0x3187, | |
271 | + 0xcc7f, 0x20c4, | |
272 | + 0xcc80, 0x3c24, | |
273 | + 0xcc81, 0x6724, | |
274 | + 0xcc82, 0x1002, | |
275 | + 0xcc83, 0x2514, | |
276 | + 0xcc84, 0x3c64, | |
277 | + 0xcc85, 0x6436, | |
278 | + 0xcc86, 0xdff4, | |
279 | + 0xcc87, 0x6436, | |
280 | + 0xcc88, 0x1002, | |
281 | + 0xcc89, 0x40a4, | |
282 | + 0xcc8a, 0x643c, | |
283 | + 0xcc8b, 0x4016, | |
284 | + 0xcc8c, 0x8c6c, | |
285 | + 0xcc8d, 0x2b24, | |
286 | + 0xcc8e, 0x3c24, | |
287 | + 0xcc8f, 0x6435, | |
288 | + 0xcc90, 0x1002, | |
289 | + 0xcc91, 0x2b24, | |
290 | + 0xcc92, 0x3c24, | |
291 | + 0xcc93, 0x643a, | |
292 | + 0xcc94, 0x4025, | |
293 | + 0xcc95, 0x8a5a, | |
294 | + 0xcc96, 0x1002, | |
295 | + 0xcc97, 0x2731, | |
296 | + 0xcc98, 0x3011, | |
297 | + 0xcc99, 0x1001, | |
298 | + 0xcc9a, 0xc7a0, | |
299 | + 0xcc9b, 0x100, | |
300 | + 0xcc9c, 0xc502, | |
301 | + 0xcc9d, 0x53ac, | |
302 | + 0xcc9e, 0xc503, | |
303 | + 0xcc9f, 0xd5d5, | |
304 | + 0xcca0, 0xc600, | |
305 | + 0xcca1, 0x2a6d, | |
306 | + 0xcca2, 0xc601, | |
307 | + 0xcca3, 0x2a4c, | |
308 | + 0xcca4, 0xc602, | |
309 | + 0xcca5, 0x111, | |
310 | + 0xcca6, 0xc60c, | |
311 | + 0xcca7, 0x5900, | |
312 | + 0xcca8, 0xc710, | |
313 | + 0xcca9, 0x700, | |
314 | + 0xccaa, 0xc718, | |
315 | + 0xccab, 0x700, | |
316 | + 0xccac, 0xc720, | |
317 | + 0xccad, 0x4700, | |
318 | + 0xccae, 0xc801, | |
319 | + 0xccaf, 0x7f50, | |
320 | + 0xccb0, 0xc802, | |
321 | + 0xccb1, 0x7760, | |
322 | + 0xccb2, 0xc803, | |
323 | + 0xccb3, 0x7fce, | |
324 | + 0xccb4, 0xc804, | |
325 | + 0xccb5, 0x5700, | |
326 | + 0xccb6, 0xc805, | |
327 | + 0xccb7, 0x5f11, | |
328 | + 0xccb8, 0xc806, | |
329 | + 0xccb9, 0x4751, | |
330 | + 0xccba, 0xc807, | |
331 | + 0xccbb, 0x57e1, | |
332 | + 0xccbc, 0xc808, | |
333 | + 0xccbd, 0x2700, | |
334 | + 0xccbe, 0xc809, | |
335 | + 0xccbf, 0x000, | |
336 | + 0xccc0, 0xc821, | |
337 | + 0xccc1, 0x002, | |
338 | + 0xccc2, 0xc822, | |
339 | + 0xccc3, 0x014, | |
340 | + 0xccc4, 0xc832, | |
341 | + 0xccc5, 0x1186, | |
342 | + 0xccc6, 0xc847, | |
343 | + 0xccc7, 0x1e02, | |
344 | + 0xccc8, 0xc013, | |
345 | + 0xccc9, 0xf341, | |
346 | + 0xccca, 0xc01a, | |
347 | + 0xcccb, 0x446, | |
348 | + 0xcccc, 0xc024, | |
349 | + 0xcccd, 0x1000, | |
350 | + 0xccce, 0xc025, | |
351 | + 0xcccf, 0xa00, | |
352 | + 0xccd0, 0xc026, | |
353 | + 0xccd1, 0xc0c, | |
354 | + 0xccd2, 0xc027, | |
355 | + 0xccd3, 0xc0c, | |
356 | + 0xccd4, 0xc029, | |
357 | + 0xccd5, 0x0a0, | |
358 | + 0xccd6, 0xc030, | |
359 | + 0xccd7, 0xa00, | |
360 | + 0xccd8, 0xc03c, | |
361 | + 0xccd9, 0x01c, | |
362 | + 0xccda, 0xc005, | |
363 | + 0xccdb, 0x7a06, | |
364 | + 0xccdc, 0x000, | |
365 | + 0xccdd, 0x2731, | |
366 | + 0xccde, 0x3011, | |
367 | + 0xccdf, 0x1001, | |
368 | + 0xcce0, 0xc620, | |
369 | + 0xcce1, 0x000, | |
370 | + 0xcce2, 0xc621, | |
371 | + 0xcce3, 0x03f, | |
372 | + 0xcce4, 0xc622, | |
373 | + 0xcce5, 0x000, | |
374 | + 0xcce6, 0xc623, | |
375 | + 0xcce7, 0x000, | |
376 | + 0xcce8, 0xc624, | |
377 | + 0xcce9, 0x000, | |
378 | + 0xccea, 0xc625, | |
379 | + 0xcceb, 0x000, | |
380 | + 0xccec, 0xc627, | |
381 | + 0xcced, 0x000, | |
382 | + 0xccee, 0xc628, | |
383 | + 0xccef, 0x000, | |
384 | + 0xccf0, 0xc62c, | |
385 | + 0xccf1, 0x000, | |
386 | + 0xccf2, 0x000, | |
387 | + 0xccf3, 0x2806, | |
388 | + 0xccf4, 0x3cb6, | |
389 | + 0xccf5, 0xc161, | |
390 | + 0xccf6, 0x6134, | |
391 | + 0xccf7, 0x6135, | |
392 | + 0xccf8, 0x5443, | |
393 | + 0xccf9, 0x303, | |
394 | + 0xccfa, 0x6524, | |
395 | + 0xccfb, 0x00b, | |
396 | + 0xccfc, 0x1002, | |
397 | + 0xccfd, 0x2104, | |
398 | + 0xccfe, 0x3c24, | |
399 | + 0xccff, 0x2105, | |
400 | + 0xcd00, 0x3805, | |
401 | + 0xcd01, 0x6524, | |
402 | + 0xcd02, 0xdff4, | |
403 | + 0xcd03, 0x4005, | |
404 | + 0xcd04, 0x6524, | |
405 | + 0xcd05, 0x1002, | |
406 | + 0xcd06, 0x5dd3, | |
407 | + 0xcd07, 0x306, | |
408 | + 0xcd08, 0x2ff7, | |
409 | + 0xcd09, 0x38f7, | |
410 | + 0xcd0a, 0x60b7, | |
411 | + 0xcd0b, 0xdffd, | |
412 | + 0xcd0c, 0x00a, | |
413 | + 0xcd0d, 0x1002, | |
414 | + 0xcd0e, 0 | |
415 | + }; | |
416 | + int i, err; | |
417 | + | |
418 | + err = set_phy_regs(phy, regs); | |
419 | + if (err) | |
420 | + return err; | |
421 | + | |
422 | + msleep(50); | |
423 | + | |
424 | + for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2) | |
425 | + err = mdio_write(phy, MDIO_DEV_PMA_PMD, sr_edc[i], | |
426 | + sr_edc[i + 1]); | |
427 | + if (!err) | |
428 | + phy->priv = edc_sr; | |
429 | + return err; | |
430 | +} | |
431 | + | |
432 | +static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype) | |
433 | +{ | |
434 | + static struct reg_val regs[] = { | |
435 | + { MDIO_DEV_PMA_PMD, 0xc04a, 0xffff, 0x5a00 }, | |
436 | + { 0, 0, 0, 0 } | |
437 | + }; | |
438 | + static struct reg_val preemphasis[] = { | |
439 | + { MDIO_DEV_PMA_PMD, 0xc014, 0xffff, 0xfe16 }, | |
440 | + { MDIO_DEV_PMA_PMD, 0xc015, 0xffff, 0xa000 }, | |
441 | + { 0, 0, 0, 0 } | |
442 | + }; | |
443 | + static u16 twinax_edc[] = { | |
444 | + 0xcc00, 0x4009, | |
445 | + 0xcc01, 0x27ff, | |
446 | + 0xcc02, 0x300f, | |
447 | + 0xcc03, 0x40aa, | |
448 | + 0xcc04, 0x401c, | |
449 | + 0xcc05, 0x401e, | |
450 | + 0xcc06, 0x2ff4, | |
451 | + 0xcc07, 0x3cd4, | |
452 | + 0xcc08, 0x2035, | |
453 | + 0xcc09, 0x3145, | |
454 | + 0xcc0a, 0x6524, | |
455 | + 0xcc0b, 0x26a2, | |
456 | + 0xcc0c, 0x3012, | |
457 | + 0xcc0d, 0x1002, | |
458 | + 0xcc0e, 0x29c2, | |
459 | + 0xcc0f, 0x3002, | |
460 | + 0xcc10, 0x1002, | |
461 | + 0xcc11, 0x2072, | |
462 | + 0xcc12, 0x3012, | |
463 | + 0xcc13, 0x1002, | |
464 | + 0xcc14, 0x22cd, | |
465 | + 0xcc15, 0x301d, | |
466 | + 0xcc16, 0x2e52, | |
467 | + 0xcc17, 0x3012, | |
468 | + 0xcc18, 0x1002, | |
469 | + 0xcc19, 0x28e2, | |
470 | + 0xcc1a, 0x3002, | |
471 | + 0xcc1b, 0x1002, | |
472 | + 0xcc1c, 0x628f, | |
473 | + 0xcc1d, 0x2ac2, | |
474 | + 0xcc1e, 0x3012, | |
475 | + 0xcc1f, 0x1002, | |
476 | + 0xcc20, 0x5553, | |
477 | + 0xcc21, 0x2ae2, | |
478 | + 0xcc22, 0x3002, | |
479 | + 0xcc23, 0x1302, | |
480 | + 0xcc24, 0x401e, | |
481 | + 0xcc25, 0x2be2, | |
482 | + 0xcc26, 0x3012, | |
483 | + 0xcc27, 0x1002, | |
484 | + 0xcc28, 0x2da2, | |
485 | + 0xcc29, 0x3012, | |
486 | + 0xcc2a, 0x1002, | |
487 | + 0xcc2b, 0x2ba2, | |
488 | + 0xcc2c, 0x3002, | |
489 | + 0xcc2d, 0x1002, | |
490 | + 0xcc2e, 0x5ee3, | |
491 | + 0xcc2f, 0x305, | |
492 | + 0xcc30, 0x400e, | |
493 | + 0xcc31, 0x2bc2, | |
494 | + 0xcc32, 0x3002, | |
495 | + 0xcc33, 0x1002, | |
496 | + 0xcc34, 0x2b82, | |
497 | + 0xcc35, 0x3012, | |
498 | + 0xcc36, 0x1002, | |
499 | + 0xcc37, 0x5663, | |
500 | + 0xcc38, 0x302, | |
501 | + 0xcc39, 0x401e, | |
502 | + 0xcc3a, 0x6f72, | |
503 | + 0xcc3b, 0x1002, | |
504 | + 0xcc3c, 0x628f, | |
505 | + 0xcc3d, 0x2be2, | |
506 | + 0xcc3e, 0x3012, | |
507 | + 0xcc3f, 0x1002, | |
508 | + 0xcc40, 0x22cd, | |
509 | + 0xcc41, 0x301d, | |
510 | + 0xcc42, 0x2e52, | |
511 | + 0xcc43, 0x3012, | |
512 | + 0xcc44, 0x1002, | |
513 | + 0xcc45, 0x2522, | |
514 | + 0xcc46, 0x3012, | |
515 | + 0xcc47, 0x1002, | |
516 | + 0xcc48, 0x2da2, | |
517 | + 0xcc49, 0x3012, | |
518 | + 0xcc4a, 0x1002, | |
519 | + 0xcc4b, 0x2ca2, | |
520 | + 0xcc4c, 0x3012, | |
521 | + 0xcc4d, 0x1002, | |
522 | + 0xcc4e, 0x2fa4, | |
523 | + 0xcc4f, 0x3cd4, | |
524 | + 0xcc50, 0x6624, | |
525 | + 0xcc51, 0x410b, | |
526 | + 0xcc52, 0x56b3, | |
527 | + 0xcc53, 0x3c4, | |
528 | + 0xcc54, 0x2fb2, | |
529 | + 0xcc55, 0x3002, | |
530 | + 0xcc56, 0x1002, | |
531 | + 0xcc57, 0x220b, | |
532 | + 0xcc58, 0x303b, | |
533 | + 0xcc59, 0x56b3, | |
534 | + 0xcc5a, 0x3c3, | |
535 | + 0xcc5b, 0x866b, | |
536 | + 0xcc5c, 0x400c, | |
537 | + 0xcc5d, 0x23a2, | |
538 | + 0xcc5e, 0x3012, | |
539 | + 0xcc5f, 0x1002, | |
540 | + 0xcc60, 0x2da2, | |
541 | + 0xcc61, 0x3012, | |
542 | + 0xcc62, 0x1002, | |
543 | + 0xcc63, 0x2ca2, | |
544 | + 0xcc64, 0x3012, | |
545 | + 0xcc65, 0x1002, | |
546 | + 0xcc66, 0x2fb4, | |
547 | + 0xcc67, 0x3cd4, | |
548 | + 0xcc68, 0x6624, | |
549 | + 0xcc69, 0x56b3, | |
550 | + 0xcc6a, 0x3c3, | |
551 | + 0xcc6b, 0x866b, | |
552 | + 0xcc6c, 0x401c, | |
553 | + 0xcc6d, 0x2205, | |
554 | + 0xcc6e, 0x3035, | |
555 | + 0xcc6f, 0x5b53, | |
556 | + 0xcc70, 0x2c52, | |
557 | + 0xcc71, 0x3002, | |
558 | + 0xcc72, 0x13c2, | |
559 | + 0xcc73, 0x5cc3, | |
560 | + 0xcc74, 0x317, | |
561 | + 0xcc75, 0x2522, | |
562 | + 0xcc76, 0x3012, | |
563 | + 0xcc77, 0x1002, | |
564 | + 0xcc78, 0x2da2, | |
565 | + 0xcc79, 0x3012, | |
566 | + 0xcc7a, 0x1002, | |
567 | + 0xcc7b, 0x2b82, | |
568 | + 0xcc7c, 0x3012, | |
569 | + 0xcc7d, 0x1002, | |
570 | + 0xcc7e, 0x5663, | |
571 | + 0xcc7f, 0x303, | |
572 | + 0xcc80, 0x401e, | |
573 | + 0xcc81, 0x004, | |
574 | + 0xcc82, 0x2c42, | |
575 | + 0xcc83, 0x3012, | |
576 | + 0xcc84, 0x1002, | |
577 | + 0xcc85, 0x6f72, | |
578 | + 0xcc86, 0x1002, | |
579 | + 0xcc87, 0x628f, | |
580 | + 0xcc88, 0x2304, | |
581 | + 0xcc89, 0x3c84, | |
582 | + 0xcc8a, 0x6436, | |
583 | + 0xcc8b, 0xdff4, | |
584 | + 0xcc8c, 0x6436, | |
585 | + 0xcc8d, 0x2ff5, | |
586 | + 0xcc8e, 0x3005, | |
587 | + 0xcc8f, 0x8656, | |
588 | + 0xcc90, 0xdfba, | |
589 | + 0xcc91, 0x56a3, | |
590 | + 0xcc92, 0xd05a, | |
591 | + 0xcc93, 0x21c2, | |
592 | + 0xcc94, 0x3012, | |
593 | + 0xcc95, 0x1392, | |
594 | + 0xcc96, 0xd05a, | |
595 | + 0xcc97, 0x56a3, | |
596 | + 0xcc98, 0xdfba, | |
597 | + 0xcc99, 0x383, | |
598 | + 0xcc9a, 0x6f72, | |
599 | + 0xcc9b, 0x1002, | |
600 | + 0xcc9c, 0x28c5, | |
601 | + 0xcc9d, 0x3005, | |
602 | + 0xcc9e, 0x4178, | |
603 | + 0xcc9f, 0x5653, | |
604 | + 0xcca0, 0x384, | |
605 | + 0xcca1, 0x22b2, | |
606 | + 0xcca2, 0x3012, | |
607 | + 0xcca3, 0x1002, | |
608 | + 0xcca4, 0x2be5, | |
609 | + 0xcca5, 0x3005, | |
610 | + 0xcca6, 0x41e8, | |
611 | + 0xcca7, 0x5653, | |
612 | + 0xcca8, 0x382, | |
613 | + 0xcca9, 0x002, | |
614 | + 0xccaa, 0x4258, | |
615 | + 0xccab, 0x2474, | |
616 | + 0xccac, 0x3c84, | |
617 | + 0xccad, 0x6437, | |
618 | + 0xccae, 0xdff4, | |
619 | + 0xccaf, 0x6437, | |
620 | + 0xccb0, 0x2ff5, | |
621 | + 0xccb1, 0x3c05, | |
622 | + 0xccb2, 0x8757, | |
623 | + 0xccb3, 0xb888, | |
624 | + 0xccb4, 0x9787, | |
625 | + 0xccb5, 0xdff4, | |
626 | + 0xccb6, 0x6724, | |
627 | + 0xccb7, 0x866a, | |
628 | + 0xccb8, 0x6f72, | |
629 | + 0xccb9, 0x1002, | |
630 | + 0xccba, 0x2d01, | |
631 | + 0xccbb, 0x3011, | |
632 | + 0xccbc, 0x1001, | |
633 | + 0xccbd, 0xc620, | |
634 | + 0xccbe, 0x14e5, | |
635 | + 0xccbf, 0xc621, | |
636 | + 0xccc0, 0xc53d, | |
637 | + 0xccc1, 0xc622, | |
638 | + 0xccc2, 0x3cbe, | |
639 | + 0xccc3, 0xc623, | |
640 | + 0xccc4, 0x4452, | |
641 | + 0xccc5, 0xc624, | |
642 | + 0xccc6, 0xc5c5, | |
643 | + 0xccc7, 0xc625, | |
644 | + 0xccc8, 0xe01e, | |
645 | + 0xccc9, 0xc627, | |
646 | + 0xccca, 0x000, | |
647 | + 0xcccb, 0xc628, | |
648 | + 0xcccc, 0x000, | |
649 | + 0xcccd, 0xc62b, | |
650 | + 0xccce, 0x000, | |
651 | + 0xcccf, 0xc62c, | |
652 | + 0xccd0, 0x000, | |
653 | + 0xccd1, 0x000, | |
654 | + 0xccd2, 0x2d01, | |
655 | + 0xccd3, 0x3011, | |
656 | + 0xccd4, 0x1001, | |
657 | + 0xccd5, 0xc620, | |
658 | + 0xccd6, 0x000, | |
659 | + 0xccd7, 0xc621, | |
660 | + 0xccd8, 0x000, | |
661 | + 0xccd9, 0xc622, | |
662 | + 0xccda, 0x0ce, | |
663 | + 0xccdb, 0xc623, | |
664 | + 0xccdc, 0x07f, | |
665 | + 0xccdd, 0xc624, | |
666 | + 0xccde, 0x032, | |
667 | + 0xccdf, 0xc625, | |
668 | + 0xcce0, 0x000, | |
669 | + 0xcce1, 0xc627, | |
670 | + 0xcce2, 0x000, | |
671 | + 0xcce3, 0xc628, | |
672 | + 0xcce4, 0x000, | |
673 | + 0xcce5, 0xc62b, | |
674 | + 0xcce6, 0x000, | |
675 | + 0xcce7, 0xc62c, | |
676 | + 0xcce8, 0x000, | |
677 | + 0xcce9, 0x000, | |
678 | + 0xccea, 0x2d01, | |
679 | + 0xcceb, 0x3011, | |
680 | + 0xccec, 0x1001, | |
681 | + 0xcced, 0xc502, | |
682 | + 0xccee, 0x609f, | |
683 | + 0xccef, 0xc600, | |
684 | + 0xccf0, 0x2a6e, | |
685 | + 0xccf1, 0xc601, | |
686 | + 0xccf2, 0x2a2c, | |
687 | + 0xccf3, 0xc60c, | |
688 | + 0xccf4, 0x5400, | |
689 | + 0xccf5, 0xc710, | |
690 | + 0xccf6, 0x700, | |
691 | + 0xccf7, 0xc718, | |
692 | + 0xccf8, 0x700, | |
693 | + 0xccf9, 0xc720, | |
694 | + 0xccfa, 0x4700, | |
695 | + 0xccfb, 0xc728, | |
696 | + 0xccfc, 0x700, | |
697 | + 0xccfd, 0xc729, | |
698 | + 0xccfe, 0x1207, | |
699 | + 0xccff, 0xc801, | |
700 | + 0xcd00, 0x7f50, | |
701 | + 0xcd01, 0xc802, | |
702 | + 0xcd02, 0x7760, | |
703 | + 0xcd03, 0xc803, | |
704 | + 0xcd04, 0x7fce, | |
705 | + 0xcd05, 0xc804, | |
706 | + 0xcd06, 0x520e, | |
707 | + 0xcd07, 0xc805, | |
708 | + 0xcd08, 0x5c11, | |
709 | + 0xcd09, 0xc806, | |
710 | + 0xcd0a, 0x3c51, | |
711 | + 0xcd0b, 0xc807, | |
712 | + 0xcd0c, 0x4061, | |
713 | + 0xcd0d, 0xc808, | |
714 | + 0xcd0e, 0x49c1, | |
715 | + 0xcd0f, 0xc809, | |
716 | + 0xcd10, 0x3840, | |
717 | + 0xcd11, 0xc80a, | |
718 | + 0xcd12, 0x000, | |
719 | + 0xcd13, 0xc821, | |
720 | + 0xcd14, 0x002, | |
721 | + 0xcd15, 0xc822, | |
722 | + 0xcd16, 0x046, | |
723 | + 0xcd17, 0xc844, | |
724 | + 0xcd18, 0x182f, | |
725 | + 0xcd19, 0xc013, | |
726 | + 0xcd1a, 0xf341, | |
727 | + 0xcd1b, 0xc01a, | |
728 | + 0xcd1c, 0x446, | |
729 | + 0xcd1d, 0xc024, | |
730 | + 0xcd1e, 0x1000, | |
731 | + 0xcd1f, 0xc025, | |
732 | + 0xcd20, 0xa00, | |
733 | + 0xcd21, 0xc026, | |
734 | + 0xcd22, 0xc0c, | |
735 | + 0xcd23, 0xc027, | |
736 | + 0xcd24, 0xc0c, | |
737 | + 0xcd25, 0xc029, | |
738 | + 0xcd26, 0x0a0, | |
739 | + 0xcd27, 0xc030, | |
740 | + 0xcd28, 0xa00, | |
741 | + 0xcd29, 0xc03c, | |
742 | + 0xcd2a, 0x01c, | |
743 | + 0xcd2b, 0x000, | |
744 | + 0xcd2c, 0x2b84, | |
745 | + 0xcd2d, 0x3c74, | |
746 | + 0xcd2e, 0x6435, | |
747 | + 0xcd2f, 0xdff4, | |
748 | + 0xcd30, 0x6435, | |
749 | + 0xcd31, 0x2806, | |
750 | + 0xcd32, 0x3006, | |
751 | + 0xcd33, 0x8565, | |
752 | + 0xcd34, 0x2b24, | |
753 | + 0xcd35, 0x3c24, | |
754 | + 0xcd36, 0x6436, | |
755 | + 0xcd37, 0x1002, | |
756 | + 0xcd38, 0x2b24, | |
757 | + 0xcd39, 0x3c24, | |
758 | + 0xcd3a, 0x6436, | |
759 | + 0xcd3b, 0x4045, | |
760 | + 0xcd3c, 0x8656, | |
761 | + 0xcd3d, 0x1002, | |
762 | + 0xcd3e, 0x2807, | |
763 | + 0xcd3f, 0x31a7, | |
764 | + 0xcd40, 0x20c4, | |
765 | + 0xcd41, 0x3c24, | |
766 | + 0xcd42, 0x6724, | |
767 | + 0xcd43, 0x1002, | |
768 | + 0xcd44, 0x2807, | |
769 | + 0xcd45, 0x3187, | |
770 | + 0xcd46, 0x20c4, | |
771 | + 0xcd47, 0x3c24, | |
772 | + 0xcd48, 0x6724, | |
773 | + 0xcd49, 0x1002, | |
774 | + 0xcd4a, 0x2514, | |
775 | + 0xcd4b, 0x3c64, | |
776 | + 0xcd4c, 0x6436, | |
777 | + 0xcd4d, 0xdff4, | |
778 | + 0xcd4e, 0x6436, | |
779 | + 0xcd4f, 0x1002, | |
780 | + 0xcd50, 0x2806, | |
781 | + 0xcd51, 0x3cb6, | |
782 | + 0xcd52, 0xc161, | |
783 | + 0xcd53, 0x6134, | |
784 | + 0xcd54, 0x6135, | |
785 | + 0xcd55, 0x5443, | |
786 | + 0xcd56, 0x303, | |
787 | + 0xcd57, 0x6524, | |
788 | + 0xcd58, 0x00b, | |
789 | + 0xcd59, 0x1002, | |
790 | + 0xcd5a, 0xd019, | |
791 | + 0xcd5b, 0x2104, | |
792 | + 0xcd5c, 0x3c24, | |
793 | + 0xcd5d, 0x2105, | |
794 | + 0xcd5e, 0x3805, | |
795 | + 0xcd5f, 0x6524, | |
796 | + 0xcd60, 0xdff4, | |
797 | + 0xcd61, 0x4005, | |
798 | + 0xcd62, 0x6524, | |
799 | + 0xcd63, 0x2e8d, | |
800 | + 0xcd64, 0x303d, | |
801 | + 0xcd65, 0x5dd3, | |
802 | + 0xcd66, 0x306, | |
803 | + 0xcd67, 0x2ff7, | |
804 | + 0xcd68, 0x38f7, | |
805 | + 0xcd69, 0x60b7, | |
806 | + 0xcd6a, 0xdffd, | |
807 | + 0xcd6b, 0x00a, | |
808 | + 0xcd6c, 0x1002, | |
809 | + 0xcd6d, 0 | |
810 | + }; | |
811 | + int i, err; | |
812 | + | |
813 | + err = set_phy_regs(phy, regs); | |
814 | + if (!err && modtype == phy_modtype_twinax_long) | |
815 | + err = set_phy_regs(phy, preemphasis); | |
816 | + if (err) | |
817 | + return err; | |
818 | + | |
819 | + msleep(50); | |
820 | + | |
821 | + for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2) | |
822 | + err = mdio_write(phy, MDIO_DEV_PMA_PMD, twinax_edc[i], | |
823 | + twinax_edc[i + 1]); | |
824 | + if (!err) | |
825 | + phy->priv = edc_twinax; | |
826 | + return err; | |
827 | +} | |
828 | + | |
829 | +static int ael2005_i2c_rd(struct cphy *phy, int dev_addr, int word_addr) | |
830 | +{ | |
831 | + int i, err; | |
832 | + unsigned int stat, data; | |
833 | + | |
834 | + err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL_I2C_CTRL, | |
835 | + (dev_addr << 8) | (1 << 8) | word_addr); | |
836 | + if (err) | |
837 | + return err; | |
838 | + | |
839 | + for (i = 0; i < 5; i++) { | |
840 | + msleep(1); | |
841 | + err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_STAT, &stat); | |
842 | + if (err) | |
843 | + return err; | |
844 | + if ((stat & 3) == 1) { | |
845 | + err = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL_I2C_DATA, | |
846 | + &data); | |
847 | + if (err) | |
848 | + return err; | |
849 | + return data >> 8; | |
850 | + } | |
851 | + } | |
852 | + CH_WARN(phy->adapter, "PHY %u I2C read of addr %u timed out\n", | |
853 | + phy->addr, word_addr); | |
854 | + return -ETIMEDOUT; | |
855 | +} | |
856 | + | |
857 | +static int get_module_type(struct cphy *phy, int delay_ms) | |
858 | +{ | |
859 | + int v; | |
860 | + unsigned int stat; | |
861 | + | |
862 | + v = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, &stat); | |
863 | + if (v) | |
864 | + return v; | |
865 | + | |
866 | + if (stat & (1 << 8)) /* module absent */ | |
867 | + return phy_modtype_none; | |
868 | + | |
869 | + if (delay_ms) | |
870 | + msleep(delay_ms); | |
871 | + | |
872 | + /* see SFF-8472 for below */ | |
873 | + v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 3); | |
874 | + if (v < 0) | |
875 | + return v; | |
876 | + | |
877 | + if (v == 0x10) | |
878 | + return phy_modtype_sr; | |
879 | + if (v == 0x20) | |
880 | + return phy_modtype_lr; | |
881 | + if (v == 0x40) | |
882 | + return phy_modtype_lrm; | |
883 | + | |
884 | + v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 6); | |
885 | + if (v < 0) | |
886 | + return v; | |
887 | + if (v != 4) | |
888 | + goto unknown; | |
889 | + | |
890 | + v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 10); | |
891 | + if (v < 0) | |
892 | + return v; | |
893 | + | |
894 | + if (v & 0x80) { | |
895 | + v = ael2005_i2c_rd(phy, MODULE_DEV_ADDR, 0x12); | |
896 | + if (v < 0) | |
897 | + return v; | |
898 | + return v > 10 ? phy_modtype_twinax_long : phy_modtype_twinax; | |
899 | + } | |
900 | +unknown: | |
901 | + return phy_modtype_unknown; | |
902 | +} | |
903 | + | |
904 | +static int ael2005_intr_enable(struct cphy *phy) | |
905 | +{ | |
906 | + int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x200); | |
907 | + return err ? err : t3_phy_lasi_intr_enable(phy); | |
908 | +} | |
909 | + | |
910 | +static int ael2005_intr_disable(struct cphy *phy) | |
911 | +{ | |
912 | + int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0x100); | |
913 | + return err ? err : t3_phy_lasi_intr_disable(phy); | |
914 | +} | |
915 | + | |
916 | +static int ael2005_intr_clear(struct cphy *phy) | |
917 | +{ | |
918 | + int err = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, 0xd00); | |
919 | + return err ? err : t3_phy_lasi_intr_clear(phy); | |
920 | +} | |
921 | + | |
922 | +static int ael2005_reset(struct cphy *phy, int wait) | |
923 | +{ | |
924 | + static struct reg_val regs0[] = { | |
925 | + { MDIO_DEV_PMA_PMD, 0xc001, 0, 1 << 5 }, | |
926 | + { MDIO_DEV_PMA_PMD, 0xc017, 0, 1 << 5 }, | |
927 | + { MDIO_DEV_PMA_PMD, 0xc013, 0xffff, 0xf341 }, | |
928 | + { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, | |
929 | + { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8100 }, | |
930 | + { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0x8000 }, | |
931 | + { MDIO_DEV_PMA_PMD, 0xc210, 0xffff, 0 }, | |
932 | + { 0, 0, 0, 0 } | |
933 | + }; | |
934 | + static struct reg_val regs1[] = { | |
935 | + { MDIO_DEV_PMA_PMD, 0xca00, 0xffff, 0x0080 }, | |
936 | + { MDIO_DEV_PMA_PMD, 0xca12, 0xffff, 0 }, | |
937 | + { 0, 0, 0, 0 } | |
938 | + }; | |
939 | + | |
940 | + int err, lasi_ctrl; | |
941 | + | |
942 | + err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, &lasi_ctrl); | |
943 | + if (err) | |
944 | + return err; | |
945 | + | |
946 | + err = t3_phy_reset(phy, MDIO_DEV_PMA_PMD, 0); | |
947 | + if (err) | |
948 | + return err; | |
949 | + | |
950 | + msleep(125); | |
951 | + phy->priv = edc_none; | |
952 | + err = set_phy_regs(phy, regs0); | |
953 | + if (err) | |
954 | + return err; | |
955 | + | |
956 | + msleep(50); | |
957 | + | |
958 | + err = get_module_type(phy, 0); | |
959 | + if (err < 0) | |
960 | + return err; | |
961 | + phy->modtype = err; | |
962 | + | |
963 | + if (err == phy_modtype_twinax || err == phy_modtype_twinax_long) | |
964 | + err = ael2005_setup_twinax_edc(phy, err); | |
965 | + else | |
966 | + err = ael2005_setup_sr_edc(phy); | |
967 | + if (err) | |
968 | + return err; | |
969 | + | |
970 | + err = set_phy_regs(phy, regs1); | |
971 | + if (err) | |
972 | + return err; | |
973 | + | |
974 | + /* reset wipes out interrupts, reenable them if they were on */ | |
975 | + if (lasi_ctrl & 1) | |
976 | + err = ael2005_intr_enable(phy); | |
977 | + return err; | |
978 | +} | |
979 | + | |
980 | +static int ael2005_intr_handler(struct cphy *phy) | |
981 | +{ | |
982 | + unsigned int stat; | |
983 | + int ret, edc_needed, cause = 0; | |
984 | + | |
985 | + ret = mdio_read(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_STAT, &stat); | |
986 | + if (ret) | |
987 | + return ret; | |
988 | + | |
989 | + if (stat & AEL2005_MODDET_IRQ) { | |
990 | + ret = mdio_write(phy, MDIO_DEV_PMA_PMD, AEL2005_GPIO_CTRL, | |
991 | + 0xd00); | |
992 | + if (ret) | |
993 | + return ret; | |
994 | + | |
995 | + /* modules have max 300 ms init time after hot plug */ | |
996 | + ret = get_module_type(phy, 300); | |
997 | + if (ret < 0) | |
998 | + return ret; | |
999 | + | |
1000 | + phy->modtype = ret; | |
1001 | + if (ret == phy_modtype_none) | |
1002 | + edc_needed = phy->priv; /* on unplug retain EDC */ | |
1003 | + else if (ret == phy_modtype_twinax || | |
1004 | + ret == phy_modtype_twinax_long) | |
1005 | + edc_needed = edc_twinax; | |
1006 | + else | |
1007 | + edc_needed = edc_sr; | |
1008 | + | |
1009 | + if (edc_needed != phy->priv) { | |
1010 | + ret = ael2005_reset(phy, 0); | |
1011 | + return ret ? ret : cphy_cause_module_change; | |
1012 | + } | |
1013 | + cause = cphy_cause_module_change; | |
1014 | + } | |
1015 | + | |
1016 | + ret = t3_phy_lasi_intr_handler(phy); | |
1017 | + if (ret < 0) | |
1018 | + return ret; | |
1019 | + | |
1020 | + ret |= cause; | |
1021 | + return ret ? ret : cphy_cause_link_change; | |
1022 | +} | |
1023 | + | |
1024 | +static struct cphy_ops ael2005_ops = { | |
1025 | + .reset = ael2005_reset, | |
1026 | + .intr_enable = ael2005_intr_enable, | |
1027 | + .intr_disable = ael2005_intr_disable, | |
1028 | + .intr_clear = ael2005_intr_clear, | |
1029 | + .intr_handler = ael2005_intr_handler, | |
1030 | + .get_link_status = get_link_status_r, | |
1031 | + .power_down = ael1002_power_down, | |
1032 | +}; | |
1033 | + | |
1034 | +int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter, | |
1035 | + int phy_addr, const struct mdio_ops *mdio_ops) | |
1036 | +{ | |
1037 | + cphy_init(phy, adapter, phy_addr, &ael2005_ops, mdio_ops, | |
1038 | + SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE | | |
1039 | + SUPPORTED_IRQ, "10GBASE-R"); | |
1040 | + msleep(125); | |
1041 | + return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, AEL_OPT_SETTINGS, 0, | |
1042 | + 1 << 5); | |
1043 | +} | |
1044 | + | |
1045 | +/* | |
1046 | + * Get link status for a 10GBASE-X device. | |
1047 | + */ | |
1048 | +static int get_link_status_x(struct cphy *phy, int *link_ok, int *speed, | |
1049 | + int *duplex, int *fc) | |
1050 | +{ | |
1051 | + if (link_ok) { | |
1052 | + unsigned int stat0, stat1, stat2; | |
1053 | + int err = mdio_read(phy, MDIO_DEV_PMA_PMD, PMD_RSD, &stat0); | |
1054 | + | |
1055 | + if (!err) | |
1056 | + err = mdio_read(phy, MDIO_DEV_PCS, PCS_STAT1_X, &stat1); | |
1057 | + if (!err) | |
1058 | + err = mdio_read(phy, MDIO_DEV_XGXS, XS_LN_STAT, &stat2); | |
1059 | + if (err) | |
1060 | + return err; | |
1061 | + *link_ok = (stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1; | |
1062 | + } | |
1063 | + if (speed) | |
1064 | + *speed = SPEED_10000; | |
1065 | + if (duplex) | |
1066 | + *duplex = DUPLEX_FULL; | |
1067 | + return 0; | |
1068 | +} | |
1069 | + | |
1070 | static struct cphy_ops qt2045_ops = { | |
1071 | .reset = ael1006_reset, | |
1072 | .intr_enable = t3_phy_lasi_intr_enable, | |
1073 | .intr_disable = t3_phy_lasi_intr_disable, | |
1074 | .intr_clear = t3_phy_lasi_intr_clear, | |
1075 | .intr_handler = t3_phy_lasi_intr_handler, | |
1076 | - .get_link_status = ael100x_get_link_status, | |
1077 | + .get_link_status = get_link_status_x, | |
1078 | .power_down = ael1006_power_down, | |
1079 | }; | |
1080 | ||
1081 | Index: linux-2.6.27/drivers/net/cxgb3/common.h | |
1082 | =================================================================== | |
1083 | --- linux-2.6.27.orig/drivers/net/cxgb3/common.h | |
1084 | +++ linux-2.6.27/drivers/net/cxgb3/common.h | |
1085 | @@ -547,7 +547,19 @@ enum { | |
1086 | /* PHY interrupt types */ | |
1087 | enum { | |
1088 | cphy_cause_link_change = 1, | |
1089 | - cphy_cause_fifo_error = 2 | |
1090 | + cphy_cause_fifo_error = 2, | |
1091 | + cphy_cause_module_change = 4, | |
1092 | +}; | |
1093 | + | |
1094 | +/* PHY module types */ | |
1095 | +enum { | |
1096 | + phy_modtype_none, | |
1097 | + phy_modtype_sr, | |
1098 | + phy_modtype_lr, | |
1099 | + phy_modtype_lrm, | |
1100 | + phy_modtype_twinax, | |
1101 | + phy_modtype_twinax_long, | |
1102 | + phy_modtype_unknown | |
1103 | }; | |
1104 | ||
1105 | /* PHY operations */ | |
1106 | @@ -572,7 +584,9 @@ struct cphy_ops { | |
1107 | ||
1108 | /* A PHY instance */ | |
1109 | struct cphy { | |
1110 | - int addr; /* PHY address */ | |
1111 | + u8 addr; /* PHY address */ | |
1112 | + u8 modtype; /* PHY module type */ | |
1113 | + short priv; /* scratch pad */ | |
1114 | unsigned int caps; /* PHY capabilities */ | |
1115 | struct adapter *adapter; /* associated adapter */ | |
1116 | const char *desc; /* PHY description */ | |
1117 | @@ -793,6 +807,8 @@ int t3_ael1002_phy_prep(struct cphy *phy | |
1118 | int phy_addr, const struct mdio_ops *mdio_ops); | |
1119 | int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter, | |
1120 | int phy_addr, const struct mdio_ops *mdio_ops); | |
1121 | +int t3_ael2005_phy_prep(struct cphy *phy, struct adapter *adapter, | |
1122 | + int phy_addr, const struct mdio_ops *mdio_ops); | |
1123 | int t3_qt2045_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, | |
1124 | const struct mdio_ops *mdio_ops); | |
1125 | int t3_xaui_direct_phy_prep(struct cphy *phy, struct adapter *adapter, | |
1126 | Index: linux-2.6.27/drivers/net/cxgb3/cxgb3_main.c | |
1127 | =================================================================== | |
1128 | --- linux-2.6.27.orig/drivers/net/cxgb3/cxgb3_main.c | |
1129 | +++ linux-2.6.27/drivers/net/cxgb3/cxgb3_main.c | |
1130 | @@ -209,6 +209,31 @@ void t3_os_link_changed(struct adapter * | |
1131 | } | |
1132 | } | |
1133 | ||
1134 | +/** | |
1135 | + * t3_os_phymod_changed - handle PHY module changes | |
1136 | + * @phy: the PHY reporting the module change | |
1137 | + * @mod_type: new module type | |
1138 | + * | |
1139 | + * This is the OS-dependent handler for PHY module changes. It is | |
1140 | + * invoked when a PHY module is removed or inserted for any OS-specific | |
1141 | + * processing. | |
1142 | + */ | |
1143 | +void t3_os_phymod_changed(struct adapter *adap, int port_id) | |
1144 | +{ | |
1145 | + static const char *mod_str[] = { | |
1146 | + NULL, "SR", "LR", "LRM", "TWINAX", "TWINAX", "unknown" | |
1147 | + }; | |
1148 | + | |
1149 | + const struct net_device *dev = adap->port[port_id]; | |
1150 | + const struct port_info *pi = netdev_priv(dev); | |
1151 | + | |
1152 | + if (pi->phy.modtype == phy_modtype_none) | |
1153 | + printk(KERN_INFO "%s: PHY module unplugged\n", dev->name); | |
1154 | + else | |
1155 | + printk(KERN_INFO "%s: %s PHY module inserted\n", dev->name, | |
1156 | + mod_str[pi->phy.modtype]); | |
1157 | +} | |
1158 | + | |
1159 | static void cxgb_set_rxmode(struct net_device *dev) | |
1160 | { | |
1161 | struct t3_rx_mode rm; | |
1162 | Index: linux-2.6.27/drivers/net/cxgb3/t3_hw.c | |
1163 | =================================================================== | |
1164 | --- linux-2.6.27.orig/drivers/net/cxgb3/t3_hw.c | |
1165 | +++ linux-2.6.27/drivers/net/cxgb3/t3_hw.c | |
1166 | @@ -511,7 +511,7 @@ static const struct port_type_info port_ | |
1167 | { t3_vsc8211_phy_prep }, | |
1168 | { NULL}, | |
1169 | { t3_xaui_direct_phy_prep }, | |
1170 | - { NULL }, | |
1171 | + { t3_ael2005_phy_prep }, | |
1172 | { t3_qt2045_phy_prep }, | |
1173 | { t3_ael1006_phy_prep }, | |
1174 | { NULL }, | |
1175 | @@ -1728,6 +1728,8 @@ int t3_phy_intr_handler(struct adapter * | |
1176 | t3_link_changed(adapter, i); | |
1177 | if (phy_cause & cphy_cause_fifo_error) | |
1178 | p->phy.fifo_errors++; | |
1179 | + if (phy_cause & cphy_cause_module_change) | |
1180 | + t3_os_phymod_changed(adapter, i); | |
1181 | } | |
1182 | } | |
1183 |