|
16 | 16 | #include <linux/of.h> |
17 | 17 | #include <linux/of_platform.h> |
18 | 18 | #include <linux/platform_device.h> |
| 19 | +#include <linux/pm.h> |
| 20 | +#include <linux/pm_runtime.h> |
19 | 21 |
|
20 | 22 | #include <linux/firmware/qcom/qcom_scm.h> |
21 | 23 |
|
@@ -108,6 +110,7 @@ struct qcom_ice { |
108 | 110 | void __iomem *base; |
109 | 111 |
|
110 | 112 | struct clk *core_clk; |
| 113 | + struct clk *iface_clk; |
111 | 114 | bool use_hwkm; |
112 | 115 | bool hwkm_init_complete; |
113 | 116 | u8 hwkm_version; |
@@ -310,20 +313,30 @@ int qcom_ice_resume(struct qcom_ice *ice) |
310 | 313 | struct device *dev = ice->dev; |
311 | 314 | int err; |
312 | 315 |
|
| 316 | + pm_runtime_get_sync(dev); |
313 | 317 | err = clk_prepare_enable(ice->core_clk); |
314 | 318 | if (err) { |
315 | 319 | dev_err(dev, "failed to enable core clock (%d)\n", |
316 | 320 | err); |
317 | 321 | return err; |
318 | 322 | } |
| 323 | + |
| 324 | + err = clk_prepare_enable(ice->iface_clk); |
| 325 | + if (err) { |
| 326 | + dev_err(dev, "failed to enable iface clock (%d)\n", |
| 327 | + err); |
| 328 | + return err; |
| 329 | + } |
319 | 330 | qcom_ice_hwkm_init(ice); |
320 | 331 | return qcom_ice_wait_bist_status(ice); |
321 | 332 | } |
322 | 333 | EXPORT_SYMBOL_GPL(qcom_ice_resume); |
323 | 334 |
|
324 | 335 | int qcom_ice_suspend(struct qcom_ice *ice) |
325 | 336 | { |
| 337 | + clk_disable_unprepare(ice->iface_clk); |
326 | 338 | clk_disable_unprepare(ice->core_clk); |
| 339 | + pm_runtime_put_sync(ice->dev); |
327 | 340 | ice->hwkm_init_complete = false; |
328 | 341 |
|
329 | 342 | return 0; |
@@ -584,6 +597,10 @@ static struct qcom_ice *qcom_ice_create(struct device *dev, |
584 | 597 | if (IS_ERR(engine->core_clk)) |
585 | 598 | return ERR_CAST(engine->core_clk); |
586 | 599 |
|
| 600 | + engine->iface_clk = devm_clk_get_enabled(dev, "iface_clk"); |
| 601 | + if (IS_ERR(engine->iface_clk)) |
| 602 | + return ERR_CAST(engine->iface_clk); |
| 603 | + |
587 | 604 | if (!qcom_ice_check_supported(engine)) |
588 | 605 | return ERR_PTR(-EOPNOTSUPP); |
589 | 606 |
|
@@ -725,6 +742,9 @@ static int qcom_ice_probe(struct platform_device *pdev) |
725 | 742 | return PTR_ERR(base); |
726 | 743 | } |
727 | 744 |
|
| 745 | + devm_pm_runtime_enable(&pdev->dev); |
| 746 | + pm_runtime_get_sync(&pdev->dev); |
| 747 | + |
728 | 748 | engine = qcom_ice_create(&pdev->dev, base); |
729 | 749 | if (IS_ERR(engine)) |
730 | 750 | return PTR_ERR(engine); |
|
0 commit comments