aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/sfe4001.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sfc/sfe4001.c')
-rw-r--r--drivers/net/sfc/sfe4001.c42
1 files changed, 33 insertions, 9 deletions
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c
index 16b80acb9992..cb25ae5b257a 100644
--- a/drivers/net/sfc/sfe4001.c
+++ b/drivers/net/sfc/sfe4001.c
@@ -186,19 +186,22 @@ static int sfn4111t_reset(struct efx_nic *efx)
186{ 186{
187 efx_oword_t reg; 187 efx_oword_t reg;
188 188
189 /* GPIO pins are also used for I2C, so block that temporarily */ 189 /* GPIO 3 and the GPIO register are shared with I2C, so block that */
190 mutex_lock(&efx->i2c_adap.bus_lock); 190 mutex_lock(&efx->i2c_adap.bus_lock);
191 191
192 /* Pull RST_N (GPIO 2) low then let it up again, setting the
193 * FLASH_CFG_1 strap (GPIO 3) appropriately. Only change the
194 * output enables; the output levels should always be 0 (low)
195 * and we rely on external pull-ups. */
192 falcon_read(efx, &reg, GPIO_CTL_REG_KER); 196 falcon_read(efx, &reg, GPIO_CTL_REG_KER);
193 EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, true); 197 EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, true);
194 EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, false);
195 falcon_write(efx, &reg, GPIO_CTL_REG_KER); 198 falcon_write(efx, &reg, GPIO_CTL_REG_KER);
196 msleep(1000); 199 msleep(1000);
197 EFX_SET_OWORD_FIELD(reg, GPIO2_OUT, true); 200 EFX_SET_OWORD_FIELD(reg, GPIO2_OEN, false);
198 EFX_SET_OWORD_FIELD(reg, GPIO3_OEN, true); 201 EFX_SET_OWORD_FIELD(reg, GPIO3_OEN,
199 EFX_SET_OWORD_FIELD(reg, GPIO3_OUT, 202 !!(efx->phy_mode & PHY_MODE_SPECIAL));
200 !(efx->phy_mode & PHY_MODE_SPECIAL));
201 falcon_write(efx, &reg, GPIO_CTL_REG_KER); 203 falcon_write(efx, &reg, GPIO_CTL_REG_KER);
204 msleep(1);
202 205
203 mutex_unlock(&efx->i2c_adap.bus_lock); 206 mutex_unlock(&efx->i2c_adap.bus_lock);
204 207
@@ -232,12 +235,18 @@ static ssize_t set_phy_flash_cfg(struct device *dev,
232 } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) { 235 } else if (efx->state != STATE_RUNNING || netif_running(efx->net_dev)) {
233 err = -EBUSY; 236 err = -EBUSY;
234 } else { 237 } else {
238 /* Reset the PHY, reconfigure the MAC and enable/disable
239 * MAC stats accordingly. */
235 efx->phy_mode = new_mode; 240 efx->phy_mode = new_mode;
241 if (new_mode & PHY_MODE_SPECIAL)
242 efx_stats_disable(efx);
236 if (efx->board_info.type == EFX_BOARD_SFE4001) 243 if (efx->board_info.type == EFX_BOARD_SFE4001)
237 err = sfe4001_poweron(efx); 244 err = sfe4001_poweron(efx);
238 else 245 else
239 err = sfn4111t_reset(efx); 246 err = sfn4111t_reset(efx);
240 efx_reconfigure_port(efx); 247 efx_reconfigure_port(efx);
248 if (!(new_mode & PHY_MODE_SPECIAL))
249 efx_stats_enable(efx);
241 } 250 }
242 rtnl_unlock(); 251 rtnl_unlock();
243 252
@@ -326,6 +335,11 @@ int sfe4001_init(struct efx_nic *efx)
326 efx->board_info.monitor = sfe4001_check_hw; 335 efx->board_info.monitor = sfe4001_check_hw;
327 efx->board_info.fini = sfe4001_fini; 336 efx->board_info.fini = sfe4001_fini;
328 337
338 if (efx->phy_mode & PHY_MODE_SPECIAL) {
339 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch
340 * will fail. */
341 efx_stats_disable(efx);
342 }
329 rc = sfe4001_poweron(efx); 343 rc = sfe4001_poweron(efx);
330 if (rc) 344 if (rc)
331 goto fail_ioexp; 345 goto fail_ioexp;
@@ -372,17 +386,25 @@ static void sfn4111t_fini(struct efx_nic *efx)
372 i2c_unregister_device(efx->board_info.hwmon_client); 386 i2c_unregister_device(efx->board_info.hwmon_client);
373} 387}
374 388
375static struct i2c_board_info sfn4111t_hwmon_info = { 389static struct i2c_board_info sfn4111t_a0_hwmon_info = {
376 I2C_BOARD_INFO("max6647", 0x4e), 390 I2C_BOARD_INFO("max6647", 0x4e),
377 .irq = -1, 391 .irq = -1,
378}; 392};
379 393
394static struct i2c_board_info sfn4111t_r5_hwmon_info = {
395 I2C_BOARD_INFO("max6646", 0x4d),
396 .irq = -1,
397};
398
380int sfn4111t_init(struct efx_nic *efx) 399int sfn4111t_init(struct efx_nic *efx)
381{ 400{
382 int rc; 401 int rc;
383 402
384 efx->board_info.hwmon_client = 403 efx->board_info.hwmon_client =
385 i2c_new_device(&efx->i2c_adap, &sfn4111t_hwmon_info); 404 i2c_new_device(&efx->i2c_adap,
405 (efx->board_info.minor < 5) ?
406 &sfn4111t_a0_hwmon_info :
407 &sfn4111t_r5_hwmon_info);
386 if (!efx->board_info.hwmon_client) 408 if (!efx->board_info.hwmon_client)
387 return -EIO; 409 return -EIO;
388 410
@@ -394,8 +416,10 @@ int sfn4111t_init(struct efx_nic *efx)
394 if (rc) 416 if (rc)
395 goto fail_hwmon; 417 goto fail_hwmon;
396 418
397 if (efx->phy_mode & PHY_MODE_SPECIAL) 419 if (efx->phy_mode & PHY_MODE_SPECIAL) {
420 efx_stats_disable(efx);
398 sfn4111t_reset(efx); 421 sfn4111t_reset(efx);
422 }
399 423
400 return 0; 424 return 0;
401 425