aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/falcon_boards.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-23 11:05:12 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-24 13:58:42 -0500
commit278c0621fbc4ef52177969edb6f07352da816fdb (patch)
tree1af11fc3f69948a0687df279255c754f5671bd99 /drivers/net/sfc/falcon_boards.c
parent981fc1b4b8cc6bfe8c6f0c07052e25738d959c68 (diff)
sfc: Make board information explicitly Falcon-specific
Rename struct efx_board to struct falcon_board. Introduce and use inline function to look up board info from struct efx_nic, in preparation for moving it. Move board init and fini calls into NIC probe and remove functions. 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.c106
1 files changed, 58 insertions, 48 deletions
diff --git a/drivers/net/sfc/falcon_boards.c b/drivers/net/sfc/falcon_boards.c
index 429d3cd646b5..af7cd2a0b449 100644
--- a/drivers/net/sfc/falcon_boards.c
+++ b/drivers/net/sfc/falcon_boards.c
@@ -65,7 +65,7 @@ static int efx_init_lm87(struct efx_nic *efx, struct i2c_board_info *info,
65 goto err; 65 goto err;
66 } 66 }
67 67
68 efx->board_info.hwmon_client = client; 68 falcon_board(efx)->hwmon_client = client;
69 return 0; 69 return 0;
70 70
71err: 71err:
@@ -75,12 +75,12 @@ err:
75 75
76static void efx_fini_lm87(struct efx_nic *efx) 76static void efx_fini_lm87(struct efx_nic *efx)
77{ 77{
78 i2c_unregister_device(efx->board_info.hwmon_client); 78 i2c_unregister_device(falcon_board(efx)->hwmon_client);
79} 79}
80 80
81static int efx_check_lm87(struct efx_nic *efx, unsigned mask) 81static int efx_check_lm87(struct efx_nic *efx, unsigned mask)
82{ 82{
83 struct i2c_client *client = efx->board_info.hwmon_client; 83 struct i2c_client *client = falcon_board(efx)->hwmon_client;
84 s32 alarms1, alarms2; 84 s32 alarms1, alarms2;
85 85
86 /* If link is up then do not monitor temperature */ 86 /* If link is up then do not monitor temperature */
@@ -189,8 +189,8 @@ static inline int efx_check_lm87(struct efx_nic *efx, unsigned mask)
189 189
190static void sfe4001_poweroff(struct efx_nic *efx) 190static void sfe4001_poweroff(struct efx_nic *efx)
191{ 191{
192 struct i2c_client *ioexp_client = efx->board_info.ioexp_client; 192 struct i2c_client *ioexp_client = falcon_board(efx)->ioexp_client;
193 struct i2c_client *hwmon_client = efx->board_info.hwmon_client; 193 struct i2c_client *hwmon_client = falcon_board(efx)->hwmon_client;
194 194
195 /* Turn off all power rails and disable outputs */ 195 /* Turn off all power rails and disable outputs */
196 i2c_smbus_write_byte_data(ioexp_client, P0_OUT, 0xff); 196 i2c_smbus_write_byte_data(ioexp_client, P0_OUT, 0xff);
@@ -203,8 +203,8 @@ static void sfe4001_poweroff(struct efx_nic *efx)
203 203
204static int sfe4001_poweron(struct efx_nic *efx) 204static int sfe4001_poweron(struct efx_nic *efx)
205{ 205{
206 struct i2c_client *hwmon_client = efx->board_info.hwmon_client; 206 struct i2c_client *ioexp_client = falcon_board(efx)->ioexp_client;
207 struct i2c_client *ioexp_client = efx->board_info.ioexp_client; 207 struct i2c_client *hwmon_client = falcon_board(efx)->hwmon_client;
208 unsigned int i, j; 208 unsigned int i, j;
209 int rc; 209 int rc;
210 u8 out; 210 u8 out;
@@ -346,7 +346,7 @@ static ssize_t set_phy_flash_cfg(struct device *dev,
346 efx->phy_mode = new_mode; 346 efx->phy_mode = new_mode;
347 if (new_mode & PHY_MODE_SPECIAL) 347 if (new_mode & PHY_MODE_SPECIAL)
348 efx_stats_disable(efx); 348 efx_stats_disable(efx);
349 if (efx->board_info.type == FALCON_BOARD_SFE4001) 349 if (falcon_board(efx)->type == FALCON_BOARD_SFE4001)
350 err = sfe4001_poweron(efx); 350 err = sfe4001_poweron(efx);
351 else 351 else
352 err = sfn4111t_reset(efx); 352 err = sfn4111t_reset(efx);
@@ -363,12 +363,14 @@ static DEVICE_ATTR(phy_flash_cfg, 0644, show_phy_flash_cfg, set_phy_flash_cfg);
363 363
364static void sfe4001_fini(struct efx_nic *efx) 364static void sfe4001_fini(struct efx_nic *efx)
365{ 365{
366 struct falcon_board *board = falcon_board(efx);
367
366 EFX_INFO(efx, "%s\n", __func__); 368 EFX_INFO(efx, "%s\n", __func__);
367 369
368 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); 370 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
369 sfe4001_poweroff(efx); 371 sfe4001_poweroff(efx);
370 i2c_unregister_device(efx->board_info.ioexp_client); 372 i2c_unregister_device(board->ioexp_client);
371 i2c_unregister_device(efx->board_info.hwmon_client); 373 i2c_unregister_device(board->hwmon_client);
372} 374}
373 375
374static int sfe4001_check_hw(struct efx_nic *efx) 376static int sfe4001_check_hw(struct efx_nic *efx)
@@ -387,7 +389,7 @@ static int sfe4001_check_hw(struct efx_nic *efx)
387 * the power undesirably. 389 * the power undesirably.
388 * We know we can read from the IO expander because we did 390 * We know we can read from the IO expander because we did
389 * it during power-on. Assume failure now is bad news. */ 391 * it during power-on. Assume failure now is bad news. */
390 status = i2c_smbus_read_byte_data(efx->board_info.ioexp_client, P1_IN); 392 status = i2c_smbus_read_byte_data(falcon_board(efx)->ioexp_client, P1_IN);
391 if (status >= 0 && 393 if (status >= 0 &&
392 (status & ((1 << P1_AFE_PWD_LBN) | (1 << P1_DSP_PWD25_LBN))) != 0) 394 (status & ((1 << P1_AFE_PWD_LBN) | (1 << P1_DSP_PWD25_LBN))) != 0)
393 return 0; 395 return 0;
@@ -409,36 +411,37 @@ static struct i2c_board_info sfe4001_hwmon_info = {
409 */ 411 */
410static int sfe4001_init(struct efx_nic *efx) 412static int sfe4001_init(struct efx_nic *efx)
411{ 413{
414 struct falcon_board *board = falcon_board(efx);
412 int rc; 415 int rc;
413 416
414#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE) 417#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
415 efx->board_info.hwmon_client = 418 board->hwmon_client =
416 i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info); 419 i2c_new_device(&efx->i2c_adap, &sfe4001_hwmon_info);
417#else 420#else
418 efx->board_info.hwmon_client = 421 board->hwmon_client =
419 i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr); 422 i2c_new_dummy(&efx->i2c_adap, sfe4001_hwmon_info.addr);
420#endif 423#endif
421 if (!efx->board_info.hwmon_client) 424 if (!board->hwmon_client)
422 return -EIO; 425 return -EIO;
423 426
424 /* Raise board/PHY high limit from 85 to 90 degrees Celsius */ 427 /* Raise board/PHY high limit from 85 to 90 degrees Celsius */
425 rc = i2c_smbus_write_byte_data(efx->board_info.hwmon_client, 428 rc = i2c_smbus_write_byte_data(board->hwmon_client,
426 MAX664X_REG_WLHO, 90); 429 MAX664X_REG_WLHO, 90);
427 if (rc) 430 if (rc)
428 goto fail_hwmon; 431 goto fail_hwmon;
429 432
430 efx->board_info.ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539); 433 board->ioexp_client = i2c_new_dummy(&efx->i2c_adap, PCA9539);
431 if (!efx->board_info.ioexp_client) { 434 if (!board->ioexp_client) {
432 rc = -EIO; 435 rc = -EIO;
433 goto fail_hwmon; 436 goto fail_hwmon;
434 } 437 }
435 438
436 /* 10Xpress has fixed-function LED pins, so there is no board-specific 439 /* 10Xpress has fixed-function LED pins, so there is no board-specific
437 * blink code. */ 440 * blink code. */
438 efx->board_info.set_id_led = tenxpress_set_id_led; 441 board->set_id_led = tenxpress_set_id_led;
439 442
440 efx->board_info.monitor = sfe4001_check_hw; 443 board->monitor = sfe4001_check_hw;
441 efx->board_info.fini = sfe4001_fini; 444 board->fini = sfe4001_fini;
442 445
443 if (efx->phy_mode & PHY_MODE_SPECIAL) { 446 if (efx->phy_mode & PHY_MODE_SPECIAL) {
444 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch 447 /* PHY won't generate a 156.25 MHz clock and MAC stats fetch
@@ -459,9 +462,9 @@ static int sfe4001_init(struct efx_nic *efx)
459fail_on: 462fail_on:
460 sfe4001_poweroff(efx); 463 sfe4001_poweroff(efx);
461fail_ioexp: 464fail_ioexp:
462 i2c_unregister_device(efx->board_info.ioexp_client); 465 i2c_unregister_device(board->ioexp_client);
463fail_hwmon: 466fail_hwmon:
464 i2c_unregister_device(efx->board_info.hwmon_client); 467 i2c_unregister_device(board->hwmon_client);
465 return rc; 468 return rc;
466} 469}
467 470
@@ -474,7 +477,7 @@ static int sfn4111t_check_hw(struct efx_nic *efx)
474 return 0; 477 return 0;
475 478
476 /* Test LHIGH, RHIGH, FAULT, EOT and IOT alarms */ 479 /* Test LHIGH, RHIGH, FAULT, EOT and IOT alarms */
477 status = i2c_smbus_read_byte_data(efx->board_info.hwmon_client, 480 status = i2c_smbus_read_byte_data(falcon_board(efx)->hwmon_client,
478 MAX664X_REG_RSL); 481 MAX664X_REG_RSL);
479 if (status < 0) 482 if (status < 0)
480 return -EIO; 483 return -EIO;
@@ -488,7 +491,7 @@ static void sfn4111t_fini(struct efx_nic *efx)
488 EFX_INFO(efx, "%s\n", __func__); 491 EFX_INFO(efx, "%s\n", __func__);
489 492
490 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); 493 device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
491 i2c_unregister_device(efx->board_info.hwmon_client); 494 i2c_unregister_device(falcon_board(efx)->hwmon_client);
492} 495}
493 496
494static struct i2c_board_info sfn4111t_a0_hwmon_info = { 497static struct i2c_board_info sfn4111t_a0_hwmon_info = {
@@ -515,20 +518,21 @@ static void sfn4111t_init_phy(struct efx_nic *efx)
515 518
516static int sfn4111t_init(struct efx_nic *efx) 519static int sfn4111t_init(struct efx_nic *efx)
517{ 520{
521 struct falcon_board *board = falcon_board(efx);
518 int rc; 522 int rc;
519 523
520 efx->board_info.hwmon_client = 524 board->hwmon_client =
521 i2c_new_device(&efx->i2c_adap, 525 i2c_new_device(&efx->i2c_adap,
522 (efx->board_info.minor < 5) ? 526 (board->minor < 5) ?
523 &sfn4111t_a0_hwmon_info : 527 &sfn4111t_a0_hwmon_info :
524 &sfn4111t_r5_hwmon_info); 528 &sfn4111t_r5_hwmon_info);
525 if (!efx->board_info.hwmon_client) 529 if (!board->hwmon_client)
526 return -EIO; 530 return -EIO;
527 531
528 efx->board_info.init_phy = sfn4111t_init_phy; 532 board->init_phy = sfn4111t_init_phy;
529 efx->board_info.set_id_led = tenxpress_set_id_led; 533 board->set_id_led = tenxpress_set_id_led;
530 efx->board_info.monitor = sfn4111t_check_hw; 534 board->monitor = sfn4111t_check_hw;
531 efx->board_info.fini = sfn4111t_fini; 535 board->fini = sfn4111t_fini;
532 536
533 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg); 537 rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
534 if (rc) 538 if (rc)
@@ -542,7 +546,7 @@ static int sfn4111t_init(struct efx_nic *efx)
542 return 0; 546 return 0;
543 547
544fail_hwmon: 548fail_hwmon:
545 i2c_unregister_device(efx->board_info.hwmon_client); 549 i2c_unregister_device(board->hwmon_client);
546 return rc; 550 return rc;
547} 551}
548 552
@@ -601,10 +605,12 @@ static void sfe4002_set_id_led(struct efx_nic *efx, enum efx_led_mode mode)
601 605
602static int sfe4002_check_hw(struct efx_nic *efx) 606static int sfe4002_check_hw(struct efx_nic *efx)
603{ 607{
608 struct falcon_board *board = falcon_board(efx);
609
604 /* A0 board rev. 4002s report a temperature fault the whole time 610 /* A0 board rev. 4002s report a temperature fault the whole time
605 * (bad sensor) so we mask it out. */ 611 * (bad sensor) so we mask it out. */
606 unsigned alarm_mask = 612 unsigned alarm_mask =
607 (efx->board_info.major == 0 && efx->board_info.minor == 0) ? 613 (board->major == 0 && board->minor == 0) ?
608 ~LM87_ALARM_TEMP_EXT1 : ~0; 614 ~LM87_ALARM_TEMP_EXT1 : ~0;
609 615
610 return efx_check_lm87(efx, alarm_mask); 616 return efx_check_lm87(efx, alarm_mask);
@@ -612,13 +618,14 @@ static int sfe4002_check_hw(struct efx_nic *efx)
612 618
613static int sfe4002_init(struct efx_nic *efx) 619static int sfe4002_init(struct efx_nic *efx)
614{ 620{
621 struct falcon_board *board = falcon_board(efx);
615 int rc = efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs); 622 int rc = efx_init_lm87(efx, &sfe4002_hwmon_info, sfe4002_lm87_regs);
616 if (rc) 623 if (rc)
617 return rc; 624 return rc;
618 efx->board_info.monitor = sfe4002_check_hw; 625 board->monitor = sfe4002_check_hw;
619 efx->board_info.init_phy = sfe4002_init_phy; 626 board->init_phy = sfe4002_init_phy;
620 efx->board_info.set_id_led = sfe4002_set_id_led; 627 board->set_id_led = sfe4002_set_id_led;
621 efx->board_info.fini = efx_fini_lm87; 628 board->fini = efx_fini_lm87;
622 return 0; 629 return 0;
623} 630}
624 631
@@ -683,13 +690,15 @@ static int sfn4112f_check_hw(struct efx_nic *efx)
683 690
684static int sfn4112f_init(struct efx_nic *efx) 691static int sfn4112f_init(struct efx_nic *efx)
685{ 692{
693 struct falcon_board *board = falcon_board(efx);
694
686 int rc = efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs); 695 int rc = efx_init_lm87(efx, &sfn4112f_hwmon_info, sfn4112f_lm87_regs);
687 if (rc) 696 if (rc)
688 return rc; 697 return rc;
689 efx->board_info.monitor = sfn4112f_check_hw; 698 board->monitor = sfn4112f_check_hw;
690 efx->board_info.init_phy = sfn4112f_init_phy; 699 board->init_phy = sfn4112f_init_phy;
691 efx->board_info.set_id_led = sfn4112f_set_id_led; 700 board->set_id_led = sfn4112f_set_id_led;
692 efx->board_info.fini = efx_fini_lm87; 701 board->fini = efx_fini_lm87;
693 return 0; 702 return 0;
694} 703}
695 704
@@ -714,24 +723,25 @@ static struct falcon_board_data board_data[] = {
714 723
715void falcon_probe_board(struct efx_nic *efx, u16 revision_info) 724void falcon_probe_board(struct efx_nic *efx, u16 revision_info)
716{ 725{
726 struct falcon_board *board = falcon_board(efx);
717 struct falcon_board_data *data = NULL; 727 struct falcon_board_data *data = NULL;
718 int i; 728 int i;
719 729
720 efx->board_info.type = FALCON_BOARD_TYPE(revision_info); 730 board->type = FALCON_BOARD_TYPE(revision_info);
721 efx->board_info.major = FALCON_BOARD_MAJOR(revision_info); 731 board->major = FALCON_BOARD_MAJOR(revision_info);
722 efx->board_info.minor = FALCON_BOARD_MINOR(revision_info); 732 board->minor = FALCON_BOARD_MINOR(revision_info);
723 733
724 for (i = 0; i < ARRAY_SIZE(board_data); i++) 734 for (i = 0; i < ARRAY_SIZE(board_data); i++)
725 if (board_data[i].type == efx->board_info.type) 735 if (board_data[i].type == board->type)
726 data = &board_data[i]; 736 data = &board_data[i];
727 737
728 if (data) { 738 if (data) {
729 EFX_INFO(efx, "board is %s rev %c%d\n", 739 EFX_INFO(efx, "board is %s rev %c%d\n",
730 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC) 740 (efx->pci_dev->subsystem_vendor == EFX_VENDID_SFC)
731 ? data->ref_model : data->gen_type, 741 ? data->ref_model : data->gen_type,
732 'A' + efx->board_info.major, efx->board_info.minor); 742 'A' + board->major, board->minor);
733 efx->board_info.init = data->init; 743 board->init = data->init;
734 } else { 744 } else {
735 EFX_ERR(efx, "unknown board type %d\n", efx->board_info.type); 745 EFX_ERR(efx, "unknown board type %d\n", board->type);
736 } 746 }
737} 747}