aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/intel/igc/igc_base.c
diff options
context:
space:
mode:
authorSasha Neftin <sasha.neftin@intel.com>2018-10-11 03:17:28 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-10-17 16:52:00 -0400
commitab4056126813c889ee6c8fb24ca8f75b84c981ab (patch)
tree66acd757449a65ac904b8471051f90f61c865d1e /drivers/net/ethernet/intel/igc/igc_base.c
parentc0071c7aa5fe0a6aa4cfc8426af893307ccd276d (diff)
igc: Add NVM support
Add code for NVM support and get MAC address, complete probe method. Signed-off-by: Sasha Neftin <sasha.neftin@intel.com> Signed-off-by: Alexander Duyck <alexander.h.duyck@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/intel/igc/igc_base.c')
-rw-r--r--drivers/net/ethernet/intel/igc/igc_base.c109
1 files changed, 109 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igc/igc_base.c b/drivers/net/ethernet/intel/igc/igc_base.c
index 4efb47497e6b..2d49814966d3 100644
--- a/drivers/net/ethernet/intel/igc/igc_base.c
+++ b/drivers/net/ethernet/intel/igc/igc_base.c
@@ -54,6 +54,22 @@ out:
54} 54}
55 55
56/** 56/**
57 * igc_check_for_link_base - Check for link
58 * @hw: pointer to the HW structure
59 *
60 * If sgmii is enabled, then use the pcs register to determine link, otherwise
61 * use the generic interface for determining link.
62 */
63static s32 igc_check_for_link_base(struct igc_hw *hw)
64{
65 s32 ret_val = 0;
66
67 ret_val = igc_check_for_copper_link(hw);
68
69 return ret_val;
70}
71
72/**
57 * igc_reset_hw_base - Reset hardware 73 * igc_reset_hw_base - Reset hardware
58 * @hw: pointer to the HW structure 74 * @hw: pointer to the HW structure
59 * 75 *
@@ -108,11 +124,50 @@ static s32 igc_reset_hw_base(struct igc_hw *hw)
108} 124}
109 125
110/** 126/**
127 * igc_init_nvm_params_base - Init NVM func ptrs.
128 * @hw: pointer to the HW structure
129 */
130static s32 igc_init_nvm_params_base(struct igc_hw *hw)
131{
132 struct igc_nvm_info *nvm = &hw->nvm;
133 u32 eecd = rd32(IGC_EECD);
134 u16 size;
135
136 size = (u16)((eecd & IGC_EECD_SIZE_EX_MASK) >>
137 IGC_EECD_SIZE_EX_SHIFT);
138
139 /* Added to a constant, "size" becomes the left-shift value
140 * for setting word_size.
141 */
142 size += NVM_WORD_SIZE_BASE_SHIFT;
143
144 /* Just in case size is out of range, cap it to the largest
145 * EEPROM size supported
146 */
147 if (size > 15)
148 size = 15;
149
150 nvm->word_size = BIT(size);
151 nvm->opcode_bits = 8;
152 nvm->delay_usec = 1;
153
154 nvm->page_size = eecd & IGC_EECD_ADDR_BITS ? 32 : 8;
155 nvm->address_bits = eecd & IGC_EECD_ADDR_BITS ?
156 16 : 8;
157
158 if (nvm->word_size == BIT(15))
159 nvm->page_size = 128;
160
161 return 0;
162}
163
164/**
111 * igc_init_mac_params_base - Init MAC func ptrs. 165 * igc_init_mac_params_base - Init MAC func ptrs.
112 * @hw: pointer to the HW structure 166 * @hw: pointer to the HW structure
113 */ 167 */
114static s32 igc_init_mac_params_base(struct igc_hw *hw) 168static s32 igc_init_mac_params_base(struct igc_hw *hw)
115{ 169{
170 struct igc_dev_spec_base *dev_spec = &hw->dev_spec._base;
116 struct igc_mac_info *mac = &hw->mac; 171 struct igc_mac_info *mac = &hw->mac;
117 172
118 /* Set mta register count */ 173 /* Set mta register count */
@@ -125,6 +180,10 @@ static s32 igc_init_mac_params_base(struct igc_hw *hw)
125 mac->ops.acquire_swfw_sync = igc_acquire_swfw_sync_i225; 180 mac->ops.acquire_swfw_sync = igc_acquire_swfw_sync_i225;
126 mac->ops.release_swfw_sync = igc_release_swfw_sync_i225; 181 mac->ops.release_swfw_sync = igc_release_swfw_sync_i225;
127 182
183 /* Allow a single clear of the SW semaphore on I225 */
184 if (mac->type == igc_i225)
185 dev_spec->clear_semaphore_once = true;
186
128 return 0; 187 return 0;
129} 188}
130 189
@@ -142,11 +201,44 @@ static s32 igc_get_invariants_base(struct igc_hw *hw)
142 if (ret_val) 201 if (ret_val)
143 goto out; 202 goto out;
144 203
204 /* NVM initialization */
205 ret_val = igc_init_nvm_params_base(hw);
206 switch (hw->mac.type) {
207 case igc_i225:
208 ret_val = igc_init_nvm_params_i225(hw);
209 break;
210 default:
211 break;
212 }
213
214 if (ret_val)
215 goto out;
216
145out: 217out:
146 return ret_val; 218 return ret_val;
147} 219}
148 220
149/** 221/**
222 * igc_get_link_up_info_base - Get link speed/duplex info
223 * @hw: pointer to the HW structure
224 * @speed: stores the current speed
225 * @duplex: stores the current duplex
226 *
227 * This is a wrapper function, if using the serial gigabit media independent
228 * interface, use PCS to retrieve the link speed and duplex information.
229 * Otherwise, use the generic function to get the link speed and duplex info.
230 */
231static s32 igc_get_link_up_info_base(struct igc_hw *hw, u16 *speed,
232 u16 *duplex)
233{
234 s32 ret_val;
235
236 ret_val = igc_get_speed_and_duplex_copper(hw, speed, duplex);
237
238 return ret_val;
239}
240
241/**
150 * igc_init_hw_base - Initialize hardware 242 * igc_init_hw_base - Initialize hardware
151 * @hw: pointer to the HW structure 243 * @hw: pointer to the HW structure
152 * 244 *
@@ -185,6 +277,19 @@ static s32 igc_init_hw_base(struct igc_hw *hw)
185} 277}
186 278
187/** 279/**
280 * igc_read_mac_addr_base - Read device MAC address
281 * @hw: pointer to the HW structure
282 */
283static s32 igc_read_mac_addr_base(struct igc_hw *hw)
284{
285 s32 ret_val = 0;
286
287 ret_val = igc_read_mac_addr(hw);
288
289 return ret_val;
290}
291
292/**
188 * igc_rx_fifo_flush_base - Clean rx fifo after Rx enable 293 * igc_rx_fifo_flush_base - Clean rx fifo after Rx enable
189 * @hw: pointer to the HW structure 294 * @hw: pointer to the HW structure
190 * 295 *
@@ -262,6 +367,10 @@ void igc_rx_fifo_flush_base(struct igc_hw *hw)
262 367
263static struct igc_mac_operations igc_mac_ops_base = { 368static struct igc_mac_operations igc_mac_ops_base = {
264 .init_hw = igc_init_hw_base, 369 .init_hw = igc_init_hw_base,
370 .check_for_link = igc_check_for_link_base,
371 .rar_set = igc_rar_set,
372 .read_mac_addr = igc_read_mac_addr_base,
373 .get_speed_and_duplex = igc_get_link_up_info_base,
265}; 374};
266 375
267const struct igc_info igc_base_info = { 376const struct igc_info igc_base_info = {