aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-23 11:04:23 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-24 13:58:40 -0500
commit981fc1b4b8cc6bfe8c6f0c07052e25738d959c68 (patch)
treeb55aa171ae37e4eff14b6750f61f667a213b518e
parent398468ed1b5c61fe8bcbc8cc1ed323e3c23b58ef (diff)
sfc: Rename efx_board::init_leds to init_phy and use for SFN4111T
efx_board::init_leds was introduced as a second stage of initialisation because of the inter-dependency between the board and PHY. We want to move board initialisation into NIC probing, which is too early to use MDIO, so SFN4111T initialisation also needs to be split. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/sfc/efx.c2
-rw-r--r--drivers/net/sfc/falcon_boards.c43
-rw-r--r--drivers/net/sfc/net_driver.h11
-rw-r--r--drivers/net/sfc/qt202x_phy.c2
-rw-r--r--drivers/net/sfc/tenxpress.c2
5 files changed, 33 insertions, 27 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c
index 612cd815088f..d7705a755164 100644
--- a/drivers/net/sfc/efx.c
+++ b/drivers/net/sfc/efx.c
@@ -1910,7 +1910,7 @@ static struct efx_phy_operations efx_dummy_phy_operations = {
1910 1910
1911static struct efx_board efx_dummy_board_info = { 1911static struct efx_board efx_dummy_board_info = {
1912 .init = efx_port_dummy_op_int, 1912 .init = efx_port_dummy_op_int,
1913 .init_leds = efx_port_dummy_op_void, 1913 .init_phy = efx_port_dummy_op_void,
1914 .set_id_led = efx_port_dummy_op_set_id_led, 1914 .set_id_led = efx_port_dummy_op_set_id_led,
1915 .monitor = efx_port_dummy_op_int, 1915 .monitor = efx_port_dummy_op_int,
1916 .fini = efx_port_dummy_op_void, 1916 .fini = efx_port_dummy_op_void,
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index b2505fc5c1f7..429d3cd646b5 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -499,9 +499,22 @@ static struct i2c_board_info sfn4111t_r5_hwmon_info = {
499 I2C_BOARD_INFO("max6646", 0x4d), 499 I2C_BOARD_INFO("max6646", 0x4d),
500}; 500};
501 501
502static void sfn4111t_init_phy(struct efx_nic *efx)
503{
504 if (!(efx->phy_mode & PHY_MODE_SPECIAL)) {
505 if (sft9001_wait_boot(efx) != -EINVAL)
506 return;
507
508 efx->phy_mode = PHY_MODE_SPECIAL;
509 efx_stats_disable(efx);
510 }
511
512 sfn4111t_reset(efx);
513 sft9001_wait_boot(efx);
514}
515
502static int sfn4111t_init(struct efx_nic *efx) 516static int sfn4111t_init(struct efx_nic *efx)
503{ 517{
504 int i = 0;
505 int rc; 518 int rc;
506 519
507 efx->board_info.hwmon_client = 520 efx->board_info.hwmon_client =
@@ -512,6 +525,7 @@ static int sfn4111t_init(struct efx_nic *efx)
512 if (!efx->board_info.hwmon_client) 525 if (!efx->board_info.hwmon_client)
513 return -EIO; 526 return -EIO;
514 527
528 efx->board_info.init_phy = sfn4111t_init_phy;
515 efx->board_info.set_id_led = tenxpress_set_id_led; 529 efx->board_info.set_id_led = tenxpress_set_id_led;
516 efx->board_info.monitor = sfn4111t_check_hw; 530 efx->board_info.monitor = sfn4111t_check_hw;
517 efx->board_info.fini = sfn4111t_fini; 531 efx->board_info.fini = sfn4111t_fini;
@@ -520,20 +534,13 @@ static int sfn4111t_init(struct efx_nic *efx)
520 if (rc) 534 if (rc)
521 goto fail_hwmon; 535 goto fail_hwmon;
522 536
523 do { 537 if (efx->phy_mode & PHY_MODE_SPECIAL)
524 if (efx->phy_mode & PHY_MODE_SPECIAL) { 538 /* PHY may not generate a 156.25 MHz clock and MAC
525 /* PHY may not generate a 156.25 MHz clock and MAC 539 * stats fetch will fail. */
526 * stats fetch will fail. */ 540 efx_stats_disable(efx);
527 efx_stats_disable(efx); 541
528 sfn4111t_reset(efx); 542 return 0;
529 }
530 rc = sft9001_wait_boot(efx);
531 if (rc == 0)
532 return 0;
533 efx->phy_mode = PHY_MODE_SPECIAL;
534 } while (rc == -EINVAL && ++i < 2);
535 543
536 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
537fail_hwmon: 544fail_hwmon:
538 i2c_unregister_device(efx->board_info.hwmon_client); 545 i2c_unregister_device(efx->board_info.hwmon_client);
539 return rc; 546 return rc;
@@ -574,7 +581,7 @@ static struct i2c_board_info sfe4002_hwmon_info = {
574#define SFE4002_RX_LED (0) /* Green */ 581#define SFE4002_RX_LED (0) /* Green */
575#define SFE4002_TX_LED (1) /* Amber */ 582#define SFE4002_TX_LED (1) /* Amber */
576 583
577static void sfe4002_init_leds(struct efx_nic *efx) 584static void sfe4002_init_phy(struct efx_nic *efx)
578{ 585{
579 /* Set the TX and RX LEDs to reflect status and activity, and the 586 /* Set the TX and RX LEDs to reflect status and activity, and the
580 * fault LED off */ 587 * fault LED off */
@@ -609,7 +616,7 @@ static int sfe4002_init(struct efx_nic *efx)
609 if (rc) 616 if (rc)
610 return rc; 617 return rc;
611 efx->board_info.monitor = sfe4002_check_hw; 618 efx->board_info.monitor = sfe4002_check_hw;
612 efx->board_info.init_leds = sfe4002_init_leds; 619 efx->board_info.init_phy = sfe4002_init_phy;
613 efx->board_info.set_id_led = sfe4002_set_id_led; 620 efx->board_info.set_id_led = sfe4002_set_id_led;
614 efx->board_info.fini = efx_fini_lm87; 621 efx->board_info.fini = efx_fini_lm87;
615 return 0; 622 return 0;
@@ -641,7 +648,7 @@ static struct i2c_board_info sfn4112f_hwmon_info = {
641#define SFN4112F_ACT_LED 0 648#define SFN4112F_ACT_LED 0
642#define SFN4112F_LINK_LED 1 649#define SFN4112F_LINK_LED 1
643 650
644static void sfn4112f_init_leds(struct efx_nic *efx) 651static void sfn4112f_init_phy(struct efx_nic *efx)
645{ 652{
646 falcon_qt202x_set_led(efx, SFN4112F_ACT_LED, 653 falcon_qt202x_set_led(efx, SFN4112F_ACT_LED,
647 QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACT); 654 QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACT);
@@ -680,7 +687,7 @@ static int sfn4112f_init(struct efx_nic *efx)
680 if (rc) 687 if (rc)
681 return rc; 688 return rc;
682 efx->board_info.monitor = sfn4112f_check_hw; 689 efx->board_info.monitor = sfn4112f_check_hw;
683 efx->board_info.init_leds = sfn4112f_init_leds; 690 efx->board_info.init_phy = sfn4112f_init_phy;
684 efx->board_info.set_id_led = sfn4112f_set_id_led; 691 efx->board_info.set_id_led = sfn4112f_set_id_led;
685 efx->board_info.fini = efx_fini_lm87; 692 efx->board_info.fini = efx_fini_lm87;
686 return 0; 693 return 0;
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h
index 6b05d69429ee..e1df589dff60 100644
--- a/drivers/net/sfc/net_driver.h
+++ b/drivers/net/sfc/net_driver.h
@@ -399,11 +399,11 @@ enum efx_led_mode {
399 * @type: Board model type 399 * @type: Board model type
400 * @major: Major rev. ('A', 'B' ...) 400 * @major: Major rev. ('A', 'B' ...)
401 * @minor: Minor rev. (0, 1, ...) 401 * @minor: Minor rev. (0, 1, ...)
402 * @init: Initialisation function 402 * @init: Allocate resources and initialise peripheral hardware
403 * @init_leds: Sets up board LEDs. May be called repeatedly. 403 * @init_phy: Do board-specific PHY initialisation
404 * @set_id_led: Set state of identifying LED or revert to automatic function 404 * @set_id_led: Set state of identifying LED or revert to automatic function
405 * @monitor: Board-specific health check function 405 * @monitor: Board-specific health check function
406 * @fini: Cleanup function 406 * @fini: Shut down hardware and free resources
407 * @hwmon_client: I2C client for hardware monitor 407 * @hwmon_client: I2C client for hardware monitor
408 * @ioexp_client: I2C client for power/port control 408 * @ioexp_client: I2C client for power/port control
409 */ 409 */
@@ -412,10 +412,7 @@ struct efx_board {
412 int major; 412 int major;
413 int minor; 413 int minor;
414 int (*init) (struct efx_nic *nic); 414 int (*init) (struct efx_nic *nic);
415 /* As the LEDs are typically attached to the PHY, LEDs 415 void (*init_phy) (struct efx_nic *efx);
416 * have a separate init callback that happens later than
417 * board init. */
418 void (*init_leds)(struct efx_nic *efx);
419 void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); 416 void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
420 int (*monitor) (struct efx_nic *nic); 417 int (*monitor) (struct efx_nic *nic);
421 void (*fini) (struct efx_nic *nic); 418 void (*fini) (struct efx_nic *nic);
diff --git a/drivers/net/sfc/qt202x_phy.c b/drivers/net/sfc/qt202x_phy.c
index 05c0f9acedbd..f26684fc8caf 100644
--- a/drivers/net/sfc/qt202x_phy.c
+++ b/drivers/net/sfc/qt202x_phy.c
@@ -126,7 +126,7 @@ static int qt202x_reset_phy(struct efx_nic *efx)
126 if (rc < 0) 126 if (rc < 0)
127 goto fail; 127 goto fail;
128 128
129 efx->board_info.init_leds(efx); 129 efx->board_info.init_phy(efx);
130 130
131 return rc; 131 return rc;
132 132
diff --git a/drivers/net/sfc/tenxpress.c b/drivers/net/sfc/tenxpress.c
index 6a8e3ea03811..2923e3d1e027 100644
--- a/drivers/net/sfc/tenxpress.c
+++ b/drivers/net/sfc/tenxpress.c
@@ -303,6 +303,8 @@ static int tenxpress_phy_init(struct efx_nic *efx)
303 u16 old_adv, adv; 303 u16 old_adv, adv;
304 int rc = 0; 304 int rc = 0;
305 305
306 efx->board_info.init_phy(efx);
307
306 phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL); 308 phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
307 if (!phy_data) 309 if (!phy_data)
308 return -ENOMEM; 310 return -ENOMEM;