aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/falcon_boards.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-23 11:03:45 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-24 13:58:39 -0500
commit398468ed1b5c61fe8bcbc8cc1ed323e3c23b58ef (patch)
tree2c9f8932143b91d8affe388bd21d98beab7c7488 /drivers/net/sfc/falcon_boards.c
parentdcf477b2d205abb8ccdb3b1cb668a0db2de202c0 (diff)
sfc: Use a single blink implementation
Only some PHYs have firmware support for a LED blink mode, so we currently blink the others in a timer function. Since all PHYs have simple on and off modes, we don't gain anything by using multiple blink implementations. Also, since we have a process context there is no need to use a timer. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/sfc/falcon_boards.c')
-rw-r--r--drivers/net/sfc/falcon_boards.c66
1 files changed, 22 insertions, 44 deletions
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index d31c134981fd..b2505fc5c1f7 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -29,40 +29,6 @@
29#define FALCON_BOARD_SFN4111T 0x51 29#define FALCON_BOARD_SFN4111T 0x51
30#define FALCON_BOARD_SFN4112F 0x52 30#define FALCON_BOARD_SFN4112F 0x52
31 31
32/* Blink support. If the PHY has no auto-blink mode so we hang it off a timer */
33#define BLINK_INTERVAL (HZ/2)
34
35static void blink_led_timer(unsigned long context)
36{
37 struct efx_nic *efx = (struct efx_nic *)context;
38 struct efx_board *board = &efx->board_info;
39
40 board->set_id_led(efx, board->blink_state);
41 board->blink_state = !board->blink_state;
42 if (board->blink_resubmit)
43 mod_timer(&board->blink_timer, jiffies + BLINK_INTERVAL);
44}
45
46static void board_blink(struct efx_nic *efx, bool blink)
47{
48 struct efx_board *board = &efx->board_info;
49
50 /* The rtnl mutex serialises all ethtool ioctls, so
51 * nothing special needs doing here. */
52 if (blink) {
53 board->blink_resubmit = true;
54 board->blink_state = false;
55 setup_timer(&board->blink_timer, blink_led_timer,
56 (unsigned long)efx);
57 mod_timer(&board->blink_timer, jiffies + BLINK_INTERVAL);
58 } else {
59 board->blink_resubmit = false;
60 if (board->blink_timer.function)
61 del_timer_sync(&board->blink_timer);
62 board->init_leds(efx);
63 }
64}
65
66/***************************************************************************** 32/*****************************************************************************
67 * Support for LM87 sensor chip used on several boards 33 * Support for LM87 sensor chip used on several boards
68 */ 34 */
@@ -469,7 +435,7 @@ static int sfe4001_init(struct efx_nic *efx)
469 435
470 /* 10Xpress has fixed-function LED pins, so there is no board-specific 436 /* 10Xpress has fixed-function LED pins, so there is no board-specific
471 * blink code. */ 437 * blink code. */
472 efx->board_info.blink = tenxpress_phy_blink; 438 efx->board_info.set_id_led = tenxpress_set_id_led;
473 439
474 efx->board_info.monitor = sfe4001_check_hw; 440 efx->board_info.monitor = sfe4001_check_hw;
475 efx->board_info.fini = sfe4001_fini; 441 efx->board_info.fini = sfe4001_fini;
@@ -546,7 +512,7 @@ static int sfn4111t_init(struct efx_nic *efx)
546 if (!efx->board_info.hwmon_client) 512 if (!efx->board_info.hwmon_client)
547 return -EIO; 513 return -EIO;
548 514
549 efx->board_info.blink = tenxpress_phy_blink; 515 efx->board_info.set_id_led = tenxpress_set_id_led;
550 efx->board_info.monitor = sfn4111t_check_hw; 516 efx->board_info.monitor = sfn4111t_check_hw;
551 efx->board_info.fini = sfn4111t_fini; 517 efx->board_info.fini = sfn4111t_fini;
552 518
@@ -619,10 +585,11 @@ static void sfe4002_init_leds(struct efx_nic *efx)
619 falcon_qt202x_set_led(efx, SFE4002_FAULT_LED, QUAKE_LED_OFF); 585 falcon_qt202x_set_led(efx, SFE4002_FAULT_LED, QUAKE_LED_OFF);
620} 586}
621 587
622static void sfe4002_set_id_led(struct efx_nic *efx, bool state) 588static void sfe4002_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
623{ 589{
624 falcon_qt202x_set_led(efx, SFE4002_FAULT_LED, state ? QUAKE_LED_ON : 590 falcon_qt202x_set_led(
625 QUAKE_LED_OFF); 591 efx, SFE4002_FAULT_LED,
592 (mode == EFX_LED_ON) ? QUAKE_LED_ON : QUAKE_LED_OFF);
626} 593}
627 594
628static int sfe4002_check_hw(struct efx_nic *efx) 595static int sfe4002_check_hw(struct efx_nic *efx)
@@ -644,7 +611,6 @@ static int sfe4002_init(struct efx_nic *efx)
644 efx->board_info.monitor = sfe4002_check_hw; 611 efx->board_info.monitor = sfe4002_check_hw;
645 efx->board_info.init_leds = sfe4002_init_leds; 612 efx->board_info.init_leds = sfe4002_init_leds;
646 efx->board_info.set_id_led = sfe4002_set_id_led; 613 efx->board_info.set_id_led = sfe4002_set_id_led;
647 efx->board_info.blink = board_blink;
648 efx->board_info.fini = efx_fini_lm87; 614 efx->board_info.fini = efx_fini_lm87;
649 return 0; 615 return 0;
650} 616}
@@ -683,10 +649,23 @@ static void sfn4112f_init_leds(struct efx_nic *efx)
683 QUAKE_LED_RXLINK | QUAKE_LED_LINK_STAT); 649 QUAKE_LED_RXLINK | QUAKE_LED_LINK_STAT);
684} 650}
685 651
686static void sfn4112f_set_id_led(struct efx_nic *efx, bool state) 652static void sfn4112f_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
687{ 653{
688 falcon_qt202x_set_led(efx, SFN4112F_LINK_LED, 654 int reg;
689 state ? QUAKE_LED_ON : QUAKE_LED_OFF); 655
656 switch (mode) {
657 case EFX_LED_OFF:
658 reg = QUAKE_LED_OFF;
659 break;
660 case EFX_LED_ON:
661 reg = QUAKE_LED_ON;
662 break;
663 default:
664 reg = QUAKE_LED_RXLINK | QUAKE_LED_LINK_STAT;
665 break;
666 }
667
668 falcon_qt202x_set_led(efx, SFN4112F_LINK_LED, reg);
690} 669}
691 670
692static int sfn4112f_check_hw(struct efx_nic *efx) 671static int sfn4112f_check_hw(struct efx_nic *efx)
@@ -703,7 +682,6 @@ static int sfn4112f_init(struct efx_nic *efx)
703 efx->board_info.monitor = sfn4112f_check_hw; 682 efx->board_info.monitor = sfn4112f_check_hw;
704 efx->board_info.init_leds = sfn4112f_init_leds; 683 efx->board_info.init_leds = sfn4112f_init_leds;
705 efx->board_info.set_id_led = sfn4112f_set_id_led; 684 efx->board_info.set_id_led = sfn4112f_set_id_led;
706 efx->board_info.blink = board_blink;
707 efx->board_info.fini = efx_fini_lm87; 685 efx->board_info.fini = efx_fini_lm87;
708 return 0; 686 return 0;
709} 687}