Skip to content

Commit 8823ddf

Browse files
committed
ARM: OMAP2+: Fix overwriting of clkctrl and modulemode values
We are currently overwiting the hwmod clkctrl registers if we configure a clock ctrl clock from device tree. While this does not expose any bugs except for kernel coders when debugging things, it should be fixed for correctness. It is now impossible to use the hwmod data for checking the clkctrl register values after booting for debugging or generating dts data from hwmod data. Let's fix the issue by adding a helper to detect if clkctrl clock is configured. Cc: Lokesh Vutla <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Tero Kristo <[email protected]> Signed-off-by: Tony Lindgren <[email protected]>
1 parent 6963c58 commit 8823ddf

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

arch/arm/mach-omap2/omap_hwmod.c

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,34 @@ static int _enable_clocks(struct omap_hwmod *oh)
993993
return 0;
994994
}
995995

996+
/**
997+
* _omap4_clkctrl_managed_by_clkfwk - true if clkctrl managed by clock framework
998+
* @oh: struct omap_hwmod *
999+
*/
1000+
static bool _omap4_clkctrl_managed_by_clkfwk(struct omap_hwmod *oh)
1001+
{
1002+
if (oh->prcm.omap4.flags & HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK)
1003+
return true;
1004+
1005+
return false;
1006+
}
1007+
1008+
/**
1009+
* _omap4_has_clkctrl_clock - returns true if a module has clkctrl clock
1010+
* @oh: struct omap_hwmod *
1011+
*/
1012+
static bool _omap4_has_clkctrl_clock(struct omap_hwmod *oh)
1013+
{
1014+
if (oh->prcm.omap4.clkctrl_offs)
1015+
return true;
1016+
1017+
if (!oh->prcm.omap4.clkctrl_offs &&
1018+
oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET)
1019+
return true;
1020+
1021+
return false;
1022+
}
1023+
9961024
/**
9971025
* _disable_clocks - disable hwmod main clock and interface clocks
9981026
* @oh: struct omap_hwmod *
@@ -1030,7 +1058,8 @@ static int _disable_clocks(struct omap_hwmod *oh)
10301058
*/
10311059
static void _omap4_enable_module(struct omap_hwmod *oh)
10321060
{
1033-
if (!oh->clkdm || !oh->prcm.omap4.modulemode)
1061+
if (!oh->clkdm || !oh->prcm.omap4.modulemode ||
1062+
_omap4_clkctrl_managed_by_clkfwk(oh))
10341063
return;
10351064

10361065
pr_debug("omap_hwmod: %s: %s: %d\n",
@@ -1061,8 +1090,10 @@ static int _omap4_wait_target_disable(struct omap_hwmod *oh)
10611090
if (oh->flags & HWMOD_NO_IDLEST)
10621091
return 0;
10631092

1064-
if (!oh->prcm.omap4.clkctrl_offs &&
1065-
!(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))
1093+
if (_omap4_clkctrl_managed_by_clkfwk(oh))
1094+
return 0;
1095+
1096+
if (!_omap4_has_clkctrl_clock(oh))
10661097
return 0;
10671098

10681099
return omap_cm_wait_module_idle(oh->clkdm->prcm_partition,
@@ -1847,7 +1878,8 @@ static int _omap4_disable_module(struct omap_hwmod *oh)
18471878
{
18481879
int v;
18491880

1850-
if (!oh->clkdm || !oh->prcm.omap4.modulemode)
1881+
if (!oh->clkdm || !oh->prcm.omap4.modulemode ||
1882+
_omap4_clkctrl_managed_by_clkfwk(oh))
18511883
return -EINVAL;
18521884

18531885
/*
@@ -2829,8 +2861,10 @@ static int _omap4_wait_target_ready(struct omap_hwmod *oh)
28292861
if (!_find_mpu_rt_port(oh))
28302862
return 0;
28312863

2832-
if (!oh->prcm.omap4.clkctrl_offs &&
2833-
!(oh->prcm.omap4.flags & HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET))
2864+
if (_omap4_clkctrl_managed_by_clkfwk(oh))
2865+
return 0;
2866+
2867+
if (!_omap4_has_clkctrl_clock(oh))
28342868
return 0;
28352869

28362870
/* XXX check module SIDLEMODE, hardreset status */
@@ -2986,8 +3020,7 @@ static int _omap4_disable_direct_prcm(struct omap_hwmod *oh)
29863020
if (!oh)
29873021
return -EINVAL;
29883022

2989-
oh->prcm.omap4.clkctrl_offs = 0;
2990-
oh->prcm.omap4.modulemode = 0;
3023+
oh->prcm.omap4.flags |= HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK;
29913024

29923025
return 0;
29933026
}

arch/arm/mach-omap2/omap_hwmod.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,12 @@ struct omap_hwmod_omap2_prcm {
446446
* HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET: Some IP blocks have a valid CLKCTRL
447447
* offset of zero; this flag bit should be set in those cases to
448448
* distinguish from hwmods that have no clkctrl offset.
449+
* HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK: Module clockctrl clock is managed
450+
* by the common clock framework and not hwmod.
449451
*/
450452
#define HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT (1 << 0)
451453
#define HWMOD_OMAP4_ZERO_CLKCTRL_OFFSET (1 << 1)
454+
#define HWMOD_OMAP4_CLKFWK_CLKCTR_CLOCK (1 << 2)
452455

453456
/**
454457
* struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data

0 commit comments

Comments
 (0)