[linux-yocto] [PATCH 3/6] dmaengine: dw: move clock operations to platform.c
wan.ahmad.zainie.wan.mohamad at intel.com
wan.ahmad.zainie.wan.mohamad at intel.com
Mon Nov 16 18:54:17 PST 2015
From: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
On BayTrail platform DMA is not functional in the PCI mode, whereby it always
failed and exit at the point when it tries to get a clock. It causes the PCI
mode probe to exit with the error message:
dw_dmac_pci: probe of 0000:00:1e.0 failed with error -2
This patch moves clock operations to where it belongs to. Thus, the clock is
provided only in ACPI / non-PCI cases.
Reported-by: Chew, Chiau Ee <chiau.ee.chew at intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko at linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul at intel.com>
(cherry picked from commit a15636e83eb0dedefcb1221be729023e4c281748)
Conflicts:
drivers/dma/dw/core.c
- Backport to Kernel 3.10.61-ltsi. Make the patch apply but
retaining the essence of it which is to remove clk related
stuff out of core.c file.
Signed-off-by: Maurice Petallo <mauricex.r.petallo at intel.com>
Change-Id: Ia696de420231608cd820fd1e227191db71540a68
Reviewed-on: https://git-gar-1.devtools.intel.com/gerrit/4363
Reviewed-by: Wan Mohamad, Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad at intel.com>
---
drivers/dma/dw/core.c | 11 -----------
drivers/dma/dw/internal.h | 2 ++
drivers/dma/dw/platform.c | 25 ++++++++++++++++++++++---
drivers/dma/dw/regs.h | 1 -
4 files changed, 24 insertions(+), 15 deletions(-)
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 2896d16..384dc6f 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -11,7 +11,6 @@
*/
#include <linux/bitops.h>
-#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/dma-mapping.h>
@@ -1509,11 +1508,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
if (!dw)
return -ENOMEM;
- dw->clk = devm_clk_get(chip->dev, "hclk");
- if (IS_ERR(dw->clk))
- return PTR_ERR(dw->clk);
- clk_prepare_enable(dw->clk);
-
dw->regs = chip->regs;
chip->dw = dw;
@@ -1673,7 +1667,6 @@ void dw_dma_shutdown(struct dw_dma_chip *chip)
struct dw_dma *dw = chip->dw;
dw_dma_off(dw);
- clk_disable_unprepare(dw->clk);
}
EXPORT_SYMBOL_GPL(dw_dma_shutdown);
@@ -1684,8 +1677,6 @@ int dw_dma_suspend(struct dw_dma_chip *chip)
struct dw_dma *dw = chip->dw;
dw_dma_off(dw);
- clk_disable_unprepare(dw->clk);
-
return 0;
}
EXPORT_SYMBOL_GPL(dw_dma_suspend);
@@ -1694,9 +1685,7 @@ int dw_dma_resume(struct dw_dma_chip *chip)
{
struct dw_dma *dw = chip->dw;
- clk_prepare_enable(dw->clk);
dma_writel(dw, CFG, DW_CFG_DMA_EN);
-
return 0;
}
EXPORT_SYMBOL_GPL(dw_dma_resume);
diff --git a/drivers/dma/dw/internal.h b/drivers/dma/dw/internal.h
index 43cc1df..34eb09a 100644
--- a/drivers/dma/dw/internal.h
+++ b/drivers/dma/dw/internal.h
@@ -21,12 +21,14 @@
* @dev: struct device of the DMA controller
* @irq: irq line
* @regs: memory mapped I/O space
+ * @clk: hclk clock
* @dw: struct dw_dma that is filed by dw_dma_probe()
*/
struct dw_dma_chip {
struct device *dev;
int irq;
void __iomem *regs;
+ struct clk *clk;
struct dw_dma *dw;
};
diff --git a/drivers/dma/dw/platform.c b/drivers/dma/dw/platform.c
index 3b71768..047e776 100644
--- a/drivers/dma/dw/platform.c
+++ b/drivers/dma/dw/platform.c
@@ -205,10 +205,17 @@ static int dw_probe(struct platform_device *pdev)
chip->dev = dev;
- err = dw_dma_probe(chip, pdata);
+ chip->clk = devm_clk_get(chip->dev, "hclk");
+ if (IS_ERR(chip->clk))
+ return PTR_ERR(chip->clk);
+ err = clk_prepare_enable(chip->clk);
if (err)
return err;
+ err = dw_dma_probe(chip, pdata);
+ if (err)
+ goto err_dw_dma_probe;
+
platform_set_drvdata(pdev, chip);
if (pdev->dev.of_node) {
@@ -223,6 +230,10 @@ static int dw_probe(struct platform_device *pdev)
dw_dma_acpi_controller_register(chip->dw);
return 0;
+
+err_dw_dma_probe:
+ clk_disable_unprepare(chip->clk);
+ return err;
}
static int dw_remove(struct platform_device *pdev)
@@ -232,7 +243,10 @@ static int dw_remove(struct platform_device *pdev)
if (pdev->dev.of_node)
of_dma_controller_free(pdev->dev.of_node);
- return dw_dma_remove(chip);
+ dw_dma_remove(chip);
+ clk_disable_unprepare(chip->clk);
+
+ return 0;
}
static void dw_shutdown(struct platform_device *pdev)
@@ -240,6 +254,7 @@ static void dw_shutdown(struct platform_device *pdev)
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
dw_dma_shutdown(chip);
+ clk_disable_unprepare(chip->clk);
}
#ifdef CONFIG_OF
@@ -265,7 +280,10 @@ static int dw_suspend_noirq(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
- return dw_dma_suspend(chip);
+ dw_dma_suspend(chip);
+ clk_disable_unprepare(chip->clk);
+
+ return 0;
}
static int dw_resume_noirq(struct device *dev)
@@ -273,6 +291,7 @@ static int dw_resume_noirq(struct device *dev)
struct platform_device *pdev = to_platform_device(dev);
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
+ clk_prepare_enable(chip->clk);
return dw_dma_resume(chip);
}
diff --git a/drivers/dma/dw/regs.h b/drivers/dma/dw/regs.h
index 73df90d..10c3ffd 100644
--- a/drivers/dma/dw/regs.h
+++ b/drivers/dma/dw/regs.h
@@ -251,7 +251,6 @@ struct dw_dma {
void __iomem *regs;
struct dma_pool *desc_pool;
struct tasklet_struct tasklet;
- struct clk *clk;
u8 all_chan_mask;
--
1.9.1
More information about the linux-yocto
mailing list