diff options
author | Paul Walmsley <paul@pwsan.com> | 2011-07-10 07:56:54 -0400 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2011-07-10 07:56:54 -0400 |
commit | 32a363c0f5b44cb4e9adfe238dfc4efa9270f7ae (patch) | |
tree | 85ce4e4b5aceea3515dffc9e79448ac5088d312d /arch/arm/mach-omap2 | |
parent | 113a74137f5c85f2c7914e78350f70247ef9447c (diff) |
OMAP2+: clockdomain: add clkdm_in_hwsup()
Add a new function, clkdm_in_hwsup(), that returns true if a clockdomain
is configured for hardware-supervised idle. It does not actually read the
hardware; rather, it checks an internal flag in the struct clockdomain, which
is changed when the clockdomain is switched in and out of hardware-supervised
idle. This should be safe, since all changes to the idle mode should
pass through the clockdomain code.
Based on a set of patches by Rajendra Nayak <rnayak@ti.com> which do
the same thing by checking the hardware bits. This approach should be
faster and more compact.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Rajendra Nayak <rnayak@ti.com>
Cc: Todd Poynor <toddpoynor@google.com>
Cc: Benoît Cousson <b-cousson@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2')
-rw-r--r-- | arch/arm/mach-omap2/clockdomain.c | 30 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clockdomain.h | 6 |
2 files changed, 34 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c index 5a57de563b30..239b558853f5 100644 --- a/arch/arm/mach-omap2/clockdomain.c +++ b/arch/arm/mach-omap2/clockdomain.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * OMAP2/3/4 clockdomain framework functions | 2 | * OMAP2/3/4 clockdomain framework functions |
3 | * | 3 | * |
4 | * Copyright (C) 2008-2010 Texas Instruments, Inc. | 4 | * Copyright (C) 2008-2011 Texas Instruments, Inc. |
5 | * Copyright (C) 2008-2010 Nokia Corporation | 5 | * Copyright (C) 2008-2011 Nokia Corporation |
6 | * | 6 | * |
7 | * Written by Paul Walmsley and Jouni Högander | 7 | * Written by Paul Walmsley and Jouni Högander |
8 | * Added OMAP4 specific support by Abhijit Pagare <abhijitpagare@ti.com> | 8 | * Added OMAP4 specific support by Abhijit Pagare <abhijitpagare@ti.com> |
@@ -704,6 +704,8 @@ int clkdm_sleep(struct clockdomain *clkdm) | |||
704 | 704 | ||
705 | pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name); | 705 | pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name); |
706 | 706 | ||
707 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; | ||
708 | |||
707 | return arch_clkdm->clkdm_sleep(clkdm); | 709 | return arch_clkdm->clkdm_sleep(clkdm); |
708 | } | 710 | } |
709 | 711 | ||
@@ -732,6 +734,8 @@ int clkdm_wakeup(struct clockdomain *clkdm) | |||
732 | 734 | ||
733 | pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name); | 735 | pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name); |
734 | 736 | ||
737 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; | ||
738 | |||
735 | return arch_clkdm->clkdm_wakeup(clkdm); | 739 | return arch_clkdm->clkdm_wakeup(clkdm); |
736 | } | 740 | } |
737 | 741 | ||
@@ -762,6 +766,8 @@ void clkdm_allow_idle(struct clockdomain *clkdm) | |||
762 | pr_debug("clockdomain: enabling automatic idle transitions for %s\n", | 766 | pr_debug("clockdomain: enabling automatic idle transitions for %s\n", |
763 | clkdm->name); | 767 | clkdm->name); |
764 | 768 | ||
769 | clkdm->_flags |= _CLKDM_FLAG_HWSUP_ENABLED; | ||
770 | |||
765 | arch_clkdm->clkdm_allow_idle(clkdm); | 771 | arch_clkdm->clkdm_allow_idle(clkdm); |
766 | pwrdm_clkdm_state_switch(clkdm); | 772 | pwrdm_clkdm_state_switch(clkdm); |
767 | } | 773 | } |
@@ -792,9 +798,29 @@ void clkdm_deny_idle(struct clockdomain *clkdm) | |||
792 | pr_debug("clockdomain: disabling automatic idle transitions for %s\n", | 798 | pr_debug("clockdomain: disabling automatic idle transitions for %s\n", |
793 | clkdm->name); | 799 | clkdm->name); |
794 | 800 | ||
801 | clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; | ||
802 | |||
795 | arch_clkdm->clkdm_deny_idle(clkdm); | 803 | arch_clkdm->clkdm_deny_idle(clkdm); |
796 | } | 804 | } |
797 | 805 | ||
806 | /** | ||
807 | * clkdm_in_hwsup - is clockdomain @clkdm have hardware-supervised idle enabled? | ||
808 | * @clkdm: struct clockdomain * | ||
809 | * | ||
810 | * Returns true if clockdomain @clkdm currently has | ||
811 | * hardware-supervised idle enabled, or false if it does not or if | ||
812 | * @clkdm is NULL. It is only valid to call this function after | ||
813 | * clkdm_init() has been called. This function does not actually read | ||
814 | * bits from the hardware; it instead tests an in-memory flag that is | ||
815 | * changed whenever the clockdomain code changes the auto-idle mode. | ||
816 | */ | ||
817 | bool clkdm_in_hwsup(struct clockdomain *clkdm) | ||
818 | { | ||
819 | if (!clkdm) | ||
820 | return false; | ||
821 | |||
822 | return (clkdm->_flags & _CLKDM_FLAG_HWSUP_ENABLED) ? true : false; | ||
823 | } | ||
798 | 824 | ||
799 | /* Clockdomain-to-clock/hwmod framework interface code */ | 825 | /* Clockdomain-to-clock/hwmod framework interface code */ |
800 | 826 | ||
diff --git a/arch/arm/mach-omap2/clockdomain.h b/arch/arm/mach-omap2/clockdomain.h index 8e0da642355c..8782a5cadfa6 100644 --- a/arch/arm/mach-omap2/clockdomain.h +++ b/arch/arm/mach-omap2/clockdomain.h | |||
@@ -83,6 +83,9 @@ struct clkdm_dep { | |||
83 | const struct omap_chip_id omap_chip; | 83 | const struct omap_chip_id omap_chip; |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /* Possible flags for struct clockdomain._flags */ | ||
87 | #define _CLKDM_FLAG_HWSUP_ENABLED BIT(0) | ||
88 | |||
86 | /** | 89 | /** |
87 | * struct clockdomain - OMAP clockdomain | 90 | * struct clockdomain - OMAP clockdomain |
88 | * @name: clockdomain name | 91 | * @name: clockdomain name |
@@ -90,6 +93,7 @@ struct clkdm_dep { | |||
90 | * @clktrctrl_reg: CLKSTCTRL reg for the given clock domain | 93 | * @clktrctrl_reg: CLKSTCTRL reg for the given clock domain |
91 | * @clktrctrl_mask: CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg | 94 | * @clktrctrl_mask: CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg |
92 | * @flags: Clockdomain capability flags | 95 | * @flags: Clockdomain capability flags |
96 | * @_flags: Flags for use only by internal clockdomain code | ||
93 | * @dep_bit: Bit shift of this clockdomain's PM_WKDEP/CM_SLEEPDEP bit | 97 | * @dep_bit: Bit shift of this clockdomain's PM_WKDEP/CM_SLEEPDEP bit |
94 | * @prcm_partition: (OMAP4 only) PRCM partition ID for this clkdm's registers | 98 | * @prcm_partition: (OMAP4 only) PRCM partition ID for this clkdm's registers |
95 | * @cm_inst: (OMAP4 only) CM instance register offset | 99 | * @cm_inst: (OMAP4 only) CM instance register offset |
@@ -114,6 +118,7 @@ struct clockdomain { | |||
114 | } pwrdm; | 118 | } pwrdm; |
115 | const u16 clktrctrl_mask; | 119 | const u16 clktrctrl_mask; |
116 | const u8 flags; | 120 | const u8 flags; |
121 | u8 _flags; | ||
117 | const u8 dep_bit; | 122 | const u8 dep_bit; |
118 | const u8 prcm_partition; | 123 | const u8 prcm_partition; |
119 | const s16 cm_inst; | 124 | const s16 cm_inst; |
@@ -178,6 +183,7 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm); | |||
178 | 183 | ||
179 | void clkdm_allow_idle(struct clockdomain *clkdm); | 184 | void clkdm_allow_idle(struct clockdomain *clkdm); |
180 | void clkdm_deny_idle(struct clockdomain *clkdm); | 185 | void clkdm_deny_idle(struct clockdomain *clkdm); |
186 | bool clkdm_in_hwsup(struct clockdomain *clkdm); | ||
181 | 187 | ||
182 | int clkdm_wakeup(struct clockdomain *clkdm); | 188 | int clkdm_wakeup(struct clockdomain *clkdm); |
183 | int clkdm_sleep(struct clockdomain *clkdm); | 189 | int clkdm_sleep(struct clockdomain *clkdm); |