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:26 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2018-10-17 16:49:33 -0400
commitc0071c7aa5fe0a6aa4cfc8426af893307ccd276d (patch)
tree4d06a191d99c460db8158f5b328826504c666354 /drivers/net/ethernet/intel/igc/igc_base.c
parent0507ef8a0372b80c30555bbeec7215f2cf874ecd (diff)
igc: Add HW initialization code
Add code for hardware initialization and reset Add code for semaphore handling Signed-off-by: Sasha Neftin <sasha.neftin@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.c187
1 files changed, 187 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igc/igc_base.c b/drivers/net/ethernet/intel/igc/igc_base.c
index 3425b7466017..4efb47497e6b 100644
--- a/drivers/net/ethernet/intel/igc/igc_base.c
+++ b/drivers/net/ethernet/intel/igc/igc_base.c
@@ -5,6 +5,184 @@
5 5
6#include "igc_hw.h" 6#include "igc_hw.h"
7#include "igc_i225.h" 7#include "igc_i225.h"
8#include "igc_mac.h"
9#include "igc_base.h"
10#include "igc.h"
11
12/**
13 * igc_set_pcie_completion_timeout - set pci-e completion timeout
14 * @hw: pointer to the HW structure
15 */
16static s32 igc_set_pcie_completion_timeout(struct igc_hw *hw)
17{
18 u32 gcr = rd32(IGC_GCR);
19 u16 pcie_devctl2;
20 s32 ret_val = 0;
21
22 /* only take action if timeout value is defaulted to 0 */
23 if (gcr & IGC_GCR_CMPL_TMOUT_MASK)
24 goto out;
25
26 /* if capabilities version is type 1 we can write the
27 * timeout of 10ms to 200ms through the GCR register
28 */
29 if (!(gcr & IGC_GCR_CAP_VER2)) {
30 gcr |= IGC_GCR_CMPL_TMOUT_10ms;
31 goto out;
32 }
33
34 /* for version 2 capabilities we need to write the config space
35 * directly in order to set the completion timeout value for
36 * 16ms to 55ms
37 */
38 ret_val = igc_read_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
39 &pcie_devctl2);
40 if (ret_val)
41 goto out;
42
43 pcie_devctl2 |= PCIE_DEVICE_CONTROL2_16ms;
44
45 ret_val = igc_write_pcie_cap_reg(hw, PCIE_DEVICE_CONTROL2,
46 &pcie_devctl2);
47out:
48 /* disable completion timeout resend */
49 gcr &= ~IGC_GCR_CMPL_TMOUT_RESEND;
50
51 wr32(IGC_GCR, gcr);
52
53 return ret_val;
54}
55
56/**
57 * igc_reset_hw_base - Reset hardware
58 * @hw: pointer to the HW structure
59 *
60 * This resets the hardware into a known state. This is a
61 * function pointer entry point called by the api module.
62 */
63static s32 igc_reset_hw_base(struct igc_hw *hw)
64{
65 s32 ret_val;
66 u32 ctrl;
67
68 /* Prevent the PCI-E bus from sticking if there is no TLP connection
69 * on the last TLP read/write transaction when MAC is reset.
70 */
71 ret_val = igc_disable_pcie_master(hw);
72 if (ret_val)
73 hw_dbg("PCI-E Master disable polling has failed.\n");
74
75 /* set the completion timeout for interface */
76 ret_val = igc_set_pcie_completion_timeout(hw);
77 if (ret_val)
78 hw_dbg("PCI-E Set completion timeout has failed.\n");
79
80 hw_dbg("Masking off all interrupts\n");
81 wr32(IGC_IMC, 0xffffffff);
82
83 wr32(IGC_RCTL, 0);
84 wr32(IGC_TCTL, IGC_TCTL_PSP);
85 wrfl();
86
87 usleep_range(10000, 20000);
88
89 ctrl = rd32(IGC_CTRL);
90
91 hw_dbg("Issuing a global reset to MAC\n");
92 wr32(IGC_CTRL, ctrl | IGC_CTRL_RST);
93
94 ret_val = igc_get_auto_rd_done(hw);
95 if (ret_val) {
96 /* When auto config read does not complete, do not
97 * return with an error. This can happen in situations
98 * where there is no eeprom and prevents getting link.
99 */
100 hw_dbg("Auto Read Done did not complete\n");
101 }
102
103 /* Clear any pending interrupt events. */
104 wr32(IGC_IMC, 0xffffffff);
105 rd32(IGC_ICR);
106
107 return ret_val;
108}
109
110/**
111 * igc_init_mac_params_base - Init MAC func ptrs.
112 * @hw: pointer to the HW structure
113 */
114static s32 igc_init_mac_params_base(struct igc_hw *hw)
115{
116 struct igc_mac_info *mac = &hw->mac;
117
118 /* Set mta register count */
119 mac->mta_reg_count = 128;
120 mac->rar_entry_count = IGC_RAR_ENTRIES;
121
122 /* reset */
123 mac->ops.reset_hw = igc_reset_hw_base;
124
125 mac->ops.acquire_swfw_sync = igc_acquire_swfw_sync_i225;
126 mac->ops.release_swfw_sync = igc_release_swfw_sync_i225;
127
128 return 0;
129}
130
131static s32 igc_get_invariants_base(struct igc_hw *hw)
132{
133 u32 link_mode = 0;
134 u32 ctrl_ext = 0;
135 s32 ret_val = 0;
136
137 ctrl_ext = rd32(IGC_CTRL_EXT);
138 link_mode = ctrl_ext & IGC_CTRL_EXT_LINK_MODE_MASK;
139
140 /* mac initialization and operations */
141 ret_val = igc_init_mac_params_base(hw);
142 if (ret_val)
143 goto out;
144
145out:
146 return ret_val;
147}
148
149/**
150 * igc_init_hw_base - Initialize hardware
151 * @hw: pointer to the HW structure
152 *
153 * This inits the hardware readying it for operation.
154 */
155static s32 igc_init_hw_base(struct igc_hw *hw)
156{
157 struct igc_mac_info *mac = &hw->mac;
158 u16 i, rar_count = mac->rar_entry_count;
159 s32 ret_val = 0;
160
161 /* Setup the receive address */
162 igc_init_rx_addrs(hw, rar_count);
163
164 /* Zero out the Multicast HASH table */
165 hw_dbg("Zeroing the MTA\n");
166 for (i = 0; i < mac->mta_reg_count; i++)
167 array_wr32(IGC_MTA, i, 0);
168
169 /* Zero out the Unicast HASH table */
170 hw_dbg("Zeroing the UTA\n");
171 for (i = 0; i < mac->uta_reg_count; i++)
172 array_wr32(IGC_UTA, i, 0);
173
174 /* Setup link and flow control */
175 ret_val = igc_setup_link(hw);
176
177 /* Clear all of the statistics registers (clear on read). It is
178 * important that we do this after we have tried to establish link
179 * because the symbol error count will increment wildly if there
180 * is no link.
181 */
182 igc_clear_hw_cntrs_base(hw);
183
184 return ret_val;
185}
8 186
9/** 187/**
10 * igc_rx_fifo_flush_base - Clean rx fifo after Rx enable 188 * igc_rx_fifo_flush_base - Clean rx fifo after Rx enable
@@ -81,3 +259,12 @@ void igc_rx_fifo_flush_base(struct igc_hw *hw)
81 rd32(IGC_RNBC); 259 rd32(IGC_RNBC);
82 rd32(IGC_MPC); 260 rd32(IGC_MPC);
83} 261}
262
263static struct igc_mac_operations igc_mac_ops_base = {
264 .init_hw = igc_init_hw_base,
265};
266
267const struct igc_info igc_base_info = {
268 .get_invariants = igc_get_invariants_base,
269 .mac_ops = &igc_mac_ops_base,
270};