aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-02-23 00:09:38 -0500
committerPaul Walmsley <paul@pwsan.com>2010-02-24 19:45:16 -0500
commit30962d9d0c74f6b00a7dece200fa08392b62817d (patch)
tree72c1e60fd4f42c244fb8fe9c68f8e3d95a880edb /arch/arm/mach-omap2/clockdomain.c
parent4d30e82c26b7212021b9a5ab57760d9b8a3075fe (diff)
OMAP2+ clock: revise omap2_clk_{disable,enable}()
Simplify the code in the omap2_clk_disable() and omap2_clk_enable() functions, reducing levels of indentation. This makes the code easier to read. Add some additional debugging pr_debug()s here also to help others understand what is going on. Revise the omap2_clk_disable() logic so that it now attempts to disable the clock's clockdomain before recursing up the clock tree. Simultaneously, ensure that omap2_clk_enable() is called on parent clocks first, before enabling the clockdomain. This ensures that a parent clock's clockdomain is enabled before the child clock's clockdomain. These sequences should be the inverse of each other. Revise the omap2_clk_enable() logic so that it now cleans up after itself upon encountering an error. Previously, an error enabling a parent clock could have resulted in inconsistent usecounts on the enclosing clockdomain. Remove the trivial _omap2_clk_disable() and _omap2_clk_enable() static functions, and replace it with the clkops calls that they were executing. For all this to work, the clockdomain omap2_clkdm_clk_enable() and omap2_clkdm_clk_disable() code must not return an error on clockdomains without CLKSTCTRL registers; so modify those functions to simply return 0 in that case. While here, add some basic kerneldoc documentation on both functions, and get rid of some old non-CodingStyle-compliant comments that have existed since the dawn of time (at least, the OMAP clock framework's time). Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Richard Woodruff <r-woodruff2@ti.com> Cc: Rajendra Nayak <rnayak@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index b26d30a14303..b87ad66f083e 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -978,7 +978,7 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
978 * downstream clocks for debugging purposes? 978 * downstream clocks for debugging purposes?
979 */ 979 */
980 980
981 if (!clkdm || !clk || !clkdm->clkstctrl_reg) 981 if (!clkdm || !clk)
982 return -EINVAL; 982 return -EINVAL;
983 983
984 if (atomic_inc_return(&clkdm->usecount) > 1) 984 if (atomic_inc_return(&clkdm->usecount) > 1)
@@ -989,6 +989,9 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
989 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name, 989 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name,
990 clk->name); 990 clk->name);
991 991
992 if (!clkdm->clkstctrl_reg)
993 return 0;
994
992 v = omap2_clkdm_clktrctrl_read(clkdm); 995 v = omap2_clkdm_clktrctrl_read(clkdm);
993 996
994 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) || 997 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||
@@ -1030,7 +1033,7 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
1030 * downstream clocks for debugging purposes? 1033 * downstream clocks for debugging purposes?
1031 */ 1034 */
1032 1035
1033 if (!clkdm || !clk || !clkdm->clkstctrl_reg) 1036 if (!clkdm || !clk)
1034 return -EINVAL; 1037 return -EINVAL;
1035 1038
1036#ifdef DEBUG 1039#ifdef DEBUG
@@ -1048,6 +1051,9 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
1048 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name, 1051 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name,
1049 clk->name); 1052 clk->name);
1050 1053
1054 if (!clkdm->clkstctrl_reg)
1055 return 0;
1056
1051 v = omap2_clkdm_clktrctrl_read(clkdm); 1057 v = omap2_clkdm_clktrctrl_read(clkdm);
1052 1058
1053 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) || 1059 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||