diff options
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 288 |
1 files changed, 204 insertions, 84 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 70912d1c71e0..c6649472ce0d 100644 --- a/arch/arm/mach-omap2/omap_hwmod.c +++ b/arch/arm/mach-omap2/omap_hwmod.c | |||
@@ -84,17 +84,16 @@ static u8 inited; | |||
84 | */ | 84 | */ |
85 | static int _update_sysc_cache(struct omap_hwmod *oh) | 85 | static int _update_sysc_cache(struct omap_hwmod *oh) |
86 | { | 86 | { |
87 | if (!oh->sysconfig) { | 87 | if (!oh->class->sysc) { |
88 | WARN(!oh->sysconfig, "omap_hwmod: %s: cannot read " | 88 | WARN(1, "omap_hwmod: %s: cannot read OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); |
89 | "OCP_SYSCONFIG: not defined on hwmod\n", oh->name); | ||
90 | return -EINVAL; | 89 | return -EINVAL; |
91 | } | 90 | } |
92 | 91 | ||
93 | /* XXX ensure module interface clock is up */ | 92 | /* XXX ensure module interface clock is up */ |
94 | 93 | ||
95 | oh->_sysc_cache = omap_hwmod_readl(oh, oh->sysconfig->sysc_offs); | 94 | oh->_sysc_cache = omap_hwmod_readl(oh, oh->class->sysc->sysc_offs); |
96 | 95 | ||
97 | if (!(oh->sysconfig->sysc_flags & SYSC_NO_CACHE)) | 96 | if (!(oh->class->sysc->sysc_flags & SYSC_NO_CACHE)) |
98 | oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; | 97 | oh->_int_flags |= _HWMOD_SYSCONFIG_LOADED; |
99 | 98 | ||
100 | return 0; | 99 | return 0; |
@@ -105,14 +104,13 @@ static int _update_sysc_cache(struct omap_hwmod *oh) | |||
105 | * @v: OCP_SYSCONFIG value to write | 104 | * @v: OCP_SYSCONFIG value to write |
106 | * @oh: struct omap_hwmod * | 105 | * @oh: struct omap_hwmod * |
107 | * | 106 | * |
108 | * Write @v into the module OCP_SYSCONFIG register, if it has one. No | 107 | * Write @v into the module class' OCP_SYSCONFIG register, if it has |
109 | * return value. | 108 | * one. No return value. |
110 | */ | 109 | */ |
111 | static void _write_sysconfig(u32 v, struct omap_hwmod *oh) | 110 | static void _write_sysconfig(u32 v, struct omap_hwmod *oh) |
112 | { | 111 | { |
113 | if (!oh->sysconfig) { | 112 | if (!oh->class->sysc) { |
114 | WARN(!oh->sysconfig, "omap_hwmod: %s: cannot write " | 113 | WARN(1, "omap_hwmod: %s: cannot write OCP_SYSCONFIG: not defined on hwmod's class\n", oh->name); |
115 | "OCP_SYSCONFIG: not defined on hwmod\n", oh->name); | ||
116 | return; | 114 | return; |
117 | } | 115 | } |
118 | 116 | ||
@@ -120,7 +118,7 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh) | |||
120 | 118 | ||
121 | if (oh->_sysc_cache != v) { | 119 | if (oh->_sysc_cache != v) { |
122 | oh->_sysc_cache = v; | 120 | oh->_sysc_cache = v; |
123 | omap_hwmod_writel(v, oh, oh->sysconfig->sysc_offs); | 121 | omap_hwmod_writel(v, oh, oh->class->sysc->sysc_offs); |
124 | } | 122 | } |
125 | } | 123 | } |
126 | 124 | ||
@@ -137,12 +135,23 @@ static void _write_sysconfig(u32 v, struct omap_hwmod *oh) | |||
137 | static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, | 135 | static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, |
138 | u32 *v) | 136 | u32 *v) |
139 | { | 137 | { |
140 | if (!oh->sysconfig || | 138 | u32 mstandby_mask; |
141 | !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) | 139 | u8 mstandby_shift; |
140 | |||
141 | if (!oh->class->sysc || | ||
142 | !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) | ||
143 | return -EINVAL; | ||
144 | |||
145 | if (!oh->class->sysc->sysc_fields) { | ||
146 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); | ||
142 | return -EINVAL; | 147 | return -EINVAL; |
148 | } | ||
143 | 149 | ||
144 | *v &= ~SYSC_MIDLEMODE_MASK; | 150 | mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; |
145 | *v |= __ffs(standbymode) << SYSC_MIDLEMODE_SHIFT; | 151 | mstandby_mask = (0x3 << mstandby_shift); |
152 | |||
153 | *v &= ~mstandby_mask; | ||
154 | *v |= __ffs(standbymode) << mstandby_shift; | ||
146 | 155 | ||
147 | return 0; | 156 | return 0; |
148 | } | 157 | } |
@@ -159,12 +168,23 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, | |||
159 | */ | 168 | */ |
160 | static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) | 169 | static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) |
161 | { | 170 | { |
162 | if (!oh->sysconfig || | 171 | u32 sidle_mask; |
163 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)) | 172 | u8 sidle_shift; |
173 | |||
174 | if (!oh->class->sysc || | ||
175 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) | ||
164 | return -EINVAL; | 176 | return -EINVAL; |
165 | 177 | ||
166 | *v &= ~SYSC_SIDLEMODE_MASK; | 178 | if (!oh->class->sysc->sysc_fields) { |
167 | *v |= __ffs(idlemode) << SYSC_SIDLEMODE_SHIFT; | 179 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
180 | return -EINVAL; | ||
181 | } | ||
182 | |||
183 | sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; | ||
184 | sidle_mask = (0x3 << sidle_shift); | ||
185 | |||
186 | *v &= ~sidle_mask; | ||
187 | *v |= __ffs(idlemode) << sidle_shift; | ||
168 | 188 | ||
169 | return 0; | 189 | return 0; |
170 | } | 190 | } |
@@ -182,12 +202,23 @@ static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) | |||
182 | */ | 202 | */ |
183 | static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) | 203 | static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) |
184 | { | 204 | { |
185 | if (!oh->sysconfig || | 205 | u32 clkact_mask; |
186 | !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) | 206 | u8 clkact_shift; |
207 | |||
208 | if (!oh->class->sysc || | ||
209 | !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) | ||
187 | return -EINVAL; | 210 | return -EINVAL; |
188 | 211 | ||
189 | *v &= ~SYSC_CLOCKACTIVITY_MASK; | 212 | if (!oh->class->sysc->sysc_fields) { |
190 | *v |= clockact << SYSC_CLOCKACTIVITY_SHIFT; | 213 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
214 | return -EINVAL; | ||
215 | } | ||
216 | |||
217 | clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; | ||
218 | clkact_mask = (0x3 << clkact_shift); | ||
219 | |||
220 | *v &= ~clkact_mask; | ||
221 | *v |= clockact << clkact_shift; | ||
191 | 222 | ||
192 | return 0; | 223 | return 0; |
193 | } | 224 | } |
@@ -202,11 +233,20 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) | |||
202 | */ | 233 | */ |
203 | static int _set_softreset(struct omap_hwmod *oh, u32 *v) | 234 | static int _set_softreset(struct omap_hwmod *oh, u32 *v) |
204 | { | 235 | { |
205 | if (!oh->sysconfig || | 236 | u32 softrst_mask; |
206 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET)) | 237 | |
238 | if (!oh->class->sysc || | ||
239 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) | ||
240 | return -EINVAL; | ||
241 | |||
242 | if (!oh->class->sysc->sysc_fields) { | ||
243 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); | ||
207 | return -EINVAL; | 244 | return -EINVAL; |
245 | } | ||
208 | 246 | ||
209 | *v |= SYSC_SOFTRESET_MASK; | 247 | softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); |
248 | |||
249 | *v |= softrst_mask; | ||
210 | 250 | ||
211 | return 0; | 251 | return 0; |
212 | } | 252 | } |
@@ -227,12 +267,23 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v) | |||
227 | static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, | 267 | static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, |
228 | u32 *v) | 268 | u32 *v) |
229 | { | 269 | { |
230 | if (!oh->sysconfig || | 270 | u32 autoidle_mask; |
231 | !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) | 271 | u8 autoidle_shift; |
272 | |||
273 | if (!oh->class->sysc || | ||
274 | !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) | ||
232 | return -EINVAL; | 275 | return -EINVAL; |
233 | 276 | ||
234 | *v &= ~SYSC_AUTOIDLE_MASK; | 277 | if (!oh->class->sysc->sysc_fields) { |
235 | *v |= autoidle << SYSC_AUTOIDLE_SHIFT; | 278 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
279 | return -EINVAL; | ||
280 | } | ||
281 | |||
282 | autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; | ||
283 | autoidle_mask = (0x3 << autoidle_shift); | ||
284 | |||
285 | *v &= ~autoidle_mask; | ||
286 | *v |= autoidle << autoidle_shift; | ||
236 | 287 | ||
237 | return 0; | 288 | return 0; |
238 | } | 289 | } |
@@ -246,14 +297,21 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, | |||
246 | */ | 297 | */ |
247 | static int _enable_wakeup(struct omap_hwmod *oh) | 298 | static int _enable_wakeup(struct omap_hwmod *oh) |
248 | { | 299 | { |
249 | u32 v; | 300 | u32 v, wakeup_mask; |
250 | 301 | ||
251 | if (!oh->sysconfig || | 302 | if (!oh->class->sysc || |
252 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 303 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
253 | return -EINVAL; | 304 | return -EINVAL; |
254 | 305 | ||
306 | if (!oh->class->sysc->sysc_fields) { | ||
307 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); | ||
308 | return -EINVAL; | ||
309 | } | ||
310 | |||
311 | wakeup_mask = (0x1 << oh->class->sysc->sysc_fields->enwkup_shift); | ||
312 | |||
255 | v = oh->_sysc_cache; | 313 | v = oh->_sysc_cache; |
256 | v |= SYSC_ENAWAKEUP_MASK; | 314 | v |= wakeup_mask; |
257 | _write_sysconfig(v, oh); | 315 | _write_sysconfig(v, oh); |
258 | 316 | ||
259 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ | 317 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ |
@@ -272,14 +330,21 @@ static int _enable_wakeup(struct omap_hwmod *oh) | |||
272 | */ | 330 | */ |
273 | static int _disable_wakeup(struct omap_hwmod *oh) | 331 | static int _disable_wakeup(struct omap_hwmod *oh) |
274 | { | 332 | { |
275 | u32 v; | 333 | u32 v, wakeup_mask; |
334 | |||
335 | if (!oh->class->sysc || | ||
336 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) | ||
337 | return -EINVAL; | ||
276 | 338 | ||
277 | if (!oh->sysconfig || | 339 | if (!oh->class->sysc->sysc_fields) { |
278 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 340 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
279 | return -EINVAL; | 341 | return -EINVAL; |
342 | } | ||
343 | |||
344 | wakeup_mask = (0x1 << oh->class->sysc->sysc_fields->enwkup_shift); | ||
280 | 345 | ||
281 | v = oh->_sysc_cache; | 346 | v = oh->_sysc_cache; |
282 | v &= ~SYSC_ENAWAKEUP_MASK; | 347 | v &= ~wakeup_mask; |
283 | _write_sysconfig(v, oh); | 348 | _write_sysconfig(v, oh); |
284 | 349 | ||
285 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ | 350 | /* XXX test pwrdm_get_wken for this hwmod's subsystem */ |
@@ -342,18 +407,18 @@ static int _init_main_clk(struct omap_hwmod *oh) | |||
342 | struct clk *c; | 407 | struct clk *c; |
343 | int ret = 0; | 408 | int ret = 0; |
344 | 409 | ||
345 | if (!oh->clkdev_con_id) | 410 | if (!oh->main_clk) |
346 | return 0; | 411 | return 0; |
347 | 412 | ||
348 | c = clk_get_sys(oh->clkdev_dev_id, oh->clkdev_con_id); | 413 | c = omap_clk_get_by_name(oh->main_clk); |
349 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get main_clk %s.%s\n", | 414 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get main_clk %s\n", |
350 | oh->name, oh->clkdev_dev_id, oh->clkdev_con_id); | 415 | oh->name, oh->main_clk); |
351 | if (IS_ERR(c)) | 416 | if (IS_ERR(c)) |
352 | ret = -EINVAL; | 417 | ret = -EINVAL; |
353 | oh->_clk = c; | 418 | oh->_clk = c; |
354 | 419 | ||
355 | WARN(!c->clkdm, "omap_hwmod: %s: missing clockdomain for %s.\n", | 420 | WARN(!c->clkdm, "omap_hwmod: %s: missing clockdomain for %s.\n", |
356 | oh->clkdev_con_id, c->name); | 421 | oh->main_clk, c->name); |
357 | 422 | ||
358 | return ret; | 423 | return ret; |
359 | } | 424 | } |
@@ -376,13 +441,12 @@ static int _init_interface_clks(struct omap_hwmod *oh) | |||
376 | return 0; | 441 | return 0; |
377 | 442 | ||
378 | for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) { | 443 | for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) { |
379 | if (!os->clkdev_con_id) | 444 | if (!os->clk) |
380 | continue; | 445 | continue; |
381 | 446 | ||
382 | c = clk_get_sys(os->clkdev_dev_id, os->clkdev_con_id); | 447 | c = omap_clk_get_by_name(os->clk); |
383 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get " | 448 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get " |
384 | "interface_clk %s.%s\n", oh->name, | 449 | "interface_clk %s\n", oh->name, os->clk); |
385 | os->clkdev_dev_id, os->clkdev_con_id); | ||
386 | if (IS_ERR(c)) | 450 | if (IS_ERR(c)) |
387 | ret = -EINVAL; | 451 | ret = -EINVAL; |
388 | os->_clk = c; | 452 | os->_clk = c; |
@@ -406,10 +470,9 @@ static int _init_opt_clks(struct omap_hwmod *oh) | |||
406 | int ret = 0; | 470 | int ret = 0; |
407 | 471 | ||
408 | for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { | 472 | for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) { |
409 | c = clk_get_sys(oc->clkdev_dev_id, oc->clkdev_con_id); | 473 | c = omap_clk_get_by_name(oc->clk); |
410 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get opt_clk " | 474 | WARN(IS_ERR(c), "omap_hwmod: %s: cannot clk_get opt_clk " |
411 | "%s.%s\n", oh->name, oc->clkdev_dev_id, | 475 | "%s\n", oh->name, oc->clk); |
412 | oc->clkdev_con_id); | ||
413 | if (IS_ERR(c)) | 476 | if (IS_ERR(c)) |
414 | ret = -EINVAL; | 477 | ret = -EINVAL; |
415 | oc->_clk = c; | 478 | oc->_clk = c; |
@@ -566,27 +629,28 @@ static void __iomem *_find_mpu_rt_base(struct omap_hwmod *oh, u8 index) | |||
566 | */ | 629 | */ |
567 | static void _sysc_enable(struct omap_hwmod *oh) | 630 | static void _sysc_enable(struct omap_hwmod *oh) |
568 | { | 631 | { |
569 | u8 idlemode; | 632 | u8 idlemode, sf; |
570 | u32 v; | 633 | u32 v; |
571 | 634 | ||
572 | if (!oh->sysconfig) | 635 | if (!oh->class->sysc) |
573 | return; | 636 | return; |
574 | 637 | ||
575 | v = oh->_sysc_cache; | 638 | v = oh->_sysc_cache; |
639 | sf = oh->class->sysc->sysc_flags; | ||
576 | 640 | ||
577 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) { | 641 | if (sf & SYSC_HAS_SIDLEMODE) { |
578 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? | 642 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? |
579 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; | 643 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; |
580 | _set_slave_idlemode(oh, idlemode, &v); | 644 | _set_slave_idlemode(oh, idlemode, &v); |
581 | } | 645 | } |
582 | 646 | ||
583 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) { | 647 | if (sf & SYSC_HAS_MIDLEMODE) { |
584 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? | 648 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? |
585 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; | 649 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; |
586 | _set_master_standbymode(oh, idlemode, &v); | 650 | _set_master_standbymode(oh, idlemode, &v); |
587 | } | 651 | } |
588 | 652 | ||
589 | if (oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE) { | 653 | if (sf & SYSC_HAS_AUTOIDLE) { |
590 | idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? | 654 | idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? |
591 | 0 : 1; | 655 | 0 : 1; |
592 | _set_module_autoidle(oh, idlemode, &v); | 656 | _set_module_autoidle(oh, idlemode, &v); |
@@ -599,9 +663,9 @@ static void _sysc_enable(struct omap_hwmod *oh) | |||
599 | * calling into this code. But this must wait until the | 663 | * calling into this code. But this must wait until the |
600 | * clock structures are tagged with omap_hwmod entries | 664 | * clock structures are tagged with omap_hwmod entries |
601 | */ | 665 | */ |
602 | if (oh->flags & HWMOD_SET_DEFAULT_CLOCKACT && | 666 | if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && |
603 | oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY) | 667 | (sf & SYSC_HAS_CLOCKACTIVITY)) |
604 | _set_clockactivity(oh, oh->sysconfig->clockact, &v); | 668 | _set_clockactivity(oh, oh->class->sysc->clockact, &v); |
605 | 669 | ||
606 | _write_sysconfig(v, oh); | 670 | _write_sysconfig(v, oh); |
607 | } | 671 | } |
@@ -617,21 +681,22 @@ static void _sysc_enable(struct omap_hwmod *oh) | |||
617 | */ | 681 | */ |
618 | static void _sysc_idle(struct omap_hwmod *oh) | 682 | static void _sysc_idle(struct omap_hwmod *oh) |
619 | { | 683 | { |
620 | u8 idlemode; | 684 | u8 idlemode, sf; |
621 | u32 v; | 685 | u32 v; |
622 | 686 | ||
623 | if (!oh->sysconfig) | 687 | if (!oh->class->sysc) |
624 | return; | 688 | return; |
625 | 689 | ||
626 | v = oh->_sysc_cache; | 690 | v = oh->_sysc_cache; |
691 | sf = oh->class->sysc->sysc_flags; | ||
627 | 692 | ||
628 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) { | 693 | if (sf & SYSC_HAS_SIDLEMODE) { |
629 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? | 694 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? |
630 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; | 695 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; |
631 | _set_slave_idlemode(oh, idlemode, &v); | 696 | _set_slave_idlemode(oh, idlemode, &v); |
632 | } | 697 | } |
633 | 698 | ||
634 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) { | 699 | if (sf & SYSC_HAS_MIDLEMODE) { |
635 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? | 700 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? |
636 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; | 701 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; |
637 | _set_master_standbymode(oh, idlemode, &v); | 702 | _set_master_standbymode(oh, idlemode, &v); |
@@ -650,19 +715,21 @@ static void _sysc_idle(struct omap_hwmod *oh) | |||
650 | static void _sysc_shutdown(struct omap_hwmod *oh) | 715 | static void _sysc_shutdown(struct omap_hwmod *oh) |
651 | { | 716 | { |
652 | u32 v; | 717 | u32 v; |
718 | u8 sf; | ||
653 | 719 | ||
654 | if (!oh->sysconfig) | 720 | if (!oh->class->sysc) |
655 | return; | 721 | return; |
656 | 722 | ||
657 | v = oh->_sysc_cache; | 723 | v = oh->_sysc_cache; |
724 | sf = oh->class->sysc->sysc_flags; | ||
658 | 725 | ||
659 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) | 726 | if (sf & SYSC_HAS_SIDLEMODE) |
660 | _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); | 727 | _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); |
661 | 728 | ||
662 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) | 729 | if (sf & SYSC_HAS_MIDLEMODE) |
663 | _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); | 730 | _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); |
664 | 731 | ||
665 | if (oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE) | 732 | if (sf & SYSC_HAS_AUTOIDLE) |
666 | _set_module_autoidle(oh, 1, &v); | 733 | _set_module_autoidle(oh, 1, &v); |
667 | 734 | ||
668 | _write_sysconfig(v, oh); | 735 | _write_sysconfig(v, oh); |
@@ -779,9 +846,9 @@ static int _reset(struct omap_hwmod *oh) | |||
779 | u32 r, v; | 846 | u32 r, v; |
780 | int c = 0; | 847 | int c = 0; |
781 | 848 | ||
782 | if (!oh->sysconfig || | 849 | if (!oh->class->sysc || |
783 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET) || | 850 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET) || |
784 | (oh->sysconfig->sysc_flags & SYSS_MISSING)) | 851 | (oh->class->sysc->sysc_flags & SYSS_MISSING)) |
785 | return -EINVAL; | 852 | return -EINVAL; |
786 | 853 | ||
787 | /* clocks must be on for this operation */ | 854 | /* clocks must be on for this operation */ |
@@ -799,7 +866,7 @@ static int _reset(struct omap_hwmod *oh) | |||
799 | return r; | 866 | return r; |
800 | _write_sysconfig(v, oh); | 867 | _write_sysconfig(v, oh); |
801 | 868 | ||
802 | omap_test_timeout((omap_hwmod_readl(oh, oh->sysconfig->syss_offs) & | 869 | omap_test_timeout((omap_hwmod_readl(oh, oh->class->sysc->syss_offs) & |
803 | SYSS_RESETDONE_MASK), | 870 | SYSS_RESETDONE_MASK), |
804 | MAX_MODULE_RESET_WAIT, c); | 871 | MAX_MODULE_RESET_WAIT, c); |
805 | 872 | ||
@@ -845,7 +912,7 @@ static int _enable(struct omap_hwmod *oh) | |||
845 | _add_initiator_dep(oh, mpu_oh); | 912 | _add_initiator_dep(oh, mpu_oh); |
846 | _enable_clocks(oh); | 913 | _enable_clocks(oh); |
847 | 914 | ||
848 | if (oh->sysconfig) { | 915 | if (oh->class->sysc) { |
849 | if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) | 916 | if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) |
850 | _update_sysc_cache(oh); | 917 | _update_sysc_cache(oh); |
851 | _sysc_enable(oh); | 918 | _sysc_enable(oh); |
@@ -876,7 +943,7 @@ static int _idle(struct omap_hwmod *oh) | |||
876 | 943 | ||
877 | pr_debug("omap_hwmod: %s: idling\n", oh->name); | 944 | pr_debug("omap_hwmod: %s: idling\n", oh->name); |
878 | 945 | ||
879 | if (oh->sysconfig) | 946 | if (oh->class->sysc) |
880 | _sysc_idle(oh); | 947 | _sysc_idle(oh); |
881 | _del_initiator_dep(oh, mpu_oh); | 948 | _del_initiator_dep(oh, mpu_oh); |
882 | _disable_clocks(oh); | 949 | _disable_clocks(oh); |
@@ -906,7 +973,7 @@ static int _shutdown(struct omap_hwmod *oh) | |||
906 | 973 | ||
907 | pr_debug("omap_hwmod: %s: disabling\n", oh->name); | 974 | pr_debug("omap_hwmod: %s: disabling\n", oh->name); |
908 | 975 | ||
909 | if (oh->sysconfig) | 976 | if (oh->class->sysc) |
910 | _sysc_shutdown(oh); | 977 | _sysc_shutdown(oh); |
911 | _del_initiator_dep(oh, mpu_oh); | 978 | _del_initiator_dep(oh, mpu_oh); |
912 | /* XXX what about the other system initiators here? DMA, tesla, d2d */ | 979 | /* XXX what about the other system initiators here? DMA, tesla, d2d */ |
@@ -966,7 +1033,7 @@ static int _setup(struct omap_hwmod *oh) | |||
966 | * _enable() function should be split to avoid the | 1033 | * _enable() function should be split to avoid the |
967 | * rewrite of the OCP_SYSCONFIG register. | 1034 | * rewrite of the OCP_SYSCONFIG register. |
968 | */ | 1035 | */ |
969 | if (oh->sysconfig) { | 1036 | if (oh->class->sysc) { |
970 | _update_sysc_cache(oh); | 1037 | _update_sysc_cache(oh); |
971 | _sysc_enable(oh); | 1038 | _sysc_enable(oh); |
972 | } | 1039 | } |
@@ -1013,9 +1080,12 @@ int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) | |||
1013 | * omap_hwmod_register - register a struct omap_hwmod | 1080 | * omap_hwmod_register - register a struct omap_hwmod |
1014 | * @oh: struct omap_hwmod * | 1081 | * @oh: struct omap_hwmod * |
1015 | * | 1082 | * |
1016 | * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod already | 1083 | * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod |
1017 | * has been registered by the same name; -EINVAL if the omap_hwmod is in the | 1084 | * already has been registered by the same name; -EINVAL if the |
1018 | * wrong state, or 0 on success. | 1085 | * omap_hwmod is in the wrong state, if @oh is NULL, if the |
1086 | * omap_hwmod's class field is NULL; if the omap_hwmod is missing a | ||
1087 | * name, or if the omap_hwmod's class is missing a name; or 0 upon | ||
1088 | * success. | ||
1019 | * | 1089 | * |
1020 | * XXX The data should be copied into bootmem, so the original data | 1090 | * XXX The data should be copied into bootmem, so the original data |
1021 | * should be marked __initdata and freed after init. This would allow | 1091 | * should be marked __initdata and freed after init. This would allow |
@@ -1027,7 +1097,8 @@ int omap_hwmod_register(struct omap_hwmod *oh) | |||
1027 | { | 1097 | { |
1028 | int ret, ms_id; | 1098 | int ret, ms_id; |
1029 | 1099 | ||
1030 | if (!oh || (oh->_state != _HWMOD_STATE_UNKNOWN)) | 1100 | if (!oh || !oh->name || !oh->class || !oh->class->name || |
1101 | (oh->_state != _HWMOD_STATE_UNKNOWN)) | ||
1031 | return -EINVAL; | 1102 | return -EINVAL; |
1032 | 1103 | ||
1033 | mutex_lock(&omap_hwmod_mutex); | 1104 | mutex_lock(&omap_hwmod_mutex); |
@@ -1300,7 +1371,7 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh) | |||
1300 | { | 1371 | { |
1301 | BUG_ON(!oh); | 1372 | BUG_ON(!oh); |
1302 | 1373 | ||
1303 | if (!oh->sysconfig || !oh->sysconfig->sysc_flags) { | 1374 | if (!oh->class->sysc || !oh->class->sysc->sysc_flags) { |
1304 | WARN(1, "omap_device: %s: OCP barrier impossible due to " | 1375 | WARN(1, "omap_device: %s: OCP barrier impossible due to " |
1305 | "device configuration\n", oh->name); | 1376 | "device configuration\n", oh->name); |
1306 | return; | 1377 | return; |
@@ -1310,7 +1381,7 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh) | |||
1310 | * Forces posted writes to complete on the OCP thread handling | 1381 | * Forces posted writes to complete on the OCP thread handling |
1311 | * register writes | 1382 | * register writes |
1312 | */ | 1383 | */ |
1313 | omap_hwmod_readl(oh, oh->sysconfig->sysc_offs); | 1384 | omap_hwmod_readl(oh, oh->class->sysc->sysc_offs); |
1314 | } | 1385 | } |
1315 | 1386 | ||
1316 | /** | 1387 | /** |
@@ -1503,8 +1574,8 @@ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh, | |||
1503 | */ | 1574 | */ |
1504 | int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) | 1575 | int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) |
1505 | { | 1576 | { |
1506 | if (!oh->sysconfig || | 1577 | if (!oh->class->sysc || |
1507 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 1578 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
1508 | return -EINVAL; | 1579 | return -EINVAL; |
1509 | 1580 | ||
1510 | mutex_lock(&omap_hwmod_mutex); | 1581 | mutex_lock(&omap_hwmod_mutex); |
@@ -1528,8 +1599,8 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) | |||
1528 | */ | 1599 | */ |
1529 | int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | 1600 | int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) |
1530 | { | 1601 | { |
1531 | if (!oh->sysconfig || | 1602 | if (!oh->class->sysc || |
1532 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 1603 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
1533 | return -EINVAL; | 1604 | return -EINVAL; |
1534 | 1605 | ||
1535 | mutex_lock(&omap_hwmod_mutex); | 1606 | mutex_lock(&omap_hwmod_mutex); |
@@ -1538,3 +1609,52 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | |||
1538 | 1609 | ||
1539 | return 0; | 1610 | return 0; |
1540 | } | 1611 | } |
1612 | |||
1613 | /** | ||
1614 | * omap_hwmod_for_each_by_class - call @fn for each hwmod of class @classname | ||
1615 | * @classname: struct omap_hwmod_class name to search for | ||
1616 | * @fn: callback function pointer to call for each hwmod in class @classname | ||
1617 | * @user: arbitrary context data to pass to the callback function | ||
1618 | * | ||
1619 | * For each omap_hwmod of class @classname, call @fn. Takes | ||
1620 | * omap_hwmod_mutex to prevent the hwmod list from changing during the | ||
1621 | * iteration. If the callback function returns something other than | ||
1622 | * zero, the iterator is terminated, and the callback function's return | ||
1623 | * value is passed back to the caller. Returns 0 upon success, -EINVAL | ||
1624 | * if @classname or @fn are NULL, or passes back the error code from @fn. | ||
1625 | */ | ||
1626 | int omap_hwmod_for_each_by_class(const char *classname, | ||
1627 | int (*fn)(struct omap_hwmod *oh, | ||
1628 | void *user), | ||
1629 | void *user) | ||
1630 | { | ||
1631 | struct omap_hwmod *temp_oh; | ||
1632 | int ret = 0; | ||
1633 | |||
1634 | if (!classname || !fn) | ||
1635 | return -EINVAL; | ||
1636 | |||
1637 | pr_debug("omap_hwmod: %s: looking for modules of class %s\n", | ||
1638 | __func__, classname); | ||
1639 | |||
1640 | mutex_lock(&omap_hwmod_mutex); | ||
1641 | |||
1642 | list_for_each_entry(temp_oh, &omap_hwmod_list, node) { | ||
1643 | if (!strcmp(temp_oh->class->name, classname)) { | ||
1644 | pr_debug("omap_hwmod: %s: %s: calling callback fn\n", | ||
1645 | __func__, temp_oh->name); | ||
1646 | ret = (*fn)(temp_oh, user); | ||
1647 | if (ret) | ||
1648 | break; | ||
1649 | } | ||
1650 | } | ||
1651 | |||
1652 | mutex_unlock(&omap_hwmod_mutex); | ||
1653 | |||
1654 | if (ret) | ||
1655 | pr_debug("omap_hwmod: %s: iterator terminated early: %d\n", | ||
1656 | __func__, ret); | ||
1657 | |||
1658 | return ret; | ||
1659 | } | ||
1660 | |||