1 Author: Tim Harvey <tharvey@gateworks.com>
2 Date: Thu May 15 00:12:26 2014 -0700
4 net: igb: add i210/i211 support for phy read/write
6 The i210/i211 uses the MDICNFG register for the phy address instead of the
9 Signed-off-by: Tim Harvey <tharvey@gateworks.com>
11 Index: linux-4.3/drivers/net/ethernet/intel/igb/e1000_phy.c
12 ===================================================================
13 --- linux-4.3.orig/drivers/net/ethernet/intel/igb/e1000_phy.c 2015-11-01 16:05:25.000000000 -0800
14 +++ linux-4.3/drivers/net/ethernet/intel/igb/e1000_phy.c 2015-12-18 10:43:28.000000000 -0800
16 s32 igb_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data)
18 struct e1000_phy_info *phy = &hw->phy;
20 + u32 i, mdicnfg, mdic = 0;
23 if (offset > MAX_PHY_REG_ADDRESS) {
25 * Control register. The MAC will take care of interfacing with the
26 * PHY to retrieve the desired data.
28 - mdic = ((offset << E1000_MDIC_REG_SHIFT) |
29 - (phy->addr << E1000_MDIC_PHY_SHIFT) |
30 - (E1000_MDIC_OP_READ));
31 + switch (hw->mac.type) {
34 + mdicnfg = rd32(E1000_MDICNFG);
35 + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
36 + mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
37 + wr32(E1000_MDICNFG, mdicnfg);
38 + mdic = ((offset << E1000_MDIC_REG_SHIFT) |
39 + (E1000_MDIC_OP_READ));
42 + mdic = ((offset << E1000_MDIC_REG_SHIFT) |
43 + (phy->addr << E1000_MDIC_PHY_SHIFT) |
44 + (E1000_MDIC_OP_READ));
48 wr32(E1000_MDIC, mdic);
51 /* Poll the ready bit to see if the MDI read completed
52 * Increasing the time out as testing showed failures with
57 + switch (hw->mac.type) {
58 + /* restore MDICNFG to have phy's addr */
61 + mdicnfg = rd32(E1000_MDICNFG);
62 + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
63 + mdicnfg |= (hw->phy.addr << E1000_MDICNFG_PHY_SHIFT);
64 + wr32(E1000_MDICNFG, mdicnfg);
73 s32 igb_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
75 struct e1000_phy_info *phy = &hw->phy;
77 + u32 i, mdicnfg, mdic = 0;
80 if (offset > MAX_PHY_REG_ADDRESS) {
82 * Control register. The MAC will take care of interfacing with the
83 * PHY to retrieve the desired data.
85 - mdic = (((u32)data) |
86 - (offset << E1000_MDIC_REG_SHIFT) |
87 - (phy->addr << E1000_MDIC_PHY_SHIFT) |
88 - (E1000_MDIC_OP_WRITE));
89 + switch (hw->mac.type) {
92 + mdicnfg = rd32(E1000_MDICNFG);
93 + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
94 + mdicnfg |= (phy->addr << E1000_MDICNFG_PHY_SHIFT);
95 + wr32(E1000_MDICNFG, mdicnfg);
96 + mdic = (((u32)data) |
97 + (offset << E1000_MDIC_REG_SHIFT) |
98 + (E1000_MDIC_OP_WRITE));
101 + mdic = (((u32)data) |
102 + (offset << E1000_MDIC_REG_SHIFT) |
103 + (phy->addr << E1000_MDIC_PHY_SHIFT) |
104 + (E1000_MDIC_OP_WRITE));
108 wr32(E1000_MDIC, mdic);
111 /* Poll the ready bit to see if the MDI read completed
112 * Increasing the time out as testing showed failures with
117 + switch (hw->mac.type) {
118 + /* restore MDICNFG to have phy's addr */
121 + mdicnfg = rd32(E1000_MDICNFG);
122 + mdicnfg &= ~(E1000_MDICNFG_PHY_MASK);
123 + mdicnfg |= (hw->phy.addr << E1000_MDICNFG_PHY_SHIFT);
124 + wr32(E1000_MDICNFG, mdicnfg);