Commit | Line | Data |
---|---|---|
d459bfe0 | 1 | /* |
5b74c676 | 2 | * arch/arm/plat-omap/include/mach/clockdomain.h |
d459bfe0 PW |
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 | ||
ce491cf8 TL |
19 | #include <plat/powerdomain.h> |
20 | #include <plat/clock.h> | |
21 | #include <plat/cpu.h> | |
d459bfe0 PW |
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 | ||
5b74c676 PW |
51 | union { |
52 | /* Name of the powerdomain to add a wkdep/sleepdep on */ | |
53 | const char *name; | |
d459bfe0 | 54 | |
5b74c676 PW |
55 | /* Powerdomain pointer (looked up at clkdm_init() time) */ |
56 | struct powerdomain *ptr; | |
57 | } pwrdm; | |
d459bfe0 PW |
58 | |
59 | /* OMAP chip types that this clockdomain dep is valid on */ | |
60 | const struct omap_chip_id omap_chip; | |
61 | ||
62 | }; | |
63 | ||
64 | struct clockdomain { | |
65 | ||
66 | /* Clockdomain name */ | |
67 | const char *name; | |
68 | ||
5b74c676 PW |
69 | union { |
70 | /* Powerdomain enclosing this clockdomain */ | |
71 | const char *name; | |
72 | ||
73 | /* Powerdomain pointer assigned at clkdm_register() */ | |
74 | struct powerdomain *ptr; | |
75 | } pwrdm; | |
d459bfe0 | 76 | |
84c0c39a AP |
77 | /* CLKSTCTRL reg for the given clock domain*/ |
78 | void __iomem *clkstctrl_reg; | |
79 | ||
d459bfe0 PW |
80 | /* CLKTRCTRL/AUTOSTATE field mask in CM_CLKSTCTRL reg */ |
81 | const u16 clktrctrl_mask; | |
82 | ||
83 | /* Clockdomain capability flags */ | |
84 | const u8 flags; | |
85 | ||
86 | /* OMAP chip types that this clockdomain is valid on */ | |
87 | const struct omap_chip_id omap_chip; | |
88 | ||
89 | /* Usecount tracking */ | |
90 | atomic_t usecount; | |
91 | ||
d459bfe0 PW |
92 | struct list_head node; |
93 | ||
94 | }; | |
95 | ||
96 | void clkdm_init(struct clockdomain **clkdms, struct clkdm_pwrdm_autodep *autodeps); | |
97 | int clkdm_register(struct clockdomain *clkdm); | |
98 | int clkdm_unregister(struct clockdomain *clkdm); | |
99 | struct clockdomain *clkdm_lookup(const char *name); | |
100 | ||
a23456e9 PDS |
101 | int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user), |
102 | void *user); | |
d459bfe0 PW |
103 | struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm); |
104 | ||
105 | void omap2_clkdm_allow_idle(struct clockdomain *clkdm); | |
106 | void omap2_clkdm_deny_idle(struct clockdomain *clkdm); | |
107 | ||
108 | int omap2_clkdm_wakeup(struct clockdomain *clkdm); | |
109 | int omap2_clkdm_sleep(struct clockdomain *clkdm); | |
110 | ||
111 | int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk); | |
112 | int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk); | |
113 | ||
114 | #endif |