1 /*******************************************************************************
3 Intel PRO/1000 Linux driver
4 Copyright(c) 1999 - 2008 Intel Corporation.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
23 Linux NICS <linux.nics@intel.com>
24 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
25 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
27 *******************************************************************************/
30 * 82562G 10/100 Network Connection
31 * 82562G-2 10/100 Network Connection
32 * 82562GT 10/100 Network Connection
33 * 82562GT-2 10/100 Network Connection
34 * 82562V 10/100 Network Connection
35 * 82562V-2 10/100 Network Connection
36 * 82566DC-2 Gigabit Network Connection
37 * 82566DC Gigabit Network Connection
38 * 82566DM-2 Gigabit Network Connection
39 * 82566DM Gigabit Network Connection
40 * 82566MC Gigabit Network Connection
41 * 82566MM Gigabit Network Connection
42 * 82567LM Gigabit Network Connection
43 * 82567LF Gigabit Network Connection
44 * 82567V Gigabit Network Connection
45 * 82567LM-2 Gigabit Network Connection
46 * 82567LF-2 Gigabit Network Connection
47 * 82567V-2 Gigabit Network Connection
48 * 82567LF-3 Gigabit Network Connection
49 * 82567LM-3 Gigabit Network Connection
50 * 82567LM-4 Gigabit Network Connection
51 * 82577LM Gigabit Network Connection
52 * 82577LC Gigabit Network Connection
53 * 82578DM Gigabit Network Connection
54 * 82578DC Gigabit Network Connection
57 #include <linux/netdevice.h>
58 #include <linux/ethtool.h>
59 #include <linux/delay.h>
60 #include <linux/pci.h>
64 #define ICH_FLASH_GFPREG 0x0000
65 #define ICH_FLASH_HSFSTS 0x0004
66 #define ICH_FLASH_HSFCTL 0x0006
67 #define ICH_FLASH_FADDR 0x0008
68 #define ICH_FLASH_FDATA0 0x0010
69 #define ICH_FLASH_PR0 0x0074
71 #define ICH_FLASH_READ_COMMAND_TIMEOUT 500
72 #define ICH_FLASH_WRITE_COMMAND_TIMEOUT 500
73 #define ICH_FLASH_ERASE_COMMAND_TIMEOUT 3000000
74 #define ICH_FLASH_LINEAR_ADDR_MASK 0x00FFFFFF
75 #define ICH_FLASH_CYCLE_REPEAT_COUNT 10
77 #define ICH_CYCLE_READ 0
78 #define ICH_CYCLE_WRITE 2
79 #define ICH_CYCLE_ERASE 3
81 #define FLASH_GFPREG_BASE_MASK 0x1FFF
82 #define FLASH_SECTOR_ADDR_SHIFT 12
84 #define ICH_FLASH_SEG_SIZE_256 256
85 #define ICH_FLASH_SEG_SIZE_4K 4096
86 #define ICH_FLASH_SEG_SIZE_8K 8192
87 #define ICH_FLASH_SEG_SIZE_64K 65536
90 #define E1000_ICH_FWSM_RSPCIPHY 0x00000040 /* Reset PHY on PCI Reset */
92 #define E1000_ICH_MNG_IAMT_MODE 0x2
94 #define ID_LED_DEFAULT_ICH8LAN ((ID_LED_DEF1_DEF2 << 12) | \
95 (ID_LED_DEF1_OFF2 << 8) | \
96 (ID_LED_DEF1_ON2 << 4) | \
99 #define E1000_ICH_NVM_SIG_WORD 0x13
100 #define E1000_ICH_NVM_SIG_MASK 0xC000
101 #define E1000_ICH_NVM_VALID_SIG_MASK 0xC0
102 #define E1000_ICH_NVM_SIG_VALUE 0x80
104 #define E1000_ICH8_LAN_INIT_TIMEOUT 1500
106 #define E1000_FEXTNVM_SW_CONFIG 1
107 #define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */
109 #define PCIE_ICH8_SNOOP_ALL PCIE_NO_SNOOP_ALL
111 #define E1000_ICH_RAR_ENTRIES 7
113 #define PHY_PAGE_SHIFT 5
114 #define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \
115 ((reg) & MAX_PHY_REG_ADDRESS))
116 #define IGP3_KMRN_DIAG PHY_REG(770, 19) /* KMRN Diagnostic */
117 #define IGP3_VR_CTRL PHY_REG(776, 18) /* Voltage Regulator Control */
119 #define IGP3_KMRN_DIAG_PCS_LOCK_LOSS 0x0002
120 #define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
121 #define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
123 #define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
125 #define SW_FLAG_TIMEOUT 1000 /* SW Semaphore flag timeout in milliseconds */
127 /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
128 /* Offset 04h HSFSTS */
129 union ich8_hws_flash_status
{
131 u16 flcdone
:1; /* bit 0 Flash Cycle Done */
132 u16 flcerr
:1; /* bit 1 Flash Cycle Error */
133 u16 dael
:1; /* bit 2 Direct Access error Log */
134 u16 berasesz
:2; /* bit 4:3 Sector Erase Size */
135 u16 flcinprog
:1; /* bit 5 flash cycle in Progress */
136 u16 reserved1
:2; /* bit 13:6 Reserved */
137 u16 reserved2
:6; /* bit 13:6 Reserved */
138 u16 fldesvalid
:1; /* bit 14 Flash Descriptor Valid */
139 u16 flockdn
:1; /* bit 15 Flash Config Lock-Down */
144 /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */
145 /* Offset 06h FLCTL */
146 union ich8_hws_flash_ctrl
{
147 struct ich8_hsflctl
{
148 u16 flcgo
:1; /* 0 Flash Cycle Go */
149 u16 flcycle
:2; /* 2:1 Flash Cycle */
150 u16 reserved
:5; /* 7:3 Reserved */
151 u16 fldbcount
:2; /* 9:8 Flash Data Byte Count */
152 u16 flockdn
:6; /* 15:10 Reserved */
157 /* ICH Flash Region Access Permissions */
158 union ich8_hws_flash_regacc
{
160 u32 grra
:8; /* 0:7 GbE region Read Access */
161 u32 grwa
:8; /* 8:15 GbE region Write Access */
162 u32 gmrag
:8; /* 23:16 GbE Master Read Access Grant */
163 u32 gmwag
:8; /* 31:24 GbE Master Write Access Grant */
168 /* ICH Flash Protected Region */
169 union ich8_flash_protected_range
{
171 u32 base
:13; /* 0:12 Protected Range Base */
172 u32 reserved1
:2; /* 13:14 Reserved */
173 u32 rpe
:1; /* 15 Read Protection Enable */
174 u32 limit
:13; /* 16:28 Protected Range Limit */
175 u32 reserved2
:2; /* 29:30 Reserved */
176 u32 wpe
:1; /* 31 Write Protection Enable */
181 static s32
e1000_setup_link_ich8lan(struct e1000_hw
*hw
);
182 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
);
183 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
);
184 static s32
e1000_check_polarity_ife_ich8lan(struct e1000_hw
*hw
);
185 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
);
186 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
187 u32 offset
, u8 byte
);
188 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
190 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
192 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
194 static s32
e1000_setup_copper_link_ich8lan(struct e1000_hw
*hw
);
195 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
);
196 static s32
e1000_get_cfg_done_ich8lan(struct e1000_hw
*hw
);
197 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
);
198 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
);
199 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
);
200 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
);
201 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
);
202 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
);
203 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
);
204 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
);
206 static inline u16
__er16flash(struct e1000_hw
*hw
, unsigned long reg
)
208 return readw(hw
->flash_address
+ reg
);
211 static inline u32
__er32flash(struct e1000_hw
*hw
, unsigned long reg
)
213 return readl(hw
->flash_address
+ reg
);
216 static inline void __ew16flash(struct e1000_hw
*hw
, unsigned long reg
, u16 val
)
218 writew(val
, hw
->flash_address
+ reg
);
221 static inline void __ew32flash(struct e1000_hw
*hw
, unsigned long reg
, u32 val
)
223 writel(val
, hw
->flash_address
+ reg
);
226 #define er16flash(reg) __er16flash(hw, (reg))
227 #define er32flash(reg) __er32flash(hw, (reg))
228 #define ew16flash(reg,val) __ew16flash(hw, (reg), (val))
229 #define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
232 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
233 * @hw: pointer to the HW structure
235 * Initialize family-specific PHY parameters and function pointers.
237 static s32
e1000_init_phy_params_pchlan(struct e1000_hw
*hw
)
239 struct e1000_phy_info
*phy
= &hw
->phy
;
243 phy
->reset_delay_us
= 100;
245 phy
->ops
.check_polarity
= e1000_check_polarity_ife_ich8lan
;
246 phy
->ops
.read_phy_reg
= e1000_read_phy_reg_hv
;
247 phy
->ops
.write_phy_reg
= e1000_write_phy_reg_hv
;
248 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
250 phy
->id
= e1000_phy_unknown
;
251 e1000e_get_phy_id(hw
);
252 phy
->type
= e1000e_get_phy_type_from_id(phy
->id
);
254 if (phy
->type
== e1000_phy_82577
) {
255 phy
->ops
.check_polarity
= e1000_check_polarity_82577
;
256 phy
->ops
.force_speed_duplex
=
257 e1000_phy_force_speed_duplex_82577
;
258 phy
->ops
.get_cable_length
= e1000_get_cable_length_82577
;
259 phy
->ops
.get_phy_info
= e1000_get_phy_info_82577
;
260 phy
->ops
.commit_phy
= e1000e_phy_sw_reset
;
267 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
268 * @hw: pointer to the HW structure
270 * Initialize family-specific PHY parameters and function pointers.
272 static s32
e1000_init_phy_params_ich8lan(struct e1000_hw
*hw
)
274 struct e1000_phy_info
*phy
= &hw
->phy
;
279 phy
->reset_delay_us
= 100;
282 * We may need to do this twice - once for IGP and if that fails,
283 * we'll set BM func pointers and try again
285 ret_val
= e1000e_determine_phy_address(hw
);
287 hw
->phy
.ops
.write_phy_reg
= e1000e_write_phy_reg_bm
;
288 hw
->phy
.ops
.read_phy_reg
= e1000e_read_phy_reg_bm
;
289 ret_val
= e1000e_determine_phy_address(hw
);
295 while ((e1000_phy_unknown
== e1000e_get_phy_type_from_id(phy
->id
)) &&
298 ret_val
= e1000e_get_phy_id(hw
);
305 case IGP03E1000_E_PHY_ID
:
306 phy
->type
= e1000_phy_igp_3
;
307 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
310 case IFE_PLUS_E_PHY_ID
:
312 phy
->type
= e1000_phy_ife
;
313 phy
->autoneg_mask
= E1000_ALL_NOT_GIG
;
315 case BME1000_E_PHY_ID
:
316 phy
->type
= e1000_phy_bm
;
317 phy
->autoneg_mask
= AUTONEG_ADVERTISE_SPEED_DEFAULT
;
318 hw
->phy
.ops
.read_phy_reg
= e1000e_read_phy_reg_bm
;
319 hw
->phy
.ops
.write_phy_reg
= e1000e_write_phy_reg_bm
;
320 hw
->phy
.ops
.commit_phy
= e1000e_phy_sw_reset
;
323 return -E1000_ERR_PHY
;
327 phy
->ops
.check_polarity
= e1000_check_polarity_ife_ich8lan
;
333 * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers
334 * @hw: pointer to the HW structure
336 * Initialize family-specific NVM parameters and function
339 static s32
e1000_init_nvm_params_ich8lan(struct e1000_hw
*hw
)
341 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
342 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
343 u32 gfpreg
, sector_base_addr
, sector_end_addr
;
346 /* Can't read flash registers if the register set isn't mapped. */
347 if (!hw
->flash_address
) {
348 hw_dbg(hw
, "ERROR: Flash registers not mapped\n");
349 return -E1000_ERR_CONFIG
;
352 nvm
->type
= e1000_nvm_flash_sw
;
354 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
357 * sector_X_addr is a "sector"-aligned address (4096 bytes)
358 * Add 1 to sector_end_addr since this sector is included in
361 sector_base_addr
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
362 sector_end_addr
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
) + 1;
364 /* flash_base_addr is byte-aligned */
365 nvm
->flash_base_addr
= sector_base_addr
<< FLASH_SECTOR_ADDR_SHIFT
;
368 * find total size of the NVM, then cut in half since the total
369 * size represents two separate NVM banks.
371 nvm
->flash_bank_size
= (sector_end_addr
- sector_base_addr
)
372 << FLASH_SECTOR_ADDR_SHIFT
;
373 nvm
->flash_bank_size
/= 2;
374 /* Adjust to word count */
375 nvm
->flash_bank_size
/= sizeof(u16
);
377 nvm
->word_size
= E1000_ICH8_SHADOW_RAM_WORDS
;
379 /* Clear shadow ram */
380 for (i
= 0; i
< nvm
->word_size
; i
++) {
381 dev_spec
->shadow_ram
[i
].modified
= 0;
382 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
389 * e1000_init_mac_params_ich8lan - Initialize MAC function pointers
390 * @hw: pointer to the HW structure
392 * Initialize family-specific MAC parameters and function
395 static s32
e1000_init_mac_params_ich8lan(struct e1000_adapter
*adapter
)
397 struct e1000_hw
*hw
= &adapter
->hw
;
398 struct e1000_mac_info
*mac
= &hw
->mac
;
400 /* Set media type function pointer */
401 hw
->phy
.media_type
= e1000_media_type_copper
;
403 /* Set mta register count */
404 mac
->mta_reg_count
= 32;
405 /* Set rar entry count */
406 mac
->rar_entry_count
= E1000_ICH_RAR_ENTRIES
;
407 if (mac
->type
== e1000_ich8lan
)
408 mac
->rar_entry_count
--;
409 /* Set if manageability features are enabled. */
410 mac
->arc_subsystem_valid
= 1;
418 mac
->ops
.id_led_init
= e1000e_id_led_init
;
420 mac
->ops
.setup_led
= e1000e_setup_led_generic
;
422 mac
->ops
.cleanup_led
= e1000_cleanup_led_ich8lan
;
423 /* turn on/off LED */
424 mac
->ops
.led_on
= e1000_led_on_ich8lan
;
425 mac
->ops
.led_off
= e1000_led_off_ich8lan
;
429 mac
->ops
.id_led_init
= e1000_id_led_init_pchlan
;
431 mac
->ops
.setup_led
= e1000_setup_led_pchlan
;
433 mac
->ops
.cleanup_led
= e1000_cleanup_led_pchlan
;
434 /* turn on/off LED */
435 mac
->ops
.led_on
= e1000_led_on_pchlan
;
436 mac
->ops
.led_off
= e1000_led_off_pchlan
;
442 /* Enable PCS Lock-loss workaround for ICH8 */
443 if (mac
->type
== e1000_ich8lan
)
444 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw
, 1);
450 * e1000_check_for_copper_link_ich8lan - Check for link (Copper)
451 * @hw: pointer to the HW structure
453 * Checks to see of the link status of the hardware has changed. If a
454 * change in link status has been detected, then we read the PHY registers
455 * to get the current speed/duplex if link exists.
457 static s32
e1000_check_for_copper_link_ich8lan(struct e1000_hw
*hw
)
459 struct e1000_mac_info
*mac
= &hw
->mac
;
464 * We only want to go out to the PHY registers to see if Auto-Neg
465 * has completed and/or if our link status has changed. The
466 * get_link_status flag is set upon receiving a Link Status
467 * Change or Rx Sequence Error interrupt.
469 if (!mac
->get_link_status
) {
474 if (hw
->mac
.type
== e1000_pchlan
) {
475 ret_val
= e1000e_write_kmrn_reg(hw
,
476 E1000_KMRNCTRLSTA_K1_CONFIG
,
477 E1000_KMRNCTRLSTA_K1_ENABLE
);
483 * First we want to see if the MII Status Register reports
484 * link. If so, then we want to get the current speed/duplex
487 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
492 goto out
; /* No link detected */
494 mac
->get_link_status
= false;
496 if (hw
->phy
.type
== e1000_phy_82578
) {
497 ret_val
= e1000_link_stall_workaround_hv(hw
);
503 * Check if there was DownShift, must be checked
504 * immediately after link-up
506 e1000e_check_downshift(hw
);
509 * If we are forcing speed/duplex, then we simply return since
510 * we have already determined whether we have link or not.
513 ret_val
= -E1000_ERR_CONFIG
;
518 * Auto-Neg is enabled. Auto Speed Detection takes care
519 * of MAC speed/duplex configuration. So we only need to
520 * configure Collision Distance in the MAC.
522 e1000e_config_collision_dist(hw
);
525 * Configure Flow Control now that Auto-Neg has completed.
526 * First, we need to restore the desired flow control
527 * settings because we may have had to re-autoneg with a
528 * different link partner.
530 ret_val
= e1000e_config_fc_after_link_up(hw
);
532 hw_dbg(hw
, "Error configuring flow control\n");
538 static s32
e1000_get_variants_ich8lan(struct e1000_adapter
*adapter
)
540 struct e1000_hw
*hw
= &adapter
->hw
;
543 rc
= e1000_init_mac_params_ich8lan(adapter
);
547 rc
= e1000_init_nvm_params_ich8lan(hw
);
551 if (hw
->mac
.type
== e1000_pchlan
)
552 rc
= e1000_init_phy_params_pchlan(hw
);
554 rc
= e1000_init_phy_params_ich8lan(hw
);
558 if (adapter
->hw
.phy
.type
== e1000_phy_ife
) {
559 adapter
->flags
&= ~FLAG_HAS_JUMBO_FRAMES
;
560 adapter
->max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
;
563 if ((adapter
->hw
.mac
.type
== e1000_ich8lan
) &&
564 (adapter
->hw
.phy
.type
== e1000_phy_igp_3
))
565 adapter
->flags
|= FLAG_LSC_GIG_SPEED_DROP
;
570 static DEFINE_MUTEX(nvm_mutex
);
573 * e1000_acquire_swflag_ich8lan - Acquire software control flag
574 * @hw: pointer to the HW structure
576 * Acquires the software control flag for performing NVM and PHY
577 * operations. This is a function pointer entry point only called by
578 * read/write routines for the PHY and NVM parts.
580 static s32
e1000_acquire_swflag_ich8lan(struct e1000_hw
*hw
)
582 u32 extcnf_ctrl
, timeout
= PHY_CFG_TIMEOUT
;
587 mutex_lock(&nvm_mutex
);
590 extcnf_ctrl
= er32(EXTCNF_CTRL
);
591 if (!(extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
))
599 hw_dbg(hw
, "SW/FW/HW has locked the resource for too long.\n");
600 ret_val
= -E1000_ERR_CONFIG
;
604 timeout
= SW_FLAG_TIMEOUT
;
606 extcnf_ctrl
|= E1000_EXTCNF_CTRL_SWFLAG
;
607 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
610 extcnf_ctrl
= er32(EXTCNF_CTRL
);
611 if (extcnf_ctrl
& E1000_EXTCNF_CTRL_SWFLAG
)
619 hw_dbg(hw
, "Failed to acquire the semaphore.\n");
620 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
621 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
622 ret_val
= -E1000_ERR_CONFIG
;
628 mutex_unlock(&nvm_mutex
);
634 * e1000_release_swflag_ich8lan - Release software control flag
635 * @hw: pointer to the HW structure
637 * Releases the software control flag for performing NVM and PHY operations.
638 * This is a function pointer entry point only called by read/write
639 * routines for the PHY and NVM parts.
641 static void e1000_release_swflag_ich8lan(struct e1000_hw
*hw
)
645 extcnf_ctrl
= er32(EXTCNF_CTRL
);
646 extcnf_ctrl
&= ~E1000_EXTCNF_CTRL_SWFLAG
;
647 ew32(EXTCNF_CTRL
, extcnf_ctrl
);
649 mutex_unlock(&nvm_mutex
);
653 * e1000_check_mng_mode_ich8lan - Checks management mode
654 * @hw: pointer to the HW structure
656 * This checks if the adapter has manageability enabled.
657 * This is a function pointer entry point only called by read/write
658 * routines for the PHY and NVM parts.
660 static bool e1000_check_mng_mode_ich8lan(struct e1000_hw
*hw
)
662 u32 fwsm
= er32(FWSM
);
664 return (fwsm
& E1000_FWSM_MODE_MASK
) ==
665 (E1000_ICH_MNG_IAMT_MODE
<< E1000_FWSM_MODE_SHIFT
);
669 * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked
670 * @hw: pointer to the HW structure
672 * Checks if firmware is blocking the reset of the PHY.
673 * This is a function pointer entry point only called by
676 static s32
e1000_check_reset_block_ich8lan(struct e1000_hw
*hw
)
682 return (fwsm
& E1000_ICH_FWSM_RSPCIPHY
) ? 0 : E1000_BLK_PHY_RESET
;
686 * e1000_phy_force_speed_duplex_ich8lan - Force PHY speed & duplex
687 * @hw: pointer to the HW structure
689 * Forces the speed and duplex settings of the PHY.
690 * This is a function pointer entry point only called by
691 * PHY setup routines.
693 static s32
e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw
*hw
)
695 struct e1000_phy_info
*phy
= &hw
->phy
;
700 if (phy
->type
!= e1000_phy_ife
) {
701 ret_val
= e1000e_phy_force_speed_duplex_igp(hw
);
705 ret_val
= e1e_rphy(hw
, PHY_CONTROL
, &data
);
709 e1000e_phy_force_speed_duplex_setup(hw
, &data
);
711 ret_val
= e1e_wphy(hw
, PHY_CONTROL
, data
);
715 /* Disable MDI-X support for 10/100 */
716 ret_val
= e1e_rphy(hw
, IFE_PHY_MDIX_CONTROL
, &data
);
720 data
&= ~IFE_PMC_AUTO_MDIX
;
721 data
&= ~IFE_PMC_FORCE_MDIX
;
723 ret_val
= e1e_wphy(hw
, IFE_PHY_MDIX_CONTROL
, data
);
727 hw_dbg(hw
, "IFE PMC: %X\n", data
);
731 if (phy
->autoneg_wait_to_complete
) {
732 hw_dbg(hw
, "Waiting for forced speed/duplex link on IFE phy.\n");
734 ret_val
= e1000e_phy_has_link_generic(hw
,
742 hw_dbg(hw
, "Link taking longer than expected.\n");
745 ret_val
= e1000e_phy_has_link_generic(hw
,
757 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
758 * done after every PHY reset.
760 static s32
e1000_hv_phy_workarounds_ich8lan(struct e1000_hw
*hw
)
764 if (hw
->mac
.type
!= e1000_pchlan
)
767 if (((hw
->phy
.type
== e1000_phy_82577
) &&
768 ((hw
->phy
.revision
== 1) || (hw
->phy
.revision
== 2))) ||
769 ((hw
->phy
.type
== e1000_phy_82578
) && (hw
->phy
.revision
== 1))) {
770 /* Disable generation of early preamble */
771 ret_val
= e1e_wphy(hw
, PHY_REG(769, 25), 0x4431);
775 /* Preamble tuning for SSC */
776 ret_val
= e1e_wphy(hw
, PHY_REG(770, 16), 0xA204);
781 if (hw
->phy
.type
== e1000_phy_82578
) {
783 * Return registers to default by doing a soft reset then
784 * writing 0x3140 to the control register.
786 if (hw
->phy
.revision
< 2) {
787 e1000e_phy_sw_reset(hw
);
788 ret_val
= e1e_wphy(hw
, PHY_CONTROL
, 0x3140);
793 ret_val
= hw
->phy
.ops
.acquire_phy(hw
);
797 e1000e_write_phy_reg_mdic(hw
, IGP01E1000_PHY_PAGE_SELECT
, 0);
798 hw
->phy
.ops
.release_phy(hw
);
804 * e1000_lan_init_done_ich8lan - Check for PHY config completion
805 * @hw: pointer to the HW structure
807 * Check the appropriate indication the MAC has finished configuring the
808 * PHY after a software reset.
810 static void e1000_lan_init_done_ich8lan(struct e1000_hw
*hw
)
812 u32 data
, loop
= E1000_ICH8_LAN_INIT_TIMEOUT
;
814 /* Wait for basic configuration completes before proceeding */
817 data
&= E1000_STATUS_LAN_INIT_DONE
;
819 } while ((!data
) && --loop
);
822 * If basic configuration is incomplete before the above loop
823 * count reaches 0, loading the configuration from NVM will
824 * leave the PHY in a bad state possibly resulting in no link.
827 hw_dbg(hw
, "LAN_INIT_DONE not set, increase timeout\n");
829 /* Clear the Init Done bit for the next init event */
831 data
&= ~E1000_STATUS_LAN_INIT_DONE
;
836 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
837 * @hw: pointer to the HW structure
840 * This is a function pointer entry point called by drivers
841 * or other shared routines.
843 static s32
e1000_phy_hw_reset_ich8lan(struct e1000_hw
*hw
)
845 struct e1000_phy_info
*phy
= &hw
->phy
;
847 u32 data
, cnf_size
, cnf_base_addr
, sw_cfg_mask
;
849 u16 reg
, word_addr
, reg_data
, reg_addr
, phy_page
= 0;
851 ret_val
= e1000e_phy_hw_reset_generic(hw
);
855 /* Allow time for h/w to get to a quiescent state after reset */
858 if (hw
->mac
.type
== e1000_pchlan
) {
859 ret_val
= e1000_hv_phy_workarounds_ich8lan(hw
);
864 /* Dummy read to clear the phy wakeup bit after lcd reset */
865 if (hw
->mac
.type
== e1000_pchlan
)
866 e1e_rphy(hw
, BM_WUC
, ®
);
869 * Initialize the PHY from the NVM on ICH platforms. This
870 * is needed due to an issue where the NVM configuration is
871 * not properly autoloaded after power transitions.
872 * Therefore, after each PHY reset, we will load the
873 * configuration data out of the NVM manually.
875 if (hw
->mac
.type
== e1000_ich8lan
&& phy
->type
== e1000_phy_igp_3
) {
876 struct e1000_adapter
*adapter
= hw
->adapter
;
878 /* Check if SW needs configure the PHY */
879 if ((adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_M_AMT
) ||
880 (adapter
->pdev
->device
== E1000_DEV_ID_ICH8_IGP_M
))
881 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG_ICH8M
;
883 sw_cfg_mask
= E1000_FEXTNVM_SW_CONFIG
;
885 data
= er32(FEXTNVM
);
886 if (!(data
& sw_cfg_mask
))
889 /* Wait for basic configuration completes before proceeding */
890 e1000_lan_init_done_ich8lan(hw
);
893 * Make sure HW does not configure LCD from PHY
894 * extended configuration before SW configuration
896 data
= er32(EXTCNF_CTRL
);
897 if (data
& E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE
)
900 cnf_size
= er32(EXTCNF_SIZE
);
901 cnf_size
&= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK
;
902 cnf_size
>>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT
;
906 cnf_base_addr
= data
& E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK
;
907 cnf_base_addr
>>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT
;
909 /* Configure LCD from extended configuration region. */
911 /* cnf_base_addr is in DWORD */
912 word_addr
= (u16
)(cnf_base_addr
<< 1);
914 for (i
= 0; i
< cnf_size
; i
++) {
915 ret_val
= e1000_read_nvm(hw
,
922 ret_val
= e1000_read_nvm(hw
,
923 (word_addr
+ i
* 2 + 1),
929 /* Save off the PHY page for future writes. */
930 if (reg_addr
== IGP01E1000_PHY_PAGE_SELECT
) {
935 reg_addr
|= phy_page
;
937 ret_val
= e1e_wphy(hw
, (u32
)reg_addr
, reg_data
);
947 * e1000_get_phy_info_ife_ich8lan - Retrieves various IFE PHY states
948 * @hw: pointer to the HW structure
950 * Populates "phy" structure with various feature states.
951 * This function is only called by other family-specific
954 static s32
e1000_get_phy_info_ife_ich8lan(struct e1000_hw
*hw
)
956 struct e1000_phy_info
*phy
= &hw
->phy
;
961 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
966 hw_dbg(hw
, "Phy info is only valid if link is up\n");
967 return -E1000_ERR_CONFIG
;
970 ret_val
= e1e_rphy(hw
, IFE_PHY_SPECIAL_CONTROL
, &data
);
973 phy
->polarity_correction
= (!(data
& IFE_PSC_AUTO_POLARITY_DISABLE
));
975 if (phy
->polarity_correction
) {
976 ret_val
= phy
->ops
.check_polarity(hw
);
980 /* Polarity is forced */
981 phy
->cable_polarity
= (data
& IFE_PSC_FORCE_POLARITY
)
982 ? e1000_rev_polarity_reversed
983 : e1000_rev_polarity_normal
;
986 ret_val
= e1e_rphy(hw
, IFE_PHY_MDIX_CONTROL
, &data
);
990 phy
->is_mdix
= (data
& IFE_PMC_MDIX_STATUS
);
992 /* The following parameters are undefined for 10/100 operation. */
993 phy
->cable_length
= E1000_CABLE_LENGTH_UNDEFINED
;
994 phy
->local_rx
= e1000_1000t_rx_status_undefined
;
995 phy
->remote_rx
= e1000_1000t_rx_status_undefined
;
1001 * e1000_get_phy_info_ich8lan - Calls appropriate PHY type get_phy_info
1002 * @hw: pointer to the HW structure
1004 * Wrapper for calling the get_phy_info routines for the appropriate phy type.
1005 * This is a function pointer entry point called by drivers
1006 * or other shared routines.
1008 static s32
e1000_get_phy_info_ich8lan(struct e1000_hw
*hw
)
1010 switch (hw
->phy
.type
) {
1012 return e1000_get_phy_info_ife_ich8lan(hw
);
1014 case e1000_phy_igp_3
:
1016 case e1000_phy_82578
:
1017 case e1000_phy_82577
:
1018 return e1000e_get_phy_info_igp(hw
);
1024 return -E1000_ERR_PHY_TYPE
;
1028 * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY
1029 * @hw: pointer to the HW structure
1031 * Polarity is determined on the polarity reversal feature being enabled.
1032 * This function is only called by other family-specific
1035 static s32
e1000_check_polarity_ife_ich8lan(struct e1000_hw
*hw
)
1037 struct e1000_phy_info
*phy
= &hw
->phy
;
1039 u16 phy_data
, offset
, mask
;
1042 * Polarity is determined based on the reversal feature being enabled.
1044 if (phy
->polarity_correction
) {
1045 offset
= IFE_PHY_EXTENDED_STATUS_CONTROL
;
1046 mask
= IFE_PESC_POLARITY_REVERSED
;
1048 offset
= IFE_PHY_SPECIAL_CONTROL
;
1049 mask
= IFE_PSC_FORCE_POLARITY
;
1052 ret_val
= e1e_rphy(hw
, offset
, &phy_data
);
1055 phy
->cable_polarity
= (phy_data
& mask
)
1056 ? e1000_rev_polarity_reversed
1057 : e1000_rev_polarity_normal
;
1063 * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state
1064 * @hw: pointer to the HW structure
1065 * @active: TRUE to enable LPLU, FALSE to disable
1067 * Sets the LPLU D0 state according to the active flag. When
1068 * activating LPLU this function also disables smart speed
1069 * and vice versa. LPLU will not be activated unless the
1070 * device autonegotiation advertisement meets standards of
1071 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1072 * This is a function pointer entry point only called by
1073 * PHY setup routines.
1075 static s32
e1000_set_d0_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
1077 struct e1000_phy_info
*phy
= &hw
->phy
;
1082 if (phy
->type
== e1000_phy_ife
)
1085 phy_ctrl
= er32(PHY_CTRL
);
1088 phy_ctrl
|= E1000_PHY_CTRL_D0A_LPLU
;
1089 ew32(PHY_CTRL
, phy_ctrl
);
1091 if (phy
->type
!= e1000_phy_igp_3
)
1095 * Call gig speed drop workaround on LPLU before accessing
1098 if (hw
->mac
.type
== e1000_ich8lan
)
1099 e1000e_gig_downshift_workaround_ich8lan(hw
);
1101 /* When LPLU is enabled, we should disable SmartSpeed */
1102 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
1103 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1104 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
1108 phy_ctrl
&= ~E1000_PHY_CTRL_D0A_LPLU
;
1109 ew32(PHY_CTRL
, phy_ctrl
);
1111 if (phy
->type
!= e1000_phy_igp_3
)
1115 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
1116 * during Dx states where the power conservation is most
1117 * important. During driver activity we should enable
1118 * SmartSpeed, so performance is maintained.
1120 if (phy
->smart_speed
== e1000_smart_speed_on
) {
1121 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1126 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
1127 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1131 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
1132 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1137 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1138 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1149 * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state
1150 * @hw: pointer to the HW structure
1151 * @active: TRUE to enable LPLU, FALSE to disable
1153 * Sets the LPLU D3 state according to the active flag. When
1154 * activating LPLU this function also disables smart speed
1155 * and vice versa. LPLU will not be activated unless the
1156 * device autonegotiation advertisement meets standards of
1157 * either 10 or 10/100 or 10/100/1000 at all duplexes.
1158 * This is a function pointer entry point only called by
1159 * PHY setup routines.
1161 static s32
e1000_set_d3_lplu_state_ich8lan(struct e1000_hw
*hw
, bool active
)
1163 struct e1000_phy_info
*phy
= &hw
->phy
;
1168 phy_ctrl
= er32(PHY_CTRL
);
1171 phy_ctrl
&= ~E1000_PHY_CTRL_NOND0A_LPLU
;
1172 ew32(PHY_CTRL
, phy_ctrl
);
1174 if (phy
->type
!= e1000_phy_igp_3
)
1178 * LPLU and SmartSpeed are mutually exclusive. LPLU is used
1179 * during Dx states where the power conservation is most
1180 * important. During driver activity we should enable
1181 * SmartSpeed, so performance is maintained.
1183 if (phy
->smart_speed
== e1000_smart_speed_on
) {
1184 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1189 data
|= IGP01E1000_PSCFR_SMART_SPEED
;
1190 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1194 } else if (phy
->smart_speed
== e1000_smart_speed_off
) {
1195 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1200 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1201 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
,
1206 } else if ((phy
->autoneg_advertised
== E1000_ALL_SPEED_DUPLEX
) ||
1207 (phy
->autoneg_advertised
== E1000_ALL_NOT_GIG
) ||
1208 (phy
->autoneg_advertised
== E1000_ALL_10_SPEED
)) {
1209 phy_ctrl
|= E1000_PHY_CTRL_NOND0A_LPLU
;
1210 ew32(PHY_CTRL
, phy_ctrl
);
1212 if (phy
->type
!= e1000_phy_igp_3
)
1216 * Call gig speed drop workaround on LPLU before accessing
1219 if (hw
->mac
.type
== e1000_ich8lan
)
1220 e1000e_gig_downshift_workaround_ich8lan(hw
);
1222 /* When LPLU is enabled, we should disable SmartSpeed */
1223 ret_val
= e1e_rphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, &data
);
1227 data
&= ~IGP01E1000_PSCFR_SMART_SPEED
;
1228 ret_val
= e1e_wphy(hw
, IGP01E1000_PHY_PORT_CONFIG
, data
);
1235 * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1
1236 * @hw: pointer to the HW structure
1237 * @bank: pointer to the variable that returns the active bank
1239 * Reads signature byte from the NVM using the flash access registers.
1240 * Word 0x13 bits 15:14 = 10b indicate a valid signature for that bank.
1242 static s32
e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw
*hw
, u32
*bank
)
1245 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
1246 u32 bank1_offset
= nvm
->flash_bank_size
* sizeof(u16
);
1247 u32 act_offset
= E1000_ICH_NVM_SIG_WORD
* 2 + 1;
1251 switch (hw
->mac
.type
) {
1255 if ((eecd
& E1000_EECD_SEC1VAL_VALID_MASK
) ==
1256 E1000_EECD_SEC1VAL_VALID_MASK
) {
1257 if (eecd
& E1000_EECD_SEC1VAL
)
1264 hw_dbg(hw
, "Unable to determine valid NVM bank via EEC - "
1265 "reading flash signature\n");
1268 /* set bank to 0 in case flash read fails */
1272 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
,
1276 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
1277 E1000_ICH_NVM_SIG_VALUE
) {
1283 ret_val
= e1000_read_flash_byte_ich8lan(hw
, act_offset
+
1288 if ((sig_byte
& E1000_ICH_NVM_VALID_SIG_MASK
) ==
1289 E1000_ICH_NVM_SIG_VALUE
) {
1294 hw_dbg(hw
, "ERROR: No valid NVM bank present\n");
1295 return -E1000_ERR_NVM
;
1302 * e1000_read_nvm_ich8lan - Read word(s) from the NVM
1303 * @hw: pointer to the HW structure
1304 * @offset: The offset (in bytes) of the word(s) to read.
1305 * @words: Size of data to read in words
1306 * @data: Pointer to the word(s) to read at offset.
1308 * Reads a word(s) from the NVM using the flash access registers.
1310 static s32
e1000_read_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
1313 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
1314 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
1320 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
1322 hw_dbg(hw
, "nvm parameter(s) out of bounds\n");
1323 return -E1000_ERR_NVM
;
1326 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1330 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
1332 hw_dbg(hw
, "Could not detect valid bank, assuming bank 0\n");
1336 act_offset
= (bank
) ? nvm
->flash_bank_size
: 0;
1337 act_offset
+= offset
;
1340 for (i
= 0; i
< words
; i
++) {
1341 if ((dev_spec
->shadow_ram
) &&
1342 (dev_spec
->shadow_ram
[offset
+i
].modified
)) {
1343 data
[i
] = dev_spec
->shadow_ram
[offset
+i
].value
;
1345 ret_val
= e1000_read_flash_word_ich8lan(hw
,
1354 e1000_release_swflag_ich8lan(hw
);
1358 hw_dbg(hw
, "NVM read error: %d\n", ret_val
);
1364 * e1000_flash_cycle_init_ich8lan - Initialize flash
1365 * @hw: pointer to the HW structure
1367 * This function does initial flash setup so that a new read/write/erase cycle
1370 static s32
e1000_flash_cycle_init_ich8lan(struct e1000_hw
*hw
)
1372 union ich8_hws_flash_status hsfsts
;
1373 s32 ret_val
= -E1000_ERR_NVM
;
1376 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
1378 /* Check if the flash descriptor is valid */
1379 if (hsfsts
.hsf_status
.fldesvalid
== 0) {
1380 hw_dbg(hw
, "Flash descriptor invalid. "
1381 "SW Sequencing must be used.");
1382 return -E1000_ERR_NVM
;
1385 /* Clear FCERR and DAEL in hw status by writing 1 */
1386 hsfsts
.hsf_status
.flcerr
= 1;
1387 hsfsts
.hsf_status
.dael
= 1;
1389 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
1392 * Either we should have a hardware SPI cycle in progress
1393 * bit to check against, in order to start a new cycle or
1394 * FDONE bit should be changed in the hardware so that it
1395 * is 1 after hardware reset, which can then be used as an
1396 * indication whether a cycle is in progress or has been
1400 if (hsfsts
.hsf_status
.flcinprog
== 0) {
1402 * There is no cycle running at present,
1403 * so we can start a cycle
1404 * Begin by setting Flash Cycle Done.
1406 hsfsts
.hsf_status
.flcdone
= 1;
1407 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
1411 * otherwise poll for sometime so the current
1412 * cycle has a chance to end before giving up.
1414 for (i
= 0; i
< ICH_FLASH_READ_COMMAND_TIMEOUT
; i
++) {
1415 hsfsts
.regval
= __er16flash(hw
, ICH_FLASH_HSFSTS
);
1416 if (hsfsts
.hsf_status
.flcinprog
== 0) {
1424 * Successful in waiting for previous cycle to timeout,
1425 * now set the Flash Cycle Done.
1427 hsfsts
.hsf_status
.flcdone
= 1;
1428 ew16flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
1430 hw_dbg(hw
, "Flash controller busy, cannot get access");
1438 * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase)
1439 * @hw: pointer to the HW structure
1440 * @timeout: maximum time to wait for completion
1442 * This function starts a flash cycle and waits for its completion.
1444 static s32
e1000_flash_cycle_ich8lan(struct e1000_hw
*hw
, u32 timeout
)
1446 union ich8_hws_flash_ctrl hsflctl
;
1447 union ich8_hws_flash_status hsfsts
;
1448 s32 ret_val
= -E1000_ERR_NVM
;
1451 /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */
1452 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
1453 hsflctl
.hsf_ctrl
.flcgo
= 1;
1454 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
1456 /* wait till FDONE bit is set to 1 */
1458 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
1459 if (hsfsts
.hsf_status
.flcdone
== 1)
1462 } while (i
++ < timeout
);
1464 if (hsfsts
.hsf_status
.flcdone
== 1 && hsfsts
.hsf_status
.flcerr
== 0)
1471 * e1000_read_flash_word_ich8lan - Read word from flash
1472 * @hw: pointer to the HW structure
1473 * @offset: offset to data location
1474 * @data: pointer to the location for storing the data
1476 * Reads the flash word at offset into data. Offset is converted
1477 * to bytes before read.
1479 static s32
e1000_read_flash_word_ich8lan(struct e1000_hw
*hw
, u32 offset
,
1482 /* Must convert offset into bytes. */
1485 return e1000_read_flash_data_ich8lan(hw
, offset
, 2, data
);
1489 * e1000_read_flash_byte_ich8lan - Read byte from flash
1490 * @hw: pointer to the HW structure
1491 * @offset: The offset of the byte to read.
1492 * @data: Pointer to a byte to store the value read.
1494 * Reads a single byte from the NVM using the flash access registers.
1496 static s32
e1000_read_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
1502 ret_val
= e1000_read_flash_data_ich8lan(hw
, offset
, 1, &word
);
1512 * e1000_read_flash_data_ich8lan - Read byte or word from NVM
1513 * @hw: pointer to the HW structure
1514 * @offset: The offset (in bytes) of the byte or word to read.
1515 * @size: Size of data to read, 1=byte 2=word
1516 * @data: Pointer to the word to store the value read.
1518 * Reads a byte or word from the NVM using the flash access registers.
1520 static s32
e1000_read_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
1523 union ich8_hws_flash_status hsfsts
;
1524 union ich8_hws_flash_ctrl hsflctl
;
1525 u32 flash_linear_addr
;
1527 s32 ret_val
= -E1000_ERR_NVM
;
1530 if (size
< 1 || size
> 2 || offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
1531 return -E1000_ERR_NVM
;
1533 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
1534 hw
->nvm
.flash_base_addr
;
1539 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
1543 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
1544 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
1545 hsflctl
.hsf_ctrl
.fldbcount
= size
- 1;
1546 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_READ
;
1547 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
1549 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
1551 ret_val
= e1000_flash_cycle_ich8lan(hw
,
1552 ICH_FLASH_READ_COMMAND_TIMEOUT
);
1555 * Check if FCERR is set to 1, if set to 1, clear it
1556 * and try the whole sequence a few more times, else
1557 * read in (shift in) the Flash Data0, the order is
1558 * least significant byte first msb to lsb
1561 flash_data
= er32flash(ICH_FLASH_FDATA0
);
1563 *data
= (u8
)(flash_data
& 0x000000FF);
1564 } else if (size
== 2) {
1565 *data
= (u16
)(flash_data
& 0x0000FFFF);
1570 * If we've gotten here, then things are probably
1571 * completely hosed, but if the error condition is
1572 * detected, it won't hurt to give it another try...
1573 * ICH_FLASH_CYCLE_REPEAT_COUNT times.
1575 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
1576 if (hsfsts
.hsf_status
.flcerr
== 1) {
1577 /* Repeat for some time before giving up. */
1579 } else if (hsfsts
.hsf_status
.flcdone
== 0) {
1580 hw_dbg(hw
, "Timeout error - flash cycle "
1581 "did not complete.");
1585 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
1591 * e1000_write_nvm_ich8lan - Write word(s) to the NVM
1592 * @hw: pointer to the HW structure
1593 * @offset: The offset (in bytes) of the word(s) to write.
1594 * @words: Size of data to write in words
1595 * @data: Pointer to the word(s) to write at offset.
1597 * Writes a byte or word to the NVM using the flash access registers.
1599 static s32
e1000_write_nvm_ich8lan(struct e1000_hw
*hw
, u16 offset
, u16 words
,
1602 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
1603 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
1606 if ((offset
>= nvm
->word_size
) || (words
> nvm
->word_size
- offset
) ||
1608 hw_dbg(hw
, "nvm parameter(s) out of bounds\n");
1609 return -E1000_ERR_NVM
;
1612 for (i
= 0; i
< words
; i
++) {
1613 dev_spec
->shadow_ram
[offset
+i
].modified
= 1;
1614 dev_spec
->shadow_ram
[offset
+i
].value
= data
[i
];
1621 * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM
1622 * @hw: pointer to the HW structure
1624 * The NVM checksum is updated by calling the generic update_nvm_checksum,
1625 * which writes the checksum to the shadow ram. The changes in the shadow
1626 * ram are then committed to the EEPROM by processing each bank at a time
1627 * checking for the modified bit and writing only the pending changes.
1628 * After a successful commit, the shadow ram is cleared and is ready for
1631 static s32
e1000_update_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
1633 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
1634 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
1635 u32 i
, act_offset
, new_bank_offset
, old_bank_offset
, bank
;
1639 ret_val
= e1000e_update_nvm_checksum_generic(hw
);
1643 if (nvm
->type
!= e1000_nvm_flash_sw
)
1646 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1651 * We're writing to the opposite bank so if we're on bank 1,
1652 * write to bank 0 etc. We also need to erase the segment that
1653 * is going to be written
1655 ret_val
= e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
);
1657 hw_dbg(hw
, "Could not detect valid bank, assuming bank 0\n");
1662 new_bank_offset
= nvm
->flash_bank_size
;
1663 old_bank_offset
= 0;
1664 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 1);
1666 e1000_release_swflag_ich8lan(hw
);
1670 old_bank_offset
= nvm
->flash_bank_size
;
1671 new_bank_offset
= 0;
1672 ret_val
= e1000_erase_flash_bank_ich8lan(hw
, 0);
1674 e1000_release_swflag_ich8lan(hw
);
1679 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
1681 * Determine whether to write the value stored
1682 * in the other NVM bank or a modified value stored
1685 if (dev_spec
->shadow_ram
[i
].modified
) {
1686 data
= dev_spec
->shadow_ram
[i
].value
;
1688 ret_val
= e1000_read_flash_word_ich8lan(hw
, i
+
1696 * If the word is 0x13, then make sure the signature bits
1697 * (15:14) are 11b until the commit has completed.
1698 * This will allow us to write 10b which indicates the
1699 * signature is valid. We want to do this after the write
1700 * has completed so that we don't mark the segment valid
1701 * while the write is still in progress
1703 if (i
== E1000_ICH_NVM_SIG_WORD
)
1704 data
|= E1000_ICH_NVM_SIG_MASK
;
1706 /* Convert offset to bytes. */
1707 act_offset
= (i
+ new_bank_offset
) << 1;
1710 /* Write the bytes to the new bank. */
1711 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
1718 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
1726 * Don't bother writing the segment valid bits if sector
1727 * programming failed.
1730 /* Possibly read-only, see e1000e_write_protect_nvm_ich8lan() */
1731 hw_dbg(hw
, "Flash commit failed.\n");
1732 e1000_release_swflag_ich8lan(hw
);
1737 * Finally validate the new segment by setting bit 15:14
1738 * to 10b in word 0x13 , this can be done without an
1739 * erase as well since these bits are 11 to start with
1740 * and we need to change bit 14 to 0b
1742 act_offset
= new_bank_offset
+ E1000_ICH_NVM_SIG_WORD
;
1743 ret_val
= e1000_read_flash_word_ich8lan(hw
, act_offset
, &data
);
1745 e1000_release_swflag_ich8lan(hw
);
1749 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
,
1753 e1000_release_swflag_ich8lan(hw
);
1758 * And invalidate the previously valid segment by setting
1759 * its signature word (0x13) high_byte to 0b. This can be
1760 * done without an erase because flash erase sets all bits
1761 * to 1's. We can write 1's to 0's without an erase
1763 act_offset
= (old_bank_offset
+ E1000_ICH_NVM_SIG_WORD
) * 2 + 1;
1764 ret_val
= e1000_retry_write_flash_byte_ich8lan(hw
, act_offset
, 0);
1766 e1000_release_swflag_ich8lan(hw
);
1770 /* Great! Everything worked, we can now clear the cached entries. */
1771 for (i
= 0; i
< E1000_ICH8_SHADOW_RAM_WORDS
; i
++) {
1772 dev_spec
->shadow_ram
[i
].modified
= 0;
1773 dev_spec
->shadow_ram
[i
].value
= 0xFFFF;
1776 e1000_release_swflag_ich8lan(hw
);
1779 * Reload the EEPROM, or else modifications will not appear
1780 * until after the next adapter reset.
1782 e1000e_reload_nvm(hw
);
1787 hw_dbg(hw
, "NVM update error: %d\n", ret_val
);
1793 * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum
1794 * @hw: pointer to the HW structure
1796 * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19.
1797 * If the bit is 0, that the EEPROM had been modified, but the checksum was not
1798 * calculated, in which case we need to calculate the checksum and set bit 6.
1800 static s32
e1000_validate_nvm_checksum_ich8lan(struct e1000_hw
*hw
)
1806 * Read 0x19 and check bit 6. If this bit is 0, the checksum
1807 * needs to be fixed. This bit is an indication that the NVM
1808 * was prepared by OEM software and did not calculate the
1809 * checksum...a likely scenario.
1811 ret_val
= e1000_read_nvm(hw
, 0x19, 1, &data
);
1815 if ((data
& 0x40) == 0) {
1817 ret_val
= e1000_write_nvm(hw
, 0x19, 1, &data
);
1820 ret_val
= e1000e_update_nvm_checksum(hw
);
1825 return e1000e_validate_nvm_checksum_generic(hw
);
1829 * e1000e_write_protect_nvm_ich8lan - Make the NVM read-only
1830 * @hw: pointer to the HW structure
1832 * To prevent malicious write/erase of the NVM, set it to be read-only
1833 * so that the hardware ignores all write/erase cycles of the NVM via
1834 * the flash control registers. The shadow-ram copy of the NVM will
1835 * still be updated, however any updates to this copy will not stick
1836 * across driver reloads.
1838 void e1000e_write_protect_nvm_ich8lan(struct e1000_hw
*hw
)
1840 union ich8_flash_protected_range pr0
;
1841 union ich8_hws_flash_status hsfsts
;
1845 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
1849 gfpreg
= er32flash(ICH_FLASH_GFPREG
);
1851 /* Write-protect GbE Sector of NVM */
1852 pr0
.regval
= er32flash(ICH_FLASH_PR0
);
1853 pr0
.range
.base
= gfpreg
& FLASH_GFPREG_BASE_MASK
;
1854 pr0
.range
.limit
= ((gfpreg
>> 16) & FLASH_GFPREG_BASE_MASK
);
1855 pr0
.range
.wpe
= true;
1856 ew32flash(ICH_FLASH_PR0
, pr0
.regval
);
1859 * Lock down a subset of GbE Flash Control Registers, e.g.
1860 * PR0 to prevent the write-protection from being lifted.
1861 * Once FLOCKDN is set, the registers protected by it cannot
1862 * be written until FLOCKDN is cleared by a hardware reset.
1864 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
1865 hsfsts
.hsf_status
.flockdn
= true;
1866 ew32flash(ICH_FLASH_HSFSTS
, hsfsts
.regval
);
1868 e1000_release_swflag_ich8lan(hw
);
1872 * e1000_write_flash_data_ich8lan - Writes bytes to the NVM
1873 * @hw: pointer to the HW structure
1874 * @offset: The offset (in bytes) of the byte/word to read.
1875 * @size: Size of data to read, 1=byte 2=word
1876 * @data: The byte(s) to write to the NVM.
1878 * Writes one/two bytes to the NVM using the flash access registers.
1880 static s32
e1000_write_flash_data_ich8lan(struct e1000_hw
*hw
, u32 offset
,
1883 union ich8_hws_flash_status hsfsts
;
1884 union ich8_hws_flash_ctrl hsflctl
;
1885 u32 flash_linear_addr
;
1890 if (size
< 1 || size
> 2 || data
> size
* 0xff ||
1891 offset
> ICH_FLASH_LINEAR_ADDR_MASK
)
1892 return -E1000_ERR_NVM
;
1894 flash_linear_addr
= (ICH_FLASH_LINEAR_ADDR_MASK
& offset
) +
1895 hw
->nvm
.flash_base_addr
;
1900 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
1904 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
1905 /* 0b/1b corresponds to 1 or 2 byte size, respectively. */
1906 hsflctl
.hsf_ctrl
.fldbcount
= size
-1;
1907 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_WRITE
;
1908 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
1910 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
1913 flash_data
= (u32
)data
& 0x00FF;
1915 flash_data
= (u32
)data
;
1917 ew32flash(ICH_FLASH_FDATA0
, flash_data
);
1920 * check if FCERR is set to 1 , if set to 1, clear it
1921 * and try the whole sequence a few more times else done
1923 ret_val
= e1000_flash_cycle_ich8lan(hw
,
1924 ICH_FLASH_WRITE_COMMAND_TIMEOUT
);
1929 * If we're here, then things are most likely
1930 * completely hosed, but if the error condition
1931 * is detected, it won't hurt to give it another
1932 * try...ICH_FLASH_CYCLE_REPEAT_COUNT times.
1934 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
1935 if (hsfsts
.hsf_status
.flcerr
== 1)
1936 /* Repeat for some time before giving up. */
1938 if (hsfsts
.hsf_status
.flcdone
== 0) {
1939 hw_dbg(hw
, "Timeout error - flash cycle "
1940 "did not complete.");
1943 } while (count
++ < ICH_FLASH_CYCLE_REPEAT_COUNT
);
1949 * e1000_write_flash_byte_ich8lan - Write a single byte to NVM
1950 * @hw: pointer to the HW structure
1951 * @offset: The index of the byte to read.
1952 * @data: The byte to write to the NVM.
1954 * Writes a single byte to the NVM using the flash access registers.
1956 static s32
e1000_write_flash_byte_ich8lan(struct e1000_hw
*hw
, u32 offset
,
1959 u16 word
= (u16
)data
;
1961 return e1000_write_flash_data_ich8lan(hw
, offset
, 1, word
);
1965 * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM
1966 * @hw: pointer to the HW structure
1967 * @offset: The offset of the byte to write.
1968 * @byte: The byte to write to the NVM.
1970 * Writes a single byte to the NVM using the flash access registers.
1971 * Goes through a retry algorithm before giving up.
1973 static s32
e1000_retry_write_flash_byte_ich8lan(struct e1000_hw
*hw
,
1974 u32 offset
, u8 byte
)
1977 u16 program_retries
;
1979 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
1983 for (program_retries
= 0; program_retries
< 100; program_retries
++) {
1984 hw_dbg(hw
, "Retrying Byte %2.2X at offset %u\n", byte
, offset
);
1986 ret_val
= e1000_write_flash_byte_ich8lan(hw
, offset
, byte
);
1990 if (program_retries
== 100)
1991 return -E1000_ERR_NVM
;
1997 * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM
1998 * @hw: pointer to the HW structure
1999 * @bank: 0 for first bank, 1 for second bank, etc.
2001 * Erases the bank specified. Each bank is a 4k block. Banks are 0 based.
2002 * bank N is 4096 * N + flash_reg_addr.
2004 static s32
e1000_erase_flash_bank_ich8lan(struct e1000_hw
*hw
, u32 bank
)
2006 struct e1000_nvm_info
*nvm
= &hw
->nvm
;
2007 union ich8_hws_flash_status hsfsts
;
2008 union ich8_hws_flash_ctrl hsflctl
;
2009 u32 flash_linear_addr
;
2010 /* bank size is in 16bit words - adjust to bytes */
2011 u32 flash_bank_size
= nvm
->flash_bank_size
* 2;
2018 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2021 * Determine HW Sector size: Read BERASE bits of hw flash status
2023 * 00: The Hw sector is 256 bytes, hence we need to erase 16
2024 * consecutive sectors. The start index for the nth Hw sector
2025 * can be calculated as = bank * 4096 + n * 256
2026 * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector.
2027 * The start index for the nth Hw sector can be calculated
2029 * 10: The Hw sector is 8K bytes, nth sector = bank * 8192
2030 * (ich9 only, otherwise error condition)
2031 * 11: The Hw sector is 64K bytes, nth sector = bank * 65536
2033 switch (hsfsts
.hsf_status
.berasesz
) {
2035 /* Hw sector size 256 */
2036 sector_size
= ICH_FLASH_SEG_SIZE_256
;
2037 iteration
= flash_bank_size
/ ICH_FLASH_SEG_SIZE_256
;
2040 sector_size
= ICH_FLASH_SEG_SIZE_4K
;
2044 sector_size
= ICH_FLASH_SEG_SIZE_8K
;
2048 sector_size
= ICH_FLASH_SEG_SIZE_64K
;
2052 return -E1000_ERR_NVM
;
2055 /* Start with the base address, then add the sector offset. */
2056 flash_linear_addr
= hw
->nvm
.flash_base_addr
;
2057 flash_linear_addr
+= (bank
) ? flash_bank_size
: 0;
2059 for (j
= 0; j
< iteration
; j
++) {
2062 ret_val
= e1000_flash_cycle_init_ich8lan(hw
);
2067 * Write a value 11 (block Erase) in Flash
2068 * Cycle field in hw flash control
2070 hsflctl
.regval
= er16flash(ICH_FLASH_HSFCTL
);
2071 hsflctl
.hsf_ctrl
.flcycle
= ICH_CYCLE_ERASE
;
2072 ew16flash(ICH_FLASH_HSFCTL
, hsflctl
.regval
);
2075 * Write the last 24 bits of an index within the
2076 * block into Flash Linear address field in Flash
2079 flash_linear_addr
+= (j
* sector_size
);
2080 ew32flash(ICH_FLASH_FADDR
, flash_linear_addr
);
2082 ret_val
= e1000_flash_cycle_ich8lan(hw
,
2083 ICH_FLASH_ERASE_COMMAND_TIMEOUT
);
2088 * Check if FCERR is set to 1. If 1,
2089 * clear it and try the whole sequence
2090 * a few more times else Done
2092 hsfsts
.regval
= er16flash(ICH_FLASH_HSFSTS
);
2093 if (hsfsts
.hsf_status
.flcerr
== 1)
2094 /* repeat for some time before giving up */
2096 else if (hsfsts
.hsf_status
.flcdone
== 0)
2098 } while (++count
< ICH_FLASH_CYCLE_REPEAT_COUNT
);
2105 * e1000_valid_led_default_ich8lan - Set the default LED settings
2106 * @hw: pointer to the HW structure
2107 * @data: Pointer to the LED settings
2109 * Reads the LED default settings from the NVM to data. If the NVM LED
2110 * settings is all 0's or F's, set the LED default to a valid LED default
2113 static s32
e1000_valid_led_default_ich8lan(struct e1000_hw
*hw
, u16
*data
)
2117 ret_val
= e1000_read_nvm(hw
, NVM_ID_LED_SETTINGS
, 1, data
);
2119 hw_dbg(hw
, "NVM Read Error\n");
2123 if (*data
== ID_LED_RESERVED_0000
||
2124 *data
== ID_LED_RESERVED_FFFF
)
2125 *data
= ID_LED_DEFAULT_ICH8LAN
;
2131 * e1000_id_led_init_pchlan - store LED configurations
2132 * @hw: pointer to the HW structure
2134 * PCH does not control LEDs via the LEDCTL register, rather it uses
2135 * the PHY LED configuration register.
2137 * PCH also does not have an "always on" or "always off" mode which
2138 * complicates the ID feature. Instead of using the "on" mode to indicate
2139 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
2140 * use "link_up" mode. The LEDs will still ID on request if there is no
2141 * link based on logic in e1000_led_[on|off]_pchlan().
2143 static s32
e1000_id_led_init_pchlan(struct e1000_hw
*hw
)
2145 struct e1000_mac_info
*mac
= &hw
->mac
;
2147 const u32 ledctl_on
= E1000_LEDCTL_MODE_LINK_UP
;
2148 const u32 ledctl_off
= E1000_LEDCTL_MODE_LINK_UP
| E1000_PHY_LED0_IVRT
;
2149 u16 data
, i
, temp
, shift
;
2151 /* Get default ID LED modes */
2152 ret_val
= hw
->nvm
.ops
.valid_led_default(hw
, &data
);
2156 mac
->ledctl_default
= er32(LEDCTL
);
2157 mac
->ledctl_mode1
= mac
->ledctl_default
;
2158 mac
->ledctl_mode2
= mac
->ledctl_default
;
2160 for (i
= 0; i
< 4; i
++) {
2161 temp
= (data
>> (i
<< 2)) & E1000_LEDCTL_LED0_MODE_MASK
;
2164 case ID_LED_ON1_DEF2
:
2165 case ID_LED_ON1_ON2
:
2166 case ID_LED_ON1_OFF2
:
2167 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
2168 mac
->ledctl_mode1
|= (ledctl_on
<< shift
);
2170 case ID_LED_OFF1_DEF2
:
2171 case ID_LED_OFF1_ON2
:
2172 case ID_LED_OFF1_OFF2
:
2173 mac
->ledctl_mode1
&= ~(E1000_PHY_LED0_MASK
<< shift
);
2174 mac
->ledctl_mode1
|= (ledctl_off
<< shift
);
2181 case ID_LED_DEF1_ON2
:
2182 case ID_LED_ON1_ON2
:
2183 case ID_LED_OFF1_ON2
:
2184 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
2185 mac
->ledctl_mode2
|= (ledctl_on
<< shift
);
2187 case ID_LED_DEF1_OFF2
:
2188 case ID_LED_ON1_OFF2
:
2189 case ID_LED_OFF1_OFF2
:
2190 mac
->ledctl_mode2
&= ~(E1000_PHY_LED0_MASK
<< shift
);
2191 mac
->ledctl_mode2
|= (ledctl_off
<< shift
);
2204 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
2205 * @hw: pointer to the HW structure
2207 * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability
2208 * register, so the the bus width is hard coded.
2210 static s32
e1000_get_bus_info_ich8lan(struct e1000_hw
*hw
)
2212 struct e1000_bus_info
*bus
= &hw
->bus
;
2215 ret_val
= e1000e_get_bus_info_pcie(hw
);
2218 * ICH devices are "PCI Express"-ish. They have
2219 * a configuration space, but do not contain
2220 * PCI Express Capability registers, so bus width
2221 * must be hardcoded.
2223 if (bus
->width
== e1000_bus_width_unknown
)
2224 bus
->width
= e1000_bus_width_pcie_x1
;
2230 * e1000_reset_hw_ich8lan - Reset the hardware
2231 * @hw: pointer to the HW structure
2233 * Does a full reset of the hardware which includes a reset of the PHY and
2236 static s32
e1000_reset_hw_ich8lan(struct e1000_hw
*hw
)
2243 * Prevent the PCI-E bus from sticking if there is no TLP connection
2244 * on the last TLP read/write transaction when MAC is reset.
2246 ret_val
= e1000e_disable_pcie_master(hw
);
2248 hw_dbg(hw
, "PCI-E Master disable polling has failed.\n");
2251 hw_dbg(hw
, "Masking off all interrupts\n");
2252 ew32(IMC
, 0xffffffff);
2255 * Disable the Transmit and Receive units. Then delay to allow
2256 * any pending transactions to complete before we hit the MAC
2257 * with the global reset.
2260 ew32(TCTL
, E1000_TCTL_PSP
);
2265 /* Workaround for ICH8 bit corruption issue in FIFO memory */
2266 if (hw
->mac
.type
== e1000_ich8lan
) {
2267 /* Set Tx and Rx buffer allocation to 8k apiece. */
2268 ew32(PBA
, E1000_PBA_8K
);
2269 /* Set Packet Buffer Size to 16k. */
2270 ew32(PBS
, E1000_PBS_16K
);
2275 if (!e1000_check_reset_block(hw
)) {
2276 /* Clear PHY Reset Asserted bit */
2277 if (hw
->mac
.type
>= e1000_pchlan
) {
2278 u32 status
= er32(STATUS
);
2279 ew32(STATUS
, status
& ~E1000_STATUS_PHYRA
);
2283 * PHY HW reset requires MAC CORE reset at the same
2284 * time to make sure the interface between MAC and the
2285 * external PHY is reset.
2287 ctrl
|= E1000_CTRL_PHY_RST
;
2289 ret_val
= e1000_acquire_swflag_ich8lan(hw
);
2290 /* Whether or not the swflag was acquired, we need to reset the part */
2291 hw_dbg(hw
, "Issuing a global reset to ich8lan\n");
2292 ew32(CTRL
, (ctrl
| E1000_CTRL_RST
));
2296 e1000_release_swflag_ich8lan(hw
);
2298 if (ctrl
& E1000_CTRL_PHY_RST
)
2299 ret_val
= hw
->phy
.ops
.get_cfg_done(hw
);
2301 if (hw
->mac
.type
>= e1000_ich10lan
) {
2302 e1000_lan_init_done_ich8lan(hw
);
2304 ret_val
= e1000e_get_auto_rd_done(hw
);
2307 * When auto config read does not complete, do not
2308 * return with an error. This can happen in situations
2309 * where there is no eeprom and prevents getting link.
2311 hw_dbg(hw
, "Auto Read Done did not complete\n");
2314 /* Dummy read to clear the phy wakeup bit after lcd reset */
2315 if (hw
->mac
.type
== e1000_pchlan
)
2316 e1e_rphy(hw
, BM_WUC
, ®
);
2319 * For PCH, this write will make sure that any noise
2320 * will be detected as a CRC error and be dropped rather than show up
2321 * as a bad packet to the DMA engine.
2323 if (hw
->mac
.type
== e1000_pchlan
)
2324 ew32(CRC_OFFSET
, 0x65656565);
2326 ew32(IMC
, 0xffffffff);
2329 kab
= er32(KABGTXD
);
2330 kab
|= E1000_KABGTXD_BGSQLBIAS
;
2333 if (hw
->mac
.type
== e1000_pchlan
)
2334 ret_val
= e1000_hv_phy_workarounds_ich8lan(hw
);
2340 * e1000_init_hw_ich8lan - Initialize the hardware
2341 * @hw: pointer to the HW structure
2343 * Prepares the hardware for transmit and receive by doing the following:
2344 * - initialize hardware bits
2345 * - initialize LED identification
2346 * - setup receive address registers
2347 * - setup flow control
2348 * - setup transmit descriptors
2349 * - clear statistics
2351 static s32
e1000_init_hw_ich8lan(struct e1000_hw
*hw
)
2353 struct e1000_mac_info
*mac
= &hw
->mac
;
2354 u32 ctrl_ext
, txdctl
, snoop
;
2358 e1000_initialize_hw_bits_ich8lan(hw
);
2360 /* Initialize identification LED */
2361 ret_val
= mac
->ops
.id_led_init(hw
);
2363 hw_dbg(hw
, "Error initializing identification LED\n");
2367 /* Setup the receive address. */
2368 e1000e_init_rx_addrs(hw
, mac
->rar_entry_count
);
2370 /* Zero out the Multicast HASH table */
2371 hw_dbg(hw
, "Zeroing the MTA\n");
2372 for (i
= 0; i
< mac
->mta_reg_count
; i
++)
2373 E1000_WRITE_REG_ARRAY(hw
, E1000_MTA
, i
, 0);
2376 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2377 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2378 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2380 if (hw
->phy
.type
== e1000_phy_82578
) {
2381 hw
->phy
.ops
.read_phy_reg(hw
, BM_WUC
, &i
);
2382 ret_val
= e1000_phy_hw_reset_ich8lan(hw
);
2387 /* Setup link and flow control */
2388 ret_val
= e1000_setup_link_ich8lan(hw
);
2390 /* Set the transmit descriptor write-back policy for both queues */
2391 txdctl
= er32(TXDCTL(0));
2392 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
2393 E1000_TXDCTL_FULL_TX_DESC_WB
;
2394 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
2395 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
2396 ew32(TXDCTL(0), txdctl
);
2397 txdctl
= er32(TXDCTL(1));
2398 txdctl
= (txdctl
& ~E1000_TXDCTL_WTHRESH
) |
2399 E1000_TXDCTL_FULL_TX_DESC_WB
;
2400 txdctl
= (txdctl
& ~E1000_TXDCTL_PTHRESH
) |
2401 E1000_TXDCTL_MAX_TX_DESC_PREFETCH
;
2402 ew32(TXDCTL(1), txdctl
);
2405 * ICH8 has opposite polarity of no_snoop bits.
2406 * By default, we should use snoop behavior.
2408 if (mac
->type
== e1000_ich8lan
)
2409 snoop
= PCIE_ICH8_SNOOP_ALL
;
2411 snoop
= (u32
) ~(PCIE_NO_SNOOP_ALL
);
2412 e1000e_set_pcie_no_snoop(hw
, snoop
);
2414 ctrl_ext
= er32(CTRL_EXT
);
2415 ctrl_ext
|= E1000_CTRL_EXT_RO_DIS
;
2416 ew32(CTRL_EXT
, ctrl_ext
);
2419 * Clear all of the statistics registers (clear on read). It is
2420 * important that we do this after we have tried to establish link
2421 * because the symbol error count will increment wildly if there
2424 e1000_clear_hw_cntrs_ich8lan(hw
);
2429 * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits
2430 * @hw: pointer to the HW structure
2432 * Sets/Clears required hardware bits necessary for correctly setting up the
2433 * hardware for transmit and receive.
2435 static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw
*hw
)
2439 /* Extended Device Control */
2440 reg
= er32(CTRL_EXT
);
2442 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
2443 if (hw
->mac
.type
>= e1000_pchlan
)
2444 reg
|= E1000_CTRL_EXT_PHYPDEN
;
2445 ew32(CTRL_EXT
, reg
);
2447 /* Transmit Descriptor Control 0 */
2448 reg
= er32(TXDCTL(0));
2450 ew32(TXDCTL(0), reg
);
2452 /* Transmit Descriptor Control 1 */
2453 reg
= er32(TXDCTL(1));
2455 ew32(TXDCTL(1), reg
);
2457 /* Transmit Arbitration Control 0 */
2458 reg
= er32(TARC(0));
2459 if (hw
->mac
.type
== e1000_ich8lan
)
2460 reg
|= (1 << 28) | (1 << 29);
2461 reg
|= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27);
2464 /* Transmit Arbitration Control 1 */
2465 reg
= er32(TARC(1));
2466 if (er32(TCTL
) & E1000_TCTL_MULR
)
2470 reg
|= (1 << 24) | (1 << 26) | (1 << 30);
2474 if (hw
->mac
.type
== e1000_ich8lan
) {
2482 * e1000_setup_link_ich8lan - Setup flow control and link settings
2483 * @hw: pointer to the HW structure
2485 * Determines which flow control settings to use, then configures flow
2486 * control. Calls the appropriate media-specific link configuration
2487 * function. Assuming the adapter has a valid link partner, a valid link
2488 * should be established. Assumes the hardware has previously been reset
2489 * and the transmitter and receiver are not enabled.
2491 static s32
e1000_setup_link_ich8lan(struct e1000_hw
*hw
)
2495 if (e1000_check_reset_block(hw
))
2499 * ICH parts do not have a word in the NVM to determine
2500 * the default flow control setting, so we explicitly
2503 if (hw
->fc
.requested_mode
== e1000_fc_default
) {
2504 /* Workaround h/w hang when Tx flow control enabled */
2505 if (hw
->mac
.type
== e1000_pchlan
)
2506 hw
->fc
.requested_mode
= e1000_fc_rx_pause
;
2508 hw
->fc
.requested_mode
= e1000_fc_full
;
2512 * Save off the requested flow control mode for use later. Depending
2513 * on the link partner's capabilities, we may or may not use this mode.
2515 hw
->fc
.current_mode
= hw
->fc
.requested_mode
;
2517 hw_dbg(hw
, "After fix-ups FlowControl is now = %x\n",
2518 hw
->fc
.current_mode
);
2520 /* Continue to configure the copper link. */
2521 ret_val
= e1000_setup_copper_link_ich8lan(hw
);
2525 ew32(FCTTV
, hw
->fc
.pause_time
);
2526 if ((hw
->phy
.type
== e1000_phy_82578
) ||
2527 (hw
->phy
.type
== e1000_phy_82577
)) {
2528 ret_val
= hw
->phy
.ops
.write_phy_reg(hw
,
2529 PHY_REG(BM_PORT_CTRL_PAGE
, 27),
2535 return e1000e_set_fc_watermarks(hw
);
2539 * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface
2540 * @hw: pointer to the HW structure
2542 * Configures the kumeran interface to the PHY to wait the appropriate time
2543 * when polling the PHY, then call the generic setup_copper_link to finish
2544 * configuring the copper link.
2546 static s32
e1000_setup_copper_link_ich8lan(struct e1000_hw
*hw
)
2553 ctrl
|= E1000_CTRL_SLU
;
2554 ctrl
&= ~(E1000_CTRL_FRCSPD
| E1000_CTRL_FRCDPX
);
2558 * Set the mac to wait the maximum time between each iteration
2559 * and increase the max iterations when polling the phy;
2560 * this fixes erroneous timeouts at 10Mbps.
2562 ret_val
= e1000e_write_kmrn_reg(hw
, GG82563_REG(0x34, 4), 0xFFFF);
2565 ret_val
= e1000e_read_kmrn_reg(hw
, GG82563_REG(0x34, 9), ®_data
);
2569 ret_val
= e1000e_write_kmrn_reg(hw
, GG82563_REG(0x34, 9), reg_data
);
2573 switch (hw
->phy
.type
) {
2574 case e1000_phy_igp_3
:
2575 ret_val
= e1000e_copper_link_setup_igp(hw
);
2580 case e1000_phy_82578
:
2581 ret_val
= e1000e_copper_link_setup_m88(hw
);
2585 case e1000_phy_82577
:
2586 ret_val
= e1000_copper_link_setup_82577(hw
);
2591 ret_val
= hw
->phy
.ops
.read_phy_reg(hw
, IFE_PHY_MDIX_CONTROL
,
2596 reg_data
&= ~IFE_PMC_AUTO_MDIX
;
2598 switch (hw
->phy
.mdix
) {
2600 reg_data
&= ~IFE_PMC_FORCE_MDIX
;
2603 reg_data
|= IFE_PMC_FORCE_MDIX
;
2607 reg_data
|= IFE_PMC_AUTO_MDIX
;
2610 ret_val
= hw
->phy
.ops
.write_phy_reg(hw
, IFE_PHY_MDIX_CONTROL
,
2618 return e1000e_setup_copper_link(hw
);
2622 * e1000_get_link_up_info_ich8lan - Get current link speed and duplex
2623 * @hw: pointer to the HW structure
2624 * @speed: pointer to store current link speed
2625 * @duplex: pointer to store the current link duplex
2627 * Calls the generic get_speed_and_duplex to retrieve the current link
2628 * information and then calls the Kumeran lock loss workaround for links at
2631 static s32
e1000_get_link_up_info_ich8lan(struct e1000_hw
*hw
, u16
*speed
,
2636 ret_val
= e1000e_get_speed_and_duplex_copper(hw
, speed
, duplex
);
2640 if ((hw
->mac
.type
== e1000_pchlan
) && (*speed
== SPEED_1000
)) {
2641 ret_val
= e1000e_write_kmrn_reg(hw
,
2642 E1000_KMRNCTRLSTA_K1_CONFIG
,
2643 E1000_KMRNCTRLSTA_K1_DISABLE
);
2648 if ((hw
->mac
.type
== e1000_ich8lan
) &&
2649 (hw
->phy
.type
== e1000_phy_igp_3
) &&
2650 (*speed
== SPEED_1000
)) {
2651 ret_val
= e1000_kmrn_lock_loss_workaround_ich8lan(hw
);
2658 * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround
2659 * @hw: pointer to the HW structure
2661 * Work-around for 82566 Kumeran PCS lock loss:
2662 * On link status change (i.e. PCI reset, speed change) and link is up and
2664 * 0) if workaround is optionally disabled do nothing
2665 * 1) wait 1ms for Kumeran link to come up
2666 * 2) check Kumeran Diagnostic register PCS lock loss bit
2667 * 3) if not set the link is locked (all is good), otherwise...
2669 * 5) repeat up to 10 times
2670 * Note: this is only called for IGP3 copper when speed is 1gb.
2672 static s32
e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
)
2674 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2680 if (!dev_spec
->kmrn_lock_loss_workaround_enabled
)
2684 * Make sure link is up before proceeding. If not just return.
2685 * Attempting this while link is negotiating fouled up link
2688 ret_val
= e1000e_phy_has_link_generic(hw
, 1, 0, &link
);
2692 for (i
= 0; i
< 10; i
++) {
2693 /* read once to clear */
2694 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
2697 /* and again to get new status */
2698 ret_val
= e1e_rphy(hw
, IGP3_KMRN_DIAG
, &data
);
2702 /* check for PCS lock */
2703 if (!(data
& IGP3_KMRN_DIAG_PCS_LOCK_LOSS
))
2706 /* Issue PHY reset */
2707 e1000_phy_hw_reset(hw
);
2710 /* Disable GigE link negotiation */
2711 phy_ctrl
= er32(PHY_CTRL
);
2712 phy_ctrl
|= (E1000_PHY_CTRL_GBE_DISABLE
|
2713 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
2714 ew32(PHY_CTRL
, phy_ctrl
);
2717 * Call gig speed drop workaround on Gig disable before accessing
2720 e1000e_gig_downshift_workaround_ich8lan(hw
);
2722 /* unable to acquire PCS lock */
2723 return -E1000_ERR_PHY
;
2727 * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state
2728 * @hw: pointer to the HW structure
2729 * @state: boolean value used to set the current Kumeran workaround state
2731 * If ICH8, set the current Kumeran workaround state (enabled - TRUE
2732 * /disabled - FALSE).
2734 void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw
*hw
,
2737 struct e1000_dev_spec_ich8lan
*dev_spec
= &hw
->dev_spec
.ich8lan
;
2739 if (hw
->mac
.type
!= e1000_ich8lan
) {
2740 hw_dbg(hw
, "Workaround applies to ICH8 only.\n");
2744 dev_spec
->kmrn_lock_loss_workaround_enabled
= state
;
2748 * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3
2749 * @hw: pointer to the HW structure
2751 * Workaround for 82566 power-down on D3 entry:
2752 * 1) disable gigabit link
2753 * 2) write VR power-down enable
2755 * Continue if successful, else issue LCD reset and repeat
2757 void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw
*hw
)
2763 if (hw
->phy
.type
!= e1000_phy_igp_3
)
2766 /* Try the workaround twice (if needed) */
2769 reg
= er32(PHY_CTRL
);
2770 reg
|= (E1000_PHY_CTRL_GBE_DISABLE
|
2771 E1000_PHY_CTRL_NOND0A_GBE_DISABLE
);
2772 ew32(PHY_CTRL
, reg
);
2775 * Call gig speed drop workaround on Gig disable before
2776 * accessing any PHY registers
2778 if (hw
->mac
.type
== e1000_ich8lan
)
2779 e1000e_gig_downshift_workaround_ich8lan(hw
);
2781 /* Write VR power-down enable */
2782 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
2783 data
&= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
2784 e1e_wphy(hw
, IGP3_VR_CTRL
, data
| IGP3_VR_CTRL_MODE_SHUTDOWN
);
2786 /* Read it back and test */
2787 e1e_rphy(hw
, IGP3_VR_CTRL
, &data
);
2788 data
&= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK
;
2789 if ((data
== IGP3_VR_CTRL_MODE_SHUTDOWN
) || retry
)
2792 /* Issue PHY reset and repeat at most one more time */
2794 ew32(CTRL
, reg
| E1000_CTRL_PHY_RST
);
2800 * e1000e_gig_downshift_workaround_ich8lan - WoL from S5 stops working
2801 * @hw: pointer to the HW structure
2803 * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC),
2804 * LPLU, Gig disable, MDIC PHY reset):
2805 * 1) Set Kumeran Near-end loopback
2806 * 2) Clear Kumeran Near-end loopback
2807 * Should only be called for ICH8[m] devices with IGP_3 Phy.
2809 void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw
*hw
)
2814 if ((hw
->mac
.type
!= e1000_ich8lan
) ||
2815 (hw
->phy
.type
!= e1000_phy_igp_3
))
2818 ret_val
= e1000e_read_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
2822 reg_data
|= E1000_KMRNCTRLSTA_DIAG_NELPBK
;
2823 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
2827 reg_data
&= ~E1000_KMRNCTRLSTA_DIAG_NELPBK
;
2828 ret_val
= e1000e_write_kmrn_reg(hw
, E1000_KMRNCTRLSTA_DIAG_OFFSET
,
2833 * e1000e_disable_gig_wol_ich8lan - disable gig during WoL
2834 * @hw: pointer to the HW structure
2836 * During S0 to Sx transition, it is possible the link remains at gig
2837 * instead of negotiating to a lower speed. Before going to Sx, set
2838 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
2841 * Should only be called for applicable parts.
2843 void e1000e_disable_gig_wol_ich8lan(struct e1000_hw
*hw
)
2847 switch (hw
->mac
.type
) {
2849 case e1000_ich10lan
:
2851 phy_ctrl
= er32(PHY_CTRL
);
2852 phy_ctrl
|= E1000_PHY_CTRL_D0A_LPLU
|
2853 E1000_PHY_CTRL_GBE_DISABLE
;
2854 ew32(PHY_CTRL
, phy_ctrl
);
2856 if (hw
->mac
.type
== e1000_pchlan
)
2857 e1000_phy_hw_reset_ich8lan(hw
);
2866 * e1000_cleanup_led_ich8lan - Restore the default LED operation
2867 * @hw: pointer to the HW structure
2869 * Return the LED back to the default configuration.
2871 static s32
e1000_cleanup_led_ich8lan(struct e1000_hw
*hw
)
2873 if (hw
->phy
.type
== e1000_phy_ife
)
2874 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
, 0);
2876 ew32(LEDCTL
, hw
->mac
.ledctl_default
);
2881 * e1000_led_on_ich8lan - Turn LEDs on
2882 * @hw: pointer to the HW structure
2886 static s32
e1000_led_on_ich8lan(struct e1000_hw
*hw
)
2888 if (hw
->phy
.type
== e1000_phy_ife
)
2889 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
2890 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_ON
));
2892 ew32(LEDCTL
, hw
->mac
.ledctl_mode2
);
2897 * e1000_led_off_ich8lan - Turn LEDs off
2898 * @hw: pointer to the HW structure
2900 * Turn off the LEDs.
2902 static s32
e1000_led_off_ich8lan(struct e1000_hw
*hw
)
2904 if (hw
->phy
.type
== e1000_phy_ife
)
2905 return e1e_wphy(hw
, IFE_PHY_SPECIAL_CONTROL_LED
,
2906 (IFE_PSCL_PROBE_MODE
| IFE_PSCL_PROBE_LEDS_OFF
));
2908 ew32(LEDCTL
, hw
->mac
.ledctl_mode1
);
2913 * e1000_setup_led_pchlan - Configures SW controllable LED
2914 * @hw: pointer to the HW structure
2916 * This prepares the SW controllable LED for use.
2918 static s32
e1000_setup_led_pchlan(struct e1000_hw
*hw
)
2920 return hw
->phy
.ops
.write_phy_reg(hw
, HV_LED_CONFIG
,
2921 (u16
)hw
->mac
.ledctl_mode1
);
2925 * e1000_cleanup_led_pchlan - Restore the default LED operation
2926 * @hw: pointer to the HW structure
2928 * Return the LED back to the default configuration.
2930 static s32
e1000_cleanup_led_pchlan(struct e1000_hw
*hw
)
2932 return hw
->phy
.ops
.write_phy_reg(hw
, HV_LED_CONFIG
,
2933 (u16
)hw
->mac
.ledctl_default
);
2937 * e1000_led_on_pchlan - Turn LEDs on
2938 * @hw: pointer to the HW structure
2942 static s32
e1000_led_on_pchlan(struct e1000_hw
*hw
)
2944 u16 data
= (u16
)hw
->mac
.ledctl_mode2
;
2948 * If no link, then turn LED on by setting the invert bit
2949 * for each LED that's mode is "link_up" in ledctl_mode2.
2951 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
2952 for (i
= 0; i
< 3; i
++) {
2953 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
2954 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
2955 E1000_LEDCTL_MODE_LINK_UP
)
2957 if (led
& E1000_PHY_LED0_IVRT
)
2958 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
2960 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
2964 return hw
->phy
.ops
.write_phy_reg(hw
, HV_LED_CONFIG
, data
);
2968 * e1000_led_off_pchlan - Turn LEDs off
2969 * @hw: pointer to the HW structure
2971 * Turn off the LEDs.
2973 static s32
e1000_led_off_pchlan(struct e1000_hw
*hw
)
2975 u16 data
= (u16
)hw
->mac
.ledctl_mode1
;
2979 * If no link, then turn LED off by clearing the invert bit
2980 * for each LED that's mode is "link_up" in ledctl_mode1.
2982 if (!(er32(STATUS
) & E1000_STATUS_LU
)) {
2983 for (i
= 0; i
< 3; i
++) {
2984 led
= (data
>> (i
* 5)) & E1000_PHY_LED0_MASK
;
2985 if ((led
& E1000_PHY_LED0_MODE_MASK
) !=
2986 E1000_LEDCTL_MODE_LINK_UP
)
2988 if (led
& E1000_PHY_LED0_IVRT
)
2989 data
&= ~(E1000_PHY_LED0_IVRT
<< (i
* 5));
2991 data
|= (E1000_PHY_LED0_IVRT
<< (i
* 5));
2995 return hw
->phy
.ops
.write_phy_reg(hw
, HV_LED_CONFIG
, data
);
2999 * e1000_get_cfg_done_ich8lan - Read config done bit
3000 * @hw: pointer to the HW structure
3002 * Read the management control register for the config done bit for
3003 * completion status. NOTE: silicon which is EEPROM-less will fail trying
3004 * to read the config done bit, so an error is *ONLY* logged and returns
3005 * 0. If we were to return with error, EEPROM-less silicon
3006 * would not be able to be reset or change link.
3008 static s32
e1000_get_cfg_done_ich8lan(struct e1000_hw
*hw
)
3012 if (hw
->mac
.type
>= e1000_pchlan
) {
3013 u32 status
= er32(STATUS
);
3015 if (status
& E1000_STATUS_PHYRA
)
3016 ew32(STATUS
, status
& ~E1000_STATUS_PHYRA
);
3019 "PHY Reset Asserted not set - needs delay\n");
3022 e1000e_get_cfg_done(hw
);
3024 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
3025 if ((hw
->mac
.type
!= e1000_ich10lan
) &&
3026 (hw
->mac
.type
!= e1000_pchlan
)) {
3027 if (((er32(EECD
) & E1000_EECD_PRES
) == 0) &&
3028 (hw
->phy
.type
== e1000_phy_igp_3
)) {
3029 e1000e_phy_init_script_igp3(hw
);
3032 if (e1000_valid_nvm_bank_detect_ich8lan(hw
, &bank
)) {
3033 /* Maybe we should do a basic PHY config */
3034 hw_dbg(hw
, "EEPROM not present\n");
3035 return -E1000_ERR_CONFIG
;
3043 * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters
3044 * @hw: pointer to the HW structure
3046 * Clears hardware counters specific to the silicon family and calls
3047 * clear_hw_cntrs_generic to clear all general purpose counters.
3049 static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw
*hw
)
3054 e1000e_clear_hw_cntrs_base(hw
);
3056 temp
= er32(ALGNERRC
);
3057 temp
= er32(RXERRC
);
3059 temp
= er32(CEXTERR
);
3061 temp
= er32(TSCTFC
);
3063 temp
= er32(MGTPRC
);
3064 temp
= er32(MGTPDC
);
3065 temp
= er32(MGTPTC
);
3068 temp
= er32(ICRXOC
);
3070 /* Clear PHY statistics registers */
3071 if ((hw
->phy
.type
== e1000_phy_82578
) ||
3072 (hw
->phy
.type
== e1000_phy_82577
)) {
3073 hw
->phy
.ops
.read_phy_reg(hw
, HV_SCC_UPPER
, &phy_data
);
3074 hw
->phy
.ops
.read_phy_reg(hw
, HV_SCC_LOWER
, &phy_data
);
3075 hw
->phy
.ops
.read_phy_reg(hw
, HV_ECOL_UPPER
, &phy_data
);
3076 hw
->phy
.ops
.read_phy_reg(hw
, HV_ECOL_LOWER
, &phy_data
);
3077 hw
->phy
.ops
.read_phy_reg(hw
, HV_MCC_UPPER
, &phy_data
);
3078 hw
->phy
.ops
.read_phy_reg(hw
, HV_MCC_LOWER
, &phy_data
);
3079 hw
->phy
.ops
.read_phy_reg(hw
, HV_LATECOL_UPPER
, &phy_data
);
3080 hw
->phy
.ops
.read_phy_reg(hw
, HV_LATECOL_LOWER
, &phy_data
);
3081 hw
->phy
.ops
.read_phy_reg(hw
, HV_COLC_UPPER
, &phy_data
);
3082 hw
->phy
.ops
.read_phy_reg(hw
, HV_COLC_LOWER
, &phy_data
);
3083 hw
->phy
.ops
.read_phy_reg(hw
, HV_DC_UPPER
, &phy_data
);
3084 hw
->phy
.ops
.read_phy_reg(hw
, HV_DC_LOWER
, &phy_data
);
3085 hw
->phy
.ops
.read_phy_reg(hw
, HV_TNCRS_UPPER
, &phy_data
);
3086 hw
->phy
.ops
.read_phy_reg(hw
, HV_TNCRS_LOWER
, &phy_data
);
3090 static struct e1000_mac_operations ich8_mac_ops
= {
3091 .id_led_init
= e1000e_id_led_init
,
3092 .check_mng_mode
= e1000_check_mng_mode_ich8lan
,
3093 .check_for_link
= e1000_check_for_copper_link_ich8lan
,
3094 /* cleanup_led dependent on mac type */
3095 .clear_hw_cntrs
= e1000_clear_hw_cntrs_ich8lan
,
3096 .get_bus_info
= e1000_get_bus_info_ich8lan
,
3097 .get_link_up_info
= e1000_get_link_up_info_ich8lan
,
3098 /* led_on dependent on mac type */
3099 /* led_off dependent on mac type */
3100 .update_mc_addr_list
= e1000e_update_mc_addr_list_generic
,
3101 .reset_hw
= e1000_reset_hw_ich8lan
,
3102 .init_hw
= e1000_init_hw_ich8lan
,
3103 .setup_link
= e1000_setup_link_ich8lan
,
3104 .setup_physical_interface
= e1000_setup_copper_link_ich8lan
,
3105 /* id_led_init dependent on mac type */
3108 static struct e1000_phy_operations ich8_phy_ops
= {
3109 .acquire_phy
= e1000_acquire_swflag_ich8lan
,
3110 .check_reset_block
= e1000_check_reset_block_ich8lan
,
3112 .force_speed_duplex
= e1000_phy_force_speed_duplex_ich8lan
,
3113 .get_cfg_done
= e1000_get_cfg_done_ich8lan
,
3114 .get_cable_length
= e1000e_get_cable_length_igp_2
,
3115 .get_phy_info
= e1000_get_phy_info_ich8lan
,
3116 .read_phy_reg
= e1000e_read_phy_reg_igp
,
3117 .release_phy
= e1000_release_swflag_ich8lan
,
3118 .reset_phy
= e1000_phy_hw_reset_ich8lan
,
3119 .set_d0_lplu_state
= e1000_set_d0_lplu_state_ich8lan
,
3120 .set_d3_lplu_state
= e1000_set_d3_lplu_state_ich8lan
,
3121 .write_phy_reg
= e1000e_write_phy_reg_igp
,
3124 static struct e1000_nvm_operations ich8_nvm_ops
= {
3125 .acquire_nvm
= e1000_acquire_swflag_ich8lan
,
3126 .read_nvm
= e1000_read_nvm_ich8lan
,
3127 .release_nvm
= e1000_release_swflag_ich8lan
,
3128 .update_nvm
= e1000_update_nvm_checksum_ich8lan
,
3129 .valid_led_default
= e1000_valid_led_default_ich8lan
,
3130 .validate_nvm
= e1000_validate_nvm_checksum_ich8lan
,
3131 .write_nvm
= e1000_write_nvm_ich8lan
,
3134 struct e1000_info e1000_ich8_info
= {
3135 .mac
= e1000_ich8lan
,
3136 .flags
= FLAG_HAS_WOL
3138 | FLAG_RX_CSUM_ENABLED
3139 | FLAG_HAS_CTRLEXT_ON_LOAD
3144 .max_hw_frame_size
= ETH_FRAME_LEN
+ ETH_FCS_LEN
,
3145 .get_variants
= e1000_get_variants_ich8lan
,
3146 .mac_ops
= &ich8_mac_ops
,
3147 .phy_ops
= &ich8_phy_ops
,
3148 .nvm_ops
= &ich8_nvm_ops
,
3151 struct e1000_info e1000_ich9_info
= {
3152 .mac
= e1000_ich9lan
,
3153 .flags
= FLAG_HAS_JUMBO_FRAMES
3156 | FLAG_RX_CSUM_ENABLED
3157 | FLAG_HAS_CTRLEXT_ON_LOAD
3163 .max_hw_frame_size
= DEFAULT_JUMBO
,
3164 .get_variants
= e1000_get_variants_ich8lan
,
3165 .mac_ops
= &ich8_mac_ops
,
3166 .phy_ops
= &ich8_phy_ops
,
3167 .nvm_ops
= &ich8_nvm_ops
,
3170 struct e1000_info e1000_ich10_info
= {
3171 .mac
= e1000_ich10lan
,
3172 .flags
= FLAG_HAS_JUMBO_FRAMES
3175 | FLAG_RX_CSUM_ENABLED
3176 | FLAG_HAS_CTRLEXT_ON_LOAD
3182 .max_hw_frame_size
= DEFAULT_JUMBO
,
3183 .get_variants
= e1000_get_variants_ich8lan
,
3184 .mac_ops
= &ich8_mac_ops
,
3185 .phy_ops
= &ich8_phy_ops
,
3186 .nvm_ops
= &ich8_nvm_ops
,
3189 struct e1000_info e1000_pch_info
= {
3190 .mac
= e1000_pchlan
,
3191 .flags
= FLAG_IS_ICH
3193 | FLAG_RX_CSUM_ENABLED
3194 | FLAG_HAS_CTRLEXT_ON_LOAD
3197 | FLAG_HAS_JUMBO_FRAMES
3200 .max_hw_frame_size
= 4096,
3201 .get_variants
= e1000_get_variants_ich8lan
,
3202 .mac_ops
= &ich8_mac_ops
,
3203 .phy_ops
= &ich8_phy_ops
,
3204 .nvm_ops
= &ich8_nvm_ops
,