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/cm4xxx.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/cm4xxx.c')
-rw-r--r-- | arch/arm/mach-omap2/cm4xxx.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/cm4xxx.c b/arch/arm/mach-omap2/cm4xxx.c new file mode 100644 index 000000000000..e4ebd6d53135 --- /dev/null +++ b/arch/arm/mach-omap2/cm4xxx.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * OMAP4 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-4xxx.h" | ||
26 | |||
27 | /* XXX move this to cm.h */ | ||
28 | /* MAX_MODULE_READY_TIME: max milliseconds for module to leave idle */ | ||
29 | #define MAX_MODULE_READY_TIME 20000 | ||
30 | |||
31 | /* | ||
32 | * OMAP4_PRCM_CM_CLKCTRL_IDLEST_MASK: isolates the IDLEST field in the | ||
33 | * CM_CLKCTRL register. | ||
34 | */ | ||
35 | #define OMAP4_PRCM_CM_CLKCTRL_IDLEST_MASK (0x2 << 16) | ||
36 | |||
37 | /* | ||
38 | * OMAP4 prcm_mod u32 fields contain packed data: the CM ID in bit 16 and | ||
39 | * the PRCM module offset address (from the CM module base) in bits 15-0. | ||
40 | */ | ||
41 | #define OMAP4_PRCM_MOD_CM_ID_SHIFT 16 | ||
42 | #define OMAP4_PRCM_MOD_OFFS_MASK 0xffff | ||
43 | |||
44 | /** | ||
45 | * omap4_cm_wait_idlest_ready - wait for a module to leave idle or standby | ||
46 | * @prcm_mod: PRCM module offset (XXX example) | ||
47 | * @prcm_dev_offs: PRCM device offset (e.g. MCASP XXX example) | ||
48 | * | ||
49 | * XXX document | ||
50 | */ | ||
51 | int omap4_cm_wait_idlest_ready(u32 prcm_mod, u8 prcm_dev_offs) | ||
52 | { | ||
53 | int i = 0; | ||
54 | u8 cm_id; | ||
55 | u16 prcm_mod_offs; | ||
56 | u32 mask = OMAP4_PRCM_CM_CLKCTRL_IDLEST_MASK; | ||
57 | |||
58 | cm_id = prcm_mod >> OMAP4_PRCM_MOD_CM_ID_SHIFT; | ||
59 | prcm_mod_offs = prcm_mod & OMAP4_PRCM_MOD_OFFS_MASK; | ||
60 | |||
61 | while (((omap4_cm_read_mod_reg(cm_id, prcm_mod_offs, prcm_dev_offs, | ||
62 | OMAP4_CM_CLKCTRL_DREG) & mask) != 0) && | ||
63 | (i++ < MAX_MODULE_READY_TIME)) | ||
64 | udelay(1); | ||
65 | |||
66 | return (i < MAX_MODULE_READY_TIME) ? 0 : -EBUSY; | ||
67 | } | ||
68 | |||