]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00177241-2 mx6 close APBH DMA clock when no I/O operation
authorAllen Xu <allen.xu@freescale.com>
Tue, 10 Apr 2012 03:37:37 +0000 (11:37 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:24 +0000 (08:34 +0200)
When there is no NAND I/O operation, close all the reference
clock, include GPMI,BCH and APBH clock.

Signed-off-by: Allen Xu <allen.xu@freescale.com>
drivers/mtd/nand/gpmi-nand/gpmi-lib.c

index 698535773ff4e23b7190a2ee82b13e49719cadae..e87b2026fc87408fed2540e82486f5e14c745200 100644 (file)
 #include <linux/delay.h>
 #include <linux/clk.h>
 #include <mach/mxs.h>
+#include <mach/clock.h>
 
 #include "gpmi-nand.h"
 #include "gpmi-regs.h"
 #include "bch-regs.h"
 
+static struct clk *mxs_dma_clk;
+
 struct timing_threshod timing_default_threshold = {
        .max_data_setup_cycles       = (BM_GPMI_TIMING0_DATA_SETUP >>
                                                BP_GPMI_TIMING0_DATA_SETUP),
@@ -128,6 +131,12 @@ int gpmi_init(struct gpmi_nand_data *this)
        struct resources *r = &this->resources;
        int ret;
 
+       mxs_dma_clk = clk_get(NULL, "mxs-dma-apbh");
+       if (IS_ERR(mxs_dma_clk)) {
+               pr_err("can not get the dma clock\n");
+               ret = -ENOENT;
+               goto err_out;
+       }
        ret = clk_prepare_enable(r->clock);
        if (ret)
                goto err_out;
@@ -719,6 +728,13 @@ void gpmi_begin(struct gpmi_nand_data *this)
                pr_err("We failed in enable the clk\n");
                goto err_out;
        }
+       if (!clk_get_usecount(mxs_dma_clk)) {
+               ret = clk_prepare_enable(mxs_dma_clk);
+               if (ret) {
+                       pr_err("We failed in enable the dma clk\n");
+                       goto err_out;
+               }
+       }
 
        /* set ready/busy timeout */
        writel(0x500 << BP_GPMI_TIMING1_BUSY_TIMEOUT,
@@ -784,6 +800,8 @@ void gpmi_end(struct gpmi_nand_data *this)
 {
        struct resources *r = &this->resources;
        clk_disable_unprepare(r->clock);
+       if (clk_get_usecount(mxs_dma_clk))
+               clk_disable_unprepare(mxs_dma_clk);
 }
 
 /* Clears a BCH interrupt. */