Commit 981fc1b4 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

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: default avatarBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 398468ed
...@@ -1910,7 +1910,7 @@ static struct efx_phy_operations efx_dummy_phy_operations = { ...@@ -1910,7 +1910,7 @@ static struct efx_phy_operations efx_dummy_phy_operations = {
static struct efx_board efx_dummy_board_info = { static struct efx_board efx_dummy_board_info = {
.init = efx_port_dummy_op_int, .init = efx_port_dummy_op_int,
.init_leds = efx_port_dummy_op_void, .init_phy = efx_port_dummy_op_void,
.set_id_led = efx_port_dummy_op_set_id_led, .set_id_led = efx_port_dummy_op_set_id_led,
.monitor = efx_port_dummy_op_int, .monitor = efx_port_dummy_op_int,
.fini = efx_port_dummy_op_void, .fini = efx_port_dummy_op_void,
......
...@@ -499,9 +499,22 @@ static struct i2c_board_info sfn4111t_r5_hwmon_info = { ...@@ -499,9 +499,22 @@ static struct i2c_board_info sfn4111t_r5_hwmon_info = {
I2C_BOARD_INFO("max6646", 0x4d), I2C_BOARD_INFO("max6646", 0x4d),
}; };
static void sfn4111t_init_phy(struct efx_nic *efx)
{
if (!(efx->phy_mode & PHY_MODE_SPECIAL)) {
if (sft9001_wait_boot(efx) != -EINVAL)
return;
efx->phy_mode = PHY_MODE_SPECIAL;
efx_stats_disable(efx);
}
sfn4111t_reset(efx);
sft9001_wait_boot(efx);
}
static int sfn4111t_init(struct efx_nic *efx) static int sfn4111t_init(struct efx_nic *efx)
{ {
int i = 0;
int rc; int rc;
efx->board_info.hwmon_client = efx->board_info.hwmon_client =
...@@ -512,6 +525,7 @@ static int sfn4111t_init(struct efx_nic *efx) ...@@ -512,6 +525,7 @@ static int sfn4111t_init(struct efx_nic *efx)
if (!efx->board_info.hwmon_client) if (!efx->board_info.hwmon_client)
return -EIO; return -EIO;
efx->board_info.init_phy = sfn4111t_init_phy;
efx->board_info.set_id_led = tenxpress_set_id_led; efx->board_info.set_id_led = tenxpress_set_id_led;
efx->board_info.monitor = sfn4111t_check_hw; efx->board_info.monitor = sfn4111t_check_hw;
efx->board_info.fini = sfn4111t_fini; efx->board_info.fini = sfn4111t_fini;
...@@ -520,20 +534,13 @@ static int sfn4111t_init(struct efx_nic *efx) ...@@ -520,20 +534,13 @@ static int sfn4111t_init(struct efx_nic *efx)
if (rc) if (rc)
goto fail_hwmon; goto fail_hwmon;
do { if (efx->phy_mode & PHY_MODE_SPECIAL)
if (efx->phy_mode & PHY_MODE_SPECIAL) { /* PHY may not generate a 156.25 MHz clock and MAC
/* PHY may not generate a 156.25 MHz clock and MAC * stats fetch will fail. */
* stats fetch will fail. */ efx_stats_disable(efx);
efx_stats_disable(efx);
sfn4111t_reset(efx); return 0;
}
rc = sft9001_wait_boot(efx);
if (rc == 0)
return 0;
efx->phy_mode = PHY_MODE_SPECIAL;
} while (rc == -EINVAL && ++i < 2);
device_remove_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
fail_hwmon: fail_hwmon:
i2c_unregister_device(efx->board_info.hwmon_client); i2c_unregister_device(efx->board_info.hwmon_client);
return rc; return rc;
...@@ -574,7 +581,7 @@ static struct i2c_board_info sfe4002_hwmon_info = { ...@@ -574,7 +581,7 @@ static struct i2c_board_info sfe4002_hwmon_info = {
#define SFE4002_RX_LED (0) /* Green */ #define SFE4002_RX_LED (0) /* Green */
#define SFE4002_TX_LED (1) /* Amber */ #define SFE4002_TX_LED (1) /* Amber */
static void sfe4002_init_leds(struct efx_nic *efx) static void sfe4002_init_phy(struct efx_nic *efx)
{ {
/* Set the TX and RX LEDs to reflect status and activity, and the /* Set the TX and RX LEDs to reflect status and activity, and the
* fault LED off */ * fault LED off */
...@@ -609,7 +616,7 @@ static int sfe4002_init(struct efx_nic *efx) ...@@ -609,7 +616,7 @@ static int sfe4002_init(struct efx_nic *efx)
if (rc) if (rc)
return rc; return rc;
efx->board_info.monitor = sfe4002_check_hw; efx->board_info.monitor = sfe4002_check_hw;
efx->board_info.init_leds = sfe4002_init_leds; efx->board_info.init_phy = sfe4002_init_phy;
efx->board_info.set_id_led = sfe4002_set_id_led; efx->board_info.set_id_led = sfe4002_set_id_led;
efx->board_info.fini = efx_fini_lm87; efx->board_info.fini = efx_fini_lm87;
return 0; return 0;
...@@ -641,7 +648,7 @@ static struct i2c_board_info sfn4112f_hwmon_info = { ...@@ -641,7 +648,7 @@ static struct i2c_board_info sfn4112f_hwmon_info = {
#define SFN4112F_ACT_LED 0 #define SFN4112F_ACT_LED 0
#define SFN4112F_LINK_LED 1 #define SFN4112F_LINK_LED 1
static void sfn4112f_init_leds(struct efx_nic *efx) static void sfn4112f_init_phy(struct efx_nic *efx)
{ {
falcon_qt202x_set_led(efx, SFN4112F_ACT_LED, falcon_qt202x_set_led(efx, SFN4112F_ACT_LED,
QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACT); QUAKE_LED_RXLINK | QUAKE_LED_LINK_ACT);
...@@ -680,7 +687,7 @@ static int sfn4112f_init(struct efx_nic *efx) ...@@ -680,7 +687,7 @@ static int sfn4112f_init(struct efx_nic *efx)
if (rc) if (rc)
return rc; return rc;
efx->board_info.monitor = sfn4112f_check_hw; efx->board_info.monitor = sfn4112f_check_hw;
efx->board_info.init_leds = sfn4112f_init_leds; efx->board_info.init_phy = sfn4112f_init_phy;
efx->board_info.set_id_led = sfn4112f_set_id_led; efx->board_info.set_id_led = sfn4112f_set_id_led;
efx->board_info.fini = efx_fini_lm87; efx->board_info.fini = efx_fini_lm87;
return 0; return 0;
......
...@@ -399,11 +399,11 @@ enum efx_led_mode { ...@@ -399,11 +399,11 @@ enum efx_led_mode {
* @type: Board model type * @type: Board model type
* @major: Major rev. ('A', 'B' ...) * @major: Major rev. ('A', 'B' ...)
* @minor: Minor rev. (0, 1, ...) * @minor: Minor rev. (0, 1, ...)
* @init: Initialisation function * @init: Allocate resources and initialise peripheral hardware
* @init_leds: Sets up board LEDs. May be called repeatedly. * @init_phy: Do board-specific PHY initialisation
* @set_id_led: Set state of identifying LED or revert to automatic function * @set_id_led: Set state of identifying LED or revert to automatic function
* @monitor: Board-specific health check function * @monitor: Board-specific health check function
* @fini: Cleanup function * @fini: Shut down hardware and free resources
* @hwmon_client: I2C client for hardware monitor * @hwmon_client: I2C client for hardware monitor
* @ioexp_client: I2C client for power/port control * @ioexp_client: I2C client for power/port control
*/ */
...@@ -412,10 +412,7 @@ struct efx_board { ...@@ -412,10 +412,7 @@ struct efx_board {
int major; int major;
int minor; int minor;
int (*init) (struct efx_nic *nic); int (*init) (struct efx_nic *nic);
/* As the LEDs are typically attached to the PHY, LEDs void (*init_phy) (struct efx_nic *efx);
* have a separate init callback that happens later than
* board init. */
void (*init_leds)(struct efx_nic *efx);
void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode); void (*set_id_led) (struct efx_nic *efx, enum efx_led_mode mode);
int (*monitor) (struct efx_nic *nic); int (*monitor) (struct efx_nic *nic);
void (*fini) (struct efx_nic *nic); void (*fini) (struct efx_nic *nic);
......
...@@ -126,7 +126,7 @@ static int qt202x_reset_phy(struct efx_nic *efx) ...@@ -126,7 +126,7 @@ static int qt202x_reset_phy(struct efx_nic *efx)
if (rc < 0) if (rc < 0)
goto fail; goto fail;
efx->board_info.init_leds(efx); efx->board_info.init_phy(efx);
return rc; return rc;
......
...@@ -303,6 +303,8 @@ static int tenxpress_phy_init(struct efx_nic *efx) ...@@ -303,6 +303,8 @@ static int tenxpress_phy_init(struct efx_nic *efx)
u16 old_adv, adv; u16 old_adv, adv;
int rc = 0; int rc = 0;
efx->board_info.init_phy(efx);
phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL); phy_data = kzalloc(sizeof(*phy_data), GFP_KERNEL);
if (!phy_data) if (!phy_data)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment