author | Florian Pose <fp@igh.de> |
Wed, 14 Feb 2018 11:46:03 +0100 | |
branch | stable-1.5 |
changeset 2723 | 37d89f56e9f1 |
parent 2685 | 740291442c05 |
permissions | -rw-r--r-- |
2685
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
1 |
/* Intel(R) Gigabit Ethernet Linux driver |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
2 |
* Copyright(c) 2007-2014 Intel Corporation. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify it |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
4 |
* under the terms and conditions of the GNU General Public License, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
5 |
* version 2, as published by the Free Software Foundation. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
6 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope it will be useful, but WITHOUT |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
8 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
9 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
10 |
* more details. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
11 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License along with |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
13 |
* this program; if not, see <http://www.gnu.org/licenses/>. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
14 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
15 |
* The full GNU General Public License is included in this distribution in |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
16 |
* the file called "COPYING". |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
17 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
18 |
* Contact Information: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
19 |
* e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
20 |
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
21 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
22 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
23 |
#include <linux/if_ether.h> |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
24 |
#include <linux/delay.h> |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
25 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
26 |
#include "e1000_mac.h" |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
27 |
#include "e1000_nvm.h" |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
28 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
29 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
30 |
* igb_raise_eec_clk - Raise EEPROM clock |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
31 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
32 |
* @eecd: pointer to the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
33 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
34 |
* Enable/Raise the EEPROM clock bit. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
35 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
36 |
static void igb_raise_eec_clk(struct e1000_hw *hw, u32 *eecd) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
37 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
38 |
*eecd = *eecd | E1000_EECD_SK; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
39 |
wr32(E1000_EECD, *eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
40 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
41 |
udelay(hw->nvm.delay_usec); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
42 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
43 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
44 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
45 |
* igb_lower_eec_clk - Lower EEPROM clock |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
46 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
47 |
* @eecd: pointer to the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
48 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
49 |
* Clear/Lower the EEPROM clock bit. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
50 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
51 |
static void igb_lower_eec_clk(struct e1000_hw *hw, u32 *eecd) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
52 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
53 |
*eecd = *eecd & ~E1000_EECD_SK; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
54 |
wr32(E1000_EECD, *eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
55 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
56 |
udelay(hw->nvm.delay_usec); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
57 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
58 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
59 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
60 |
* igb_shift_out_eec_bits - Shift data bits our to the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
61 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
62 |
* @data: data to send to the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
63 |
* @count: number of bits to shift out |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
64 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
65 |
* We need to shift 'count' bits out to the EEPROM. So, the value in the |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
66 |
* "data" parameter will be shifted out to the EEPROM one bit at a time. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
67 |
* In order to do this, "data" must be broken down into bits. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
68 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
69 |
static void igb_shift_out_eec_bits(struct e1000_hw *hw, u16 data, u16 count) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
70 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
71 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
72 |
u32 eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
73 |
u32 mask; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
74 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
75 |
mask = 0x01 << (count - 1); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
76 |
if (nvm->type == e1000_nvm_eeprom_spi) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
77 |
eecd |= E1000_EECD_DO; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
78 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
79 |
do { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
80 |
eecd &= ~E1000_EECD_DI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
81 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
82 |
if (data & mask) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
83 |
eecd |= E1000_EECD_DI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
84 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
85 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
86 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
87 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
88 |
udelay(nvm->delay_usec); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
89 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
90 |
igb_raise_eec_clk(hw, &eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
91 |
igb_lower_eec_clk(hw, &eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
92 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
93 |
mask >>= 1; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
94 |
} while (mask); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
95 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
96 |
eecd &= ~E1000_EECD_DI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
97 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
98 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
99 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
100 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
101 |
* igb_shift_in_eec_bits - Shift data bits in from the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
102 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
103 |
* @count: number of bits to shift in |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
104 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
105 |
* In order to read a register from the EEPROM, we need to shift 'count' bits |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
106 |
* in from the EEPROM. Bits are "shifted in" by raising the clock input to |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
107 |
* the EEPROM (setting the SK bit), and then reading the value of the data out |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
108 |
* "DO" bit. During this "shifting in" process the data in "DI" bit should |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
109 |
* always be clear. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
110 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
111 |
static u16 igb_shift_in_eec_bits(struct e1000_hw *hw, u16 count) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
112 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
113 |
u32 eecd; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
114 |
u32 i; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
115 |
u16 data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
116 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
117 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
118 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
119 |
eecd &= ~(E1000_EECD_DO | E1000_EECD_DI); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
120 |
data = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
121 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
122 |
for (i = 0; i < count; i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
123 |
data <<= 1; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
124 |
igb_raise_eec_clk(hw, &eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
125 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
126 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
127 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
128 |
eecd &= ~E1000_EECD_DI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
129 |
if (eecd & E1000_EECD_DO) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
130 |
data |= 1; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
131 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
132 |
igb_lower_eec_clk(hw, &eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
133 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
134 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
135 |
return data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
136 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
137 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
138 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
139 |
* igb_poll_eerd_eewr_done - Poll for EEPROM read/write completion |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
140 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
141 |
* @ee_reg: EEPROM flag for polling |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
142 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
143 |
* Polls the EEPROM status bit for either read or write completion based |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
144 |
* upon the value of 'ee_reg'. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
145 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
146 |
static s32 igb_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
147 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
148 |
u32 attempts = 100000; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
149 |
u32 i, reg = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
150 |
s32 ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
151 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
152 |
for (i = 0; i < attempts; i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
153 |
if (ee_reg == E1000_NVM_POLL_READ) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
154 |
reg = rd32(E1000_EERD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
155 |
else |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
156 |
reg = rd32(E1000_EEWR); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
157 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
158 |
if (reg & E1000_NVM_RW_REG_DONE) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
159 |
ret_val = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
160 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
161 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
162 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
163 |
udelay(5); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
164 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
165 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
166 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
167 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
168 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
169 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
170 |
* igb_acquire_nvm - Generic request for access to EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
171 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
172 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
173 |
* Set the EEPROM access request bit and wait for EEPROM access grant bit. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
174 |
* Return successful if access grant bit set, else clear the request for |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
175 |
* EEPROM access and return -E1000_ERR_NVM (-1). |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
176 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
177 |
s32 igb_acquire_nvm(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
178 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
179 |
u32 eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
180 |
s32 timeout = E1000_NVM_GRANT_ATTEMPTS; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
181 |
s32 ret_val = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
182 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
183 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
184 |
wr32(E1000_EECD, eecd | E1000_EECD_REQ); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
185 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
186 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
187 |
while (timeout) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
188 |
if (eecd & E1000_EECD_GNT) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
189 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
190 |
udelay(5); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
191 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
192 |
timeout--; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
193 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
194 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
195 |
if (!timeout) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
196 |
eecd &= ~E1000_EECD_REQ; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
197 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
198 |
hw_dbg("Could not acquire NVM grant\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
199 |
ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
200 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
201 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
202 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
203 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
204 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
205 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
206 |
* igb_standby_nvm - Return EEPROM to standby state |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
207 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
208 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
209 |
* Return the EEPROM to a standby state. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
210 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
211 |
static void igb_standby_nvm(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
212 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
213 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
214 |
u32 eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
215 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
216 |
if (nvm->type == e1000_nvm_eeprom_spi) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
217 |
/* Toggle CS to flush commands */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
218 |
eecd |= E1000_EECD_CS; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
219 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
220 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
221 |
udelay(nvm->delay_usec); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
222 |
eecd &= ~E1000_EECD_CS; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
223 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
224 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
225 |
udelay(nvm->delay_usec); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
226 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
227 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
228 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
229 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
230 |
* e1000_stop_nvm - Terminate EEPROM command |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
231 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
232 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
233 |
* Terminates the current command by inverting the EEPROM's chip select pin. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
234 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
235 |
static void e1000_stop_nvm(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
236 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
237 |
u32 eecd; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
238 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
239 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
240 |
if (hw->nvm.type == e1000_nvm_eeprom_spi) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
241 |
/* Pull CS high */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
242 |
eecd |= E1000_EECD_CS; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
243 |
igb_lower_eec_clk(hw, &eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
244 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
245 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
246 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
247 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
248 |
* igb_release_nvm - Release exclusive access to EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
249 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
250 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
251 |
* Stop any current commands to the EEPROM and clear the EEPROM request bit. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
252 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
253 |
void igb_release_nvm(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
254 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
255 |
u32 eecd; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
256 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
257 |
e1000_stop_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
258 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
259 |
eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
260 |
eecd &= ~E1000_EECD_REQ; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
261 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
262 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
263 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
264 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
265 |
* igb_ready_nvm_eeprom - Prepares EEPROM for read/write |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
266 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
267 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
268 |
* Setups the EEPROM for reading and writing. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
269 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
270 |
static s32 igb_ready_nvm_eeprom(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
271 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
272 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
273 |
u32 eecd = rd32(E1000_EECD); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
274 |
s32 ret_val = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
275 |
u16 timeout = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
276 |
u8 spi_stat_reg; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
277 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
278 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
279 |
if (nvm->type == e1000_nvm_eeprom_spi) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
280 |
/* Clear SK and CS */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
281 |
eecd &= ~(E1000_EECD_CS | E1000_EECD_SK); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
282 |
wr32(E1000_EECD, eecd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
283 |
wrfl(); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
284 |
udelay(1); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
285 |
timeout = NVM_MAX_RETRY_SPI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
286 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
287 |
/* Read "Status Register" repeatedly until the LSB is cleared. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
288 |
* The EEPROM will signal that the command has been completed |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
289 |
* by clearing bit 0 of the internal status register. If it's |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
290 |
* not cleared within 'timeout', then error out. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
291 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
292 |
while (timeout) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
293 |
igb_shift_out_eec_bits(hw, NVM_RDSR_OPCODE_SPI, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
294 |
hw->nvm.opcode_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
295 |
spi_stat_reg = (u8)igb_shift_in_eec_bits(hw, 8); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
296 |
if (!(spi_stat_reg & NVM_STATUS_RDY_SPI)) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
297 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
298 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
299 |
udelay(5); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
300 |
igb_standby_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
301 |
timeout--; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
302 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
303 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
304 |
if (!timeout) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
305 |
hw_dbg("SPI NVM Status error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
306 |
ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
307 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
308 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
309 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
310 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
311 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
312 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
313 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
314 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
315 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
316 |
* igb_read_nvm_spi - Read EEPROM's using SPI |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
317 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
318 |
* @offset: offset of word in the EEPROM to read |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
319 |
* @words: number of words to read |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
320 |
* @data: word read from the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
321 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
322 |
* Reads a 16 bit word from the EEPROM. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
323 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
324 |
s32 igb_read_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
325 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
326 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
327 |
u32 i = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
328 |
s32 ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
329 |
u16 word_in; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
330 |
u8 read_opcode = NVM_READ_OPCODE_SPI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
331 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
332 |
/* A check for invalid values: offset too large, too many words, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
333 |
* and not enough words. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
334 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
335 |
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
336 |
(words == 0)) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
337 |
hw_dbg("nvm parameter(s) out of bounds\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
338 |
ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
339 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
340 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
341 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
342 |
ret_val = nvm->ops.acquire(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
343 |
if (ret_val) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
344 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
345 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
346 |
ret_val = igb_ready_nvm_eeprom(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
347 |
if (ret_val) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
348 |
goto release; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
349 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
350 |
igb_standby_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
351 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
352 |
if ((nvm->address_bits == 8) && (offset >= 128)) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
353 |
read_opcode |= NVM_A8_OPCODE_SPI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
354 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
355 |
/* Send the READ command (opcode + addr) */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
356 |
igb_shift_out_eec_bits(hw, read_opcode, nvm->opcode_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
357 |
igb_shift_out_eec_bits(hw, (u16)(offset*2), nvm->address_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
358 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
359 |
/* Read the data. SPI NVMs increment the address with each byte |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
360 |
* read and will roll over if reading beyond the end. This allows |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
361 |
* us to read the whole NVM from any offset |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
362 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
363 |
for (i = 0; i < words; i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
364 |
word_in = igb_shift_in_eec_bits(hw, 16); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
365 |
data[i] = (word_in >> 8) | (word_in << 8); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
366 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
367 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
368 |
release: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
369 |
nvm->ops.release(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
370 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
371 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
372 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
373 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
374 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
375 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
376 |
* igb_read_nvm_eerd - Reads EEPROM using EERD register |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
377 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
378 |
* @offset: offset of word in the EEPROM to read |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
379 |
* @words: number of words to read |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
380 |
* @data: word read from the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
381 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
382 |
* Reads a 16 bit word from the EEPROM using the EERD register. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
383 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
384 |
s32 igb_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
385 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
386 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
387 |
u32 i, eerd = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
388 |
s32 ret_val = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
389 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
390 |
/* A check for invalid values: offset too large, too many words, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
391 |
* and not enough words. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
392 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
393 |
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
394 |
(words == 0)) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
395 |
hw_dbg("nvm parameter(s) out of bounds\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
396 |
ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
397 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
398 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
399 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
400 |
for (i = 0; i < words; i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
401 |
eerd = ((offset+i) << E1000_NVM_RW_ADDR_SHIFT) + |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
402 |
E1000_NVM_RW_REG_START; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
403 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
404 |
wr32(E1000_EERD, eerd); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
405 |
ret_val = igb_poll_eerd_eewr_done(hw, E1000_NVM_POLL_READ); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
406 |
if (ret_val) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
407 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
408 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
409 |
data[i] = (rd32(E1000_EERD) >> |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
410 |
E1000_NVM_RW_REG_DATA); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
411 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
412 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
413 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
414 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
415 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
416 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
417 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
418 |
* igb_write_nvm_spi - Write to EEPROM using SPI |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
419 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
420 |
* @offset: offset within the EEPROM to be written to |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
421 |
* @words: number of words to write |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
422 |
* @data: 16 bit word(s) to be written to the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
423 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
424 |
* Writes data to EEPROM at offset using SPI interface. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
425 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
426 |
* If e1000_update_nvm_checksum is not called after this function , the |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
427 |
* EEPROM will most likley contain an invalid checksum. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
428 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
429 |
s32 igb_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
430 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
431 |
struct e1000_nvm_info *nvm = &hw->nvm; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
432 |
s32 ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
433 |
u16 widx = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
434 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
435 |
/* A check for invalid values: offset too large, too many words, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
436 |
* and not enough words. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
437 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
438 |
if ((offset >= nvm->word_size) || (words > (nvm->word_size - offset)) || |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
439 |
(words == 0)) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
440 |
hw_dbg("nvm parameter(s) out of bounds\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
441 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
442 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
443 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
444 |
while (widx < words) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
445 |
u8 write_opcode = NVM_WRITE_OPCODE_SPI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
446 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
447 |
ret_val = nvm->ops.acquire(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
448 |
if (ret_val) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
449 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
450 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
451 |
ret_val = igb_ready_nvm_eeprom(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
452 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
453 |
nvm->ops.release(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
454 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
455 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
456 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
457 |
igb_standby_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
458 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
459 |
/* Send the WRITE ENABLE command (8 bit opcode) */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
460 |
igb_shift_out_eec_bits(hw, NVM_WREN_OPCODE_SPI, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
461 |
nvm->opcode_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
462 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
463 |
igb_standby_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
464 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
465 |
/* Some SPI eeproms use the 8th address bit embedded in the |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
466 |
* opcode |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
467 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
468 |
if ((nvm->address_bits == 8) && (offset >= 128)) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
469 |
write_opcode |= NVM_A8_OPCODE_SPI; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
470 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
471 |
/* Send the Write command (8-bit opcode + addr) */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
472 |
igb_shift_out_eec_bits(hw, write_opcode, nvm->opcode_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
473 |
igb_shift_out_eec_bits(hw, (u16)((offset + widx) * 2), |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
474 |
nvm->address_bits); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
475 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
476 |
/* Loop to allow for up to whole page write of eeprom */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
477 |
while (widx < words) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
478 |
u16 word_out = data[widx]; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
479 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
480 |
word_out = (word_out >> 8) | (word_out << 8); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
481 |
igb_shift_out_eec_bits(hw, word_out, 16); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
482 |
widx++; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
483 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
484 |
if ((((offset + widx) * 2) % nvm->page_size) == 0) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
485 |
igb_standby_nvm(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
486 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
487 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
488 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
489 |
usleep_range(1000, 2000); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
490 |
nvm->ops.release(hw); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
491 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
492 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
493 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
494 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
495 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
496 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
497 |
* igb_read_part_string - Read device part number |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
498 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
499 |
* @part_num: pointer to device part number |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
500 |
* @part_num_size: size of part number buffer |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
501 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
502 |
* Reads the product board assembly (PBA) number from the EEPROM and stores |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
503 |
* the value in part_num. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
504 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
505 |
s32 igb_read_part_string(struct e1000_hw *hw, u8 *part_num, u32 part_num_size) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
506 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
507 |
s32 ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
508 |
u16 nvm_data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
509 |
u16 pointer; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
510 |
u16 offset; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
511 |
u16 length; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
512 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
513 |
if (part_num == NULL) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
514 |
hw_dbg("PBA string buffer was null\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
515 |
ret_val = E1000_ERR_INVALID_ARGUMENT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
516 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
517 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
518 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
519 |
ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_0, 1, &nvm_data); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
520 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
521 |
hw_dbg("NVM Read Error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
522 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
523 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
524 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
525 |
ret_val = hw->nvm.ops.read(hw, NVM_PBA_OFFSET_1, 1, &pointer); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
526 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
527 |
hw_dbg("NVM Read Error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
528 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
529 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
530 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
531 |
/* if nvm_data is not ptr guard the PBA must be in legacy format which |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
532 |
* means pointer is actually our second data word for the PBA number |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
533 |
* and we can decode it into an ascii string |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
534 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
535 |
if (nvm_data != NVM_PBA_PTR_GUARD) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
536 |
hw_dbg("NVM PBA number is not stored as string\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
537 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
538 |
/* we will need 11 characters to store the PBA */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
539 |
if (part_num_size < 11) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
540 |
hw_dbg("PBA string buffer too small\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
541 |
return E1000_ERR_NO_SPACE; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
542 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
543 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
544 |
/* extract hex string from data and pointer */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
545 |
part_num[0] = (nvm_data >> 12) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
546 |
part_num[1] = (nvm_data >> 8) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
547 |
part_num[2] = (nvm_data >> 4) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
548 |
part_num[3] = nvm_data & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
549 |
part_num[4] = (pointer >> 12) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
550 |
part_num[5] = (pointer >> 8) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
551 |
part_num[6] = '-'; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
552 |
part_num[7] = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
553 |
part_num[8] = (pointer >> 4) & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
554 |
part_num[9] = pointer & 0xF; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
555 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
556 |
/* put a null character on the end of our string */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
557 |
part_num[10] = '\0'; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
558 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
559 |
/* switch all the data but the '-' to hex char */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
560 |
for (offset = 0; offset < 10; offset++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
561 |
if (part_num[offset] < 0xA) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
562 |
part_num[offset] += '0'; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
563 |
else if (part_num[offset] < 0x10) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
564 |
part_num[offset] += 'A' - 0xA; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
565 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
566 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
567 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
568 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
569 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
570 |
ret_val = hw->nvm.ops.read(hw, pointer, 1, &length); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
571 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
572 |
hw_dbg("NVM Read Error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
573 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
574 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
575 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
576 |
if (length == 0xFFFF || length == 0) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
577 |
hw_dbg("NVM PBA number section invalid length\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
578 |
ret_val = E1000_ERR_NVM_PBA_SECTION; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
579 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
580 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
581 |
/* check if part_num buffer is big enough */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
582 |
if (part_num_size < (((u32)length * 2) - 1)) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
583 |
hw_dbg("PBA string buffer too small\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
584 |
ret_val = E1000_ERR_NO_SPACE; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
585 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
586 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
587 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
588 |
/* trim pba length from start of string */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
589 |
pointer++; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
590 |
length--; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
591 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
592 |
for (offset = 0; offset < length; offset++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
593 |
ret_val = hw->nvm.ops.read(hw, pointer + offset, 1, &nvm_data); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
594 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
595 |
hw_dbg("NVM Read Error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
596 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
597 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
598 |
part_num[offset * 2] = (u8)(nvm_data >> 8); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
599 |
part_num[(offset * 2) + 1] = (u8)(nvm_data & 0xFF); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
600 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
601 |
part_num[offset * 2] = '\0'; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
602 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
603 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
604 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
605 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
606 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
607 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
608 |
* igb_read_mac_addr - Read device MAC address |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
609 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
610 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
611 |
* Reads the device MAC address from the EEPROM and stores the value. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
612 |
* Since devices with two ports use the same EEPROM, we increment the |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
613 |
* last bit in the MAC address for the second port. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
614 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
615 |
s32 igb_read_mac_addr(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
616 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
617 |
u32 rar_high; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
618 |
u32 rar_low; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
619 |
u16 i; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
620 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
621 |
rar_high = rd32(E1000_RAH(0)); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
622 |
rar_low = rd32(E1000_RAL(0)); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
623 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
624 |
for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
625 |
hw->mac.perm_addr[i] = (u8)(rar_low >> (i*8)); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
626 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
627 |
for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
628 |
hw->mac.perm_addr[i+4] = (u8)(rar_high >> (i*8)); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
629 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
630 |
for (i = 0; i < ETH_ALEN; i++) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
631 |
hw->mac.addr[i] = hw->mac.perm_addr[i]; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
632 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
633 |
return 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
634 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
635 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
636 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
637 |
* igb_validate_nvm_checksum - Validate EEPROM checksum |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
638 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
639 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
640 |
* Calculates the EEPROM checksum by reading/adding each word of the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
641 |
* and then verifies that the sum of the EEPROM is equal to 0xBABA. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
642 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
643 |
s32 igb_validate_nvm_checksum(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
644 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
645 |
s32 ret_val = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
646 |
u16 checksum = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
647 |
u16 i, nvm_data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
648 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
649 |
for (i = 0; i < (NVM_CHECKSUM_REG + 1); i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
650 |
ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
651 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
652 |
hw_dbg("NVM Read Error\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
653 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
654 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
655 |
checksum += nvm_data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
656 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
657 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
658 |
if (checksum != (u16) NVM_SUM) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
659 |
hw_dbg("NVM Checksum Invalid\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
660 |
ret_val = -E1000_ERR_NVM; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
661 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
662 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
663 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
664 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
665 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
666 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
667 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
668 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
669 |
* igb_update_nvm_checksum - Update EEPROM checksum |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
670 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
671 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
672 |
* Updates the EEPROM checksum by reading/adding each word of the EEPROM |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
673 |
* up to the checksum. Then calculates the EEPROM checksum and writes the |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
674 |
* value to the EEPROM. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
675 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
676 |
s32 igb_update_nvm_checksum(struct e1000_hw *hw) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
677 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
678 |
s32 ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
679 |
u16 checksum = 0; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
680 |
u16 i, nvm_data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
681 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
682 |
for (i = 0; i < NVM_CHECKSUM_REG; i++) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
683 |
ret_val = hw->nvm.ops.read(hw, i, 1, &nvm_data); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
684 |
if (ret_val) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
685 |
hw_dbg("NVM Read Error while updating checksum.\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
686 |
goto out; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
687 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
688 |
checksum += nvm_data; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
689 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
690 |
checksum = (u16) NVM_SUM - checksum; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
691 |
ret_val = hw->nvm.ops.write(hw, NVM_CHECKSUM_REG, 1, &checksum); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
692 |
if (ret_val) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
693 |
hw_dbg("NVM Write Error while updating checksum.\n"); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
694 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
695 |
out: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
696 |
return ret_val; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
697 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
698 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
699 |
/** |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
700 |
* igb_get_fw_version - Get firmware version information |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
701 |
* @hw: pointer to the HW structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
702 |
* @fw_vers: pointer to output structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
703 |
* |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
704 |
* unsupported MAC types will return all 0 version structure |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
705 |
**/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
706 |
void igb_get_fw_version(struct e1000_hw *hw, struct e1000_fw_version *fw_vers) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
707 |
{ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
708 |
u16 eeprom_verh, eeprom_verl, etrack_test, fw_version; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
709 |
u8 q, hval, rem, result; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
710 |
u16 comb_verh, comb_verl, comb_offset; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
711 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
712 |
memset(fw_vers, 0, sizeof(struct e1000_fw_version)); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
713 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
714 |
/* basic eeprom version numbers and bits used vary by part and by tool |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
715 |
* used to create the nvm images. Check which data format we have. |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
716 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
717 |
hw->nvm.ops.read(hw, NVM_ETRACK_HIWORD, 1, &etrack_test); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
718 |
switch (hw->mac.type) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
719 |
case e1000_i211: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
720 |
igb_read_invm_version(hw, fw_vers); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
721 |
return; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
722 |
case e1000_82575: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
723 |
case e1000_82576: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
724 |
case e1000_82580: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
725 |
/* Use this format, unless EETRACK ID exists, |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
726 |
* then use alternate format |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
727 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
728 |
if ((etrack_test & NVM_MAJOR_MASK) != NVM_ETRACK_VALID) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
729 |
hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
730 |
fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
731 |
>> NVM_MAJOR_SHIFT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
732 |
fw_vers->eep_minor = (fw_version & NVM_MINOR_MASK) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
733 |
>> NVM_MINOR_SHIFT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
734 |
fw_vers->eep_build = (fw_version & NVM_IMAGE_ID_MASK); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
735 |
goto etrack_id; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
736 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
737 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
738 |
case e1000_i210: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
739 |
if (!(igb_get_flash_presence_i210(hw))) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
740 |
igb_read_invm_version(hw, fw_vers); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
741 |
return; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
742 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
743 |
/* fall through */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
744 |
case e1000_i350: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
745 |
/* find combo image version */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
746 |
hw->nvm.ops.read(hw, NVM_COMB_VER_PTR, 1, &comb_offset); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
747 |
if ((comb_offset != 0x0) && |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
748 |
(comb_offset != NVM_VER_INVALID)) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
749 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
750 |
hw->nvm.ops.read(hw, (NVM_COMB_VER_OFF + comb_offset |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
751 |
+ 1), 1, &comb_verh); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
752 |
hw->nvm.ops.read(hw, (NVM_COMB_VER_OFF + comb_offset), |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
753 |
1, &comb_verl); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
754 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
755 |
/* get Option Rom version if it exists and is valid */ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
756 |
if ((comb_verh && comb_verl) && |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
757 |
((comb_verh != NVM_VER_INVALID) && |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
758 |
(comb_verl != NVM_VER_INVALID))) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
759 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
760 |
fw_vers->or_valid = true; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
761 |
fw_vers->or_major = |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
762 |
comb_verl >> NVM_COMB_VER_SHFT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
763 |
fw_vers->or_build = |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
764 |
(comb_verl << NVM_COMB_VER_SHFT) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
765 |
| (comb_verh >> NVM_COMB_VER_SHFT); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
766 |
fw_vers->or_patch = |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
767 |
comb_verh & NVM_COMB_VER_MASK; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
768 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
769 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
770 |
break; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
771 |
default: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
772 |
return; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
773 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
774 |
hw->nvm.ops.read(hw, NVM_VERSION, 1, &fw_version); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
775 |
fw_vers->eep_major = (fw_version & NVM_MAJOR_MASK) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
776 |
>> NVM_MAJOR_SHIFT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
777 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
778 |
/* check for old style version format in newer images*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
779 |
if ((fw_version & NVM_NEW_DEC_MASK) == 0x0) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
780 |
eeprom_verl = (fw_version & NVM_COMB_VER_MASK); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
781 |
} else { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
782 |
eeprom_verl = (fw_version & NVM_MINOR_MASK) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
783 |
>> NVM_MINOR_SHIFT; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
784 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
785 |
/* Convert minor value to hex before assigning to output struct |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
786 |
* Val to be converted will not be higher than 99, per tool output |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
787 |
*/ |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
788 |
q = eeprom_verl / NVM_HEX_CONV; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
789 |
hval = q * NVM_HEX_TENS; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
790 |
rem = eeprom_verl % NVM_HEX_CONV; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
791 |
result = hval + rem; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
792 |
fw_vers->eep_minor = result; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
793 |
|
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
794 |
etrack_id: |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
795 |
if ((etrack_test & NVM_MAJOR_MASK) == NVM_ETRACK_VALID) { |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
796 |
hw->nvm.ops.read(hw, NVM_ETRACK_WORD, 1, &eeprom_verl); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
797 |
hw->nvm.ops.read(hw, (NVM_ETRACK_WORD + 1), 1, &eeprom_verh); |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
798 |
fw_vers->etrack_id = (eeprom_verh << NVM_ETRACK_SHIFT) |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
799 |
| eeprom_verl; |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
800 |
} |
740291442c05
Added clean igb driver from kernel 3.18 (no EtherCAT yet).
Florian Pose <fp@igh.de>
parents:
diff
changeset
|
801 |
} |