Loading drivers/soc/qcom/qbt1000.c +40 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ #include <linux/atomic.h> #include <linux/of.h> #include <linux/input.h> #include <linux/pm_runtime.h> #include <linux/pm_wakeup.h> #include <uapi/linux/qbt1000.h> #include <soc/qcom/scm.h> #include "qseecom_kernel.h" Loading Loading @@ -83,7 +85,9 @@ struct qbt1000_drvdata { uint32_t ssc_subsys_id; uint32_t ssc_spi_port; uint32_t ssc_spi_port_slave_index; struct wakeup_source w_lock; }; #define W_LOCK_DELAY_MS (2000) /** * get_cmd_rsp_buffers() - Function sets cmd & rsp buffer pointers and Loading Loading @@ -754,7 +758,7 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg) } drvdata = file->private_data; pm_runtime_get_sync(drvdata->dev); mutex_lock(&drvdata->mutex); if (((drvdata->sensor_conn_type == SPI) && (!drvdata->clock_state)) || ((drvdata->sensor_conn_type == SSC_SPI) && (!drvdata->ssc_state))) { Loading Loading @@ -899,6 +903,8 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg) } end: pm_runtime_mark_last_busy(drvdata->dev); pm_runtime_put_autosuspend(drvdata->dev); mutex_unlock(&drvdata->mutex); return rc; } Loading Loading @@ -1219,6 +1225,10 @@ static int qbt1000_probe(struct platform_device *pdev) atomic_set(&drvdata->available, 1); mutex_init(&drvdata->mutex); wakeup_source_init(&drvdata->w_lock, "qbt_wake_source"); pm_runtime_set_autosuspend_delay(dev, W_LOCK_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); rc = qbt1000_dev_register(drvdata); if (rc < 0) Loading Loading @@ -1259,9 +1269,10 @@ static int qbt1000_remove(struct platform_device *pdev) return 0; } static int qbt1000_suspend(struct platform_device *pdev, pm_message_t state) static int qbt1000_suspend(struct device *dev) { int rc = 0; struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); /* Loading @@ -1280,18 +1291,44 @@ static int qbt1000_suspend(struct platform_device *pdev, pm_message_t state) return rc; } static int qbt1000_runtime_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); __pm_relax(&drvdata->w_lock); return 0; }; static int qbt1000_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); __pm_stay_awake(&drvdata->w_lock); return 0; }; static struct of_device_id qbt1000_match[] = { { .compatible = "qcom,qbt1000" }, {} }; static const struct dev_pm_ops qbt1000_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(qbt1000_suspend, NULL) SET_RUNTIME_PM_OPS(qbt1000_runtime_suspend, qbt1000_runtime_resume, NULL) }; static struct platform_driver qbt1000_plat_driver = { .probe = qbt1000_probe, .remove = qbt1000_remove, .suspend = qbt1000_suspend, .driver = { .name = "qbt1000", .owner = THIS_MODULE, .pm = &qbt1000_dev_pm_ops, .of_match_table = qbt1000_match, }, }; Loading Loading
drivers/soc/qcom/qbt1000.c +40 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,8 @@ #include <linux/atomic.h> #include <linux/of.h> #include <linux/input.h> #include <linux/pm_runtime.h> #include <linux/pm_wakeup.h> #include <uapi/linux/qbt1000.h> #include <soc/qcom/scm.h> #include "qseecom_kernel.h" Loading Loading @@ -83,7 +85,9 @@ struct qbt1000_drvdata { uint32_t ssc_subsys_id; uint32_t ssc_spi_port; uint32_t ssc_spi_port_slave_index; struct wakeup_source w_lock; }; #define W_LOCK_DELAY_MS (2000) /** * get_cmd_rsp_buffers() - Function sets cmd & rsp buffer pointers and Loading Loading @@ -754,7 +758,7 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg) } drvdata = file->private_data; pm_runtime_get_sync(drvdata->dev); mutex_lock(&drvdata->mutex); if (((drvdata->sensor_conn_type == SPI) && (!drvdata->clock_state)) || ((drvdata->sensor_conn_type == SSC_SPI) && (!drvdata->ssc_state))) { Loading Loading @@ -899,6 +903,8 @@ static long qbt1000_ioctl(struct file *file, unsigned cmd, unsigned long arg) } end: pm_runtime_mark_last_busy(drvdata->dev); pm_runtime_put_autosuspend(drvdata->dev); mutex_unlock(&drvdata->mutex); return rc; } Loading Loading @@ -1219,6 +1225,10 @@ static int qbt1000_probe(struct platform_device *pdev) atomic_set(&drvdata->available, 1); mutex_init(&drvdata->mutex); wakeup_source_init(&drvdata->w_lock, "qbt_wake_source"); pm_runtime_set_autosuspend_delay(dev, W_LOCK_DELAY_MS); pm_runtime_use_autosuspend(dev); pm_runtime_enable(dev); rc = qbt1000_dev_register(drvdata); if (rc < 0) Loading Loading @@ -1259,9 +1269,10 @@ static int qbt1000_remove(struct platform_device *pdev) return 0; } static int qbt1000_suspend(struct platform_device *pdev, pm_message_t state) static int qbt1000_suspend(struct device *dev) { int rc = 0; struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); /* Loading @@ -1280,18 +1291,44 @@ static int qbt1000_suspend(struct platform_device *pdev, pm_message_t state) return rc; } static int qbt1000_runtime_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); __pm_relax(&drvdata->w_lock); return 0; }; static int qbt1000_runtime_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct qbt1000_drvdata *drvdata = platform_get_drvdata(pdev); __pm_stay_awake(&drvdata->w_lock); return 0; }; static struct of_device_id qbt1000_match[] = { { .compatible = "qcom,qbt1000" }, {} }; static const struct dev_pm_ops qbt1000_dev_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(qbt1000_suspend, NULL) SET_RUNTIME_PM_OPS(qbt1000_runtime_suspend, qbt1000_runtime_resume, NULL) }; static struct platform_driver qbt1000_plat_driver = { .probe = qbt1000_probe, .remove = qbt1000_remove, .suspend = qbt1000_suspend, .driver = { .name = "qbt1000", .owner = THIS_MODULE, .pm = &qbt1000_dev_pm_ops, .of_match_table = qbt1000_match, }, }; Loading