mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 21:59:12 -04:00
Merge "icnss2: Add support for Runtime PM"
This commit is contained in:
commit
3f51b8647d
2 changed files with 93 additions and 2 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include <linux/etherdevice.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/of_irq.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/soc/qcom/qmi.h>
|
||||
#include <linux/sysfs.h>
|
||||
#include <linux/thermal.h>
|
||||
|
|
@ -3018,6 +3019,21 @@ static void icnss_init_control_params(struct icnss_priv *priv)
|
|||
}
|
||||
}
|
||||
|
||||
static inline void icnss_runtime_pm_init(struct icnss_priv *priv)
|
||||
{
|
||||
pm_runtime_get_sync(&priv->pdev->dev);
|
||||
pm_runtime_forbid(&priv->pdev->dev);
|
||||
pm_runtime_set_active(&priv->pdev->dev);
|
||||
pm_runtime_enable(&priv->pdev->dev);
|
||||
}
|
||||
|
||||
static inline void icnss_runtime_pm_deinit(struct icnss_priv *priv)
|
||||
{
|
||||
pm_runtime_disable(&priv->pdev->dev);
|
||||
pm_runtime_allow(&priv->pdev->dev);
|
||||
pm_runtime_put_sync(&priv->pdev->dev);
|
||||
}
|
||||
|
||||
static int icnss_probe(struct platform_device *pdev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
|
@ -3120,6 +3136,8 @@ static int icnss_probe(struct platform_device *pdev)
|
|||
ret = icnss_genl_init();
|
||||
if (ret < 0)
|
||||
icnss_pr_err("ICNSS genl init failed %d\n", ret);
|
||||
|
||||
icnss_runtime_pm_init(priv);
|
||||
}
|
||||
|
||||
icnss_pr_info("Platform driver probed successfully\n");
|
||||
|
|
@ -3145,8 +3163,10 @@ static int icnss_remove(struct platform_device *pdev)
|
|||
|
||||
icnss_pr_info("Removing driver: state: 0x%lx\n", priv->state);
|
||||
|
||||
if (priv->device_id == WCN6750_DEVICE_ID)
|
||||
if (priv->device_id == WCN6750_DEVICE_ID) {
|
||||
icnss_genl_exit();
|
||||
icnss_runtime_pm_deinit(priv);
|
||||
}
|
||||
|
||||
device_init_wakeup(&priv->pdev->dev, false);
|
||||
|
||||
|
|
@ -3304,15 +3324,84 @@ out:
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_CNSS_QCA6750
|
||||
static int icnss_pm_runtime_suspend(struct device *dev)
|
||||
{
|
||||
struct icnss_priv *priv = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
|
||||
if (priv->magic != ICNSS_MAGIC) {
|
||||
icnss_pr_err("Invalid drvdata for runtime suspend: dev %pK, data %pK, magic 0x%x\n",
|
||||
dev, priv, priv->magic);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!priv->ops || !priv->ops->runtime_suspend)
|
||||
goto out;
|
||||
|
||||
icnss_pr_vdbg("Runtime suspend\n");
|
||||
ret = priv->ops->runtime_suspend(dev);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int icnss_pm_runtime_resume(struct device *dev)
|
||||
{
|
||||
struct icnss_priv *priv = dev_get_drvdata(dev);
|
||||
int ret = 0;
|
||||
|
||||
if (priv->magic != ICNSS_MAGIC) {
|
||||
icnss_pr_err("Invalid drvdata for runtime resume: dev %pK, data %pK, magic 0x%x\n",
|
||||
dev, priv, priv->magic);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!priv->ops || !priv->ops->runtime_resume)
|
||||
goto out;
|
||||
|
||||
ret = wlfw_exit_power_save_send_msg(priv);
|
||||
if (ret) {
|
||||
priv->stats.pm_resume_err++;
|
||||
return ret;
|
||||
}
|
||||
|
||||
icnss_pr_vdbg("Runtime resume\n");
|
||||
ret = priv->ops->runtime_resume(dev);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int icnss_pm_runtime_idle(struct device *dev)
|
||||
{
|
||||
icnss_pr_vdbg("Runtime idle\n");
|
||||
|
||||
pm_request_autosuspend(dev);
|
||||
|
||||
return -EBUSY;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_CNSS_QCA6750
|
||||
static const struct dev_pm_ops icnss_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(icnss_pm_suspend,
|
||||
icnss_pm_resume)
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(icnss_pm_suspend_noirq,
|
||||
icnss_pm_resume_noirq)
|
||||
SET_RUNTIME_PM_OPS(icnss_pm_runtime_suspend, icnss_pm_runtime_resume,
|
||||
icnss_pm_runtime_idle)
|
||||
};
|
||||
#else
|
||||
static const struct dev_pm_ops icnss_pm_ops = {
|
||||
SET_SYSTEM_SLEEP_PM_OPS(icnss_pm_suspend,
|
||||
icnss_pm_resume)
|
||||
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(icnss_pm_suspend_noirq,
|
||||
icnss_pm_resume_noirq)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
static struct platform_driver icnss_driver = {
|
||||
.probe = icnss_probe,
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ struct icnss_driver_ops {
|
|||
int (*pm_resume)(struct device *dev);
|
||||
int (*suspend_noirq)(struct device *dev);
|
||||
int (*resume_noirq)(struct device *dev);
|
||||
int (*runtime_suspend)(struct device *dev);
|
||||
int (*runtime_resume)(struct device *dev);
|
||||
int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent);
|
||||
int (*idle_shutdown)(struct device *dev);
|
||||
int (*idle_restart)(struct device *dev);
|
||||
|
|
|
|||
Loading…
Reference in a new issue