aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/falcon_boards.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-25 11:09:41 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-26 18:59:16 -0500
commit44838a447de3b1541cbf845853c4f8999310b0dd (patch)
tree53d5f1b0a6ad773764c7f97eb1d48619e781a67f /drivers/net/sfc/falcon_boards.c
parent734a350a6ccee59647f064fd49cd6cebc5dda48b (diff)
sfc: Clean up struct falcon_board and struct falcon_board_data
Put all static information in struct falcon_board_type and replace it with a pointer in struct falcon_board. Simplify probing aocordingly. 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.c115
1 files changed, 54 insertions, 61 deletions
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index f05c9d330a46..ac1258ea677c 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -348,7 +348,7 @@ static ssize_t set_phy_flash_cfg(struct device *dev,
348 efx->phy_mode = new_mode; 348 efx->phy_mode = new_mode;
349 if (new_mode & PHY_MODE_SPECIAL) 349 if (new_mode & PHY_MODE_SPECIAL)
350 efx_stats_disable(efx); 350 efx_stats_disable(efx);
351 if (falcon_board(efx)->type == FALCON_BOARD_SFE4001) 351 if (falcon_board(efx)->type->id == FALCON_BOARD_SFE4001)
352 err = sfe4001_poweron(efx); 352 err = sfe4001_poweron(efx);
353 else 353 else
354 err = sfn4111t_reset(efx); 354 err = sfn4111t_reset(efx);
@@ -438,13 +438,6 @@ static int sfe4001_init(struct efx_nic *efx)
438 goto fail_hwmon; 438 goto fail_hwmon;
439 } 439 }
440 440
441 /* 10Xpress has fixed-function LED pins, so there is no board-specific
442 * blink code. */
443 board->set_id_led = tenxpress_set_id_led;
444
445 board->monitor = sfe4001_check_hw;
446 board->fini = sfe4001_fini;
447
448 if (efx->phy_mode & PHY_MODE_SPECIAL) { 441 if (efx->phy_mode & PHY_MODE_SPECIAL) {
449 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch 442 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch
450 * will fail. */ 443 * will fail. */
@@ -531,11 +524,6 @@ static int sfn4111t_init(struct efx_nic *efx)
531 if (!board->hwmon_client) 524 if (!board->hwmon_client)
532 return -EIO; 525 return -EIO;
533 526
534 board->init_phy = sfn4111t_init_phy;
535 board->set_id_led = tenxpress_set_id_led;
536 board->monitor = sfn4111t_check_hw;
537 board->fini = sfn4111t_fini;
538
539 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); 527 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
540 if (rc) 528 if (rc)
541 goto fail_hwmon; 529 goto fail_hwmon;
@@ -620,15 +608,7 @@ static int sfe4002_check_hw(struct efx_nic *efx)
620 608
621static int sfe4002_init(struct efx_nic *efx) 609static int sfe4002_init(struct efx_nic *efx)
622{ 610{
623 struct falcon_board *board = falcon_board(efx); 611 return efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs);
624 int rc = efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs);
625 if (rc)
626 return rc;
627 board->monitor = sfe4002_check_hw;
628 board->init_phy = sfe4002_init_phy;
629 board->set_id_led = sfe4002_set_id_led;
630 board->fini = efx_fini_lm87;
631 return 0;
632} 612}
633 613
634/***************************************************************************** 614/*****************************************************************************
@@ -692,67 +672,80 @@ static int sfn4112f_check_hw(struct efx_nic *efx)
692 672
693static int sfn4112f_init(struct efx_nic *efx) 673static int sfn4112f_init(struct efx_nic *efx)
694{ 674{
695 struct falcon_board *board = falcon_board(efx); 675 return efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs);
696
697 int rc = efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs);
698 if (rc)
699 return rc;
700 board->monitor = sfn4112f_check_hw;
701 board->init_phy = sfn4112f_init_phy;
702 board->set_id_led = sfn4112f_set_id_led;
703 board->fini = efx_fini_lm87;
704 return 0;
705} 676}
706 677
707/* This will get expanded as board-specific details get moved out of the 678static const struct falcon_board_type board_types[] = {
708 * PHY drivers. */ 679 {
709struct falcon_board_data { 680 .id = FALCON_BOARD_SFE4001,
710 u8 type; 681 .ref_model = "SFE4001",
711 const char *ref_model; 682 .gen_type = "10GBASE-T adapter",
712 const char *gen_type; 683 .init = sfe4001_init,
713 int (*init) (struct efx_nic *nic); 684 .init_phy = efx_port_dummy_op_void,
714}; 685 .fini = sfe4001_fini,
715 686 .set_id_led = tenxpress_set_id_led,
716 687 .monitor = sfe4001_check_hw,
717static struct falcon_board_data board_data[] = { 688 },
718 { FALCON_BOARD_SFE4001, "SFE4001", "10GBASE-T adapter", sfe4001_init }, 689 {
719 { FALCON_BOARD_SFE4002, "SFE4002", "XFP adapter", sfe4002_init }, 690 .id = FALCON_BOARD_SFE4002,
720 { FALCON_BOARD_SFN4111T, "SFN4111T", "100/1000/10GBASE-T adapter", 691 .ref_model = "SFE4002",
721 sfn4111t_init }, 692 .gen_type = "XFP adapter",
722 { FALCON_BOARD_SFN4112F, "SFN4112F", "SFP+ adapter", 693 .init = sfe4002_init,
723 sfn4112f_init }, 694 .init_phy = sfe4002_init_phy,
695 .fini = efx_fini_lm87,
696 .set_id_led = sfe4002_set_id_led,
697 .monitor = sfe4002_check_hw,
698 },
699 {
700 .id = FALCON_BOARD_SFN4111T,
701 .ref_model = "SFN4111T",
702 .gen_type = "100/1000/10GBASE-T adapter",
703 .init = sfn4111t_init,
704 .init_phy = sfn4111t_init_phy,
705 .fini = sfn4111t_fini,
706 .set_id_led = tenxpress_set_id_led,
707 .monitor = sfn4111t_check_hw,
708 },
709 {
710 .id = FALCON_BOARD_SFN4112F,
711 .ref_model = "SFN4112F",
712 .gen_type = "SFP+ adapter",
713 .init = sfn4112f_init,
714 .init_phy = sfn4112f_init_phy,
715 .fini = efx_fini_lm87,
716 .set_id_led = sfn4112f_set_id_led,
717 .monitor = sfn4112f_check_hw,
718 },
724}; 719};
725 720
726static struct falcon_board falcon_dummy_board = { 721static const struct falcon_board_type falcon_dummy_board = {
727 .init = efx_port_dummy_op_int, 722 .init = efx_port_dummy_op_int,
728 .init_phy = efx_port_dummy_op_void, 723 .init_phy = efx_port_dummy_op_void,
724 .fini = efx_port_dummy_op_void,
729 .set_id_led = efx_port_dummy_op_set_id_led, 725 .set_id_led = efx_port_dummy_op_set_id_led,
730 .monitor = efx_port_dummy_op_int, 726 .monitor = efx_port_dummy_op_int,
731 .fini = efx_port_dummy_op_void,
732}; 727};
733 728
734void falcon_probe_board(struct efx_nic *efx, u16 revision_info) 729void falcon_probe_board(struct efx_nic *efx, u16 revision_info)
735{ 730{
736 struct falcon_board *board = falcon_board(efx); 731 struct falcon_board *board = falcon_board(efx);
737 struct falcon_board_data *data = NULL; 732 u8 type_id = FALCON_BOARD_TYPE(revision_info);
738 int i; 733 int i;
739 734
740 *board = falcon_dummy_board;
741 board->type = FALCON_BOARD_TYPE(revision_info);
742 board->major = FALCON_BOARD_MAJOR(revision_info); 735 board->major = FALCON_BOARD_MAJOR(revision_info);
743 board->minor = FALCON_BOARD_MINOR(revision_info); 736 board->minor = FALCON_BOARD_MINOR(revision_info);
744 737
745 for (i = 0; i < ARRAY_SIZE(board_data); i++) 738 for (i = 0; i < ARRAY_SIZE(board_types); i++)
746 if (board_data[i].type == board->type) 739 if (board_types[i].id == type_id)
747 data = &board_data[i]; 740 board->type = &board_types[i];
748 741
749 if (data) { 742 if (board->type) {
750 EFX_INFO(efx, "board is %s rev %c%d\n", 743 EFX_INFO(efx, "board is %s rev %c%d\n",
751 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) 744 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
752 ? data->ref_model : data->gen_type, 745 ? board->type->ref_model : board->type->gen_type,
753 'A' + board->major, board->minor); 746 'A' + board->major, board->minor);
754 board->init = data->init;
755 } else { 747 } else {
756 EFX_ERR(efx, "unknown board type %d\n", board->type); 748 EFX_ERR(efx, "unknown board type %d\n", type_id);
749 board->type = &falcon_dummy_board;
757 } 750 }
758} 751}