18cfa0ad2SJack F Vogel /****************************************************************************** 28cfa0ad2SJack F Vogel 38cfa0ad2SJack F Vogel Copyright (c) 2001-2008, Intel Corporation 48cfa0ad2SJack F Vogel All rights reserved. 58cfa0ad2SJack F Vogel 68cfa0ad2SJack F Vogel Redistribution and use in source and binary forms, with or without 78cfa0ad2SJack F Vogel modification, are permitted provided that the following conditions are met: 88cfa0ad2SJack F Vogel 98cfa0ad2SJack F Vogel 1. Redistributions of source code must retain the above copyright notice, 108cfa0ad2SJack F Vogel this list of conditions and the following disclaimer. 118cfa0ad2SJack F Vogel 128cfa0ad2SJack F Vogel 2. Redistributions in binary form must reproduce the above copyright 138cfa0ad2SJack F Vogel notice, this list of conditions and the following disclaimer in the 148cfa0ad2SJack F Vogel documentation and/or other materials provided with the distribution. 158cfa0ad2SJack F Vogel 168cfa0ad2SJack F Vogel 3. Neither the name of the Intel Corporation nor the names of its 178cfa0ad2SJack F Vogel contributors may be used to endorse or promote products derived from 188cfa0ad2SJack F Vogel this software without specific prior written permission. 198cfa0ad2SJack F Vogel 208cfa0ad2SJack F Vogel THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 218cfa0ad2SJack F Vogel AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 228cfa0ad2SJack F Vogel IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 238cfa0ad2SJack F Vogel ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 248cfa0ad2SJack F Vogel LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 258cfa0ad2SJack F Vogel CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 268cfa0ad2SJack F Vogel SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 278cfa0ad2SJack F Vogel INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 288cfa0ad2SJack F Vogel CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 298cfa0ad2SJack F Vogel ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 308cfa0ad2SJack F Vogel POSSIBILITY OF SUCH DAMAGE. 318cfa0ad2SJack F Vogel 328cfa0ad2SJack F Vogel ******************************************************************************/ 338cfa0ad2SJack F Vogel /*$FreeBSD$*/ 348cfa0ad2SJack F Vogel 35daf9197cSJack F Vogel /* 36daf9197cSJack F Vogel * 82562G 10/100 Network Connection 37daf9197cSJack F Vogel * 82562G-2 10/100 Network Connection 38daf9197cSJack F Vogel * 82562GT 10/100 Network Connection 39daf9197cSJack F Vogel * 82562GT-2 10/100 Network Connection 40daf9197cSJack F Vogel * 82562V 10/100 Network Connection 41daf9197cSJack F Vogel * 82562V-2 10/100 Network Connection 42daf9197cSJack F Vogel * 82566DC-2 Gigabit Network Connection 43daf9197cSJack F Vogel * 82566DC Gigabit Network Connection 44daf9197cSJack F Vogel * 82566DM-2 Gigabit Network Connection 45daf9197cSJack F Vogel * 82566DM Gigabit Network Connection 46daf9197cSJack F Vogel * 82566MC Gigabit Network Connection 47daf9197cSJack F Vogel * 82566MM Gigabit Network Connection 48daf9197cSJack F Vogel * 82567LM Gigabit Network Connection 49daf9197cSJack F Vogel * 82567LF Gigabit Network Connection 50daf9197cSJack F Vogel * 82567V Gigabit Network Connection 51daf9197cSJack F Vogel * 82567LM-2 Gigabit Network Connection 52daf9197cSJack F Vogel * 82567LF-2 Gigabit Network Connection 53daf9197cSJack F Vogel * 82567V-2 Gigabit Network Connection 54daf9197cSJack F Vogel * 82567LF-3 Gigabit Network Connection 55daf9197cSJack F Vogel * 82567LM-3 Gigabit Network Connection 56daf9197cSJack F Vogel * 82567LM-4 Gigabit Network Connection 578cfa0ad2SJack F Vogel */ 588cfa0ad2SJack F Vogel 598cfa0ad2SJack F Vogel #include "e1000_api.h" 608cfa0ad2SJack F Vogel 618cfa0ad2SJack F Vogel static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw); 628cfa0ad2SJack F Vogel static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw); 638cfa0ad2SJack F Vogel static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw); 648cfa0ad2SJack F Vogel static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw); 658cfa0ad2SJack F Vogel static void e1000_release_swflag_ich8lan(struct e1000_hw *hw); 668cfa0ad2SJack F Vogel static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw); 678cfa0ad2SJack F Vogel static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw); 688cfa0ad2SJack F Vogel static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw); 698cfa0ad2SJack F Vogel static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw); 708cfa0ad2SJack F Vogel static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw); 718cfa0ad2SJack F Vogel static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw); 728cfa0ad2SJack F Vogel static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, 738cfa0ad2SJack F Vogel bool active); 748cfa0ad2SJack F Vogel static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, 758cfa0ad2SJack F Vogel bool active); 768cfa0ad2SJack F Vogel static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, 778cfa0ad2SJack F Vogel u16 words, u16 *data); 788cfa0ad2SJack F Vogel static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, 798cfa0ad2SJack F Vogel u16 words, u16 *data); 808cfa0ad2SJack F Vogel static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw); 818cfa0ad2SJack F Vogel static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw); 828cfa0ad2SJack F Vogel static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, 838cfa0ad2SJack F Vogel u16 *data); 848cfa0ad2SJack F Vogel static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw); 858cfa0ad2SJack F Vogel static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw); 868cfa0ad2SJack F Vogel static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw); 878cfa0ad2SJack F Vogel static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw); 888cfa0ad2SJack F Vogel static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw); 898cfa0ad2SJack F Vogel static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, 908cfa0ad2SJack F Vogel u16 *speed, u16 *duplex); 918cfa0ad2SJack F Vogel static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw); 928cfa0ad2SJack F Vogel static s32 e1000_led_on_ich8lan(struct e1000_hw *hw); 938cfa0ad2SJack F Vogel static s32 e1000_led_off_ich8lan(struct e1000_hw *hw); 948cfa0ad2SJack F Vogel static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw); 958cfa0ad2SJack F Vogel static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); 968cfa0ad2SJack F Vogel static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout); 978cfa0ad2SJack F Vogel static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw); 988cfa0ad2SJack F Vogel static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw); 998cfa0ad2SJack F Vogel static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw); 1008cfa0ad2SJack F Vogel static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); 1018cfa0ad2SJack F Vogel static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, 1028cfa0ad2SJack F Vogel u32 offset, u8 *data); 1038cfa0ad2SJack F Vogel static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, 1048cfa0ad2SJack F Vogel u8 size, u16 *data); 1058cfa0ad2SJack F Vogel static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, 1068cfa0ad2SJack F Vogel u32 offset, u16 *data); 1078cfa0ad2SJack F Vogel static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, 1088cfa0ad2SJack F Vogel u32 offset, u8 byte); 1098cfa0ad2SJack F Vogel static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, 1108cfa0ad2SJack F Vogel u32 offset, u8 data); 1118cfa0ad2SJack F Vogel static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, 1128cfa0ad2SJack F Vogel u8 size, u16 data); 1138cfa0ad2SJack F Vogel static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw); 1148cfa0ad2SJack F Vogel static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw); 1158cfa0ad2SJack F Vogel 1168cfa0ad2SJack F Vogel /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */ 1178cfa0ad2SJack F Vogel /* Offset 04h HSFSTS */ 1188cfa0ad2SJack F Vogel union ich8_hws_flash_status { 1198cfa0ad2SJack F Vogel struct ich8_hsfsts { 1208cfa0ad2SJack F Vogel u16 flcdone :1; /* bit 0 Flash Cycle Done */ 1218cfa0ad2SJack F Vogel u16 flcerr :1; /* bit 1 Flash Cycle Error */ 1228cfa0ad2SJack F Vogel u16 dael :1; /* bit 2 Direct Access error Log */ 1238cfa0ad2SJack F Vogel u16 berasesz :2; /* bit 4:3 Sector Erase Size */ 1248cfa0ad2SJack F Vogel u16 flcinprog :1; /* bit 5 flash cycle in Progress */ 1258cfa0ad2SJack F Vogel u16 reserved1 :2; /* bit 13:6 Reserved */ 1268cfa0ad2SJack F Vogel u16 reserved2 :6; /* bit 13:6 Reserved */ 1278cfa0ad2SJack F Vogel u16 fldesvalid :1; /* bit 14 Flash Descriptor Valid */ 1288cfa0ad2SJack F Vogel u16 flockdn :1; /* bit 15 Flash Config Lock-Down */ 1298cfa0ad2SJack F Vogel } hsf_status; 1308cfa0ad2SJack F Vogel u16 regval; 1318cfa0ad2SJack F Vogel }; 1328cfa0ad2SJack F Vogel 1338cfa0ad2SJack F Vogel /* ICH GbE Flash Hardware Sequencing Flash control Register bit breakdown */ 1348cfa0ad2SJack F Vogel /* Offset 06h FLCTL */ 1358cfa0ad2SJack F Vogel union ich8_hws_flash_ctrl { 1368cfa0ad2SJack F Vogel struct ich8_hsflctl { 1378cfa0ad2SJack F Vogel u16 flcgo :1; /* 0 Flash Cycle Go */ 1388cfa0ad2SJack F Vogel u16 flcycle :2; /* 2:1 Flash Cycle */ 1398cfa0ad2SJack F Vogel u16 reserved :5; /* 7:3 Reserved */ 1408cfa0ad2SJack F Vogel u16 fldbcount :2; /* 9:8 Flash Data Byte Count */ 1418cfa0ad2SJack F Vogel u16 flockdn :6; /* 15:10 Reserved */ 1428cfa0ad2SJack F Vogel } hsf_ctrl; 1438cfa0ad2SJack F Vogel u16 regval; 1448cfa0ad2SJack F Vogel }; 1458cfa0ad2SJack F Vogel 1468cfa0ad2SJack F Vogel /* ICH Flash Region Access Permissions */ 1478cfa0ad2SJack F Vogel union ich8_hws_flash_regacc { 1488cfa0ad2SJack F Vogel struct ich8_flracc { 1498cfa0ad2SJack F Vogel u32 grra :8; /* 0:7 GbE region Read Access */ 1508cfa0ad2SJack F Vogel u32 grwa :8; /* 8:15 GbE region Write Access */ 1518cfa0ad2SJack F Vogel u32 gmrag :8; /* 23:16 GbE Master Read Access Grant */ 1528cfa0ad2SJack F Vogel u32 gmwag :8; /* 31:24 GbE Master Write Access Grant */ 1538cfa0ad2SJack F Vogel } hsf_flregacc; 1548cfa0ad2SJack F Vogel u16 regval; 1558cfa0ad2SJack F Vogel }; 1568cfa0ad2SJack F Vogel 1578cfa0ad2SJack F Vogel /** 1588cfa0ad2SJack F Vogel * e1000_init_phy_params_ich8lan - Initialize PHY function pointers 1598cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 1608cfa0ad2SJack F Vogel * 1618cfa0ad2SJack F Vogel * Initialize family-specific PHY parameters and function pointers. 1628cfa0ad2SJack F Vogel **/ 1638cfa0ad2SJack F Vogel static s32 e1000_init_phy_params_ich8lan(struct e1000_hw *hw) 1648cfa0ad2SJack F Vogel { 1658cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 1668cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 1678cfa0ad2SJack F Vogel u16 i = 0; 1688cfa0ad2SJack F Vogel 1698cfa0ad2SJack F Vogel DEBUGFUNC("e1000_init_phy_params_ich8lan"); 1708cfa0ad2SJack F Vogel 1718cfa0ad2SJack F Vogel phy->addr = 1; 1728cfa0ad2SJack F Vogel phy->reset_delay_us = 100; 1738cfa0ad2SJack F Vogel 1748cfa0ad2SJack F Vogel phy->ops.acquire = e1000_acquire_swflag_ich8lan; 1758cfa0ad2SJack F Vogel phy->ops.check_polarity = e1000_check_polarity_ife_ich8lan; 1768cfa0ad2SJack F Vogel phy->ops.check_reset_block = e1000_check_reset_block_ich8lan; 1778cfa0ad2SJack F Vogel phy->ops.force_speed_duplex = e1000_phy_force_speed_duplex_ich8lan; 1788cfa0ad2SJack F Vogel phy->ops.get_cable_length = e1000_get_cable_length_igp_2; 1798cfa0ad2SJack F Vogel phy->ops.get_cfg_done = e1000_get_cfg_done_ich8lan; 1808cfa0ad2SJack F Vogel phy->ops.get_info = e1000_get_phy_info_ich8lan; 1818cfa0ad2SJack F Vogel phy->ops.read_reg = e1000_read_phy_reg_igp; 1828cfa0ad2SJack F Vogel phy->ops.release = e1000_release_swflag_ich8lan; 1838cfa0ad2SJack F Vogel phy->ops.reset = e1000_phy_hw_reset_ich8lan; 1848cfa0ad2SJack F Vogel phy->ops.set_d0_lplu_state = e1000_set_d0_lplu_state_ich8lan; 1858cfa0ad2SJack F Vogel phy->ops.set_d3_lplu_state = e1000_set_d3_lplu_state_ich8lan; 1868cfa0ad2SJack F Vogel phy->ops.write_reg = e1000_write_phy_reg_igp; 1878cfa0ad2SJack F Vogel phy->ops.power_up = e1000_power_up_phy_copper; 1888cfa0ad2SJack F Vogel phy->ops.power_down = e1000_power_down_phy_copper_ich8lan; 1898cfa0ad2SJack F Vogel 1908cfa0ad2SJack F Vogel /* 1918cfa0ad2SJack F Vogel * We may need to do this twice - once for IGP and if that fails, 1928cfa0ad2SJack F Vogel * we'll set BM func pointers and try again 1938cfa0ad2SJack F Vogel */ 1948cfa0ad2SJack F Vogel ret_val = e1000_determine_phy_address(hw); 1958cfa0ad2SJack F Vogel if (ret_val) { 1968cfa0ad2SJack F Vogel phy->ops.write_reg = e1000_write_phy_reg_bm; 1978cfa0ad2SJack F Vogel phy->ops.read_reg = e1000_read_phy_reg_bm; 1988cfa0ad2SJack F Vogel ret_val = e1000_determine_phy_address(hw); 1998cfa0ad2SJack F Vogel if (ret_val) { 2008cfa0ad2SJack F Vogel DEBUGOUT("Cannot determine PHY address. Erroring out\n"); 2018cfa0ad2SJack F Vogel goto out; 2028cfa0ad2SJack F Vogel } 2038cfa0ad2SJack F Vogel } 2048cfa0ad2SJack F Vogel 2058cfa0ad2SJack F Vogel phy->id = 0; 2068cfa0ad2SJack F Vogel while ((e1000_phy_unknown == e1000_get_phy_type_from_id(phy->id)) && 2078cfa0ad2SJack F Vogel (i++ < 100)) { 2088cfa0ad2SJack F Vogel msec_delay(1); 2098cfa0ad2SJack F Vogel ret_val = e1000_get_phy_id(hw); 2108cfa0ad2SJack F Vogel if (ret_val) 2118cfa0ad2SJack F Vogel goto out; 2128cfa0ad2SJack F Vogel } 2138cfa0ad2SJack F Vogel 2148cfa0ad2SJack F Vogel /* Verify phy id */ 2158cfa0ad2SJack F Vogel switch (phy->id) { 2168cfa0ad2SJack F Vogel case IGP03E1000_E_PHY_ID: 2178cfa0ad2SJack F Vogel phy->type = e1000_phy_igp_3; 2188cfa0ad2SJack F Vogel phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; 2198cfa0ad2SJack F Vogel break; 2208cfa0ad2SJack F Vogel case IFE_E_PHY_ID: 2218cfa0ad2SJack F Vogel case IFE_PLUS_E_PHY_ID: 2228cfa0ad2SJack F Vogel case IFE_C_E_PHY_ID: 2238cfa0ad2SJack F Vogel phy->type = e1000_phy_ife; 2248cfa0ad2SJack F Vogel phy->autoneg_mask = E1000_ALL_NOT_GIG; 2258cfa0ad2SJack F Vogel break; 2268cfa0ad2SJack F Vogel case BME1000_E_PHY_ID: 2278cfa0ad2SJack F Vogel phy->type = e1000_phy_bm; 2288cfa0ad2SJack F Vogel phy->autoneg_mask = AUTONEG_ADVERTISE_SPEED_DEFAULT; 2298cfa0ad2SJack F Vogel phy->ops.read_reg = e1000_read_phy_reg_bm; 2308cfa0ad2SJack F Vogel phy->ops.write_reg = e1000_write_phy_reg_bm; 2318cfa0ad2SJack F Vogel phy->ops.commit = e1000_phy_sw_reset_generic; 2328cfa0ad2SJack F Vogel break; 2338cfa0ad2SJack F Vogel default: 2348cfa0ad2SJack F Vogel ret_val = -E1000_ERR_PHY; 2358cfa0ad2SJack F Vogel goto out; 2368cfa0ad2SJack F Vogel } 2378cfa0ad2SJack F Vogel 2388cfa0ad2SJack F Vogel out: 2398cfa0ad2SJack F Vogel return ret_val; 2408cfa0ad2SJack F Vogel } 2418cfa0ad2SJack F Vogel 2428cfa0ad2SJack F Vogel /** 2438cfa0ad2SJack F Vogel * e1000_init_nvm_params_ich8lan - Initialize NVM function pointers 2448cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 2458cfa0ad2SJack F Vogel * 2468cfa0ad2SJack F Vogel * Initialize family-specific NVM parameters and function 2478cfa0ad2SJack F Vogel * pointers. 2488cfa0ad2SJack F Vogel **/ 2498cfa0ad2SJack F Vogel static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw) 2508cfa0ad2SJack F Vogel { 2518cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 252daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 2538cfa0ad2SJack F Vogel u32 gfpreg, sector_base_addr, sector_end_addr; 2548cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 2558cfa0ad2SJack F Vogel u16 i; 2568cfa0ad2SJack F Vogel 2578cfa0ad2SJack F Vogel DEBUGFUNC("e1000_init_nvm_params_ich8lan"); 2588cfa0ad2SJack F Vogel 2598cfa0ad2SJack F Vogel /* Can't read flash registers if the register set isn't mapped. */ 2608cfa0ad2SJack F Vogel if (!hw->flash_address) { 2618cfa0ad2SJack F Vogel DEBUGOUT("ERROR: Flash registers not mapped\n"); 2628cfa0ad2SJack F Vogel ret_val = -E1000_ERR_CONFIG; 2638cfa0ad2SJack F Vogel goto out; 2648cfa0ad2SJack F Vogel } 2658cfa0ad2SJack F Vogel 2668cfa0ad2SJack F Vogel nvm->type = e1000_nvm_flash_sw; 2678cfa0ad2SJack F Vogel 2688cfa0ad2SJack F Vogel gfpreg = E1000_READ_FLASH_REG(hw, ICH_FLASH_GFPREG); 2698cfa0ad2SJack F Vogel 2708cfa0ad2SJack F Vogel /* 2718cfa0ad2SJack F Vogel * sector_X_addr is a "sector"-aligned address (4096 bytes) 2728cfa0ad2SJack F Vogel * Add 1 to sector_end_addr since this sector is included in 2738cfa0ad2SJack F Vogel * the overall size. 2748cfa0ad2SJack F Vogel */ 2758cfa0ad2SJack F Vogel sector_base_addr = gfpreg & FLASH_GFPREG_BASE_MASK; 2768cfa0ad2SJack F Vogel sector_end_addr = ((gfpreg >> 16) & FLASH_GFPREG_BASE_MASK) + 1; 2778cfa0ad2SJack F Vogel 2788cfa0ad2SJack F Vogel /* flash_base_addr is byte-aligned */ 2798cfa0ad2SJack F Vogel nvm->flash_base_addr = sector_base_addr << FLASH_SECTOR_ADDR_SHIFT; 2808cfa0ad2SJack F Vogel 2818cfa0ad2SJack F Vogel /* 2828cfa0ad2SJack F Vogel * find total size of the NVM, then cut in half since the total 2838cfa0ad2SJack F Vogel * size represents two separate NVM banks. 2848cfa0ad2SJack F Vogel */ 2858cfa0ad2SJack F Vogel nvm->flash_bank_size = (sector_end_addr - sector_base_addr) 2868cfa0ad2SJack F Vogel << FLASH_SECTOR_ADDR_SHIFT; 2878cfa0ad2SJack F Vogel nvm->flash_bank_size /= 2; 2888cfa0ad2SJack F Vogel /* Adjust to word count */ 2898cfa0ad2SJack F Vogel nvm->flash_bank_size /= sizeof(u16); 2908cfa0ad2SJack F Vogel 2918cfa0ad2SJack F Vogel nvm->word_size = E1000_SHADOW_RAM_WORDS; 2928cfa0ad2SJack F Vogel 2938cfa0ad2SJack F Vogel /* Clear shadow ram */ 2948cfa0ad2SJack F Vogel for (i = 0; i < nvm->word_size; i++) { 2958cfa0ad2SJack F Vogel dev_spec->shadow_ram[i].modified = FALSE; 2968cfa0ad2SJack F Vogel dev_spec->shadow_ram[i].value = 0xFFFF; 2978cfa0ad2SJack F Vogel } 2988cfa0ad2SJack F Vogel 2998cfa0ad2SJack F Vogel /* Function Pointers */ 3008cfa0ad2SJack F Vogel nvm->ops.acquire = e1000_acquire_swflag_ich8lan; 3018cfa0ad2SJack F Vogel nvm->ops.read = e1000_read_nvm_ich8lan; 3028cfa0ad2SJack F Vogel nvm->ops.release = e1000_release_swflag_ich8lan; 3038cfa0ad2SJack F Vogel nvm->ops.update = e1000_update_nvm_checksum_ich8lan; 3048cfa0ad2SJack F Vogel nvm->ops.valid_led_default = e1000_valid_led_default_ich8lan; 3058cfa0ad2SJack F Vogel nvm->ops.validate = e1000_validate_nvm_checksum_ich8lan; 3068cfa0ad2SJack F Vogel nvm->ops.write = e1000_write_nvm_ich8lan; 3078cfa0ad2SJack F Vogel 3088cfa0ad2SJack F Vogel out: 3098cfa0ad2SJack F Vogel return ret_val; 3108cfa0ad2SJack F Vogel } 3118cfa0ad2SJack F Vogel 3128cfa0ad2SJack F Vogel /** 3138cfa0ad2SJack F Vogel * e1000_init_mac_params_ich8lan - Initialize MAC function pointers 3148cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 3158cfa0ad2SJack F Vogel * 3168cfa0ad2SJack F Vogel * Initialize family-specific MAC parameters and function 3178cfa0ad2SJack F Vogel * pointers. 3188cfa0ad2SJack F Vogel **/ 3198cfa0ad2SJack F Vogel static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw) 3208cfa0ad2SJack F Vogel { 3218cfa0ad2SJack F Vogel struct e1000_mac_info *mac = &hw->mac; 3228cfa0ad2SJack F Vogel 3238cfa0ad2SJack F Vogel DEBUGFUNC("e1000_init_mac_params_ich8lan"); 3248cfa0ad2SJack F Vogel 3258cfa0ad2SJack F Vogel /* Set media type function pointer */ 3268cfa0ad2SJack F Vogel hw->phy.media_type = e1000_media_type_copper; 3278cfa0ad2SJack F Vogel 3288cfa0ad2SJack F Vogel /* Set mta register count */ 3298cfa0ad2SJack F Vogel mac->mta_reg_count = 32; 3308cfa0ad2SJack F Vogel /* Set rar entry count */ 3318cfa0ad2SJack F Vogel mac->rar_entry_count = E1000_ICH_RAR_ENTRIES; 3328cfa0ad2SJack F Vogel if (mac->type == e1000_ich8lan) 3338cfa0ad2SJack F Vogel mac->rar_entry_count--; 3348cfa0ad2SJack F Vogel /* Set if part includes ASF firmware */ 3358cfa0ad2SJack F Vogel mac->asf_firmware_present = TRUE; 3368cfa0ad2SJack F Vogel /* Set if manageability features are enabled. */ 3378cfa0ad2SJack F Vogel mac->arc_subsystem_valid = TRUE; 3388cfa0ad2SJack F Vogel 3398cfa0ad2SJack F Vogel /* Function pointers */ 3408cfa0ad2SJack F Vogel 3418cfa0ad2SJack F Vogel /* bus type/speed/width */ 3428cfa0ad2SJack F Vogel mac->ops.get_bus_info = e1000_get_bus_info_ich8lan; 343daf9197cSJack F Vogel /* function id */ 344daf9197cSJack F Vogel mac->ops.set_lan_id = e1000_set_lan_id_single_port; 3458cfa0ad2SJack F Vogel /* reset */ 3468cfa0ad2SJack F Vogel mac->ops.reset_hw = e1000_reset_hw_ich8lan; 3478cfa0ad2SJack F Vogel /* hw initialization */ 3488cfa0ad2SJack F Vogel mac->ops.init_hw = e1000_init_hw_ich8lan; 3498cfa0ad2SJack F Vogel /* link setup */ 3508cfa0ad2SJack F Vogel mac->ops.setup_link = e1000_setup_link_ich8lan; 3518cfa0ad2SJack F Vogel /* physical interface setup */ 3528cfa0ad2SJack F Vogel mac->ops.setup_physical_interface = e1000_setup_copper_link_ich8lan; 3538cfa0ad2SJack F Vogel /* check for link */ 3548cfa0ad2SJack F Vogel mac->ops.check_for_link = e1000_check_for_copper_link_generic; 3558cfa0ad2SJack F Vogel /* check management mode */ 3568cfa0ad2SJack F Vogel mac->ops.check_mng_mode = e1000_check_mng_mode_ich8lan; 3578cfa0ad2SJack F Vogel /* link info */ 3588cfa0ad2SJack F Vogel mac->ops.get_link_up_info = e1000_get_link_up_info_ich8lan; 3598cfa0ad2SJack F Vogel /* multicast address update */ 3608cfa0ad2SJack F Vogel mac->ops.update_mc_addr_list = e1000_update_mc_addr_list_generic; 3618cfa0ad2SJack F Vogel /* setting MTA */ 3628cfa0ad2SJack F Vogel mac->ops.mta_set = e1000_mta_set_generic; 3638cfa0ad2SJack F Vogel /* blink LED */ 3648cfa0ad2SJack F Vogel mac->ops.blink_led = e1000_blink_led_generic; 3658cfa0ad2SJack F Vogel /* setup LED */ 3668cfa0ad2SJack F Vogel mac->ops.setup_led = e1000_setup_led_generic; 3678cfa0ad2SJack F Vogel /* cleanup LED */ 3688cfa0ad2SJack F Vogel mac->ops.cleanup_led = e1000_cleanup_led_ich8lan; 3698cfa0ad2SJack F Vogel /* turn on/off LED */ 3708cfa0ad2SJack F Vogel mac->ops.led_on = e1000_led_on_ich8lan; 3718cfa0ad2SJack F Vogel mac->ops.led_off = e1000_led_off_ich8lan; 3728cfa0ad2SJack F Vogel /* clear hardware counters */ 3738cfa0ad2SJack F Vogel mac->ops.clear_hw_cntrs = e1000_clear_hw_cntrs_ich8lan; 3748cfa0ad2SJack F Vogel 3758cfa0ad2SJack F Vogel /* Enable PCS Lock-loss workaround for ICH8 */ 3768cfa0ad2SJack F Vogel if (mac->type == e1000_ich8lan) 3778cfa0ad2SJack F Vogel e1000_set_kmrn_lock_loss_workaround_ich8lan(hw, TRUE); 3788cfa0ad2SJack F Vogel 3798cfa0ad2SJack F Vogel 380daf9197cSJack F Vogel return E1000_SUCCESS; 3818cfa0ad2SJack F Vogel } 3828cfa0ad2SJack F Vogel 3838cfa0ad2SJack F Vogel /** 3848cfa0ad2SJack F Vogel * e1000_init_function_pointers_ich8lan - Initialize ICH8 function pointers 3858cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 3868cfa0ad2SJack F Vogel * 3878cfa0ad2SJack F Vogel * Initialize family-specific function pointers for PHY, MAC, and NVM. 3888cfa0ad2SJack F Vogel **/ 3898cfa0ad2SJack F Vogel void e1000_init_function_pointers_ich8lan(struct e1000_hw *hw) 3908cfa0ad2SJack F Vogel { 3918cfa0ad2SJack F Vogel DEBUGFUNC("e1000_init_function_pointers_ich8lan"); 3928cfa0ad2SJack F Vogel 3938cfa0ad2SJack F Vogel hw->mac.ops.init_params = e1000_init_mac_params_ich8lan; 3948cfa0ad2SJack F Vogel hw->nvm.ops.init_params = e1000_init_nvm_params_ich8lan; 3958cfa0ad2SJack F Vogel hw->phy.ops.init_params = e1000_init_phy_params_ich8lan; 3968cfa0ad2SJack F Vogel } 3978cfa0ad2SJack F Vogel 3988cfa0ad2SJack F Vogel /** 3998cfa0ad2SJack F Vogel * e1000_acquire_swflag_ich8lan - Acquire software control flag 4008cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 4018cfa0ad2SJack F Vogel * 4028cfa0ad2SJack F Vogel * Acquires the software control flag for performing NVM and PHY 4038cfa0ad2SJack F Vogel * operations. This is a function pointer entry point only called by 4048cfa0ad2SJack F Vogel * read/write routines for the PHY and NVM parts. 4058cfa0ad2SJack F Vogel **/ 4068cfa0ad2SJack F Vogel static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) 4078cfa0ad2SJack F Vogel { 4088cfa0ad2SJack F Vogel u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT; 4098cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 4108cfa0ad2SJack F Vogel 4118cfa0ad2SJack F Vogel DEBUGFUNC("e1000_acquire_swflag_ich8lan"); 4128cfa0ad2SJack F Vogel 4138cfa0ad2SJack F Vogel while (timeout) { 4148cfa0ad2SJack F Vogel extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 4158cfa0ad2SJack F Vogel extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; 4168cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl); 4178cfa0ad2SJack F Vogel 4188cfa0ad2SJack F Vogel extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 4198cfa0ad2SJack F Vogel if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG) 4208cfa0ad2SJack F Vogel break; 4218cfa0ad2SJack F Vogel msec_delay_irq(1); 4228cfa0ad2SJack F Vogel timeout--; 4238cfa0ad2SJack F Vogel } 4248cfa0ad2SJack F Vogel 4258cfa0ad2SJack F Vogel if (!timeout) { 4268cfa0ad2SJack F Vogel DEBUGOUT("FW or HW has locked the resource for too long.\n"); 4278cfa0ad2SJack F Vogel extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 4288cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl); 4298cfa0ad2SJack F Vogel ret_val = -E1000_ERR_CONFIG; 4308cfa0ad2SJack F Vogel goto out; 4318cfa0ad2SJack F Vogel } 4328cfa0ad2SJack F Vogel 4338cfa0ad2SJack F Vogel out: 4348cfa0ad2SJack F Vogel return ret_val; 4358cfa0ad2SJack F Vogel } 4368cfa0ad2SJack F Vogel 4378cfa0ad2SJack F Vogel /** 4388cfa0ad2SJack F Vogel * e1000_release_swflag_ich8lan - Release software control flag 4398cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 4408cfa0ad2SJack F Vogel * 4418cfa0ad2SJack F Vogel * Releases the software control flag for performing NVM and PHY operations. 4428cfa0ad2SJack F Vogel * This is a function pointer entry point only called by read/write 4438cfa0ad2SJack F Vogel * routines for the PHY and NVM parts. 4448cfa0ad2SJack F Vogel **/ 4458cfa0ad2SJack F Vogel static void e1000_release_swflag_ich8lan(struct e1000_hw *hw) 4468cfa0ad2SJack F Vogel { 4478cfa0ad2SJack F Vogel u32 extcnf_ctrl; 4488cfa0ad2SJack F Vogel 4498cfa0ad2SJack F Vogel DEBUGFUNC("e1000_release_swflag_ich8lan"); 4508cfa0ad2SJack F Vogel 4518cfa0ad2SJack F Vogel extcnf_ctrl = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 4528cfa0ad2SJack F Vogel extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 4538cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_EXTCNF_CTRL, extcnf_ctrl); 4548cfa0ad2SJack F Vogel 4558cfa0ad2SJack F Vogel return; 4568cfa0ad2SJack F Vogel } 4578cfa0ad2SJack F Vogel 4588cfa0ad2SJack F Vogel /** 4598cfa0ad2SJack F Vogel * e1000_check_mng_mode_ich8lan - Checks management mode 4608cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 4618cfa0ad2SJack F Vogel * 4628cfa0ad2SJack F Vogel * This checks if the adapter has manageability enabled. 4638cfa0ad2SJack F Vogel * This is a function pointer entry point only called by read/write 4648cfa0ad2SJack F Vogel * routines for the PHY and NVM parts. 4658cfa0ad2SJack F Vogel **/ 4668cfa0ad2SJack F Vogel static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw) 4678cfa0ad2SJack F Vogel { 4688cfa0ad2SJack F Vogel u32 fwsm; 4698cfa0ad2SJack F Vogel 4708cfa0ad2SJack F Vogel DEBUGFUNC("e1000_check_mng_mode_ich8lan"); 4718cfa0ad2SJack F Vogel 4728cfa0ad2SJack F Vogel fwsm = E1000_READ_REG(hw, E1000_FWSM); 4738cfa0ad2SJack F Vogel 474daf9197cSJack F Vogel return (fwsm & E1000_FWSM_MODE_MASK) == 475daf9197cSJack F Vogel (E1000_ICH_MNG_IAMT_MODE << E1000_FWSM_MODE_SHIFT); 4768cfa0ad2SJack F Vogel } 4778cfa0ad2SJack F Vogel 4788cfa0ad2SJack F Vogel /** 4798cfa0ad2SJack F Vogel * e1000_check_reset_block_ich8lan - Check if PHY reset is blocked 4808cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 4818cfa0ad2SJack F Vogel * 4828cfa0ad2SJack F Vogel * Checks if firmware is blocking the reset of the PHY. 4838cfa0ad2SJack F Vogel * This is a function pointer entry point only called by 4848cfa0ad2SJack F Vogel * reset routines. 4858cfa0ad2SJack F Vogel **/ 4868cfa0ad2SJack F Vogel static s32 e1000_check_reset_block_ich8lan(struct e1000_hw *hw) 4878cfa0ad2SJack F Vogel { 4888cfa0ad2SJack F Vogel u32 fwsm; 4898cfa0ad2SJack F Vogel 4908cfa0ad2SJack F Vogel DEBUGFUNC("e1000_check_reset_block_ich8lan"); 4918cfa0ad2SJack F Vogel 4928cfa0ad2SJack F Vogel fwsm = E1000_READ_REG(hw, E1000_FWSM); 4938cfa0ad2SJack F Vogel 4948cfa0ad2SJack F Vogel return (fwsm & E1000_ICH_FWSM_RSPCIPHY) ? E1000_SUCCESS 4958cfa0ad2SJack F Vogel : E1000_BLK_PHY_RESET; 4968cfa0ad2SJack F Vogel } 4978cfa0ad2SJack F Vogel 4988cfa0ad2SJack F Vogel /** 4998cfa0ad2SJack F Vogel * e1000_phy_force_speed_duplex_ich8lan - Force PHY speed & duplex 5008cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 5018cfa0ad2SJack F Vogel * 5028cfa0ad2SJack F Vogel * Forces the speed and duplex settings of the PHY. 5038cfa0ad2SJack F Vogel * This is a function pointer entry point only called by 5048cfa0ad2SJack F Vogel * PHY setup routines. 5058cfa0ad2SJack F Vogel **/ 5068cfa0ad2SJack F Vogel static s32 e1000_phy_force_speed_duplex_ich8lan(struct e1000_hw *hw) 5078cfa0ad2SJack F Vogel { 5088cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 5098cfa0ad2SJack F Vogel s32 ret_val; 5108cfa0ad2SJack F Vogel u16 data; 5118cfa0ad2SJack F Vogel bool link; 5128cfa0ad2SJack F Vogel 5138cfa0ad2SJack F Vogel DEBUGFUNC("e1000_phy_force_speed_duplex_ich8lan"); 5148cfa0ad2SJack F Vogel 5158cfa0ad2SJack F Vogel if (phy->type != e1000_phy_ife) { 5168cfa0ad2SJack F Vogel ret_val = e1000_phy_force_speed_duplex_igp(hw); 5178cfa0ad2SJack F Vogel goto out; 5188cfa0ad2SJack F Vogel } 5198cfa0ad2SJack F Vogel 5208cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, PHY_CONTROL, &data); 5218cfa0ad2SJack F Vogel if (ret_val) 5228cfa0ad2SJack F Vogel goto out; 5238cfa0ad2SJack F Vogel 5248cfa0ad2SJack F Vogel e1000_phy_force_speed_duplex_setup(hw, &data); 5258cfa0ad2SJack F Vogel 5268cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, PHY_CONTROL, data); 5278cfa0ad2SJack F Vogel if (ret_val) 5288cfa0ad2SJack F Vogel goto out; 5298cfa0ad2SJack F Vogel 5308cfa0ad2SJack F Vogel /* Disable MDI-X support for 10/100 */ 5318cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 5328cfa0ad2SJack F Vogel if (ret_val) 5338cfa0ad2SJack F Vogel goto out; 5348cfa0ad2SJack F Vogel 5358cfa0ad2SJack F Vogel data &= ~IFE_PMC_AUTO_MDIX; 5368cfa0ad2SJack F Vogel data &= ~IFE_PMC_FORCE_MDIX; 5378cfa0ad2SJack F Vogel 5388cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, data); 5398cfa0ad2SJack F Vogel if (ret_val) 5408cfa0ad2SJack F Vogel goto out; 5418cfa0ad2SJack F Vogel 5428cfa0ad2SJack F Vogel DEBUGOUT1("IFE PMC: %X\n", data); 5438cfa0ad2SJack F Vogel 5448cfa0ad2SJack F Vogel usec_delay(1); 5458cfa0ad2SJack F Vogel 5468cfa0ad2SJack F Vogel if (phy->autoneg_wait_to_complete) { 5478cfa0ad2SJack F Vogel DEBUGOUT("Waiting for forced speed/duplex link on IFE phy.\n"); 5488cfa0ad2SJack F Vogel 5498cfa0ad2SJack F Vogel ret_val = e1000_phy_has_link_generic(hw, 5508cfa0ad2SJack F Vogel PHY_FORCE_LIMIT, 5518cfa0ad2SJack F Vogel 100000, 5528cfa0ad2SJack F Vogel &link); 5538cfa0ad2SJack F Vogel if (ret_val) 5548cfa0ad2SJack F Vogel goto out; 5558cfa0ad2SJack F Vogel 556daf9197cSJack F Vogel if (!link) 5578cfa0ad2SJack F Vogel DEBUGOUT("Link taking longer than expected.\n"); 5588cfa0ad2SJack F Vogel 5598cfa0ad2SJack F Vogel /* Try once more */ 5608cfa0ad2SJack F Vogel ret_val = e1000_phy_has_link_generic(hw, 5618cfa0ad2SJack F Vogel PHY_FORCE_LIMIT, 5628cfa0ad2SJack F Vogel 100000, 5638cfa0ad2SJack F Vogel &link); 5648cfa0ad2SJack F Vogel if (ret_val) 5658cfa0ad2SJack F Vogel goto out; 5668cfa0ad2SJack F Vogel } 5678cfa0ad2SJack F Vogel 5688cfa0ad2SJack F Vogel out: 5698cfa0ad2SJack F Vogel return ret_val; 5708cfa0ad2SJack F Vogel } 5718cfa0ad2SJack F Vogel 5728cfa0ad2SJack F Vogel /** 5738cfa0ad2SJack F Vogel * e1000_phy_hw_reset_ich8lan - Performs a PHY reset 5748cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 5758cfa0ad2SJack F Vogel * 5768cfa0ad2SJack F Vogel * Resets the PHY 5778cfa0ad2SJack F Vogel * This is a function pointer entry point called by drivers 5788cfa0ad2SJack F Vogel * or other shared routines. 5798cfa0ad2SJack F Vogel **/ 5808cfa0ad2SJack F Vogel static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw) 5818cfa0ad2SJack F Vogel { 5828cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 5838cfa0ad2SJack F Vogel u32 i, data, cnf_size, cnf_base_addr, sw_cfg_mask; 5848cfa0ad2SJack F Vogel s32 ret_val; 5858cfa0ad2SJack F Vogel u16 loop = E1000_ICH8_LAN_INIT_TIMEOUT; 5868cfa0ad2SJack F Vogel u16 word_addr, reg_data, reg_addr, phy_page = 0; 5878cfa0ad2SJack F Vogel 5888cfa0ad2SJack F Vogel DEBUGFUNC("e1000_phy_hw_reset_ich8lan"); 5898cfa0ad2SJack F Vogel 5908cfa0ad2SJack F Vogel ret_val = e1000_phy_hw_reset_generic(hw); 5918cfa0ad2SJack F Vogel if (ret_val) 5928cfa0ad2SJack F Vogel goto out; 5938cfa0ad2SJack F Vogel 5948cfa0ad2SJack F Vogel /* 5958cfa0ad2SJack F Vogel * Initialize the PHY from the NVM on ICH platforms. This 5968cfa0ad2SJack F Vogel * is needed due to an issue where the NVM configuration is 5978cfa0ad2SJack F Vogel * not properly autoloaded after power transitions. 5988cfa0ad2SJack F Vogel * Therefore, after each PHY reset, we will load the 5998cfa0ad2SJack F Vogel * configuration data out of the NVM manually. 6008cfa0ad2SJack F Vogel */ 6018cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich8lan && phy->type == e1000_phy_igp_3) { 6028cfa0ad2SJack F Vogel /* Check if SW needs configure the PHY */ 6038cfa0ad2SJack F Vogel if ((hw->device_id == E1000_DEV_ID_ICH8_IGP_M_AMT) || 6048cfa0ad2SJack F Vogel (hw->device_id == E1000_DEV_ID_ICH8_IGP_M)) 6058cfa0ad2SJack F Vogel sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG_ICH8M; 6068cfa0ad2SJack F Vogel else 6078cfa0ad2SJack F Vogel sw_cfg_mask = E1000_FEXTNVM_SW_CONFIG; 6088cfa0ad2SJack F Vogel 6098cfa0ad2SJack F Vogel data = E1000_READ_REG(hw, E1000_FEXTNVM); 6108cfa0ad2SJack F Vogel if (!(data & sw_cfg_mask)) 6118cfa0ad2SJack F Vogel goto out; 6128cfa0ad2SJack F Vogel 6138cfa0ad2SJack F Vogel /* Wait for basic configuration completes before proceeding*/ 6148cfa0ad2SJack F Vogel do { 6158cfa0ad2SJack F Vogel data = E1000_READ_REG(hw, E1000_STATUS); 6168cfa0ad2SJack F Vogel data &= E1000_STATUS_LAN_INIT_DONE; 6178cfa0ad2SJack F Vogel usec_delay(100); 6188cfa0ad2SJack F Vogel } while ((!data) && --loop); 6198cfa0ad2SJack F Vogel 6208cfa0ad2SJack F Vogel /* 6218cfa0ad2SJack F Vogel * If basic configuration is incomplete before the above loop 6228cfa0ad2SJack F Vogel * count reaches 0, loading the configuration from NVM will 6238cfa0ad2SJack F Vogel * leave the PHY in a bad state possibly resulting in no link. 6248cfa0ad2SJack F Vogel */ 625daf9197cSJack F Vogel if (loop == 0) 6268cfa0ad2SJack F Vogel DEBUGOUT("LAN_INIT_DONE not set, increase timeout\n"); 6278cfa0ad2SJack F Vogel 6288cfa0ad2SJack F Vogel /* Clear the Init Done bit for the next init event */ 6298cfa0ad2SJack F Vogel data = E1000_READ_REG(hw, E1000_STATUS); 6308cfa0ad2SJack F Vogel data &= ~E1000_STATUS_LAN_INIT_DONE; 6318cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_STATUS, data); 6328cfa0ad2SJack F Vogel 6338cfa0ad2SJack F Vogel /* 6348cfa0ad2SJack F Vogel * Make sure HW does not configure LCD from PHY 6358cfa0ad2SJack F Vogel * extended configuration before SW configuration 6368cfa0ad2SJack F Vogel */ 6378cfa0ad2SJack F Vogel data = E1000_READ_REG(hw, E1000_EXTCNF_CTRL); 6388cfa0ad2SJack F Vogel if (data & E1000_EXTCNF_CTRL_LCD_WRITE_ENABLE) 6398cfa0ad2SJack F Vogel goto out; 6408cfa0ad2SJack F Vogel 6418cfa0ad2SJack F Vogel cnf_size = E1000_READ_REG(hw, E1000_EXTCNF_SIZE); 6428cfa0ad2SJack F Vogel cnf_size &= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_MASK; 6438cfa0ad2SJack F Vogel cnf_size >>= E1000_EXTCNF_SIZE_EXT_PCIE_LENGTH_SHIFT; 6448cfa0ad2SJack F Vogel if (!cnf_size) 6458cfa0ad2SJack F Vogel goto out; 6468cfa0ad2SJack F Vogel 6478cfa0ad2SJack F Vogel cnf_base_addr = data & E1000_EXTCNF_CTRL_EXT_CNF_POINTER_MASK; 6488cfa0ad2SJack F Vogel cnf_base_addr >>= E1000_EXTCNF_CTRL_EXT_CNF_POINTER_SHIFT; 6498cfa0ad2SJack F Vogel 650daf9197cSJack F Vogel /* Configure LCD from extended configuration region. */ 6518cfa0ad2SJack F Vogel 6528cfa0ad2SJack F Vogel /* cnf_base_addr is in DWORD */ 6538cfa0ad2SJack F Vogel word_addr = (u16)(cnf_base_addr << 1); 6548cfa0ad2SJack F Vogel 6558cfa0ad2SJack F Vogel for (i = 0; i < cnf_size; i++) { 656daf9197cSJack F Vogel ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2), 1, 6578cfa0ad2SJack F Vogel ®_data); 6588cfa0ad2SJack F Vogel if (ret_val) 6598cfa0ad2SJack F Vogel goto out; 6608cfa0ad2SJack F Vogel 661daf9197cSJack F Vogel ret_val = hw->nvm.ops.read(hw, (word_addr + i * 2 + 1), 662daf9197cSJack F Vogel 1, ®_addr); 6638cfa0ad2SJack F Vogel if (ret_val) 6648cfa0ad2SJack F Vogel goto out; 6658cfa0ad2SJack F Vogel 6668cfa0ad2SJack F Vogel /* Save off the PHY page for future writes. */ 6678cfa0ad2SJack F Vogel if (reg_addr == IGP01E1000_PHY_PAGE_SELECT) { 6688cfa0ad2SJack F Vogel phy_page = reg_data; 6698cfa0ad2SJack F Vogel continue; 6708cfa0ad2SJack F Vogel } 6718cfa0ad2SJack F Vogel 6728cfa0ad2SJack F Vogel reg_addr |= phy_page; 6738cfa0ad2SJack F Vogel 674daf9197cSJack F Vogel ret_val = phy->ops.write_reg(hw, (u32)reg_addr, reg_data); 6758cfa0ad2SJack F Vogel if (ret_val) 6768cfa0ad2SJack F Vogel goto out; 6778cfa0ad2SJack F Vogel } 6788cfa0ad2SJack F Vogel } 6798cfa0ad2SJack F Vogel 6808cfa0ad2SJack F Vogel out: 6818cfa0ad2SJack F Vogel return ret_val; 6828cfa0ad2SJack F Vogel } 6838cfa0ad2SJack F Vogel 6848cfa0ad2SJack F Vogel /** 6858cfa0ad2SJack F Vogel * e1000_get_phy_info_ich8lan - Calls appropriate PHY type get_phy_info 6868cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 6878cfa0ad2SJack F Vogel * 6888cfa0ad2SJack F Vogel * Wrapper for calling the get_phy_info routines for the appropriate phy type. 6898cfa0ad2SJack F Vogel **/ 6908cfa0ad2SJack F Vogel static s32 e1000_get_phy_info_ich8lan(struct e1000_hw *hw) 6918cfa0ad2SJack F Vogel { 6928cfa0ad2SJack F Vogel s32 ret_val = -E1000_ERR_PHY_TYPE; 6938cfa0ad2SJack F Vogel 6948cfa0ad2SJack F Vogel DEBUGFUNC("e1000_get_phy_info_ich8lan"); 6958cfa0ad2SJack F Vogel 6968cfa0ad2SJack F Vogel switch (hw->phy.type) { 6978cfa0ad2SJack F Vogel case e1000_phy_ife: 6988cfa0ad2SJack F Vogel ret_val = e1000_get_phy_info_ife_ich8lan(hw); 6998cfa0ad2SJack F Vogel break; 7008cfa0ad2SJack F Vogel case e1000_phy_igp_3: 7018cfa0ad2SJack F Vogel case e1000_phy_bm: 7028cfa0ad2SJack F Vogel ret_val = e1000_get_phy_info_igp(hw); 7038cfa0ad2SJack F Vogel break; 7048cfa0ad2SJack F Vogel default: 7058cfa0ad2SJack F Vogel break; 7068cfa0ad2SJack F Vogel } 7078cfa0ad2SJack F Vogel 7088cfa0ad2SJack F Vogel return ret_val; 7098cfa0ad2SJack F Vogel } 7108cfa0ad2SJack F Vogel 7118cfa0ad2SJack F Vogel /** 7128cfa0ad2SJack F Vogel * e1000_get_phy_info_ife_ich8lan - Retrieves various IFE PHY states 7138cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 7148cfa0ad2SJack F Vogel * 7158cfa0ad2SJack F Vogel * Populates "phy" structure with various feature states. 7168cfa0ad2SJack F Vogel * This function is only called by other family-specific 7178cfa0ad2SJack F Vogel * routines. 7188cfa0ad2SJack F Vogel **/ 7198cfa0ad2SJack F Vogel static s32 e1000_get_phy_info_ife_ich8lan(struct e1000_hw *hw) 7208cfa0ad2SJack F Vogel { 7218cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 7228cfa0ad2SJack F Vogel s32 ret_val; 7238cfa0ad2SJack F Vogel u16 data; 7248cfa0ad2SJack F Vogel bool link; 7258cfa0ad2SJack F Vogel 7268cfa0ad2SJack F Vogel DEBUGFUNC("e1000_get_phy_info_ife_ich8lan"); 7278cfa0ad2SJack F Vogel 7288cfa0ad2SJack F Vogel ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 7298cfa0ad2SJack F Vogel if (ret_val) 7308cfa0ad2SJack F Vogel goto out; 7318cfa0ad2SJack F Vogel 7328cfa0ad2SJack F Vogel if (!link) { 7338cfa0ad2SJack F Vogel DEBUGOUT("Phy info is only valid if link is up\n"); 7348cfa0ad2SJack F Vogel ret_val = -E1000_ERR_CONFIG; 7358cfa0ad2SJack F Vogel goto out; 7368cfa0ad2SJack F Vogel } 7378cfa0ad2SJack F Vogel 7388cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, IFE_PHY_SPECIAL_CONTROL, &data); 7398cfa0ad2SJack F Vogel if (ret_val) 7408cfa0ad2SJack F Vogel goto out; 7418cfa0ad2SJack F Vogel phy->polarity_correction = (data & IFE_PSC_AUTO_POLARITY_DISABLE) 7428cfa0ad2SJack F Vogel ? FALSE : TRUE; 7438cfa0ad2SJack F Vogel 7448cfa0ad2SJack F Vogel if (phy->polarity_correction) { 7458cfa0ad2SJack F Vogel ret_val = e1000_check_polarity_ife_ich8lan(hw); 7468cfa0ad2SJack F Vogel if (ret_val) 7478cfa0ad2SJack F Vogel goto out; 7488cfa0ad2SJack F Vogel } else { 7498cfa0ad2SJack F Vogel /* Polarity is forced */ 7508cfa0ad2SJack F Vogel phy->cable_polarity = (data & IFE_PSC_FORCE_POLARITY) 7518cfa0ad2SJack F Vogel ? e1000_rev_polarity_reversed 7528cfa0ad2SJack F Vogel : e1000_rev_polarity_normal; 7538cfa0ad2SJack F Vogel } 7548cfa0ad2SJack F Vogel 7558cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, &data); 7568cfa0ad2SJack F Vogel if (ret_val) 7578cfa0ad2SJack F Vogel goto out; 7588cfa0ad2SJack F Vogel 7598cfa0ad2SJack F Vogel phy->is_mdix = (data & IFE_PMC_MDIX_STATUS) ? TRUE : FALSE; 7608cfa0ad2SJack F Vogel 7618cfa0ad2SJack F Vogel /* The following parameters are undefined for 10/100 operation. */ 7628cfa0ad2SJack F Vogel phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; 7638cfa0ad2SJack F Vogel phy->local_rx = e1000_1000t_rx_status_undefined; 7648cfa0ad2SJack F Vogel phy->remote_rx = e1000_1000t_rx_status_undefined; 7658cfa0ad2SJack F Vogel 7668cfa0ad2SJack F Vogel out: 7678cfa0ad2SJack F Vogel return ret_val; 7688cfa0ad2SJack F Vogel } 7698cfa0ad2SJack F Vogel 7708cfa0ad2SJack F Vogel /** 7718cfa0ad2SJack F Vogel * e1000_check_polarity_ife_ich8lan - Check cable polarity for IFE PHY 7728cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 7738cfa0ad2SJack F Vogel * 7748cfa0ad2SJack F Vogel * Polarity is determined on the polarity reversal feature being enabled. 7758cfa0ad2SJack F Vogel * This function is only called by other family-specific 7768cfa0ad2SJack F Vogel * routines. 7778cfa0ad2SJack F Vogel **/ 7788cfa0ad2SJack F Vogel static s32 e1000_check_polarity_ife_ich8lan(struct e1000_hw *hw) 7798cfa0ad2SJack F Vogel { 7808cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 7818cfa0ad2SJack F Vogel s32 ret_val; 7828cfa0ad2SJack F Vogel u16 phy_data, offset, mask; 7838cfa0ad2SJack F Vogel 7848cfa0ad2SJack F Vogel DEBUGFUNC("e1000_check_polarity_ife_ich8lan"); 7858cfa0ad2SJack F Vogel 7868cfa0ad2SJack F Vogel /* 787daf9197cSJack F Vogel * Polarity is determined based on the reversal feature being enabled. 7888cfa0ad2SJack F Vogel */ 7898cfa0ad2SJack F Vogel if (phy->polarity_correction) { 7908cfa0ad2SJack F Vogel offset = IFE_PHY_EXTENDED_STATUS_CONTROL; 7918cfa0ad2SJack F Vogel mask = IFE_PESC_POLARITY_REVERSED; 7928cfa0ad2SJack F Vogel } else { 7938cfa0ad2SJack F Vogel offset = IFE_PHY_SPECIAL_CONTROL; 7948cfa0ad2SJack F Vogel mask = IFE_PSC_FORCE_POLARITY; 7958cfa0ad2SJack F Vogel } 7968cfa0ad2SJack F Vogel 7978cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, offset, &phy_data); 7988cfa0ad2SJack F Vogel 7998cfa0ad2SJack F Vogel if (!ret_val) 8008cfa0ad2SJack F Vogel phy->cable_polarity = (phy_data & mask) 8018cfa0ad2SJack F Vogel ? e1000_rev_polarity_reversed 8028cfa0ad2SJack F Vogel : e1000_rev_polarity_normal; 8038cfa0ad2SJack F Vogel 8048cfa0ad2SJack F Vogel return ret_val; 8058cfa0ad2SJack F Vogel } 8068cfa0ad2SJack F Vogel 8078cfa0ad2SJack F Vogel /** 8088cfa0ad2SJack F Vogel * e1000_set_d0_lplu_state_ich8lan - Set Low Power Linkup D0 state 8098cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 8108cfa0ad2SJack F Vogel * @active: TRUE to enable LPLU, FALSE to disable 8118cfa0ad2SJack F Vogel * 8128cfa0ad2SJack F Vogel * Sets the LPLU D0 state according to the active flag. When 8138cfa0ad2SJack F Vogel * activating LPLU this function also disables smart speed 8148cfa0ad2SJack F Vogel * and vice versa. LPLU will not be activated unless the 8158cfa0ad2SJack F Vogel * device autonegotiation advertisement meets standards of 8168cfa0ad2SJack F Vogel * either 10 or 10/100 or 10/100/1000 at all duplexes. 8178cfa0ad2SJack F Vogel * This is a function pointer entry point only called by 8188cfa0ad2SJack F Vogel * PHY setup routines. 8198cfa0ad2SJack F Vogel **/ 820daf9197cSJack F Vogel static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active) 8218cfa0ad2SJack F Vogel { 8228cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 8238cfa0ad2SJack F Vogel u32 phy_ctrl; 8248cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 8258cfa0ad2SJack F Vogel u16 data; 8268cfa0ad2SJack F Vogel 8278cfa0ad2SJack F Vogel DEBUGFUNC("e1000_set_d0_lplu_state_ich8lan"); 8288cfa0ad2SJack F Vogel 8298cfa0ad2SJack F Vogel if (phy->type == e1000_phy_ife) 8308cfa0ad2SJack F Vogel goto out; 8318cfa0ad2SJack F Vogel 8328cfa0ad2SJack F Vogel phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL); 8338cfa0ad2SJack F Vogel 8348cfa0ad2SJack F Vogel if (active) { 8358cfa0ad2SJack F Vogel phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU; 8368cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 8378cfa0ad2SJack F Vogel 8388cfa0ad2SJack F Vogel /* 8398cfa0ad2SJack F Vogel * Call gig speed drop workaround on LPLU before accessing 8408cfa0ad2SJack F Vogel * any PHY registers 8418cfa0ad2SJack F Vogel */ 8428cfa0ad2SJack F Vogel if ((hw->mac.type == e1000_ich8lan) && 8438cfa0ad2SJack F Vogel (hw->phy.type == e1000_phy_igp_3)) 8448cfa0ad2SJack F Vogel e1000_gig_downshift_workaround_ich8lan(hw); 8458cfa0ad2SJack F Vogel 8468cfa0ad2SJack F Vogel /* When LPLU is enabled, we should disable SmartSpeed */ 8478cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 8488cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8498cfa0ad2SJack F Vogel &data); 8508cfa0ad2SJack F Vogel data &= ~IGP01E1000_PSCFR_SMART_SPEED; 8518cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 8528cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8538cfa0ad2SJack F Vogel data); 8548cfa0ad2SJack F Vogel if (ret_val) 8558cfa0ad2SJack F Vogel goto out; 8568cfa0ad2SJack F Vogel } else { 8578cfa0ad2SJack F Vogel phy_ctrl &= ~E1000_PHY_CTRL_D0A_LPLU; 8588cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 8598cfa0ad2SJack F Vogel 8608cfa0ad2SJack F Vogel /* 8618cfa0ad2SJack F Vogel * LPLU and SmartSpeed are mutually exclusive. LPLU is used 8628cfa0ad2SJack F Vogel * during Dx states where the power conservation is most 8638cfa0ad2SJack F Vogel * important. During driver activity we should enable 8648cfa0ad2SJack F Vogel * SmartSpeed, so performance is maintained. 8658cfa0ad2SJack F Vogel */ 8668cfa0ad2SJack F Vogel if (phy->smart_speed == e1000_smart_speed_on) { 8678cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 8688cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8698cfa0ad2SJack F Vogel &data); 8708cfa0ad2SJack F Vogel if (ret_val) 8718cfa0ad2SJack F Vogel goto out; 8728cfa0ad2SJack F Vogel 8738cfa0ad2SJack F Vogel data |= IGP01E1000_PSCFR_SMART_SPEED; 8748cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 8758cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8768cfa0ad2SJack F Vogel data); 8778cfa0ad2SJack F Vogel if (ret_val) 8788cfa0ad2SJack F Vogel goto out; 8798cfa0ad2SJack F Vogel } else if (phy->smart_speed == e1000_smart_speed_off) { 8808cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 8818cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8828cfa0ad2SJack F Vogel &data); 8838cfa0ad2SJack F Vogel if (ret_val) 8848cfa0ad2SJack F Vogel goto out; 8858cfa0ad2SJack F Vogel 8868cfa0ad2SJack F Vogel data &= ~IGP01E1000_PSCFR_SMART_SPEED; 8878cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 8888cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 8898cfa0ad2SJack F Vogel data); 8908cfa0ad2SJack F Vogel if (ret_val) 8918cfa0ad2SJack F Vogel goto out; 8928cfa0ad2SJack F Vogel } 8938cfa0ad2SJack F Vogel } 8948cfa0ad2SJack F Vogel 8958cfa0ad2SJack F Vogel out: 8968cfa0ad2SJack F Vogel return ret_val; 8978cfa0ad2SJack F Vogel } 8988cfa0ad2SJack F Vogel 8998cfa0ad2SJack F Vogel /** 9008cfa0ad2SJack F Vogel * e1000_set_d3_lplu_state_ich8lan - Set Low Power Linkup D3 state 9018cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 9028cfa0ad2SJack F Vogel * @active: TRUE to enable LPLU, FALSE to disable 9038cfa0ad2SJack F Vogel * 9048cfa0ad2SJack F Vogel * Sets the LPLU D3 state according to the active flag. When 9058cfa0ad2SJack F Vogel * activating LPLU this function also disables smart speed 9068cfa0ad2SJack F Vogel * and vice versa. LPLU will not be activated unless the 9078cfa0ad2SJack F Vogel * device autonegotiation advertisement meets standards of 9088cfa0ad2SJack F Vogel * either 10 or 10/100 or 10/100/1000 at all duplexes. 9098cfa0ad2SJack F Vogel * This is a function pointer entry point only called by 9108cfa0ad2SJack F Vogel * PHY setup routines. 9118cfa0ad2SJack F Vogel **/ 912daf9197cSJack F Vogel static s32 e1000_set_d3_lplu_state_ich8lan(struct e1000_hw *hw, bool active) 9138cfa0ad2SJack F Vogel { 9148cfa0ad2SJack F Vogel struct e1000_phy_info *phy = &hw->phy; 9158cfa0ad2SJack F Vogel u32 phy_ctrl; 9168cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 9178cfa0ad2SJack F Vogel u16 data; 9188cfa0ad2SJack F Vogel 9198cfa0ad2SJack F Vogel DEBUGFUNC("e1000_set_d3_lplu_state_ich8lan"); 9208cfa0ad2SJack F Vogel 9218cfa0ad2SJack F Vogel phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL); 9228cfa0ad2SJack F Vogel 9238cfa0ad2SJack F Vogel if (!active) { 9248cfa0ad2SJack F Vogel phy_ctrl &= ~E1000_PHY_CTRL_NOND0A_LPLU; 9258cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 9268cfa0ad2SJack F Vogel /* 9278cfa0ad2SJack F Vogel * LPLU and SmartSpeed are mutually exclusive. LPLU is used 9288cfa0ad2SJack F Vogel * during Dx states where the power conservation is most 9298cfa0ad2SJack F Vogel * important. During driver activity we should enable 9308cfa0ad2SJack F Vogel * SmartSpeed, so performance is maintained. 9318cfa0ad2SJack F Vogel */ 9328cfa0ad2SJack F Vogel if (phy->smart_speed == e1000_smart_speed_on) { 9338cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 9348cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9358cfa0ad2SJack F Vogel &data); 9368cfa0ad2SJack F Vogel if (ret_val) 9378cfa0ad2SJack F Vogel goto out; 9388cfa0ad2SJack F Vogel 9398cfa0ad2SJack F Vogel data |= IGP01E1000_PSCFR_SMART_SPEED; 9408cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 9418cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9428cfa0ad2SJack F Vogel data); 9438cfa0ad2SJack F Vogel if (ret_val) 9448cfa0ad2SJack F Vogel goto out; 9458cfa0ad2SJack F Vogel } else if (phy->smart_speed == e1000_smart_speed_off) { 9468cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 9478cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9488cfa0ad2SJack F Vogel &data); 9498cfa0ad2SJack F Vogel if (ret_val) 9508cfa0ad2SJack F Vogel goto out; 9518cfa0ad2SJack F Vogel 9528cfa0ad2SJack F Vogel data &= ~IGP01E1000_PSCFR_SMART_SPEED; 9538cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 9548cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9558cfa0ad2SJack F Vogel data); 9568cfa0ad2SJack F Vogel if (ret_val) 9578cfa0ad2SJack F Vogel goto out; 9588cfa0ad2SJack F Vogel } 9598cfa0ad2SJack F Vogel } else if ((phy->autoneg_advertised == E1000_ALL_SPEED_DUPLEX) || 9608cfa0ad2SJack F Vogel (phy->autoneg_advertised == E1000_ALL_NOT_GIG) || 9618cfa0ad2SJack F Vogel (phy->autoneg_advertised == E1000_ALL_10_SPEED)) { 9628cfa0ad2SJack F Vogel phy_ctrl |= E1000_PHY_CTRL_NOND0A_LPLU; 9638cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 9648cfa0ad2SJack F Vogel 9658cfa0ad2SJack F Vogel /* 9668cfa0ad2SJack F Vogel * Call gig speed drop workaround on LPLU before accessing 9678cfa0ad2SJack F Vogel * any PHY registers 9688cfa0ad2SJack F Vogel */ 9698cfa0ad2SJack F Vogel if ((hw->mac.type == e1000_ich8lan) && 9708cfa0ad2SJack F Vogel (hw->phy.type == e1000_phy_igp_3)) 9718cfa0ad2SJack F Vogel e1000_gig_downshift_workaround_ich8lan(hw); 9728cfa0ad2SJack F Vogel 9738cfa0ad2SJack F Vogel /* When LPLU is enabled, we should disable SmartSpeed */ 9748cfa0ad2SJack F Vogel ret_val = phy->ops.read_reg(hw, 9758cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9768cfa0ad2SJack F Vogel &data); 9778cfa0ad2SJack F Vogel if (ret_val) 9788cfa0ad2SJack F Vogel goto out; 9798cfa0ad2SJack F Vogel 9808cfa0ad2SJack F Vogel data &= ~IGP01E1000_PSCFR_SMART_SPEED; 9818cfa0ad2SJack F Vogel ret_val = phy->ops.write_reg(hw, 9828cfa0ad2SJack F Vogel IGP01E1000_PHY_PORT_CONFIG, 9838cfa0ad2SJack F Vogel data); 9848cfa0ad2SJack F Vogel } 9858cfa0ad2SJack F Vogel 9868cfa0ad2SJack F Vogel out: 9878cfa0ad2SJack F Vogel return ret_val; 9888cfa0ad2SJack F Vogel } 9898cfa0ad2SJack F Vogel 9908cfa0ad2SJack F Vogel /** 9918cfa0ad2SJack F Vogel * e1000_valid_nvm_bank_detect_ich8lan - finds out the valid bank 0 or 1 9928cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 9938cfa0ad2SJack F Vogel * @bank: pointer to the variable that returns the active bank 9948cfa0ad2SJack F Vogel * 9958cfa0ad2SJack F Vogel * Reads signature byte from the NVM using the flash access registers. 9968cfa0ad2SJack F Vogel **/ 9978cfa0ad2SJack F Vogel static s32 e1000_valid_nvm_bank_detect_ich8lan(struct e1000_hw *hw, u32 *bank) 9988cfa0ad2SJack F Vogel { 9998cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 10008cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 10018cfa0ad2SJack F Vogel /* flash bank size is in words */ 10028cfa0ad2SJack F Vogel u32 bank1_offset = nvm->flash_bank_size * sizeof(u16); 10038cfa0ad2SJack F Vogel u32 act_offset = E1000_ICH_NVM_SIG_WORD * 2 + 1; 10048cfa0ad2SJack F Vogel u8 bank_high_byte = 0; 10058cfa0ad2SJack F Vogel 10068cfa0ad2SJack F Vogel if (hw->mac.type != e1000_ich10lan) { 10078cfa0ad2SJack F Vogel if (E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_SEC1VAL) 10088cfa0ad2SJack F Vogel *bank = 1; 10098cfa0ad2SJack F Vogel else 10108cfa0ad2SJack F Vogel *bank = 0; 1011daf9197cSJack F Vogel } else { 10128cfa0ad2SJack F Vogel /* 10138cfa0ad2SJack F Vogel * Make sure the signature for bank 0 is valid, 10148cfa0ad2SJack F Vogel * if not check for bank1 10158cfa0ad2SJack F Vogel */ 10168cfa0ad2SJack F Vogel e1000_read_flash_byte_ich8lan(hw, act_offset, &bank_high_byte); 10178cfa0ad2SJack F Vogel if ((bank_high_byte & 0xC0) == 0x80) { 10188cfa0ad2SJack F Vogel *bank = 0; 10198cfa0ad2SJack F Vogel } else { 10208cfa0ad2SJack F Vogel /* 10218cfa0ad2SJack F Vogel * find if segment 1 is valid by verifying 10228cfa0ad2SJack F Vogel * bit 15:14 = 10b in word 0x13 10238cfa0ad2SJack F Vogel */ 10248cfa0ad2SJack F Vogel e1000_read_flash_byte_ich8lan(hw, 10258cfa0ad2SJack F Vogel act_offset + bank1_offset, 10268cfa0ad2SJack F Vogel &bank_high_byte); 10278cfa0ad2SJack F Vogel 10288cfa0ad2SJack F Vogel /* bank1 has a valid signature equivalent to SEC1V */ 10298cfa0ad2SJack F Vogel if ((bank_high_byte & 0xC0) == 0x80) { 10308cfa0ad2SJack F Vogel *bank = 1; 10318cfa0ad2SJack F Vogel } else { 10328cfa0ad2SJack F Vogel DEBUGOUT("ERROR: EEPROM not present\n"); 10338cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 10348cfa0ad2SJack F Vogel } 10358cfa0ad2SJack F Vogel } 10368cfa0ad2SJack F Vogel } 10378cfa0ad2SJack F Vogel 10388cfa0ad2SJack F Vogel return ret_val; 10398cfa0ad2SJack F Vogel } 10408cfa0ad2SJack F Vogel 10418cfa0ad2SJack F Vogel /** 10428cfa0ad2SJack F Vogel * e1000_read_nvm_ich8lan - Read word(s) from the NVM 10438cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 10448cfa0ad2SJack F Vogel * @offset: The offset (in bytes) of the word(s) to read. 10458cfa0ad2SJack F Vogel * @words: Size of data to read in words 10468cfa0ad2SJack F Vogel * @data: Pointer to the word(s) to read at offset. 10478cfa0ad2SJack F Vogel * 10488cfa0ad2SJack F Vogel * Reads a word(s) from the NVM using the flash access registers. 10498cfa0ad2SJack F Vogel **/ 10508cfa0ad2SJack F Vogel static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, 10518cfa0ad2SJack F Vogel u16 *data) 10528cfa0ad2SJack F Vogel { 10538cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 1054daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 10558cfa0ad2SJack F Vogel u32 act_offset; 10568cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 10578cfa0ad2SJack F Vogel u32 bank = 0; 10588cfa0ad2SJack F Vogel u16 i, word; 10598cfa0ad2SJack F Vogel 10608cfa0ad2SJack F Vogel DEBUGFUNC("e1000_read_nvm_ich8lan"); 10618cfa0ad2SJack F Vogel 10628cfa0ad2SJack F Vogel if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || 10638cfa0ad2SJack F Vogel (words == 0)) { 10648cfa0ad2SJack F Vogel DEBUGOUT("nvm parameter(s) out of bounds\n"); 10658cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 10668cfa0ad2SJack F Vogel goto out; 10678cfa0ad2SJack F Vogel } 10688cfa0ad2SJack F Vogel 10698cfa0ad2SJack F Vogel ret_val = nvm->ops.acquire(hw); 10708cfa0ad2SJack F Vogel if (ret_val) 10718cfa0ad2SJack F Vogel goto out; 10728cfa0ad2SJack F Vogel 10738cfa0ad2SJack F Vogel ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); 10748cfa0ad2SJack F Vogel if (ret_val != E1000_SUCCESS) 10758cfa0ad2SJack F Vogel goto out; 10768cfa0ad2SJack F Vogel 10778cfa0ad2SJack F Vogel act_offset = (bank) ? nvm->flash_bank_size : 0; 10788cfa0ad2SJack F Vogel act_offset += offset; 10798cfa0ad2SJack F Vogel 10808cfa0ad2SJack F Vogel for (i = 0; i < words; i++) { 10818cfa0ad2SJack F Vogel if ((dev_spec->shadow_ram) && 10828cfa0ad2SJack F Vogel (dev_spec->shadow_ram[offset+i].modified)) { 10838cfa0ad2SJack F Vogel data[i] = dev_spec->shadow_ram[offset+i].value; 10848cfa0ad2SJack F Vogel } else { 10858cfa0ad2SJack F Vogel ret_val = e1000_read_flash_word_ich8lan(hw, 10868cfa0ad2SJack F Vogel act_offset + i, 10878cfa0ad2SJack F Vogel &word); 10888cfa0ad2SJack F Vogel if (ret_val) 10898cfa0ad2SJack F Vogel break; 10908cfa0ad2SJack F Vogel data[i] = word; 10918cfa0ad2SJack F Vogel } 10928cfa0ad2SJack F Vogel } 10938cfa0ad2SJack F Vogel 10948cfa0ad2SJack F Vogel nvm->ops.release(hw); 10958cfa0ad2SJack F Vogel 10968cfa0ad2SJack F Vogel out: 10978cfa0ad2SJack F Vogel return ret_val; 10988cfa0ad2SJack F Vogel } 10998cfa0ad2SJack F Vogel 11008cfa0ad2SJack F Vogel /** 11018cfa0ad2SJack F Vogel * e1000_flash_cycle_init_ich8lan - Initialize flash 11028cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 11038cfa0ad2SJack F Vogel * 11048cfa0ad2SJack F Vogel * This function does initial flash setup so that a new read/write/erase cycle 11058cfa0ad2SJack F Vogel * can be started. 11068cfa0ad2SJack F Vogel **/ 11078cfa0ad2SJack F Vogel static s32 e1000_flash_cycle_init_ich8lan(struct e1000_hw *hw) 11088cfa0ad2SJack F Vogel { 11098cfa0ad2SJack F Vogel union ich8_hws_flash_status hsfsts; 11108cfa0ad2SJack F Vogel s32 ret_val = -E1000_ERR_NVM; 11118cfa0ad2SJack F Vogel s32 i = 0; 11128cfa0ad2SJack F Vogel 11138cfa0ad2SJack F Vogel DEBUGFUNC("e1000_flash_cycle_init_ich8lan"); 11148cfa0ad2SJack F Vogel 11158cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS); 11168cfa0ad2SJack F Vogel 11178cfa0ad2SJack F Vogel /* Check if the flash descriptor is valid */ 11188cfa0ad2SJack F Vogel if (hsfsts.hsf_status.fldesvalid == 0) { 11198cfa0ad2SJack F Vogel DEBUGOUT("Flash descriptor invalid. " 11208cfa0ad2SJack F Vogel "SW Sequencing must be used."); 11218cfa0ad2SJack F Vogel goto out; 11228cfa0ad2SJack F Vogel } 11238cfa0ad2SJack F Vogel 11248cfa0ad2SJack F Vogel /* Clear FCERR and DAEL in hw status by writing 1 */ 11258cfa0ad2SJack F Vogel hsfsts.hsf_status.flcerr = 1; 11268cfa0ad2SJack F Vogel hsfsts.hsf_status.dael = 1; 11278cfa0ad2SJack F Vogel 11288cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval); 11298cfa0ad2SJack F Vogel 11308cfa0ad2SJack F Vogel /* 11318cfa0ad2SJack F Vogel * Either we should have a hardware SPI cycle in progress 11328cfa0ad2SJack F Vogel * bit to check against, in order to start a new cycle or 11338cfa0ad2SJack F Vogel * FDONE bit should be changed in the hardware so that it 11348cfa0ad2SJack F Vogel * is 1 after hardware reset, which can then be used as an 11358cfa0ad2SJack F Vogel * indication whether a cycle is in progress or has been 11368cfa0ad2SJack F Vogel * completed. 11378cfa0ad2SJack F Vogel */ 11388cfa0ad2SJack F Vogel 11398cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcinprog == 0) { 11408cfa0ad2SJack F Vogel /* 11418cfa0ad2SJack F Vogel * There is no cycle running at present, 11428cfa0ad2SJack F Vogel * so we can start a cycle. 11438cfa0ad2SJack F Vogel * Begin by setting Flash Cycle Done. 11448cfa0ad2SJack F Vogel */ 11458cfa0ad2SJack F Vogel hsfsts.hsf_status.flcdone = 1; 11468cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, hsfsts.regval); 11478cfa0ad2SJack F Vogel ret_val = E1000_SUCCESS; 11488cfa0ad2SJack F Vogel } else { 11498cfa0ad2SJack F Vogel /* 11508cfa0ad2SJack F Vogel * Otherwise poll for sometime so the current 11518cfa0ad2SJack F Vogel * cycle has a chance to end before giving up. 11528cfa0ad2SJack F Vogel */ 11538cfa0ad2SJack F Vogel for (i = 0; i < ICH_FLASH_READ_COMMAND_TIMEOUT; i++) { 11548cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, 11558cfa0ad2SJack F Vogel ICH_FLASH_HSFSTS); 11568cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcinprog == 0) { 11578cfa0ad2SJack F Vogel ret_val = E1000_SUCCESS; 11588cfa0ad2SJack F Vogel break; 11598cfa0ad2SJack F Vogel } 11608cfa0ad2SJack F Vogel usec_delay(1); 11618cfa0ad2SJack F Vogel } 11628cfa0ad2SJack F Vogel if (ret_val == E1000_SUCCESS) { 11638cfa0ad2SJack F Vogel /* 11648cfa0ad2SJack F Vogel * Successful in waiting for previous cycle to timeout, 11658cfa0ad2SJack F Vogel * now set the Flash Cycle Done. 11668cfa0ad2SJack F Vogel */ 11678cfa0ad2SJack F Vogel hsfsts.hsf_status.flcdone = 1; 1168daf9197cSJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFSTS, 11698cfa0ad2SJack F Vogel hsfsts.regval); 11708cfa0ad2SJack F Vogel } else { 11718cfa0ad2SJack F Vogel DEBUGOUT("Flash controller busy, cannot get access"); 11728cfa0ad2SJack F Vogel } 11738cfa0ad2SJack F Vogel } 11748cfa0ad2SJack F Vogel 11758cfa0ad2SJack F Vogel out: 11768cfa0ad2SJack F Vogel return ret_val; 11778cfa0ad2SJack F Vogel } 11788cfa0ad2SJack F Vogel 11798cfa0ad2SJack F Vogel /** 11808cfa0ad2SJack F Vogel * e1000_flash_cycle_ich8lan - Starts flash cycle (read/write/erase) 11818cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 11828cfa0ad2SJack F Vogel * @timeout: maximum time to wait for completion 11838cfa0ad2SJack F Vogel * 11848cfa0ad2SJack F Vogel * This function starts a flash cycle and waits for its completion. 11858cfa0ad2SJack F Vogel **/ 11868cfa0ad2SJack F Vogel static s32 e1000_flash_cycle_ich8lan(struct e1000_hw *hw, u32 timeout) 11878cfa0ad2SJack F Vogel { 11888cfa0ad2SJack F Vogel union ich8_hws_flash_ctrl hsflctl; 11898cfa0ad2SJack F Vogel union ich8_hws_flash_status hsfsts; 11908cfa0ad2SJack F Vogel s32 ret_val = -E1000_ERR_NVM; 11918cfa0ad2SJack F Vogel u32 i = 0; 11928cfa0ad2SJack F Vogel 11938cfa0ad2SJack F Vogel DEBUGFUNC("e1000_flash_cycle_ich8lan"); 11948cfa0ad2SJack F Vogel 11958cfa0ad2SJack F Vogel /* Start a cycle by writing 1 in Flash Cycle Go in Hw Flash Control */ 11968cfa0ad2SJack F Vogel hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL); 11978cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.flcgo = 1; 11988cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval); 11998cfa0ad2SJack F Vogel 12008cfa0ad2SJack F Vogel /* wait till FDONE bit is set to 1 */ 12018cfa0ad2SJack F Vogel do { 12028cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS); 12038cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcdone == 1) 12048cfa0ad2SJack F Vogel break; 12058cfa0ad2SJack F Vogel usec_delay(1); 12068cfa0ad2SJack F Vogel } while (i++ < timeout); 12078cfa0ad2SJack F Vogel 12088cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcdone == 1 && hsfsts.hsf_status.flcerr == 0) 12098cfa0ad2SJack F Vogel ret_val = E1000_SUCCESS; 12108cfa0ad2SJack F Vogel 12118cfa0ad2SJack F Vogel return ret_val; 12128cfa0ad2SJack F Vogel } 12138cfa0ad2SJack F Vogel 12148cfa0ad2SJack F Vogel /** 12158cfa0ad2SJack F Vogel * e1000_read_flash_word_ich8lan - Read word from flash 12168cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 12178cfa0ad2SJack F Vogel * @offset: offset to data location 12188cfa0ad2SJack F Vogel * @data: pointer to the location for storing the data 12198cfa0ad2SJack F Vogel * 12208cfa0ad2SJack F Vogel * Reads the flash word at offset into data. Offset is converted 12218cfa0ad2SJack F Vogel * to bytes before read. 12228cfa0ad2SJack F Vogel **/ 12238cfa0ad2SJack F Vogel static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset, 12248cfa0ad2SJack F Vogel u16 *data) 12258cfa0ad2SJack F Vogel { 12268cfa0ad2SJack F Vogel s32 ret_val; 12278cfa0ad2SJack F Vogel 12288cfa0ad2SJack F Vogel DEBUGFUNC("e1000_read_flash_word_ich8lan"); 12298cfa0ad2SJack F Vogel 12308cfa0ad2SJack F Vogel if (!data) { 12318cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 12328cfa0ad2SJack F Vogel goto out; 12338cfa0ad2SJack F Vogel } 12348cfa0ad2SJack F Vogel 12358cfa0ad2SJack F Vogel /* Must convert offset into bytes. */ 12368cfa0ad2SJack F Vogel offset <<= 1; 12378cfa0ad2SJack F Vogel 12388cfa0ad2SJack F Vogel ret_val = e1000_read_flash_data_ich8lan(hw, offset, 2, data); 12398cfa0ad2SJack F Vogel 12408cfa0ad2SJack F Vogel out: 12418cfa0ad2SJack F Vogel return ret_val; 12428cfa0ad2SJack F Vogel } 12438cfa0ad2SJack F Vogel 12448cfa0ad2SJack F Vogel /** 12458cfa0ad2SJack F Vogel * e1000_read_flash_byte_ich8lan - Read byte from flash 12468cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 12478cfa0ad2SJack F Vogel * @offset: The offset of the byte to read. 12488cfa0ad2SJack F Vogel * @data: Pointer to a byte to store the value read. 12498cfa0ad2SJack F Vogel * 12508cfa0ad2SJack F Vogel * Reads a single byte from the NVM using the flash access registers. 12518cfa0ad2SJack F Vogel **/ 12528cfa0ad2SJack F Vogel static s32 e1000_read_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, 12538cfa0ad2SJack F Vogel u8 *data) 12548cfa0ad2SJack F Vogel { 12558cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 12568cfa0ad2SJack F Vogel u16 word = 0; 12578cfa0ad2SJack F Vogel 12588cfa0ad2SJack F Vogel ret_val = e1000_read_flash_data_ich8lan(hw, offset, 1, &word); 12598cfa0ad2SJack F Vogel if (ret_val) 12608cfa0ad2SJack F Vogel goto out; 12618cfa0ad2SJack F Vogel 12628cfa0ad2SJack F Vogel *data = (u8)word; 12638cfa0ad2SJack F Vogel 12648cfa0ad2SJack F Vogel out: 12658cfa0ad2SJack F Vogel return ret_val; 12668cfa0ad2SJack F Vogel } 12678cfa0ad2SJack F Vogel 12688cfa0ad2SJack F Vogel /** 12698cfa0ad2SJack F Vogel * e1000_read_flash_data_ich8lan - Read byte or word from NVM 12708cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 12718cfa0ad2SJack F Vogel * @offset: The offset (in bytes) of the byte or word to read. 12728cfa0ad2SJack F Vogel * @size: Size of data to read, 1=byte 2=word 12738cfa0ad2SJack F Vogel * @data: Pointer to the word to store the value read. 12748cfa0ad2SJack F Vogel * 12758cfa0ad2SJack F Vogel * Reads a byte or word from the NVM using the flash access registers. 12768cfa0ad2SJack F Vogel **/ 12778cfa0ad2SJack F Vogel static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, 12788cfa0ad2SJack F Vogel u8 size, u16 *data) 12798cfa0ad2SJack F Vogel { 12808cfa0ad2SJack F Vogel union ich8_hws_flash_status hsfsts; 12818cfa0ad2SJack F Vogel union ich8_hws_flash_ctrl hsflctl; 12828cfa0ad2SJack F Vogel u32 flash_linear_addr; 12838cfa0ad2SJack F Vogel u32 flash_data = 0; 12848cfa0ad2SJack F Vogel s32 ret_val = -E1000_ERR_NVM; 12858cfa0ad2SJack F Vogel u8 count = 0; 12868cfa0ad2SJack F Vogel 12878cfa0ad2SJack F Vogel DEBUGFUNC("e1000_read_flash_data_ich8lan"); 12888cfa0ad2SJack F Vogel 12898cfa0ad2SJack F Vogel if (size < 1 || size > 2 || offset > ICH_FLASH_LINEAR_ADDR_MASK) 12908cfa0ad2SJack F Vogel goto out; 12918cfa0ad2SJack F Vogel 12928cfa0ad2SJack F Vogel flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + 12938cfa0ad2SJack F Vogel hw->nvm.flash_base_addr; 12948cfa0ad2SJack F Vogel 12958cfa0ad2SJack F Vogel do { 12968cfa0ad2SJack F Vogel usec_delay(1); 12978cfa0ad2SJack F Vogel /* Steps */ 12988cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_init_ich8lan(hw); 12998cfa0ad2SJack F Vogel if (ret_val != E1000_SUCCESS) 13008cfa0ad2SJack F Vogel break; 13018cfa0ad2SJack F Vogel 13028cfa0ad2SJack F Vogel hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL); 13038cfa0ad2SJack F Vogel /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 13048cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.fldbcount = size - 1; 13058cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_READ; 13068cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval); 13078cfa0ad2SJack F Vogel 13088cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr); 13098cfa0ad2SJack F Vogel 13108cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_ich8lan(hw, 13118cfa0ad2SJack F Vogel ICH_FLASH_READ_COMMAND_TIMEOUT); 13128cfa0ad2SJack F Vogel 13138cfa0ad2SJack F Vogel /* 13148cfa0ad2SJack F Vogel * Check if FCERR is set to 1, if set to 1, clear it 13158cfa0ad2SJack F Vogel * and try the whole sequence a few more times, else 13168cfa0ad2SJack F Vogel * read in (shift in) the Flash Data0, the order is 13178cfa0ad2SJack F Vogel * least significant byte first msb to lsb 13188cfa0ad2SJack F Vogel */ 13198cfa0ad2SJack F Vogel if (ret_val == E1000_SUCCESS) { 13208cfa0ad2SJack F Vogel flash_data = E1000_READ_FLASH_REG(hw, ICH_FLASH_FDATA0); 1321daf9197cSJack F Vogel if (size == 1) 13228cfa0ad2SJack F Vogel *data = (u8)(flash_data & 0x000000FF); 1323daf9197cSJack F Vogel else if (size == 2) 13248cfa0ad2SJack F Vogel *data = (u16)(flash_data & 0x0000FFFF); 13258cfa0ad2SJack F Vogel break; 13268cfa0ad2SJack F Vogel } else { 13278cfa0ad2SJack F Vogel /* 13288cfa0ad2SJack F Vogel * If we've gotten here, then things are probably 13298cfa0ad2SJack F Vogel * completely hosed, but if the error condition is 13308cfa0ad2SJack F Vogel * detected, it won't hurt to give it another try... 13318cfa0ad2SJack F Vogel * ICH_FLASH_CYCLE_REPEAT_COUNT times. 13328cfa0ad2SJack F Vogel */ 13338cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, 13348cfa0ad2SJack F Vogel ICH_FLASH_HSFSTS); 13358cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcerr == 1) { 13368cfa0ad2SJack F Vogel /* Repeat for some time before giving up. */ 13378cfa0ad2SJack F Vogel continue; 13388cfa0ad2SJack F Vogel } else if (hsfsts.hsf_status.flcdone == 0) { 13398cfa0ad2SJack F Vogel DEBUGOUT("Timeout error - flash cycle " 13408cfa0ad2SJack F Vogel "did not complete."); 13418cfa0ad2SJack F Vogel break; 13428cfa0ad2SJack F Vogel } 13438cfa0ad2SJack F Vogel } 13448cfa0ad2SJack F Vogel } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); 13458cfa0ad2SJack F Vogel 13468cfa0ad2SJack F Vogel out: 13478cfa0ad2SJack F Vogel return ret_val; 13488cfa0ad2SJack F Vogel } 13498cfa0ad2SJack F Vogel 13508cfa0ad2SJack F Vogel /** 13518cfa0ad2SJack F Vogel * e1000_write_nvm_ich8lan - Write word(s) to the NVM 13528cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 13538cfa0ad2SJack F Vogel * @offset: The offset (in bytes) of the word(s) to write. 13548cfa0ad2SJack F Vogel * @words: Size of data to write in words 13558cfa0ad2SJack F Vogel * @data: Pointer to the word(s) to write at offset. 13568cfa0ad2SJack F Vogel * 13578cfa0ad2SJack F Vogel * Writes a byte or word to the NVM using the flash access registers. 13588cfa0ad2SJack F Vogel **/ 13598cfa0ad2SJack F Vogel static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words, 13608cfa0ad2SJack F Vogel u16 *data) 13618cfa0ad2SJack F Vogel { 13628cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 1363daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 13648cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 13658cfa0ad2SJack F Vogel u16 i; 13668cfa0ad2SJack F Vogel 13678cfa0ad2SJack F Vogel DEBUGFUNC("e1000_write_nvm_ich8lan"); 13688cfa0ad2SJack F Vogel 13698cfa0ad2SJack F Vogel if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || 13708cfa0ad2SJack F Vogel (words == 0)) { 13718cfa0ad2SJack F Vogel DEBUGOUT("nvm parameter(s) out of bounds\n"); 13728cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 13738cfa0ad2SJack F Vogel goto out; 13748cfa0ad2SJack F Vogel } 13758cfa0ad2SJack F Vogel 13768cfa0ad2SJack F Vogel ret_val = nvm->ops.acquire(hw); 13778cfa0ad2SJack F Vogel if (ret_val) 13788cfa0ad2SJack F Vogel goto out; 13798cfa0ad2SJack F Vogel 13808cfa0ad2SJack F Vogel for (i = 0; i < words; i++) { 13818cfa0ad2SJack F Vogel dev_spec->shadow_ram[offset+i].modified = TRUE; 13828cfa0ad2SJack F Vogel dev_spec->shadow_ram[offset+i].value = data[i]; 13838cfa0ad2SJack F Vogel } 13848cfa0ad2SJack F Vogel 13858cfa0ad2SJack F Vogel nvm->ops.release(hw); 13868cfa0ad2SJack F Vogel 13878cfa0ad2SJack F Vogel out: 13888cfa0ad2SJack F Vogel return ret_val; 13898cfa0ad2SJack F Vogel } 13908cfa0ad2SJack F Vogel 13918cfa0ad2SJack F Vogel /** 13928cfa0ad2SJack F Vogel * e1000_update_nvm_checksum_ich8lan - Update the checksum for NVM 13938cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 13948cfa0ad2SJack F Vogel * 13958cfa0ad2SJack F Vogel * The NVM checksum is updated by calling the generic update_nvm_checksum, 13968cfa0ad2SJack F Vogel * which writes the checksum to the shadow ram. The changes in the shadow 13978cfa0ad2SJack F Vogel * ram are then committed to the EEPROM by processing each bank at a time 13988cfa0ad2SJack F Vogel * checking for the modified bit and writing only the pending changes. 13998cfa0ad2SJack F Vogel * After a successful commit, the shadow ram is cleared and is ready for 14008cfa0ad2SJack F Vogel * future writes. 14018cfa0ad2SJack F Vogel **/ 14028cfa0ad2SJack F Vogel static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw) 14038cfa0ad2SJack F Vogel { 14048cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 1405daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 14068cfa0ad2SJack F Vogel u32 i, act_offset, new_bank_offset, old_bank_offset, bank; 14078cfa0ad2SJack F Vogel s32 ret_val; 14088cfa0ad2SJack F Vogel u16 data; 14098cfa0ad2SJack F Vogel 14108cfa0ad2SJack F Vogel DEBUGFUNC("e1000_update_nvm_checksum_ich8lan"); 14118cfa0ad2SJack F Vogel 14128cfa0ad2SJack F Vogel ret_val = e1000_update_nvm_checksum_generic(hw); 14138cfa0ad2SJack F Vogel if (ret_val) 14148cfa0ad2SJack F Vogel goto out; 14158cfa0ad2SJack F Vogel 14168cfa0ad2SJack F Vogel if (nvm->type != e1000_nvm_flash_sw) 14178cfa0ad2SJack F Vogel goto out; 14188cfa0ad2SJack F Vogel 14198cfa0ad2SJack F Vogel ret_val = nvm->ops.acquire(hw); 14208cfa0ad2SJack F Vogel if (ret_val) 14218cfa0ad2SJack F Vogel goto out; 14228cfa0ad2SJack F Vogel 14238cfa0ad2SJack F Vogel /* 14248cfa0ad2SJack F Vogel * We're writing to the opposite bank so if we're on bank 1, 14258cfa0ad2SJack F Vogel * write to bank 0 etc. We also need to erase the segment that 14268cfa0ad2SJack F Vogel * is going to be written 14278cfa0ad2SJack F Vogel */ 14288cfa0ad2SJack F Vogel ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); 14298cfa0ad2SJack F Vogel if (ret_val != E1000_SUCCESS) 14308cfa0ad2SJack F Vogel goto out; 14318cfa0ad2SJack F Vogel 14328cfa0ad2SJack F Vogel if (bank == 0) { 14338cfa0ad2SJack F Vogel new_bank_offset = nvm->flash_bank_size; 14348cfa0ad2SJack F Vogel old_bank_offset = 0; 14358cfa0ad2SJack F Vogel e1000_erase_flash_bank_ich8lan(hw, 1); 14368cfa0ad2SJack F Vogel } else { 14378cfa0ad2SJack F Vogel old_bank_offset = nvm->flash_bank_size; 14388cfa0ad2SJack F Vogel new_bank_offset = 0; 14398cfa0ad2SJack F Vogel e1000_erase_flash_bank_ich8lan(hw, 0); 14408cfa0ad2SJack F Vogel } 14418cfa0ad2SJack F Vogel 14428cfa0ad2SJack F Vogel for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) { 14438cfa0ad2SJack F Vogel /* 14448cfa0ad2SJack F Vogel * Determine whether to write the value stored 14458cfa0ad2SJack F Vogel * in the other NVM bank or a modified value stored 14468cfa0ad2SJack F Vogel * in the shadow RAM 14478cfa0ad2SJack F Vogel */ 14488cfa0ad2SJack F Vogel if (dev_spec->shadow_ram[i].modified) { 14498cfa0ad2SJack F Vogel data = dev_spec->shadow_ram[i].value; 14508cfa0ad2SJack F Vogel } else { 14518cfa0ad2SJack F Vogel e1000_read_flash_word_ich8lan(hw, 14528cfa0ad2SJack F Vogel i + old_bank_offset, 14538cfa0ad2SJack F Vogel &data); 14548cfa0ad2SJack F Vogel } 14558cfa0ad2SJack F Vogel 14568cfa0ad2SJack F Vogel /* 14578cfa0ad2SJack F Vogel * If the word is 0x13, then make sure the signature bits 14588cfa0ad2SJack F Vogel * (15:14) are 11b until the commit has completed. 14598cfa0ad2SJack F Vogel * This will allow us to write 10b which indicates the 14608cfa0ad2SJack F Vogel * signature is valid. We want to do this after the write 14618cfa0ad2SJack F Vogel * has completed so that we don't mark the segment valid 14628cfa0ad2SJack F Vogel * while the write is still in progress 14638cfa0ad2SJack F Vogel */ 14648cfa0ad2SJack F Vogel if (i == E1000_ICH_NVM_SIG_WORD) 14658cfa0ad2SJack F Vogel data |= E1000_ICH_NVM_SIG_MASK; 14668cfa0ad2SJack F Vogel 14678cfa0ad2SJack F Vogel /* Convert offset to bytes. */ 14688cfa0ad2SJack F Vogel act_offset = (i + new_bank_offset) << 1; 14698cfa0ad2SJack F Vogel 14708cfa0ad2SJack F Vogel usec_delay(100); 14718cfa0ad2SJack F Vogel /* Write the bytes to the new bank. */ 14728cfa0ad2SJack F Vogel ret_val = e1000_retry_write_flash_byte_ich8lan(hw, 14738cfa0ad2SJack F Vogel act_offset, 14748cfa0ad2SJack F Vogel (u8)data); 14758cfa0ad2SJack F Vogel if (ret_val) 14768cfa0ad2SJack F Vogel break; 14778cfa0ad2SJack F Vogel 14788cfa0ad2SJack F Vogel usec_delay(100); 14798cfa0ad2SJack F Vogel ret_val = e1000_retry_write_flash_byte_ich8lan(hw, 14808cfa0ad2SJack F Vogel act_offset + 1, 14818cfa0ad2SJack F Vogel (u8)(data >> 8)); 14828cfa0ad2SJack F Vogel if (ret_val) 14838cfa0ad2SJack F Vogel break; 14848cfa0ad2SJack F Vogel } 14858cfa0ad2SJack F Vogel 14868cfa0ad2SJack F Vogel /* 14878cfa0ad2SJack F Vogel * Don't bother writing the segment valid bits if sector 14888cfa0ad2SJack F Vogel * programming failed. 14898cfa0ad2SJack F Vogel */ 14908cfa0ad2SJack F Vogel if (ret_val) { 14918cfa0ad2SJack F Vogel DEBUGOUT("Flash commit failed.\n"); 14928cfa0ad2SJack F Vogel nvm->ops.release(hw); 14938cfa0ad2SJack F Vogel goto out; 14948cfa0ad2SJack F Vogel } 14958cfa0ad2SJack F Vogel 14968cfa0ad2SJack F Vogel /* 14978cfa0ad2SJack F Vogel * Finally validate the new segment by setting bit 15:14 14988cfa0ad2SJack F Vogel * to 10b in word 0x13 , this can be done without an 14998cfa0ad2SJack F Vogel * erase as well since these bits are 11 to start with 15008cfa0ad2SJack F Vogel * and we need to change bit 14 to 0b 15018cfa0ad2SJack F Vogel */ 15028cfa0ad2SJack F Vogel act_offset = new_bank_offset + E1000_ICH_NVM_SIG_WORD; 15038cfa0ad2SJack F Vogel e1000_read_flash_word_ich8lan(hw, act_offset, &data); 15048cfa0ad2SJack F Vogel data &= 0xBFFF; 15058cfa0ad2SJack F Vogel ret_val = e1000_retry_write_flash_byte_ich8lan(hw, 15068cfa0ad2SJack F Vogel act_offset * 2 + 1, 15078cfa0ad2SJack F Vogel (u8)(data >> 8)); 15088cfa0ad2SJack F Vogel if (ret_val) { 15098cfa0ad2SJack F Vogel nvm->ops.release(hw); 15108cfa0ad2SJack F Vogel goto out; 15118cfa0ad2SJack F Vogel } 15128cfa0ad2SJack F Vogel 15138cfa0ad2SJack F Vogel /* 15148cfa0ad2SJack F Vogel * And invalidate the previously valid segment by setting 15158cfa0ad2SJack F Vogel * its signature word (0x13) high_byte to 0b. This can be 15168cfa0ad2SJack F Vogel * done without an erase because flash erase sets all bits 15178cfa0ad2SJack F Vogel * to 1's. We can write 1's to 0's without an erase 15188cfa0ad2SJack F Vogel */ 15198cfa0ad2SJack F Vogel act_offset = (old_bank_offset + E1000_ICH_NVM_SIG_WORD) * 2 + 1; 15208cfa0ad2SJack F Vogel ret_val = e1000_retry_write_flash_byte_ich8lan(hw, act_offset, 0); 15218cfa0ad2SJack F Vogel if (ret_val) { 15228cfa0ad2SJack F Vogel nvm->ops.release(hw); 15238cfa0ad2SJack F Vogel goto out; 15248cfa0ad2SJack F Vogel } 15258cfa0ad2SJack F Vogel 15268cfa0ad2SJack F Vogel /* Great! Everything worked, we can now clear the cached entries. */ 15278cfa0ad2SJack F Vogel for (i = 0; i < E1000_SHADOW_RAM_WORDS; i++) { 15288cfa0ad2SJack F Vogel dev_spec->shadow_ram[i].modified = FALSE; 15298cfa0ad2SJack F Vogel dev_spec->shadow_ram[i].value = 0xFFFF; 15308cfa0ad2SJack F Vogel } 15318cfa0ad2SJack F Vogel 15328cfa0ad2SJack F Vogel nvm->ops.release(hw); 15338cfa0ad2SJack F Vogel 15348cfa0ad2SJack F Vogel /* 15358cfa0ad2SJack F Vogel * Reload the EEPROM, or else modifications will not appear 15368cfa0ad2SJack F Vogel * until after the next adapter reset. 15378cfa0ad2SJack F Vogel */ 15388cfa0ad2SJack F Vogel nvm->ops.reload(hw); 15398cfa0ad2SJack F Vogel msec_delay(10); 15408cfa0ad2SJack F Vogel 15418cfa0ad2SJack F Vogel out: 15428cfa0ad2SJack F Vogel return ret_val; 15438cfa0ad2SJack F Vogel } 15448cfa0ad2SJack F Vogel 15458cfa0ad2SJack F Vogel /** 15468cfa0ad2SJack F Vogel * e1000_validate_nvm_checksum_ich8lan - Validate EEPROM checksum 15478cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 15488cfa0ad2SJack F Vogel * 15498cfa0ad2SJack F Vogel * Check to see if checksum needs to be fixed by reading bit 6 in word 0x19. 1550daf9197cSJack F Vogel * If the bit is 0, that the EEPROM had been modified, but the checksum was not 1551daf9197cSJack F Vogel * calculated, in which case we need to calculate the checksum and set bit 6. 15528cfa0ad2SJack F Vogel **/ 15538cfa0ad2SJack F Vogel static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw) 15548cfa0ad2SJack F Vogel { 15558cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 15568cfa0ad2SJack F Vogel u16 data; 15578cfa0ad2SJack F Vogel 15588cfa0ad2SJack F Vogel DEBUGFUNC("e1000_validate_nvm_checksum_ich8lan"); 15598cfa0ad2SJack F Vogel 15608cfa0ad2SJack F Vogel /* 15618cfa0ad2SJack F Vogel * Read 0x19 and check bit 6. If this bit is 0, the checksum 15628cfa0ad2SJack F Vogel * needs to be fixed. This bit is an indication that the NVM 15638cfa0ad2SJack F Vogel * was prepared by OEM software and did not calculate the 15648cfa0ad2SJack F Vogel * checksum...a likely scenario. 15658cfa0ad2SJack F Vogel */ 15668cfa0ad2SJack F Vogel ret_val = hw->nvm.ops.read(hw, 0x19, 1, &data); 15678cfa0ad2SJack F Vogel if (ret_val) 15688cfa0ad2SJack F Vogel goto out; 15698cfa0ad2SJack F Vogel 15708cfa0ad2SJack F Vogel if ((data & 0x40) == 0) { 15718cfa0ad2SJack F Vogel data |= 0x40; 15728cfa0ad2SJack F Vogel ret_val = hw->nvm.ops.write(hw, 0x19, 1, &data); 15738cfa0ad2SJack F Vogel if (ret_val) 15748cfa0ad2SJack F Vogel goto out; 15758cfa0ad2SJack F Vogel ret_val = hw->nvm.ops.update(hw); 15768cfa0ad2SJack F Vogel if (ret_val) 15778cfa0ad2SJack F Vogel goto out; 15788cfa0ad2SJack F Vogel } 15798cfa0ad2SJack F Vogel 15808cfa0ad2SJack F Vogel ret_val = e1000_validate_nvm_checksum_generic(hw); 15818cfa0ad2SJack F Vogel 15828cfa0ad2SJack F Vogel out: 15838cfa0ad2SJack F Vogel return ret_val; 15848cfa0ad2SJack F Vogel } 15858cfa0ad2SJack F Vogel 15868cfa0ad2SJack F Vogel /** 15878cfa0ad2SJack F Vogel * e1000_write_flash_data_ich8lan - Writes bytes to the NVM 15888cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 15898cfa0ad2SJack F Vogel * @offset: The offset (in bytes) of the byte/word to read. 15908cfa0ad2SJack F Vogel * @size: Size of data to read, 1=byte 2=word 15918cfa0ad2SJack F Vogel * @data: The byte(s) to write to the NVM. 15928cfa0ad2SJack F Vogel * 15938cfa0ad2SJack F Vogel * Writes one/two bytes to the NVM using the flash access registers. 15948cfa0ad2SJack F Vogel **/ 15958cfa0ad2SJack F Vogel static s32 e1000_write_flash_data_ich8lan(struct e1000_hw *hw, u32 offset, 15968cfa0ad2SJack F Vogel u8 size, u16 data) 15978cfa0ad2SJack F Vogel { 15988cfa0ad2SJack F Vogel union ich8_hws_flash_status hsfsts; 15998cfa0ad2SJack F Vogel union ich8_hws_flash_ctrl hsflctl; 16008cfa0ad2SJack F Vogel u32 flash_linear_addr; 16018cfa0ad2SJack F Vogel u32 flash_data = 0; 16028cfa0ad2SJack F Vogel s32 ret_val = -E1000_ERR_NVM; 16038cfa0ad2SJack F Vogel u8 count = 0; 16048cfa0ad2SJack F Vogel 16058cfa0ad2SJack F Vogel DEBUGFUNC("e1000_write_ich8_data"); 16068cfa0ad2SJack F Vogel 16078cfa0ad2SJack F Vogel if (size < 1 || size > 2 || data > size * 0xff || 16088cfa0ad2SJack F Vogel offset > ICH_FLASH_LINEAR_ADDR_MASK) 16098cfa0ad2SJack F Vogel goto out; 16108cfa0ad2SJack F Vogel 16118cfa0ad2SJack F Vogel flash_linear_addr = (ICH_FLASH_LINEAR_ADDR_MASK & offset) + 16128cfa0ad2SJack F Vogel hw->nvm.flash_base_addr; 16138cfa0ad2SJack F Vogel 16148cfa0ad2SJack F Vogel do { 16158cfa0ad2SJack F Vogel usec_delay(1); 16168cfa0ad2SJack F Vogel /* Steps */ 16178cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_init_ich8lan(hw); 16188cfa0ad2SJack F Vogel if (ret_val != E1000_SUCCESS) 16198cfa0ad2SJack F Vogel break; 16208cfa0ad2SJack F Vogel 16218cfa0ad2SJack F Vogel hsflctl.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFCTL); 16228cfa0ad2SJack F Vogel /* 0b/1b corresponds to 1 or 2 byte size, respectively. */ 16238cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.fldbcount = size - 1; 16248cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_WRITE; 16258cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, hsflctl.regval); 16268cfa0ad2SJack F Vogel 16278cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, flash_linear_addr); 16288cfa0ad2SJack F Vogel 16298cfa0ad2SJack F Vogel if (size == 1) 16308cfa0ad2SJack F Vogel flash_data = (u32)data & 0x00FF; 16318cfa0ad2SJack F Vogel else 16328cfa0ad2SJack F Vogel flash_data = (u32)data; 16338cfa0ad2SJack F Vogel 16348cfa0ad2SJack F Vogel E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FDATA0, flash_data); 16358cfa0ad2SJack F Vogel 16368cfa0ad2SJack F Vogel /* 16378cfa0ad2SJack F Vogel * check if FCERR is set to 1 , if set to 1, clear it 16388cfa0ad2SJack F Vogel * and try the whole sequence a few more times else done 16398cfa0ad2SJack F Vogel */ 16408cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_ich8lan(hw, 16418cfa0ad2SJack F Vogel ICH_FLASH_WRITE_COMMAND_TIMEOUT); 1642daf9197cSJack F Vogel if (ret_val == E1000_SUCCESS) 16438cfa0ad2SJack F Vogel break; 1644daf9197cSJack F Vogel 16458cfa0ad2SJack F Vogel /* 16468cfa0ad2SJack F Vogel * If we're here, then things are most likely 16478cfa0ad2SJack F Vogel * completely hosed, but if the error condition 16488cfa0ad2SJack F Vogel * is detected, it won't hurt to give it another 16498cfa0ad2SJack F Vogel * try...ICH_FLASH_CYCLE_REPEAT_COUNT times. 16508cfa0ad2SJack F Vogel */ 1651daf9197cSJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS); 16528cfa0ad2SJack F Vogel if (hsfsts.hsf_status.flcerr == 1) { 16538cfa0ad2SJack F Vogel /* Repeat for some time before giving up. */ 16548cfa0ad2SJack F Vogel continue; 16558cfa0ad2SJack F Vogel } else if (hsfsts.hsf_status.flcdone == 0) { 16568cfa0ad2SJack F Vogel DEBUGOUT("Timeout error - flash cycle " 16578cfa0ad2SJack F Vogel "did not complete."); 16588cfa0ad2SJack F Vogel break; 16598cfa0ad2SJack F Vogel } 16608cfa0ad2SJack F Vogel } while (count++ < ICH_FLASH_CYCLE_REPEAT_COUNT); 16618cfa0ad2SJack F Vogel 16628cfa0ad2SJack F Vogel out: 16638cfa0ad2SJack F Vogel return ret_val; 16648cfa0ad2SJack F Vogel } 16658cfa0ad2SJack F Vogel 16668cfa0ad2SJack F Vogel /** 16678cfa0ad2SJack F Vogel * e1000_write_flash_byte_ich8lan - Write a single byte to NVM 16688cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 16698cfa0ad2SJack F Vogel * @offset: The index of the byte to read. 16708cfa0ad2SJack F Vogel * @data: The byte to write to the NVM. 16718cfa0ad2SJack F Vogel * 16728cfa0ad2SJack F Vogel * Writes a single byte to the NVM using the flash access registers. 16738cfa0ad2SJack F Vogel **/ 16748cfa0ad2SJack F Vogel static s32 e1000_write_flash_byte_ich8lan(struct e1000_hw *hw, u32 offset, 16758cfa0ad2SJack F Vogel u8 data) 16768cfa0ad2SJack F Vogel { 16778cfa0ad2SJack F Vogel u16 word = (u16)data; 16788cfa0ad2SJack F Vogel 16798cfa0ad2SJack F Vogel DEBUGFUNC("e1000_write_flash_byte_ich8lan"); 16808cfa0ad2SJack F Vogel 16818cfa0ad2SJack F Vogel return e1000_write_flash_data_ich8lan(hw, offset, 1, word); 16828cfa0ad2SJack F Vogel } 16838cfa0ad2SJack F Vogel 16848cfa0ad2SJack F Vogel /** 16858cfa0ad2SJack F Vogel * e1000_retry_write_flash_byte_ich8lan - Writes a single byte to NVM 16868cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 16878cfa0ad2SJack F Vogel * @offset: The offset of the byte to write. 16888cfa0ad2SJack F Vogel * @byte: The byte to write to the NVM. 16898cfa0ad2SJack F Vogel * 16908cfa0ad2SJack F Vogel * Writes a single byte to the NVM using the flash access registers. 16918cfa0ad2SJack F Vogel * Goes through a retry algorithm before giving up. 16928cfa0ad2SJack F Vogel **/ 16938cfa0ad2SJack F Vogel static s32 e1000_retry_write_flash_byte_ich8lan(struct e1000_hw *hw, 16948cfa0ad2SJack F Vogel u32 offset, u8 byte) 16958cfa0ad2SJack F Vogel { 16968cfa0ad2SJack F Vogel s32 ret_val; 16978cfa0ad2SJack F Vogel u16 program_retries; 16988cfa0ad2SJack F Vogel 16998cfa0ad2SJack F Vogel DEBUGFUNC("e1000_retry_write_flash_byte_ich8lan"); 17008cfa0ad2SJack F Vogel 17018cfa0ad2SJack F Vogel ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); 17028cfa0ad2SJack F Vogel if (ret_val == E1000_SUCCESS) 17038cfa0ad2SJack F Vogel goto out; 17048cfa0ad2SJack F Vogel 17058cfa0ad2SJack F Vogel for (program_retries = 0; program_retries < 100; program_retries++) { 17068cfa0ad2SJack F Vogel DEBUGOUT2("Retrying Byte %2.2X at offset %u\n", byte, offset); 17078cfa0ad2SJack F Vogel usec_delay(100); 17088cfa0ad2SJack F Vogel ret_val = e1000_write_flash_byte_ich8lan(hw, offset, byte); 17098cfa0ad2SJack F Vogel if (ret_val == E1000_SUCCESS) 17108cfa0ad2SJack F Vogel break; 17118cfa0ad2SJack F Vogel } 17128cfa0ad2SJack F Vogel if (program_retries == 100) { 17138cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 17148cfa0ad2SJack F Vogel goto out; 17158cfa0ad2SJack F Vogel } 17168cfa0ad2SJack F Vogel 17178cfa0ad2SJack F Vogel out: 17188cfa0ad2SJack F Vogel return ret_val; 17198cfa0ad2SJack F Vogel } 17208cfa0ad2SJack F Vogel 17218cfa0ad2SJack F Vogel /** 17228cfa0ad2SJack F Vogel * e1000_erase_flash_bank_ich8lan - Erase a bank (4k) from NVM 17238cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 17248cfa0ad2SJack F Vogel * @bank: 0 for first bank, 1 for second bank, etc. 17258cfa0ad2SJack F Vogel * 17268cfa0ad2SJack F Vogel * Erases the bank specified. Each bank is a 4k block. Banks are 0 based. 17278cfa0ad2SJack F Vogel * bank N is 4096 * N + flash_reg_addr. 17288cfa0ad2SJack F Vogel **/ 17298cfa0ad2SJack F Vogel static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank) 17308cfa0ad2SJack F Vogel { 17318cfa0ad2SJack F Vogel struct e1000_nvm_info *nvm = &hw->nvm; 17328cfa0ad2SJack F Vogel union ich8_hws_flash_status hsfsts; 17338cfa0ad2SJack F Vogel union ich8_hws_flash_ctrl hsflctl; 17348cfa0ad2SJack F Vogel u32 flash_linear_addr; 17358cfa0ad2SJack F Vogel /* bank size is in 16bit words - adjust to bytes */ 17368cfa0ad2SJack F Vogel u32 flash_bank_size = nvm->flash_bank_size * 2; 17378cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 17388cfa0ad2SJack F Vogel s32 count = 0; 17398cfa0ad2SJack F Vogel s32 j, iteration, sector_size; 17408cfa0ad2SJack F Vogel 17418cfa0ad2SJack F Vogel DEBUGFUNC("e1000_erase_flash_bank_ich8lan"); 17428cfa0ad2SJack F Vogel 17438cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, ICH_FLASH_HSFSTS); 17448cfa0ad2SJack F Vogel 17458cfa0ad2SJack F Vogel /* 17468cfa0ad2SJack F Vogel * Determine HW Sector size: Read BERASE bits of hw flash status 17478cfa0ad2SJack F Vogel * register 17488cfa0ad2SJack F Vogel * 00: The Hw sector is 256 bytes, hence we need to erase 16 17498cfa0ad2SJack F Vogel * consecutive sectors. The start index for the nth Hw sector 17508cfa0ad2SJack F Vogel * can be calculated as = bank * 4096 + n * 256 17518cfa0ad2SJack F Vogel * 01: The Hw sector is 4K bytes, hence we need to erase 1 sector. 17528cfa0ad2SJack F Vogel * The start index for the nth Hw sector can be calculated 17538cfa0ad2SJack F Vogel * as = bank * 4096 17548cfa0ad2SJack F Vogel * 10: The Hw sector is 8K bytes, nth sector = bank * 8192 17558cfa0ad2SJack F Vogel * (ich9 only, otherwise error condition) 17568cfa0ad2SJack F Vogel * 11: The Hw sector is 64K bytes, nth sector = bank * 65536 17578cfa0ad2SJack F Vogel */ 17588cfa0ad2SJack F Vogel switch (hsfsts.hsf_status.berasesz) { 17598cfa0ad2SJack F Vogel case 0: 17608cfa0ad2SJack F Vogel /* Hw sector size 256 */ 17618cfa0ad2SJack F Vogel sector_size = ICH_FLASH_SEG_SIZE_256; 17628cfa0ad2SJack F Vogel iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_256; 17638cfa0ad2SJack F Vogel break; 17648cfa0ad2SJack F Vogel case 1: 17658cfa0ad2SJack F Vogel sector_size = ICH_FLASH_SEG_SIZE_4K; 17668cfa0ad2SJack F Vogel iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_4K; 17678cfa0ad2SJack F Vogel break; 17688cfa0ad2SJack F Vogel case 2: 17698cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich9lan) { 17708cfa0ad2SJack F Vogel sector_size = ICH_FLASH_SEG_SIZE_8K; 17718cfa0ad2SJack F Vogel iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_8K; 17728cfa0ad2SJack F Vogel } else { 17738cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 17748cfa0ad2SJack F Vogel goto out; 17758cfa0ad2SJack F Vogel } 17768cfa0ad2SJack F Vogel break; 17778cfa0ad2SJack F Vogel case 3: 17788cfa0ad2SJack F Vogel sector_size = ICH_FLASH_SEG_SIZE_64K; 17798cfa0ad2SJack F Vogel iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_64K; 17808cfa0ad2SJack F Vogel break; 17818cfa0ad2SJack F Vogel default: 17828cfa0ad2SJack F Vogel ret_val = -E1000_ERR_NVM; 17838cfa0ad2SJack F Vogel goto out; 17848cfa0ad2SJack F Vogel } 17858cfa0ad2SJack F Vogel 17868cfa0ad2SJack F Vogel /* Start with the base address, then add the sector offset. */ 17878cfa0ad2SJack F Vogel flash_linear_addr = hw->nvm.flash_base_addr; 17888cfa0ad2SJack F Vogel flash_linear_addr += (bank) ? (sector_size * iteration) : 0; 17898cfa0ad2SJack F Vogel 17908cfa0ad2SJack F Vogel for (j = 0; j < iteration ; j++) { 17918cfa0ad2SJack F Vogel do { 17928cfa0ad2SJack F Vogel /* Steps */ 17938cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_init_ich8lan(hw); 17948cfa0ad2SJack F Vogel if (ret_val) 17958cfa0ad2SJack F Vogel goto out; 17968cfa0ad2SJack F Vogel 17978cfa0ad2SJack F Vogel /* 17988cfa0ad2SJack F Vogel * Write a value 11 (block Erase) in Flash 17998cfa0ad2SJack F Vogel * Cycle field in hw flash control 18008cfa0ad2SJack F Vogel */ 18018cfa0ad2SJack F Vogel hsflctl.regval = E1000_READ_FLASH_REG16(hw, 18028cfa0ad2SJack F Vogel ICH_FLASH_HSFCTL); 18038cfa0ad2SJack F Vogel hsflctl.hsf_ctrl.flcycle = ICH_CYCLE_ERASE; 1804daf9197cSJack F Vogel E1000_WRITE_FLASH_REG16(hw, ICH_FLASH_HSFCTL, 18058cfa0ad2SJack F Vogel hsflctl.regval); 18068cfa0ad2SJack F Vogel 18078cfa0ad2SJack F Vogel /* 18088cfa0ad2SJack F Vogel * Write the last 24 bits of an index within the 18098cfa0ad2SJack F Vogel * block into Flash Linear address field in Flash 18108cfa0ad2SJack F Vogel * Address. 18118cfa0ad2SJack F Vogel */ 18128cfa0ad2SJack F Vogel flash_linear_addr += (j * sector_size); 1813daf9197cSJack F Vogel E1000_WRITE_FLASH_REG(hw, ICH_FLASH_FADDR, 18148cfa0ad2SJack F Vogel flash_linear_addr); 18158cfa0ad2SJack F Vogel 18168cfa0ad2SJack F Vogel ret_val = e1000_flash_cycle_ich8lan(hw, 18178cfa0ad2SJack F Vogel ICH_FLASH_ERASE_COMMAND_TIMEOUT); 1818daf9197cSJack F Vogel if (ret_val == E1000_SUCCESS) 18198cfa0ad2SJack F Vogel break; 1820daf9197cSJack F Vogel 18218cfa0ad2SJack F Vogel /* 18228cfa0ad2SJack F Vogel * Check if FCERR is set to 1. If 1, 18238cfa0ad2SJack F Vogel * clear it and try the whole sequence 18248cfa0ad2SJack F Vogel * a few more times else Done 18258cfa0ad2SJack F Vogel */ 18268cfa0ad2SJack F Vogel hsfsts.regval = E1000_READ_FLASH_REG16(hw, 18278cfa0ad2SJack F Vogel ICH_FLASH_HSFSTS); 1828daf9197cSJack F Vogel if (hsfsts.hsf_status.flcerr == 1) 1829daf9197cSJack F Vogel /* repeat for some time before giving up */ 18308cfa0ad2SJack F Vogel continue; 1831daf9197cSJack F Vogel else if (hsfsts.hsf_status.flcdone == 0) 18328cfa0ad2SJack F Vogel goto out; 18338cfa0ad2SJack F Vogel } while (++count < ICH_FLASH_CYCLE_REPEAT_COUNT); 18348cfa0ad2SJack F Vogel } 18358cfa0ad2SJack F Vogel 18368cfa0ad2SJack F Vogel out: 18378cfa0ad2SJack F Vogel return ret_val; 18388cfa0ad2SJack F Vogel } 18398cfa0ad2SJack F Vogel 18408cfa0ad2SJack F Vogel /** 18418cfa0ad2SJack F Vogel * e1000_valid_led_default_ich8lan - Set the default LED settings 18428cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 18438cfa0ad2SJack F Vogel * @data: Pointer to the LED settings 18448cfa0ad2SJack F Vogel * 18458cfa0ad2SJack F Vogel * Reads the LED default settings from the NVM to data. If the NVM LED 18468cfa0ad2SJack F Vogel * settings is all 0's or F's, set the LED default to a valid LED default 18478cfa0ad2SJack F Vogel * setting. 18488cfa0ad2SJack F Vogel **/ 18498cfa0ad2SJack F Vogel static s32 e1000_valid_led_default_ich8lan(struct e1000_hw *hw, u16 *data) 18508cfa0ad2SJack F Vogel { 18518cfa0ad2SJack F Vogel s32 ret_val; 18528cfa0ad2SJack F Vogel 18538cfa0ad2SJack F Vogel DEBUGFUNC("e1000_valid_led_default_ich8lan"); 18548cfa0ad2SJack F Vogel 18558cfa0ad2SJack F Vogel ret_val = hw->nvm.ops.read(hw, NVM_ID_LED_SETTINGS, 1, data); 18568cfa0ad2SJack F Vogel if (ret_val) { 18578cfa0ad2SJack F Vogel DEBUGOUT("NVM Read Error\n"); 18588cfa0ad2SJack F Vogel goto out; 18598cfa0ad2SJack F Vogel } 18608cfa0ad2SJack F Vogel 18618cfa0ad2SJack F Vogel if (*data == ID_LED_RESERVED_0000 || 18628cfa0ad2SJack F Vogel *data == ID_LED_RESERVED_FFFF) 18638cfa0ad2SJack F Vogel *data = ID_LED_DEFAULT_ICH8LAN; 18648cfa0ad2SJack F Vogel 18658cfa0ad2SJack F Vogel out: 18668cfa0ad2SJack F Vogel return ret_val; 18678cfa0ad2SJack F Vogel } 18688cfa0ad2SJack F Vogel 18698cfa0ad2SJack F Vogel /** 18708cfa0ad2SJack F Vogel * e1000_get_bus_info_ich8lan - Get/Set the bus type and width 18718cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 18728cfa0ad2SJack F Vogel * 18738cfa0ad2SJack F Vogel * ICH8 use the PCI Express bus, but does not contain a PCI Express Capability 18748cfa0ad2SJack F Vogel * register, so the the bus width is hard coded. 18758cfa0ad2SJack F Vogel **/ 18768cfa0ad2SJack F Vogel static s32 e1000_get_bus_info_ich8lan(struct e1000_hw *hw) 18778cfa0ad2SJack F Vogel { 18788cfa0ad2SJack F Vogel struct e1000_bus_info *bus = &hw->bus; 18798cfa0ad2SJack F Vogel s32 ret_val; 18808cfa0ad2SJack F Vogel 18818cfa0ad2SJack F Vogel DEBUGFUNC("e1000_get_bus_info_ich8lan"); 18828cfa0ad2SJack F Vogel 18838cfa0ad2SJack F Vogel ret_val = e1000_get_bus_info_pcie_generic(hw); 18848cfa0ad2SJack F Vogel 18858cfa0ad2SJack F Vogel /* 18868cfa0ad2SJack F Vogel * ICH devices are "PCI Express"-ish. They have 18878cfa0ad2SJack F Vogel * a configuration space, but do not contain 18888cfa0ad2SJack F Vogel * PCI Express Capability registers, so bus width 18898cfa0ad2SJack F Vogel * must be hardcoded. 18908cfa0ad2SJack F Vogel */ 18918cfa0ad2SJack F Vogel if (bus->width == e1000_bus_width_unknown) 18928cfa0ad2SJack F Vogel bus->width = e1000_bus_width_pcie_x1; 18938cfa0ad2SJack F Vogel 18948cfa0ad2SJack F Vogel return ret_val; 18958cfa0ad2SJack F Vogel } 18968cfa0ad2SJack F Vogel 18978cfa0ad2SJack F Vogel /** 18988cfa0ad2SJack F Vogel * e1000_reset_hw_ich8lan - Reset the hardware 18998cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 19008cfa0ad2SJack F Vogel * 19018cfa0ad2SJack F Vogel * Does a full reset of the hardware which includes a reset of the PHY and 19028cfa0ad2SJack F Vogel * MAC. 19038cfa0ad2SJack F Vogel **/ 19048cfa0ad2SJack F Vogel static s32 e1000_reset_hw_ich8lan(struct e1000_hw *hw) 19058cfa0ad2SJack F Vogel { 19068cfa0ad2SJack F Vogel u32 ctrl, icr, kab; 19078cfa0ad2SJack F Vogel s32 ret_val; 19088cfa0ad2SJack F Vogel 19098cfa0ad2SJack F Vogel DEBUGFUNC("e1000_reset_hw_ich8lan"); 19108cfa0ad2SJack F Vogel 19118cfa0ad2SJack F Vogel /* 19128cfa0ad2SJack F Vogel * Prevent the PCI-E bus from sticking if there is no TLP connection 19138cfa0ad2SJack F Vogel * on the last TLP read/write transaction when MAC is reset. 19148cfa0ad2SJack F Vogel */ 19158cfa0ad2SJack F Vogel ret_val = e1000_disable_pcie_master_generic(hw); 1916daf9197cSJack F Vogel if (ret_val) 19178cfa0ad2SJack F Vogel DEBUGOUT("PCI-E Master disable polling has failed.\n"); 19188cfa0ad2SJack F Vogel 19198cfa0ad2SJack F Vogel DEBUGOUT("Masking off all interrupts\n"); 19208cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); 19218cfa0ad2SJack F Vogel 19228cfa0ad2SJack F Vogel /* 19238cfa0ad2SJack F Vogel * Disable the Transmit and Receive units. Then delay to allow 19248cfa0ad2SJack F Vogel * any pending transactions to complete before we hit the MAC 19258cfa0ad2SJack F Vogel * with the global reset. 19268cfa0ad2SJack F Vogel */ 19278cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_RCTL, 0); 19288cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TCTL, E1000_TCTL_PSP); 19298cfa0ad2SJack F Vogel E1000_WRITE_FLUSH(hw); 19308cfa0ad2SJack F Vogel 19318cfa0ad2SJack F Vogel msec_delay(10); 19328cfa0ad2SJack F Vogel 19338cfa0ad2SJack F Vogel /* Workaround for ICH8 bit corruption issue in FIFO memory */ 19348cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich8lan) { 19358cfa0ad2SJack F Vogel /* Set Tx and Rx buffer allocation to 8k apiece. */ 19368cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PBA, E1000_PBA_8K); 19378cfa0ad2SJack F Vogel /* Set Packet Buffer Size to 16k. */ 19388cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PBS, E1000_PBS_16K); 19398cfa0ad2SJack F Vogel } 19408cfa0ad2SJack F Vogel 19418cfa0ad2SJack F Vogel ctrl = E1000_READ_REG(hw, E1000_CTRL); 19428cfa0ad2SJack F Vogel 19438cfa0ad2SJack F Vogel if (!hw->phy.ops.check_reset_block(hw) && !hw->phy.reset_disable) { 19448cfa0ad2SJack F Vogel /* 19458cfa0ad2SJack F Vogel * PHY HW reset requires MAC CORE reset at the same 19468cfa0ad2SJack F Vogel * time to make sure the interface between MAC and the 19478cfa0ad2SJack F Vogel * external PHY is reset. 19488cfa0ad2SJack F Vogel */ 19498cfa0ad2SJack F Vogel ctrl |= E1000_CTRL_PHY_RST; 19508cfa0ad2SJack F Vogel } 19518cfa0ad2SJack F Vogel ret_val = e1000_acquire_swflag_ich8lan(hw); 1952daf9197cSJack F Vogel DEBUGOUT("Issuing a global reset to ich8lan\n"); 19538cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_CTRL, (ctrl | E1000_CTRL_RST)); 19548cfa0ad2SJack F Vogel msec_delay(20); 19558cfa0ad2SJack F Vogel 19568cfa0ad2SJack F Vogel ret_val = e1000_get_auto_rd_done_generic(hw); 19578cfa0ad2SJack F Vogel if (ret_val) { 19588cfa0ad2SJack F Vogel /* 19598cfa0ad2SJack F Vogel * When auto config read does not complete, do not 19608cfa0ad2SJack F Vogel * return with an error. This can happen in situations 19618cfa0ad2SJack F Vogel * where there is no eeprom and prevents getting link. 19628cfa0ad2SJack F Vogel */ 19638cfa0ad2SJack F Vogel DEBUGOUT("Auto Read Done did not complete\n"); 19648cfa0ad2SJack F Vogel } 19658cfa0ad2SJack F Vogel 19668cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_IMC, 0xffffffff); 19678cfa0ad2SJack F Vogel icr = E1000_READ_REG(hw, E1000_ICR); 19688cfa0ad2SJack F Vogel 19698cfa0ad2SJack F Vogel kab = E1000_READ_REG(hw, E1000_KABGTXD); 19708cfa0ad2SJack F Vogel kab |= E1000_KABGTXD_BGSQLBIAS; 19718cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_KABGTXD, kab); 19728cfa0ad2SJack F Vogel 19738cfa0ad2SJack F Vogel return ret_val; 19748cfa0ad2SJack F Vogel } 19758cfa0ad2SJack F Vogel 19768cfa0ad2SJack F Vogel /** 19778cfa0ad2SJack F Vogel * e1000_init_hw_ich8lan - Initialize the hardware 19788cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 19798cfa0ad2SJack F Vogel * 19808cfa0ad2SJack F Vogel * Prepares the hardware for transmit and receive by doing the following: 19818cfa0ad2SJack F Vogel * - initialize hardware bits 19828cfa0ad2SJack F Vogel * - initialize LED identification 19838cfa0ad2SJack F Vogel * - setup receive address registers 19848cfa0ad2SJack F Vogel * - setup flow control 19858cfa0ad2SJack F Vogel * - setup transmit descriptors 19868cfa0ad2SJack F Vogel * - clear statistics 19878cfa0ad2SJack F Vogel **/ 19888cfa0ad2SJack F Vogel static s32 e1000_init_hw_ich8lan(struct e1000_hw *hw) 19898cfa0ad2SJack F Vogel { 19908cfa0ad2SJack F Vogel struct e1000_mac_info *mac = &hw->mac; 19918cfa0ad2SJack F Vogel u32 ctrl_ext, txdctl, snoop; 19928cfa0ad2SJack F Vogel s32 ret_val; 19938cfa0ad2SJack F Vogel u16 i; 19948cfa0ad2SJack F Vogel 19958cfa0ad2SJack F Vogel DEBUGFUNC("e1000_init_hw_ich8lan"); 19968cfa0ad2SJack F Vogel 19978cfa0ad2SJack F Vogel e1000_initialize_hw_bits_ich8lan(hw); 19988cfa0ad2SJack F Vogel 19998cfa0ad2SJack F Vogel /* Initialize identification LED */ 20008cfa0ad2SJack F Vogel ret_val = e1000_id_led_init_generic(hw); 20018cfa0ad2SJack F Vogel if (ret_val) { 20028cfa0ad2SJack F Vogel DEBUGOUT("Error initializing identification LED\n"); 20038cfa0ad2SJack F Vogel /* This is not fatal and we should not stop init due to this */ 20048cfa0ad2SJack F Vogel } 20058cfa0ad2SJack F Vogel 20068cfa0ad2SJack F Vogel /* Setup the receive address. */ 20078cfa0ad2SJack F Vogel e1000_init_rx_addrs_generic(hw, mac->rar_entry_count); 20088cfa0ad2SJack F Vogel 20098cfa0ad2SJack F Vogel /* Zero out the Multicast HASH table */ 20108cfa0ad2SJack F Vogel DEBUGOUT("Zeroing the MTA\n"); 20118cfa0ad2SJack F Vogel for (i = 0; i < mac->mta_reg_count; i++) 20128cfa0ad2SJack F Vogel E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0); 20138cfa0ad2SJack F Vogel 20148cfa0ad2SJack F Vogel /* Setup link and flow control */ 20158cfa0ad2SJack F Vogel ret_val = mac->ops.setup_link(hw); 20168cfa0ad2SJack F Vogel 20178cfa0ad2SJack F Vogel /* Set the transmit descriptor write-back policy for both queues */ 20188cfa0ad2SJack F Vogel txdctl = E1000_READ_REG(hw, E1000_TXDCTL(0)); 20198cfa0ad2SJack F Vogel txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | 20208cfa0ad2SJack F Vogel E1000_TXDCTL_FULL_TX_DESC_WB; 20218cfa0ad2SJack F Vogel txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | 20228cfa0ad2SJack F Vogel E1000_TXDCTL_MAX_TX_DESC_PREFETCH; 20238cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TXDCTL(0), txdctl); 20248cfa0ad2SJack F Vogel txdctl = E1000_READ_REG(hw, E1000_TXDCTL(1)); 20258cfa0ad2SJack F Vogel txdctl = (txdctl & ~E1000_TXDCTL_WTHRESH) | 20268cfa0ad2SJack F Vogel E1000_TXDCTL_FULL_TX_DESC_WB; 20278cfa0ad2SJack F Vogel txdctl = (txdctl & ~E1000_TXDCTL_PTHRESH) | 20288cfa0ad2SJack F Vogel E1000_TXDCTL_MAX_TX_DESC_PREFETCH; 20298cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TXDCTL(1), txdctl); 20308cfa0ad2SJack F Vogel 20318cfa0ad2SJack F Vogel /* 20328cfa0ad2SJack F Vogel * ICH8 has opposite polarity of no_snoop bits. 20338cfa0ad2SJack F Vogel * By default, we should use snoop behavior. 20348cfa0ad2SJack F Vogel */ 20358cfa0ad2SJack F Vogel if (mac->type == e1000_ich8lan) 20368cfa0ad2SJack F Vogel snoop = PCIE_ICH8_SNOOP_ALL; 20378cfa0ad2SJack F Vogel else 20388cfa0ad2SJack F Vogel snoop = (u32)~(PCIE_NO_SNOOP_ALL); 20398cfa0ad2SJack F Vogel e1000_set_pcie_no_snoop_generic(hw, snoop); 20408cfa0ad2SJack F Vogel 20418cfa0ad2SJack F Vogel ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT); 20428cfa0ad2SJack F Vogel ctrl_ext |= E1000_CTRL_EXT_RO_DIS; 20438cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext); 20448cfa0ad2SJack F Vogel 20458cfa0ad2SJack F Vogel /* 20468cfa0ad2SJack F Vogel * Clear all of the statistics registers (clear on read). It is 20478cfa0ad2SJack F Vogel * important that we do this after we have tried to establish link 20488cfa0ad2SJack F Vogel * because the symbol error count will increment wildly if there 20498cfa0ad2SJack F Vogel * is no link. 20508cfa0ad2SJack F Vogel */ 20518cfa0ad2SJack F Vogel e1000_clear_hw_cntrs_ich8lan(hw); 20528cfa0ad2SJack F Vogel 20538cfa0ad2SJack F Vogel return ret_val; 20548cfa0ad2SJack F Vogel } 20558cfa0ad2SJack F Vogel /** 20568cfa0ad2SJack F Vogel * e1000_initialize_hw_bits_ich8lan - Initialize required hardware bits 20578cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 20588cfa0ad2SJack F Vogel * 20598cfa0ad2SJack F Vogel * Sets/Clears required hardware bits necessary for correctly setting up the 20608cfa0ad2SJack F Vogel * hardware for transmit and receive. 20618cfa0ad2SJack F Vogel **/ 20628cfa0ad2SJack F Vogel static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw) 20638cfa0ad2SJack F Vogel { 20648cfa0ad2SJack F Vogel u32 reg; 20658cfa0ad2SJack F Vogel 20668cfa0ad2SJack F Vogel DEBUGFUNC("e1000_initialize_hw_bits_ich8lan"); 20678cfa0ad2SJack F Vogel 20688cfa0ad2SJack F Vogel /* Extended Device Control */ 20698cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_CTRL_EXT); 20708cfa0ad2SJack F Vogel reg |= (1 << 22); 20718cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_CTRL_EXT, reg); 20728cfa0ad2SJack F Vogel 20738cfa0ad2SJack F Vogel /* Transmit Descriptor Control 0 */ 20748cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_TXDCTL(0)); 20758cfa0ad2SJack F Vogel reg |= (1 << 22); 20768cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TXDCTL(0), reg); 20778cfa0ad2SJack F Vogel 20788cfa0ad2SJack F Vogel /* Transmit Descriptor Control 1 */ 20798cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_TXDCTL(1)); 20808cfa0ad2SJack F Vogel reg |= (1 << 22); 20818cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TXDCTL(1), reg); 20828cfa0ad2SJack F Vogel 20838cfa0ad2SJack F Vogel /* Transmit Arbitration Control 0 */ 20848cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_TARC(0)); 20858cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich8lan) 20868cfa0ad2SJack F Vogel reg |= (1 << 28) | (1 << 29); 20878cfa0ad2SJack F Vogel reg |= (1 << 23) | (1 << 24) | (1 << 26) | (1 << 27); 20888cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TARC(0), reg); 20898cfa0ad2SJack F Vogel 20908cfa0ad2SJack F Vogel /* Transmit Arbitration Control 1 */ 20918cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_TARC(1)); 20928cfa0ad2SJack F Vogel if (E1000_READ_REG(hw, E1000_TCTL) & E1000_TCTL_MULR) 20938cfa0ad2SJack F Vogel reg &= ~(1 << 28); 20948cfa0ad2SJack F Vogel else 20958cfa0ad2SJack F Vogel reg |= (1 << 28); 20968cfa0ad2SJack F Vogel reg |= (1 << 24) | (1 << 26) | (1 << 30); 20978cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_TARC(1), reg); 20988cfa0ad2SJack F Vogel 20998cfa0ad2SJack F Vogel /* Device Status */ 21008cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich8lan) { 21018cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_STATUS); 21028cfa0ad2SJack F Vogel reg &= ~(1 << 31); 21038cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_STATUS, reg); 21048cfa0ad2SJack F Vogel } 21058cfa0ad2SJack F Vogel 21068cfa0ad2SJack F Vogel return; 21078cfa0ad2SJack F Vogel } 21088cfa0ad2SJack F Vogel 21098cfa0ad2SJack F Vogel /** 21108cfa0ad2SJack F Vogel * e1000_setup_link_ich8lan - Setup flow control and link settings 21118cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 21128cfa0ad2SJack F Vogel * 21138cfa0ad2SJack F Vogel * Determines which flow control settings to use, then configures flow 21148cfa0ad2SJack F Vogel * control. Calls the appropriate media-specific link configuration 21158cfa0ad2SJack F Vogel * function. Assuming the adapter has a valid link partner, a valid link 21168cfa0ad2SJack F Vogel * should be established. Assumes the hardware has previously been reset 21178cfa0ad2SJack F Vogel * and the transmitter and receiver are not enabled. 21188cfa0ad2SJack F Vogel **/ 21198cfa0ad2SJack F Vogel static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw) 21208cfa0ad2SJack F Vogel { 21218cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 21228cfa0ad2SJack F Vogel 21238cfa0ad2SJack F Vogel DEBUGFUNC("e1000_setup_link_ich8lan"); 21248cfa0ad2SJack F Vogel 21258cfa0ad2SJack F Vogel if (hw->phy.ops.check_reset_block(hw)) 21268cfa0ad2SJack F Vogel goto out; 21278cfa0ad2SJack F Vogel 21288cfa0ad2SJack F Vogel /* 21298cfa0ad2SJack F Vogel * ICH parts do not have a word in the NVM to determine 21308cfa0ad2SJack F Vogel * the default flow control setting, so we explicitly 21318cfa0ad2SJack F Vogel * set it to full. 21328cfa0ad2SJack F Vogel */ 2133daf9197cSJack F Vogel if (hw->fc.requested_mode == e1000_fc_default) 2134daf9197cSJack F Vogel hw->fc.requested_mode = e1000_fc_full; 21358cfa0ad2SJack F Vogel 2136daf9197cSJack F Vogel /* 2137daf9197cSJack F Vogel * Save off the requested flow control mode for use later. Depending 2138daf9197cSJack F Vogel * on the link partner's capabilities, we may or may not use this mode. 2139daf9197cSJack F Vogel */ 2140daf9197cSJack F Vogel hw->fc.current_mode = hw->fc.requested_mode; 21418cfa0ad2SJack F Vogel 2142daf9197cSJack F Vogel DEBUGOUT1("After fix-ups FlowControl is now = %x\n", 2143daf9197cSJack F Vogel hw->fc.current_mode); 21448cfa0ad2SJack F Vogel 21458cfa0ad2SJack F Vogel /* Continue to configure the copper link. */ 21468cfa0ad2SJack F Vogel ret_val = hw->mac.ops.setup_physical_interface(hw); 21478cfa0ad2SJack F Vogel if (ret_val) 21488cfa0ad2SJack F Vogel goto out; 21498cfa0ad2SJack F Vogel 21508cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_FCTTV, hw->fc.pause_time); 21518cfa0ad2SJack F Vogel 21528cfa0ad2SJack F Vogel ret_val = e1000_set_fc_watermarks_generic(hw); 21538cfa0ad2SJack F Vogel 21548cfa0ad2SJack F Vogel out: 21558cfa0ad2SJack F Vogel return ret_val; 21568cfa0ad2SJack F Vogel } 21578cfa0ad2SJack F Vogel 21588cfa0ad2SJack F Vogel /** 21598cfa0ad2SJack F Vogel * e1000_setup_copper_link_ich8lan - Configure MAC/PHY interface 21608cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 21618cfa0ad2SJack F Vogel * 21628cfa0ad2SJack F Vogel * Configures the kumeran interface to the PHY to wait the appropriate time 21638cfa0ad2SJack F Vogel * when polling the PHY, then call the generic setup_copper_link to finish 21648cfa0ad2SJack F Vogel * configuring the copper link. 21658cfa0ad2SJack F Vogel **/ 21668cfa0ad2SJack F Vogel static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw) 21678cfa0ad2SJack F Vogel { 21688cfa0ad2SJack F Vogel u32 ctrl; 21698cfa0ad2SJack F Vogel s32 ret_val; 21708cfa0ad2SJack F Vogel u16 reg_data; 21718cfa0ad2SJack F Vogel 21728cfa0ad2SJack F Vogel DEBUGFUNC("e1000_setup_copper_link_ich8lan"); 21738cfa0ad2SJack F Vogel 21748cfa0ad2SJack F Vogel ctrl = E1000_READ_REG(hw, E1000_CTRL); 21758cfa0ad2SJack F Vogel ctrl |= E1000_CTRL_SLU; 21768cfa0ad2SJack F Vogel ctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX); 21778cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_CTRL, ctrl); 21788cfa0ad2SJack F Vogel 21798cfa0ad2SJack F Vogel /* 21808cfa0ad2SJack F Vogel * Set the mac to wait the maximum time between each iteration 21818cfa0ad2SJack F Vogel * and increase the max iterations when polling the phy; 21828cfa0ad2SJack F Vogel * this fixes erroneous timeouts at 10Mbps. 21838cfa0ad2SJack F Vogel */ 21848cfa0ad2SJack F Vogel ret_val = e1000_write_kmrn_reg_generic(hw, GG82563_REG(0x34, 4), 21858cfa0ad2SJack F Vogel 0xFFFF); 21868cfa0ad2SJack F Vogel if (ret_val) 21878cfa0ad2SJack F Vogel goto out; 21888cfa0ad2SJack F Vogel ret_val = e1000_read_kmrn_reg_generic(hw, GG82563_REG(0x34, 9), 21898cfa0ad2SJack F Vogel ®_data); 21908cfa0ad2SJack F Vogel if (ret_val) 21918cfa0ad2SJack F Vogel goto out; 21928cfa0ad2SJack F Vogel reg_data |= 0x3F; 21938cfa0ad2SJack F Vogel ret_val = e1000_write_kmrn_reg_generic(hw, GG82563_REG(0x34, 9), 21948cfa0ad2SJack F Vogel reg_data); 21958cfa0ad2SJack F Vogel if (ret_val) 21968cfa0ad2SJack F Vogel goto out; 21978cfa0ad2SJack F Vogel 21988cfa0ad2SJack F Vogel if (hw->phy.type == e1000_phy_igp_3) { 21998cfa0ad2SJack F Vogel ret_val = e1000_copper_link_setup_igp(hw); 22008cfa0ad2SJack F Vogel if (ret_val) 22018cfa0ad2SJack F Vogel goto out; 22028cfa0ad2SJack F Vogel } else if (hw->phy.type == e1000_phy_bm) { 22038cfa0ad2SJack F Vogel ret_val = e1000_copper_link_setup_m88(hw); 22048cfa0ad2SJack F Vogel if (ret_val) 22058cfa0ad2SJack F Vogel goto out; 22068cfa0ad2SJack F Vogel } 22078cfa0ad2SJack F Vogel 22088cfa0ad2SJack F Vogel if (hw->phy.type == e1000_phy_ife) { 22098cfa0ad2SJack F Vogel ret_val = hw->phy.ops.read_reg(hw, IFE_PHY_MDIX_CONTROL, 22108cfa0ad2SJack F Vogel ®_data); 22118cfa0ad2SJack F Vogel if (ret_val) 22128cfa0ad2SJack F Vogel goto out; 22138cfa0ad2SJack F Vogel 22148cfa0ad2SJack F Vogel reg_data &= ~IFE_PMC_AUTO_MDIX; 22158cfa0ad2SJack F Vogel 22168cfa0ad2SJack F Vogel switch (hw->phy.mdix) { 22178cfa0ad2SJack F Vogel case 1: 22188cfa0ad2SJack F Vogel reg_data &= ~IFE_PMC_FORCE_MDIX; 22198cfa0ad2SJack F Vogel break; 22208cfa0ad2SJack F Vogel case 2: 22218cfa0ad2SJack F Vogel reg_data |= IFE_PMC_FORCE_MDIX; 22228cfa0ad2SJack F Vogel break; 22238cfa0ad2SJack F Vogel case 0: 22248cfa0ad2SJack F Vogel default: 22258cfa0ad2SJack F Vogel reg_data |= IFE_PMC_AUTO_MDIX; 22268cfa0ad2SJack F Vogel break; 22278cfa0ad2SJack F Vogel } 22288cfa0ad2SJack F Vogel ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_MDIX_CONTROL, 22298cfa0ad2SJack F Vogel reg_data); 22308cfa0ad2SJack F Vogel if (ret_val) 22318cfa0ad2SJack F Vogel goto out; 22328cfa0ad2SJack F Vogel } 22338cfa0ad2SJack F Vogel ret_val = e1000_setup_copper_link_generic(hw); 22348cfa0ad2SJack F Vogel 22358cfa0ad2SJack F Vogel out: 22368cfa0ad2SJack F Vogel return ret_val; 22378cfa0ad2SJack F Vogel } 22388cfa0ad2SJack F Vogel 22398cfa0ad2SJack F Vogel /** 22408cfa0ad2SJack F Vogel * e1000_get_link_up_info_ich8lan - Get current link speed and duplex 22418cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 22428cfa0ad2SJack F Vogel * @speed: pointer to store current link speed 22438cfa0ad2SJack F Vogel * @duplex: pointer to store the current link duplex 22448cfa0ad2SJack F Vogel * 22458cfa0ad2SJack F Vogel * Calls the generic get_speed_and_duplex to retrieve the current link 22468cfa0ad2SJack F Vogel * information and then calls the Kumeran lock loss workaround for links at 22478cfa0ad2SJack F Vogel * gigabit speeds. 22488cfa0ad2SJack F Vogel **/ 22498cfa0ad2SJack F Vogel static s32 e1000_get_link_up_info_ich8lan(struct e1000_hw *hw, u16 *speed, 22508cfa0ad2SJack F Vogel u16 *duplex) 22518cfa0ad2SJack F Vogel { 22528cfa0ad2SJack F Vogel s32 ret_val; 22538cfa0ad2SJack F Vogel 22548cfa0ad2SJack F Vogel DEBUGFUNC("e1000_get_link_up_info_ich8lan"); 22558cfa0ad2SJack F Vogel 22568cfa0ad2SJack F Vogel ret_val = e1000_get_speed_and_duplex_copper_generic(hw, speed, duplex); 22578cfa0ad2SJack F Vogel if (ret_val) 22588cfa0ad2SJack F Vogel goto out; 22598cfa0ad2SJack F Vogel 22608cfa0ad2SJack F Vogel if ((hw->mac.type == e1000_ich8lan) && 22618cfa0ad2SJack F Vogel (hw->phy.type == e1000_phy_igp_3) && 22628cfa0ad2SJack F Vogel (*speed == SPEED_1000)) { 22638cfa0ad2SJack F Vogel ret_val = e1000_kmrn_lock_loss_workaround_ich8lan(hw); 22648cfa0ad2SJack F Vogel } 22658cfa0ad2SJack F Vogel 22668cfa0ad2SJack F Vogel out: 22678cfa0ad2SJack F Vogel return ret_val; 22688cfa0ad2SJack F Vogel } 22698cfa0ad2SJack F Vogel 22708cfa0ad2SJack F Vogel /** 22718cfa0ad2SJack F Vogel * e1000_kmrn_lock_loss_workaround_ich8lan - Kumeran workaround 22728cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 22738cfa0ad2SJack F Vogel * 22748cfa0ad2SJack F Vogel * Work-around for 82566 Kumeran PCS lock loss: 22758cfa0ad2SJack F Vogel * On link status change (i.e. PCI reset, speed change) and link is up and 22768cfa0ad2SJack F Vogel * speed is gigabit- 22778cfa0ad2SJack F Vogel * 0) if workaround is optionally disabled do nothing 22788cfa0ad2SJack F Vogel * 1) wait 1ms for Kumeran link to come up 22798cfa0ad2SJack F Vogel * 2) check Kumeran Diagnostic register PCS lock loss bit 22808cfa0ad2SJack F Vogel * 3) if not set the link is locked (all is good), otherwise... 22818cfa0ad2SJack F Vogel * 4) reset the PHY 22828cfa0ad2SJack F Vogel * 5) repeat up to 10 times 22838cfa0ad2SJack F Vogel * Note: this is only called for IGP3 copper when speed is 1gb. 22848cfa0ad2SJack F Vogel **/ 22858cfa0ad2SJack F Vogel static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw) 22868cfa0ad2SJack F Vogel { 2287daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 22888cfa0ad2SJack F Vogel u32 phy_ctrl; 22898cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 22908cfa0ad2SJack F Vogel u16 i, data; 22918cfa0ad2SJack F Vogel bool link; 22928cfa0ad2SJack F Vogel 22938cfa0ad2SJack F Vogel DEBUGFUNC("e1000_kmrn_lock_loss_workaround_ich8lan"); 22948cfa0ad2SJack F Vogel 22958cfa0ad2SJack F Vogel if (!(dev_spec->kmrn_lock_loss_workaround_enabled)) 22968cfa0ad2SJack F Vogel goto out; 22978cfa0ad2SJack F Vogel 22988cfa0ad2SJack F Vogel /* 22998cfa0ad2SJack F Vogel * Make sure link is up before proceeding. If not just return. 23008cfa0ad2SJack F Vogel * Attempting this while link is negotiating fouled up link 23018cfa0ad2SJack F Vogel * stability 23028cfa0ad2SJack F Vogel */ 23038cfa0ad2SJack F Vogel ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link); 23048cfa0ad2SJack F Vogel if (!link) { 23058cfa0ad2SJack F Vogel ret_val = E1000_SUCCESS; 23068cfa0ad2SJack F Vogel goto out; 23078cfa0ad2SJack F Vogel } 23088cfa0ad2SJack F Vogel 23098cfa0ad2SJack F Vogel for (i = 0; i < 10; i++) { 23108cfa0ad2SJack F Vogel /* read once to clear */ 23118cfa0ad2SJack F Vogel ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data); 23128cfa0ad2SJack F Vogel if (ret_val) 23138cfa0ad2SJack F Vogel goto out; 23148cfa0ad2SJack F Vogel /* and again to get new status */ 23158cfa0ad2SJack F Vogel ret_val = hw->phy.ops.read_reg(hw, IGP3_KMRN_DIAG, &data); 23168cfa0ad2SJack F Vogel if (ret_val) 23178cfa0ad2SJack F Vogel goto out; 23188cfa0ad2SJack F Vogel 23198cfa0ad2SJack F Vogel /* check for PCS lock */ 23208cfa0ad2SJack F Vogel if (!(data & IGP3_KMRN_DIAG_PCS_LOCK_LOSS)) { 23218cfa0ad2SJack F Vogel ret_val = E1000_SUCCESS; 23228cfa0ad2SJack F Vogel goto out; 23238cfa0ad2SJack F Vogel } 23248cfa0ad2SJack F Vogel 23258cfa0ad2SJack F Vogel /* Issue PHY reset */ 23268cfa0ad2SJack F Vogel hw->phy.ops.reset(hw); 23278cfa0ad2SJack F Vogel msec_delay_irq(5); 23288cfa0ad2SJack F Vogel } 23298cfa0ad2SJack F Vogel /* Disable GigE link negotiation */ 23308cfa0ad2SJack F Vogel phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL); 23318cfa0ad2SJack F Vogel phy_ctrl |= (E1000_PHY_CTRL_GBE_DISABLE | 23328cfa0ad2SJack F Vogel E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 23338cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 23348cfa0ad2SJack F Vogel 23358cfa0ad2SJack F Vogel /* 23368cfa0ad2SJack F Vogel * Call gig speed drop workaround on Gig disable before accessing 23378cfa0ad2SJack F Vogel * any PHY registers 23388cfa0ad2SJack F Vogel */ 23398cfa0ad2SJack F Vogel e1000_gig_downshift_workaround_ich8lan(hw); 23408cfa0ad2SJack F Vogel 23418cfa0ad2SJack F Vogel /* unable to acquire PCS lock */ 23428cfa0ad2SJack F Vogel ret_val = -E1000_ERR_PHY; 23438cfa0ad2SJack F Vogel 23448cfa0ad2SJack F Vogel out: 23458cfa0ad2SJack F Vogel return ret_val; 23468cfa0ad2SJack F Vogel } 23478cfa0ad2SJack F Vogel 23488cfa0ad2SJack F Vogel /** 23498cfa0ad2SJack F Vogel * e1000_set_kmrn_lock_loss_workaround_ich8lan - Set Kumeran workaround state 23508cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 23518cfa0ad2SJack F Vogel * @state: boolean value used to set the current Kumeran workaround state 23528cfa0ad2SJack F Vogel * 23538cfa0ad2SJack F Vogel * If ICH8, set the current Kumeran workaround state (enabled - TRUE 23548cfa0ad2SJack F Vogel * /disabled - FALSE). 23558cfa0ad2SJack F Vogel **/ 23568cfa0ad2SJack F Vogel void e1000_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, 23578cfa0ad2SJack F Vogel bool state) 23588cfa0ad2SJack F Vogel { 2359daf9197cSJack F Vogel struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 23608cfa0ad2SJack F Vogel 23618cfa0ad2SJack F Vogel DEBUGFUNC("e1000_set_kmrn_lock_loss_workaround_ich8lan"); 23628cfa0ad2SJack F Vogel 23638cfa0ad2SJack F Vogel if (hw->mac.type != e1000_ich8lan) { 23648cfa0ad2SJack F Vogel DEBUGOUT("Workaround applies to ICH8 only.\n"); 2365daf9197cSJack F Vogel return; 23668cfa0ad2SJack F Vogel } 23678cfa0ad2SJack F Vogel 23688cfa0ad2SJack F Vogel dev_spec->kmrn_lock_loss_workaround_enabled = state; 23698cfa0ad2SJack F Vogel 23708cfa0ad2SJack F Vogel return; 23718cfa0ad2SJack F Vogel } 23728cfa0ad2SJack F Vogel 23738cfa0ad2SJack F Vogel /** 23748cfa0ad2SJack F Vogel * e1000_ipg3_phy_powerdown_workaround_ich8lan - Power down workaround on D3 23758cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 23768cfa0ad2SJack F Vogel * 23778cfa0ad2SJack F Vogel * Workaround for 82566 power-down on D3 entry: 23788cfa0ad2SJack F Vogel * 1) disable gigabit link 23798cfa0ad2SJack F Vogel * 2) write VR power-down enable 23808cfa0ad2SJack F Vogel * 3) read it back 23818cfa0ad2SJack F Vogel * Continue if successful, else issue LCD reset and repeat 23828cfa0ad2SJack F Vogel **/ 23838cfa0ad2SJack F Vogel void e1000_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw) 23848cfa0ad2SJack F Vogel { 23858cfa0ad2SJack F Vogel u32 reg; 23868cfa0ad2SJack F Vogel u16 data; 23878cfa0ad2SJack F Vogel u8 retry = 0; 23888cfa0ad2SJack F Vogel 23898cfa0ad2SJack F Vogel DEBUGFUNC("e1000_igp3_phy_powerdown_workaround_ich8lan"); 23908cfa0ad2SJack F Vogel 23918cfa0ad2SJack F Vogel if (hw->phy.type != e1000_phy_igp_3) 23928cfa0ad2SJack F Vogel goto out; 23938cfa0ad2SJack F Vogel 23948cfa0ad2SJack F Vogel /* Try the workaround twice (if needed) */ 23958cfa0ad2SJack F Vogel do { 23968cfa0ad2SJack F Vogel /* Disable link */ 23978cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_PHY_CTRL); 23988cfa0ad2SJack F Vogel reg |= (E1000_PHY_CTRL_GBE_DISABLE | 23998cfa0ad2SJack F Vogel E1000_PHY_CTRL_NOND0A_GBE_DISABLE); 24008cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, reg); 24018cfa0ad2SJack F Vogel 24028cfa0ad2SJack F Vogel /* 24038cfa0ad2SJack F Vogel * Call gig speed drop workaround on Gig disable before 24048cfa0ad2SJack F Vogel * accessing any PHY registers 24058cfa0ad2SJack F Vogel */ 24068cfa0ad2SJack F Vogel if (hw->mac.type == e1000_ich8lan) 24078cfa0ad2SJack F Vogel e1000_gig_downshift_workaround_ich8lan(hw); 24088cfa0ad2SJack F Vogel 24098cfa0ad2SJack F Vogel /* Write VR power-down enable */ 24108cfa0ad2SJack F Vogel hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data); 24118cfa0ad2SJack F Vogel data &= ~IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; 2412daf9197cSJack F Vogel hw->phy.ops.write_reg(hw, IGP3_VR_CTRL, 24138cfa0ad2SJack F Vogel data | IGP3_VR_CTRL_MODE_SHUTDOWN); 24148cfa0ad2SJack F Vogel 24158cfa0ad2SJack F Vogel /* Read it back and test */ 24168cfa0ad2SJack F Vogel hw->phy.ops.read_reg(hw, IGP3_VR_CTRL, &data); 24178cfa0ad2SJack F Vogel data &= IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK; 24188cfa0ad2SJack F Vogel if ((data == IGP3_VR_CTRL_MODE_SHUTDOWN) || retry) 24198cfa0ad2SJack F Vogel break; 24208cfa0ad2SJack F Vogel 24218cfa0ad2SJack F Vogel /* Issue PHY reset and repeat at most one more time */ 24228cfa0ad2SJack F Vogel reg = E1000_READ_REG(hw, E1000_CTRL); 24238cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_CTRL, reg | E1000_CTRL_PHY_RST); 24248cfa0ad2SJack F Vogel retry++; 24258cfa0ad2SJack F Vogel } while (retry); 24268cfa0ad2SJack F Vogel 24278cfa0ad2SJack F Vogel out: 24288cfa0ad2SJack F Vogel return; 24298cfa0ad2SJack F Vogel } 24308cfa0ad2SJack F Vogel 24318cfa0ad2SJack F Vogel /** 24328cfa0ad2SJack F Vogel * e1000_gig_downshift_workaround_ich8lan - WoL from S5 stops working 24338cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 24348cfa0ad2SJack F Vogel * 24358cfa0ad2SJack F Vogel * Steps to take when dropping from 1Gb/s (eg. link cable removal (LSC), 24368cfa0ad2SJack F Vogel * LPLU, Gig disable, MDIC PHY reset): 24378cfa0ad2SJack F Vogel * 1) Set Kumeran Near-end loopback 24388cfa0ad2SJack F Vogel * 2) Clear Kumeran Near-end loopback 24398cfa0ad2SJack F Vogel * Should only be called for ICH8[m] devices with IGP_3 Phy. 24408cfa0ad2SJack F Vogel **/ 24418cfa0ad2SJack F Vogel void e1000_gig_downshift_workaround_ich8lan(struct e1000_hw *hw) 24428cfa0ad2SJack F Vogel { 24438cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 24448cfa0ad2SJack F Vogel u16 reg_data; 24458cfa0ad2SJack F Vogel 24468cfa0ad2SJack F Vogel DEBUGFUNC("e1000_gig_downshift_workaround_ich8lan"); 24478cfa0ad2SJack F Vogel 24488cfa0ad2SJack F Vogel if ((hw->mac.type != e1000_ich8lan) || 24498cfa0ad2SJack F Vogel (hw->phy.type != e1000_phy_igp_3)) 24508cfa0ad2SJack F Vogel goto out; 24518cfa0ad2SJack F Vogel 24528cfa0ad2SJack F Vogel ret_val = e1000_read_kmrn_reg_generic(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, 24538cfa0ad2SJack F Vogel ®_data); 24548cfa0ad2SJack F Vogel if (ret_val) 24558cfa0ad2SJack F Vogel goto out; 24568cfa0ad2SJack F Vogel reg_data |= E1000_KMRNCTRLSTA_DIAG_NELPBK; 24578cfa0ad2SJack F Vogel ret_val = e1000_write_kmrn_reg_generic(hw, 24588cfa0ad2SJack F Vogel E1000_KMRNCTRLSTA_DIAG_OFFSET, 24598cfa0ad2SJack F Vogel reg_data); 24608cfa0ad2SJack F Vogel if (ret_val) 24618cfa0ad2SJack F Vogel goto out; 24628cfa0ad2SJack F Vogel reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; 24638cfa0ad2SJack F Vogel ret_val = e1000_write_kmrn_reg_generic(hw, 24648cfa0ad2SJack F Vogel E1000_KMRNCTRLSTA_DIAG_OFFSET, 24658cfa0ad2SJack F Vogel reg_data); 24668cfa0ad2SJack F Vogel out: 24678cfa0ad2SJack F Vogel return; 24688cfa0ad2SJack F Vogel } 24698cfa0ad2SJack F Vogel 24708cfa0ad2SJack F Vogel /** 24718cfa0ad2SJack F Vogel * e1000_disable_gig_wol_ich8lan - disable gig during WoL 24728cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 24738cfa0ad2SJack F Vogel * 24748cfa0ad2SJack F Vogel * During S0 to Sx transition, it is possible the link remains at gig 24758cfa0ad2SJack F Vogel * instead of negotiating to a lower speed. Before going to Sx, set 24768cfa0ad2SJack F Vogel * 'LPLU Enabled' and 'Gig Disable' to force link speed negotiation 24778cfa0ad2SJack F Vogel * to a lower speed. 24788cfa0ad2SJack F Vogel * 24798cfa0ad2SJack F Vogel * Should only be called for ICH9 and ICH10 devices. 24808cfa0ad2SJack F Vogel **/ 24818cfa0ad2SJack F Vogel void e1000_disable_gig_wol_ich8lan(struct e1000_hw *hw) 24828cfa0ad2SJack F Vogel { 24838cfa0ad2SJack F Vogel u32 phy_ctrl; 24848cfa0ad2SJack F Vogel 24858cfa0ad2SJack F Vogel if ((hw->mac.type == e1000_ich10lan) || 24868cfa0ad2SJack F Vogel (hw->mac.type == e1000_ich9lan)) { 24878cfa0ad2SJack F Vogel phy_ctrl = E1000_READ_REG(hw, E1000_PHY_CTRL); 24888cfa0ad2SJack F Vogel phy_ctrl |= E1000_PHY_CTRL_D0A_LPLU | 24898cfa0ad2SJack F Vogel E1000_PHY_CTRL_GBE_DISABLE; 24908cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_PHY_CTRL, phy_ctrl); 24918cfa0ad2SJack F Vogel } 24928cfa0ad2SJack F Vogel 24938cfa0ad2SJack F Vogel return; 24948cfa0ad2SJack F Vogel } 24958cfa0ad2SJack F Vogel 24968cfa0ad2SJack F Vogel /** 24978cfa0ad2SJack F Vogel * e1000_cleanup_led_ich8lan - Restore the default LED operation 24988cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 24998cfa0ad2SJack F Vogel * 25008cfa0ad2SJack F Vogel * Return the LED back to the default configuration. 25018cfa0ad2SJack F Vogel **/ 25028cfa0ad2SJack F Vogel static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw) 25038cfa0ad2SJack F Vogel { 25048cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 25058cfa0ad2SJack F Vogel 25068cfa0ad2SJack F Vogel DEBUGFUNC("e1000_cleanup_led_ich8lan"); 25078cfa0ad2SJack F Vogel 25088cfa0ad2SJack F Vogel if (hw->phy.type == e1000_phy_ife) 2509daf9197cSJack F Vogel ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 25108cfa0ad2SJack F Vogel 0); 25118cfa0ad2SJack F Vogel else 25128cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_default); 25138cfa0ad2SJack F Vogel 25148cfa0ad2SJack F Vogel return ret_val; 25158cfa0ad2SJack F Vogel } 25168cfa0ad2SJack F Vogel 25178cfa0ad2SJack F Vogel /** 25188cfa0ad2SJack F Vogel * e1000_led_on_ich8lan - Turn LEDs on 25198cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 25208cfa0ad2SJack F Vogel * 25218cfa0ad2SJack F Vogel * Turn on the LEDs. 25228cfa0ad2SJack F Vogel **/ 25238cfa0ad2SJack F Vogel static s32 e1000_led_on_ich8lan(struct e1000_hw *hw) 25248cfa0ad2SJack F Vogel { 25258cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 25268cfa0ad2SJack F Vogel 25278cfa0ad2SJack F Vogel DEBUGFUNC("e1000_led_on_ich8lan"); 25288cfa0ad2SJack F Vogel 25298cfa0ad2SJack F Vogel if (hw->phy.type == e1000_phy_ife) 2530daf9197cSJack F Vogel ret_val = hw->phy.ops.write_reg(hw, IFE_PHY_SPECIAL_CONTROL_LED, 25318cfa0ad2SJack F Vogel (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_ON)); 25328cfa0ad2SJack F Vogel else 25338cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode2); 25348cfa0ad2SJack F Vogel 25358cfa0ad2SJack F Vogel return ret_val; 25368cfa0ad2SJack F Vogel } 25378cfa0ad2SJack F Vogel 25388cfa0ad2SJack F Vogel /** 25398cfa0ad2SJack F Vogel * e1000_led_off_ich8lan - Turn LEDs off 25408cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 25418cfa0ad2SJack F Vogel * 25428cfa0ad2SJack F Vogel * Turn off the LEDs. 25438cfa0ad2SJack F Vogel **/ 25448cfa0ad2SJack F Vogel static s32 e1000_led_off_ich8lan(struct e1000_hw *hw) 25458cfa0ad2SJack F Vogel { 25468cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 25478cfa0ad2SJack F Vogel 25488cfa0ad2SJack F Vogel DEBUGFUNC("e1000_led_off_ich8lan"); 25498cfa0ad2SJack F Vogel 25508cfa0ad2SJack F Vogel if (hw->phy.type == e1000_phy_ife) 25518cfa0ad2SJack F Vogel ret_val = hw->phy.ops.write_reg(hw, 25528cfa0ad2SJack F Vogel IFE_PHY_SPECIAL_CONTROL_LED, 25538cfa0ad2SJack F Vogel (IFE_PSCL_PROBE_MODE | IFE_PSCL_PROBE_LEDS_OFF)); 25548cfa0ad2SJack F Vogel else 25558cfa0ad2SJack F Vogel E1000_WRITE_REG(hw, E1000_LEDCTL, hw->mac.ledctl_mode1); 25568cfa0ad2SJack F Vogel 25578cfa0ad2SJack F Vogel return ret_val; 25588cfa0ad2SJack F Vogel } 25598cfa0ad2SJack F Vogel 25608cfa0ad2SJack F Vogel /** 25618cfa0ad2SJack F Vogel * e1000_get_cfg_done_ich8lan - Read config done bit 25628cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 25638cfa0ad2SJack F Vogel * 25648cfa0ad2SJack F Vogel * Read the management control register for the config done bit for 25658cfa0ad2SJack F Vogel * completion status. NOTE: silicon which is EEPROM-less will fail trying 25668cfa0ad2SJack F Vogel * to read the config done bit, so an error is *ONLY* logged and returns 25678cfa0ad2SJack F Vogel * E1000_SUCCESS. If we were to return with error, EEPROM-less silicon 25688cfa0ad2SJack F Vogel * would not be able to be reset or change link. 25698cfa0ad2SJack F Vogel **/ 25708cfa0ad2SJack F Vogel static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw) 25718cfa0ad2SJack F Vogel { 25728cfa0ad2SJack F Vogel s32 ret_val = E1000_SUCCESS; 25738cfa0ad2SJack F Vogel u32 bank = 0; 25748cfa0ad2SJack F Vogel 25758cfa0ad2SJack F Vogel e1000_get_cfg_done_generic(hw); 25768cfa0ad2SJack F Vogel 25778cfa0ad2SJack F Vogel /* If EEPROM is not marked present, init the IGP 3 PHY manually */ 25788cfa0ad2SJack F Vogel if (hw->mac.type != e1000_ich10lan) { 25798cfa0ad2SJack F Vogel if (((E1000_READ_REG(hw, E1000_EECD) & E1000_EECD_PRES) == 0) && 25808cfa0ad2SJack F Vogel (hw->phy.type == e1000_phy_igp_3)) { 25818cfa0ad2SJack F Vogel e1000_phy_init_script_igp3(hw); 25828cfa0ad2SJack F Vogel } 25838cfa0ad2SJack F Vogel } else { 25848cfa0ad2SJack F Vogel if (e1000_valid_nvm_bank_detect_ich8lan(hw, &bank)) { 2585daf9197cSJack F Vogel /* Maybe we should do a basic PHY config */ 25868cfa0ad2SJack F Vogel DEBUGOUT("EEPROM not present\n"); 25878cfa0ad2SJack F Vogel ret_val = -E1000_ERR_CONFIG; 25888cfa0ad2SJack F Vogel } 25898cfa0ad2SJack F Vogel } 25908cfa0ad2SJack F Vogel 25918cfa0ad2SJack F Vogel return ret_val; 25928cfa0ad2SJack F Vogel } 25938cfa0ad2SJack F Vogel 25948cfa0ad2SJack F Vogel /** 25958cfa0ad2SJack F Vogel * e1000_power_down_phy_copper_ich8lan - Remove link during PHY power down 25968cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 25978cfa0ad2SJack F Vogel * 25988cfa0ad2SJack F Vogel * In the case of a PHY power down to save power, or to turn off link during a 25998cfa0ad2SJack F Vogel * driver unload, or wake on lan is not enabled, remove the link. 26008cfa0ad2SJack F Vogel **/ 26018cfa0ad2SJack F Vogel static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw) 26028cfa0ad2SJack F Vogel { 26038cfa0ad2SJack F Vogel /* If the management interface is not enabled, then power down */ 2604daf9197cSJack F Vogel if (!(hw->mac.ops.check_mng_mode(hw) || 2605daf9197cSJack F Vogel hw->phy.ops.check_reset_block(hw))) 26068cfa0ad2SJack F Vogel e1000_power_down_phy_copper(hw); 26078cfa0ad2SJack F Vogel 26088cfa0ad2SJack F Vogel return; 26098cfa0ad2SJack F Vogel } 26108cfa0ad2SJack F Vogel 26118cfa0ad2SJack F Vogel /** 26128cfa0ad2SJack F Vogel * e1000_clear_hw_cntrs_ich8lan - Clear statistical counters 26138cfa0ad2SJack F Vogel * @hw: pointer to the HW structure 26148cfa0ad2SJack F Vogel * 26158cfa0ad2SJack F Vogel * Clears hardware counters specific to the silicon family and calls 26168cfa0ad2SJack F Vogel * clear_hw_cntrs_generic to clear all general purpose counters. 26178cfa0ad2SJack F Vogel **/ 26188cfa0ad2SJack F Vogel static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw) 26198cfa0ad2SJack F Vogel { 26208cfa0ad2SJack F Vogel DEBUGFUNC("e1000_clear_hw_cntrs_ich8lan"); 26218cfa0ad2SJack F Vogel 26228cfa0ad2SJack F Vogel e1000_clear_hw_cntrs_base_generic(hw); 26238cfa0ad2SJack F Vogel 2624daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_ALGNERRC); 2625daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_RXERRC); 2626daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_TNCRS); 2627daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_CEXTERR); 2628daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_TSCTC); 2629daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_TSCTFC); 26308cfa0ad2SJack F Vogel 2631daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_MGTPRC); 2632daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_MGTPDC); 2633daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_MGTPTC); 26348cfa0ad2SJack F Vogel 2635daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_IAC); 2636daf9197cSJack F Vogel E1000_READ_REG(hw, E1000_ICRXOC); 26378cfa0ad2SJack F Vogel } 26388cfa0ad2SJack F Vogel 2639