Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 175626
b: refs/heads/master
c: 6f8b7ff
h: refs/heads/master
v: v3
  • Loading branch information
Paul Walmsley authored and paul committed Dec 12, 2009
1 parent ede4bbb commit 68adc45
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3863c74b512c1afd3ce6b2f81d8dea9f1d860968
refs/heads/master: 6f8b7ff5b01e16a65c3b17865ce047faeca40907
7 changes: 4 additions & 3 deletions trunk/arch/arm/mach-omap2/cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <asm/atomic.h>

#include <plat/common.h>

#include "cm.h"
#include "cm-regbits-24xx.h"
#include "cm-regbits-34xx.h"
Expand Down Expand Up @@ -61,9 +63,8 @@ int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift)
mask = 1 << idlest_shift;

/* XXX should be OMAP2 CM */
while (((cm_read_mod_reg(prcm_mod, cm_idlest_reg) & mask) != ena) &&
(i++ < MAX_MODULE_READY_TIME))
udelay(1);
omap_test_timeout(((cm_read_mod_reg(prcm_mod, cm_idlest_reg) & mask) == ena),
MAX_MODULE_READY_TIME, i);

return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY;
}
Expand Down
13 changes: 5 additions & 8 deletions trunk/arch/arm/mach-omap2/omap_hwmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <linux/mutex.h>
#include <linux/bootmem.h>

#include <plat/common.h>
#include <plat/cpu.h>
#include <plat/clockdomain.h>
#include <plat/powerdomain.h>
Expand Down Expand Up @@ -736,7 +737,7 @@ static int _wait_target_ready(struct omap_hwmod *oh)
static int _reset(struct omap_hwmod *oh)
{
u32 r, v;
int c;
int c = 0;

if (!oh->sysconfig ||
!(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET) ||
Expand All @@ -758,13 +759,9 @@ static int _reset(struct omap_hwmod *oh)
return r;
_write_sysconfig(v, oh);

c = 0;
while (c < MAX_MODULE_RESET_WAIT &&
!(omap_hwmod_readl(oh, oh->sysconfig->syss_offs) &
SYSS_RESETDONE_MASK)) {
udelay(1);
c++;
}
omap_test_timeout((omap_hwmod_readl(oh, oh->sysconfig->syss_offs) &
SYSS_RESETDONE_MASK),
MAX_MODULE_RESET_WAIT, c);

if (c == MAX_MODULE_RESET_WAIT)
WARN(1, "omap_hwmod: %s: failed to reset in %d usec\n",
Expand Down
5 changes: 2 additions & 3 deletions trunk/arch/arm/mach-omap2/prcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,8 @@ int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, const char *name)
BUG();

/* Wait for lock */
while (((__raw_readl(reg) & mask) != ena) &&
(i++ < MAX_MODULE_ENABLE_WAIT))
udelay(1);
omap_test_timeout(((__raw_readl(reg) & mask) == ena),
MAX_MODULE_ENABLE_WAIT, i);

if (i < MAX_MODULE_ENABLE_WAIT)
pr_debug("cm: Module associated with clock %s ready after %d "
Expand Down
20 changes: 20 additions & 0 deletions trunk/arch/arm/plat-omap/include/plat/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,24 @@ void omap2_set_globals_sdrc(struct omap_globals *);
void omap2_set_globals_control(struct omap_globals *);
void omap2_set_globals_prcm(struct omap_globals *);

/**
* omap_test_timeout - busy-loop, testing a condition
* @cond: condition to test until it evaluates to true
* @timeout: maximum number of microseconds in the timeout
* @index: loop index (integer)
*
* Loop waiting for @cond to become true or until at least @timeout
* microseconds have passed. To use, define some integer @index in the
* calling code. After running, if @index == @timeout, then the loop has
* timed out.
*/
#define omap_test_timeout(cond, timeout, index) \
({ \
for (index = 0; index < timeout; index++) { \
if (cond) \
break; \
udelay(1); \
} \
})

#endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */

0 comments on commit 68adc45

Please sign in to comment.