diff options
author | Paul Walmsley <paul@pwsan.com> | 2008-08-19 04:08:43 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2008-08-19 04:08:43 -0400 |
commit | d459bfe01f523983a822de8c2d3fe0bd2f2c194e (patch) | |
tree | 9f583480f3c0940778bb0f7b4fee5c68eb5b5bfc /arch/arm/plat-omap | |
parent | ecb24aa129c6d4b2152571f856320aa7dea41676 (diff) |
ARM: OMAP2: Clockdomain: Add base OMAP2/3 clockdomain code
This patch creates an interface to the clockdomain registers in the
PRM/CM modules on OMAP2/3. This interface is intended to be used by
PM code, e.g., pm.c; not by device drivers directly.
The patch also adds clockdomain usecount tracking. This is intended
to be called whenever the first clock in a clockdomain is enabled, or
when the last enabled clock in a clockdomain is disabled. If the
clockdomain is in software-supervised mode, the code will force-wakeup
or force-sleep the clockdomain. If the clockdomain is in
hardware-supervised mode, the first clock enable will add sleep and
wakeup dependencies on a user-selectable set of parent domains (usually
MPU & IVA2), and the disable will remove them.
Each clockdomain will be defined in later patches as static
structures. The clockdomain structures are linked into a list at boot
by clkdm_register(), similar to the OMAP clock code.
The patch adds a Kconfig option, CONFIG_OMAP_DEBUG_CLOCKDOMAIN, which
when enabled will emit verbose debug messages via pr_debug().
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/plat-omap')
-rw-r--r-- | arch/arm/plat-omap/Kconfig | 12 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/mach/clockdomain.h | 106 |
2 files changed, 118 insertions, 0 deletions
diff --git a/arch/arm/plat-omap/Kconfig b/arch/arm/plat-omap/Kconfig index e815fa35f7f4..ef62bf21e179 100644 --- a/arch/arm/plat-omap/Kconfig +++ b/arch/arm/plat-omap/Kconfig | |||
@@ -41,6 +41,18 @@ config OMAP_DEBUG_POWERDOMAIN | |||
41 | for every powerdomain register write. However, the | 41 | for every powerdomain register write. However, the |
42 | extra detail costs some memory. | 42 | extra detail costs some memory. |
43 | 43 | ||
44 | config OMAP_DEBUG_CLOCKDOMAIN | ||
45 | bool "Emit debug messages from clockdomain layer" | ||
46 | depends on ARCH_OMAP2 || ARCH_OMAP3 | ||
47 | default n | ||
48 | help | ||
49 | Say Y here if you want to compile in clockdomain layer | ||
50 | debugging messages for OMAP2/3. These messages can | ||
51 | provide more detail as to why some clockdomain calls | ||
52 | may be failing, and will also emit a descriptive message | ||
53 | for every clockdomain register write. However, the | ||
54 | extra detail costs some memory. | ||
55 | |||
44 | config OMAP_RESET_CLOCKS | 56 | config OMAP_RESET_CLOCKS |
45 | bool "Reset unused clocks during boot" | 57 | bool "Reset unused clocks during boot" |
46 | depends on ARCH_OMAP | 58 | depends on ARCH_OMAP |
diff --git a/arch/arm/plat-omap/include/mach/clockdomain.h b/arch/arm/plat-omap/include/mach/clockdomain.h new file mode 100644 index 000000000000..1f51f0173784 --- /dev/null +++ b/arch/arm/plat-omap/include/mach/clockdomain.h | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * linux/include/asm-arm/arch-omap/clockdomain.h | ||
3 | * | ||
4 | * OMAP2/3 clockdomain framework functions | ||
5 | * | ||
6 | * Copyright (C) 2008 Texas Instruments, Inc. | ||
7 | * Copyright (C) 2008 Nokia Corporation | ||
8 | * | ||
9 | * Written by Paul Walmsley | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #ifndef __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H | ||
17 | #define __ASM_ARM_ARCH_OMAP_CLOCKDOMAIN_H | ||
18 | |||
19 | #include <mach/powerdomain.h> | ||
20 | #include <mach/clock.h> | ||
21 | #include <mach/cpu.h> | ||
22 | |||
23 | /* Clockdomain capability flags */ | ||
24 | #define CLKDM_CAN_FORCE_SLEEP (1 << 0) | ||
25 | #define CLKDM_CAN_FORCE_WAKEUP (1 << 1) | ||
26 | #define CLKDM_CAN_ENABLE_AUTO (1 << 2) | ||
27 | #define CLKDM_CAN_DISABLE_AUTO (1 << 3) | ||
28 | |||
29 | #define CLKDM_CAN_HWSUP (CLKDM_CAN_ENABLE_AUTO | CLKDM_CAN_DISABLE_AUTO) | ||
30 | #define CLKDM_CAN_SWSUP (CLKDM_CAN_FORCE_SLEEP | CLKDM_CAN_FORCE_WAKEUP) | ||
31 | #define CLKDM_CAN_HWSUP_SWSUP (CLKDM_CAN_SWSUP | CLKDM_CAN_HWSUP) | ||
32 | |||
33 | /* OMAP24XX CM_CLKSTCTRL_*.AUTOSTATE_* register bit values */ | ||
34 | #define OMAP24XX_CLKSTCTRL_DISABLE_AUTO 0x0 | ||
35 | #define OMAP24XX_CLKSTCTRL_ENABLE_AUTO 0x1 | ||
36 | |||
37 | /* OMAP3XXX CM_CLKSTCTRL_*.CLKTRCTRL_* register bit values */ | ||
38 | #define OMAP34XX_CLKSTCTRL_DISABLE_AUTO 0x0 | ||
39 | #define OMAP34XX_CLKSTCTRL_FORCE_SLEEP 0x1 | ||
40 | #define OMAP34XX_CLKSTCTRL_FORCE_WAKEUP 0x2 | ||
41 | #define OMAP34XX_CLKSTCTRL_ENABLE_AUTO 0x3 | ||
42 | |||
43 | /* | ||
44 | * struct clkdm_pwrdm_autodep - a powerdomain that should have wkdeps | ||
45 | * and sleepdeps added when a powerdomain should stay active in hwsup mode; | ||
46 | * and conversely, removed when the powerdomain should be allowed to go | ||
47 | * inactive in hwsup mode. | ||
48 | */ | ||
49 | struct clkdm_pwrdm_autodep { | ||
50 | |||
51 | /* Name of the powerdomain to add a wkdep/sleepdep on */ | ||
52 | const char *pwrdm_name; | ||
53 | |||
54 | /* Powerdomain pointer (looked up at clkdm_init() time) */ | ||
55 | struct powerdomain *pwrdm; | ||
56 | |||
57 | /* OMAP chip types that this clockdomain dep is valid on */ | ||
58 | const struct omap_chip_id omap_chip; | ||
59 | |||
60 | }; | ||
61 | |||
62 | struct clockdomain { | ||
63 | |||
64 | /* Clockdomain name */ | ||
65 | const char *name; | ||
66 | |||
67 | /* Powerdomain enclosing this clockdomain */ | ||
68 | const char *pwrdm_name; | ||
69 | |||
70 | /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */ | ||
71 | const u16 clktrctrl_mask; | ||
72 | |||
73 | /* Clockdomain capability flags */ | ||
74 | const u8 flags; | ||
75 | |||
76 | /* OMAP chip types that this clockdomain is valid on */ | ||
77 | const struct omap_chip_id omap_chip; | ||
78 | |||
79 | /* Usecount tracking */ | ||
80 | atomic_t usecount; | ||
81 | |||
82 | /* Powerdomain pointer assigned at clkdm_register() */ | ||
83 | struct powerdomain *pwrdm; | ||
84 | |||
85 | struct list_head node; | ||
86 | |||
87 | }; | ||
88 | |||
89 | void clkdm_init(struct clockdomain **clkdms, struct clkdm_pwrdm_autodep *autodeps); | ||
90 | int clkdm_register(struct clockdomain *clkdm); | ||
91 | int clkdm_unregister(struct clockdomain *clkdm); | ||
92 | struct clockdomain *clkdm_lookup(const char *name); | ||
93 | |||
94 | int clkdm_for_each(int (*fn)(struct clockdomain *clkdm)); | ||
95 | struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm); | ||
96 | |||
97 | void omap2_clkdm_allow_idle(struct clockdomain *clkdm); | ||
98 | void omap2_clkdm_deny_idle(struct clockdomain *clkdm); | ||
99 | |||
100 | int omap2_clkdm_wakeup(struct clockdomain *clkdm); | ||
101 | int omap2_clkdm_sleep(struct clockdomain *clkdm); | ||
102 | |||
103 | int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk); | ||
104 | int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk); | ||
105 | |||
106 | #endif | ||