]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ENGR00179497-1 ECSPI: disable ecspi clock after probe and spi transfer
authorRobin Gong <B38343@freescale.com>
Thu, 12 Apr 2012 06:40:42 +0000 (14:40 +0800)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 24 May 2013 06:34:25 +0000 (08:34 +0200)
before, it enable spi clock after probe, never been disable unless driver
removed. To reduce power, disable clock after probe, and enable it before
every spi transfer and disable it after spi transfer
Signed-off-by: Robin Gong <B38343@freescale.com>
drivers/spi/spi_imx.c

index eba76009595611e676612f47ccfb8364cc98abce..be58e17dc52629bdc82e9d5c1f0ea92c8285c90c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2007, 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc. All Rights Reserved.
  * Copyright (C) 2008 Juergen Beisert
  *
  * This program is free software; you can redistribute it and/or
@@ -652,6 +652,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
        struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
        struct spi_imx_config config;
 
+       clk_enable(spi_imx->clk);
        config.bpw = t ? t->bits_per_word : spi->bits_per_word;
        config.speed_hz  = t ? t->speed_hz : spi->max_speed_hz;
        config.mode = spi->mode;
@@ -678,7 +679,7 @@ static int spi_imx_setupxfer(struct spi_device *spi,
                BUG();
 
        spi_imx->devtype_data.config(spi_imx, &config);
-
+       clk_disable(spi_imx->clk);
        return 0;
 }
 
@@ -687,6 +688,7 @@ static int spi_imx_transfer(struct spi_device *spi,
 {
        struct spi_imx_data *spi_imx = spi_master_get_devdata(spi->master);
 
+       clk_enable(spi_imx->clk);
        spi_imx->tx_buf = transfer->tx_buf;
        spi_imx->rx_buf = transfer->rx_buf;
        spi_imx->count = transfer->len;
@@ -699,6 +701,7 @@ static int spi_imx_transfer(struct spi_device *spi,
        spi_imx->devtype_data.intctrl(spi_imx, MXC_INT_TE);
 
        wait_for_completion(&spi_imx->xfer_done);
+       clk_disable(spi_imx->clk);
 
        return transfer->len;
 }
@@ -863,12 +866,12 @@ static int __devinit spi_imx_probe(struct platform_device *pdev)
        spi_imx->devtype_data.reset(spi_imx);
 
        spi_imx->devtype_data.intctrl(spi_imx, 0);
-
        ret = spi_bitbang_start(&spi_imx->bitbang);
        if (ret) {
                dev_err(&pdev->dev, "bitbang start failed with %d\n", ret);
                goto out_clk_put;
        }
+       clk_disable(spi_imx->clk);
 
        dev_info(&pdev->dev, "probed\n");
 
@@ -902,7 +905,7 @@ static int __devexit spi_imx_remove(struct platform_device *pdev)
        int i;
 
        spi_bitbang_stop(&spi_imx->bitbang);
-
+       clk_enable(spi_imx->clk);
        writel(0, spi_imx->base + MXC_CSPICTRL);
        clk_disable(spi_imx->clk);
        clk_put(spi_imx->clk);