diff options
Diffstat (limited to 'sound/soc/omap/mcpdm.c')
-rw-r--r-- | sound/soc/omap/mcpdm.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/sound/soc/omap/mcpdm.c b/sound/soc/omap/mcpdm.c index 928f03707451..d29cc982b562 100644 --- a/sound/soc/omap/mcpdm.c +++ b/sound/soc/omap/mcpdm.c | |||
@@ -28,7 +28,7 @@ | |||
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/err.h> | 30 | #include <linux/err.h> |
31 | #include <linux/clk.h> | 31 | #include <linux/pm_runtime.h> |
32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
33 | #include <linux/io.h> | 33 | #include <linux/io.h> |
34 | #include <linux/irq.h> | 34 | #include <linux/irq.h> |
@@ -322,11 +322,11 @@ static irqreturn_t omap_mcpdm_irq_handler(int irq, void *dev_id) | |||
322 | return IRQ_HANDLED; | 322 | return IRQ_HANDLED; |
323 | } | 323 | } |
324 | 324 | ||
325 | int omap_mcpdm_request(void) | 325 | int omap_mcpdm_request(void) |
326 | { | 326 | { |
327 | int ret; | 327 | int ret; |
328 | 328 | ||
329 | clk_enable(mcpdm->clk); | 329 | pm_runtime_get_sync(mcpdm->dev); |
330 | 330 | ||
331 | spin_lock(&mcpdm->lock); | 331 | spin_lock(&mcpdm->lock); |
332 | 332 | ||
@@ -353,7 +353,8 @@ int omap_mcpdm_request(void) | |||
353 | return 0; | 353 | return 0; |
354 | 354 | ||
355 | err: | 355 | err: |
356 | clk_disable(mcpdm->clk); | 356 | mcpdm->free = 1; |
357 | pm_runtime_put_sync(mcpdm->dev); | ||
357 | return ret; | 358 | return ret; |
358 | } | 359 | } |
359 | 360 | ||
@@ -368,7 +369,7 @@ void omap_mcpdm_free(void) | |||
368 | mcpdm->free = 1; | 369 | mcpdm->free = 1; |
369 | spin_unlock(&mcpdm->lock); | 370 | spin_unlock(&mcpdm->lock); |
370 | 371 | ||
371 | clk_disable(mcpdm->clk); | 372 | pm_runtime_put_sync(mcpdm->dev); |
372 | 373 | ||
373 | free_irq(mcpdm->irq, (void *)mcpdm); | 374 | free_irq(mcpdm->irq, (void *)mcpdm); |
374 | } | 375 | } |
@@ -421,28 +422,29 @@ int __devinit omap_mcpdm_probe(struct platform_device *pdev) | |||
421 | 422 | ||
422 | spin_lock_init(&mcpdm->lock); | 423 | spin_lock_init(&mcpdm->lock); |
423 | mcpdm->free = 1; | 424 | mcpdm->free = 1; |
425 | |||
426 | if (!request_mem_region(res->start, resource_size(res), "McPDM")) { | ||
427 | ret = -EBUSY; | ||
428 | goto err_resource; | ||
429 | } | ||
430 | |||
424 | mcpdm->io_base = ioremap(res->start, resource_size(res)); | 431 | mcpdm->io_base = ioremap(res->start, resource_size(res)); |
425 | if (!mcpdm->io_base) { | 432 | if (!mcpdm->io_base) { |
426 | ret = -ENOMEM; | 433 | ret = -ENOMEM; |
427 | goto err_resource; | 434 | goto err_remap; |
428 | } | 435 | } |
429 | 436 | ||
430 | mcpdm->irq = platform_get_irq(pdev, 0); | 437 | mcpdm->irq = platform_get_irq(pdev, 0); |
431 | 438 | ||
432 | mcpdm->clk = clk_get(&pdev->dev, "pdm_ck"); | ||
433 | if (IS_ERR(mcpdm->clk)) { | ||
434 | ret = PTR_ERR(mcpdm->clk); | ||
435 | dev_err(&pdev->dev, "unable to get pdm_ck: %d\n", ret); | ||
436 | goto err_clk; | ||
437 | } | ||
438 | |||
439 | mcpdm->dev = &pdev->dev; | 439 | mcpdm->dev = &pdev->dev; |
440 | platform_set_drvdata(pdev, mcpdm); | 440 | platform_set_drvdata(pdev, mcpdm); |
441 | 441 | ||
442 | pm_runtime_enable(mcpdm->dev); | ||
443 | |||
442 | return 0; | 444 | return 0; |
443 | 445 | ||
444 | err_clk: | 446 | err_remap: |
445 | iounmap(mcpdm->io_base); | 447 | release_mem_region(res->start, resource_size(res)); |
446 | err_resource: | 448 | err_resource: |
447 | kfree(mcpdm); | 449 | kfree(mcpdm); |
448 | exit: | 450 | exit: |
@@ -452,14 +454,16 @@ exit: | |||
452 | int __devexit omap_mcpdm_remove(struct platform_device *pdev) | 454 | int __devexit omap_mcpdm_remove(struct platform_device *pdev) |
453 | { | 455 | { |
454 | struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); | 456 | struct omap_mcpdm *mcpdm_ptr = platform_get_drvdata(pdev); |
457 | struct resource *res; | ||
455 | 458 | ||
456 | platform_set_drvdata(pdev, NULL); | 459 | platform_set_drvdata(pdev, NULL); |
457 | 460 | ||
458 | clk_put(mcpdm_ptr->clk); | 461 | pm_runtime_disable(mcpdm_ptr->dev); |
459 | 462 | ||
460 | iounmap(mcpdm_ptr->io_base); | 463 | iounmap(mcpdm_ptr->io_base); |
464 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
465 | release_mem_region(res->start, resource_size(res)); | ||
461 | 466 | ||
462 | mcpdm_ptr->clk = NULL; | ||
463 | mcpdm_ptr->free = 0; | 467 | mcpdm_ptr->free = 0; |
464 | mcpdm_ptr->dev = NULL; | 468 | mcpdm_ptr->dev = NULL; |
465 | 469 | ||