1
2
3
4
5#include "e1000_hw.h"
6#include "e1000_82575.h"
7#include "e1000_mac.h"
8#include "e1000_base.h"
9#include "e1000_manage.h"
10
11
12
13
14
15
16
17s32 e1000_acquire_phy_base(struct e1000_hw *hw)
18{
19 u16 mask = E1000_SWFW_PHY0_SM;
20
21 DEBUGFUNC("e1000_acquire_phy_base");
22
23 if (hw->bus.func == E1000_FUNC_1)
24 mask = E1000_SWFW_PHY1_SM;
25 else if (hw->bus.func == E1000_FUNC_2)
26 mask = E1000_SWFW_PHY2_SM;
27 else if (hw->bus.func == E1000_FUNC_3)
28 mask = E1000_SWFW_PHY3_SM;
29
30 return hw->mac.ops.acquire_swfw_sync(hw, mask);
31}
32
33
34
35
36
37
38
39void e1000_release_phy_base(struct e1000_hw *hw)
40{
41 u16 mask = E1000_SWFW_PHY0_SM;
42
43 DEBUGFUNC("e1000_release_phy_base");
44
45 if (hw->bus.func == E1000_FUNC_1)
46 mask = E1000_SWFW_PHY1_SM;
47 else if (hw->bus.func == E1000_FUNC_2)
48 mask = E1000_SWFW_PHY2_SM;
49 else if (hw->bus.func == E1000_FUNC_3)
50 mask = E1000_SWFW_PHY3_SM;
51
52 hw->mac.ops.release_swfw_sync(hw, mask);
53}
54
55
56
57
58
59
60
61s32 e1000_init_hw_base(struct e1000_hw *hw)
62{
63 struct e1000_mac_info *mac = &hw->mac;
64 s32 ret_val;
65 u16 i, rar_count = mac->rar_entry_count;
66
67 DEBUGFUNC("e1000_init_hw_base");
68
69
70 e1000_init_rx_addrs_generic(hw, rar_count);
71
72
73 DEBUGOUT("Zeroing the MTA\n");
74 for (i = 0; i < mac->mta_reg_count; i++)
75 E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
76
77
78 DEBUGOUT("Zeroing the UTA\n");
79 for (i = 0; i < mac->uta_reg_count; i++)
80 E1000_WRITE_REG_ARRAY(hw, E1000_UTA, i, 0);
81
82
83 ret_val = mac->ops.setup_link(hw);
84
85
86
87
88
89
90 e1000_clear_hw_cntrs_base_generic(hw);
91
92 return ret_val;
93}
94
95
96
97
98
99
100
101
102void e1000_power_down_phy_copper_base(struct e1000_hw *hw)
103{
104 struct e1000_phy_info *phy = &hw->phy;
105
106 if (!(phy->ops.check_reset_block))
107 return;
108
109
110 if (phy->ops.check_reset_block(hw))
111 e1000_power_down_phy_copper(hw);
112}
113
114
115
116
117
118
119
120
121
122
123void e1000_rx_fifo_flush_base(struct e1000_hw *hw)
124{
125 u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled;
126 int i, ms_wait;
127
128 DEBUGFUNC("e1000_rx_fifo_flush_base");
129
130
131 rfctl = E1000_READ_REG(hw, E1000_RFCTL);
132 rfctl |= E1000_RFCTL_IPV6_EX_DIS;
133 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
134
135 if (!(E1000_READ_REG(hw, E1000_MANC) & E1000_MANC_RCV_TCO_EN))
136 return;
137
138
139 for (i = 0; i < 4; i++) {
140 rxdctl[i] = E1000_READ_REG(hw, E1000_RXDCTL(i));
141 E1000_WRITE_REG(hw, E1000_RXDCTL(i),
142 rxdctl[i] & ~E1000_RXDCTL_QUEUE_ENABLE);
143 }
144
145 for (ms_wait = 0; ms_wait < 10; ms_wait++) {
146 msec_delay(1);
147 rx_enabled = 0;
148 for (i = 0; i < 4; i++)
149 rx_enabled |= E1000_READ_REG(hw, E1000_RXDCTL(i));
150 if (!(rx_enabled & E1000_RXDCTL_QUEUE_ENABLE))
151 break;
152 }
153
154 if (ms_wait == 10)
155 DEBUGOUT("Queue disable timed out after 10ms\n");
156
157
158
159
160
161 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl & ~E1000_RFCTL_LEF);
162
163 rlpml = E1000_READ_REG(hw, E1000_RLPML);
164 E1000_WRITE_REG(hw, E1000_RLPML, 0);
165
166 rctl = E1000_READ_REG(hw, E1000_RCTL);
167 temp_rctl = rctl & ~(E1000_RCTL_EN | E1000_RCTL_SBP);
168 temp_rctl |= E1000_RCTL_LPE;
169
170 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl);
171 E1000_WRITE_REG(hw, E1000_RCTL, temp_rctl | E1000_RCTL_EN);
172 E1000_WRITE_FLUSH(hw);
173 msec_delay(2);
174
175
176
177
178 for (i = 0; i < 4; i++)
179 E1000_WRITE_REG(hw, E1000_RXDCTL(i), rxdctl[i]);
180 E1000_WRITE_REG(hw, E1000_RCTL, rctl);
181 E1000_WRITE_FLUSH(hw);
182
183 E1000_WRITE_REG(hw, E1000_RLPML, rlpml);
184 E1000_WRITE_REG(hw, E1000_RFCTL, rfctl);
185
186
187 E1000_READ_REG(hw, E1000_ROC);
188 E1000_READ_REG(hw, E1000_RNBC);
189 E1000_READ_REG(hw, E1000_MPC);
190}
191