diff options
author | Carolyn Wyborny <carolyn.wyborny@intel.com> | 2013-07-16 15:17:32 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2013-08-22 05:25:57 -0400 |
commit | 5a823d8cdd0e16081bc09a03fa253b9750c4b034 (patch) | |
tree | dd97b262ad554e72c64304a08ff99304b09e866b /drivers/net/ethernet | |
parent | 2ccd994c4c85a787ba4873f1481edd42c4ff46bf (diff) |
igb: Refactor of init_nvm_params
This patch refactors the init_nvm_params functions for 82575 and adds a new
function for the i210/i211 devices in order to configure separately the NVM
functionality for the i210/i211 family.
Signed-off-by: Carolyn Wyborny <carolyn.wyborny@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_82575.c | 106 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_defines.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_hw.h | 1 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_i210.c | 47 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/igb/e1000_i210.h | 2 |
5 files changed, 92 insertions, 65 deletions
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c index 9057d10a698a..8d79face0717 100644 --- a/drivers/net/ethernet/intel/igb/e1000_82575.c +++ b/drivers/net/ethernet/intel/igb/e1000_82575.c | |||
@@ -238,6 +238,7 @@ static s32 igb_init_nvm_params_82575(struct e1000_hw *hw) | |||
238 | 238 | ||
239 | size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> | 239 | size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >> |
240 | E1000_EECD_SIZE_EX_SHIFT); | 240 | E1000_EECD_SIZE_EX_SHIFT); |
241 | |||
241 | /* Added to a constant, "size" becomes the left-shift value | 242 | /* Added to a constant, "size" becomes the left-shift value |
242 | * for setting word_size. | 243 | * for setting word_size. |
243 | */ | 244 | */ |
@@ -250,86 +251,52 @@ static s32 igb_init_nvm_params_82575(struct e1000_hw *hw) | |||
250 | size = 15; | 251 | size = 15; |
251 | 252 | ||
252 | nvm->word_size = 1 << size; | 253 | nvm->word_size = 1 << size; |
253 | if (hw->mac.type < e1000_i210) { | 254 | nvm->opcode_bits = 8; |
254 | nvm->opcode_bits = 8; | 255 | nvm->delay_usec = 1; |
255 | nvm->delay_usec = 1; | ||
256 | |||
257 | switch (nvm->override) { | ||
258 | case e1000_nvm_override_spi_large: | ||
259 | nvm->page_size = 32; | ||
260 | nvm->address_bits = 16; | ||
261 | break; | ||
262 | case e1000_nvm_override_spi_small: | ||
263 | nvm->page_size = 8; | ||
264 | nvm->address_bits = 8; | ||
265 | break; | ||
266 | default: | ||
267 | nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; | ||
268 | nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? | ||
269 | 16 : 8; | ||
270 | break; | ||
271 | } | ||
272 | if (nvm->word_size == (1 << 15)) | ||
273 | nvm->page_size = 128; | ||
274 | 256 | ||
275 | nvm->type = e1000_nvm_eeprom_spi; | 257 | switch (nvm->override) { |
276 | } else { | 258 | case e1000_nvm_override_spi_large: |
277 | nvm->type = e1000_nvm_flash_hw; | 259 | nvm->page_size = 32; |
260 | nvm->address_bits = 16; | ||
261 | break; | ||
262 | case e1000_nvm_override_spi_small: | ||
263 | nvm->page_size = 8; | ||
264 | nvm->address_bits = 8; | ||
265 | break; | ||
266 | default: | ||
267 | nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; | ||
268 | nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? | ||
269 | 16 : 8; | ||
270 | break; | ||
278 | } | 271 | } |
272 | if (nvm->word_size == (1 << 15)) | ||
273 | nvm->page_size = 128; | ||
274 | |||
275 | nvm->type = e1000_nvm_eeprom_spi; | ||
279 | 276 | ||
280 | /* NVM Function Pointers */ | 277 | /* NVM Function Pointers */ |
278 | nvm->ops.acquire = igb_acquire_nvm_82575; | ||
279 | nvm->ops.release = igb_release_nvm_82575; | ||
280 | nvm->ops.write = igb_write_nvm_spi; | ||
281 | nvm->ops.validate = igb_validate_nvm_checksum; | ||
282 | nvm->ops.update = igb_update_nvm_checksum; | ||
283 | if (nvm->word_size < (1 << 15)) | ||
284 | nvm->ops.read = igb_read_nvm_eerd; | ||
285 | else | ||
286 | nvm->ops.read = igb_read_nvm_spi; | ||
287 | |||
288 | /* override generic family function pointers for specific descendants */ | ||
281 | switch (hw->mac.type) { | 289 | switch (hw->mac.type) { |
282 | case e1000_82580: | 290 | case e1000_82580: |
283 | nvm->ops.validate = igb_validate_nvm_checksum_82580; | 291 | nvm->ops.validate = igb_validate_nvm_checksum_82580; |
284 | nvm->ops.update = igb_update_nvm_checksum_82580; | 292 | nvm->ops.update = igb_update_nvm_checksum_82580; |
285 | nvm->ops.acquire = igb_acquire_nvm_82575; | ||
286 | nvm->ops.release = igb_release_nvm_82575; | ||
287 | if (nvm->word_size < (1 << 15)) | ||
288 | nvm->ops.read = igb_read_nvm_eerd; | ||
289 | else | ||
290 | nvm->ops.read = igb_read_nvm_spi; | ||
291 | nvm->ops.write = igb_write_nvm_spi; | ||
292 | break; | 293 | break; |
293 | case e1000_i354: | 294 | case e1000_i354: |
294 | case e1000_i350: | 295 | case e1000_i350: |
295 | nvm->ops.validate = igb_validate_nvm_checksum_i350; | 296 | nvm->ops.validate = igb_validate_nvm_checksum_i350; |
296 | nvm->ops.update = igb_update_nvm_checksum_i350; | 297 | nvm->ops.update = igb_update_nvm_checksum_i350; |
297 | nvm->ops.acquire = igb_acquire_nvm_82575; | ||
298 | nvm->ops.release = igb_release_nvm_82575; | ||
299 | if (nvm->word_size < (1 << 15)) | ||
300 | nvm->ops.read = igb_read_nvm_eerd; | ||
301 | else | ||
302 | nvm->ops.read = igb_read_nvm_spi; | ||
303 | nvm->ops.write = igb_write_nvm_spi; | ||
304 | break; | ||
305 | case e1000_i210: | ||
306 | nvm->ops.validate = igb_validate_nvm_checksum_i210; | ||
307 | nvm->ops.update = igb_update_nvm_checksum_i210; | ||
308 | nvm->ops.acquire = igb_acquire_nvm_i210; | ||
309 | nvm->ops.release = igb_release_nvm_i210; | ||
310 | nvm->ops.read = igb_read_nvm_srrd_i210; | ||
311 | nvm->ops.write = igb_write_nvm_srwr_i210; | ||
312 | nvm->ops.valid_led_default = igb_valid_led_default_i210; | ||
313 | break; | ||
314 | case e1000_i211: | ||
315 | nvm->ops.acquire = igb_acquire_nvm_i210; | ||
316 | nvm->ops.release = igb_release_nvm_i210; | ||
317 | nvm->ops.read = igb_read_nvm_i211; | ||
318 | nvm->ops.valid_led_default = igb_valid_led_default_i210; | ||
319 | nvm->ops.validate = NULL; | ||
320 | nvm->ops.update = NULL; | ||
321 | nvm->ops.write = NULL; | ||
322 | break; | 298 | break; |
323 | default: | 299 | default: |
324 | nvm->ops.validate = igb_validate_nvm_checksum; | ||
325 | nvm->ops.update = igb_update_nvm_checksum; | ||
326 | nvm->ops.acquire = igb_acquire_nvm_82575; | ||
327 | nvm->ops.release = igb_release_nvm_82575; | ||
328 | if (nvm->word_size < (1 << 15)) | ||
329 | nvm->ops.read = igb_read_nvm_eerd; | ||
330 | else | ||
331 | nvm->ops.read = igb_read_nvm_spi; | ||
332 | nvm->ops.write = igb_write_nvm_spi; | ||
333 | break; | 300 | break; |
334 | } | 301 | } |
335 | 302 | ||
@@ -601,6 +568,15 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw) | |||
601 | 568 | ||
602 | /* NVM initialization */ | 569 | /* NVM initialization */ |
603 | ret_val = igb_init_nvm_params_82575(hw); | 570 | ret_val = igb_init_nvm_params_82575(hw); |
571 | switch (hw->mac.type) { | ||
572 | case e1000_i210: | ||
573 | case e1000_i211: | ||
574 | ret_val = igb_init_nvm_params_i210(hw); | ||
575 | break; | ||
576 | default: | ||
577 | break; | ||
578 | } | ||
579 | |||
604 | if (ret_val) | 580 | if (ret_val) |
605 | goto out; | 581 | goto out; |
606 | 582 | ||
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h index aa201abb8ad2..179935576e14 100644 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h | |||
@@ -620,6 +620,7 @@ | |||
620 | #define E1000_EECD_SIZE_EX_SHIFT 11 | 620 | #define E1000_EECD_SIZE_EX_SHIFT 11 |
621 | #define E1000_EECD_FLUPD_I210 0x00800000 /* Update FLASH */ | 621 | #define E1000_EECD_FLUPD_I210 0x00800000 /* Update FLASH */ |
622 | #define E1000_EECD_FLUDONE_I210 0x04000000 /* Update FLASH done*/ | 622 | #define E1000_EECD_FLUDONE_I210 0x04000000 /* Update FLASH done*/ |
623 | #define E1000_EECD_FLASH_DETECTED_I210 0x00080000 /* FLASH detected */ | ||
623 | #define E1000_FLUDONE_ATTEMPTS 20000 | 624 | #define E1000_FLUDONE_ATTEMPTS 20000 |
624 | #define E1000_EERD_EEWR_MAX_COUNT 512 /* buffered EEPROM words rw */ | 625 | #define E1000_EERD_EEWR_MAX_COUNT 512 /* buffered EEPROM words rw */ |
625 | #define E1000_I210_FIFO_SEL_RX 0x00 | 626 | #define E1000_I210_FIFO_SEL_RX 0x00 |
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h index 94d7866b9c20..4329e8c17b33 100644 --- a/drivers/net/ethernet/intel/igb/e1000_hw.h +++ b/drivers/net/ethernet/intel/igb/e1000_hw.h | |||
@@ -110,6 +110,7 @@ enum e1000_nvm_type { | |||
110 | e1000_nvm_none, | 110 | e1000_nvm_none, |
111 | e1000_nvm_eeprom_spi, | 111 | e1000_nvm_eeprom_spi, |
112 | e1000_nvm_flash_hw, | 112 | e1000_nvm_flash_hw, |
113 | e1000_nvm_invm, | ||
113 | e1000_nvm_flash_sw | 114 | e1000_nvm_flash_sw |
114 | }; | 115 | }; |
115 | 116 | ||
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c index ddb3cf51b9b9..4aebf35a0d75 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.c +++ b/drivers/net/ethernet/intel/igb/e1000_i210.c | |||
@@ -661,6 +661,23 @@ static s32 igb_pool_flash_update_done_i210(struct e1000_hw *hw) | |||
661 | } | 661 | } |
662 | 662 | ||
663 | /** | 663 | /** |
664 | * igb_get_flash_presence_i210 - Check if flash device is detected. | ||
665 | * @hw: pointer to the HW structure | ||
666 | * | ||
667 | **/ | ||
668 | bool igb_get_flash_presence_i210(struct e1000_hw *hw) | ||
669 | { | ||
670 | u32 eec = 0; | ||
671 | bool ret_val = false; | ||
672 | |||
673 | eec = rd32(E1000_EECD); | ||
674 | if (eec & E1000_EECD_FLASH_DETECTED_I210) | ||
675 | ret_val = true; | ||
676 | |||
677 | return ret_val; | ||
678 | } | ||
679 | |||
680 | /** | ||
664 | * igb_update_flash_i210 - Commit EEPROM to the flash | 681 | * igb_update_flash_i210 - Commit EEPROM to the flash |
665 | * @hw: pointer to the HW structure | 682 | * @hw: pointer to the HW structure |
666 | * | 683 | * |
@@ -786,3 +803,33 @@ s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data) | |||
786 | { | 803 | { |
787 | return __igb_access_xmdio_reg(hw, addr, dev_addr, &data, false); | 804 | return __igb_access_xmdio_reg(hw, addr, dev_addr, &data, false); |
788 | } | 805 | } |
806 | |||
807 | /** | ||
808 | * igb_init_nvm_params_i210 - Init NVM func ptrs. | ||
809 | * @hw: pointer to the HW structure | ||
810 | **/ | ||
811 | s32 igb_init_nvm_params_i210(struct e1000_hw *hw) | ||
812 | { | ||
813 | s32 ret_val = 0; | ||
814 | struct e1000_nvm_info *nvm = &hw->nvm; | ||
815 | |||
816 | nvm->ops.acquire = igb_acquire_nvm_i210; | ||
817 | nvm->ops.release = igb_release_nvm_i210; | ||
818 | nvm->ops.valid_led_default = igb_valid_led_default_i210; | ||
819 | |||
820 | /* NVM Function Pointers */ | ||
821 | if (igb_get_flash_presence_i210(hw)) { | ||
822 | hw->nvm.type = e1000_nvm_flash_hw; | ||
823 | nvm->ops.read = igb_read_nvm_srrd_i210; | ||
824 | nvm->ops.write = igb_write_nvm_srwr_i210; | ||
825 | nvm->ops.validate = igb_validate_nvm_checksum_i210; | ||
826 | nvm->ops.update = igb_update_nvm_checksum_i210; | ||
827 | } else { | ||
828 | hw->nvm.type = e1000_nvm_invm; | ||
829 | nvm->ops.read = igb_read_nvm_i211; | ||
830 | nvm->ops.write = NULL; | ||
831 | nvm->ops.validate = NULL; | ||
832 | nvm->ops.update = NULL; | ||
833 | } | ||
834 | return ret_val; | ||
835 | } | ||
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h index 5caa332e7556..a2a1f70cc8dd 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.h +++ b/drivers/net/ethernet/intel/igb/e1000_i210.h | |||
@@ -49,6 +49,8 @@ extern s32 igb_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, | |||
49 | u16 *data); | 49 | u16 *data); |
50 | extern s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, | 50 | extern s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, |
51 | u16 data); | 51 | u16 data); |
52 | extern s32 igb_init_nvm_params_i210(struct e1000_hw *hw); | ||
53 | extern bool igb_get_flash_presence_i210(struct e1000_hw *hw); | ||
52 | 54 | ||
53 | #define E1000_STM_OPCODE 0xDB00 | 55 | #define E1000_STM_OPCODE 0xDB00 |
54 | #define E1000_EEPROM_FLASH_SIZE_WORD 0x11 | 56 | #define E1000_EEPROM_FLASH_SIZE_WORD 0x11 |