aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/xfp_phy.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-04-29 04:05:08 -0400
committerDavid S. Miller <davem@davemloft.net>2009-04-29 20:32:30 -0400
commit68e7f45e118f98b77cfa007aa2d97b5dac69fe6b (patch)
treed2e05579a0fc1f5a28bce8ff09ac6863d1907186 /drivers/net/sfc/xfp_phy.c
parent1b1c2e95103ce391c2ea39a9460968fcb73deb30 (diff)
sfc: Use generic MDIO functions and definitions
Make use of the newly-added generic MDIO clause 45 support and remove redundant definitions. Add an 'efx_' prefix to the remaining driver-specific MDIO functions and remove arguments which are redundant with efx->mdio.prtad. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/xfp_phy.c')
-rw-r--r--drivers/net/sfc/xfp_phy.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/drivers/net/sfc/xfp_phy.c b/drivers/net/sfc/xfp_phy.c
index bb1ef77d5f56..aad2dca19772 100644
--- a/drivers/net/sfc/xfp_phy.c
+++ b/drivers/net/sfc/xfp_phy.c
@@ -19,9 +19,9 @@
19#include "phy.h" 19#include "phy.h"
20#include "falcon.h" 20#include "falcon.h"
21 21
22#define XFP_REQUIRED_DEVS (MDIO_MMDREG_DEVS_PCS | \ 22#define XFP_REQUIRED_DEVS (MDIO_DEVS_PCS | \
23 MDIO_MMDREG_DEVS_PMAPMD | \ 23 MDIO_DEVS_PMAPMD | \
24 MDIO_MMDREG_DEVS_PHYXS) 24 MDIO_DEVS_PHYXS)
25 25
26#define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \ 26#define XFP_LOOPBACKS ((1 << LOOPBACK_PCS) | \
27 (1 << LOOPBACK_PMAPMD) | \ 27 (1 << LOOPBACK_PMAPMD) | \
@@ -49,8 +49,7 @@
49void xfp_set_led(struct efx_nic *p, int led, int mode) 49void xfp_set_led(struct efx_nic *p, int led, int mode)
50{ 50{
51 int addr = MDIO_QUAKE_LED0_REG + led; 51 int addr = MDIO_QUAKE_LED0_REG + led;
52 mdio_clause45_write(p, p->mii.phy_id, MDIO_MMD_PMAPMD, addr, 52 efx_mdio_write(p, MDIO_MMD_PMAPMD, addr, mode);
53 mode);
54} 53}
55 54
56struct xfp_phy_data { 55struct xfp_phy_data {
@@ -63,14 +62,12 @@ struct xfp_phy_data {
63static int qt2025c_wait_reset(struct efx_nic *efx) 62static int qt2025c_wait_reset(struct efx_nic *efx)
64{ 63{
65 unsigned long timeout = jiffies + 10 * HZ; 64 unsigned long timeout = jiffies + 10 * HZ;
66 int phy_id = efx->mii.phy_id;
67 int reg, old_counter = 0; 65 int reg, old_counter = 0;
68 66
69 /* Wait for firmware heartbeat to start */ 67 /* Wait for firmware heartbeat to start */
70 for (;;) { 68 for (;;) {
71 int counter; 69 int counter;
72 reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS, 70 reg = efx_mdio_read(efx, MDIO_MMD_PCS, PCS_FW_HEARTBEAT_REG);
73 PCS_FW_HEARTBEAT_REG);
74 if (reg < 0) 71 if (reg < 0)
75 return reg; 72 return reg;
76 counter = ((reg >> PCS_FW_HEARTB_LBN) & 73 counter = ((reg >> PCS_FW_HEARTB_LBN) &
@@ -86,8 +83,7 @@ static int qt2025c_wait_reset(struct efx_nic *efx)
86 83
87 /* Wait for firmware status to look good */ 84 /* Wait for firmware status to look good */
88 for (;;) { 85 for (;;) {
89 reg = mdio_clause45_read(efx, phy_id, MDIO_MMD_PCS, 86 reg = efx_mdio_read(efx, MDIO_MMD_PCS, PCS_UC8051_STATUS_REG);
90 PCS_UC8051_STATUS_REG);
91 if (reg < 0) 87 if (reg < 0)
92 return reg; 88 return reg;
93 if ((reg & 89 if ((reg &
@@ -109,9 +105,9 @@ static int xfp_reset_phy(struct efx_nic *efx)
109{ 105{
110 int rc; 106 int rc;
111 107
112 rc = mdio_clause45_reset_mmd(efx, MDIO_MMD_PHYXS, 108 rc = efx_mdio_reset_mmd(efx, MDIO_MMD_PHYXS,
113 XFP_MAX_RESET_TIME / XFP_RESET_WAIT, 109 XFP_MAX_RESET_TIME / XFP_RESET_WAIT,
114 XFP_RESET_WAIT); 110 XFP_RESET_WAIT);
115 if (rc < 0) 111 if (rc < 0)
116 goto fail; 112 goto fail;
117 113
@@ -126,8 +122,7 @@ static int xfp_reset_phy(struct efx_nic *efx)
126 122
127 /* Check that all the MMDs we expect are present and responding. We 123 /* Check that all the MMDs we expect are present and responding. We
128 * expect faults on some if the link is down, but not on the PHY XS */ 124 * expect faults on some if the link is down, but not on the PHY XS */
129 rc = mdio_clause45_check_mmds(efx, XFP_REQUIRED_DEVS, 125 rc = efx_mdio_check_mmds(efx, XFP_REQUIRED_DEVS, MDIO_DEVS_PHYXS);
130 MDIO_MMDREG_DEVS_PHYXS);
131 if (rc < 0) 126 if (rc < 0)
132 goto fail; 127 goto fail;
133 128
@@ -143,7 +138,7 @@ static int xfp_reset_phy(struct efx_nic *efx)
143static int xfp_phy_init(struct efx_nic *efx) 138static int xfp_phy_init(struct efx_nic *efx)
144{ 139{
145 struct xfp_phy_data *phy_data; 140 struct xfp_phy_data *phy_data;
146 u32 devid = mdio_clause45_read_id(efx, MDIO_MMD_PHYXS); 141 u32 devid = efx_mdio_read_id(efx, MDIO_MMD_PHYXS);
147 int rc; 142 int rc;
148 143
149 phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL); 144 phy_data = kzalloc(sizeof(struct xfp_phy_data), GFP_KERNEL);
@@ -152,8 +147,8 @@ static int xfp_phy_init(struct efx_nic *efx)
152 efx->phy_data = phy_data; 147 efx->phy_data = phy_data;
153 148
154 EFX_INFO(efx, "PHY ID reg %x (OUI %06x model %02x revision %x)\n", 149 EFX_INFO(efx, "PHY ID reg %x (OUI %06x model %02x revision %x)\n",
155 devid, mdio_id_oui(devid), mdio_id_model(devid), 150 devid, efx_mdio_id_oui(devid), efx_mdio_id_model(devid),
156 mdio_id_rev(devid)); 151 efx_mdio_id_rev(devid));
157 152
158 phy_data->phy_mode = efx->phy_mode; 153 phy_data->phy_mode = efx->phy_mode;
159 154
@@ -179,7 +174,7 @@ static void xfp_phy_clear_interrupt(struct efx_nic *efx)
179 174
180static int xfp_link_ok(struct efx_nic *efx) 175static int xfp_link_ok(struct efx_nic *efx)
181{ 176{
182 return mdio_clause45_links_ok(efx, XFP_REQUIRED_DEVS); 177 return efx_mdio_links_ok(efx, XFP_REQUIRED_DEVS);
183} 178}
184 179
185static void xfp_phy_poll(struct efx_nic *efx) 180static void xfp_phy_poll(struct efx_nic *efx)
@@ -200,9 +195,9 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
200 * or optical transceivers, varying somewhat between 195 * or optical transceivers, varying somewhat between
201 * firmware versions. Only 'static mode' appears to 196 * firmware versions. Only 'static mode' appears to
202 * cover everything. */ 197 * cover everything. */
203 mdio_clause45_set_flag( 198 mdio_set_flag(
204 efx, efx->mii.phy_id, MDIO_MMD_PMAPMD, 199 &efx->mdio, efx->mdio.prtad, MDIO_MMD_PMAPMD,
205 PMA_PMD_FTX_CTRL2_REG, PMA_PMD_FTX_STATIC_LBN, 200 PMA_PMD_FTX_CTRL2_REG, 1 << PMA_PMD_FTX_STATIC_LBN,
206 efx->phy_mode & PHY_MODE_TX_DISABLED || 201 efx->phy_mode & PHY_MODE_TX_DISABLED ||
207 efx->phy_mode & PHY_MODE_LOW_POWER || 202 efx->phy_mode & PHY_MODE_LOW_POWER ||
208 efx->loopback_mode == LOOPBACK_PCS || 203 efx->loopback_mode == LOOPBACK_PCS ||
@@ -213,10 +208,10 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
213 (phy_data->phy_mode & PHY_MODE_TX_DISABLED)) 208 (phy_data->phy_mode & PHY_MODE_TX_DISABLED))
214 xfp_reset_phy(efx); 209 xfp_reset_phy(efx);
215 210
216 mdio_clause45_transmit_disable(efx); 211 efx_mdio_transmit_disable(efx);
217 } 212 }
218 213
219 mdio_clause45_phy_reconfigure(efx); 214 efx_mdio_phy_reconfigure(efx);
220 215
221 phy_data->phy_mode = efx->phy_mode; 216 phy_data->phy_mode = efx->phy_mode;
222 efx->link_up = xfp_link_ok(efx); 217 efx->link_up = xfp_link_ok(efx);
@@ -225,6 +220,10 @@ static void xfp_phy_reconfigure(struct efx_nic *efx)
225 efx->link_fc = efx->wanted_fc; 220 efx->link_fc = efx->wanted_fc;
226} 221}
227 222
223static void xfp_phy_get_settings(struct efx_nic *efx, struct ethtool_cmd *ecmd)
224{
225 mdio45_ethtool_gset(&efx->mdio, ecmd);
226}
228 227
229static void xfp_phy_fini(struct efx_nic *efx) 228static void xfp_phy_fini(struct efx_nic *efx)
230{ 229{
@@ -243,8 +242,8 @@ struct efx_phy_operations falcon_xfp_phy_ops = {
243 .poll = xfp_phy_poll, 242 .poll = xfp_phy_poll,
244 .fini = xfp_phy_fini, 243 .fini = xfp_phy_fini,
245 .clear_interrupt = xfp_phy_clear_interrupt, 244 .clear_interrupt = xfp_phy_clear_interrupt,
246 .get_settings = mdio_clause45_get_settings, 245 .get_settings = xfp_phy_get_settings,
247 .set_settings = mdio_clause45_set_settings, 246 .set_settings = efx_mdio_set_settings,
248 .mmds = XFP_REQUIRED_DEVS, 247 .mmds = XFP_REQUIRED_DEVS,
249 .loopbacks = XFP_LOOPBACKS, 248 .loopbacks = XFP_LOOPBACKS,
250}; 249};