aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/cxgb3/ael1002.c
diff options
context:
space:
mode:
authorDivy Le Ray <divy@chelsio.com>2008-10-08 20:39:31 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-08 20:39:31 -0400
commit9b1e36566c5fafbcc732c971acfcf8580332931a (patch)
tree2c779d712f07f0b097ad1a2041779597b7ca9bbc /drivers/net/cxgb3/ael1002.c
parentf231e0a5a2d01da40515c24f1daa689fe8cfd8d7 (diff)
cxgb3: commnonize LASI phy code
Add generic code to manage interrupt driven PHYs. Do not reset the phy after link parameters update, the new values might get lost. Return early from link change notification when the link parameters remain unchanged. Signed-off-by: Divy Le Ray <divy@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/cxgb3/ael1002.c')
-rw-r--r--drivers/net/cxgb3/ael1002.c46
1 files changed, 8 insertions, 38 deletions
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c
index f4e046e32fc6..f6e575fa7468 100644
--- a/drivers/net/cxgb3/ael1002.c
+++ b/drivers/net/cxgb3/ael1002.c
@@ -39,9 +39,6 @@ enum {
39 AEL1002_PWR_DOWN_LO = 0xc012, 39 AEL1002_PWR_DOWN_LO = 0xc012,
40 AEL1002_XFI_EQL = 0xc015, 40 AEL1002_XFI_EQL = 0xc015,
41 AEL1002_LB_EN = 0xc017, 41 AEL1002_LB_EN = 0xc017,
42
43 LASI_CTRL = 0x9002,
44 LASI_STAT = 0x9005
45}; 42};
46 43
47static void ael100x_txon(struct cphy *phy) 44static void ael100x_txon(struct cphy *phy)
@@ -134,33 +131,6 @@ static int ael1006_reset(struct cphy *phy, int wait)
134 return t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait); 131 return t3_phy_reset(phy, MDIO_DEV_PMA_PMD, wait);
135} 132}
136 133
137static int ael1006_intr_enable(struct cphy *phy)
138{
139 return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 1);
140}
141
142static int ael1006_intr_disable(struct cphy *phy)
143{
144 return mdio_write(phy, MDIO_DEV_PMA_PMD, LASI_CTRL, 0);
145}
146
147static int ael1006_intr_clear(struct cphy *phy)
148{
149 u32 val;
150
151 return mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &val);
152}
153
154static int ael1006_intr_handler(struct cphy *phy)
155{
156 unsigned int status;
157 int err = mdio_read(phy, MDIO_DEV_PMA_PMD, LASI_STAT, &status);
158
159 if (err)
160 return err;
161 return (status & 1) ? cphy_cause_link_change : 0;
162}
163
164static int ael1006_power_down(struct cphy *phy, int enable) 134static int ael1006_power_down(struct cphy *phy, int enable)
165{ 135{
166 return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR, 136 return t3_mdio_change_bits(phy, MDIO_DEV_PMA_PMD, MII_BMCR,
@@ -169,10 +139,10 @@ static int ael1006_power_down(struct cphy *phy, int enable)
169 139
170static struct cphy_ops ael1006_ops = { 140static struct cphy_ops ael1006_ops = {
171 .reset = ael1006_reset, 141 .reset = ael1006_reset,
172 .intr_enable = ael1006_intr_enable, 142 .intr_enable = t3_phy_lasi_intr_enable,
173 .intr_disable = ael1006_intr_disable, 143 .intr_disable = t3_phy_lasi_intr_disable,
174 .intr_clear = ael1006_intr_clear, 144 .intr_clear = t3_phy_lasi_intr_clear,
175 .intr_handler = ael1006_intr_handler, 145 .intr_handler = t3_phy_lasi_intr_handler,
176 .get_link_status = ael100x_get_link_status, 146 .get_link_status = ael100x_get_link_status,
177 .power_down = ael1006_power_down, 147 .power_down = ael1006_power_down,
178}; 148};
@@ -189,10 +159,10 @@ int t3_ael1006_phy_prep(struct cphy *phy, struct adapter *adapter,
189 159
190static struct cphy_ops qt2045_ops = { 160static struct cphy_ops qt2045_ops = {
191 .reset = ael1006_reset, 161 .reset = ael1006_reset,
192 .intr_enable = ael1006_intr_enable, 162 .intr_enable = t3_phy_lasi_intr_enable,
193 .intr_disable = ael1006_intr_disable, 163 .intr_disable = t3_phy_lasi_intr_disable,
194 .intr_clear = ael1006_intr_clear, 164 .intr_clear = t3_phy_lasi_intr_clear,
195 .intr_handler = ael1006_intr_handler, 165 .intr_handler = t3_phy_lasi_intr_handler,
196 .get_link_status = ael100x_get_link_status, 166 .get_link_status = ael100x_get_link_status,
197 .power_down = ael1006_power_down, 167 .power_down = ael1006_power_down,
198}; 168};