Commit 75abde4d authored by Vasily Khoruzhick's avatar Vasily Khoruzhick Committed by John W. Linville

libertas: Prepare stuff for if_spi.c pm support

To support suspend/resume in if_spi we need two things:
- re-setup fw in lbs_resume(), because if_spi powercycles card;
- don't touch hwaddr on second lbs_update_hw_spec() call for same
  reason;
Signed-off-by: default avatarVasily Khoruzhick <anarsoul@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 16f775be
...@@ -145,9 +145,13 @@ int lbs_update_hw_spec(struct lbs_private *priv) ...@@ -145,9 +145,13 @@ int lbs_update_hw_spec(struct lbs_private *priv)
if (priv->current_addr[0] == 0xff) if (priv->current_addr[0] == 0xff)
memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN); memmove(priv->current_addr, cmd.permanentaddr, ETH_ALEN);
if (!priv->copied_hwaddr) {
memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN); memcpy(priv->dev->dev_addr, priv->current_addr, ETH_ALEN);
if (priv->mesh_dev) if (priv->mesh_dev)
memcpy(priv->mesh_dev->dev_addr, priv->current_addr, ETH_ALEN); memcpy(priv->mesh_dev->dev_addr,
priv->current_addr, ETH_ALEN);
priv->copied_hwaddr = 1;
}
out: out:
lbs_deb_leave(LBS_DEB_CMD); lbs_deb_leave(LBS_DEB_CMD);
......
...@@ -90,6 +90,7 @@ struct lbs_private { ...@@ -90,6 +90,7 @@ struct lbs_private {
void *card; void *card;
u8 fw_ready; u8 fw_ready;
u8 surpriseremoved; u8 surpriseremoved;
u8 setup_fw_on_resume;
int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb); int (*hw_host_to_card) (struct lbs_private *priv, u8 type, u8 *payload, u16 nb);
void (*reset_card) (struct lbs_private *priv); void (*reset_card) (struct lbs_private *priv);
int (*enter_deep_sleep) (struct lbs_private *priv); int (*enter_deep_sleep) (struct lbs_private *priv);
...@@ -101,6 +102,7 @@ struct lbs_private { ...@@ -101,6 +102,7 @@ struct lbs_private {
u32 fwcapinfo; u32 fwcapinfo;
u16 regioncode; u16 regioncode;
u8 current_addr[ETH_ALEN]; u8 current_addr[ETH_ALEN];
u8 copied_hwaddr;
/* Command download */ /* Command download */
u8 dnld_sent; u8 dnld_sent;
......
...@@ -539,6 +539,43 @@ static int lbs_thread(void *data) ...@@ -539,6 +539,43 @@ static int lbs_thread(void *data)
return 0; return 0;
} }
/**
* @brief This function gets the HW spec from the firmware and sets
* some basic parameters.
*
* @param priv A pointer to struct lbs_private structure
* @return 0 or -1
*/
static int lbs_setup_firmware(struct lbs_private *priv)
{
int ret = -1;
s16 curlevel = 0, minlevel = 0, maxlevel = 0;
lbs_deb_enter(LBS_DEB_FW);
/* Read MAC address from firmware */
memset(priv->current_addr, 0xff, ETH_ALEN);
ret = lbs_update_hw_spec(priv);
if (ret)
goto done;
/* Read power levels if available */
ret = lbs_get_tx_power(priv, &curlevel, &minlevel, &maxlevel);
if (ret == 0) {
priv->txpower_cur = curlevel;
priv->txpower_min = minlevel;
priv->txpower_max = maxlevel;
}
/* Send cmd to FW to enable 11D function */
ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_11D_ENABLE, 1);
lbs_set_mac_control(priv);
done:
lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
return ret;
}
int lbs_suspend(struct lbs_private *priv) int lbs_suspend(struct lbs_private *priv)
{ {
int ret; int ret;
...@@ -584,47 +621,13 @@ int lbs_resume(struct lbs_private *priv) ...@@ -584,47 +621,13 @@ int lbs_resume(struct lbs_private *priv)
lbs_pr_err("deep sleep activation failed: %d\n", ret); lbs_pr_err("deep sleep activation failed: %d\n", ret);
} }
lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); if (priv->setup_fw_on_resume)
return ret; ret = lbs_setup_firmware(priv);
}
EXPORT_SYMBOL_GPL(lbs_resume);
/**
* @brief This function gets the HW spec from the firmware and sets
* some basic parameters.
*
* @param priv A pointer to struct lbs_private structure
* @return 0 or -1
*/
static int lbs_setup_firmware(struct lbs_private *priv)
{
int ret = -1;
s16 curlevel = 0, minlevel = 0, maxlevel = 0;
lbs_deb_enter(LBS_DEB_FW);
/* Read MAC address from firmware */
memset(priv->current_addr, 0xff, ETH_ALEN);
ret = lbs_update_hw_spec(priv);
if (ret)
goto done;
/* Read power levels if available */
ret = lbs_get_tx_power(priv, &curlevel, &minlevel, &maxlevel);
if (ret == 0) {
priv->txpower_cur = curlevel;
priv->txpower_min = minlevel;
priv->txpower_max = maxlevel;
}
/* Send cmd to FW to enable 11D function */
ret = lbs_set_snmp_mib(priv, SNMP_MIB_OID_11D_ENABLE, 1);
lbs_set_mac_control(priv);
done:
lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret); lbs_deb_leave_args(LBS_DEB_FW, "ret %d", ret);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(lbs_resume);
/** /**
* This function handles the timeout of command sending. * This function handles the timeout of command sending.
......
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