diff options
| author | Ben Hutchings <bhutchings@solarflare.com> | 2009-02-27 08:06:45 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2009-03-02 06:15:03 -0500 |
| commit | 190dbcfd6806c7c88fc028acda95731ffd43979d (patch) | |
| tree | 3ad2f2bd43ab71c45dd051d5c52c476871dd5b87 /drivers/net | |
| parent | 7b065f91faf56f5445ba45878ce6c55ea6388bb3 (diff) | |
sfc: SFT9001/SFN4111T: Check PHY boot status during board initialisation
During SFN4111T initialisation, check whether the PHY boot status
indicates a bad firmware checksum. If so, prepare to reflash rather
than continuing with normal initialisation.
Remove redundant PHY boot status check from tenxpress_phy_init().
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
| -rw-r--r-- | drivers/net/sfc/phy.h | 4 | ||||
| -rw-r--r-- | drivers/net/sfc/sfe4001.c | 20 | ||||
| -rw-r--r-- | drivers/net/sfc/tenxpress.c | 88 |
3 files changed, 72 insertions, 40 deletions
diff --git a/drivers/net/sfc/phy.h b/drivers/net/sfc/phy.h index 07e855c148bc..f6e47227d245 100644 --- a/drivers/net/sfc/phy.h +++ b/drivers/net/sfc/phy.h | |||
| @@ -18,6 +18,10 @@ extern struct efx_phy_operations falcon_sft9001_phy_ops; | |||
| 18 | 18 | ||
| 19 | extern void tenxpress_phy_blink(struct efx_nic *efx, bool blink); | 19 | extern void tenxpress_phy_blink(struct efx_nic *efx, bool blink); |
| 20 | 20 | ||
| 21 | /* Wait for the PHY to boot. Return 0 on success, -EINVAL if the PHY failed | ||
| 22 | * to boot due to corrupt flash, or some other negative error code. */ | ||
| 23 | extern int sft9001_wait_boot(struct efx_nic *efx); | ||
| 24 | |||
| 21 | /**************************************************************************** | 25 | /**************************************************************************** |
| 22 | * Exported functions from the driver for XFP optical PHYs | 26 | * Exported functions from the driver for XFP optical PHYs |
| 23 | */ | 27 | */ |
diff --git a/drivers/net/sfc/sfe4001.c b/drivers/net/sfc/sfe4001.c index c0e906831623..4eac5da81e5a 100644 --- a/drivers/net/sfc/sfe4001.c +++ b/drivers/net/sfc/sfe4001.c | |||
| @@ -399,6 +399,7 @@ static struct i2c_board_info sfn4111t_r5_hwmon_info = { | |||
| 399 | 399 | ||
| 400 | int sfn4111t_init(struct efx_nic *efx) | 400 | int sfn4111t_init(struct efx_nic *efx) |
| 401 | { | 401 | { |
| 402 | int i = 0; | ||
| 402 | int rc; | 403 | int rc; |
| 403 | 404 | ||
| 404 | efx->board_info.hwmon_client = | 405 | efx->board_info.hwmon_client = |
| @@ -417,13 +418,20 @@ int sfn4111t_init(struct efx_nic *efx) | |||
| 417 | if (rc) | 418 | if (rc) |
| 418 | goto fail_hwmon; | 419 | goto fail_hwmon; |
| 419 | 420 | ||
| 420 | if (efx->phy_mode & PHY_MODE_SPECIAL) { | 421 | do { |
| 421 | efx_stats_disable(efx); | 422 | if (efx->phy_mode & PHY_MODE_SPECIAL) { |
| 422 | sfn4111t_reset(efx); | 423 | /* PHY may not generate a 156.25 MHz clock and MAC |
| 423 | } | 424 | * stats fetch will fail. */ |
| 424 | 425 | efx_stats_disable(efx); | |
| 425 | return 0; | 426 | sfn4111t_reset(efx); |
| 427 | } | ||
| 428 | rc = sft9001_wait_boot(efx); | ||
| 429 | if (rc == 0) | ||
| 430 | return 0; | ||
| 431 | efx->phy_mode = PHY_MODE_SPECIAL; | ||
| 432 | } while (rc == -EINVAL && ++i < 2); | ||
| 426 | 433 | ||
| 434 | device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); | ||
| 427 | fail_hwmon: | 435 | fail_hwmon: |
| 428 | i2c_unregister_device(efx->board_info.hwmon_client); | 436 | i2c_unregister_device(efx->board_info.hwmon_client); |
| 429 | return rc; | 437 | return rc; |
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c index 23583ba2e7eb..e61dc4d4741c 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c | |||
| @@ -158,14 +158,16 @@ | |||
| 158 | #define PCS_10GBASET_BLKLK_WIDTH 1 | 158 | #define PCS_10GBASET_BLKLK_WIDTH 1 |
| 159 | 159 | ||
| 160 | /* Boot status register */ | 160 | /* Boot status register */ |
| 161 | #define PCS_BOOT_STATUS_REG 53248 | 161 | #define PCS_BOOT_STATUS_REG 53248 |
| 162 | #define PCS_BOOT_FATAL_ERR_LBN (0) | 162 | #define PCS_BOOT_FATAL_ERROR_LBN 0 |
| 163 | #define PCS_BOOT_PROGRESS_LBN (1) | 163 | #define PCS_BOOT_PROGRESS_LBN 1 |
| 164 | #define PCS_BOOT_PROGRESS_WIDTH (2) | 164 | #define PCS_BOOT_PROGRESS_WIDTH 2 |
| 165 | #define PCS_BOOT_COMPLETE_LBN (3) | 165 | #define PCS_BOOT_PROGRESS_INIT 0 |
| 166 | 166 | #define PCS_BOOT_PROGRESS_WAIT_MDIO 1 | |
| 167 | #define PCS_BOOT_MAX_DELAY (100) | 167 | #define PCS_BOOT_PROGRESS_CHECKSUM 2 |
| 168 | #define PCS_BOOT_POLL_DELAY (10) | 168 | #define PCS_BOOT_PROGRESS_JUMP 3 |
| 169 | #define PCS_BOOT_DOWNLOAD_WAIT_LBN 3 | ||
| 170 | #define PCS_BOOT_CODE_STARTED_LBN 4 | ||
| 169 | 171 | ||
| 170 | /* 100M/1G PHY registers */ | 172 | /* 100M/1G PHY registers */ |
| 171 | #define GPHY_XCONTROL_REG 49152 | 173 | #define GPHY_XCONTROL_REG 49152 |
| @@ -230,40 +232,62 @@ static ssize_t set_phy_short_reach(struct device *dev, | |||
| 230 | static DEVICE_ATTR(phy_short_reach, 0644, show_phy_short_reach, | 232 | static DEVICE_ATTR(phy_short_reach, 0644, show_phy_short_reach, |
| 231 | set_phy_short_reach); | 233 | set_phy_short_reach); |
| 232 | 234 | ||
| 233 | /* Check that the C166 has booted successfully */ | 235 | int sft9001_wait_boot(struct efx_nic *efx) |
| 234 | static int tenxpress_phy_check(struct efx_nic *efx) | ||
| 235 | { | 236 | { |
| 236 | int phy_id = efx->mii.phy_id; | 237 | unsigned long timeout = jiffies + HZ + 1; |
| 237 | int count = PCS_BOOT_MAX_DELAY / PCS_BOOT_POLL_DELAY; | ||
| 238 | int boot_stat; | 238 | int boot_stat; |
| 239 | 239 | ||
| 240 | /* Wait for the boot to complete (or not) */ | 240 | for (;;) { |
| 241 | while (count) { | 241 | boot_stat = mdio_clause45_read(efx, efx->mii.phy_id, |
| 242 | boot_stat = mdio_clause45_read(efx, phy_id, | ||
| 243 | MDIO_MMD_PCS, | 242 | MDIO_MMD_PCS, |
| 244 | PCS_BOOT_STATUS_REG); | 243 | PCS_BOOT_STATUS_REG); |
| 245 | if (boot_stat & (1 << PCS_BOOT_COMPLETE_LBN)) | 244 | if (boot_stat >= 0) { |
| 246 | break; | 245 | EFX_LOG(efx, "PHY boot status = %#x\n", boot_stat); |
| 247 | count--; | 246 | switch (boot_stat & |
| 248 | udelay(PCS_BOOT_POLL_DELAY); | 247 | ((1 << PCS_BOOT_FATAL_ERROR_LBN) | |
| 249 | } | 248 | (3 << PCS_BOOT_PROGRESS_LBN) | |
| 249 | (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN) | | ||
| 250 | (1 << PCS_BOOT_CODE_STARTED_LBN))) { | ||
| 251 | case ((1 << PCS_BOOT_FATAL_ERROR_LBN) | | ||
| 252 | (PCS_BOOT_PROGRESS_CHECKSUM << | ||
| 253 | PCS_BOOT_PROGRESS_LBN)): | ||
| 254 | case ((1 << PCS_BOOT_FATAL_ERROR_LBN) | | ||
| 255 | (PCS_BOOT_PROGRESS_INIT << | ||
| 256 | PCS_BOOT_PROGRESS_LBN) | | ||
| 257 | (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN)): | ||
| 258 | return -EINVAL; | ||
| 259 | case ((PCS_BOOT_PROGRESS_WAIT_MDIO << | ||
| 260 | PCS_BOOT_PROGRESS_LBN) | | ||
| 261 | (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN)): | ||
| 262 | return (efx->phy_mode & PHY_MODE_SPECIAL) ? | ||
| 263 | 0 : -EIO; | ||
| 264 | case ((PCS_BOOT_PROGRESS_JUMP << | ||
| 265 | PCS_BOOT_PROGRESS_LBN) | | ||
| 266 | (1 << PCS_BOOT_CODE_STARTED_LBN)): | ||
| 267 | case ((PCS_BOOT_PROGRESS_JUMP << | ||
| 268 | PCS_BOOT_PROGRESS_LBN) | | ||
| 269 | (1 << PCS_BOOT_DOWNLOAD_WAIT_LBN) | | ||
| 270 | (1 << PCS_BOOT_CODE_STARTED_LBN)): | ||
| 271 | return (efx->phy_mode & PHY_MODE_SPECIAL) ? | ||
| 272 | -EIO : 0; | ||
| 273 | default: | ||
| 274 | if (boot_stat & (1 << PCS_BOOT_FATAL_ERROR_LBN)) | ||
| 275 | return -EIO; | ||
| 276 | break; | ||
| 277 | } | ||
| 278 | } | ||
| 250 | 279 | ||
| 251 | if (!count) { | 280 | if (time_after_eq(jiffies, timeout)) |
| 252 | EFX_ERR(efx, "%s: PHY boot timed out. Last status " | 281 | return -ETIMEDOUT; |
| 253 | "%x\n", __func__, | ||
| 254 | (boot_stat >> PCS_BOOT_PROGRESS_LBN) & | ||
| 255 | ((1 << PCS_BOOT_PROGRESS_WIDTH) - 1)); | ||
| 256 | return -ETIMEDOUT; | ||
| 257 | } | ||
| 258 | 282 | ||
| 259 | return 0; | 283 | msleep(50); |
| 284 | } | ||
| 260 | } | 285 | } |
| 261 | 286 | ||
| 262 | static int tenxpress_init(struct efx_nic *efx) | 287 | static int tenxpress_init(struct efx_nic *efx) |
| 263 | { | 288 | { |
| 264 | int phy_id = efx->mii.phy_id; | 289 | int phy_id = efx->mii.phy_id; |
| 265 | int reg; | 290 | int reg; |
| 266 | int rc; | ||
| 267 | 291 | ||
| 268 | if (efx->phy_type == PHY_TYPE_SFX7101) { | 292 | if (efx->phy_type == PHY_TYPE_SFX7101) { |
| 269 | /* Enable 312.5 MHz clock */ | 293 | /* Enable 312.5 MHz clock */ |
| @@ -286,10 +310,6 @@ static int tenxpress_init(struct efx_nic *efx) | |||
| 286 | false); | 310 | false); |
| 287 | } | 311 | } |
| 288 | 312 | ||
| 289 | rc = tenxpress_phy_check(efx); | ||
| 290 | if (rc < 0) | ||
| 291 | return rc; | ||
| 292 | |||
| 293 | /* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */ | 313 | /* Set the LEDs up as: Green = Link, Amber = Link/Act, Red = Off */ |
| 294 | if (efx->phy_type == PHY_TYPE_SFX7101) { | 314 | if (efx->phy_type == PHY_TYPE_SFX7101) { |
| 295 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PMAPMD, | 315 | mdio_clause45_set_flag(efx, phy_id, MDIO_MMD_PMAPMD, |
| @@ -300,7 +320,7 @@ static int tenxpress_init(struct efx_nic *efx) | |||
| 300 | PMA_PMD_LED_OVERR_REG, PMA_PMD_LED_DEFAULT); | 320 | PMA_PMD_LED_OVERR_REG, PMA_PMD_LED_DEFAULT); |
| 301 | } | 321 | } |
| 302 | 322 | ||
| 303 | return rc; | 323 | return 0; |
| 304 | } | 324 | } |
| 305 | 325 | ||
| 306 | static int tenxpress_phy_init(struct efx_nic *efx) | 326 | static int tenxpress_phy_init(struct efx_nic *efx) |
