aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto
diff options
context:
space:
mode:
authorMark A. Greer <mgreer@animalcreek.com>2012-12-21 12:04:02 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2013-01-05 05:43:56 -0500
commitb359f034c8bf6c6ae4785c1172786ce73eccf9f2 (patch)
tree5da7872e7fa88e34b7552abef88cfa16704068bf /drivers/crypto
parent3ff59bcee7be7796ce566dfef0604eda013cc8c2 (diff)
crypto: omap-sham - Convert to use pm_runtime API
Convert the omap-sham crypto driver to use the pm_runtime API instead of the clk API. CC: Kevin Hilman <khilman@deeprootsystems.com> CC: Dmitry Kasatkin <dmitry.kasatkin@intel.com> Signed-off-by: Mark A. Greer <mgreer@animalcreek.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto')
-rw-r--r--drivers/crypto/omap-sham.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/drivers/crypto/omap-sham.c b/drivers/crypto/omap-sham.c
index 2df7a54fc3b9..777eb9fdd096 100644
--- a/drivers/crypto/omap-sham.c
+++ b/drivers/crypto/omap-sham.c
@@ -22,12 +22,12 @@
22#include <linux/errno.h> 22#include <linux/errno.h>
23#include <linux/interrupt.h> 23#include <linux/interrupt.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/clk.h>
26#include <linux/irq.h> 25#include <linux/irq.h>
27#include <linux/io.h> 26#include <linux/io.h>
28#include <linux/platform_device.h> 27#include <linux/platform_device.h>
29#include <linux/scatterlist.h> 28#include <linux/scatterlist.h>
30#include <linux/dma-mapping.h> 29#include <linux/dma-mapping.h>
30#include <linux/pm_runtime.h>
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/crypto.h> 32#include <linux/crypto.h>
33#include <linux/cryptohash.h> 33#include <linux/cryptohash.h>
@@ -140,7 +140,6 @@ struct omap_sham_dev {
140 struct device *dev; 140 struct device *dev;
141 void __iomem *io_base; 141 void __iomem *io_base;
142 int irq; 142 int irq;
143 struct clk *iclk;
144 spinlock_t lock; 143 spinlock_t lock;
145 int err; 144 int err;
146 int dma; 145 int dma;
@@ -237,7 +236,7 @@ static void omap_sham_copy_ready_hash(struct ahash_request *req)
237 236
238static int omap_sham_hw_init(struct omap_sham_dev *dd) 237static int omap_sham_hw_init(struct omap_sham_dev *dd)
239{ 238{
240 clk_enable(dd->iclk); 239 pm_runtime_get_sync(dd->dev);
241 240
242 if (!test_bit(FLAGS_INIT, &dd->flags)) { 241 if (!test_bit(FLAGS_INIT, &dd->flags)) {
243 omap_sham_write_mask(dd, SHA_REG_MASK, 242 omap_sham_write_mask(dd, SHA_REG_MASK,
@@ -652,7 +651,8 @@ static void omap_sham_finish_req(struct ahash_request *req, int err)
652 /* atomic operation is not needed here */ 651 /* atomic operation is not needed here */
653 dd->flags &= ~(BIT(FLAGS_BUSY) | BIT(FLAGS_FINAL) | BIT(FLAGS_CPU) | 652 dd->flags &= ~(BIT(FLAGS_BUSY) | BIT(FLAGS_FINAL) | BIT(FLAGS_CPU) |
654 BIT(FLAGS_DMA_READY) | BIT(FLAGS_OUTPUT_READY)); 653 BIT(FLAGS_DMA_READY) | BIT(FLAGS_OUTPUT_READY));
655 clk_disable(dd->iclk); 654
655 pm_runtime_put_sync(dd->dev);
656 656
657 if (req->base.complete) 657 if (req->base.complete)
658 req->base.complete(&req->base, err); 658 req->base.complete(&req->base, err);
@@ -1197,14 +1197,6 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
1197 if (err) 1197 if (err)
1198 goto dma_err; 1198 goto dma_err;
1199 1199
1200 /* Initializing the clock */
1201 dd->iclk = clk_get(dev, "ick");
1202 if (IS_ERR(dd->iclk)) {
1203 dev_err(dev, "clock intialization failed.\n");
1204 err = PTR_ERR(dd->iclk);
1205 goto clk_err;
1206 }
1207
1208 dd->io_base = ioremap(dd->phys_base, SZ_4K); 1200 dd->io_base = ioremap(dd->phys_base, SZ_4K);
1209 if (!dd->io_base) { 1201 if (!dd->io_base) {
1210 dev_err(dev, "can't ioremap\n"); 1202 dev_err(dev, "can't ioremap\n");
@@ -1212,11 +1204,14 @@ static int __devinit omap_sham_probe(struct platform_device *pdev)
1212 goto io_err; 1204 goto io_err;
1213 } 1205 }
1214 1206
1215 clk_enable(dd->iclk); 1207 pm_runtime_enable(dev);
1208 pm_runtime_get_sync(dev);
1209
1216 dev_info(dev, "hw accel on OMAP rev %u.%u\n", 1210 dev_info(dev, "hw accel on OMAP rev %u.%u\n",
1217 (omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MAJOR) >> 4, 1211 (omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MAJOR) >> 4,
1218 omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MINOR); 1212 omap_sham_read(dd, SHA_REG_REV) & SHA_REG_REV_MINOR);
1219 clk_disable(dd->iclk); 1213
1214 pm_runtime_put_sync(&pdev->dev);
1220 1215
1221 spin_lock(&sham.lock); 1216 spin_lock(&sham.lock);
1222 list_add_tail(&dd->list, &sham.dev_list); 1217 list_add_tail(&dd->list, &sham.dev_list);
@@ -1234,9 +1229,8 @@ err_algs:
1234 for (j = 0; j < i; j++) 1229 for (j = 0; j < i; j++)
1235 crypto_unregister_ahash(&algs[j]); 1230 crypto_unregister_ahash(&algs[j]);
1236 iounmap(dd->io_base); 1231 iounmap(dd->io_base);
1232 pm_runtime_disable(dev);
1237io_err: 1233io_err:
1238 clk_put(dd->iclk);
1239clk_err:
1240 omap_sham_dma_cleanup(dd); 1234 omap_sham_dma_cleanup(dd);
1241dma_err: 1235dma_err:
1242 if (dd->irq >= 0) 1236 if (dd->irq >= 0)
@@ -1265,7 +1259,7 @@ static int __devexit omap_sham_remove(struct platform_device *pdev)
1265 crypto_unregister_ahash(&algs[i]); 1259 crypto_unregister_ahash(&algs[i]);
1266 tasklet_kill(&dd->done_task); 1260 tasklet_kill(&dd->done_task);
1267 iounmap(dd->io_base); 1261 iounmap(dd->io_base);
1268 clk_put(dd->iclk); 1262 pm_runtime_disable(&pdev->dev);
1269 omap_sham_dma_cleanup(dd); 1263 omap_sham_dma_cleanup(dd);
1270 if (dd->irq >= 0) 1264 if (dd->irq >= 0)
1271 free_irq(dd->irq, dd); 1265 free_irq(dd->irq, dd);