diff options
author | Paul Walmsley <paul@pwsan.com> | 2012-06-21 23:40:40 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2012-06-21 23:40:40 -0400 |
commit | c354a86484b61e32100eb94c1f3f0aa512958cee (patch) | |
tree | cb78c61596276677675b1a6c11437e2f37ff051d /drivers/w1 | |
parent | 96b1b29d37b0ca3ecd424a1fe301406cf525fc04 (diff) |
W1: OMAP HDQ1W: use runtime PM
Convert the OMAP HDQ driver to use runtime PM. Compile- and boot-tested,
but not tested in actual use.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: NeilBrown <neilb@suse.de>
Cc: Evgeniy Polyakov <zbr@ioremap.net>
Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
Tested-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/w1')
-rw-r--r-- | drivers/w1/masters/omap_hdq.c | 78 |
1 files changed, 13 insertions, 65 deletions
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c index 344db9c5ab88..291897c881be 100644 --- a/drivers/w1/masters/omap_hdq.c +++ b/drivers/w1/masters/omap_hdq.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/w1/masters/omap_hdq.c | 2 | * drivers/w1/masters/omap_hdq.c |
3 | * | 3 | * |
4 | * Copyright (C) 2007 Texas Instruments, Inc. | 4 | * Copyright (C) 2007,2012 Texas Instruments, Inc. |
5 | * | 5 | * |
6 | * This file is licensed under the terms of the GNU General Public License | 6 | * This file is licensed under the terms of the GNU General Public License |
7 | * version 2. This program is licensed "as is" without any warranty of any | 7 | * version 2. This program is licensed "as is" without any warranty of any |
@@ -14,9 +14,9 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/clk.h> | ||
18 | #include <linux/io.h> | 17 | #include <linux/io.h> |
19 | #include <linux/sched.h> | 18 | #include <linux/sched.h> |
19 | #include <linux/pm_runtime.h> | ||
20 | 20 | ||
21 | #include <asm/irq.h> | 21 | #include <asm/irq.h> |
22 | #include <mach/hardware.h> | 22 | #include <mach/hardware.h> |
@@ -61,8 +61,6 @@ struct hdq_data { | |||
61 | /* lock status update */ | 61 | /* lock status update */ |
62 | struct mutex hdq_mutex; | 62 | struct mutex hdq_mutex; |
63 | int hdq_usecount; | 63 | int hdq_usecount; |
64 | struct clk *hdq_ick; | ||
65 | struct clk *hdq_fck; | ||
66 | u8 hdq_irqstatus; | 64 | u8 hdq_irqstatus; |
67 | /* device lock */ | 65 | /* device lock */ |
68 | spinlock_t hdq_spinlock; | 66 | spinlock_t hdq_spinlock; |
@@ -419,17 +417,8 @@ static int omap_hdq_get(struct hdq_data *hdq_data) | |||
419 | hdq_data->hdq_usecount++; | 417 | hdq_data->hdq_usecount++; |
420 | try_module_get(THIS_MODULE); | 418 | try_module_get(THIS_MODULE); |
421 | if (1 == hdq_data->hdq_usecount) { | 419 | if (1 == hdq_data->hdq_usecount) { |
422 | if (clk_enable(hdq_data->hdq_ick)) { | 420 | |
423 | dev_dbg(hdq_data->dev, "Can not enable ick\n"); | 421 | pm_runtime_get_sync(hdq_data->dev); |
424 | ret = -ENODEV; | ||
425 | goto clk_err; | ||
426 | } | ||
427 | if (clk_enable(hdq_data->hdq_fck)) { | ||
428 | dev_dbg(hdq_data->dev, "Can not enable fck\n"); | ||
429 | clk_disable(hdq_data->hdq_ick); | ||
430 | ret = -ENODEV; | ||
431 | goto clk_err; | ||
432 | } | ||
433 | 422 | ||
434 | /* make sure HDQ is out of reset */ | 423 | /* make sure HDQ is out of reset */ |
435 | if (!(hdq_reg_in(hdq_data, OMAP_HDQ_SYSSTATUS) & | 424 | if (!(hdq_reg_in(hdq_data, OMAP_HDQ_SYSSTATUS) & |
@@ -450,9 +439,6 @@ static int omap_hdq_get(struct hdq_data *hdq_data) | |||
450 | } | 439 | } |
451 | } | 440 | } |
452 | 441 | ||
453 | clk_err: | ||
454 | clk_put(hdq_data->hdq_ick); | ||
455 | clk_put(hdq_data->hdq_fck); | ||
456 | out: | 442 | out: |
457 | mutex_unlock(&hdq_data->hdq_mutex); | 443 | mutex_unlock(&hdq_data->hdq_mutex); |
458 | rtn: | 444 | rtn: |
@@ -475,10 +461,8 @@ static int omap_hdq_put(struct hdq_data *hdq_data) | |||
475 | } else { | 461 | } else { |
476 | hdq_data->hdq_usecount--; | 462 | hdq_data->hdq_usecount--; |
477 | module_put(THIS_MODULE); | 463 | module_put(THIS_MODULE); |
478 | if (0 == hdq_data->hdq_usecount) { | 464 | if (0 == hdq_data->hdq_usecount) |
479 | clk_disable(hdq_data->hdq_ick); | 465 | pm_runtime_put_sync(hdq_data->dev); |
480 | clk_disable(hdq_data->hdq_fck); | ||
481 | } | ||
482 | } | 466 | } |
483 | mutex_unlock(&hdq_data->hdq_mutex); | 467 | mutex_unlock(&hdq_data->hdq_mutex); |
484 | 468 | ||
@@ -591,35 +575,11 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) | |||
591 | goto err_ioremap; | 575 | goto err_ioremap; |
592 | } | 576 | } |
593 | 577 | ||
594 | /* get interface & functional clock objects */ | ||
595 | hdq_data->hdq_ick = clk_get(&pdev->dev, "ick"); | ||
596 | if (IS_ERR(hdq_data->hdq_ick)) { | ||
597 | dev_dbg(&pdev->dev, "Can't get HDQ ick clock object\n"); | ||
598 | ret = PTR_ERR(hdq_data->hdq_ick); | ||
599 | goto err_ick; | ||
600 | } | ||
601 | |||
602 | hdq_data->hdq_fck = clk_get(&pdev->dev, "fck"); | ||
603 | if (IS_ERR(hdq_data->hdq_fck)) { | ||
604 | dev_dbg(&pdev->dev, "Can't get HDQ fck clock object\n"); | ||
605 | ret = PTR_ERR(hdq_data->hdq_fck); | ||
606 | goto err_fck; | ||
607 | } | ||
608 | |||
609 | hdq_data->hdq_usecount = 0; | 578 | hdq_data->hdq_usecount = 0; |
610 | mutex_init(&hdq_data->hdq_mutex); | 579 | mutex_init(&hdq_data->hdq_mutex); |
611 | 580 | ||
612 | if (clk_enable(hdq_data->hdq_ick)) { | 581 | pm_runtime_enable(&pdev->dev); |
613 | dev_dbg(&pdev->dev, "Can not enable ick\n"); | 582 | pm_runtime_get_sync(&pdev->dev); |
614 | ret = -ENODEV; | ||
615 | goto err_intfclk; | ||
616 | } | ||
617 | |||
618 | if (clk_enable(hdq_data->hdq_fck)) { | ||
619 | dev_dbg(&pdev->dev, "Can not enable fck\n"); | ||
620 | ret = -ENODEV; | ||
621 | goto err_fnclk; | ||
622 | } | ||
623 | 583 | ||
624 | rev = hdq_reg_in(hdq_data, OMAP_HDQ_REVISION); | 584 | rev = hdq_reg_in(hdq_data, OMAP_HDQ_REVISION); |
625 | dev_info(&pdev->dev, "OMAP HDQ Hardware Rev %c.%c. Driver in %s mode\n", | 585 | dev_info(&pdev->dev, "OMAP HDQ Hardware Rev %c.%c. Driver in %s mode\n", |
@@ -641,9 +601,7 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) | |||
641 | 601 | ||
642 | omap_hdq_break(hdq_data); | 602 | omap_hdq_break(hdq_data); |
643 | 603 | ||
644 | /* don't clock the HDQ until it is needed */ | 604 | pm_runtime_put_sync(&pdev->dev); |
645 | clk_disable(hdq_data->hdq_ick); | ||
646 | clk_disable(hdq_data->hdq_fck); | ||
647 | 605 | ||
648 | omap_w1_master.data = hdq_data; | 606 | omap_w1_master.data = hdq_data; |
649 | 607 | ||
@@ -655,20 +613,11 @@ static int __devinit omap_hdq_probe(struct platform_device *pdev) | |||
655 | 613 | ||
656 | return 0; | 614 | return 0; |
657 | 615 | ||
658 | err_w1: | ||
659 | err_irq: | 616 | err_irq: |
660 | clk_disable(hdq_data->hdq_fck); | 617 | pm_runtime_put_sync(&pdev->dev); |
661 | 618 | err_w1: | |
662 | err_fnclk: | 619 | pm_runtime_disable(&pdev->dev); |
663 | clk_disable(hdq_data->hdq_ick); | ||
664 | |||
665 | err_intfclk: | ||
666 | clk_put(hdq_data->hdq_fck); | ||
667 | |||
668 | err_fck: | ||
669 | clk_put(hdq_data->hdq_ick); | ||
670 | 620 | ||
671 | err_ick: | ||
672 | iounmap(hdq_data->hdq_base); | 621 | iounmap(hdq_data->hdq_base); |
673 | 622 | ||
674 | err_ioremap: | 623 | err_ioremap: |
@@ -696,8 +645,7 @@ static int omap_hdq_remove(struct platform_device *pdev) | |||
696 | mutex_unlock(&hdq_data->hdq_mutex); | 645 | mutex_unlock(&hdq_data->hdq_mutex); |
697 | 646 | ||
698 | /* remove module dependency */ | 647 | /* remove module dependency */ |
699 | clk_put(hdq_data->hdq_ick); | 648 | pm_runtime_disable(&pdev->dev); |
700 | clk_put(hdq_data->hdq_fck); | ||
701 | free_irq(INT_24XX_HDQ_IRQ, hdq_data); | 649 | free_irq(INT_24XX_HDQ_IRQ, hdq_data); |
702 | platform_set_drvdata(pdev, NULL); | 650 | platform_set_drvdata(pdev, NULL); |
703 | iounmap(hdq_data->hdq_base); | 651 | iounmap(hdq_data->hdq_base); |