diff options
author | Paul Walmsley <paul@pwsan.com> | 2009-09-03 13:14:02 -0400 |
---|---|---|
committer | paul <paul@twilight.(none)> | 2009-09-03 13:14:02 -0400 |
commit | 71348bcaac6f4c372525d4d62e88a82a7330435b (patch) | |
tree | d0815681a02f914a8f24fb4f5050d357ecfbdfb5 /arch/arm/mach-omap2/cm.c | |
parent | c0407a96d04794be586eab4a412320079446cf93 (diff) |
OMAP2/3/4 PRCM: add module IDLEST wait code
After a hardware module's clocks are enabled, Linux must wait for it
to indicate readiness via its IDLEST bit before attempting to access
the device, otherwise register accesses to the device may trigger an
abort. This has traditionally been implemented in the clock
framework, but this is the wrong place for it: the clock framework
doesn't know which module clocks must be enabled for a module to leave
idle; and if a module is not in smart-idle mode, it may never leave
idle at all. This type of information is best stored in a
per-hardware module data structure (coming in a following patch),
rather than a per-clock data structure. The new code will use these new
functions to handle waiting for modules to enable.
Once hardware module data is filled in for all of the on-chip devices,
the clock framework code to handle IDLEST waiting can be removed.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/cm.c')
-rw-r--r-- | arch/arm/mach-omap2/cm.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/cm.c b/arch/arm/mach-omap2/cm.c new file mode 100644 index 000000000000..8eb2dab8c7db --- /dev/null +++ b/arch/arm/mach-omap2/cm.c | |||
@@ -0,0 +1,70 @@ | |||
1 | /* | ||
2 | * OMAP2/3 CM module functions | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * Paul Walmsley | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License version 2 as | ||
9 | * published by the Free Software Foundation. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/delay.h> | ||
16 | #include <linux/spinlock.h> | ||
17 | #include <linux/list.h> | ||
18 | #include <linux/errno.h> | ||
19 | #include <linux/err.h> | ||
20 | #include <linux/io.h> | ||
21 | |||
22 | #include <asm/atomic.h> | ||
23 | |||
24 | #include "cm.h" | ||
25 | #include "cm-regbits-24xx.h" | ||
26 | #include "cm-regbits-34xx.h" | ||
27 | |||
28 | /* MAX_MODULE_READY_TIME: max milliseconds for module to leave idle */ | ||
29 | #define MAX_MODULE_READY_TIME 20000 | ||
30 | |||
31 | static const u8 cm_idlest_offs[] = { | ||
32 | CM_IDLEST1, CM_IDLEST2, OMAP2430_CM_IDLEST3 | ||
33 | }; | ||
34 | |||
35 | /** | ||
36 | * omap2_cm_wait_idlest_ready - wait for a module to leave idle or standby | ||
37 | * @prcm_mod: PRCM module offset | ||
38 | * @idlest_id: CM_IDLESTx register ID (i.e., x = 1, 2, 3) | ||
39 | * @idlest_shift: shift of the bit in the CM_IDLEST* register to check | ||
40 | * | ||
41 | * XXX document | ||
42 | */ | ||
43 | int omap2_cm_wait_module_ready(s16 prcm_mod, u8 idlest_id, u8 idlest_shift) | ||
44 | { | ||
45 | int ena = 0, i = 0; | ||
46 | u8 cm_idlest_reg; | ||
47 | u32 mask; | ||
48 | |||
49 | if (!idlest_id || (idlest_id > ARRAY_SIZE(cm_idlest_offs))) | ||
50 | return -EINVAL; | ||
51 | |||
52 | cm_idlest_reg = cm_idlest_offs[idlest_id - 1]; | ||
53 | |||
54 | if (cpu_is_omap24xx()) | ||
55 | ena = idlest_shift; | ||
56 | else if (cpu_is_omap34xx()) | ||
57 | ena = 0; | ||
58 | else | ||
59 | BUG(); | ||
60 | |||
61 | mask = 1 << idlest_shift; | ||
62 | |||
63 | /* XXX should be OMAP2 CM */ | ||
64 | while (((cm_read_mod_reg(prcm_mod, cm_idlest_reg) & mask) != ena) && | ||
65 | (i++ < MAX_MODULE_READY_TIME)) | ||
66 | udelay(1); | ||
67 | |||
68 | return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY; | ||
69 | } | ||
70 | |||