Skip to content

Commit a15636e

Browse files
andy-shevVinod Koul
authored andcommitted
dmaengine: dw: move clock operations to platform.c
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@intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
1 parent 4d130de commit a15636e

4 files changed

Lines changed: 24 additions & 20 deletions

File tree

‎drivers/dma/dw/core.c‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
*/
1212

1313
#include <linux/bitops.h>
14-
#include <linux/clk.h>
1514
#include <linux/delay.h>
1615
#include <linux/dmaengine.h>
1716
#include <linux/dma-mapping.h>
@@ -1488,13 +1487,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
14881487
dw->regs = chip->regs;
14891488
chip->dw = dw;
14901489

1491-
dw->clk = devm_clk_get(chip->dev, "hclk");
1492-
if (IS_ERR(dw->clk))
1493-
return PTR_ERR(dw->clk);
1494-
err = clk_prepare_enable(dw->clk);
1495-
if (err)
1496-
return err;
1497-
14981490
dw_params = dma_read_byaddr(chip->regs, DW_PARAMS);
14991491
autocfg = dw_params >> DW_PARAMS_EN & 0x1;
15001492

@@ -1665,7 +1657,6 @@ int dw_dma_probe(struct dw_dma_chip *chip, struct dw_dma_platform_data *pdata)
16651657
err_dma_register:
16661658
free_irq(chip->irq, dw);
16671659
err_pdata:
1668-
clk_disable_unprepare(dw->clk);
16691660
return err;
16701661
}
16711662
EXPORT_SYMBOL_GPL(dw_dma_probe);
@@ -1687,8 +1678,6 @@ int dw_dma_remove(struct dw_dma_chip *chip)
16871678
channel_clear_bit(dw, CH_EN, dwc->mask);
16881679
}
16891680

1690-
clk_disable_unprepare(dw->clk);
1691-
16921681
return 0;
16931682
}
16941683
EXPORT_SYMBOL_GPL(dw_dma_remove);
@@ -1698,7 +1687,6 @@ void dw_dma_shutdown(struct dw_dma_chip *chip)
16981687
struct dw_dma *dw = chip->dw;
16991688

17001689
dw_dma_off(dw);
1701-
clk_disable_unprepare(dw->clk);
17021690
}
17031691
EXPORT_SYMBOL_GPL(dw_dma_shutdown);
17041692

@@ -1709,8 +1697,6 @@ int dw_dma_suspend(struct dw_dma_chip *chip)
17091697
struct dw_dma *dw = chip->dw;
17101698

17111699
dw_dma_off(dw);
1712-
clk_disable_unprepare(dw->clk);
1713-
17141700
return 0;
17151701
}
17161702
EXPORT_SYMBOL_GPL(dw_dma_suspend);
@@ -1719,9 +1705,7 @@ int dw_dma_resume(struct dw_dma_chip *chip)
17191705
{
17201706
struct dw_dma *dw = chip->dw;
17211707

1722-
clk_prepare_enable(dw->clk);
17231708
dma_writel(dw, CFG, DW_CFG_DMA_EN);
1724-
17251709
return 0;
17261710
}
17271711
EXPORT_SYMBOL_GPL(dw_dma_resume);

‎drivers/dma/dw/internal.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@
2121
* @dev: struct device of the DMA controller
2222
* @irq: irq line
2323
* @regs: memory mapped I/O space
24+
* @clk: hclk clock
2425
* @dw: struct dw_dma that is filed by dw_dma_probe()
2526
*/
2627
struct dw_dma_chip {
2728
struct device *dev;
2829
int irq;
2930
void __iomem *regs;
31+
struct clk *clk;
3032
struct dw_dma *dw;
3133
};
3234

‎drivers/dma/dw/platform.c‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,17 @@ static int dw_probe(struct platform_device *pdev)
178178

179179
chip->dev = dev;
180180

181-
err = dw_dma_probe(chip, pdata);
181+
chip->clk = devm_clk_get(chip->dev, "hclk");
182+
if (IS_ERR(chip->clk))
183+
return PTR_ERR(chip->clk);
184+
err = clk_prepare_enable(chip->clk);
182185
if (err)
183186
return err;
184187

188+
err = dw_dma_probe(chip, pdata);
189+
if (err)
190+
goto err_dw_dma_probe;
191+
185192
platform_set_drvdata(pdev, chip);
186193

187194
if (pdev->dev.of_node) {
@@ -196,6 +203,10 @@ static int dw_probe(struct platform_device *pdev)
196203
dw_dma_acpi_controller_register(chip->dw);
197204

198205
return 0;
206+
207+
err_dw_dma_probe:
208+
clk_disable_unprepare(chip->clk);
209+
return err;
199210
}
200211

201212
static int dw_remove(struct platform_device *pdev)
@@ -205,14 +216,18 @@ static int dw_remove(struct platform_device *pdev)
205216
if (pdev->dev.of_node)
206217
of_dma_controller_free(pdev->dev.of_node);
207218

208-
return dw_dma_remove(chip);
219+
dw_dma_remove(chip);
220+
clk_disable_unprepare(chip->clk);
221+
222+
return 0;
209223
}
210224

211225
static void dw_shutdown(struct platform_device *pdev)
212226
{
213227
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
214228

215229
dw_dma_shutdown(chip);
230+
clk_disable_unprepare(chip->clk);
216231
}
217232

218233
#ifdef CONFIG_OF
@@ -238,14 +253,18 @@ static int dw_suspend_late(struct device *dev)
238253
struct platform_device *pdev = to_platform_device(dev);
239254
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
240255

241-
return dw_dma_suspend(chip);
256+
dw_dma_suspend(chip);
257+
clk_disable_unprepare(chip->clk);
258+
259+
return 0;
242260
}
243261

244262
static int dw_resume_early(struct device *dev)
245263
{
246264
struct platform_device *pdev = to_platform_device(dev);
247265
struct dw_dma_chip *chip = platform_get_drvdata(pdev);
248266

267+
clk_prepare_enable(chip->clk);
249268
return dw_dma_resume(chip);
250269
}
251270

‎drivers/dma/dw/regs.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,6 @@ struct dw_dma {
251251
void __iomem *regs;
252252
struct dma_pool *desc_pool;
253253
struct tasklet_struct tasklet;
254-
struct clk *clk;
255254

256255
/* channels */
257256
struct dw_dma_chan *chan;

0 commit comments

Comments
 (0)