aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/e1000e/ich8lan.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2009-06-11 10:00:49 -0400
committerPatrick McHardy <kaber@trash.net>2009-06-11 10:00:49 -0400
commit36432dae73cf2c90a59b39c8df9fd8219272b005 (patch)
tree660b9104305a809ec4fdeb295ca13d6e90790ecc /drivers/net/e1000e/ich8lan.c
parent440f0d588555892601cfe511728a0fc0c8204063 (diff)
parentbb400801c2f40bbd9a688818323ad09abfc4e581 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next-2.6
Diffstat (limited to 'drivers/net/e1000e/ich8lan.c')
-rw-r--r--drivers/net/e1000e/ich8lan.c448
1 files changed, 423 insertions, 25 deletions
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index 6d1aab6316ba..9e23f50fb9cd 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -48,6 +48,10 @@
48 * 82567LF-3 Gigabit Network Connection 48 * 82567LF-3 Gigabit Network Connection
49 * 82567LM-3 Gigabit Network Connection 49 * 82567LM-3 Gigabit Network Connection
50 * 82567LM-4 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
51 */ 55 */
52 56
53#include <linux/netdevice.h> 57#include <linux/netdevice.h>
@@ -116,6 +120,8 @@
116#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300 120#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300
117#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200 121#define IGP3_VR_CTRL_MODE_SHUTDOWN 0x0200
118 122
123#define HV_LED_CONFIG PHY_REG(768, 30) /* LED Configuration */
124
119/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 125/* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */
120/* Offset 04h HSFSTS */ 126/* Offset 04h HSFSTS */
121union ich8_hws_flash_status { 127union ich8_hws_flash_status {
@@ -186,6 +192,14 @@ static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,
186static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw); 192static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);
187static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); 193static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw);
188static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw); 194static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);
195static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);
196static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);
197static s32 e1000_led_off_ich8lan(struct e1000_hw *hw);
198static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw);
199static s32 e1000_setup_led_pchlan(struct e1000_hw *hw);
200static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw);
201static s32 e1000_led_on_pchlan(struct e1000_hw *hw);
202static s32 e1000_led_off_pchlan(struct e1000_hw *hw);
189 203
190static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg) 204static inline u16 __er16flash(struct e1000_hw *hw, unsigned long reg)
191{ 205{
@@ -213,6 +227,41 @@ static inline void __ew32flash(struct e1000_hw *hw, unsigned long reg, u32 val)
213#define ew32flash(reg,val) __ew32flash(hw, (reg), (val)) 227#define ew32flash(reg,val) __ew32flash(hw, (reg), (val))
214 228
215/** 229/**
230 * e1000_init_phy_params_pchlan - Initialize PHY function pointers
231 * @hw: pointer to the HW structure
232 *
233 * Initialize family-specific PHY parameters and function pointers.
234 **/
235static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)
236{
237 struct e1000_phy_info *phy = &hw->phy;
238 s32 ret_val = 0;
239
240 phy->addr = 1;
241 phy->reset_delay_us = 100;
242
243 phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan;
244 phy->ops.read_phy_reg = e1000_read_phy_reg_hv;
245 phy->ops.write_phy_reg = e1000_write_phy_reg_hv;
246 phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT;
247
248 phy->id = e1000_phy_unknown;
249 e1000e_get_phy_id(hw);
250 phy->type = e1000e_get_phy_type_from_id(phy->id);
251
252 if (phy->type == e1000_phy_82577) {
253 phy->ops.check_polarity = e1000_check_polarity_82577;
254 phy->ops.force_speed_duplex =
255 e1000_phy_force_speed_duplex_82577;
256 phy->ops.get_cable_length = e1000_get_cable_length_82577;
257 phy->ops.get_phy_info = e1000_get_phy_info_82577;
258 phy->ops.commit_phy = e1000e_phy_sw_reset;
259 }
260
261 return ret_val;
262}
263
264/**
216 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers 265 * e1000_init_phy_params_ich8lan - Initialize PHY function pointers
217 * @hw: pointer to the HW structure 266 * @hw: pointer to the HW structure
218 * 267 *
@@ -273,6 +322,8 @@ static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw)
273 break; 322 break;
274 } 323 }
275 324
325 phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan;
326
276 return 0; 327 return 0;
277} 328}
278 329
@@ -358,6 +409,36 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_adapter *adapter)
358 /* Set if manageability features are enabled. */ 409 /* Set if manageability features are enabled. */
359 mac->arc_subsystem_valid = 1; 410 mac->arc_subsystem_valid = 1;
360 411
412 /* LED operations */
413 switch (mac->type) {
414 case e1000_ich8lan:
415 case e1000_ich9lan:
416 case e1000_ich10lan:
417 /* ID LED init */
418 mac->ops.id_led_init = e1000e_id_led_init;
419 /* setup LED */
420 mac->ops.setup_led = e1000e_setup_led_generic;
421 /* cleanup LED */
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;
426 break;
427 case e1000_pchlan:
428 /* ID LED init */
429 mac->ops.id_led_init = e1000_id_led_init_pchlan;
430 /* setup LED */
431 mac->ops.setup_led = e1000_setup_led_pchlan;
432 /* cleanup LED */
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;
437 break;
438 default:
439 break;
440 }
441
361 /* Enable PCS Lock-loss workaround for ICH8 */ 442 /* Enable PCS Lock-loss workaround for ICH8 */
362 if (mac->type == e1000_ich8lan) 443 if (mac->type == e1000_ich8lan)
363 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1); 444 e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, 1);
@@ -378,10 +459,18 @@ static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter)
378 if (rc) 459 if (rc)
379 return rc; 460 return rc;
380 461
381 rc = e1000_init_phy_params_ich8lan(hw); 462 if (hw->mac.type == e1000_pchlan)
463 rc = e1000_init_phy_params_pchlan(hw);
464 else
465 rc = e1000_init_phy_params_ich8lan(hw);
382 if (rc) 466 if (rc)
383 return rc; 467 return rc;
384 468
469 if (adapter->hw.phy.type == e1000_phy_ife) {
470 adapter->flags &= ~FLAG_HAS_JUMBO_FRAMES;
471 adapter->max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN;
472 }
473
385 if ((adapter->hw.mac.type == e1000_ich8lan) && 474 if ((adapter->hw.mac.type == e1000_ich8lan) &&
386 (adapter->hw.phy.type == e1000_phy_igp_3)) 475 (adapter->hw.phy.type == e1000_phy_igp_3))
387 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP; 476 adapter->flags |= FLAG_LSC_GIG_SPEED_DROP;
@@ -410,12 +499,15 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
410 499
411 while (timeout) { 500 while (timeout) {
412 extcnf_ctrl = er32(EXTCNF_CTRL); 501 extcnf_ctrl = er32(EXTCNF_CTRL);
413 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
414 ew32(EXTCNF_CTRL, extcnf_ctrl);
415 502
416 extcnf_ctrl = er32(EXTCNF_CTRL); 503 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) {
417 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) 504 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
418 break; 505 ew32(EXTCNF_CTRL, extcnf_ctrl);
506
507 extcnf_ctrl = er32(EXTCNF_CTRL);
508 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
509 break;
510 }
419 mdelay(1); 511 mdelay(1);
420 timeout--; 512 timeout--;
421 } 513 }
@@ -555,6 +647,53 @@ static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw)
555} 647}
556 648
557/** 649/**
650 * e1000_hv_phy_workarounds_ich8lan - A series of Phy workarounds to be
651 * done after every PHY reset.
652 **/
653static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)
654{
655 s32 ret_val = 0;
656
657 if (hw->mac.type != e1000_pchlan)
658 return ret_val;
659
660 if (((hw->phy.type == e1000_phy_82577) &&
661 ((hw->phy.revision == 1) || (hw->phy.revision == 2))) ||
662 ((hw->phy.type == e1000_phy_82578) && (hw->phy.revision == 1))) {
663 /* Disable generation of early preamble */
664 ret_val = e1e_wphy(hw, PHY_REG(769, 25), 0x4431);
665 if (ret_val)
666 return ret_val;
667
668 /* Preamble tuning for SSC */
669 ret_val = e1e_wphy(hw, PHY_REG(770, 16), 0xA204);
670 if (ret_val)
671 return ret_val;
672 }
673
674 if (hw->phy.type == e1000_phy_82578) {
675 /*
676 * Return registers to default by doing a soft reset then
677 * writing 0x3140 to the control register.
678 */
679 if (hw->phy.revision < 2) {
680 e1000e_phy_sw_reset(hw);
681 ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140);
682 }
683 }
684
685 /* Select page 0 */
686 ret_val = hw->phy.ops.acquire_phy(hw);
687 if (ret_val)
688 return ret_val;
689 hw->phy.addr = 1;
690 e1000e_write_phy_reg_mdic(hw, IGP01E1000_PHY_PAGE_SELECT, 0);
691 hw->phy.ops.release_phy(hw);
692
693 return ret_val;
694}
695
696/**
558 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset 697 * e1000_phy_hw_reset_ich8lan - Performs a PHY reset
559 * @hw: pointer to the HW structure 698 * @hw: pointer to the HW structure
560 * 699 *
@@ -575,6 +714,12 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)
575 if (ret_val) 714 if (ret_val)
576 return ret_val; 715 return ret_val;
577 716
717 if (hw->mac.type == e1000_pchlan) {
718 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
719 if (ret_val)
720 return ret_val;
721 }
722
578 /* 723 /*
579 * Initialize the PHY from the NVM on ICH platforms. This 724 * Initialize the PHY from the NVM on ICH platforms. This
580 * is needed due to an issue where the NVM configuration is 725 * is needed due to an issue where the NVM configuration is
@@ -701,7 +846,7 @@ static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw)
701 phy->polarity_correction = (!(data & IFE_PSC_AUTO_POLARITY_DISABLE)); 846 phy->polarity_correction = (!(data & IFE_PSC_AUTO_POLARITY_DISABLE));
702 847
703 if (phy->polarity_correction) { 848 if (phy->polarity_correction) {
704 ret_val = e1000_check_polarity_ife_ich8lan(hw); 849 ret_val = phy->ops.check_polarity(hw);
705 if (ret_val) 850 if (ret_val)
706 return ret_val; 851 return ret_val;
707 } else { 852 } else {
@@ -741,6 +886,8 @@ static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw)
741 break; 886 break;
742 case e1000_phy_igp_3: 887 case e1000_phy_igp_3:
743 case e1000_phy_bm: 888 case e1000_phy_bm:
889 case e1000_phy_82578:
890 case e1000_phy_82577:
744 return e1000e_get_phy_info_igp(hw); 891 return e1000e_get_phy_info_igp(hw);
745 break; 892 break;
746 default: 893 default:
@@ -1852,6 +1999,79 @@ static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data)
1852} 1999}
1853 2000
1854/** 2001/**
2002 * e1000_id_led_init_pchlan - store LED configurations
2003 * @hw: pointer to the HW structure
2004 *
2005 * PCH does not control LEDs via the LEDCTL register, rather it uses
2006 * the PHY LED configuration register.
2007 *
2008 * PCH also does not have an "always on" or "always off" mode which
2009 * complicates the ID feature. Instead of using the "on" mode to indicate
2010 * in ledctl_mode2 the LEDs to use for ID (see e1000e_id_led_init()),
2011 * use "link_up" mode. The LEDs will still ID on request if there is no
2012 * link based on logic in e1000_led_[on|off]_pchlan().
2013 **/
2014static s32 e1000_id_led_init_pchlan(struct e1000_hw *hw)
2015{
2016 struct e1000_mac_info *mac = &hw->mac;
2017 s32 ret_val;
2018 const u32 ledctl_on = E1000_LEDCTL_MODE_LINK_UP;
2019 const u32 ledctl_off = E1000_LEDCTL_MODE_LINK_UP | E1000_PHY_LED0_IVRT;
2020 u16 data, i, temp, shift;
2021
2022 /* Get default ID LED modes */
2023 ret_val = hw->nvm.ops.valid_led_default(hw, &data);
2024 if (ret_val)
2025 goto out;
2026
2027 mac->ledctl_default = er32(LEDCTL);
2028 mac->ledctl_mode1 = mac->ledctl_default;
2029 mac->ledctl_mode2 = mac->ledctl_default;
2030
2031 for (i = 0; i < 4; i++) {
2032 temp = (data >> (i << 2)) & E1000_LEDCTL_LED0_MODE_MASK;
2033 shift = (i * 5);
2034 switch (temp) {
2035 case ID_LED_ON1_DEF2:
2036 case ID_LED_ON1_ON2:
2037 case ID_LED_ON1_OFF2:
2038 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2039 mac->ledctl_mode1 |= (ledctl_on << shift);
2040 break;
2041 case ID_LED_OFF1_DEF2:
2042 case ID_LED_OFF1_ON2:
2043 case ID_LED_OFF1_OFF2:
2044 mac->ledctl_mode1 &= ~(E1000_PHY_LED0_MASK << shift);
2045 mac->ledctl_mode1 |= (ledctl_off << shift);
2046 break;
2047 default:
2048 /* Do nothing */
2049 break;
2050 }
2051 switch (temp) {
2052 case ID_LED_DEF1_ON2:
2053 case ID_LED_ON1_ON2:
2054 case ID_LED_OFF1_ON2:
2055 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
2056 mac->ledctl_mode2 |= (ledctl_on << shift);
2057 break;
2058 case ID_LED_DEF1_OFF2:
2059 case ID_LED_ON1_OFF2:
2060 case ID_LED_OFF1_OFF2:
2061 mac->ledctl_mode2 &= ~(E1000_PHY_LED0_MASK << shift);
2062 mac->ledctl_mode2 |= (ledctl_off << shift);
2063 break;
2064 default:
2065 /* Do nothing */
2066 break;
2067 }
2068 }
2069
2070out:
2071 return ret_val;
2072}
2073
2074/**
1855 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width 2075 * e1000_get_bus_info_ich8lan - Get/Set the bus type and width
1856 * @hw: pointer to the HW structure 2076 * @hw: pointer to the HW structure
1857 * 2077 *
@@ -1960,6 +2180,9 @@ static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw)
1960 kab |= E1000_KABGTXD_BGSQLBIAS; 2180 kab |= E1000_KABGTXD_BGSQLBIAS;
1961 ew32(KABGTXD, kab); 2181 ew32(KABGTXD, kab);
1962 2182
2183 if (hw->mac.type == e1000_pchlan)
2184 ret_val = e1000_hv_phy_workarounds_ich8lan(hw);
2185
1963 return ret_val; 2186 return ret_val;
1964} 2187}
1965 2188
@@ -1985,7 +2208,7 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
1985 e1000_initialize_hw_bits_ich8lan(hw); 2208 e1000_initialize_hw_bits_ich8lan(hw);
1986 2209
1987 /* Initialize identification LED */ 2210 /* Initialize identification LED */
1988 ret_val = e1000e_id_led_init(hw); 2211 ret_val = mac->ops.id_led_init(hw);
1989 if (ret_val) { 2212 if (ret_val) {
1990 hw_dbg(hw, "Error initializing identification LED\n"); 2213 hw_dbg(hw, "Error initializing identification LED\n");
1991 return ret_val; 2214 return ret_val;
@@ -2031,6 +2254,16 @@ static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw)
2031 ew32(CTRL_EXT, ctrl_ext); 2254 ew32(CTRL_EXT, ctrl_ext);
2032 2255
2033 /* 2256 /*
2257 * The 82578 Rx buffer will stall if wakeup is enabled in host and
2258 * the ME. Reading the BM_WUC register will clear the host wakeup bit.
2259 * Reset the phy after disabling host wakeup to reset the Rx buffer.
2260 */
2261 if (hw->phy.type == e1000_phy_82578) {
2262 e1e_rphy(hw, BM_WUC, &i);
2263 e1000e_phy_hw_reset_generic(hw);
2264 }
2265
2266 /*
2034 * Clear all of the statistics registers (clear on read). It is 2267 * Clear all of the statistics registers (clear on read). It is
2035 * important that we do this after we have tried to establish link 2268 * important that we do this after we have tried to establish link
2036 * because the symbol error count will increment wildly if there 2269 * because the symbol error count will increment wildly if there
@@ -2054,6 +2287,9 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)
2054 /* Extended Device Control */ 2287 /* Extended Device Control */
2055 reg = er32(CTRL_EXT); 2288 reg = er32(CTRL_EXT);
2056 reg |= (1 << 22); 2289 reg |= (1 << 22);
2290 /* Enable PHY low-power state when MAC is at D3 w/o WoL */
2291 if (hw->mac.type >= e1000_pchlan)
2292 reg |= E1000_CTRL_EXT_PHYPDEN;
2057 ew32(CTRL_EXT, reg); 2293 ew32(CTRL_EXT, reg);
2058 2294
2059 /* Transmit Descriptor Control 0 */ 2295 /* Transmit Descriptor Control 0 */
@@ -2112,8 +2348,13 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
2112 * the default flow control setting, so we explicitly 2348 * the default flow control setting, so we explicitly
2113 * set it to full. 2349 * set it to full.
2114 */ 2350 */
2115 if (hw->fc.requested_mode == e1000_fc_default) 2351 if (hw->fc.requested_mode == e1000_fc_default) {
2116 hw->fc.requested_mode = e1000_fc_full; 2352 /* Workaround h/w hang when Tx flow control enabled */
2353 if (hw->mac.type == e1000_pchlan)
2354 hw->fc.requested_mode = e1000_fc_rx_pause;
2355 else
2356 hw->fc.requested_mode = e1000_fc_full;
2357 }
2117 2358
2118 /* 2359 /*
2119 * Save off the requested flow control mode for use later. Depending 2360 * Save off the requested flow control mode for use later. Depending
@@ -2130,6 +2371,14 @@ static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw)
2130 return ret_val; 2371 return ret_val;
2131 2372
2132 ew32(FCTTV, hw->fc.pause_time); 2373 ew32(FCTTV, hw->fc.pause_time);
2374 if ((hw->phy.type == e1000_phy_82578) ||
2375 (hw->phy.type == e1000_phy_82577)) {
2376 ret_val = hw->phy.ops.write_phy_reg(hw,
2377 PHY_REG(BM_PORT_CTRL_PAGE, 27),
2378 hw->fc.pause_time);
2379 if (ret_val)
2380 return ret_val;
2381 }
2133 2382
2134 return e1000e_set_fc_watermarks(hw); 2383 return e1000e_set_fc_watermarks(hw);
2135} 2384}
@@ -2169,18 +2418,26 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
2169 if (ret_val) 2418 if (ret_val)
2170 return ret_val; 2419 return ret_val;
2171 2420
2172 if (hw->phy.type == e1000_phy_igp_3) { 2421 switch (hw->phy.type) {
2422 case e1000_phy_igp_3:
2173 ret_val = e1000e_copper_link_setup_igp(hw); 2423 ret_val = e1000e_copper_link_setup_igp(hw);
2174 if (ret_val) 2424 if (ret_val)
2175 return ret_val; 2425 return ret_val;
2176 } else if (hw->phy.type == e1000_phy_bm) { 2426 break;
2427 case e1000_phy_bm:
2428 case e1000_phy_82578:
2177 ret_val = e1000e_copper_link_setup_m88(hw); 2429 ret_val = e1000e_copper_link_setup_m88(hw);
2178 if (ret_val) 2430 if (ret_val)
2179 return ret_val; 2431 return ret_val;
2180 } 2432 break;
2181 2433 case e1000_phy_82577:
2182 if (hw->phy.type == e1000_phy_ife) { 2434 ret_val = e1000_copper_link_setup_82577(hw);
2183 ret_val = e1e_rphy(hw, IFE_PHY_MDIX_CONTROL, &reg_data); 2435 if (ret_val)
2436 return ret_val;
2437 break;
2438 case e1000_phy_ife:
2439 ret_val = hw->phy.ops.read_phy_reg(hw, IFE_PHY_MDIX_CONTROL,
2440 &reg_data);
2184 if (ret_val) 2441 if (ret_val)
2185 return ret_val; 2442 return ret_val;
2186 2443
@@ -2198,9 +2455,13 @@ static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw)
2198 reg_data |= IFE_PMC_AUTO_MDIX; 2455 reg_data |= IFE_PMC_AUTO_MDIX;
2199 break; 2456 break;
2200 } 2457 }
2201 ret_val = e1e_wphy(hw, IFE_PHY_MDIX_CONTROL, reg_data); 2458 ret_val = hw->phy.ops.write_phy_reg(hw, IFE_PHY_MDIX_CONTROL,
2459 reg_data);
2202 if (ret_val) 2460 if (ret_val)
2203 return ret_val; 2461 return ret_val;
2462 break;
2463 default:
2464 break;
2204 } 2465 }
2205 return e1000e_setup_copper_link(hw); 2466 return e1000e_setup_copper_link(hw);
2206} 2467}
@@ -2417,18 +2678,26 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)
2417 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation 2678 * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation
2418 * to a lower speed. 2679 * to a lower speed.
2419 * 2680 *
2420 * Should only be called for ICH9 and ICH10 devices. 2681 * Should only be called for applicable parts.
2421 **/ 2682 **/
2422void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw) 2683void e1000e_disable_gig_wol_ich8lan(struct e1000_hw *hw)
2423{ 2684{
2424 u32 phy_ctrl; 2685 u32 phy_ctrl;
2425 2686
2426 if ((hw->mac.type == e1000_ich10lan) || 2687 switch (hw->mac.type) {
2427 (hw->mac.type == e1000_ich9lan)) { 2688 case e1000_ich9lan:
2689 case e1000_ich10lan:
2690 case e1000_pchlan:
2428 phy_ctrl = er32(PHY_CTRL); 2691 phy_ctrl = er32(PHY_CTRL);
2429 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | 2692 phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU |
2430 E1000_PHY_CTRL_GBE_DISABLE; 2693 E1000_PHY_CTRL_GBE_DISABLE;
2431 ew32(PHY_CTRL, phy_ctrl); 2694 ew32(PHY_CTRL, phy_ctrl);
2695
2696 /* Workaround SWFLAG unexpectedly set during S0->Sx */
2697 if (hw->mac.type == e1000_pchlan)
2698 udelay(500);
2699 default:
2700 break;
2432 } 2701 }
2433 2702
2434 return; 2703 return;
@@ -2482,13 +2751,99 @@ static s32 e1000_led_off_ich8lan(struct e1000_hw *hw)
2482} 2751}
2483 2752
2484/** 2753/**
2754 * e1000_setup_led_pchlan - Configures SW controllable LED
2755 * @hw: pointer to the HW structure
2756 *
2757 * This prepares the SW controllable LED for use.
2758 **/
2759static s32 e1000_setup_led_pchlan(struct e1000_hw *hw)
2760{
2761 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG,
2762 (u16)hw->mac.ledctl_mode1);
2763}
2764
2765/**
2766 * e1000_cleanup_led_pchlan - Restore the default LED operation
2767 * @hw: pointer to the HW structure
2768 *
2769 * Return the LED back to the default configuration.
2770 **/
2771static s32 e1000_cleanup_led_pchlan(struct e1000_hw *hw)
2772{
2773 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG,
2774 (u16)hw->mac.ledctl_default);
2775}
2776
2777/**
2778 * e1000_led_on_pchlan - Turn LEDs on
2779 * @hw: pointer to the HW structure
2780 *
2781 * Turn on the LEDs.
2782 **/
2783static s32 e1000_led_on_pchlan(struct e1000_hw *hw)
2784{
2785 u16 data = (u16)hw->mac.ledctl_mode2;
2786 u32 i, led;
2787
2788 /*
2789 * If no link, then turn LED on by setting the invert bit
2790 * for each LED that's mode is "link_up" in ledctl_mode2.
2791 */
2792 if (!(er32(STATUS) & E1000_STATUS_LU)) {
2793 for (i = 0; i < 3; i++) {
2794 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
2795 if ((led & E1000_PHY_LED0_MODE_MASK) !=
2796 E1000_LEDCTL_MODE_LINK_UP)
2797 continue;
2798 if (led & E1000_PHY_LED0_IVRT)
2799 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
2800 else
2801 data |= (E1000_PHY_LED0_IVRT << (i * 5));
2802 }
2803 }
2804
2805 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data);
2806}
2807
2808/**
2809 * e1000_led_off_pchlan - Turn LEDs off
2810 * @hw: pointer to the HW structure
2811 *
2812 * Turn off the LEDs.
2813 **/
2814static s32 e1000_led_off_pchlan(struct e1000_hw *hw)
2815{
2816 u16 data = (u16)hw->mac.ledctl_mode1;
2817 u32 i, led;
2818
2819 /*
2820 * If no link, then turn LED off by clearing the invert bit
2821 * for each LED that's mode is "link_up" in ledctl_mode1.
2822 */
2823 if (!(er32(STATUS) & E1000_STATUS_LU)) {
2824 for (i = 0; i < 3; i++) {
2825 led = (data >> (i * 5)) & E1000_PHY_LED0_MASK;
2826 if ((led & E1000_PHY_LED0_MODE_MASK) !=
2827 E1000_LEDCTL_MODE_LINK_UP)
2828 continue;
2829 if (led & E1000_PHY_LED0_IVRT)
2830 data &= ~(E1000_PHY_LED0_IVRT << (i * 5));
2831 else
2832 data |= (E1000_PHY_LED0_IVRT << (i * 5));
2833 }
2834 }
2835
2836 return hw->phy.ops.write_phy_reg(hw, HV_LED_CONFIG, data);
2837}
2838
2839/**
2485 * e1000_get_cfg_done_ich8lan - Read config done bit 2840 * e1000_get_cfg_done_ich8lan - Read config done bit
2486 * @hw: pointer to the HW structure 2841 * @hw: pointer to the HW structure
2487 * 2842 *
2488 * Read the management control register for the config done bit for 2843 * Read the management control register for the config done bit for
2489 * completion status. NOTE: silicon which is EEPROM-less will fail trying 2844 * completion status. NOTE: silicon which is EEPROM-less will fail trying
2490 * to read the config done bit, so an error is *ONLY* logged and returns 2845 * to read the config done bit, so an error is *ONLY* logged and returns
2491 * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon 2846 * 0. If we were to return with error, EEPROM-less silicon
2492 * would not be able to be reset or change link. 2847 * would not be able to be reset or change link.
2493 **/ 2848 **/
2494static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw) 2849static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
@@ -2498,7 +2853,8 @@ static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2498 e1000e_get_cfg_done(hw); 2853 e1000e_get_cfg_done(hw);
2499 2854
2500 /* If EEPROM is not marked present, init the IGP 3 PHY manually */ 2855 /* If EEPROM is not marked present, init the IGP 3 PHY manually */
2501 if (hw->mac.type != e1000_ich10lan) { 2856 if ((hw->mac.type != e1000_ich10lan) &&
2857 (hw->mac.type != e1000_pchlan)) {
2502 if (((er32(EECD) & E1000_EECD_PRES) == 0) && 2858 if (((er32(EECD) & E1000_EECD_PRES) == 0) &&
2503 (hw->phy.type == e1000_phy_igp_3)) { 2859 (hw->phy.type == e1000_phy_igp_3)) {
2504 e1000e_phy_init_script_igp3(hw); 2860 e1000e_phy_init_script_igp3(hw);
@@ -2524,6 +2880,7 @@ static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)
2524static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) 2880static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2525{ 2881{
2526 u32 temp; 2882 u32 temp;
2883 u16 phy_data;
2527 2884
2528 e1000e_clear_hw_cntrs_base(hw); 2885 e1000e_clear_hw_cntrs_base(hw);
2529 2886
@@ -2541,22 +2898,42 @@ static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw)
2541 temp = er32(IAC); 2898 temp = er32(IAC);
2542 temp = er32(ICRXOC); 2899 temp = er32(ICRXOC);
2543 2900
2901 /* Clear PHY statistics registers */
2902 if ((hw->phy.type == e1000_phy_82578) ||
2903 (hw->phy.type == e1000_phy_82577)) {
2904 hw->phy.ops.read_phy_reg(hw, HV_SCC_UPPER, &phy_data);
2905 hw->phy.ops.read_phy_reg(hw, HV_SCC_LOWER, &phy_data);
2906 hw->phy.ops.read_phy_reg(hw, HV_ECOL_UPPER, &phy_data);
2907 hw->phy.ops.read_phy_reg(hw, HV_ECOL_LOWER, &phy_data);
2908 hw->phy.ops.read_phy_reg(hw, HV_MCC_UPPER, &phy_data);
2909 hw->phy.ops.read_phy_reg(hw, HV_MCC_LOWER, &phy_data);
2910 hw->phy.ops.read_phy_reg(hw, HV_LATECOL_UPPER, &phy_data);
2911 hw->phy.ops.read_phy_reg(hw, HV_LATECOL_LOWER, &phy_data);
2912 hw->phy.ops.read_phy_reg(hw, HV_COLC_UPPER, &phy_data);
2913 hw->phy.ops.read_phy_reg(hw, HV_COLC_LOWER, &phy_data);
2914 hw->phy.ops.read_phy_reg(hw, HV_DC_UPPER, &phy_data);
2915 hw->phy.ops.read_phy_reg(hw, HV_DC_LOWER, &phy_data);
2916 hw->phy.ops.read_phy_reg(hw, HV_TNCRS_UPPER, &phy_data);
2917 hw->phy.ops.read_phy_reg(hw, HV_TNCRS_LOWER, &phy_data);
2918 }
2544} 2919}
2545 2920
2546static struct e1000_mac_operations ich8_mac_ops = { 2921static struct e1000_mac_operations ich8_mac_ops = {
2922 .id_led_init = e1000e_id_led_init,
2547 .check_mng_mode = e1000_check_mng_mode_ich8lan, 2923 .check_mng_mode = e1000_check_mng_mode_ich8lan,
2548 .check_for_link = e1000e_check_for_copper_link, 2924 .check_for_link = e1000e_check_for_copper_link,
2549 .cleanup_led = e1000_cleanup_led_ich8lan, 2925 /* cleanup_led dependent on mac type */
2550 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan, 2926 .clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan,
2551 .get_bus_info = e1000_get_bus_info_ich8lan, 2927 .get_bus_info = e1000_get_bus_info_ich8lan,
2552 .get_link_up_info = e1000_get_link_up_info_ich8lan, 2928 .get_link_up_info = e1000_get_link_up_info_ich8lan,
2553 .led_on = e1000_led_on_ich8lan, 2929 /* led_on dependent on mac type */
2554 .led_off = e1000_led_off_ich8lan, 2930 /* led_off dependent on mac type */
2555 .update_mc_addr_list = e1000e_update_mc_addr_list_generic, 2931 .update_mc_addr_list = e1000e_update_mc_addr_list_generic,
2556 .reset_hw = e1000_reset_hw_ich8lan, 2932 .reset_hw = e1000_reset_hw_ich8lan,
2557 .init_hw = e1000_init_hw_ich8lan, 2933 .init_hw = e1000_init_hw_ich8lan,
2558 .setup_link = e1000_setup_link_ich8lan, 2934 .setup_link = e1000_setup_link_ich8lan,
2559 .setup_physical_interface= e1000_setup_copper_link_ich8lan, 2935 .setup_physical_interface= e1000_setup_copper_link_ich8lan,
2936 /* id_led_init dependent on mac type */
2560}; 2937};
2561 2938
2562static struct e1000_phy_operations ich8_phy_ops = { 2939static struct e1000_phy_operations ich8_phy_ops = {
@@ -2595,6 +2972,7 @@ struct e1000_info e1000_ich8_info = {
2595 | FLAG_HAS_FLASH 2972 | FLAG_HAS_FLASH
2596 | FLAG_APME_IN_WUC, 2973 | FLAG_APME_IN_WUC,
2597 .pba = 8, 2974 .pba = 8,
2975 .max_hw_frame_size = ETH_FRAME_LEN + ETH_FCS_LEN,
2598 .get_variants = e1000_get_variants_ich8lan, 2976 .get_variants = e1000_get_variants_ich8lan,
2599 .mac_ops = &ich8_mac_ops, 2977 .mac_ops = &ich8_mac_ops,
2600 .phy_ops = &ich8_phy_ops, 2978 .phy_ops = &ich8_phy_ops,
@@ -2613,6 +2991,7 @@ struct e1000_info e1000_ich9_info = {
2613 | FLAG_HAS_FLASH 2991 | FLAG_HAS_FLASH
2614 | FLAG_APME_IN_WUC, 2992 | FLAG_APME_IN_WUC,
2615 .pba = 10, 2993 .pba = 10,
2994 .max_hw_frame_size = DEFAULT_JUMBO,
2616 .get_variants = e1000_get_variants_ich8lan, 2995 .get_variants = e1000_get_variants_ich8lan,
2617 .mac_ops = &ich8_mac_ops, 2996 .mac_ops = &ich8_mac_ops,
2618 .phy_ops = &ich8_phy_ops, 2997 .phy_ops = &ich8_phy_ops,
@@ -2631,6 +3010,25 @@ struct e1000_info e1000_ich10_info = {
2631 | FLAG_HAS_FLASH 3010 | FLAG_HAS_FLASH
2632 | FLAG_APME_IN_WUC, 3011 | FLAG_APME_IN_WUC,
2633 .pba = 10, 3012 .pba = 10,
3013 .max_hw_frame_size = DEFAULT_JUMBO,
3014 .get_variants = e1000_get_variants_ich8lan,
3015 .mac_ops = &ich8_mac_ops,
3016 .phy_ops = &ich8_phy_ops,
3017 .nvm_ops = &ich8_nvm_ops,
3018};
3019
3020struct e1000_info e1000_pch_info = {
3021 .mac = e1000_pchlan,
3022 .flags = FLAG_IS_ICH
3023 | FLAG_HAS_WOL
3024 | FLAG_RX_CSUM_ENABLED
3025 | FLAG_HAS_CTRLEXT_ON_LOAD
3026 | FLAG_HAS_AMT
3027 | FLAG_HAS_FLASH
3028 | FLAG_HAS_JUMBO_FRAMES
3029 | FLAG_APME_IN_WUC,
3030 .pba = 26,
3031 .max_hw_frame_size = 4096,
2634 .get_variants = e1000_get_variants_ich8lan, 3032 .get_variants = e1000_get_variants_ich8lan,
2635 .mac_ops = &ich8_mac_ops, 3033 .mac_ops = &ich8_mac_ops,
2636 .phy_ops = &ich8_phy_ops, 3034 .phy_ops = &ich8_phy_ops,