diff options
author | Paul Walmsley <paul@pwsan.com> | 2010-02-23 00:09:34 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2010-02-24 19:45:14 -0500 |
commit | 43b40992ce21def8d5957f32d7ddb728af89bfce (patch) | |
tree | 2e6f25d2d3d5cfbea42564d25cd887279ee8ab00 /arch/arm/mach-omap2/omap_hwmod.c | |
parent | 7359154e94623f6a5a68a77b9fcfbef40633c93f (diff) |
OMAP hwmod: add hwmod class support
Add support for categorizing and iterating over hardware IP blocks by
the "class" of the IP block. The class is the type of the IP block:
e.g., "timer", "timer1ms", etc. Move the OCP_SYSCONFIG/SYSSTATUS data
from the struct omap_hwmod into the struct omap_hwmod_class, since
it's expected to stay consistent for each class. While here, fix some
comments.
The hwmod_class structures in this patch were designed and proposed by
Benoît Cousson <b-cousson@ti.com> and were refined in a discussion
between Thara Gopinath <thara@ti.com>, Kevin Hilman
<khilman@deeprootsystems.com>, and myself.
This patch uses WARN() lines that are longer than 80 characters, as
Kevin noted a broader lkml consensus to increase greppability by
keeping the messages all on one line.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Benoît Cousson <b-cousson@ti.com>
Cc: Thara Gopinath <thara@ti.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r-- | arch/arm/mach-omap2/omap_hwmod.c | 222 |
1 files changed, 135 insertions, 87 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c index 501660aae962..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 | ||
@@ -140,17 +138,16 @@ static int _set_master_standbymode(struct omap_hwmod *oh, u8 standbymode, | |||
140 | u32 mstandby_mask; | 138 | u32 mstandby_mask; |
141 | u8 mstandby_shift; | 139 | u8 mstandby_shift; |
142 | 140 | ||
143 | if (!oh->sysconfig || | 141 | if (!oh->class->sysc || |
144 | !(oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE)) | 142 | !(oh->class->sysc->sysc_flags & SYSC_HAS_MIDLEMODE)) |
145 | return -EINVAL; | 143 | return -EINVAL; |
146 | 144 | ||
147 | if (!oh->sysconfig->sysc_fields) { | 145 | if (!oh->class->sysc->sysc_fields) { |
148 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 146 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
149 | "sysconfig not provided!\n"); | ||
150 | return -EINVAL; | 147 | return -EINVAL; |
151 | } | 148 | } |
152 | 149 | ||
153 | mstandby_shift = oh->sysconfig->sysc_fields->midle_shift; | 150 | mstandby_shift = oh->class->sysc->sysc_fields->midle_shift; |
154 | mstandby_mask = (0x3 << mstandby_shift); | 151 | mstandby_mask = (0x3 << mstandby_shift); |
155 | 152 | ||
156 | *v &= ~mstandby_mask; | 153 | *v &= ~mstandby_mask; |
@@ -174,17 +171,16 @@ static int _set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode, u32 *v) | |||
174 | u32 sidle_mask; | 171 | u32 sidle_mask; |
175 | u8 sidle_shift; | 172 | u8 sidle_shift; |
176 | 173 | ||
177 | if (!oh->sysconfig || | 174 | if (!oh->class->sysc || |
178 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE)) | 175 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SIDLEMODE)) |
179 | return -EINVAL; | 176 | return -EINVAL; |
180 | 177 | ||
181 | if (!oh->sysconfig->sysc_fields) { | 178 | if (!oh->class->sysc->sysc_fields) { |
182 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 179 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
183 | "sysconfig not provided!\n"); | ||
184 | return -EINVAL; | 180 | return -EINVAL; |
185 | } | 181 | } |
186 | 182 | ||
187 | sidle_shift = oh->sysconfig->sysc_fields->sidle_shift; | 183 | sidle_shift = oh->class->sysc->sysc_fields->sidle_shift; |
188 | sidle_mask = (0x3 << sidle_shift); | 184 | sidle_mask = (0x3 << sidle_shift); |
189 | 185 | ||
190 | *v &= ~sidle_mask; | 186 | *v &= ~sidle_mask; |
@@ -209,17 +205,16 @@ static int _set_clockactivity(struct omap_hwmod *oh, u8 clockact, u32 *v) | |||
209 | u32 clkact_mask; | 205 | u32 clkact_mask; |
210 | u8 clkact_shift; | 206 | u8 clkact_shift; |
211 | 207 | ||
212 | if (!oh->sysconfig || | 208 | if (!oh->class->sysc || |
213 | !(oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) | 209 | !(oh->class->sysc->sysc_flags & SYSC_HAS_CLOCKACTIVITY)) |
214 | return -EINVAL; | 210 | return -EINVAL; |
215 | 211 | ||
216 | if (!oh->sysconfig->sysc_fields) { | 212 | if (!oh->class->sysc->sysc_fields) { |
217 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 213 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
218 | "sysconfig not provided!\n"); | ||
219 | return -EINVAL; | 214 | return -EINVAL; |
220 | } | 215 | } |
221 | 216 | ||
222 | clkact_shift = oh->sysconfig->sysc_fields->clkact_shift; | 217 | clkact_shift = oh->class->sysc->sysc_fields->clkact_shift; |
223 | clkact_mask = (0x3 << clkact_shift); | 218 | clkact_mask = (0x3 << clkact_shift); |
224 | 219 | ||
225 | *v &= ~clkact_mask; | 220 | *v &= ~clkact_mask; |
@@ -240,17 +235,16 @@ static int _set_softreset(struct omap_hwmod *oh, u32 *v) | |||
240 | { | 235 | { |
241 | u32 softrst_mask; | 236 | u32 softrst_mask; |
242 | 237 | ||
243 | if (!oh->sysconfig || | 238 | if (!oh->class->sysc || |
244 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET)) | 239 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET)) |
245 | return -EINVAL; | 240 | return -EINVAL; |
246 | 241 | ||
247 | if (!oh->sysconfig->sysc_fields) { | 242 | if (!oh->class->sysc->sysc_fields) { |
248 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 243 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
249 | "sysconfig not provided!\n"); | ||
250 | return -EINVAL; | 244 | return -EINVAL; |
251 | } | 245 | } |
252 | 246 | ||
253 | softrst_mask = (0x1 << oh->sysconfig->sysc_fields->srst_shift); | 247 | softrst_mask = (0x1 << oh->class->sysc->sysc_fields->srst_shift); |
254 | 248 | ||
255 | *v |= softrst_mask; | 249 | *v |= softrst_mask; |
256 | 250 | ||
@@ -276,17 +270,16 @@ static int _set_module_autoidle(struct omap_hwmod *oh, u8 autoidle, | |||
276 | u32 autoidle_mask; | 270 | u32 autoidle_mask; |
277 | u8 autoidle_shift; | 271 | u8 autoidle_shift; |
278 | 272 | ||
279 | if (!oh->sysconfig || | 273 | if (!oh->class->sysc || |
280 | !(oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE)) | 274 | !(oh->class->sysc->sysc_flags & SYSC_HAS_AUTOIDLE)) |
281 | return -EINVAL; | 275 | return -EINVAL; |
282 | 276 | ||
283 | if (!oh->sysconfig->sysc_fields) { | 277 | if (!oh->class->sysc->sysc_fields) { |
284 | WARN(oh->sysconfig->sysc_fields, "offset struct for " | 278 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
285 | "sysconfig not provided!\n"); | ||
286 | return -EINVAL; | 279 | return -EINVAL; |
287 | } | 280 | } |
288 | 281 | ||
289 | autoidle_shift = oh->sysconfig->sysc_fields->autoidle_shift; | 282 | autoidle_shift = oh->class->sysc->sysc_fields->autoidle_shift; |
290 | autoidle_mask = (0x3 << autoidle_shift); | 283 | autoidle_mask = (0x3 << autoidle_shift); |
291 | 284 | ||
292 | *v &= ~autoidle_mask; | 285 | *v &= ~autoidle_mask; |
@@ -306,17 +299,16 @@ static int _enable_wakeup(struct omap_hwmod *oh) | |||
306 | { | 299 | { |
307 | u32 v, wakeup_mask; | 300 | u32 v, wakeup_mask; |
308 | 301 | ||
309 | if (!oh->sysconfig || | 302 | if (!oh->class->sysc || |
310 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 303 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
311 | return -EINVAL; | 304 | return -EINVAL; |
312 | 305 | ||
313 | if (!oh->sysconfig->sysc_fields) { | 306 | if (!oh->class->sysc->sysc_fields) { |
314 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 307 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
315 | "sysconfig not provided!\n"); | ||
316 | return -EINVAL; | 308 | return -EINVAL; |
317 | } | 309 | } |
318 | 310 | ||
319 | wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift); | 311 | wakeup_mask = (0x1 << oh->class->sysc->sysc_fields->enwkup_shift); |
320 | 312 | ||
321 | v = oh->_sysc_cache; | 313 | v = oh->_sysc_cache; |
322 | v |= wakeup_mask; | 314 | v |= wakeup_mask; |
@@ -340,17 +332,16 @@ static int _disable_wakeup(struct omap_hwmod *oh) | |||
340 | { | 332 | { |
341 | u32 v, wakeup_mask; | 333 | u32 v, wakeup_mask; |
342 | 334 | ||
343 | if (!oh->sysconfig || | 335 | if (!oh->class->sysc || |
344 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 336 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
345 | return -EINVAL; | 337 | return -EINVAL; |
346 | 338 | ||
347 | if (!oh->sysconfig->sysc_fields) { | 339 | if (!oh->class->sysc->sysc_fields) { |
348 | WARN(!oh->sysconfig->sysc_fields, "offset struct for " | 340 | WARN(1, "omap_hwmod: %s: offset struct for sysconfig not provided in class\n", oh->name); |
349 | "sysconfig not provided!\n"); | ||
350 | return -EINVAL; | 341 | return -EINVAL; |
351 | } | 342 | } |
352 | 343 | ||
353 | wakeup_mask = (0x1 << oh->sysconfig->sysc_fields->enwkup_shift); | 344 | wakeup_mask = (0x1 << oh->class->sysc->sysc_fields->enwkup_shift); |
354 | 345 | ||
355 | v = oh->_sysc_cache; | 346 | v = oh->_sysc_cache; |
356 | v &= ~wakeup_mask; | 347 | v &= ~wakeup_mask; |
@@ -638,27 +629,28 @@ static void __iomem *_find_mpu_rt_base(struct omap_hwmod *oh, u8 index) | |||
638 | */ | 629 | */ |
639 | static void _sysc_enable(struct omap_hwmod *oh) | 630 | static void _sysc_enable(struct omap_hwmod *oh) |
640 | { | 631 | { |
641 | u8 idlemode; | 632 | u8 idlemode, sf; |
642 | u32 v; | 633 | u32 v; |
643 | 634 | ||
644 | if (!oh->sysconfig) | 635 | if (!oh->class->sysc) |
645 | return; | 636 | return; |
646 | 637 | ||
647 | v = oh->_sysc_cache; | 638 | v = oh->_sysc_cache; |
639 | sf = oh->class->sysc->sysc_flags; | ||
648 | 640 | ||
649 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) { | 641 | if (sf & SYSC_HAS_SIDLEMODE) { |
650 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? | 642 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? |
651 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; | 643 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; |
652 | _set_slave_idlemode(oh, idlemode, &v); | 644 | _set_slave_idlemode(oh, idlemode, &v); |
653 | } | 645 | } |
654 | 646 | ||
655 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) { | 647 | if (sf & SYSC_HAS_MIDLEMODE) { |
656 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? | 648 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? |
657 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; | 649 | HWMOD_IDLEMODE_NO : HWMOD_IDLEMODE_SMART; |
658 | _set_master_standbymode(oh, idlemode, &v); | 650 | _set_master_standbymode(oh, idlemode, &v); |
659 | } | 651 | } |
660 | 652 | ||
661 | if (oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE) { | 653 | if (sf & SYSC_HAS_AUTOIDLE) { |
662 | idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? | 654 | idlemode = (oh->flags & HWMOD_NO_OCP_AUTOIDLE) ? |
663 | 0 : 1; | 655 | 0 : 1; |
664 | _set_module_autoidle(oh, idlemode, &v); | 656 | _set_module_autoidle(oh, idlemode, &v); |
@@ -671,9 +663,9 @@ static void _sysc_enable(struct omap_hwmod *oh) | |||
671 | * calling into this code. But this must wait until the | 663 | * calling into this code. But this must wait until the |
672 | * clock structures are tagged with omap_hwmod entries | 664 | * clock structures are tagged with omap_hwmod entries |
673 | */ | 665 | */ |
674 | if (oh->flags & HWMOD_SET_DEFAULT_CLOCKACT && | 666 | if ((oh->flags & HWMOD_SET_DEFAULT_CLOCKACT) && |
675 | oh->sysconfig->sysc_flags & SYSC_HAS_CLOCKACTIVITY) | 667 | (sf & SYSC_HAS_CLOCKACTIVITY)) |
676 | _set_clockactivity(oh, oh->sysconfig->clockact, &v); | 668 | _set_clockactivity(oh, oh->class->sysc->clockact, &v); |
677 | 669 | ||
678 | _write_sysconfig(v, oh); | 670 | _write_sysconfig(v, oh); |
679 | } | 671 | } |
@@ -689,21 +681,22 @@ static void _sysc_enable(struct omap_hwmod *oh) | |||
689 | */ | 681 | */ |
690 | static void _sysc_idle(struct omap_hwmod *oh) | 682 | static void _sysc_idle(struct omap_hwmod *oh) |
691 | { | 683 | { |
692 | u8 idlemode; | 684 | u8 idlemode, sf; |
693 | u32 v; | 685 | u32 v; |
694 | 686 | ||
695 | if (!oh->sysconfig) | 687 | if (!oh->class->sysc) |
696 | return; | 688 | return; |
697 | 689 | ||
698 | v = oh->_sysc_cache; | 690 | v = oh->_sysc_cache; |
691 | sf = oh->class->sysc->sysc_flags; | ||
699 | 692 | ||
700 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) { | 693 | if (sf & SYSC_HAS_SIDLEMODE) { |
701 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? | 694 | idlemode = (oh->flags & HWMOD_SWSUP_SIDLE) ? |
702 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; | 695 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; |
703 | _set_slave_idlemode(oh, idlemode, &v); | 696 | _set_slave_idlemode(oh, idlemode, &v); |
704 | } | 697 | } |
705 | 698 | ||
706 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) { | 699 | if (sf & SYSC_HAS_MIDLEMODE) { |
707 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? | 700 | idlemode = (oh->flags & HWMOD_SWSUP_MSTANDBY) ? |
708 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; | 701 | HWMOD_IDLEMODE_FORCE : HWMOD_IDLEMODE_SMART; |
709 | _set_master_standbymode(oh, idlemode, &v); | 702 | _set_master_standbymode(oh, idlemode, &v); |
@@ -722,19 +715,21 @@ static void _sysc_idle(struct omap_hwmod *oh) | |||
722 | static void _sysc_shutdown(struct omap_hwmod *oh) | 715 | static void _sysc_shutdown(struct omap_hwmod *oh) |
723 | { | 716 | { |
724 | u32 v; | 717 | u32 v; |
718 | u8 sf; | ||
725 | 719 | ||
726 | if (!oh->sysconfig) | 720 | if (!oh->class->sysc) |
727 | return; | 721 | return; |
728 | 722 | ||
729 | v = oh->_sysc_cache; | 723 | v = oh->_sysc_cache; |
724 | sf = oh->class->sysc->sysc_flags; | ||
730 | 725 | ||
731 | if (oh->sysconfig->sysc_flags & SYSC_HAS_SIDLEMODE) | 726 | if (sf & SYSC_HAS_SIDLEMODE) |
732 | _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); | 727 | _set_slave_idlemode(oh, HWMOD_IDLEMODE_FORCE, &v); |
733 | 728 | ||
734 | if (oh->sysconfig->sysc_flags & SYSC_HAS_MIDLEMODE) | 729 | if (sf & SYSC_HAS_MIDLEMODE) |
735 | _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); | 730 | _set_master_standbymode(oh, HWMOD_IDLEMODE_FORCE, &v); |
736 | 731 | ||
737 | if (oh->sysconfig->sysc_flags & SYSC_HAS_AUTOIDLE) | 732 | if (sf & SYSC_HAS_AUTOIDLE) |
738 | _set_module_autoidle(oh, 1, &v); | 733 | _set_module_autoidle(oh, 1, &v); |
739 | 734 | ||
740 | _write_sysconfig(v, oh); | 735 | _write_sysconfig(v, oh); |
@@ -851,9 +846,9 @@ static int _reset(struct omap_hwmod *oh) | |||
851 | u32 r, v; | 846 | u32 r, v; |
852 | int c = 0; | 847 | int c = 0; |
853 | 848 | ||
854 | if (!oh->sysconfig || | 849 | if (!oh->class->sysc || |
855 | !(oh->sysconfig->sysc_flags & SYSC_HAS_SOFTRESET) || | 850 | !(oh->class->sysc->sysc_flags & SYSC_HAS_SOFTRESET) || |
856 | (oh->sysconfig->sysc_flags & SYSS_MISSING)) | 851 | (oh->class->sysc->sysc_flags & SYSS_MISSING)) |
857 | return -EINVAL; | 852 | return -EINVAL; |
858 | 853 | ||
859 | /* clocks must be on for this operation */ | 854 | /* clocks must be on for this operation */ |
@@ -871,7 +866,7 @@ static int _reset(struct omap_hwmod *oh) | |||
871 | return r; | 866 | return r; |
872 | _write_sysconfig(v, oh); | 867 | _write_sysconfig(v, oh); |
873 | 868 | ||
874 | omap_test_timeout((omap_hwmod_readl(oh, oh->sysconfig->syss_offs) & | 869 | omap_test_timeout((omap_hwmod_readl(oh, oh->class->sysc->syss_offs) & |
875 | SYSS_RESETDONE_MASK), | 870 | SYSS_RESETDONE_MASK), |
876 | MAX_MODULE_RESET_WAIT, c); | 871 | MAX_MODULE_RESET_WAIT, c); |
877 | 872 | ||
@@ -917,7 +912,7 @@ static int _enable(struct omap_hwmod *oh) | |||
917 | _add_initiator_dep(oh, mpu_oh); | 912 | _add_initiator_dep(oh, mpu_oh); |
918 | _enable_clocks(oh); | 913 | _enable_clocks(oh); |
919 | 914 | ||
920 | if (oh->sysconfig) { | 915 | if (oh->class->sysc) { |
921 | if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) | 916 | if (!(oh->_int_flags & _HWMOD_SYSCONFIG_LOADED)) |
922 | _update_sysc_cache(oh); | 917 | _update_sysc_cache(oh); |
923 | _sysc_enable(oh); | 918 | _sysc_enable(oh); |
@@ -948,7 +943,7 @@ static int _idle(struct omap_hwmod *oh) | |||
948 | 943 | ||
949 | pr_debug("omap_hwmod: %s: idling\n", oh->name); | 944 | pr_debug("omap_hwmod: %s: idling\n", oh->name); |
950 | 945 | ||
951 | if (oh->sysconfig) | 946 | if (oh->class->sysc) |
952 | _sysc_idle(oh); | 947 | _sysc_idle(oh); |
953 | _del_initiator_dep(oh, mpu_oh); | 948 | _del_initiator_dep(oh, mpu_oh); |
954 | _disable_clocks(oh); | 949 | _disable_clocks(oh); |
@@ -978,7 +973,7 @@ static int _shutdown(struct omap_hwmod *oh) | |||
978 | 973 | ||
979 | pr_debug("omap_hwmod: %s: disabling\n", oh->name); | 974 | pr_debug("omap_hwmod: %s: disabling\n", oh->name); |
980 | 975 | ||
981 | if (oh->sysconfig) | 976 | if (oh->class->sysc) |
982 | _sysc_shutdown(oh); | 977 | _sysc_shutdown(oh); |
983 | _del_initiator_dep(oh, mpu_oh); | 978 | _del_initiator_dep(oh, mpu_oh); |
984 | /* XXX what about the other system initiators here? DMA, tesla, d2d */ | 979 | /* XXX what about the other system initiators here? DMA, tesla, d2d */ |
@@ -1038,7 +1033,7 @@ static int _setup(struct omap_hwmod *oh) | |||
1038 | * _enable() function should be split to avoid the | 1033 | * _enable() function should be split to avoid the |
1039 | * rewrite of the OCP_SYSCONFIG register. | 1034 | * rewrite of the OCP_SYSCONFIG register. |
1040 | */ | 1035 | */ |
1041 | if (oh->sysconfig) { | 1036 | if (oh->class->sysc) { |
1042 | _update_sysc_cache(oh); | 1037 | _update_sysc_cache(oh); |
1043 | _sysc_enable(oh); | 1038 | _sysc_enable(oh); |
1044 | } | 1039 | } |
@@ -1085,9 +1080,12 @@ int omap_hwmod_set_slave_idlemode(struct omap_hwmod *oh, u8 idlemode) | |||
1085 | * omap_hwmod_register - register a struct omap_hwmod | 1080 | * omap_hwmod_register - register a struct omap_hwmod |
1086 | * @oh: struct omap_hwmod * | 1081 | * @oh: struct omap_hwmod * |
1087 | * | 1082 | * |
1088 | * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod already | 1083 | * Registers the omap_hwmod @oh. Returns -EEXIST if an omap_hwmod |
1089 | * 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 |
1090 | * 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. | ||
1091 | * | 1089 | * |
1092 | * 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 |
1093 | * should be marked __initdata and freed after init. This would allow | 1091 | * should be marked __initdata and freed after init. This would allow |
@@ -1099,7 +1097,8 @@ int omap_hwmod_register(struct omap_hwmod *oh) | |||
1099 | { | 1097 | { |
1100 | int ret, ms_id; | 1098 | int ret, ms_id; |
1101 | 1099 | ||
1102 | if (!oh || (oh->_state != _HWMOD_STATE_UNKNOWN)) | 1100 | if (!oh || !oh->name || !oh->class || !oh->class->name || |
1101 | (oh->_state != _HWMOD_STATE_UNKNOWN)) | ||
1103 | return -EINVAL; | 1102 | return -EINVAL; |
1104 | 1103 | ||
1105 | mutex_lock(&omap_hwmod_mutex); | 1104 | mutex_lock(&omap_hwmod_mutex); |
@@ -1372,7 +1371,7 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh) | |||
1372 | { | 1371 | { |
1373 | BUG_ON(!oh); | 1372 | BUG_ON(!oh); |
1374 | 1373 | ||
1375 | if (!oh->sysconfig || !oh->sysconfig->sysc_flags) { | 1374 | if (!oh->class->sysc || !oh->class->sysc->sysc_flags) { |
1376 | WARN(1, "omap_device: %s: OCP barrier impossible due to " | 1375 | WARN(1, "omap_device: %s: OCP barrier impossible due to " |
1377 | "device configuration\n", oh->name); | 1376 | "device configuration\n", oh->name); |
1378 | return; | 1377 | return; |
@@ -1382,7 +1381,7 @@ void omap_hwmod_ocp_barrier(struct omap_hwmod *oh) | |||
1382 | * Forces posted writes to complete on the OCP thread handling | 1381 | * Forces posted writes to complete on the OCP thread handling |
1383 | * register writes | 1382 | * register writes |
1384 | */ | 1383 | */ |
1385 | omap_hwmod_readl(oh, oh->sysconfig->sysc_offs); | 1384 | omap_hwmod_readl(oh, oh->class->sysc->sysc_offs); |
1386 | } | 1385 | } |
1387 | 1386 | ||
1388 | /** | 1387 | /** |
@@ -1575,8 +1574,8 @@ int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh, | |||
1575 | */ | 1574 | */ |
1576 | int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) | 1575 | int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) |
1577 | { | 1576 | { |
1578 | if (!oh->sysconfig || | 1577 | if (!oh->class->sysc || |
1579 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 1578 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
1580 | return -EINVAL; | 1579 | return -EINVAL; |
1581 | 1580 | ||
1582 | mutex_lock(&omap_hwmod_mutex); | 1581 | mutex_lock(&omap_hwmod_mutex); |
@@ -1600,8 +1599,8 @@ int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) | |||
1600 | */ | 1599 | */ |
1601 | int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | 1600 | int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) |
1602 | { | 1601 | { |
1603 | if (!oh->sysconfig || | 1602 | if (!oh->class->sysc || |
1604 | !(oh->sysconfig->sysc_flags & SYSC_HAS_ENAWAKEUP)) | 1603 | !(oh->class->sysc->sysc_flags & SYSC_HAS_ENAWAKEUP)) |
1605 | return -EINVAL; | 1604 | return -EINVAL; |
1606 | 1605 | ||
1607 | mutex_lock(&omap_hwmod_mutex); | 1606 | mutex_lock(&omap_hwmod_mutex); |
@@ -1610,3 +1609,52 @@ int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) | |||
1610 | 1609 | ||
1611 | return 0; | 1610 | return 0; |
1612 | } | 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 | |||