diff options
-rw-r--r-- | arch/arm/mach-omap2/powerdomain.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/powerdomain.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/voltage.c | 80 | ||||
-rw-r--r-- | arch/arm/mach-omap2/voltage.h | 9 |
4 files changed, 93 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index 984457d612b7..5164d587ef52 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c | |||
@@ -99,6 +99,8 @@ static int _pwrdm_register(struct powerdomain *pwrdm) | |||
99 | return -EINVAL; | 99 | return -EINVAL; |
100 | } | 100 | } |
101 | pwrdm->voltdm.ptr = voltdm; | 101 | pwrdm->voltdm.ptr = voltdm; |
102 | INIT_LIST_HEAD(&pwrdm->voltdm_node); | ||
103 | voltdm_add_pwrdm(voltdm, pwrdm); | ||
102 | 104 | ||
103 | list_add(&pwrdm->node, &pwrdm_list); | 105 | list_add(&pwrdm->node, &pwrdm_list); |
104 | 106 | ||
diff --git a/arch/arm/mach-omap2/powerdomain.h b/arch/arm/mach-omap2/powerdomain.h index d8a7f914d9b3..42e6dd8f2a78 100644 --- a/arch/arm/mach-omap2/powerdomain.h +++ b/arch/arm/mach-omap2/powerdomain.h | |||
@@ -91,6 +91,7 @@ struct powerdomain; | |||
91 | * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON | 91 | * @pwrsts_mem_on: Possible memory bank pwrstates when pwrdm in ON |
92 | * @pwrdm_clkdms: Clockdomains in this powerdomain | 92 | * @pwrdm_clkdms: Clockdomains in this powerdomain |
93 | * @node: list_head linking all powerdomains | 93 | * @node: list_head linking all powerdomains |
94 | * @voltdm_node: list_head linking all powerdomains in a voltagedomain | ||
94 | * @state: | 95 | * @state: |
95 | * @state_counter: | 96 | * @state_counter: |
96 | * @timer: | 97 | * @timer: |
@@ -114,6 +115,7 @@ struct powerdomain { | |||
114 | const u8 prcm_partition; | 115 | const u8 prcm_partition; |
115 | struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS]; | 116 | struct clockdomain *pwrdm_clkdms[PWRDM_MAX_CLKDMS]; |
116 | struct list_head node; | 117 | struct list_head node; |
118 | struct list_head voltdm_node; | ||
117 | int state; | 119 | int state; |
118 | unsigned state_counter[PWRDM_MAX_PWRSTS]; | 120 | unsigned state_counter[PWRDM_MAX_PWRSTS]; |
119 | unsigned ret_logic_off_counter; | 121 | unsigned ret_logic_off_counter; |
diff --git a/arch/arm/mach-omap2/voltage.c b/arch/arm/mach-omap2/voltage.c index 48a2593878c6..1e5c1225e2be 100644 --- a/arch/arm/mach-omap2/voltage.c +++ b/arch/arm/mach-omap2/voltage.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include "control.h" | 36 | #include "control.h" |
37 | 37 | ||
38 | #include "voltage.h" | 38 | #include "voltage.h" |
39 | #include "powerdomain.h" | ||
39 | 40 | ||
40 | #include "vc.h" | 41 | #include "vc.h" |
41 | #include "vp.h" | 42 | #include "vp.h" |
@@ -1085,11 +1086,90 @@ static struct voltagedomain *_voltdm_lookup(const char *name) | |||
1085 | return voltdm; | 1086 | return voltdm; |
1086 | } | 1087 | } |
1087 | 1088 | ||
1089 | /** | ||
1090 | * voltdm_add_pwrdm - add a powerdomain to a voltagedomain | ||
1091 | * @voltdm: struct voltagedomain * to add the powerdomain to | ||
1092 | * @pwrdm: struct powerdomain * to associate with a voltagedomain | ||
1093 | * | ||
1094 | * Associate the powerdomain @pwrdm with a voltagedomain @voltdm. This | ||
1095 | * enables the use of voltdm_for_each_pwrdm(). Returns -EINVAL if | ||
1096 | * presented with invalid pointers; -ENOMEM if memory could not be allocated; | ||
1097 | * or 0 upon success. | ||
1098 | */ | ||
1099 | int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm) | ||
1100 | { | ||
1101 | if (!voltdm || !pwrdm) | ||
1102 | return -EINVAL; | ||
1103 | |||
1104 | pr_debug("voltagedomain: associating powerdomain %s with voltagedomain " | ||
1105 | "%s\n", pwrdm->name, voltdm->name); | ||
1106 | |||
1107 | list_add(&pwrdm->voltdm_node, &voltdm->pwrdm_list); | ||
1108 | |||
1109 | return 0; | ||
1110 | } | ||
1111 | |||
1112 | /** | ||
1113 | * voltdm_for_each_pwrdm - call function for each pwrdm in a voltdm | ||
1114 | * @voltdm: struct voltagedomain * to iterate over | ||
1115 | * @fn: callback function * | ||
1116 | * | ||
1117 | * Call the supplied function @fn for each powerdomain in the | ||
1118 | * voltagedomain @voltdm. Returns -EINVAL if presented with invalid | ||
1119 | * pointers; or passes along the last return value of the callback | ||
1120 | * function, which should be 0 for success or anything else to | ||
1121 | * indicate failure. | ||
1122 | */ | ||
1123 | int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, | ||
1124 | int (*fn)(struct voltagedomain *voltdm, | ||
1125 | struct powerdomain *pwrdm)) | ||
1126 | { | ||
1127 | struct powerdomain *pwrdm; | ||
1128 | int ret = 0; | ||
1129 | |||
1130 | if (!fn) | ||
1131 | return -EINVAL; | ||
1132 | |||
1133 | list_for_each_entry(pwrdm, &voltdm->pwrdm_list, voltdm_node) | ||
1134 | ret = (*fn)(voltdm, pwrdm); | ||
1135 | |||
1136 | return ret; | ||
1137 | } | ||
1138 | |||
1139 | /** | ||
1140 | * voltdm_for_each - call function on each registered voltagedomain | ||
1141 | * @fn: callback function * | ||
1142 | * | ||
1143 | * Call the supplied function @fn for each registered voltagedomain. | ||
1144 | * The callback function @fn can return anything but 0 to bail out | ||
1145 | * early from the iterator. Returns the last return value of the | ||
1146 | * callback function, which should be 0 for success or anything else | ||
1147 | * to indicate failure; or -EINVAL if the function pointer is null. | ||
1148 | */ | ||
1149 | int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), | ||
1150 | void *user) | ||
1151 | { | ||
1152 | struct voltagedomain *temp_voltdm; | ||
1153 | int ret = 0; | ||
1154 | |||
1155 | if (!fn) | ||
1156 | return -EINVAL; | ||
1157 | |||
1158 | list_for_each_entry(temp_voltdm, &voltdm_list, node) { | ||
1159 | ret = (*fn)(temp_voltdm, user); | ||
1160 | if (ret) | ||
1161 | break; | ||
1162 | } | ||
1163 | |||
1164 | return ret; | ||
1165 | } | ||
1166 | |||
1088 | static int _voltdm_register(struct voltagedomain *voltdm) | 1167 | static int _voltdm_register(struct voltagedomain *voltdm) |
1089 | { | 1168 | { |
1090 | if (!voltdm || !voltdm->name) | 1169 | if (!voltdm || !voltdm->name) |
1091 | return -EINVAL; | 1170 | return -EINVAL; |
1092 | 1171 | ||
1172 | INIT_LIST_HEAD(&voltdm->pwrdm_list); | ||
1093 | list_add(&voltdm->node, &voltdm_list); | 1173 | list_add(&voltdm->node, &voltdm_list); |
1094 | 1174 | ||
1095 | pr_debug("voltagedomain: registered %s\n", voltdm->name); | 1175 | pr_debug("voltagedomain: registered %s\n", voltdm->name); |
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 966aa8880345..5063ab33af7b 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h | |||
@@ -19,6 +19,8 @@ | |||
19 | #include "vc.h" | 19 | #include "vc.h" |
20 | #include "vp.h" | 20 | #include "vp.h" |
21 | 21 | ||
22 | struct powerdomain; | ||
23 | |||
22 | /* XXX document */ | 24 | /* XXX document */ |
23 | #define VOLTSCALE_VPFORCEUPDATE 1 | 25 | #define VOLTSCALE_VPFORCEUPDATE 1 |
24 | #define VOLTSCALE_VCBYPASS 2 | 26 | #define VOLTSCALE_VCBYPASS 2 |
@@ -55,12 +57,14 @@ struct omap_vfsm_instance_data { | |||
55 | * @name: Name of the voltage domain which can be used as a unique identifier. | 57 | * @name: Name of the voltage domain which can be used as a unique identifier. |
56 | * @scalable: Whether or not this voltage domain is scalable | 58 | * @scalable: Whether or not this voltage domain is scalable |
57 | * @node: list_head linking all voltage domains | 59 | * @node: list_head linking all voltage domains |
60 | * @pwrdm_list: list_head linking all powerdomains in this voltagedomain | ||
58 | * @vdd: to be removed | 61 | * @vdd: to be removed |
59 | */ | 62 | */ |
60 | struct voltagedomain { | 63 | struct voltagedomain { |
61 | char *name; | 64 | char *name; |
62 | bool scalable; | 65 | bool scalable; |
63 | struct list_head node; | 66 | struct list_head node; |
67 | struct list_head pwrdm_list; | ||
64 | struct omap_vdd_info *vdd; | 68 | struct omap_vdd_info *vdd; |
65 | }; | 69 | }; |
66 | 70 | ||
@@ -187,4 +191,9 @@ extern void omap44xx_voltagedomains_init(void); | |||
187 | struct voltagedomain *voltdm_lookup(const char *name); | 191 | struct voltagedomain *voltdm_lookup(const char *name); |
188 | void voltdm_init(struct voltagedomain **voltdm_list); | 192 | void voltdm_init(struct voltagedomain **voltdm_list); |
189 | int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); | 193 | int voltdm_add_pwrdm(struct voltagedomain *voltdm, struct powerdomain *pwrdm); |
194 | int voltdm_for_each(int (*fn)(struct voltagedomain *voltdm, void *user), | ||
195 | void *user); | ||
196 | int voltdm_for_each_pwrdm(struct voltagedomain *voltdm, | ||
197 | int (*fn)(struct voltagedomain *voltdm, | ||
198 | struct powerdomain *pwrdm)); | ||
190 | #endif | 199 | #endif |