aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-12-21 23:05:15 -0500
committerPaul Walmsley <paul@pwsan.com>2010-12-21 23:05:15 -0500
commit55ae35073b1c76f24c3736cf797c40d9932b19aa (patch)
tree0309763ffbd016bb884ca916b35a15d10f1982a5 /arch/arm/mach-omap2/clockdomain.c
parentbd2122ca358fbd5c8e94869ae731a0951b36c757 (diff)
OMAP2/3: clockdomain: remove unneeded .clkstctrl_reg, remove some direct CM register accesses
Reverse some of the effects of commit 84c0c39aec31a09571fc08a752a2f4da0fe9fcf2 ("ARM: OMAP4: PM: Make OMAP3 Clock-domain framework compatible for OMAP4"). On OMAP2/3, the CM_CLKSTCTRL register is at a constant offset from the powerdomain's CM instance. Also, remove some of the direct CM register access from the clockdomain code, moving it to the OMAP2/3 CM code instead. The intention here is to simplify the clockdomain code. (The long-term goal is to move all direct CM register access across the OMAP core code to the appropriate cm*.c file.) Signed-off-by: Paul Walmsley <paul@pwsan.com> Tested-by: Rajendra Nayak <rnayak@ti.com> Tested-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c135
1 files changed, 45 insertions, 90 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 555a518836b9..e5605c21ad38 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -29,7 +29,7 @@
29#include "prm2xxx_3xxx.h" 29#include "prm2xxx_3xxx.h"
30#include "prm-regbits-24xx.h" 30#include "prm-regbits-24xx.h"
31#include "cm2xxx_3xxx.h" 31#include "cm2xxx_3xxx.h"
32#include "cm-regbits-34xx.h" 32#include "cm-regbits-24xx.h"
33#include "cminst44xx.h" 33#include "cminst44xx.h"
34#include "prcm44xx.h" 34#include "prcm44xx.h"
35 35
@@ -246,30 +246,18 @@ static void _clkdm_del_autodeps(struct clockdomain *clkdm)
246 */ 246 */
247static void _enable_hwsup(struct clockdomain *clkdm) 247static void _enable_hwsup(struct clockdomain *clkdm)
248{ 248{
249 u32 bits, v;
250
251 if (cpu_is_omap24xx()) 249 if (cpu_is_omap24xx())
252 bits = OMAP24XX_CLKSTCTRL_ENABLE_AUTO; 250 omap2xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
251 clkdm->clktrctrl_mask);
253 else if (cpu_is_omap34xx()) 252 else if (cpu_is_omap34xx())
254 bits = OMAP34XX_CLKSTCTRL_ENABLE_AUTO; 253 omap3xxx_cm_clkdm_enable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
254 clkdm->clktrctrl_mask);
255 else if (cpu_is_omap44xx()) 255 else if (cpu_is_omap44xx())
256 return omap4_cminst_clkdm_enable_hwsup(clkdm->prcm_partition, 256 return omap4_cminst_clkdm_enable_hwsup(clkdm->prcm_partition,
257 clkdm->cm_inst, 257 clkdm->cm_inst,
258 clkdm->clkdm_offs); 258 clkdm->clkdm_offs);
259 else 259 else
260 BUG(); 260 BUG();
261
262 bits = bits << __ffs(clkdm->clktrctrl_mask);
263
264 /*
265 * XXX clkstctrl_reg is known on OMAP2 - this clkdm
266 * field is not needed
267 */
268 v = __raw_readl(clkdm->clkstctrl_reg);
269 v &= ~(clkdm->clktrctrl_mask);
270 v |= bits;
271 __raw_writel(v, clkdm->clkstctrl_reg);
272
273} 261}
274 262
275/** 263/**
@@ -284,29 +272,18 @@ static void _enable_hwsup(struct clockdomain *clkdm)
284 */ 272 */
285static void _disable_hwsup(struct clockdomain *clkdm) 273static void _disable_hwsup(struct clockdomain *clkdm)
286{ 274{
287 u32 bits, v;
288
289 if (cpu_is_omap24xx()) 275 if (cpu_is_omap24xx())
290 bits = OMAP24XX_CLKSTCTRL_DISABLE_AUTO; 276 omap2xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
277 clkdm->clktrctrl_mask);
291 else if (cpu_is_omap34xx()) 278 else if (cpu_is_omap34xx())
292 bits = OMAP34XX_CLKSTCTRL_DISABLE_AUTO; 279 omap3xxx_cm_clkdm_disable_hwsup(clkdm->pwrdm.ptr->prcm_offs,
280 clkdm->clktrctrl_mask);
293 else if (cpu_is_omap44xx()) 281 else if (cpu_is_omap44xx())
294 return omap4_cminst_clkdm_disable_hwsup(clkdm->prcm_partition, 282 return omap4_cminst_clkdm_disable_hwsup(clkdm->prcm_partition,
295 clkdm->cm_inst, 283 clkdm->cm_inst,
296 clkdm->clkdm_offs); 284 clkdm->clkdm_offs);
297 else 285 else
298 BUG(); 286 BUG();
299
300 bits = bits << __ffs(clkdm->clktrctrl_mask);
301
302 /*
303 * XXX clkstctrl_reg is known on OMAP2 - this clkdm
304 * field is not needed
305 */
306 v = __raw_readl(clkdm->clkstctrl_reg);
307 v &= ~(clkdm->clktrctrl_mask);
308 v |= bits;
309 __raw_writel(v, clkdm->clkstctrl_reg);
310} 287}
311 288
312/* Public functions */ 289/* Public functions */
@@ -735,34 +712,6 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
735} 712}
736 713
737/** 714/**
738 * omap2_clkdm_clktrctrl_read - read the clkdm's current state transition mode
739 * @clkdm: struct clkdm * of a clockdomain
740 *
741 * Return the clockdomain @clkdm current state transition mode from the
742 * corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if @clkdm
743 * is NULL or the current mode upon success.
744 */
745static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
746{
747 u32 v = 0;
748
749 if (!clkdm)
750 return -EINVAL;
751
752 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
753 v = __raw_readl(clkdm->clkstctrl_reg);
754 v &= clkdm->clktrctrl_mask;
755 v >>= __ffs(clkdm->clktrctrl_mask);
756 } else if (cpu_is_omap44xx()) {
757 pr_warn("OMAP4 clockdomain: missing wakeup/sleep deps\n");
758 } else {
759 BUG();
760 }
761
762 return v;
763}
764
765/**
766 * omap2_clkdm_sleep - force clockdomain sleep transition 715 * omap2_clkdm_sleep - force clockdomain sleep transition
767 * @clkdm: struct clockdomain * 716 * @clkdm: struct clockdomain *
768 * 717 *
@@ -773,8 +722,6 @@ static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
773 */ 722 */
774int omap2_clkdm_sleep(struct clockdomain *clkdm) 723int omap2_clkdm_sleep(struct clockdomain *clkdm)
775{ 724{
776 u32 bits, v;
777
778 if (!clkdm) 725 if (!clkdm)
779 return -EINVAL; 726 return -EINVAL;
780 727
@@ -793,13 +740,8 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
793 740
794 } else if (cpu_is_omap34xx()) { 741 } else if (cpu_is_omap34xx()) {
795 742
796 bits = (OMAP34XX_CLKSTCTRL_FORCE_SLEEP << 743 omap3xxx_cm_clkdm_force_sleep(clkdm->pwrdm.ptr->prcm_offs,
797 __ffs(clkdm->clktrctrl_mask)); 744 clkdm->clktrctrl_mask);
798
799 v = __raw_readl(clkdm->clkstctrl_reg);
800 v &= ~(clkdm->clktrctrl_mask);
801 v |= bits;
802 __raw_writel(v, clkdm->clkstctrl_reg);
803 745
804 } else if (cpu_is_omap44xx()) { 746 } else if (cpu_is_omap44xx()) {
805 747
@@ -825,8 +767,6 @@ int omap2_clkdm_sleep(struct clockdomain *clkdm)
825 */ 767 */
826int omap2_clkdm_wakeup(struct clockdomain *clkdm) 768int omap2_clkdm_wakeup(struct clockdomain *clkdm)
827{ 769{
828 u32 bits, v;
829
830 if (!clkdm) 770 if (!clkdm)
831 return -EINVAL; 771 return -EINVAL;
832 772
@@ -845,13 +785,8 @@ int omap2_clkdm_wakeup(struct clockdomain *clkdm)
845 785
846 } else if (cpu_is_omap34xx()) { 786 } else if (cpu_is_omap34xx()) {
847 787
848 bits = (OMAP34XX_CLKSTCTRL_FORCE_WAKEUP << 788 omap3xxx_cm_clkdm_force_wakeup(clkdm->pwrdm.ptr->prcm_offs,
849 __ffs(clkdm->clktrctrl_mask)); 789 clkdm->clktrctrl_mask);
850
851 v = __raw_readl(clkdm->clkstctrl_reg);
852 v &= ~(clkdm->clktrctrl_mask);
853 v |= bits;
854 __raw_writel(v, clkdm->clkstctrl_reg);
855 790
856 } else if (cpu_is_omap44xx()) { 791 } else if (cpu_is_omap44xx()) {
857 792
@@ -964,7 +899,7 @@ void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
964 */ 899 */
965int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk) 900int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
966{ 901{
967 int v; 902 bool hwsup = false;
968 903
969 /* 904 /*
970 * XXX Rewrite this code to maintain a list of enabled 905 * XXX Rewrite this code to maintain a list of enabled
@@ -982,13 +917,23 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
982 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name, 917 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name,
983 clk->name); 918 clk->name);
984 919
985 if (!clkdm->clkstctrl_reg) 920 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
986 return 0;
987 921
988 v = omap2_clkdm_clktrctrl_read(clkdm); 922 if (!clkdm->clktrctrl_mask)
923 return 0;
924
925 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
926 clkdm->clktrctrl_mask);
927
928 } else if (cpu_is_omap44xx()) {
929
930 hwsup = omap4_cminst_is_clkdm_in_hwsup(clkdm->prcm_partition,
931 clkdm->cm_inst,
932 clkdm->clkdm_offs);
989 933
990 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) || 934 }
991 (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO)) { 935
936 if (hwsup) {
992 /* Disable HW transitions when we are changing deps */ 937 /* Disable HW transitions when we are changing deps */
993 _disable_hwsup(clkdm); 938 _disable_hwsup(clkdm);
994 _clkdm_add_autodeps(clkdm); 939 _clkdm_add_autodeps(clkdm);
@@ -1019,7 +964,7 @@ int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
1019 */ 964 */
1020int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk) 965int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
1021{ 966{
1022 int v; 967 bool hwsup = false;
1023 968
1024 /* 969 /*
1025 * XXX Rewrite this code to maintain a list of enabled 970 * XXX Rewrite this code to maintain a list of enabled
@@ -1044,13 +989,23 @@ int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
1044 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name, 989 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name,
1045 clk->name); 990 clk->name);
1046 991
1047 if (!clkdm->clkstctrl_reg) 992 if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
1048 return 0; 993
994 if (!clkdm->clktrctrl_mask)
995 return 0;
996
997 hwsup = omap2_cm_is_clkdm_in_hwsup(clkdm->pwrdm.ptr->prcm_offs,
998 clkdm->clktrctrl_mask);
1049 999
1050 v = omap2_clkdm_clktrctrl_read(clkdm); 1000 } else if (cpu_is_omap44xx()) {
1001
1002 hwsup = omap4_cminst_is_clkdm_in_hwsup(clkdm->prcm_partition,
1003 clkdm->cm_inst,
1004 clkdm->clkdm_offs);
1005
1006 }
1051 1007
1052 if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) || 1008 if (hwsup) {
1053 (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO)) {
1054 /* Disable HW transitions when we are changing deps */ 1009 /* Disable HW transitions when we are changing deps */
1055 _disable_hwsup(clkdm); 1010 _disable_hwsup(clkdm);
1056 _clkdm_del_autodeps(clkdm); 1011 _clkdm_del_autodeps(clkdm);