1
2
3
4
5
6
7
8
9
10
11
12
13
14#include "e1000_api.h"
15
16STATIC s32 e1000_init_phy_params_82541(struct e1000_hw *hw);
17STATIC s32 e1000_init_nvm_params_82541(struct e1000_hw *hw);
18STATIC s32 e1000_init_mac_params_82541(struct e1000_hw *hw);
19STATIC s32 e1000_reset_hw_82541(struct e1000_hw *hw);
20STATIC s32 e1000_init_hw_82541(struct e1000_hw *hw);
21STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
22 u16 *duplex);
23STATIC s32 e1000_phy_hw_reset_82541(struct e1000_hw *hw);
24STATIC s32 e1000_setup_copper_link_82541(struct e1000_hw *hw);
25STATIC s32 e1000_check_for_link_82541(struct e1000_hw *hw);
26STATIC s32 e1000_get_cable_length_igp_82541(struct e1000_hw *hw);
27STATIC s32 e1000_set_d3_lplu_state_82541(struct e1000_hw *hw,
28 bool active);
29STATIC s32 e1000_setup_led_82541(struct e1000_hw *hw);
30STATIC s32 e1000_cleanup_led_82541(struct e1000_hw *hw);
31STATIC void e1000_clear_hw_cntrs_82541(struct e1000_hw *hw);
32STATIC s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
33 bool link_up);
34STATIC s32 e1000_phy_init_script_82541(struct e1000_hw *hw);
35STATIC void e1000_power_down_phy_copper_82541(struct e1000_hw *hw);
36
37STATIC const u16 e1000_igp_cable_length_table[] = {
38 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10,
39 10, 10, 20, 20, 20, 20, 20, 25, 25, 25, 25, 25, 25, 25, 30, 30, 30, 30,
40 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 60, 60,
41 60, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80,
42 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100, 100, 100, 100, 100, 100,
43 100, 100, 100, 100, 100, 100, 100, 100, 110, 110, 110, 110, 110, 110,
44 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 120, 120,
45 120, 120, 120, 120, 120, 120, 120, 120};
46#define IGP01E1000_AGC_LENGTH_TABLE_SIZE \
47 (sizeof(e1000_igp_cable_length_table) / \
48 sizeof(e1000_igp_cable_length_table[0]))
49
50
51
52
53
54STATIC s32 e1000_init_phy_params_82541(struct e1000_hw *hw)
55{
56 struct e1000_phy_info *phy = &hw->phy;
57 s32 ret_val;
58
59 DEBUGFUNC("e1000_init_phy_params_82541");
60
61 phy->addr = 1;
62 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
63 phy->reset_delay_us = 10000;
64 phy->type = e1000_phy_igp;
65
66
67 phy->ops.check_polarity = e1000_check_polarity_igp;
68 phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_igp;
69 phy->ops.get_cable_length = e1000_get_cable_length_igp_82541;
70 phy->ops.get_cfg_done = e1000_get_cfg_done_generic;
71 phy->ops.get_info = e1000_get_phy_info_igp;
72 phy->ops.read_reg = e1000_read_phy_reg_igp;
73 phy->ops.reset = e1000_phy_hw_reset_82541;
74 phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_82541;
75 phy->ops.write_reg = e1000_write_phy_reg_igp;
76 phy->ops.power_up = e1000_power_up_phy_copper;
77 phy->ops.power_down = e1000_power_down_phy_copper_82541;
78
79 ret_val = e1000_get_phy_id(hw);
80 if (ret_val)
81 goto out;
82
83
84 if (phy->id != IGP01E1000_I_PHY_ID) {
85 ret_val = -E1000_ERR_PHY;
86 goto out;
87 }
88
89out:
90 return ret_val;
91}
92
93
94
95
96
97STATIC s32 e1000_init_nvm_params_82541(struct e1000_hw *hw)
98{
99 struct e1000_nvm_info *nvm = &hw->nvm;
100 s32 ret_val = E1000_SUCCESS;
101 u32 eecd = E1000_READ_REG(hw, E1000_EECD);
102 u16 size;
103
104 DEBUGFUNC("e1000_init_nvm_params_82541");
105
106 switch (nvm->override) {
107 case e1000_nvm_override_spi_large:
108 nvm->type = e1000_nvm_eeprom_spi;
109 eecd |= E1000_EECD_ADDR_BITS;
110 break;
111 case e1000_nvm_override_spi_small:
112 nvm->type = e1000_nvm_eeprom_spi;
113 eecd &= ~E1000_EECD_ADDR_BITS;
114 break;
115 case e1000_nvm_override_microwire_large:
116 nvm->type = e1000_nvm_eeprom_microwire;
117 eecd |= E1000_EECD_SIZE;
118 break;
119 case e1000_nvm_override_microwire_small:
120 nvm->type = e1000_nvm_eeprom_microwire;
121 eecd &= ~E1000_EECD_SIZE;
122 break;
123 default:
124 nvm->type = eecd & E1000_EECD_TYPE ? e1000_nvm_eeprom_spi
125 : e1000_nvm_eeprom_microwire;
126 break;
127 }
128
129 if (nvm->type == e1000_nvm_eeprom_spi) {
130 nvm->address_bits = (eecd & E1000_EECD_ADDR_BITS) ? 16 : 8;
131 nvm->delay_usec = 1;
132 nvm->opcode_bits = 8;
133 nvm->page_size = (eecd & E1000_EECD_ADDR_BITS) ? 32 : 8;
134
135
136 nvm->ops.acquire = e1000_acquire_nvm_generic;
137 nvm->ops.read = e1000_read_nvm_spi;
138 nvm->ops.release = e1000_release_nvm_generic;
139 nvm->ops.update = e1000_update_nvm_checksum_generic;
140 nvm->ops.valid_led_default = e1000_valid_led_default_generic;
141 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
142 nvm->ops.write = e1000_write_nvm_spi;
143
144
145
146
147
148
149
150 nvm->word_size = 64;
151 ret_val = nvm->ops.read(hw, NVM_CFG, 1, &size);
152 if (ret_val)
153 goto out;
154 size = (size & NVM_SIZE_MASK) >> NVM_SIZE_SHIFT;
155
156
157
158
159
160 if (size) {
161 size += NVM_WORD_SIZE_BASE_SHIFT_82541;
162 nvm->word_size = 1 << size;
163 }
164 } else {
165 nvm->address_bits = (eecd & E1000_EECD_ADDR_BITS) ? 8 : 6;
166 nvm->delay_usec = 50;
167 nvm->opcode_bits = 3;
168 nvm->word_size = (eecd & E1000_EECD_ADDR_BITS) ? 256 : 64;
169
170
171 nvm->ops.acquire = e1000_acquire_nvm_generic;
172 nvm->ops.read = e1000_read_nvm_microwire;
173 nvm->ops.release = e1000_release_nvm_generic;
174 nvm->ops.update = e1000_update_nvm_checksum_generic;
175 nvm->ops.valid_led_default = e1000_valid_led_default_generic;
176 nvm->ops.validate = e1000_validate_nvm_checksum_generic;
177 nvm->ops.write = e1000_write_nvm_microwire;
178 }
179
180out:
181 return ret_val;
182}
183
184
185
186
187
188STATIC s32 e1000_init_mac_params_82541(struct e1000_hw *hw)
189{
190 struct e1000_mac_info *mac = &hw->mac;
191
192 DEBUGFUNC("e1000_init_mac_params_82541");
193
194
195 hw->phy.media_type = e1000_media_type_copper;
196
197 mac->mta_reg_count = 128;
198
199 mac->rar_entry_count = E1000_RAR_ENTRIES;
200
201 mac->asf_firmware_present = true;
202
203
204
205
206 mac->ops.get_bus_info = e1000_get_bus_info_pci_generic;
207
208 mac->ops.set_lan_id = e1000_set_lan_id_single_port;
209
210 mac->ops.reset_hw = e1000_reset_hw_82541;
211
212 mac->ops.init_hw = e1000_init_hw_82541;
213
214 mac->ops.setup_link = e1000_setup_link_generic;
215
216 mac->ops.setup_physical_interface = e1000_setup_copper_link_82541;
217
218 mac->ops.check_for_link = e1000_check_for_link_82541;
219
220 mac->ops.get_link_up_info = e1000_get_link_up_info_82541;
221
222 mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic;
223
224 mac->ops.write_vfta = e1000_write_vfta_generic;
225
226 mac->ops.clear_vfta = e1000_clear_vfta_generic;
227
228 mac->ops.id_led_init = e1000_id_led_init_generic;
229
230 mac->ops.setup_led = e1000_setup_led_82541;
231
232 mac->ops.cleanup_led = e1000_cleanup_led_82541;
233
234 mac->ops.led_on = e1000_led_on_generic;
235 mac->ops.led_off = e1000_led_off_generic;
236
237 mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_82541;
238
239 return E1000_SUCCESS;
240}
241
242
243
244
245
246
247
248void e1000_init_function_pointers_82541(struct e1000_hw *hw)
249{
250 DEBUGFUNC("e1000_init_function_pointers_82541");
251
252 hw->mac.ops.init_params = e1000_init_mac_params_82541;
253 hw->nvm.ops.init_params = e1000_init_nvm_params_82541;
254 hw->phy.ops.init_params = e1000_init_phy_params_82541;
255}
256
257
258
259
260
261
262
263STATIC s32 e1000_reset_hw_82541(struct e1000_hw *hw)
264{
265 u32 ledctl, ctrl, manc;
266
267 DEBUGFUNC("e1000_reset_hw_82541");
268
269 DEBUGOUT("Masking off all interrupts\n");
270 E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
271
272 E1000_WRITE_REG(hw, E1000_RCTL, 0);
273 E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP);
274 E1000_WRITE_FLUSH(hw);
275
276
277
278
279
280 msec_delay(10);
281
282 ctrl = E1000_READ_REG(hw, E1000_CTRL);
283
284
285 if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
286 E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_PHY_RST));
287 E1000_WRITE_FLUSH(hw);
288 msec_delay(5);
289 }
290
291 DEBUGOUT("Issuing a global reset to 82541/82547 MAC\n");
292 switch (hw->mac.type) {
293 case e1000_82541:
294 case e1000_82541_rev_2:
295
296
297
298
299
300 E1000_WRITE_REG_IO(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
301 break;
302 default:
303 E1000_WRITE_REG(hw, E1000_CTRL, ctrl | E1000_CTRL_RST);
304 break;
305 }
306
307
308 msec_delay(20);
309
310
311 manc = E1000_READ_REG(hw, E1000_MANC);
312 manc &= ~E1000_MANC_ARP_EN;
313 E1000_WRITE_REG(hw, E1000_MANC, manc);
314
315 if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
316 e1000_phy_init_script_82541(hw);
317
318
319 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
320 ledctl &= IGP_ACTIVITY_LED_MASK;
321 ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
322 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
323 }
324
325
326 DEBUGOUT("Masking off all interrupts\n");
327 E1000_WRITE_REG(hw, E1000_IMC, 0xFFFFFFFF);
328
329
330 E1000_READ_REG(hw, E1000_ICR);
331
332 return E1000_SUCCESS;
333}
334
335
336
337
338
339
340
341STATIC s32 e1000_init_hw_82541(struct e1000_hw *hw)
342{
343 struct e1000_mac_info *mac = &hw->mac;
344 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
345 u32 i, txdctl;
346 s32 ret_val;
347
348 DEBUGFUNC("e1000_init_hw_82541");
349
350
351 ret_val = mac->ops.id_led_init(hw);
352 if (ret_val) {
353 DEBUGOUT("Error initializing identification LED\n");
354
355 }
356
357
358 ret_val = hw->phy.ops.read_reg(hw, IGP01E1000_GMII_FIFO,
359 &dev_spec->spd_default);
360 if (ret_val)
361 goto out;
362
363
364 DEBUGOUT("Initializing the IEEE VLAN\n");
365 mac->ops.clear_vfta(hw);
366
367
368 e1000_init_rx_addrs_generic(hw, mac->rar_entry_count);
369
370
371 DEBUGOUT("Zeroing the MTA\n");
372 for (i = 0; i < mac->mta_reg_count; i++) {
373 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
374
375
376
377
378
379
380 E1000_WRITE_FLUSH(hw);
381 }
382
383
384 ret_val = mac->ops.setup_link(hw);
385
386 txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0));
387 txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) |
388 E1000_TXDCTL_FULL_TX_DESC_WB;
389 E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl);
390
391
392
393
394
395
396
397 e1000_clear_hw_cntrs_82541(hw);
398
399out:
400 return ret_val;
401}
402
403
404
405
406
407
408
409
410
411STATIC s32 e1000_get_link_up_info_82541(struct e1000_hw *hw, u16 *speed,
412 u16 *duplex)
413{
414 struct e1000_phy_info *phy = &hw->phy;
415 s32 ret_val;
416 u16 data;
417
418 DEBUGFUNC("e1000_get_link_up_info_82541");
419
420 ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex);
421 if (ret_val)
422 goto out;
423
424 if (!phy->speed_downgraded)
425 goto out;
426
427
428
429
430
431
432
433 ret_val = phy->ops.read_reg(hw, PHY_AUTONEG_EXP, &data);
434 if (ret_val)
435 goto out;
436
437 if (!(data & NWAY_ER_LP_NWAY_CAPS)) {
438 *duplex = HALF_DUPLEX;
439 } else {
440 ret_val = phy->ops.read_reg(hw, PHY_LP_ABILITY, &data);
441 if (ret_val)
442 goto out;
443
444 if (*speed == SPEED_100) {
445 if (!(data & NWAY_LPAR_100TX_FD_CAPS))
446 *duplex = HALF_DUPLEX;
447 } else if (*speed == SPEED_10) {
448 if (!(data & NWAY_LPAR_10T_FD_CAPS))
449 *duplex = HALF_DUPLEX;
450 }
451 }
452
453out:
454 return ret_val;
455}
456
457
458
459
460
461
462
463
464
465
466STATIC s32 e1000_phy_hw_reset_82541(struct e1000_hw *hw)
467{
468 s32 ret_val;
469 u32 ledctl;
470
471 DEBUGFUNC("e1000_phy_hw_reset_82541");
472
473 ret_val = e1000_phy_hw_reset_generic(hw);
474 if (ret_val)
475 goto out;
476
477 e1000_phy_init_script_82541(hw);
478
479 if ((hw->mac.type == e1000_82541) || (hw->mac.type == e1000_82547)) {
480
481 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
482 ledctl &= IGP_ACTIVITY_LED_MASK;
483 ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
484 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
485 }
486
487out:
488 return ret_val;
489}
490
491
492
493
494
495
496
497
498
499
500STATIC s32 e1000_setup_copper_link_82541(struct e1000_hw *hw)
501{
502 struct e1000_phy_info *phy = &hw->phy;
503 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
504 s32 ret_val;
505 u32 ctrl, ledctl;
506
507 DEBUGFUNC("e1000_setup_copper_link_82541");
508
509 ctrl = E1000_READ_REG(hw, E1000_CTRL);
510 ctrl |= E1000_CTRL_SLU;
511 ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);
512 E1000_WRITE_REG(hw, E1000_CTRL, ctrl);
513
514
515
516 if (hw->mac.type == e1000_82541 || hw->mac.type == e1000_82547) {
517 dev_spec->dsp_config = e1000_dsp_config_disabled;
518 phy->mdix = 1;
519 } else {
520 dev_spec->dsp_config = e1000_dsp_config_enabled;
521 }
522
523 ret_val = e1000_copper_link_setup_igp(hw);
524 if (ret_val)
525 goto out;
526
527 if (hw->mac.autoneg) {
528 if (dev_spec->ffe_config == e1000_ffe_config_active)
529 dev_spec->ffe_config = e1000_ffe_config_enabled;
530 }
531
532
533 ledctl = E1000_READ_REG(hw, E1000_LEDCTL);
534 ledctl &= IGP_ACTIVITY_LED_MASK;
535 ledctl |= (IGP_ACTIVITY_LED_ENABLE | IGP_LED3_MODE);
536 E1000_WRITE_REG(hw, E1000_LEDCTL, ledctl);
537
538 ret_val = e1000_setup_copper_link_generic(hw);
539
540out:
541 return ret_val;
542}
543
544
545
546
547
548
549
550
551STATIC s32 e1000_check_for_link_82541(struct e1000_hw *hw)
552{
553 struct e1000_mac_info *mac = &hw->mac;
554 s32 ret_val;
555 bool link;
556
557 DEBUGFUNC("e1000_check_for_link_82541");
558
559
560
561
562
563
564
565 if (!mac->get_link_status) {
566 ret_val = E1000_SUCCESS;
567 goto out;
568 }
569
570
571
572
573
574
575 ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
576 if (ret_val)
577 goto out;
578
579 if (!link) {
580 ret_val = e1000_config_dsp_after_link_change_82541(hw, false);
581 goto out;
582 }
583
584 mac->get_link_status = false;
585
586
587
588
589
590 e1000_check_downshift_generic(hw);
591
592
593
594
595
596 if (!mac->autoneg) {
597 ret_val = -E1000_ERR_CONFIG;
598 goto out;
599 }
600
601 ret_val = e1000_config_dsp_after_link_change_82541(hw, true);
602
603
604
605
606
607
608 mac->ops.config_collision_dist(hw);
609
610
611
612
613
614
615
616 ret_val = e1000_config_fc_after_link_up_generic(hw);
617 if (ret_val)
618 DEBUGOUT("Error configuring flow control\n");
619
620out:
621 return ret_val;
622}
623
624
625
626
627
628
629
630
631
632
633
634
635STATIC s32 e1000_config_dsp_after_link_change_82541(struct e1000_hw *hw,
636 bool link_up)
637{
638 struct e1000_phy_info *phy = &hw->phy;
639 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
640 s32 ret_val;
641 u32 idle_errs = 0;
642 u16 phy_data, phy_saved_data, speed, duplex, i;
643 u16 ffe_idle_err_timeout = FFE_IDLE_ERR_COUNT_TIMEOUT_20;
644 u16 dsp_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {
645 IGP01E1000_PHY_AGC_PARAM_A,
646 IGP01E1000_PHY_AGC_PARAM_B,
647 IGP01E1000_PHY_AGC_PARAM_C,
648 IGP01E1000_PHY_AGC_PARAM_D};
649
650 DEBUGFUNC("e1000_config_dsp_after_link_change_82541");
651
652 if (link_up) {
653 ret_val = hw->mac.ops.get_link_up_info(hw, &speed, &duplex);
654 if (ret_val) {
655 DEBUGOUT("Error getting link speed and duplex\n");
656 goto out;
657 }
658
659 if (speed != SPEED_1000) {
660 ret_val = E1000_SUCCESS;
661 goto out;
662 }
663
664 ret_val = phy->ops.get_cable_length(hw);
665 if (ret_val)
666 goto out;
667
668 if ((dev_spec->dsp_config == e1000_dsp_config_enabled) &&
669 phy->min_cable_length >= 50) {
670
671 for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
672 ret_val = phy->ops.read_reg(hw,
673 dsp_reg_array[i],
674 &phy_data);
675 if (ret_val)
676 goto out;
677
678 phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
679
680 ret_val = phy->ops.write_reg(hw,
681 dsp_reg_array[i],
682 phy_data);
683 if (ret_val)
684 goto out;
685 }
686 dev_spec->dsp_config = e1000_dsp_config_activated;
687 }
688
689 if ((dev_spec->ffe_config != e1000_ffe_config_enabled) ||
690 (phy->min_cable_length >= 50)) {
691 ret_val = E1000_SUCCESS;
692 goto out;
693 }
694
695
696 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data);
697 if (ret_val)
698 goto out;
699
700 for (i = 0; i < ffe_idle_err_timeout; i++) {
701 usec_delay(1000);
702 ret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS,
703 &phy_data);
704 if (ret_val)
705 goto out;
706
707 idle_errs += (phy_data & SR_1000T_IDLE_ERROR_CNT);
708 if (idle_errs > SR_1000T_PHY_EXCESSIVE_IDLE_ERR_COUNT) {
709 dev_spec->ffe_config = e1000_ffe_config_active;
710
711 ret_val = phy->ops.write_reg(hw,
712 IGP01E1000_PHY_DSP_FFE,
713 IGP01E1000_PHY_DSP_FFE_CM_CP);
714 if (ret_val)
715 goto out;
716 break;
717 }
718
719 if (idle_errs)
720 ffe_idle_err_timeout =
721 FFE_IDLE_ERR_COUNT_TIMEOUT_100;
722 }
723 } else {
724 if (dev_spec->dsp_config == e1000_dsp_config_activated) {
725
726
727
728
729 ret_val = phy->ops.read_reg(hw, 0x2F5B,
730 &phy_saved_data);
731 if (ret_val)
732 goto out;
733
734
735 ret_val = phy->ops.write_reg(hw, 0x2F5B, 0x0003);
736 if (ret_val)
737 goto out;
738
739 msec_delay_irq(20);
740
741 ret_val = phy->ops.write_reg(hw, 0x0000,
742 IGP01E1000_IEEE_FORCE_GIG);
743 if (ret_val)
744 goto out;
745 for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
746 ret_val = phy->ops.read_reg(hw,
747 dsp_reg_array[i],
748 &phy_data);
749 if (ret_val)
750 goto out;
751
752 phy_data &= ~IGP01E1000_PHY_EDAC_MU_INDEX;
753 phy_data |= IGP01E1000_PHY_EDAC_SIGN_EXT_9_BITS;
754
755 ret_val = phy->ops.write_reg(hw,
756 dsp_reg_array[i],
757 phy_data);
758 if (ret_val)
759 goto out;
760 }
761
762 ret_val = phy->ops.write_reg(hw, 0x0000,
763 IGP01E1000_IEEE_RESTART_AUTONEG);
764 if (ret_val)
765 goto out;
766
767 msec_delay_irq(20);
768
769
770 ret_val = phy->ops.write_reg(hw, 0x2F5B,
771 phy_saved_data);
772 if (ret_val)
773 goto out;
774
775 dev_spec->dsp_config = e1000_dsp_config_enabled;
776 }
777
778 if (dev_spec->ffe_config != e1000_ffe_config_active) {
779 ret_val = E1000_SUCCESS;
780 goto out;
781 }
782
783
784
785
786
787 ret_val = phy->ops.read_reg(hw, 0x2F5B, &phy_saved_data);
788 if (ret_val)
789 goto out;
790
791
792 ret_val = phy->ops.write_reg(hw, 0x2F5B, 0x0003);
793 if (ret_val)
794 goto out;
795
796 msec_delay_irq(20);
797
798 ret_val = phy->ops.write_reg(hw, 0x0000,
799 IGP01E1000_IEEE_FORCE_GIG);
800 if (ret_val)
801 goto out;
802
803 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_DSP_FFE,
804 IGP01E1000_PHY_DSP_FFE_DEFAULT);
805 if (ret_val)
806 goto out;
807
808 ret_val = phy->ops.write_reg(hw, 0x0000,
809 IGP01E1000_IEEE_RESTART_AUTONEG);
810 if (ret_val)
811 goto out;
812
813 msec_delay_irq(20);
814
815
816 ret_val = phy->ops.write_reg(hw, 0x2F5B, phy_saved_data);
817
818 if (ret_val)
819 goto out;
820
821 dev_spec->ffe_config = e1000_ffe_config_enabled;
822 }
823
824out:
825 return ret_val;
826}
827
828
829
830
831
832
833
834
835
836
837
838
839STATIC s32 e1000_get_cable_length_igp_82541(struct e1000_hw *hw)
840{
841 struct e1000_phy_info *phy = &hw->phy;
842 s32 ret_val = E1000_SUCCESS;
843 u16 i, data;
844 u16 cur_agc_value, agc_value = 0;
845 u16 min_agc_value = IGP01E1000_AGC_LENGTH_TABLE_SIZE;
846 u16 agc_reg_array[IGP01E1000_PHY_CHANNEL_NUM] = {IGP01E1000_PHY_AGC_A,
847 IGP01E1000_PHY_AGC_B,
848 IGP01E1000_PHY_AGC_C,
849 IGP01E1000_PHY_AGC_D};
850
851 DEBUGFUNC("e1000_get_cable_length_igp_82541");
852
853
854 for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) {
855 ret_val = phy->ops.read_reg(hw, agc_reg_array[i], &data);
856 if (ret_val)
857 goto out;
858
859 cur_agc_value = data >> IGP01E1000_AGC_LENGTH_SHIFT;
860
861
862 if ((cur_agc_value >= IGP01E1000_AGC_LENGTH_TABLE_SIZE - 1) ||
863 (cur_agc_value == 0)) {
864 ret_val = -E1000_ERR_PHY;
865 goto out;
866 }
867
868 agc_value += cur_agc_value;
869
870 if (min_agc_value > cur_agc_value)
871 min_agc_value = cur_agc_value;
872 }
873
874
875 if (agc_value < IGP01E1000_PHY_CHANNEL_NUM * 50) {
876 agc_value -= min_agc_value;
877
878 agc_value /= (IGP01E1000_PHY_CHANNEL_NUM - 1);
879 } else {
880
881 agc_value /= IGP01E1000_PHY_CHANNEL_NUM;
882 }
883
884 phy->min_cable_length = (e1000_igp_cable_length_table[agc_value] >
885 IGP01E1000_AGC_RANGE)
886 ? (e1000_igp_cable_length_table[agc_value] -
887 IGP01E1000_AGC_RANGE)
888 : 0;
889 phy->max_cable_length = e1000_igp_cable_length_table[agc_value] +
890 IGP01E1000_AGC_RANGE;
891
892 phy->cable_length = (phy->min_cable_length + phy->max_cable_length) / 2;
893
894out:
895 return ret_val;
896}
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912STATIC s32 e1000_set_d3_lplu_state_82541(struct e1000_hw *hw, bool active)
913{
914 struct e1000_phy_info *phy = &hw->phy;
915 s32 ret_val;
916 u16 data;
917
918 DEBUGFUNC("e1000_set_d3_lplu_state_82541");
919
920 switch (hw->mac.type) {
921 case e1000_82541_rev_2:
922 case e1000_82547_rev_2:
923 break;
924 default:
925 ret_val = e1000_set_d3_lplu_state_generic(hw, active);
926 goto out;
927 break;
928 }
929
930 ret_val = phy->ops.read_reg(hw, IGP01E1000_GMII_FIFO, &data);
931 if (ret_val)
932 goto out;
933
934 if (!active) {
935 data &= ~IGP01E1000_GMII_FLEX_SPD;
936 ret_val = phy->ops.write_reg(hw, IGP01E1000_GMII_FIFO, data);
937 if (ret_val)
938 goto out;
939
940
941
942
943
944
945
946 if (phy->smart_speed == e1000_smart_speed_on) {
947 ret_val = phy->ops.read_reg(hw,
948 IGP01E1000_PHY_PORT_CONFIG,
949 &data);
950 if (ret_val)
951 goto out;
952
953 data |= IGP01E1000_PSCFR_SMART_SPEED;
954 ret_val = phy->ops.write_reg(hw,
955 IGP01E1000_PHY_PORT_CONFIG,
956 data);
957 if (ret_val)
958 goto out;
959 } else if (phy->smart_speed == e1000_smart_speed_off) {
960 ret_val = phy->ops.read_reg(hw,
961 IGP01E1000_PHY_PORT_CONFIG,
962 &data);
963 if (ret_val)
964 goto out;
965
966 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
967 ret_val = phy->ops.write_reg(hw,
968 IGP01E1000_PHY_PORT_CONFIG,
969 data);
970 if (ret_val)
971 goto out;
972 }
973 } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) ||
974 (phy->autoneg_advertised == E1000_ALL_NOT_GIG) ||
975 (phy->autoneg_advertised == E1000_ALL_10_SPEED)) {
976 data |= IGP01E1000_GMII_FLEX_SPD;
977 ret_val = phy->ops.write_reg(hw, IGP01E1000_GMII_FIFO, data);
978 if (ret_val)
979 goto out;
980
981
982 ret_val = phy->ops.read_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
983 &data);
984 if (ret_val)
985 goto out;
986
987 data &= ~IGP01E1000_PSCFR_SMART_SPEED;
988 ret_val = phy->ops.write_reg(hw, IGP01E1000_PHY_PORT_CONFIG,
989 data);
990 }
991
992out:
993 return ret_val;
994}
995
996
997
998
999
1000
1001
1002
1003STATIC s32 e1000_setup_led_82541(struct e1000_hw *hw)
1004{
1005 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
1006 s32 ret_val;
1007
1008 DEBUGFUNC("e1000_setup_led_82541");
1009
1010 ret_val = hw->phy.ops.read_reg(hw, IGP01E1000_GMII_FIFO,
1011 &dev_spec->spd_default);
1012 if (ret_val)
1013 goto out;
1014
1015 ret_val = hw->phy.ops.write_reg(hw, IGP01E1000_GMII_FIFO,
1016 (u16)(dev_spec->spd_default &
1017 ~IGP01E1000_GMII_SPD));
1018 if (ret_val)
1019 goto out;
1020
1021 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1);
1022
1023out:
1024 return ret_val;
1025}
1026
1027
1028
1029
1030
1031
1032
1033
1034STATIC s32 e1000_cleanup_led_82541(struct e1000_hw *hw)
1035{
1036 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
1037 s32 ret_val;
1038
1039 DEBUGFUNC("e1000_cleanup_led_82541");
1040
1041 ret_val = hw->phy.ops.write_reg(hw, IGP01E1000_GMII_FIFO,
1042 dev_spec->spd_default);
1043 if (ret_val)
1044 goto out;
1045
1046 E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default);
1047
1048out:
1049 return ret_val;
1050}
1051
1052
1053
1054
1055
1056
1057
1058STATIC s32 e1000_phy_init_script_82541(struct e1000_hw *hw)
1059{
1060 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
1061 u32 ret_val;
1062 u16 phy_saved_data;
1063
1064 DEBUGFUNC("e1000_phy_init_script_82541");
1065
1066 if (!dev_spec->phy_init_script) {
1067 ret_val = E1000_SUCCESS;
1068 goto out;
1069 }
1070
1071
1072 msec_delay(20);
1073
1074
1075
1076
1077
1078 ret_val = hw->phy.ops.read_reg(hw, 0x2F5B, &phy_saved_data);
1079
1080
1081 hw->phy.ops.write_reg(hw, 0x2F5B, 0x0003);
1082
1083 msec_delay(20);
1084
1085 hw->phy.ops.write_reg(hw, 0x0000, 0x0140);
1086
1087 msec_delay(5);
1088
1089 switch (hw->mac.type) {
1090 case e1000_82541:
1091 case e1000_82547:
1092 hw->phy.ops.write_reg(hw, 0x1F95, 0x0001);
1093
1094 hw->phy.ops.write_reg(hw, 0x1F71, 0xBD21);
1095
1096 hw->phy.ops.write_reg(hw, 0x1F79, 0x0018);
1097
1098 hw->phy.ops.write_reg(hw, 0x1F30, 0x1600);
1099
1100 hw->phy.ops.write_reg(hw, 0x1F31, 0x0014);
1101
1102 hw->phy.ops.write_reg(hw, 0x1F32, 0x161C);
1103
1104 hw->phy.ops.write_reg(hw, 0x1F94, 0x0003);
1105
1106 hw->phy.ops.write_reg(hw, 0x1F96, 0x003F);
1107
1108 hw->phy.ops.write_reg(hw, 0x2010, 0x0008);
1109 break;
1110 case e1000_82541_rev_2:
1111 case e1000_82547_rev_2:
1112 hw->phy.ops.write_reg(hw, 0x1F73, 0x0099);
1113 break;
1114 default:
1115 break;
1116 }
1117
1118 hw->phy.ops.write_reg(hw, 0x0000, 0x3300);
1119
1120 msec_delay(20);
1121
1122
1123 hw->phy.ops.write_reg(hw, 0x2F5B, phy_saved_data);
1124
1125 if (hw->mac.type == e1000_82547) {
1126 u16 fused, fine, coarse;
1127
1128
1129 hw->phy.ops.read_reg(hw, IGP01E1000_ANALOG_SPARE_FUSE_STATUS,
1130 &fused);
1131
1132 if (!(fused & IGP01E1000_ANALOG_SPARE_FUSE_ENABLED)) {
1133 hw->phy.ops.read_reg(hw, IGP01E1000_ANALOG_FUSE_STATUS,
1134 &fused);
1135
1136 fine = fused & IGP01E1000_ANALOG_FUSE_FINE_MASK;
1137 coarse = fused & IGP01E1000_ANALOG_FUSE_COARSE_MASK;
1138
1139 if (coarse > IGP01E1000_ANALOG_FUSE_COARSE_THRESH) {
1140 coarse -= IGP01E1000_ANALOG_FUSE_COARSE_10;
1141 fine -= IGP01E1000_ANALOG_FUSE_FINE_1;
1142 } else if (coarse ==
1143 IGP01E1000_ANALOG_FUSE_COARSE_THRESH)
1144 fine -= IGP01E1000_ANALOG_FUSE_FINE_10;
1145
1146 fused = (fused & IGP01E1000_ANALOG_FUSE_POLY_MASK) |
1147 (fine & IGP01E1000_ANALOG_FUSE_FINE_MASK) |
1148 (coarse & IGP01E1000_ANALOG_FUSE_COARSE_MASK);
1149
1150 hw->phy.ops.write_reg(hw,
1151 IGP01E1000_ANALOG_FUSE_CONTROL,
1152 fused);
1153 hw->phy.ops.write_reg(hw,
1154 IGP01E1000_ANALOG_FUSE_BYPASS,
1155 IGP01E1000_ANALOG_FUSE_ENABLE_SW_CONTROL);
1156 }
1157 }
1158
1159out:
1160 return ret_val;
1161}
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171void e1000_init_script_state_82541(struct e1000_hw *hw, bool state)
1172{
1173 struct e1000_dev_spec_82541 *dev_spec = &hw->dev_spec._82541;
1174
1175 DEBUGFUNC("e1000_init_script_state_82541");
1176
1177 if (hw->phy.type != e1000_phy_igp) {
1178 DEBUGOUT("Initialization script not necessary.\n");
1179 goto out;
1180 }
1181
1182 dev_spec->phy_init_script = state;
1183
1184out:
1185 return;
1186}
1187
1188
1189
1190
1191
1192
1193
1194
1195STATIC void e1000_power_down_phy_copper_82541(struct e1000_hw *hw)
1196{
1197
1198 if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_SMBUS_EN))
1199 e1000_power_down_phy_copper(hw);
1200
1201 return;
1202}
1203
1204
1205
1206
1207
1208
1209
1210STATIC void e1000_clear_hw_cntrs_82541(struct e1000_hw *hw)
1211{
1212 DEBUGFUNC("e1000_clear_hw_cntrs_82541");
1213
1214 e1000_clear_hw_cntrs_base_generic(hw);
1215
1216 E1000_READ_REG(hw, E1000_PRC64);
1217 E1000_READ_REG(hw, E1000_PRC127);
1218 E1000_READ_REG(hw, E1000_PRC255);
1219 E1000_READ_REG(hw, E1000_PRC511);
1220 E1000_READ_REG(hw, E1000_PRC1023);
1221 E1000_READ_REG(hw, E1000_PRC1522);
1222 E1000_READ_REG(hw, E1000_PTC64);
1223 E1000_READ_REG(hw, E1000_PTC127);
1224 E1000_READ_REG(hw, E1000_PTC255);
1225 E1000_READ_REG(hw, E1000_PTC511);
1226 E1000_READ_REG(hw, E1000_PTC1023);
1227 E1000_READ_REG(hw, E1000_PTC1522);
1228
1229 E1000_READ_REG(hw, E1000_ALGNERRC);
1230 E1000_READ_REG(hw, E1000_RXERRC);
1231 E1000_READ_REG(hw, E1000_TNCRS);
1232 E1000_READ_REG(hw, E1000_CEXTERR);
1233 E1000_READ_REG(hw, E1000_TSCTC);
1234 E1000_READ_REG(hw, E1000_TSCTFC);
1235
1236 E1000_READ_REG(hw, E1000_MGTPRC);
1237 E1000_READ_REG(hw, E1000_MGTPDC);
1238 E1000_READ_REG(hw, E1000_MGTPTC);
1239}
1240