aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn Wyborny <carolyn.wyborny@intel.com>2012-11-20 23:44:10 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2012-12-01 06:04:12 -0500
commit7916a53d203f12461095886cf72d58e9281240d9 (patch)
tree39039b228a40757bb1d2682fa03619a46b6a6a8d
parent23e0f1488f193d53d282404c1ab50112cb237341 (diff)
igb: Refactoring of i210 file.
This patch refactors the functions in e1000_i210.c in order to remove need for prototypes. 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>
-rw-r--r--drivers/net/ethernet/intel/igb/e1000_i210.c243
1 files changed, 119 insertions, 124 deletions
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c
index 239650e5e545..fbcdbebb0b5f 100644
--- a/drivers/net/ethernet/intel/igb/e1000_i210.c
+++ b/drivers/net/ethernet/intel/igb/e1000_i210.c
@@ -35,11 +35,42 @@
35#include "e1000_hw.h" 35#include "e1000_hw.h"
36#include "e1000_i210.h" 36#include "e1000_i210.h"
37 37
38static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw); 38/**
39static void igb_put_hw_semaphore_i210(struct e1000_hw *hw); 39 * igb_get_hw_semaphore_i210 - Acquire hardware semaphore
40static s32 igb_write_nvm_srwr(struct e1000_hw *hw, u16 offset, u16 words, 40 * @hw: pointer to the HW structure
41 u16 *data); 41 *
42static s32 igb_pool_flash_update_done_i210(struct e1000_hw *hw); 42 * Acquire the HW semaphore to access the PHY or NVM
43 */
44static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw)
45{
46 u32 swsm;
47 s32 ret_val = E1000_SUCCESS;
48 s32 timeout = hw->nvm.word_size + 1;
49 s32 i = 0;
50
51 /* Get the FW semaphore. */
52 for (i = 0; i < timeout; i++) {
53 swsm = rd32(E1000_SWSM);
54 wr32(E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
55
56 /* Semaphore acquired if bit latched */
57 if (rd32(E1000_SWSM) & E1000_SWSM_SWESMBI)
58 break;
59
60 udelay(50);
61 }
62
63 if (i == timeout) {
64 /* Release semaphores */
65 igb_put_hw_semaphore(hw);
66 hw_dbg("Driver can't access the NVM\n");
67 ret_val = -E1000_ERR_NVM;
68 goto out;
69 }
70
71out:
72 return ret_val;
73}
43 74
44/** 75/**
45 * igb_acquire_nvm_i210 - Request for access to EEPROM 76 * igb_acquire_nvm_i210 - Request for access to EEPROM
@@ -68,6 +99,23 @@ void igb_release_nvm_i210(struct e1000_hw *hw)
68} 99}
69 100
70/** 101/**
102 * igb_put_hw_semaphore_i210 - Release hardware semaphore
103 * @hw: pointer to the HW structure
104 *
105 * Release hardware semaphore used to access the PHY or NVM
106 */
107static void igb_put_hw_semaphore_i210(struct e1000_hw *hw)
108{
109 u32 swsm;
110
111 swsm = rd32(E1000_SWSM);
112
113 swsm &= ~E1000_SWSM_SWESMBI;
114
115 wr32(E1000_SWSM, swsm);
116}
117
118/**
71 * igb_acquire_swfw_sync_i210 - Acquire SW/FW semaphore 119 * igb_acquire_swfw_sync_i210 - Acquire SW/FW semaphore
72 * @hw: pointer to the HW structure 120 * @hw: pointer to the HW structure
73 * @mask: specifies which semaphore to acquire 121 * @mask: specifies which semaphore to acquire
@@ -138,60 +186,6 @@ void igb_release_swfw_sync_i210(struct e1000_hw *hw, u16 mask)
138} 186}
139 187
140/** 188/**
141 * igb_get_hw_semaphore_i210 - Acquire hardware semaphore
142 * @hw: pointer to the HW structure
143 *
144 * Acquire the HW semaphore to access the PHY or NVM
145 **/
146static s32 igb_get_hw_semaphore_i210(struct e1000_hw *hw)
147{
148 u32 swsm;
149 s32 ret_val = E1000_SUCCESS;
150 s32 timeout = hw->nvm.word_size + 1;
151 s32 i = 0;
152
153 /* Get the FW semaphore. */
154 for (i = 0; i < timeout; i++) {
155 swsm = rd32(E1000_SWSM);
156 wr32(E1000_SWSM, swsm | E1000_SWSM_SWESMBI);
157
158 /* Semaphore acquired if bit latched */
159 if (rd32(E1000_SWSM) & E1000_SWSM_SWESMBI)
160 break;
161
162 udelay(50);
163 }
164
165 if (i == timeout) {
166 /* Release semaphores */
167 igb_put_hw_semaphore(hw);
168 hw_dbg("Driver can't access the NVM\n");
169 ret_val = -E1000_ERR_NVM;
170 goto out;
171 }
172
173out:
174 return ret_val;
175}
176
177/**
178 * igb_put_hw_semaphore_i210 - Release hardware semaphore
179 * @hw: pointer to the HW structure
180 *
181 * Release hardware semaphore used to access the PHY or NVM
182 **/
183static void igb_put_hw_semaphore_i210(struct e1000_hw *hw)
184{
185 u32 swsm;
186
187 swsm = rd32(E1000_SWSM);
188
189 swsm &= ~E1000_SWSM_SWESMBI;
190
191 wr32(E1000_SWSM, swsm);
192}
193
194/**
195 * igb_read_nvm_srrd_i210 - Reads Shadow Ram using EERD register 189 * igb_read_nvm_srrd_i210 - Reads Shadow Ram using EERD register
196 * @hw: pointer to the HW structure 190 * @hw: pointer to the HW structure
197 * @offset: offset of word in the Shadow Ram to read 191 * @offset: offset of word in the Shadow Ram to read
@@ -229,49 +223,6 @@ s32 igb_read_nvm_srrd_i210(struct e1000_hw *hw, u16 offset, u16 words,
229} 223}
230 224
231/** 225/**
232 * igb_write_nvm_srwr_i210 - Write to Shadow RAM using EEWR
233 * @hw: pointer to the HW structure
234 * @offset: offset within the Shadow RAM to be written to
235 * @words: number of words to write
236 * @data: 16 bit word(s) to be written to the Shadow RAM
237 *
238 * Writes data to Shadow RAM at offset using EEWR register.
239 *
240 * If e1000_update_nvm_checksum is not called after this function , the
241 * data will not be committed to FLASH and also Shadow RAM will most likely
242 * contain an invalid checksum.
243 *
244 * If error code is returned, data and Shadow RAM may be inconsistent - buffer
245 * partially written.
246 **/
247s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
248 u16 *data)
249{
250 s32 status = E1000_SUCCESS;
251 u16 i, count;
252
253 /* We cannot hold synchronization semaphores for too long,
254 * because of forceful takeover procedure. However it is more efficient
255 * to write in bursts than synchronizing access for each word. */
256 for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
257 count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
258 E1000_EERD_EEWR_MAX_COUNT : (words - i);
259 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
260 status = igb_write_nvm_srwr(hw, offset, count,
261 data + i);
262 hw->nvm.ops.release(hw);
263 } else {
264 status = E1000_ERR_SWFW_SYNC;
265 }
266
267 if (status != E1000_SUCCESS)
268 break;
269 }
270
271 return status;
272}
273
274/**
275 * igb_write_nvm_srwr - Write to Shadow Ram using EEWR 226 * igb_write_nvm_srwr - Write to Shadow Ram using EEWR
276 * @hw: pointer to the HW structure 227 * @hw: pointer to the HW structure
277 * @offset: offset within the Shadow Ram to be written to 228 * @offset: offset within the Shadow Ram to be written to
@@ -329,6 +280,50 @@ out:
329} 280}
330 281
331/** 282/**
283 * igb_write_nvm_srwr_i210 - Write to Shadow RAM using EEWR
284 * @hw: pointer to the HW structure
285 * @offset: offset within the Shadow RAM to be written to
286 * @words: number of words to write
287 * @data: 16 bit word(s) to be written to the Shadow RAM
288 *
289 * Writes data to Shadow RAM at offset using EEWR register.
290 *
291 * If e1000_update_nvm_checksum is not called after this function , the
292 * data will not be committed to FLASH and also Shadow RAM will most likely
293 * contain an invalid checksum.
294 *
295 * If error code is returned, data and Shadow RAM may be inconsistent - buffer
296 * partially written.
297 */
298s32 igb_write_nvm_srwr_i210(struct e1000_hw *hw, u16 offset, u16 words,
299 u16 *data)
300{
301 s32 status = E1000_SUCCESS;
302 u16 i, count;
303
304 /* We cannot hold synchronization semaphores for too long,
305 * because of forceful takeover procedure. However it is more efficient
306 * to write in bursts than synchronizing access for each word.
307 */
308 for (i = 0; i < words; i += E1000_EERD_EEWR_MAX_COUNT) {
309 count = (words - i) / E1000_EERD_EEWR_MAX_COUNT > 0 ?
310 E1000_EERD_EEWR_MAX_COUNT : (words - i);
311 if (hw->nvm.ops.acquire(hw) == E1000_SUCCESS) {
312 status = igb_write_nvm_srwr(hw, offset, count,
313 data + i);
314 hw->nvm.ops.release(hw);
315 } else {
316 status = E1000_ERR_SWFW_SYNC;
317 }
318
319 if (status != E1000_SUCCESS)
320 break;
321 }
322
323 return status;
324}
325
326/**
332 * igb_read_nvm_i211 - Read NVM wrapper function for I211 327 * igb_read_nvm_i211 - Read NVM wrapper function for I211
333 * @hw: pointer to the HW structure 328 * @hw: pointer to the HW structure
334 * @address: the word address (aka eeprom offset) to read 329 * @address: the word address (aka eeprom offset) to read
@@ -637,6 +632,28 @@ out:
637} 632}
638 633
639/** 634/**
635 * igb_pool_flash_update_done_i210 - Pool FLUDONE status.
636 * @hw: pointer to the HW structure
637 *
638 */
639static s32 igb_pool_flash_update_done_i210(struct e1000_hw *hw)
640{
641 s32 ret_val = -E1000_ERR_NVM;
642 u32 i, reg;
643
644 for (i = 0; i < E1000_FLUDONE_ATTEMPTS; i++) {
645 reg = rd32(E1000_EECD);
646 if (reg & E1000_EECD_FLUDONE_I210) {
647 ret_val = E1000_SUCCESS;
648 break;
649 }
650 udelay(5);
651 }
652
653 return ret_val;
654}
655
656/**
640 * igb_update_flash_i210 - Commit EEPROM to the flash 657 * igb_update_flash_i210 - Commit EEPROM to the flash
641 * @hw: pointer to the HW structure 658 * @hw: pointer to the HW structure
642 * 659 *
@@ -666,28 +683,6 @@ out:
666} 683}
667 684
668/** 685/**
669 * igb_pool_flash_update_done_i210 - Pool FLUDONE status.
670 * @hw: pointer to the HW structure
671 *
672 **/
673s32 igb_pool_flash_update_done_i210(struct e1000_hw *hw)
674{
675 s32 ret_val = -E1000_ERR_NVM;
676 u32 i, reg;
677
678 for (i = 0; i < E1000_FLUDONE_ATTEMPTS; i++) {
679 reg = rd32(E1000_EECD);
680 if (reg & E1000_EECD_FLUDONE_I210) {
681 ret_val = E1000_SUCCESS;
682 break;
683 }
684 udelay(5);
685 }
686
687 return ret_val;
688}
689
690/**
691 * igb_valid_led_default_i210 - Verify a valid default LED config 686 * igb_valid_led_default_i210 - Verify a valid default LED config
692 * @hw: pointer to the HW structure 687 * @hw: pointer to the HW structure
693 * @data: pointer to the NVM (EEPROM) 688 * @data: pointer to the NVM (EEPROM)