hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/crypto/ccree/cc_pm.c
....@@ -1,5 +1,5 @@
11 // SPDX-License-Identifier: GPL-2.0
2
-/* Copyright (C) 2012-2018 ARM Limited or its affiliates. */
2
+/* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
33
44 #include <linux/kernel.h>
55 #include <linux/interrupt.h>
....@@ -8,7 +8,6 @@
88 #include "cc_buffer_mgr.h"
99 #include "cc_request_mgr.h"
1010 #include "cc_sram_mgr.h"
11
-#include "cc_ivgen.h"
1211 #include "cc_hash.h"
1312 #include "cc_pm.h"
1413 #include "cc_fips.h"
....@@ -16,32 +15,33 @@
1615 #define POWER_DOWN_ENABLE 0x01
1716 #define POWER_DOWN_DISABLE 0x00
1817
19
-const struct dev_pm_ops ccree_pm = {
20
- SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
21
-};
22
-
23
-int cc_pm_suspend(struct device *dev)
18
+static int cc_pm_suspend(struct device *dev)
2419 {
2520 struct cc_drvdata *drvdata = dev_get_drvdata(dev);
2621
2722 dev_dbg(dev, "set HOST_POWER_DOWN_EN\n");
2823 fini_cc_regs(drvdata);
2924 cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE);
30
- cc_clk_off(drvdata);
25
+ clk_disable_unprepare(drvdata->clk);
3126 return 0;
3227 }
3328
34
-int cc_pm_resume(struct device *dev)
29
+static int cc_pm_resume(struct device *dev)
3530 {
3631 int rc;
3732 struct cc_drvdata *drvdata = dev_get_drvdata(dev);
3833
3934 dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n");
4035 /* Enables the device source clk */
41
- rc = cc_clk_on(drvdata);
36
+ rc = clk_prepare_enable(drvdata->clk);
4237 if (rc) {
4338 dev_err(dev, "failed getting clock back on. We're toast.\n");
4439 return rc;
40
+ }
41
+ /* wait for Cryptocell reset completion */
42
+ if (!cc_wait_for_reset_completion(drvdata)) {
43
+ dev_err(dev, "Cryptocell reset not completed");
44
+ return -EBUSY;
4545 }
4646
4747 cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE);
....@@ -55,54 +55,26 @@
5555
5656 cc_init_hash_sram(drvdata);
5757
58
- cc_init_iv_sram(drvdata);
5958 return 0;
6059 }
6160
61
+const struct dev_pm_ops ccree_pm = {
62
+ SET_RUNTIME_PM_OPS(cc_pm_suspend, cc_pm_resume, NULL)
63
+};
64
+
6265 int cc_pm_get(struct device *dev)
6366 {
64
- int rc = 0;
65
- struct cc_drvdata *drvdata = dev_get_drvdata(dev);
66
-
67
- if (drvdata->pm_on)
68
- rc = pm_runtime_get_sync(dev);
69
-
70
- return (rc == 1 ? 0 : rc);
71
-}
72
-
73
-int cc_pm_put_suspend(struct device *dev)
74
-{
75
- int rc = 0;
76
- struct cc_drvdata *drvdata = dev_get_drvdata(dev);
77
-
78
- if (drvdata->pm_on) {
79
- pm_runtime_mark_last_busy(dev);
80
- rc = pm_runtime_put_autosuspend(dev);
67
+ int rc = pm_runtime_get_sync(dev);
68
+ if (rc < 0) {
69
+ pm_runtime_put_noidle(dev);
70
+ return rc;
8171 }
8272
83
- return rc;
73
+ return 0;
8474 }
8575
86
-int cc_pm_init(struct cc_drvdata *drvdata)
76
+void cc_pm_put_suspend(struct device *dev)
8777 {
88
- struct device *dev = drvdata_to_dev(drvdata);
89
-
90
- /* must be before the enabling to avoid resdundent suspending */
91
- pm_runtime_set_autosuspend_delay(dev, CC_SUSPEND_TIMEOUT);
92
- pm_runtime_use_autosuspend(dev);
93
- /* set us as active - note we won't do PM ops until cc_pm_go()! */
94
- return pm_runtime_set_active(dev);
95
-}
96
-
97
-/* enable the PM module*/
98
-void cc_pm_go(struct cc_drvdata *drvdata)
99
-{
100
- pm_runtime_enable(drvdata_to_dev(drvdata));
101
- drvdata->pm_on = true;
102
-}
103
-
104
-void cc_pm_fini(struct cc_drvdata *drvdata)
105
-{
106
- pm_runtime_disable(drvdata_to_dev(drvdata));
107
- drvdata->pm_on = false;
78
+ pm_runtime_mark_last_busy(dev);
79
+ pm_runtime_put_autosuspend(dev);
10880 }