[PATCH 2/2] ARM: Orion: mv_dma: Add support for clk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mv_dma needs the crypto clock. Some orion platforms support gating of the
clock.  If the clock exists enable/disable it as appropriate.

Signed-off-by: Simon Baatz <gmbnomis@xxxxxxxxx>
---
 arch/arm/mach-kirkwood/common.c |    1 +
 drivers/crypto/mv_dma.c         |   14 ++++++++++++++
 2 files changed, 15 insertions(+)

diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
index 560b920..e7bbc60 100644
--- a/arch/arm/mach-kirkwood/common.c
+++ b/arch/arm/mach-kirkwood/common.c
@@ -234,6 +234,7 @@ void __init kirkwood_clk_init(void)
 	orion_clkdev_add(NULL, "orion-ehci.0", usb0);
 	orion_clkdev_add(NULL, "orion_nand", runit);
 	orion_clkdev_add(NULL, "mvsdio", sdio);
+	orion_clkdev_add(NULL, "mv_tdma", crypto);
 	orion_clkdev_add(NULL, "mv_crypto", crypto);
 	orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".0", xor0);
 	orion_clkdev_add(NULL, MV_XOR_SHARED_NAME ".1", xor1);
diff --git a/drivers/crypto/mv_dma.c b/drivers/crypto/mv_dma.c
index 125dfee..9fdb7be 100644
--- a/drivers/crypto/mv_dma.c
+++ b/drivers/crypto/mv_dma.c
@@ -13,6 +13,7 @@
 #include <linux/dmapool.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/clk.h>
 #include <linux/slab.h>
 #include <linux/platform_device.h>
 
@@ -36,6 +37,7 @@ struct mv_dma_priv {
 	struct device *dev;
 	void __iomem *reg;
 	int irq;
+	struct clk *clk;
 	/* protecting the dma descriptors and stuff */
 	spinlock_t lock;
 	struct dma_desclist desclist;
@@ -292,6 +294,12 @@ static int mv_init_engine(struct platform_device *pdev,
 		goto out_unmap_reg;
 	}
 
+	/* Not all platforms can gate the clock, so it is not
+	   an error if the clock does not exists. */
+	tpg.clk = clk_get(&pdev->dev, NULL);
+	if (!IS_ERR(tpg.clk))
+		clk_prepare_enable(tpg.clk);
+
 	/* initialise DMA descriptor list */
 	if (init_dma_desclist(&tpg.desclist, tpg.dev,
 			sizeof(struct mv_dma_desc), MV_DMA_ALIGN, 0)) {
@@ -343,6 +351,12 @@ static int mv_remove(struct platform_device *pdev)
 	fini_dma_desclist(&tpg.desclist);
 	free_irq(tpg.irq, &tpg);
 	iounmap(tpg.reg);
+
+	if (!IS_ERR(tpg.clk)) {
+		clk_disable_unprepare(tpg.clk);
+		clk_put(tpg.clk);
+	}
+
 	tpg.dev = NULL;
 	return 0;
 }
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux