Skip to content

Commit

Permalink
OMAP: McBSP: Add pm runtime support
Browse files Browse the repository at this point in the history
Add pm runtime support for McBSP driver.
Reference to fclk is not removed because it is required when the
functional clock is switched from one source to another.

Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Acked-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Jarkko Nikula <jhnikula@gmail.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Kishon Vijay Abraham I authored and Tony Lindgren committed Feb 24, 2011
1 parent f36d01d commit e95496d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
5 changes: 3 additions & 2 deletions arch/arm/mach-omap2/mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <plat/cpu.h>
#include <plat/mcbsp.h>
#include <plat/omap_device.h>
#include <linux/pm_runtime.h>

#include "control.h"

Expand Down Expand Up @@ -83,7 +84,7 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id)
return -EINVAL;
}

clk_disable(mcbsp->fclk);
pm_runtime_put_sync(mcbsp->dev);

r = clk_set_parent(mcbsp->fclk, fck_src);
if (IS_ERR_VALUE(r)) {
Expand All @@ -93,7 +94,7 @@ int omap2_mcbsp_set_clks_src(u8 id, u8 fck_src_id)
return -EINVAL;
}

clk_enable(mcbsp->fclk);
pm_runtime_get_sync(mcbsp->dev);

clk_put(fck_src);

Expand Down
1 change: 0 additions & 1 deletion arch/arm/plat-omap/include/plat/mcbsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ struct omap_mcbsp {
/* Protect the field .free, while checking if the mcbsp is in use */
spinlock_t lock;
struct omap_mcbsp_platform_data *pdata;
struct clk *iclk;
struct clk *fclk;
#ifdef CONFIG_ARCH_OMAP3
struct omap_mcbsp_st_data *st_data;
Expand Down
23 changes: 6 additions & 17 deletions arch/arm/plat-omap/mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <plat/dma.h>
#include <plat/mcbsp.h>
#include <plat/omap_device.h>
#include <linux/pm_runtime.h>

/* XXX These "sideways" includes are a sign that something is wrong */
#include "../mach-omap2/cm2xxx_3xxx.h"
Expand Down Expand Up @@ -757,8 +758,7 @@ int omap_mcbsp_request(unsigned int id)
if (mcbsp->pdata && mcbsp->pdata->ops && mcbsp->pdata->ops->request)
mcbsp->pdata->ops->request(id);

clk_enable(mcbsp->iclk);
clk_enable(mcbsp->fclk);
pm_runtime_get_sync(mcbsp->dev);

/* Do procedure specific to omap34xx arch, if applicable */
omap34xx_mcbsp_request(mcbsp);
Expand Down Expand Up @@ -806,8 +806,7 @@ int omap_mcbsp_request(unsigned int id)
/* Do procedure specific to omap34xx arch, if applicable */
omap34xx_mcbsp_free(mcbsp);

clk_disable(mcbsp->fclk);
clk_disable(mcbsp->iclk);
pm_runtime_put_sync(mcbsp->dev);

spin_lock(&mcbsp->lock);
mcbsp->free = true;
Expand Down Expand Up @@ -837,8 +836,7 @@ void omap_mcbsp_free(unsigned int id)
/* Do procedure specific to omap34xx arch, if applicable */
omap34xx_mcbsp_free(mcbsp);

clk_disable(mcbsp->fclk);
clk_disable(mcbsp->iclk);
pm_runtime_put_sync(mcbsp->dev);

if (mcbsp->io_type == OMAP_MCBSP_IRQ_IO) {
/* Free IRQs */
Expand Down Expand Up @@ -1827,32 +1825,24 @@ static int __devinit omap_mcbsp_probe(struct platform_device *pdev)
}
mcbsp->dma_tx_sync = res->start;

mcbsp->iclk = clk_get(&pdev->dev, "ick");
if (IS_ERR(mcbsp->iclk)) {
ret = PTR_ERR(mcbsp->iclk);
dev_err(&pdev->dev, "unable to get ick: %d\n", ret);
goto err_res;
}

mcbsp->fclk = clk_get(&pdev->dev, "fck");
if (IS_ERR(mcbsp->fclk)) {
ret = PTR_ERR(mcbsp->fclk);
dev_err(&pdev->dev, "unable to get fck: %d\n", ret);
goto err_fclk;
goto err_res;
}

mcbsp->pdata = pdata;
mcbsp->dev = &pdev->dev;
mcbsp_ptr[id] = mcbsp;
platform_set_drvdata(pdev, mcbsp);
pm_runtime_enable(mcbsp->dev);

/* Initialize mcbsp properties for OMAP34XX if needed / applicable */
omap34xx_device_init(mcbsp);

return 0;

err_fclk:
clk_put(mcbsp->iclk);
err_res:
iounmap(mcbsp->io_base);
err_ioremap:
Expand All @@ -1875,7 +1865,6 @@ static int __devexit omap_mcbsp_remove(struct platform_device *pdev)
omap34xx_device_exit(mcbsp);

clk_put(mcbsp->fclk);
clk_put(mcbsp->iclk);

iounmap(mcbsp->io_base);
kfree(mcbsp);
Expand Down

0 comments on commit e95496d

Please sign in to comment.