diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-11-25 11:09:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-26 18:59:16 -0500 |
commit | 44838a447de3b1541cbf845853c4f8999310b0dd (patch) | |
tree | 53d5f1b0a6ad773764c7f97eb1d48619e781a67f /drivers/net/sfc | |
parent | 734a350a6ccee59647f064fd49cd6cebc5dda48b (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')
-rw-r--r-- | drivers/net/sfc/efx.c | 2 | ||||
-rw-r--r-- | drivers/net/sfc/ethtool.c | 6 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.c | 4 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.h | 34 | ||||
-rw-r--r-- | drivers/net/sfc/falcon_boards.c | 115 | ||||
-rw-r--r-- | drivers/net/sfc/qt202x_phy.c | 2 | ||||
-rw-r--r-- | drivers/net/sfc/tenxpress.c | 2 |
7 files changed, 85 insertions, 80 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index 9f3ef387a047..dc85efaf15a0 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -1309,7 +1309,7 @@ static void efx_monitor(struct work_struct *data) | |||
1309 | goto out_requeue; | 1309 | goto out_requeue; |
1310 | if (!efx->port_enabled) | 1310 | if (!efx->port_enabled) |
1311 | goto out_unlock; | 1311 | goto out_unlock; |
1312 | rc = falcon_board(efx)->monitor(efx); | 1312 | rc = falcon_board(efx)->type->monitor(efx); |
1313 | if (rc) { | 1313 | if (rc) { |
1314 | EFX_ERR(efx, "Board sensor %s; shutting down PHY\n", | 1314 | EFX_ERR(efx, "Board sensor %s; shutting down PHY\n", |
1315 | (rc == -ERANGE) ? "reported fault" : "failed"); | 1315 | (rc == -ERANGE) ? "reported fault" : "failed"); |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index d8915b95e65a..bb9abf24f545 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -174,14 +174,14 @@ static int efx_ethtool_phys_id(struct net_device *net_dev, u32 count) | |||
174 | struct efx_nic *efx = netdev_priv(net_dev); | 174 | struct efx_nic *efx = netdev_priv(net_dev); |
175 | 175 | ||
176 | do { | 176 | do { |
177 | falcon_board(efx)->set_id_led(efx, EFX_LED_ON); | 177 | falcon_board(efx)->type->set_id_led(efx, EFX_LED_ON); |
178 | schedule_timeout_interruptible(HZ / 2); | 178 | schedule_timeout_interruptible(HZ / 2); |
179 | 179 | ||
180 | falcon_board(efx)->set_id_led(efx, EFX_LED_OFF); | 180 | falcon_board(efx)->type->set_id_led(efx, EFX_LED_OFF); |
181 | schedule_timeout_interruptible(HZ / 2); | 181 | schedule_timeout_interruptible(HZ / 2); |
182 | } while (!signal_pending(current) && --count != 0); | 182 | } while (!signal_pending(current) && --count != 0); |
183 | 183 | ||
184 | falcon_board(efx)->set_id_led(efx, EFX_LED_DEFAULT); | 184 | falcon_board(efx)->type->set_id_led(efx, EFX_LED_DEFAULT); |
185 | return 0; | 185 | return 0; |
186 | } | 186 | } |
187 | 187 | ||
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 2c0be6ccc624..2f1f1fca0802 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -2864,7 +2864,7 @@ int falcon_probe_nic(struct efx_nic *efx) | |||
2864 | if (rc) | 2864 | if (rc) |
2865 | goto fail5; | 2865 | goto fail5; |
2866 | 2866 | ||
2867 | rc = falcon_board(efx)->init(efx); | 2867 | rc = falcon_board(efx)->type->init(efx); |
2868 | if (rc) { | 2868 | if (rc) { |
2869 | EFX_ERR(efx, "failed to initialise board\n"); | 2869 | EFX_ERR(efx, "failed to initialise board\n"); |
2870 | goto fail6; | 2870 | goto fail6; |
@@ -3067,7 +3067,7 @@ void falcon_remove_nic(struct efx_nic *efx) | |||
3067 | struct falcon_board *board = falcon_board(efx); | 3067 | struct falcon_board *board = falcon_board(efx); |
3068 | int rc; | 3068 | int rc; |
3069 | 3069 | ||
3070 | falcon_board(efx)->fini(efx); | 3070 | board->type->fini(efx); |
3071 | 3071 | ||
3072 | /* Remove I2C adapter and clear it in preparation for a retry */ | 3072 | /* Remove I2C adapter and clear it in preparation for a retry */ |
3073 | rc = i2c_del_adapter(&board->i2c_adap); | 3073 | rc = i2c_del_adapter(&board->i2c_adap); |
diff --git a/drivers/net/sfc/falcon.h b/drivers/net/sfc/falcon.h index ea6ac06fa26a..b331889ca46c 100644 --- a/drivers/net/sfc/falcon.h +++ b/drivers/net/sfc/falcon.h | |||
@@ -31,29 +31,41 @@ static inline int falcon_rev(struct efx_nic *efx) | |||
31 | } | 31 | } |
32 | 32 | ||
33 | /** | 33 | /** |
34 | * struct falcon_board - board information | 34 | * struct falcon_board_type - board operations and type information |
35 | * @type: Board model type | 35 | * @id: Board type id, as found in NVRAM |
36 | * @major: Major rev. ('A', 'B' ...) | 36 | * @ref_model: Model number of Solarflare reference design |
37 | * @minor: Minor rev. (0, 1, ...) | 37 | * @gen_type: Generic board type description |
38 | * @init: Allocate resources and initialise peripheral hardware | 38 | * @init: Allocate resources and initialise peripheral hardware |
39 | * @init_phy: Do board-specific PHY initialisation | 39 | * @init_phy: Do board-specific PHY initialisation |
40 | * @fini: Shut down hardware and free resources | ||
40 | * @set_id_led: Set state of identifying LED or revert to automatic function | 41 | * @set_id_led: Set state of identifying LED or revert to automatic function |
41 | * @monitor: Board-specific health check function | 42 | * @monitor: Board-specific health check function |
42 | * @fini: Shut down hardware and free resources | 43 | */ |
44 | struct falcon_board_type { | ||
45 | u8 id; | ||
46 | const char *ref_model; | ||
47 | const char *gen_type; | ||
48 | int (*init) (struct efx_nic *nic); | ||
49 | void (*init_phy) (struct efx_nic *efx); | ||
50 | void (*fini) (struct efx_nic *nic); | ||
51 | void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); | ||
52 | int (*monitor) (struct efx_nic *nic); | ||
53 | }; | ||
54 | |||
55 | /** | ||
56 | * struct falcon_board - board information | ||
57 | * @type: Type of board | ||
58 | * @major: Major rev. ('A', 'B' ...) | ||
59 | * @minor: Minor rev. (0, 1, ...) | ||
43 | * @i2c_adap: I2C adapter for on-board peripherals | 60 | * @i2c_adap: I2C adapter for on-board peripherals |
44 | * @i2c_data: Data for bit-banging algorithm | 61 | * @i2c_data: Data for bit-banging algorithm |
45 | * @hwmon_client: I2C client for hardware monitor | 62 | * @hwmon_client: I2C client for hardware monitor |
46 | * @ioexp_client: I2C client for power/port control | 63 | * @ioexp_client: I2C client for power/port control |
47 | */ | 64 | */ |
48 | struct falcon_board { | 65 | struct falcon_board { |
49 | int type; | 66 | const struct falcon_board_type *type; |
50 | int major; | 67 | int major; |
51 | int minor; | 68 | int minor; |
52 | int (*init) (struct efx_nic *nic); | ||
53 | void (*init_phy) (struct efx_nic *efx); | ||
54 | void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); | ||
55 | int (*monitor) (struct efx_nic *nic); | ||
56 | void (*fini) (struct efx_nic *nic); | ||
57 | struct i2c_adapter i2c_adap; | 69 | struct i2c_adapter i2c_adap; |
58 | struct i2c_algo_bit_data i2c_data; | 70 | struct i2c_algo_bit_data i2c_data; |
59 | struct i2c_client *hwmon_client, *ioexp_client; | 71 | struct i2c_client *hwmon_client, *ioexp_client; |
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 | ||
621 | static int sfe4002_init(struct efx_nic *efx) | 609 | static 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 | ||
693 | static int sfn4112f_init(struct efx_nic *efx) | 673 | static 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 | 678 | static const struct falcon_board_type board_types[] = { |
708 | * PHY drivers. */ | 679 | { |
709 | struct 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, | |
717 | static 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 | ||
726 | static struct falcon_board falcon_dummy_board = { | 721 | static 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 | ||
734 | void falcon_probe_board(struct efx_nic *efx, u16 revision_info) | 729 | void 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 | } |
diff --git a/drivers/net/sfc/qt202x_phy.c b/drivers/net/sfc/qt202x_phy.c index 8208ac0ffad7..f9c354e9fc3c 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 | falcon_board(efx)->init_phy(efx); | 129 | falcon_board(efx)->type->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 b001f38524f7..a95402d601c7 100644 --- a/drivers/net/sfc/tenxpress.c +++ b/drivers/net/sfc/tenxpress.c | |||
@@ -303,7 +303,7 @@ 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 | falcon_board(efx)->init_phy(efx); | 306 | falcon_board(efx)->type->init_phy(efx); |
307 | 307 | ||
308 | phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL); | 308 | phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL); |
309 | if (!phy_data) | 309 | if (!phy_data) |