aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorThara Gopinath <thara@ti.com>2010-02-24 14:05:58 -0500
committerPaul Walmsley <paul@pwsan.com>2010-02-24 14:05:58 -0500
commit358f0e630d5409ab3837b86db3595560eae773b6 (patch)
tree0b4d6d8c555bee693f50819e7d717a43548643a5 /arch/arm/mach-omap2/omap_hwmod.c
parent5eb75f557843132da08938609def2774ee467d95 (diff)
OMAP3: hwmod: support to specify the offset position of various SYSCONFIG register bits.
In OMAP3 Some modules like Smartreflex do not have the regular sysconfig register.Instead clockactivity bits are part of another register at a different bit position than the usual bit positions 8 and 9. In OMAP4, a new scheme is available due to the new protocol between the PRCM and the IPs. Depending of the scheme, the SYSCONFIG bitfields position will be different. The IP_REVISION register should be at offset 0x00. It should contain a SCHEME field. From this we can determine whether the IP follows legacy scheme or the new scheme. 31:30 SCHEME Used to distinguish between old scheme and current. Read 0x0: Legacy protocol. Read 0x1: New PRCM protocol defined for new OMAP4 IPs For legacy IP 13:12 MIDLEMODE 11:8 CLOCKACTIVITY 6 EMUSOFT 5 EMUFREE 4:3 SIDLEMODE 2 ENAWAKEUP 1 SOFTRESET 0 AUTOIDLE For new OMAP4 IP's, the bit position in SYSCONFIG is (for simple target): 5:4 STANDBYMODE (Ex MIDLEMODE) 3:2 IDLEMODE (Ex SIDLEMODE) 1 FREEEMU (Ex EMUFREE) 0 SOFTRESET Unfortunately In OMAP4 also some IPs will not follow any of these two schemes. This is the case at least for McASP, SmartReflex and some security IPs. This patch introduces a new field sysc_fields in omap_hwmod_sysconfig which can be used by the hwmod structures to specify the offsets for the sysconfig register of the IP.Also two static structures omap_hwmod_sysc_type1 and omap_hwmod_sysc_type2 are defined which can be used directly to populate the sysc_fields if the IP follows legacy or new OMAP4 scheme. If the IP follows none of these two schemes a new omap_hwmod_sysc_fields structure has to be defined and passed as part of omap_hwmod_sysconfig. Signed-off-by: Thara Gopinath <thara@ti.com> Signed-off-by: Benoit Cousson <b-cousson@ti.com> Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c100
1 files changed, 87 insertions, 13 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 70912d1c71e..fb11ec176d5 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -137,12 +137,24 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh)
137static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, 137static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
138 u32 *v) 138 u32 *v)
139{ 139{
140 u32 mstandby_mask;
141 u8 mstandby_shift;
142
140 if (!oh->sysconfig || 143 if (!oh->sysconfig ||
141 !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) 144 !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE))
142 return -EINVAL; 145 return -EINVAL;
143 146
144 *v &= ~SYSC_MIDLEMODE_MASK; 147 if (!oh->sysconfig->sysc_fields) {
145 *v |= __ffs(standbymode) << SYSC_MIDLEMODE_SHIFT; 148 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
149 "sysconfig not provided!\n");
150 return -EINVAL;
151 }
152
153 mstandby_shift = oh->sysconfig->sysc_fields->midle_shift;
154 mstandby_mask = (0x3 << mstandby_shift);
155
156 *v &= ~mstandby_mask;
157 *v |= __ffs(standbymode) << mstandby_shift;
146 158
147 return 0; 159 return 0;
148} 160}
@@ -159,12 +171,24 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode,
159 */ 171 */
160static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) 172static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
161{ 173{
174 u32 sidle_mask;
175 u8 sidle_shift;
176
162 if (!oh->sysconfig || 177 if (!oh->sysconfig ||
163 !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)) 178 !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE))
164 return -EINVAL; 179 return -EINVAL;
165 180
166 *v &= ~SYSC_SIDLEMODE_MASK; 181 if (!oh->sysconfig->sysc_fields) {
167 *v |= __ffs(idlemode) << SYSC_SIDLEMODE_SHIFT; 182 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
183 "sysconfig not provided!\n");
184 return -EINVAL;
185 }
186
187 sidle_shift = oh->sysconfig->sysc_fields->sidle_shift;
188 sidle_mask = (0x3 << sidle_shift);
189
190 *v &= ~sidle_mask;
191 *v |= __ffs(idlemode) << sidle_shift;
168 192
169 return 0; 193 return 0;
170} 194}
@@ -182,12 +206,24 @@ static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v)
182 */ 206 */
183static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) 207static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
184{ 208{
209 u32 clkact_mask;
210 u8 clkact_shift;
211
185 if (!oh->sysconfig || 212 if (!oh->sysconfig ||
186 !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) 213 !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY))
187 return -EINVAL; 214 return -EINVAL;
188 215
189 *v &= ~SYSC_CLOCKACTIVITY_MASK; 216 if (!oh->sysconfig->sysc_fields) {
190 *v |= clockact << SYSC_CLOCKACTIVITY_SHIFT; 217 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
218 "sysconfig not provided!\n");
219 return -EINVAL;
220 }
221
222 clkact_shift = oh->sysconfig->sysc_fields->clkact_shift;
223 clkact_mask = (0x3 << clkact_shift);
224
225 *v &= ~clkact_mask;
226 *v |= clockact << clkact_shift;
191 227
192 return 0; 228 return 0;
193} 229}
@@ -202,11 +238,21 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v)
202 */ 238 */
203static int _set_softreset(struct omap_hwmod *oh, u32 *v) 239static int _set_softreset(struct omap_hwmod *oh, u32 *v)
204{ 240{
241 u32 softrst_mask;
242
205 if (!oh->sysconfig || 243 if (!oh->sysconfig ||
206 !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET)) 244 !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET))
207 return -EINVAL; 245 return -EINVAL;
208 246
209 *v |= SYSC_SOFTRESET_MASK; 247 if (!oh->sysconfig->sysc_fields) {
248 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
249 "sysconfig not provided!\n");
250 return -EINVAL;
251 }
252
253 softrst_mask = (0x1 << oh->sysconfig->sysc_fields->srst_shift);
254
255 *v |= softrst_mask;
210 256
211 return 0; 257 return 0;
212} 258}
@@ -227,12 +273,24 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v)
227static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, 273static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
228 u32 *v) 274 u32 *v)
229{ 275{
276 u32 autoidle_mask;
277 u8 autoidle_shift;
278
230 if (!oh->sysconfig || 279 if (!oh->sysconfig ||
231 !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) 280 !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE))
232 return -EINVAL; 281 return -EINVAL;
233 282
234 *v &= ~SYSC_AUTOIDLE_MASK; 283 if (!oh->sysconfig->sysc_fields) {
235 *v |= autoidle << SYSC_AUTOIDLE_SHIFT; 284 WARN(oh->sysconfig->sysc_fields, "offset struct for "
285 "sysconfig not provided!\n");
286 return -EINVAL;
287 }
288
289 autoidle_shift = oh->sysconfig->sysc_fields->autoidle_shift;
290 autoidle_mask = (0x3 << autoidle_shift);
291
292 *v &= ~autoidle_mask;
293 *v |= autoidle << autoidle_shift;
236 294
237 return 0; 295 return 0;
238} 296}
@@ -246,14 +304,22 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle,
246 */ 304 */
247static int _enable_wakeup(struct omap_hwmod *oh) 305static int _enable_wakeup(struct omap_hwmod *oh)
248{ 306{
249 u32 v; 307 u32 v, wakeup_mask;
250 308
251 if (!oh->sysconfig || 309 if (!oh->sysconfig ||
252 !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) 310 !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP))
253 return -EINVAL; 311 return -EINVAL;
254 312
313 if (!oh->sysconfig->sysc_fields) {
314 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
315 "sysconfig not provided!\n");
316 return -EINVAL;
317 }
318
319 wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift);
320
255 v = oh->_sysc_cache; 321 v = oh->_sysc_cache;
256 v |= SYSC_ENAWAKEUP_MASK; 322 v |= wakeup_mask;
257 _write_sysconfig(v, oh); 323 _write_sysconfig(v, oh);
258 324
259 /* XXX test pwrdm_get_wken for this hwmod's subsystem */ 325 /* XXX test pwrdm_get_wken for this hwmod's subsystem */
@@ -272,14 +338,22 @@ static int _enable_wakeup(struct omap_hwmod *oh)
272 */ 338 */
273static int _disable_wakeup(struct omap_hwmod *oh) 339static int _disable_wakeup(struct omap_hwmod *oh)
274{ 340{
275 u32 v; 341 u32 v, wakeup_mask;
276 342
277 if (!oh->sysconfig || 343 if (!oh->sysconfig ||
278 !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) 344 !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP))
279 return -EINVAL; 345 return -EINVAL;
280 346
347 if (!oh->sysconfig->sysc_fields) {
348 WARN(!oh->sysconfig->sysc_fields, "offset struct for "
349 "sysconfig not provided!\n");
350 return -EINVAL;
351 }
352
353 wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift);
354
281 v = oh->_sysc_cache; 355 v = oh->_sysc_cache;
282 v &= ~SYSC_ENAWAKEUP_MASK; 356 v &= ~wakeup_mask;
283 _write_sysconfig(v, oh); 357 _write_sysconfig(v, oh);
284 358
285 /* XXX test pwrdm_get_wken for this hwmod's subsystem */ 359 /* XXX test pwrdm_get_wken for this hwmod's subsystem */