aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2010-02-23 00:09:34 -0500
committerPaul Walmsley <paul@pwsan.com>2010-02-24 19:45:14 -0500
commit43b40992ce21def8d5957f32d7ddb728af89bfce (patch)
tree2e6f25d2d3d5cfbea42564d25cd887279ee8ab00
parent7359154e94623f6a5a68a77b9fcfbef40633c93f (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>
-rw-r--r--arch/arm/mach-omap2/Makefile7
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c222
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2420_data.c6
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_2430_data.c6
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_3xxx_data.c7
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_common_data.c24
-rw-r--r--arch/arm/mach-omap2/omap_hwmod_common_data.h24
-rw-r--r--arch/arm/plat-omap/include/plat/omap_hwmod.h37
8 files changed, 234 insertions, 99 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 7fa4dec2947e..d3984d34fd03 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -5,15 +5,16 @@
5# Common support 5# Common support
6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o 6obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o
7 7
8omap-2-3-common = irq.o sdrc.o omap_hwmod.o \ 8omap-2-3-common = irq.o sdrc.o
9hwmod-common = omap_hwmod.o \
9 omap_hwmod_common_data.o 10 omap_hwmod_common_data.o
10prcm-common = prcm.o powerdomain.o 11prcm-common = prcm.o powerdomain.o
11clock-common = clock.o clock_common_data.o \ 12clock-common = clock.o clock_common_data.o \
12 clockdomain.o clkt_dpll.o \ 13 clockdomain.o clkt_dpll.o \
13 clkt_clksel.o 14 clkt_clksel.o
14 15
15obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) 16obj-$(CONFIG_ARCH_OMAP2) += $(omap-2-3-common) $(prcm-common) $(hwmod-common)
16obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(prcm-common) 17obj-$(CONFIG_ARCH_OMAP3) += $(omap-2-3-common) $(prcm-common) $(hwmod-common)
17obj-$(CONFIG_ARCH_OMAP4) += $(prcm-common) 18obj-$(CONFIG_ARCH_OMAP4) += $(prcm-common)
18 19
19obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o 20obj-$(CONFIG_OMAP_MCBSP) += mcbsp.o
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 */
85static int _update_sysc_cache(struct omap_hwmod *oh) 85static 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 */
111static void _write_sysconfig(u32 v, struct omap_hwmod *oh) 110static 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 */
639static void _sysc_enable(struct omap_hwmod *oh) 630static 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 */
690static void _sysc_idle(struct omap_hwmod *oh) 682static 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)
722static void _sysc_shutdown(struct omap_hwmod *oh) 715static 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 */
1576int omap_hwmod_enable_wakeup(struct omap_hwmod *oh) 1575int 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 */
1601int omap_hwmod_disable_wakeup(struct omap_hwmod *oh) 1600int 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 */
1626int 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
diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index a1c5839fc52d..eb7ee2453b24 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -16,6 +16,8 @@
16#include <plat/cpu.h> 16#include <plat/cpu.h>
17#include <plat/dma.h> 17#include <plat/dma.h>
18 18
19#include "omap_hwmod_common_data.h"
20
19#include "prm-regbits-24xx.h" 21#include "prm-regbits-24xx.h"
20 22
21/* 23/*
@@ -58,6 +60,7 @@ static struct omap_hwmod_ocp_if *omap2420_l3_masters[] = {
58/* L3 */ 60/* L3 */
59static struct omap_hwmod omap2420_l3_hwmod = { 61static struct omap_hwmod omap2420_l3_hwmod = {
60 .name = "l3_hwmod", 62 .name = "l3_hwmod",
63 .class = &l3_hwmod_class,
61 .masters = omap2420_l3_masters, 64 .masters = omap2420_l3_masters,
62 .masters_cnt = ARRAY_SIZE(omap2420_l3_masters), 65 .masters_cnt = ARRAY_SIZE(omap2420_l3_masters),
63 .slaves = omap2420_l3_slaves, 66 .slaves = omap2420_l3_slaves,
@@ -87,6 +90,7 @@ static struct omap_hwmod_ocp_if *omap2420_l4_core_masters[] = {
87/* L4 CORE */ 90/* L4 CORE */
88static struct omap_hwmod omap2420_l4_core_hwmod = { 91static struct omap_hwmod omap2420_l4_core_hwmod = {
89 .name = "l4_core_hwmod", 92 .name = "l4_core_hwmod",
93 .class = &l4_hwmod_class,
90 .masters = omap2420_l4_core_masters, 94 .masters = omap2420_l4_core_masters,
91 .masters_cnt = ARRAY_SIZE(omap2420_l4_core_masters), 95 .masters_cnt = ARRAY_SIZE(omap2420_l4_core_masters),
92 .slaves = omap2420_l4_core_slaves, 96 .slaves = omap2420_l4_core_slaves,
@@ -106,6 +110,7 @@ static struct omap_hwmod_ocp_if *omap2420_l4_wkup_masters[] = {
106/* L4 WKUP */ 110/* L4 WKUP */
107static struct omap_hwmod omap2420_l4_wkup_hwmod = { 111static struct omap_hwmod omap2420_l4_wkup_hwmod = {
108 .name = "l4_wkup_hwmod", 112 .name = "l4_wkup_hwmod",
113 .class = &l4_hwmod_class,
109 .masters = omap2420_l4_wkup_masters, 114 .masters = omap2420_l4_wkup_masters,
110 .masters_cnt = ARRAY_SIZE(omap2420_l4_wkup_masters), 115 .masters_cnt = ARRAY_SIZE(omap2420_l4_wkup_masters),
111 .slaves = omap2420_l4_wkup_slaves, 116 .slaves = omap2420_l4_wkup_slaves,
@@ -121,6 +126,7 @@ static struct omap_hwmod_ocp_if *omap2420_mpu_masters[] = {
121/* MPU */ 126/* MPU */
122static struct omap_hwmod omap2420_mpu_hwmod = { 127static struct omap_hwmod omap2420_mpu_hwmod = {
123 .name = "mpu_hwmod", 128 .name = "mpu_hwmod",
129 .class = &mpu_hwmod_class,
124 .main_clk = "mpu_ck", 130 .main_clk = "mpu_ck",
125 .masters = omap2420_mpu_masters, 131 .masters = omap2420_mpu_masters,
126 .masters_cnt = ARRAY_SIZE(omap2420_mpu_masters), 132 .masters_cnt = ARRAY_SIZE(omap2420_mpu_masters),
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index ed2de7936c10..241bd8230729 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -16,6 +16,8 @@
16#include <plat/cpu.h> 16#include <plat/cpu.h>
17#include <plat/dma.h> 17#include <plat/dma.h>
18 18
19#include "omap_hwmod_common_data.h"
20
19#include "prm-regbits-24xx.h" 21#include "prm-regbits-24xx.h"
20 22
21/* 23/*
@@ -58,6 +60,7 @@ static struct omap_hwmod_ocp_if *omap2430_l3_masters[] = {
58/* L3 */ 60/* L3 */
59static struct omap_hwmod omap2430_l3_hwmod = { 61static struct omap_hwmod omap2430_l3_hwmod = {
60 .name = "l3_hwmod", 62 .name = "l3_hwmod",
63 .class = &l3_hwmod_class,
61 .masters = omap2430_l3_masters, 64 .masters = omap2430_l3_masters,
62 .masters_cnt = ARRAY_SIZE(omap2430_l3_masters), 65 .masters_cnt = ARRAY_SIZE(omap2430_l3_masters),
63 .slaves = omap2430_l3_slaves, 66 .slaves = omap2430_l3_slaves,
@@ -89,6 +92,7 @@ static struct omap_hwmod_ocp_if *omap2430_l4_core_masters[] = {
89/* L4 CORE */ 92/* L4 CORE */
90static struct omap_hwmod omap2430_l4_core_hwmod = { 93static struct omap_hwmod omap2430_l4_core_hwmod = {
91 .name = "l4_core_hwmod", 94 .name = "l4_core_hwmod",
95 .class = &l4_hwmod_class,
92 .masters = omap2430_l4_core_masters, 96 .masters = omap2430_l4_core_masters,
93 .masters_cnt = ARRAY_SIZE(omap2430_l4_core_masters), 97 .masters_cnt = ARRAY_SIZE(omap2430_l4_core_masters),
94 .slaves = omap2430_l4_core_slaves, 98 .slaves = omap2430_l4_core_slaves,
@@ -108,6 +112,7 @@ static struct omap_hwmod_ocp_if *omap2430_l4_wkup_masters[] = {
108/* L4 WKUP */ 112/* L4 WKUP */
109static struct omap_hwmod omap2430_l4_wkup_hwmod = { 113static struct omap_hwmod omap2430_l4_wkup_hwmod = {
110 .name = "l4_wkup_hwmod", 114 .name = "l4_wkup_hwmod",
115 .class = &l4_hwmod_class,
111 .masters = omap2430_l4_wkup_masters, 116 .masters = omap2430_l4_wkup_masters,
112 .masters_cnt = ARRAY_SIZE(omap2430_l4_wkup_masters), 117 .masters_cnt = ARRAY_SIZE(omap2430_l4_wkup_masters),
113 .slaves = omap2430_l4_wkup_slaves, 118 .slaves = omap2430_l4_wkup_slaves,
@@ -123,6 +128,7 @@ static struct omap_hwmod_ocp_if *omap2430_mpu_masters[] = {
123/* MPU */ 128/* MPU */
124static struct omap_hwmod omap2430_mpu_hwmod = { 129static struct omap_hwmod omap2430_mpu_hwmod = {
125 .name = "mpu_hwmod", 130 .name = "mpu_hwmod",
131 .class = &mpu_hwmod_class,
126 .main_clk = "mpu_ck", 132 .main_clk = "mpu_ck",
127 .masters = omap2430_mpu_masters, 133 .masters = omap2430_mpu_masters,
128 .masters_cnt = ARRAY_SIZE(omap2430_mpu_masters), 134 .masters_cnt = ARRAY_SIZE(omap2430_mpu_masters),
diff --git a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
index 8d4b686a5e04..ed6084004260 100644
--- a/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
@@ -18,6 +18,8 @@
18#include <plat/cpu.h> 18#include <plat/cpu.h>
19#include <plat/dma.h> 19#include <plat/dma.h>
20 20
21#include "omap_hwmod_common_data.h"
22
21#include "prm-regbits-34xx.h" 23#include "prm-regbits-34xx.h"
22 24
23/* 25/*
@@ -69,6 +71,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_l3_masters[] = {
69/* L3 */ 71/* L3 */
70static struct omap_hwmod omap3xxx_l3_hwmod = { 72static struct omap_hwmod omap3xxx_l3_hwmod = {
71 .name = "l3_hwmod", 73 .name = "l3_hwmod",
74 .class = &l3_hwmod_class,
72 .masters = omap3xxx_l3_masters, 75 .masters = omap3xxx_l3_masters,
73 .masters_cnt = ARRAY_SIZE(omap3xxx_l3_masters), 76 .masters_cnt = ARRAY_SIZE(omap3xxx_l3_masters),
74 .slaves = omap3xxx_l3_slaves, 77 .slaves = omap3xxx_l3_slaves,
@@ -98,6 +101,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_l4_core_masters[] = {
98/* L4 CORE */ 101/* L4 CORE */
99static struct omap_hwmod omap3xxx_l4_core_hwmod = { 102static struct omap_hwmod omap3xxx_l4_core_hwmod = {
100 .name = "l4_core_hwmod", 103 .name = "l4_core_hwmod",
104 .class = &l4_hwmod_class,
101 .masters = omap3xxx_l4_core_masters, 105 .masters = omap3xxx_l4_core_masters,
102 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_core_masters), 106 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_core_masters),
103 .slaves = omap3xxx_l4_core_slaves, 107 .slaves = omap3xxx_l4_core_slaves,
@@ -117,6 +121,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_l4_per_masters[] = {
117/* L4 PER */ 121/* L4 PER */
118static struct omap_hwmod omap3xxx_l4_per_hwmod = { 122static struct omap_hwmod omap3xxx_l4_per_hwmod = {
119 .name = "l4_per_hwmod", 123 .name = "l4_per_hwmod",
124 .class = &l4_hwmod_class,
120 .masters = omap3xxx_l4_per_masters, 125 .masters = omap3xxx_l4_per_masters,
121 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_per_masters), 126 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_per_masters),
122 .slaves = omap3xxx_l4_per_slaves, 127 .slaves = omap3xxx_l4_per_slaves,
@@ -136,6 +141,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_l4_wkup_masters[] = {
136/* L4 WKUP */ 141/* L4 WKUP */
137static struct omap_hwmod omap3xxx_l4_wkup_hwmod = { 142static struct omap_hwmod omap3xxx_l4_wkup_hwmod = {
138 .name = "l4_wkup_hwmod", 143 .name = "l4_wkup_hwmod",
144 .class = &l4_hwmod_class,
139 .masters = omap3xxx_l4_wkup_masters, 145 .masters = omap3xxx_l4_wkup_masters,
140 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_wkup_masters), 146 .masters_cnt = ARRAY_SIZE(omap3xxx_l4_wkup_masters),
141 .slaves = omap3xxx_l4_wkup_slaves, 147 .slaves = omap3xxx_l4_wkup_slaves,
@@ -151,6 +157,7 @@ static struct omap_hwmod_ocp_if *omap3xxx_mpu_masters[] = {
151/* MPU */ 157/* MPU */
152static struct omap_hwmod omap3xxx_mpu_hwmod = { 158static struct omap_hwmod omap3xxx_mpu_hwmod = {
153 .name = "mpu_hwmod", 159 .name = "mpu_hwmod",
160 .class = &mpu_hwmod_class,
154 .main_clk = "arm_fck", 161 .main_clk = "arm_fck",
155 .masters = omap3xxx_mpu_masters, 162 .masters = omap3xxx_mpu_masters,
156 .masters_cnt = ARRAY_SIZE(omap3xxx_mpu_masters), 163 .masters_cnt = ARRAY_SIZE(omap3xxx_mpu_masters),
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.c b/arch/arm/mach-omap2/omap_hwmod_common_data.c
index 2567c6edc6af..1e80b914fa1a 100644
--- a/arch/arm/mach-omap2/omap_hwmod_common_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.c
@@ -3,6 +3,10 @@
3 * 3 *
4 * Copyright (C) 2010 Texas Instruments, Inc. 4 * Copyright (C) 2010 Texas Instruments, Inc.
5 * Thara Gopinath <thara@ti.com> 5 * Thara Gopinath <thara@ti.com>
6 * Benoît Cousson
7 *
8 * Copyright (C) 2010 Nokia Corporation
9 * Paul Walmsley
6 * 10 *
7 * This program is free software; you can redistribute it and/or modify 11 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 12 * it under the terms of the GNU General Public License version 2 as
@@ -14,6 +18,8 @@
14 18
15#include <plat/omap_hwmod.h> 19#include <plat/omap_hwmod.h>
16 20
21#include "omap_hwmod_common_data.h"
22
17/** 23/**
18 * struct omap_hwmod_sysc_type1 - TYPE1 sysconfig scheme. 24 * struct omap_hwmod_sysc_type1 - TYPE1 sysconfig scheme.
19 * 25 *
@@ -42,3 +48,21 @@ struct omap_hwmod_sysc_fields omap_hwmod_sysc_type2 = {
42 .sidle_shift = SYSC_TYPE2_SIDLEMODE_SHIFT, 48 .sidle_shift = SYSC_TYPE2_SIDLEMODE_SHIFT,
43 .srst_shift = SYSC_TYPE2_SOFTRESET_SHIFT, 49 .srst_shift = SYSC_TYPE2_SOFTRESET_SHIFT,
44}; 50};
51
52
53/*
54 * omap_hwmod class data
55 */
56
57struct omap_hwmod_class l3_hwmod_class = {
58 .name = "l3"
59};
60
61struct omap_hwmod_class l4_hwmod_class = {
62 .name = "l4"
63};
64
65struct omap_hwmod_class mpu_hwmod_class = {
66 .name = "mpu"
67};
68
diff --git a/arch/arm/mach-omap2/omap_hwmod_common_data.h b/arch/arm/mach-omap2/omap_hwmod_common_data.h
new file mode 100644
index 000000000000..3645a28c7c27
--- /dev/null
+++ b/arch/arm/mach-omap2/omap_hwmod_common_data.h
@@ -0,0 +1,24 @@
1/*
2 * omap_hwmod_common_data.h - OMAP hwmod common macros and declarations
3 *
4 * Copyright (C) 2010 Nokia Corporation
5 * Paul Walmsley
6 *
7 * Copyright (C) 2010 Texas Instruments, Inc.
8 * Benoît Cousson
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14#ifndef __ARCH_ARM_MACH_OMAP2_OMAP_HWMOD_COMMON_DATA_H
15#define __ARCH_ARM_MACH_OMAP2_OMAP_HWMOD_COMMON_DATA_H
16
17#include <plat/omap_hwmod.h>
18
19/* OMAP hwmod classes - forward declarations */
20extern struct omap_hwmod_class l3_hwmod_class;
21extern struct omap_hwmod_class l4_hwmod_class;
22extern struct omap_hwmod_class mpu_hwmod_class;
23
24#endif
diff --git a/arch/arm/plat-omap/include/plat/omap_hwmod.h b/arch/arm/plat-omap/include/plat/omap_hwmod.h
index d2241fc6379a..440b4164f2f6 100644
--- a/arch/arm/plat-omap/include/plat/omap_hwmod.h
+++ b/arch/arm/plat-omap/include/plat/omap_hwmod.h
@@ -4,7 +4,7 @@
4 * Copyright (C) 2009 Nokia Corporation 4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley 5 * Paul Walmsley
6 * 6 *
7 * Created in collaboration with (alphabetical order): Benoit Cousson, 7 * Created in collaboration with (alphabetical order): Benoît Cousson,
8 * Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram Pandita, Sakari 8 * Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram Pandita, Sakari
9 * Poussa, Anand Sawant, Santosh Shilimkar, Richard Woodruff 9 * Poussa, Anand Sawant, Santosh Shilimkar, Richard Woodruff
10 * 10 *
@@ -254,7 +254,7 @@ struct omap_hwmod_ocp_if {
254 * @sidle_shift: Offset of the sidle bit 254 * @sidle_shift: Offset of the sidle bit
255 * @enwkup_shift: Offset of the enawakeup bit 255 * @enwkup_shift: Offset of the enawakeup bit
256 * @srst_shift: Offset of the softreset bit 256 * @srst_shift: Offset of the softreset bit
257 * @autoidle_shift: Offset of the autoidle bit. 257 * @autoidle_shift: Offset of the autoidle bit
258 */ 258 */
259struct omap_hwmod_sysc_fields { 259struct omap_hwmod_sysc_fields {
260 u8 midle_shift; 260 u8 midle_shift;
@@ -266,7 +266,7 @@ struct omap_hwmod_sysc_fields {
266}; 266};
267 267
268/** 268/**
269 * struct omap_hwmod_sysconfig - hwmod OCP_SYSCONFIG/OCP_SYSSTATUS data 269 * struct omap_hwmod_class_sysconfig - hwmod class OCP_SYS* data
270 * @rev_offs: IP block revision register offset (from module base addr) 270 * @rev_offs: IP block revision register offset (from module base addr)
271 * @sysc_offs: OCP_SYSCONFIG register offset (from module base addr) 271 * @sysc_offs: OCP_SYSCONFIG register offset (from module base addr)
272 * @syss_offs: OCP_SYSSTATUS register offset (from module base addr) 272 * @syss_offs: OCP_SYSSTATUS register offset (from module base addr)
@@ -282,16 +282,15 @@ struct omap_hwmod_sysc_fields {
282 * been associated with the clocks marked in @clockact. This field is 282 * been associated with the clocks marked in @clockact. This field is
283 * only used if HWMOD_SET_DEFAULT_CLOCKACT is set (see below) 283 * only used if HWMOD_SET_DEFAULT_CLOCKACT is set (see below)
284 * 284 *
285 *
286 * @sysc_fields: structure containing the offset positions of various bits in 285 * @sysc_fields: structure containing the offset positions of various bits in
287 * SYSCONFIG register. This can be populated using omap_hwmod_sysc_type1 or 286 * SYSCONFIG register. This can be populated using omap_hwmod_sysc_type1 or
288 * omap_hwmod_sysc_type2 defined in omap_hwmod_common_data.c depending on 287 * omap_hwmod_sysc_type2 defined in omap_hwmod_common_data.c depending on
289 * whether the device ip is compliant with the original PRCM protocol 288 * whether the device ip is compliant with the original PRCM protocol
290 * defined for OMAP2420 or the new PRCM protocol for new OMAP4 IPs. 289 * defined for OMAP2420 or the new PRCM protocol for new OMAP4 IPs.
291 * If the device follows a differnt scheme for the sysconfig register , 290 * If the device follows a different scheme for the sysconfig register ,
292 * then this field has to be populated with the correct offset structure. 291 * then this field has to be populated with the correct offset structure.
293 */ 292 */
294struct omap_hwmod_sysconfig { 293struct omap_hwmod_class_sysconfig {
295 u16 rev_offs; 294 u16 rev_offs;
296 u16 sysc_offs; 295 u16 sysc_offs;
297 u16 syss_offs; 296 u16 syss_offs;
@@ -391,8 +390,24 @@ struct omap_hwmod_omap4_prcm {
391#define _HWMOD_STATE_DISABLED 6 390#define _HWMOD_STATE_DISABLED 6
392 391
393/** 392/**
393 * struct omap_hwmod_class - the type of an IP block
394 * @name: name of the hwmod_class
395 * @sysc: device SYSCONFIG/SYSSTATUS register data
396 * @rev: revision of the IP class
397 *
398 * Represent the class of a OMAP hardware "modules" (e.g. timer,
399 * smartreflex, gpio, uart...)
400 */
401struct omap_hwmod_class {
402 const char *name;
403 struct omap_hwmod_class_sysconfig *sysc;
404 u32 rev;
405};
406
407/**
394 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks) 408 * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks)
395 * @name: name of the hwmod 409 * @name: name of the hwmod
410 * @class: struct omap_hwmod_class * to the class of this hwmod
396 * @od: struct omap_device currently associated with this hwmod (internal use) 411 * @od: struct omap_device currently associated with this hwmod (internal use)
397 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt) 412 * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt)
398 * @sdma_chs: ptr to an array of SDMA channel IDs (see also sdma_chs_cnt) 413 * @sdma_chs: ptr to an array of SDMA channel IDs (see also sdma_chs_cnt)
@@ -402,7 +417,6 @@ struct omap_hwmod_omap4_prcm {
402 * @opt_clks: other device clocks that drivers can request (0..*) 417 * @opt_clks: other device clocks that drivers can request (0..*)
403 * @masters: ptr to array of OCP ifs that this hwmod can initiate on 418 * @masters: ptr to array of OCP ifs that this hwmod can initiate on
404 * @slaves: ptr to array of OCP ifs that this hwmod can respond on 419 * @slaves: ptr to array of OCP ifs that this hwmod can respond on
405 * @sysconfig: device SYSCONFIG/SYSSTATUS register data
406 * @dev_attr: arbitrary device attributes that can be passed to the driver 420 * @dev_attr: arbitrary device attributes that can be passed to the driver
407 * @_sysc_cache: internal-use hwmod flags 421 * @_sysc_cache: internal-use hwmod flags
408 * @_rt_va: cached register target start address (internal use) 422 * @_rt_va: cached register target start address (internal use)
@@ -431,6 +445,7 @@ struct omap_hwmod_omap4_prcm {
431 */ 445 */
432struct omap_hwmod { 446struct omap_hwmod {
433 const char *name; 447 const char *name;
448 struct omap_hwmod_class *class;
434 struct omap_device *od; 449 struct omap_device *od;
435 struct omap_hwmod_irq_info *mpu_irqs; 450 struct omap_hwmod_irq_info *mpu_irqs;
436 struct omap_hwmod_dma_info *sdma_chs; 451 struct omap_hwmod_dma_info *sdma_chs;
@@ -443,7 +458,6 @@ struct omap_hwmod {
443 struct omap_hwmod_opt_clk *opt_clks; 458 struct omap_hwmod_opt_clk *opt_clks;
444 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */ 459 struct omap_hwmod_ocp_if **masters; /* connect to *_IA */
445 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */ 460 struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
446 struct omap_hwmod_sysconfig *sysconfig;
447 void *dev_attr; 461 void *dev_attr;
448 u32 _sysc_cache; 462 u32 _sysc_cache;
449 void __iomem *_rt_va; 463 void __iomem *_rt_va;
@@ -504,6 +518,11 @@ int omap_hwmod_set_clockact_none(struct omap_hwmod *oh);
504int omap_hwmod_enable_wakeup(struct omap_hwmod *oh); 518int omap_hwmod_enable_wakeup(struct omap_hwmod *oh);
505int omap_hwmod_disable_wakeup(struct omap_hwmod *oh); 519int omap_hwmod_disable_wakeup(struct omap_hwmod *oh);
506 520
521int omap_hwmod_for_each_by_class(const char *classname,
522 int (*fn)(struct omap_hwmod *oh,
523 void *user),
524 void *user);
525
507/* 526/*
508 * Chip variant-specific hwmod init routines - XXX should be converted 527 * Chip variant-specific hwmod init routines - XXX should be converted
509 * to use initcalls once the initial boot ordering is straightened out 528 * to use initcalls once the initial boot ordering is straightened out