summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMisael Lopez Cruz <misael.lopez@ti.com>2011-04-07 08:39:16 +0100
committerAndy Green <andy.green@linaro.org>2011-04-07 08:39:16 +0100
commit3691e8d2e526c12f11281d0198bc3775e6c7c049 (patch)
tree7d7376bc7cf35de5124b8b2ae7aa78ed26d32f70 /sound
parent1d812887a8cc83cd7b8455b1af2ff37127090d9c (diff)
ASoC: McPDM: Convert to pm_runtime framework
Convert McPDM driver to pm_runtime framework. Change-Id: Ibdcb43ee70c6dbbdb3eec606e3c14e014ada15f2 Signed-off-by: Jorge Eduardo Candelaria <jorge.candelaria@ti.com> Signed-off-by: Margarita Olaya Cabrera <magi.olaya@ti.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/omap/omap-mcpdm.c53
1 files changed, 23 insertions, 30 deletions
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c
index 145871f2045..e8715b06ad2 100644
--- a/sound/soc/omap/omap-mcpdm.c
+++ b/sound/soc/omap/omap-mcpdm.c
@@ -33,6 +33,7 @@
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/slab.h>
+#include <linux/pm_runtime.h>
#include <sound/core.h>
#include <sound/pcm.h>
@@ -43,6 +44,7 @@
#include <plat/dma.h>
#include <plat/mcpdm.h>
#include <plat/mcbsp.h>
+#include <plat/omap_hwmod.h>
#include "omap-mcpdm.h"
#include "omap-pcm.h"
@@ -388,11 +390,10 @@ static int omap_mcpdm_request(struct omap_mcpdm *mcpdm)
int ret;
int ctrl;
- pdev = container_of(mcpdm->dev, struct platform_device, dev);
+ pdev = to_platform_device(mcpdm->dev);
pdata = pdev->dev.platform_data;
- if (pdata->device_enable)
- pdata->device_enable(pdev);
+ pm_runtime_get_sync(&pdev->dev);
spin_lock(&mcpdm->lock);
@@ -426,8 +427,7 @@ static int omap_mcpdm_request(struct omap_mcpdm *mcpdm)
return 0;
err:
- if (pdata->device_idle)
- pdata->device_idle(pdev);
+ pm_runtime_put_sync(&pdev->dev);
return ret;
}
@@ -448,8 +448,7 @@ static void omap_mcpdm_free(struct omap_mcpdm *mcpdm)
mcpdm->free = 1;
spin_unlock(&mcpdm->lock);
- if (pdata->device_idle)
- pdata->device_idle(pdev);
+ pm_runtime_put_sync(&pdev->dev);
free_irq(mcpdm->irq, (void *)mcpdm);
}
@@ -619,50 +618,48 @@ static struct snd_soc_dai_driver omap_mcpdm_dai = {
static __devinit int asoc_mcpdm_probe(struct platform_device *pdev)
{
struct omap_mcpdm *mcpdm;
- struct resource *res;
+ struct omap_hwmod *oh;
int ret = 0;
- mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL);
- if (!mcpdm) {
- ret = -ENOMEM;
- goto exit;
+ oh = omap_hwmod_lookup("omap-mcpdm-dai");
+ if (oh == NULL) {
+ dev_err(&pdev->dev, "no hwmod device found\n");
+ return -ENODEV;
}
+
+ mcpdm = kzalloc(sizeof(struct omap_mcpdm), GFP_KERNEL);
+ if (!mcpdm)
+ return -ENOMEM;
+
platform_set_drvdata(pdev, mcpdm);
mcpdm->downlink = &omap_mcpdm_links[0];
mcpdm->uplink = &omap_mcpdm_links[1];
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (res == NULL) {
- dev_err(&pdev->dev, "no resource\n");
- goto err_resource;
- }
-
spin_lock_init(&mcpdm->lock);
mcpdm->free = 1;
- mcpdm->io_base = ioremap(res->start, resource_size(res));
+ mcpdm->io_base = omap_hwmod_get_mpu_rt_va(oh);
if (!mcpdm->io_base) {
ret = -ENOMEM;
- goto err_resource;
+ goto err;
}
mcpdm->irq = platform_get_irq(pdev, 0);
if (mcpdm->irq < 0) {
ret = mcpdm->irq;
- goto err_irq;
+ goto err;
}
+ pm_runtime_enable(&pdev->dev);
+
mcpdm->dev = &pdev->dev;
ret = snd_soc_register_dai(&pdev->dev, &omap_mcpdm_dai);
if (ret == 0)
return 0;
-err_irq:
- iounmap(mcpdm->io_base);
-err_resource:
+err:
kfree(mcpdm);
-exit:
return ret;
}
@@ -671,11 +668,7 @@ static int __devexit asoc_mcpdm_remove(struct platform_device *pdev)
struct omap_mcpdm *mcpdm = platform_get_drvdata(pdev);
snd_soc_unregister_dai(&pdev->dev);
-
- if (pdata->device_shutdown)
- pdata->device_shutdown(pdev);
- iounmap(mcpdm->io_base);
-
+ pm_runtime_put_sync(&pdev->dev);
kfree(mcpdm);
return 0;
}