#include "e1000_api.h"Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static void | e1000_reload_nvm_generic (struct e1000_hw *hw) |
| e1000_reload_nvm_generic - Reloads EEPROM : pointer to the HW structure | |
| void | e1000_init_nvm_ops_generic (struct e1000_hw *hw) |
| e1000_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure | |
| s32 | e1000_null_read_nvm (struct e1000_hw *hw __unused, u16 a __unused, u16 b __unused, u16 *c __unused) |
| e1000_null_nvm_read - No-op function, return 0 : pointer to the HW structure | |
| void | e1000_null_nvm_generic (struct e1000_hw *hw __unused) |
| e1000_null_nvm_generic - No-op function, return void : pointer to the HW structure | |
| s32 | e1000_null_led_default (struct e1000_hw *hw __unused, u16 *data __unused) |
| e1000_null_led_default - No-op function, return 0 : pointer to the HW structure | |
| s32 | e1000_null_write_nvm (struct e1000_hw *hw __unused, u16 a __unused, u16 b __unused, u16 *c __unused) |
| e1000_null_write_nvm - No-op function, return 0 : pointer to the HW structure | |
| static void | e1000_raise_eec_clk (struct e1000_hw *hw, u32 *eecd) |
| e1000_raise_eec_clk - Raise EEPROM clock : pointer to the HW structure : pointer to the EEPROM | |
| static void | e1000_lower_eec_clk (struct e1000_hw *hw, u32 *eecd) |
| e1000_lower_eec_clk - Lower EEPROM clock : pointer to the HW structure : pointer to the EEPROM | |
| static void | e1000_shift_out_eec_bits (struct e1000_hw *hw, u16 data, u16 count) |
| e1000_shift_out_eec_bits - Shift data bits our to the EEPROM : pointer to the HW structure : data to send to the EEPROM : number of bits to shift out | |
| static u16 | e1000_shift_in_eec_bits (struct e1000_hw *hw, u16 count) |
| e1000_shift_in_eec_bits - Shift data bits in from the EEPROM : pointer to the HW structure : number of bits to shift in | |
| s32 | e1000_poll_eerd_eewr_done (struct e1000_hw *hw, int ee_reg) |
| e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling | |
| s32 | e1000_acquire_nvm_generic (struct e1000_hw *hw) |
| e1000_acquire_nvm_generic - Generic request for access to EEPROM : pointer to the HW structure | |
| static void | e1000_standby_nvm (struct e1000_hw *hw) |
| e1000_standby_nvm - Return EEPROM to standby state : pointer to the HW structure | |
| void | e1000_stop_nvm (struct e1000_hw *hw) |
| e1000_stop_nvm - Terminate EEPROM command : pointer to the HW structure | |
| void | e1000_release_nvm_generic (struct e1000_hw *hw) |
| e1000_release_nvm_generic - Release exclusive access to EEPROM : pointer to the HW structure | |
| static s32 | e1000_ready_nvm_eeprom (struct e1000_hw *hw) |
| e1000_ready_nvm_eeprom - Prepares EEPROM for read/write : pointer to the HW structure | |
| s32 | e1000_read_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
| e1000_read_nvm_spi - Read EEPROM's using SPI : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM | |
| s32 | e1000_read_nvm_microwire (struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
| e1000_read_nvm_microwire - Reads EEPROM's using microwire : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM | |
| s32 | e1000_read_nvm_eerd (struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
| e1000_read_nvm_eerd - Reads EEPROM using EERD register : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM | |
| s32 | e1000_write_nvm_spi (struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
| e1000_write_nvm_spi - Write to EEPROM using SPI : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM | |
| s32 | e1000_write_nvm_microwire (struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
| e1000_write_nvm_microwire - Writes EEPROM using microwire : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM | |
| s32 | e1000_read_pba_num_generic (struct e1000_hw *hw, u32 *pba_num) |
| e1000_read_pba_num_generic - Read device part number : pointer to the HW structure : pointer to device part number | |
| s32 | e1000_read_mac_addr_generic (struct e1000_hw *hw) |
| e1000_read_mac_addr_generic - Read device MAC address : pointer to the HW structure | |
| s32 | e1000_validate_nvm_checksum_generic (struct e1000_hw *hw) |
| e1000_validate_nvm_checksum_generic - Validate EEPROM checksum : pointer to the HW structure | |
| s32 | e1000_update_nvm_checksum_generic (struct e1000_hw *hw) |
| e1000_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure | |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| static void e1000_reload_nvm_generic | ( | struct e1000_hw * | hw | ) | [static] |
e1000_reload_nvm_generic - Reloads EEPROM : pointer to the HW structure
Reloads the EEPROM by setting the "Reinitialize from EEPROM" bit in the extended control register.
Definition at line 912 of file e1000_nvm.c.
References DEBUGFUNC, E1000_CTRL_EXT, E1000_CTRL_EXT_EE_RST, E1000_READ_REG, E1000_WRITE_FLUSH, E1000_WRITE_REG, u32, and usec_delay.
Referenced by e1000_init_nvm_ops_generic().
00913 { 00914 u32 ctrl_ext; 00915 00916 DEBUGFUNC("e1000_reload_nvm_generic"); 00917 00918 usec_delay(10); 00919 ctrl_ext = E1000_READ_REG(hw, E1000_CTRL_EXT); 00920 ctrl_ext |= E1000_CTRL_EXT_EE_RST; 00921 E1000_WRITE_REG(hw, E1000_CTRL_EXT, ctrl_ext); 00922 E1000_WRITE_FLUSH(hw); 00923 }
| void e1000_init_nvm_ops_generic | ( | struct e1000_hw * | hw | ) |
e1000_init_nvm_ops_generic - Initialize NVM function pointers : pointer to the HW structure
Setups up the function pointers to no-op functions
Definition at line 41 of file e1000_nvm.c.
References e1000_nvm_operations::acquire, DEBUGFUNC, e1000_null_led_default(), e1000_null_nvm_generic(), e1000_null_ops_generic(), e1000_null_read_nvm(), e1000_null_write_nvm(), e1000_reload_nvm_generic(), e1000_nvm_operations::init_params, e1000_hw::nvm, e1000_nvm_info::ops, e1000_nvm_operations::read, e1000_nvm_operations::release, e1000_nvm_operations::reload, e1000_nvm_operations::update, e1000_nvm_operations::valid_led_default, e1000_nvm_operations::validate, and e1000_nvm_operations::write.
Referenced by e1000_setup_init_funcs().
00042 { 00043 struct e1000_nvm_info *nvm = &hw->nvm; 00044 DEBUGFUNC("e1000_init_nvm_ops_generic"); 00045 00046 /* Initialize function pointers */ 00047 nvm->ops.init_params = e1000_null_ops_generic; 00048 nvm->ops.acquire = e1000_null_ops_generic; 00049 nvm->ops.read = e1000_null_read_nvm; 00050 nvm->ops.release = e1000_null_nvm_generic; 00051 nvm->ops.reload = e1000_reload_nvm_generic; 00052 nvm->ops.update = e1000_null_ops_generic; 00053 nvm->ops.valid_led_default = e1000_null_led_default; 00054 nvm->ops.validate = e1000_null_ops_generic; 00055 nvm->ops.write = e1000_null_write_nvm; 00056 }
| s32 e1000_null_read_nvm | ( | struct e1000_hw *hw | __unused, | |
| u16 a | __unused, | |||
| u16 b | __unused, | |||
| u16 *c | __unused | |||
| ) |
e1000_null_nvm_read - No-op function, return 0 : pointer to the HW structure
Definition at line 62 of file e1000_nvm.c.
References DEBUGFUNC, and E1000_SUCCESS.
Referenced by e1000_init_nvm_ops_generic().
00064 { 00065 DEBUGFUNC("e1000_null_read_nvm"); 00066 return E1000_SUCCESS; 00067 }
e1000_null_nvm_generic - No-op function, return void : pointer to the HW structure
Definition at line 73 of file e1000_nvm.c.
References DEBUGFUNC.
Referenced by e1000_init_nvm_ops_generic().
00074 { 00075 DEBUGFUNC("e1000_null_nvm_generic"); 00076 return; 00077 }
e1000_null_led_default - No-op function, return 0 : pointer to the HW structure
Definition at line 83 of file e1000_nvm.c.
References DEBUGFUNC, and E1000_SUCCESS.
Referenced by e1000_init_nvm_ops_generic().
00085 { 00086 DEBUGFUNC("e1000_null_led_default"); 00087 return E1000_SUCCESS; 00088 }
| s32 e1000_null_write_nvm | ( | struct e1000_hw *hw | __unused, | |
| u16 a | __unused, | |||
| u16 b | __unused, | |||
| u16 *c | __unused | |||
| ) |
e1000_null_write_nvm - No-op function, return 0 : pointer to the HW structure
Definition at line 94 of file e1000_nvm.c.
References DEBUGFUNC, and E1000_SUCCESS.
Referenced by e1000_init_nvm_ops_generic().
00096 { 00097 DEBUGFUNC("e1000_null_write_nvm"); 00098 return E1000_SUCCESS; 00099 }
e1000_raise_eec_clk - Raise EEPROM clock : pointer to the HW structure : pointer to the EEPROM
Enable/Raise the EEPROM clock bit.
Definition at line 108 of file e1000_nvm.c.
References e1000_nvm_info::delay_usec, E1000_EECD, E1000_EECD_SK, E1000_WRITE_FLUSH, E1000_WRITE_REG, e1000_hw::nvm, and usec_delay.
Referenced by e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), and e1000_stop_nvm().
00109 { 00110 *eecd = *eecd | E1000_EECD_SK; 00111 E1000_WRITE_REG(hw, E1000_EECD, *eecd); 00112 E1000_WRITE_FLUSH(hw); 00113 usec_delay(hw->nvm.delay_usec); 00114 }
e1000_lower_eec_clk - Lower EEPROM clock : pointer to the HW structure : pointer to the EEPROM
Clear/Lower the EEPROM clock bit.
Definition at line 123 of file e1000_nvm.c.
References e1000_nvm_info::delay_usec, E1000_EECD, E1000_EECD_SK, E1000_WRITE_FLUSH, E1000_WRITE_REG, e1000_hw::nvm, and usec_delay.
Referenced by e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), and e1000_stop_nvm().
00124 { 00125 *eecd = *eecd & ~E1000_EECD_SK; 00126 E1000_WRITE_REG(hw, E1000_EECD, *eecd); 00127 E1000_WRITE_FLUSH(hw); 00128 usec_delay(hw->nvm.delay_usec); 00129 }
e1000_shift_out_eec_bits - Shift data bits our to the EEPROM : pointer to the HW structure : data to send to the EEPROM : number of bits to shift out
We need to shift 'count' bits out to the EEPROM. So, the value in the "data" parameter will be shifted out to the EEPROM one bit at a time. In order to do this, "data" must be broken down into bits.
Definition at line 141 of file e1000_nvm.c.
References DEBUGFUNC, e1000_nvm_info::delay_usec, E1000_EECD, E1000_EECD_DI, E1000_EECD_DO, e1000_lower_eec_clk(), e1000_nvm_eeprom_microwire, e1000_nvm_eeprom_spi, e1000_raise_eec_clk(), E1000_READ_REG, E1000_WRITE_FLUSH, E1000_WRITE_REG, e1000_hw::nvm, e1000_nvm_info::type, u32, and usec_delay.
Referenced by e1000_read_nvm_microwire(), e1000_read_nvm_spi(), e1000_ready_nvm_eeprom(), e1000_write_nvm_microwire(), and e1000_write_nvm_spi().
00142 { 00143 struct e1000_nvm_info *nvm = &hw->nvm; 00144 u32 eecd = E1000_READ_REG(hw, E1000_EECD); 00145 u32 mask; 00146 00147 DEBUGFUNC("e1000_shift_out_eec_bits"); 00148 00149 mask = 0x01 << (count - 1); 00150 if (nvm->type == e1000_nvm_eeprom_microwire) 00151 eecd &= ~E1000_EECD_DO; 00152 else 00153 if (nvm->type == e1000_nvm_eeprom_spi) 00154 eecd |= E1000_EECD_DO; 00155 00156 do { 00157 eecd &= ~E1000_EECD_DI; 00158 00159 if (data & mask) 00160 eecd |= E1000_EECD_DI; 00161 00162 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00163 E1000_WRITE_FLUSH(hw); 00164 00165 usec_delay(nvm->delay_usec); 00166 00167 e1000_raise_eec_clk(hw, &eecd); 00168 e1000_lower_eec_clk(hw, &eecd); 00169 00170 mask >>= 1; 00171 } while (mask); 00172 00173 eecd &= ~E1000_EECD_DI; 00174 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00175 }
e1000_shift_in_eec_bits - Shift data bits in from the EEPROM : pointer to the HW structure : number of bits to shift in
In order to read a register from the EEPROM, we need to shift 'count' bits in from the EEPROM. Bits are "shifted in" by raising the clock input to the EEPROM (setting the SK bit), and then reading the value of the data out "DO" bit. During this "shifting in" process the data in "DI" bit should always be clear.
Definition at line 188 of file e1000_nvm.c.
References DEBUGFUNC, E1000_EECD, E1000_EECD_DI, E1000_EECD_DO, e1000_lower_eec_clk(), e1000_raise_eec_clk(), E1000_READ_REG, u16, and u32.
Referenced by e1000_read_nvm_microwire(), e1000_read_nvm_spi(), and e1000_ready_nvm_eeprom().
00189 { 00190 u32 eecd; 00191 u32 i; 00192 u16 data; 00193 00194 DEBUGFUNC("e1000_shift_in_eec_bits"); 00195 00196 eecd = E1000_READ_REG(hw, E1000_EECD); 00197 00198 eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); 00199 data = 0; 00200 00201 for (i = 0; i < count; i++) { 00202 data <<= 1; 00203 e1000_raise_eec_clk(hw, &eecd); 00204 00205 eecd = E1000_READ_REG(hw, E1000_EECD); 00206 00207 eecd &= ~E1000_EECD_DI; 00208 if (eecd & E1000_EECD_DO) 00209 data |= 1; 00210 00211 e1000_lower_eec_clk(hw, &eecd); 00212 } 00213 00214 return data; 00215 }
e1000_poll_eerd_eewr_done - Poll for EEPROM read/write completion : pointer to the HW structure : EEPROM flag for polling
Polls the EEPROM status bit for either read or write completion based upon the value of 'ee_reg'.
Definition at line 225 of file e1000_nvm.c.
References DEBUGFUNC, E1000_EERD, E1000_EEWR, E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_REG_DONE, E1000_READ_REG, E1000_SUCCESS, u32, and usec_delay.
Referenced by e1000_read_nvm_eerd().
00226 { 00227 u32 attempts = 100000; 00228 u32 i, reg = 0; 00229 s32 ret_val = -E1000_ERR_NVM; 00230 00231 DEBUGFUNC("e1000_poll_eerd_eewr_done"); 00232 00233 for (i = 0; i < attempts; i++) { 00234 if (ee_reg == E1000_NVM_POLL_READ) 00235 reg = E1000_READ_REG(hw, E1000_EERD); 00236 else 00237 reg = E1000_READ_REG(hw, E1000_EEWR); 00238 00239 if (reg & E1000_NVM_RW_REG_DONE) { 00240 ret_val = E1000_SUCCESS; 00241 break; 00242 } 00243 00244 usec_delay(5); 00245 } 00246 00247 return ret_val; 00248 }
e1000_acquire_nvm_generic - Generic request for access to EEPROM : pointer to the HW structure
Set the EEPROM access request bit and wait for EEPROM access grant bit. Return successful if access grant bit set, else clear the request for EEPROM access and return -E1000_ERR_NVM (-1).
Definition at line 258 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, E1000_EECD, E1000_EECD_GNT, E1000_EECD_REQ, E1000_ERR_NVM, E1000_NVM_GRANT_ATTEMPTS, E1000_READ_REG, E1000_SUCCESS, E1000_WRITE_REG, timeout(), u32, and usec_delay.
Referenced by e1000_init_nvm_params_82540(), and e1000_init_nvm_params_82541().
00259 { 00260 u32 eecd = E1000_READ_REG(hw, E1000_EECD); 00261 s32 timeout = E1000_NVM_GRANT_ATTEMPTS; 00262 s32 ret_val = E1000_SUCCESS; 00263 00264 DEBUGFUNC("e1000_acquire_nvm_generic"); 00265 00266 E1000_WRITE_REG(hw, E1000_EECD, eecd | E1000_EECD_REQ); 00267 eecd = E1000_READ_REG(hw, E1000_EECD); 00268 00269 while (timeout) { 00270 if (eecd & E1000_EECD_GNT) 00271 break; 00272 usec_delay(5); 00273 eecd = E1000_READ_REG(hw, E1000_EECD); 00274 timeout--; 00275 } 00276 00277 if (!timeout) { 00278 eecd &= ~E1000_EECD_REQ; 00279 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00280 DEBUGOUT("Could not acquire NVM grant\n"); 00281 ret_val = -E1000_ERR_NVM; 00282 } 00283 00284 return ret_val; 00285 }
| static void e1000_standby_nvm | ( | struct e1000_hw * | hw | ) | [static] |
e1000_standby_nvm - Return EEPROM to standby state : pointer to the HW structure
Return the EEPROM to a standby state.
Definition at line 293 of file e1000_nvm.c.
References DEBUGFUNC, e1000_nvm_info::delay_usec, E1000_EECD, E1000_EECD_CS, E1000_EECD_SK, e1000_lower_eec_clk(), e1000_nvm_eeprom_microwire, e1000_nvm_eeprom_spi, e1000_raise_eec_clk(), E1000_READ_REG, E1000_WRITE_FLUSH, E1000_WRITE_REG, e1000_hw::nvm, e1000_nvm_info::type, u32, and usec_delay.
Referenced by e1000_read_nvm_microwire(), e1000_read_nvm_spi(), e1000_ready_nvm_eeprom(), e1000_write_nvm_microwire(), and e1000_write_nvm_spi().
00294 { 00295 struct e1000_nvm_info *nvm = &hw->nvm; 00296 u32 eecd = E1000_READ_REG(hw, E1000_EECD); 00297 00298 DEBUGFUNC("e1000_standby_nvm"); 00299 00300 if (nvm->type == e1000_nvm_eeprom_microwire) { 00301 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); 00302 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00303 E1000_WRITE_FLUSH(hw); 00304 usec_delay(nvm->delay_usec); 00305 00306 e1000_raise_eec_clk(hw, &eecd); 00307 00308 /* Select EEPROM */ 00309 eecd |= E1000_EECD_CS; 00310 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00311 E1000_WRITE_FLUSH(hw); 00312 usec_delay(nvm->delay_usec); 00313 00314 e1000_lower_eec_clk(hw, &eecd); 00315 } else 00316 if (nvm->type == e1000_nvm_eeprom_spi) { 00317 /* Toggle CS to flush commands */ 00318 eecd |= E1000_EECD_CS; 00319 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00320 E1000_WRITE_FLUSH(hw); 00321 usec_delay(nvm->delay_usec); 00322 eecd &= ~E1000_EECD_CS; 00323 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00324 E1000_WRITE_FLUSH(hw); 00325 usec_delay(nvm->delay_usec); 00326 } 00327 }
| void e1000_stop_nvm | ( | struct e1000_hw * | hw | ) |
e1000_stop_nvm - Terminate EEPROM command : pointer to the HW structure
Terminates the current command by inverting the EEPROM's chip select pin.
Definition at line 335 of file e1000_nvm.c.
References DEBUGFUNC, E1000_EECD, E1000_EECD_CS, E1000_EECD_DI, e1000_lower_eec_clk(), e1000_nvm_eeprom_microwire, e1000_nvm_eeprom_spi, e1000_raise_eec_clk(), E1000_READ_REG, E1000_WRITE_REG, e1000_hw::nvm, e1000_nvm_info::type, and u32.
Referenced by e1000_init_nvm_params_82542(), and e1000_release_nvm_generic().
00336 { 00337 u32 eecd; 00338 00339 DEBUGFUNC("e1000_stop_nvm"); 00340 00341 eecd = E1000_READ_REG(hw, E1000_EECD); 00342 if (hw->nvm.type == e1000_nvm_eeprom_spi) { 00343 /* Pull CS high */ 00344 eecd |= E1000_EECD_CS; 00345 e1000_lower_eec_clk(hw, &eecd); 00346 } else if (hw->nvm.type == e1000_nvm_eeprom_microwire) { 00347 /* CS on Microwire is active-high */ 00348 eecd &= ~(E1000_EECD_CS | E1000_EECD_DI); 00349 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00350 e1000_raise_eec_clk(hw, &eecd); 00351 e1000_lower_eec_clk(hw, &eecd); 00352 } 00353 }
| void e1000_release_nvm_generic | ( | struct e1000_hw * | hw | ) |
e1000_release_nvm_generic - Release exclusive access to EEPROM : pointer to the HW structure
Stop any current commands to the EEPROM and clear the EEPROM request bit.
Definition at line 361 of file e1000_nvm.c.
References DEBUGFUNC, E1000_EECD, E1000_EECD_REQ, E1000_READ_REG, e1000_stop_nvm(), E1000_WRITE_REG, and u32.
Referenced by e1000_init_nvm_params_82540(), and e1000_init_nvm_params_82541().
00362 { 00363 u32 eecd; 00364 00365 DEBUGFUNC("e1000_release_nvm_generic"); 00366 00367 e1000_stop_nvm(hw); 00368 00369 eecd = E1000_READ_REG(hw, E1000_EECD); 00370 eecd &= ~E1000_EECD_REQ; 00371 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00372 }
e1000_ready_nvm_eeprom - Prepares EEPROM for read/write : pointer to the HW structure
Setups the EEPROM for reading and writing.
Definition at line 380 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, E1000_EECD, E1000_EECD_CS, E1000_EECD_DI, E1000_EECD_SK, E1000_ERR_NVM, e1000_nvm_eeprom_microwire, e1000_nvm_eeprom_spi, E1000_READ_REG, e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), E1000_SUCCESS, E1000_WRITE_REG, e1000_hw::nvm, NVM_MAX_RETRY_SPI, NVM_RDSR_OPCODE_SPI, NVM_STATUS_RDY_SPI, e1000_nvm_info::opcode_bits, timeout(), e1000_nvm_info::type, u16, u32, u8, and usec_delay.
Referenced by e1000_read_nvm_microwire(), e1000_read_nvm_spi(), e1000_write_nvm_microwire(), and e1000_write_nvm_spi().
00381 { 00382 struct e1000_nvm_info *nvm = &hw->nvm; 00383 u32 eecd = E1000_READ_REG(hw, E1000_EECD); 00384 s32 ret_val = E1000_SUCCESS; 00385 u16 timeout = 0; 00386 u8 spi_stat_reg; 00387 00388 DEBUGFUNC("e1000_ready_nvm_eeprom"); 00389 00390 if (nvm->type == e1000_nvm_eeprom_microwire) { 00391 /* Clear SK and DI */ 00392 eecd &= ~(E1000_EECD_DI | E1000_EECD_SK); 00393 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00394 /* Set CS */ 00395 eecd |= E1000_EECD_CS; 00396 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00397 } else 00398 if (nvm->type == e1000_nvm_eeprom_spi) { 00399 /* Clear SK and CS */ 00400 eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); 00401 E1000_WRITE_REG(hw, E1000_EECD, eecd); 00402 usec_delay(1); 00403 timeout = NVM_MAX_RETRY_SPI; 00404 00405 /* 00406 * Read "Status Register" repeatedly until the LSB is cleared. 00407 * The EEPROM will signal that the command has been completed 00408 * by clearing bit 0 of the internal status register. If it's 00409 * not cleared within 'timeout', then error out. 00410 */ 00411 while (timeout) { 00412 e1000_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI, 00413 hw->nvm.opcode_bits); 00414 spi_stat_reg = (u8)e1000_shift_in_eec_bits(hw, 8); 00415 if (!(spi_stat_reg & NVM_STATUS_RDY_SPI)) 00416 break; 00417 00418 usec_delay(5); 00419 e1000_standby_nvm(hw); 00420 timeout--; 00421 } 00422 00423 if (!timeout) { 00424 DEBUGOUT("SPI NVM Status error\n"); 00425 ret_val = -E1000_ERR_NVM; 00426 goto out; 00427 } 00428 } 00429 00430 out: 00431 return ret_val; 00432 }
e1000_read_nvm_spi - Read EEPROM's using SPI : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
Reads a 16 bit word from the EEPROM.
Definition at line 443 of file e1000_nvm.c.
References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_A8_OPCODE_SPI, NVM_READ_OPCODE_SPI, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, u8, and e1000_nvm_info::word_size.
Referenced by e1000_init_nvm_params_82541().
00444 { 00445 struct e1000_nvm_info *nvm = &hw->nvm; 00446 u32 i = 0; 00447 s32 ret_val; 00448 u16 word_in; 00449 u8 read_opcode = NVM_READ_OPCODE_SPI; 00450 00451 DEBUGFUNC("e1000_read_nvm_spi"); 00452 00453 /* 00454 * A check for invalid values: offset too large, too many words, 00455 * and not enough words. 00456 */ 00457 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 00458 (words == 0)) { 00459 DEBUGOUT("nvm parameter(s) out of bounds\n"); 00460 ret_val = -E1000_ERR_NVM; 00461 goto out; 00462 } 00463 00464 ret_val = nvm->ops.acquire(hw); 00465 if (ret_val) 00466 goto out; 00467 00468 ret_val = e1000_ready_nvm_eeprom(hw); 00469 if (ret_val) 00470 goto release; 00471 00472 e1000_standby_nvm(hw); 00473 00474 if ((nvm->address_bits == 8) && (offset >= 128)) 00475 read_opcode |= NVM_A8_OPCODE_SPI; 00476 00477 /* Send the READ command (opcode + addr) */ 00478 e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits); 00479 e1000_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits); 00480 00481 /* 00482 * Read the data. SPI NVMs increment the address with each byte 00483 * read and will roll over if reading beyond the end. This allows 00484 * us to read the whole NVM from any offset 00485 */ 00486 for (i = 0; i < words; i++) { 00487 word_in = e1000_shift_in_eec_bits(hw, 16); 00488 data[i] = (word_in >> 8) | (word_in << 8); 00489 } 00490 00491 release: 00492 nvm->ops.release(hw); 00493 00494 out: 00495 return ret_val; 00496 }
e1000_read_nvm_microwire - Reads EEPROM's using microwire : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
Reads a 16 bit word from the EEPROM.
Definition at line 507 of file e1000_nvm.c.
References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_in_eec_bits(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_READ_OPCODE_MICROWIRE, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, u8, and e1000_nvm_info::word_size.
Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().
00509 { 00510 struct e1000_nvm_info *nvm = &hw->nvm; 00511 u32 i = 0; 00512 s32 ret_val; 00513 u8 read_opcode = NVM_READ_OPCODE_MICROWIRE; 00514 00515 DEBUGFUNC("e1000_read_nvm_microwire"); 00516 00517 /* 00518 * A check for invalid values: offset too large, too many words, 00519 * and not enough words. 00520 */ 00521 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 00522 (words == 0)) { 00523 DEBUGOUT("nvm parameter(s) out of bounds\n"); 00524 ret_val = -E1000_ERR_NVM; 00525 goto out; 00526 } 00527 00528 ret_val = nvm->ops.acquire(hw); 00529 if (ret_val) 00530 goto out; 00531 00532 ret_val = e1000_ready_nvm_eeprom(hw); 00533 if (ret_val) 00534 goto release; 00535 00536 for (i = 0; i < words; i++) { 00537 /* Send the READ command (opcode + addr) */ 00538 e1000_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits); 00539 e1000_shift_out_eec_bits(hw, (u16)(offset + i), 00540 nvm->address_bits); 00541 00542 /* 00543 * Read the data. For microwire, each word requires the 00544 * overhead of setup and tear-down. 00545 */ 00546 data[i] = e1000_shift_in_eec_bits(hw, 16); 00547 e1000_standby_nvm(hw); 00548 } 00549 00550 release: 00551 nvm->ops.release(hw); 00552 00553 out: 00554 return ret_val; 00555 }
e1000_read_nvm_eerd - Reads EEPROM using EERD register : pointer to the HW structure : offset of word in the EEPROM to read : number of words to read : word read from the EEPROM
Reads a 16 bit word from the EEPROM using the EERD register.
Definition at line 566 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, E1000_EERD, E1000_ERR_NVM, E1000_NVM_POLL_READ, E1000_NVM_RW_ADDR_SHIFT, E1000_NVM_RW_REG_DATA, E1000_NVM_RW_REG_START, e1000_poll_eerd_eewr_done(), E1000_READ_REG, E1000_SUCCESS, E1000_WRITE_REG, e1000_hw::nvm, u32, and e1000_nvm_info::word_size.
00567 { 00568 struct e1000_nvm_info *nvm = &hw->nvm; 00569 u32 i, eerd = 0; 00570 s32 ret_val = E1000_SUCCESS; 00571 00572 DEBUGFUNC("e1000_read_nvm_eerd"); 00573 00574 /* 00575 * A check for invalid values: offset too large, too many words, 00576 * too many words for the offset, and not enough words. 00577 */ 00578 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 00579 (words == 0)) { 00580 DEBUGOUT("nvm parameter(s) out of bounds\n"); 00581 ret_val = -E1000_ERR_NVM; 00582 goto out; 00583 } 00584 00585 for (i = 0; i < words; i++) { 00586 eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) + 00587 E1000_NVM_RW_REG_START; 00588 00589 E1000_WRITE_REG(hw, E1000_EERD, eerd); 00590 ret_val = e1000_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); 00591 if (ret_val) 00592 break; 00593 00594 data[i] = (E1000_READ_REG(hw, E1000_EERD) >> 00595 E1000_NVM_RW_REG_DATA); 00596 } 00597 00598 out: 00599 return ret_val; 00600 }
e1000_write_nvm_spi - Write to EEPROM using SPI : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM
Writes data to EEPROM at offset using SPI interface.
If e1000_update_nvm_checksum is not called after this function , the EEPROM will most likely contain an invalid checksum.
Definition at line 614 of file e1000_nvm.c.
References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, e1000_ready_nvm_eeprom(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), msec_delay, e1000_hw::nvm, NVM_A8_OPCODE_SPI, NVM_WREN_OPCODE_SPI, NVM_WRITE_OPCODE_SPI, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_info::page_size, e1000_nvm_operations::release, u16, u8, and e1000_nvm_info::word_size.
Referenced by e1000_init_nvm_params_82541().
00615 { 00616 struct e1000_nvm_info *nvm = &hw->nvm; 00617 s32 ret_val; 00618 u16 widx = 0; 00619 00620 DEBUGFUNC("e1000_write_nvm_spi"); 00621 00622 /* 00623 * A check for invalid values: offset too large, too many words, 00624 * and not enough words. 00625 */ 00626 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 00627 (words == 0)) { 00628 DEBUGOUT("nvm parameter(s) out of bounds\n"); 00629 ret_val = -E1000_ERR_NVM; 00630 goto out; 00631 } 00632 00633 ret_val = nvm->ops.acquire(hw); 00634 if (ret_val) 00635 goto out; 00636 00637 while (widx < words) { 00638 u8 write_opcode = NVM_WRITE_OPCODE_SPI; 00639 00640 ret_val = e1000_ready_nvm_eeprom(hw); 00641 if (ret_val) 00642 goto release; 00643 00644 e1000_standby_nvm(hw); 00645 00646 /* Send the WRITE ENABLE command (8 bit opcode) */ 00647 e1000_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI, 00648 nvm->opcode_bits); 00649 00650 e1000_standby_nvm(hw); 00651 00652 /* 00653 * Some SPI eeproms use the 8th address bit embedded in the 00654 * opcode 00655 */ 00656 if ((nvm->address_bits == 8) && (offset >= 128)) 00657 write_opcode |= NVM_A8_OPCODE_SPI; 00658 00659 /* Send the Write command (8-bit opcode + addr) */ 00660 e1000_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits); 00661 e1000_shift_out_eec_bits(hw, (u16)((offset + widx) * 2), 00662 nvm->address_bits); 00663 00664 /* Loop to allow for up to whole page write of eeprom */ 00665 while (widx < words) { 00666 u16 word_out = data[widx]; 00667 word_out = (word_out >> 8) | (word_out << 8); 00668 e1000_shift_out_eec_bits(hw, word_out, 16); 00669 widx++; 00670 00671 if ((((offset + widx) * 2) % nvm->page_size) == 0) { 00672 e1000_standby_nvm(hw); 00673 break; 00674 } 00675 } 00676 } 00677 00678 msec_delay(10); 00679 release: 00680 nvm->ops.release(hw); 00681 00682 out: 00683 return ret_val; 00684 }
e1000_write_nvm_microwire - Writes EEPROM using microwire : pointer to the HW structure : offset within the EEPROM to be written to : number of words to write : 16 bit word(s) to be written to the EEPROM
Writes data to EEPROM at offset using microwire interface.
If e1000_update_nvm_checksum is not called after this function , the EEPROM will most likely contain an invalid checksum.
Definition at line 698 of file e1000_nvm.c.
References e1000_nvm_operations::acquire, e1000_nvm_info::address_bits, DEBUGFUNC, DEBUGOUT, E1000_EECD, E1000_EECD_DO, E1000_ERR_NVM, E1000_READ_REG, e1000_ready_nvm_eeprom(), e1000_shift_out_eec_bits(), e1000_standby_nvm(), e1000_hw::nvm, NVM_EWDS_OPCODE_MICROWIRE, NVM_EWEN_OPCODE_MICROWIRE, NVM_WRITE_OPCODE_MICROWIRE, e1000_nvm_info::opcode_bits, e1000_nvm_info::ops, e1000_nvm_operations::release, u16, u32, usec_delay, and e1000_nvm_info::word_size.
Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().
00700 { 00701 struct e1000_nvm_info *nvm = &hw->nvm; 00702 s32 ret_val; 00703 u32 eecd; 00704 u16 words_written = 0; 00705 u16 widx = 0; 00706 00707 DEBUGFUNC("e1000_write_nvm_microwire"); 00708 00709 /* 00710 * A check for invalid values: offset too large, too many words, 00711 * and not enough words. 00712 */ 00713 if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || 00714 (words == 0)) { 00715 DEBUGOUT("nvm parameter(s) out of bounds\n"); 00716 ret_val = -E1000_ERR_NVM; 00717 goto out; 00718 } 00719 00720 ret_val = nvm->ops.acquire(hw); 00721 if (ret_val) 00722 goto out; 00723 00724 ret_val = e1000_ready_nvm_eeprom(hw); 00725 if (ret_val) 00726 goto release; 00727 00728 e1000_shift_out_eec_bits(hw, NVM_EWEN_OPCODE_MICROWIRE, 00729 (u16)(nvm->opcode_bits + 2)); 00730 00731 e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2)); 00732 00733 e1000_standby_nvm(hw); 00734 00735 while (words_written < words) { 00736 e1000_shift_out_eec_bits(hw, NVM_WRITE_OPCODE_MICROWIRE, 00737 nvm->opcode_bits); 00738 00739 e1000_shift_out_eec_bits(hw, (u16)(offset + words_written), 00740 nvm->address_bits); 00741 00742 e1000_shift_out_eec_bits(hw, data[words_written], 16); 00743 00744 e1000_standby_nvm(hw); 00745 00746 for (widx = 0; widx < 200; widx++) { 00747 eecd = E1000_READ_REG(hw, E1000_EECD); 00748 if (eecd & E1000_EECD_DO) 00749 break; 00750 usec_delay(50); 00751 } 00752 00753 if (widx == 200) { 00754 DEBUGOUT("NVM Write did not complete\n"); 00755 ret_val = -E1000_ERR_NVM; 00756 goto release; 00757 } 00758 00759 e1000_standby_nvm(hw); 00760 00761 words_written++; 00762 } 00763 00764 e1000_shift_out_eec_bits(hw, NVM_EWDS_OPCODE_MICROWIRE, 00765 (u16)(nvm->opcode_bits + 2)); 00766 00767 e1000_shift_out_eec_bits(hw, 0, (u16)(nvm->address_bits - 2)); 00768 00769 release: 00770 nvm->ops.release(hw); 00771 00772 out: 00773 return ret_val; 00774 }
e1000_read_pba_num_generic - Read device part number : pointer to the HW structure : pointer to device part number
Reads the product board assembly (PBA) number from the EEPROM and stores the value in pba_num.
Definition at line 784 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, e1000_hw::nvm, NVM_PBA_OFFSET_0, NVM_PBA_OFFSET_1, e1000_nvm_info::ops, e1000_nvm_operations::read, u16, and u32.
Referenced by e1000_read_pba_num().
00785 { 00786 s32 ret_val; 00787 u16 nvm_data; 00788 00789 DEBUGFUNC("e1000_read_pba_num_generic"); 00790 00791 ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); 00792 if (ret_val) { 00793 DEBUGOUT("NVM Read Error\n"); 00794 goto out; 00795 } 00796 *pba_num = (u32)(nvm_data << 16); 00797 00798 ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &nvm_data); 00799 if (ret_val) { 00800 DEBUGOUT("NVM Read Error\n"); 00801 goto out; 00802 } 00803 *pba_num |= nvm_data; 00804 00805 out: 00806 return ret_val; 00807 }
e1000_read_mac_addr_generic - Read device MAC address : pointer to the HW structure
Reads the device MAC address from the EEPROM and stores the value. Since devices with two ports use the same EEPROM, we increment the last bit in the MAC address for the second port.
Definition at line 817 of file e1000_nvm.c.
References e1000_mac_info::addr, E1000_RAH, E1000_RAH_MAC_ADDR_LEN, E1000_RAL, E1000_RAL_MAC_ADDR_LEN, E1000_READ_REG, E1000_SUCCESS, ETH_ADDR_LEN, e1000_hw::mac, e1000_mac_info::perm_addr, u16, u32, and u8.
Referenced by e1000_init_mac_ops_generic(), and e1000_read_mac_addr().
00818 { 00819 u32 rar_high; 00820 u32 rar_low; 00821 u16 i; 00822 00823 rar_high = E1000_READ_REG(hw, E1000_RAH(0)); 00824 rar_low = E1000_READ_REG(hw, E1000_RAL(0)); 00825 00826 for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) 00827 hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); 00828 00829 for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) 00830 hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8)); 00831 00832 for (i = 0; i < ETH_ADDR_LEN; i++) 00833 hw->mac.addr[i] = hw->mac.perm_addr[i]; 00834 00835 return E1000_SUCCESS; 00836 }
e1000_validate_nvm_checksum_generic - Validate EEPROM checksum : pointer to the HW structure
Calculates the EEPROM checksum by reading/adding each word of the EEPROM and then verifies that the sum of the EEPROM is equal to 0xBABA.
Definition at line 845 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, E1000_ERR_NVM, E1000_SUCCESS, e1000_hw::nvm, NVM_CHECKSUM_REG, NVM_SUM, e1000_nvm_info::ops, e1000_nvm_operations::read, and u16.
Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().
00846 { 00847 s32 ret_val = E1000_SUCCESS; 00848 u16 checksum = 0; 00849 u16 i, nvm_data; 00850 00851 DEBUGFUNC("e1000_validate_nvm_checksum_generic"); 00852 00853 for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { 00854 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data); 00855 if (ret_val) { 00856 DEBUGOUT("NVM Read Error\n"); 00857 goto out; 00858 } 00859 checksum += nvm_data; 00860 } 00861 00862 if (checksum != (u16) NVM_SUM) { 00863 DEBUGOUT("NVM Checksum Invalid\n"); 00864 ret_val = -E1000_ERR_NVM; 00865 goto out; 00866 } 00867 00868 out: 00869 return ret_val; 00870 }
e1000_update_nvm_checksum_generic - Update EEPROM checksum : pointer to the HW structure
Updates the EEPROM checksum by reading/adding each word of the EEPROM up to the checksum. Then calculates the EEPROM checksum and writes the value to the EEPROM.
Definition at line 880 of file e1000_nvm.c.
References DEBUGFUNC, DEBUGOUT, e1000_hw::nvm, NVM_CHECKSUM_REG, NVM_SUM, e1000_nvm_info::ops, e1000_nvm_operations::read, u16, and e1000_nvm_operations::write.
Referenced by e1000_init_nvm_params_82540(), e1000_init_nvm_params_82541(), e1000_init_nvm_params_82542(), and e1000_init_nvm_params_82543().
00881 { 00882 s32 ret_val; 00883 u16 checksum = 0; 00884 u16 i, nvm_data; 00885 00886 DEBUGFUNC("e1000_update_nvm_checksum"); 00887 00888 for (i = 0; i < NVM_CHECKSUM_REG; i++) { 00889 ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data); 00890 if (ret_val) { 00891 DEBUGOUT("NVM Read Error while updating checksum.\n"); 00892 goto out; 00893 } 00894 checksum += nvm_data; 00895 } 00896 checksum = (u16) NVM_SUM - checksum; 00897 ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum); 00898 if (ret_val) 00899 DEBUGOUT("NVM Write Error while updating checksum.\n"); 00900 00901 out: 00902 return ret_val; 00903 }
1.5.7.1