perf: Add support for supplementary event registers
[linux-2.6/x86.git] / arch / arm / plat-omap / omap_device.c
blob57adb270767b8bb2ebc409cdd2a50e6d6e83b0d0
1 /*
2 * omap_device implementation
4 * Copyright (C) 2009-2010 Nokia Corporation
5 * Paul Walmsley, Kevin Hilman
7 * Developed in collaboration with (alphabetical order): Benoit
8 * Cousson, Thara Gopinath, Tony Lindgren, Rajendra Nayak, Vikram
9 * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
10 * Woodruff
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
16 * This code provides a consistent interface for OMAP device drivers
17 * to control power management and interconnect properties of their
18 * devices.
20 * In the medium- to long-term, this code should either be
21 * a) implemented via arch-specific pointers in platform_data
22 * or
23 * b) implemented as a proper omap_bus/omap_device in Linux, no more
24 * platform_data func pointers
27 * Guidelines for usage by driver authors:
29 * 1. These functions are intended to be used by device drivers via
30 * function pointers in struct platform_data. As an example,
31 * omap_device_enable() should be passed to the driver as
33 * struct foo_driver_platform_data {
34 * ...
35 * int (*device_enable)(struct platform_device *pdev);
36 * ...
37 * }
39 * Note that the generic "device_enable" name is used, rather than
40 * "omap_device_enable". This is so other architectures can pass in their
41 * own enable/disable functions here.
43 * This should be populated during device setup:
45 * ...
46 * pdata->device_enable = omap_device_enable;
47 * ...
49 * 2. Drivers should first check to ensure the function pointer is not null
50 * before calling it, as in:
52 * if (pdata->device_enable)
53 * pdata->device_enable(pdev);
55 * This allows other architectures that don't use similar device_enable()/
56 * device_shutdown() functions to execute normally.
58 * ...
60 * Suggested usage by device drivers:
62 * During device initialization:
63 * device_enable()
65 * During device idle:
66 * (save remaining device context if necessary)
67 * device_idle();
69 * During device resume:
70 * device_enable();
71 * (restore context if necessary)
73 * During device shutdown:
74 * device_shutdown()
75 * (device must be reinitialized at this point to use it again)
78 #undef DEBUG
80 #include <linux/kernel.h>
81 #include <linux/platform_device.h>
82 #include <linux/slab.h>
83 #include <linux/err.h>
84 #include <linux/io.h>
85 #include <linux/clk.h>
87 #include <plat/omap_device.h>
88 #include <plat/omap_hwmod.h>
90 /* These parameters are passed to _omap_device_{de,}activate() */
91 #define USE_WAKEUP_LAT 0
92 #define IGNORE_WAKEUP_LAT 1
94 /* Private functions */
96 /**
97 * _omap_device_activate - increase device readiness
98 * @od: struct omap_device *
99 * @ignore_lat: increase to latency target (0) or full readiness (1)?
101 * Increase readiness of omap_device @od (thus decreasing device
102 * wakeup latency, but consuming more power). If @ignore_lat is
103 * IGNORE_WAKEUP_LAT, make the omap_device fully active. Otherwise,
104 * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
105 * latency is greater than the requested maximum wakeup latency, step
106 * backwards in the omap_device_pm_latency table to ensure the
107 * device's maximum wakeup latency is less than or equal to the
108 * requested maximum wakeup latency. Returns 0.
110 static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
112 struct timespec a, b, c;
114 pr_debug("omap_device: %s: activating\n", od->pdev.name);
116 while (od->pm_lat_level > 0) {
117 struct omap_device_pm_latency *odpl;
118 unsigned long long act_lat = 0;
120 od->pm_lat_level--;
122 odpl = od->pm_lats + od->pm_lat_level;
124 if (!ignore_lat &&
125 (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
126 break;
128 read_persistent_clock(&a);
130 /* XXX check return code */
131 odpl->activate_func(od);
133 read_persistent_clock(&b);
135 c = timespec_sub(b, a);
136 act_lat = timespec_to_ns(&c);
138 pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time "
139 "%llu nsec\n", od->pdev.name, od->pm_lat_level,
140 act_lat);
142 if (act_lat > odpl->activate_lat) {
143 odpl->activate_lat_worst = act_lat;
144 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
145 odpl->activate_lat = act_lat;
146 pr_warning("omap_device: %s.%d: new worst case "
147 "activate latency %d: %llu\n",
148 od->pdev.name, od->pdev.id,
149 od->pm_lat_level, act_lat);
150 } else
151 pr_warning("omap_device: %s.%d: activate "
152 "latency %d higher than exptected. "
153 "(%llu > %d)\n",
154 od->pdev.name, od->pdev.id,
155 od->pm_lat_level, act_lat,
156 odpl->activate_lat);
159 od->dev_wakeup_lat -= odpl->activate_lat;
162 return 0;
166 * _omap_device_deactivate - decrease device readiness
167 * @od: struct omap_device *
168 * @ignore_lat: decrease to latency target (0) or full inactivity (1)?
170 * Decrease readiness of omap_device @od (thus increasing device
171 * wakeup latency, but conserving power). If @ignore_lat is
172 * IGNORE_WAKEUP_LAT, make the omap_device fully inactive. Otherwise,
173 * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
174 * latency is less than the requested maximum wakeup latency, step
175 * forwards in the omap_device_pm_latency table to ensure the device's
176 * maximum wakeup latency is less than or equal to the requested
177 * maximum wakeup latency. Returns 0.
179 static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
181 struct timespec a, b, c;
183 pr_debug("omap_device: %s: deactivating\n", od->pdev.name);
185 while (od->pm_lat_level < od->pm_lats_cnt) {
186 struct omap_device_pm_latency *odpl;
187 unsigned long long deact_lat = 0;
189 odpl = od->pm_lats + od->pm_lat_level;
191 if (!ignore_lat &&
192 ((od->dev_wakeup_lat + odpl->activate_lat) >
193 od->_dev_wakeup_lat_limit))
194 break;
196 read_persistent_clock(&a);
198 /* XXX check return code */
199 odpl->deactivate_func(od);
201 read_persistent_clock(&b);
203 c = timespec_sub(b, a);
204 deact_lat = timespec_to_ns(&c);
206 pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time "
207 "%llu nsec\n", od->pdev.name, od->pm_lat_level,
208 deact_lat);
210 if (deact_lat > odpl->deactivate_lat) {
211 odpl->deactivate_lat_worst = deact_lat;
212 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
213 odpl->deactivate_lat = deact_lat;
214 pr_warning("omap_device: %s.%d: new worst case "
215 "deactivate latency %d: %llu\n",
216 od->pdev.name, od->pdev.id,
217 od->pm_lat_level, deact_lat);
218 } else
219 pr_warning("omap_device: %s.%d: deactivate "
220 "latency %d higher than exptected. "
221 "(%llu > %d)\n",
222 od->pdev.name, od->pdev.id,
223 od->pm_lat_level, deact_lat,
224 odpl->deactivate_lat);
228 od->dev_wakeup_lat += odpl->activate_lat;
230 od->pm_lat_level++;
233 return 0;
236 static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
238 return container_of(pdev, struct omap_device, pdev);
242 * _add_optional_clock_alias - Add clock alias for hwmod optional clocks
243 * @od: struct omap_device *od
245 * For every optional clock present per hwmod per omap_device, this function
246 * adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role>
247 * if an entry is already present in it with the form <dev-id=NULL, con-id=role>
249 * The function is called from inside omap_device_build_ss(), after
250 * omap_device_register.
252 * This allows drivers to get a pointer to its optional clocks based on its role
253 * by calling clk_get(<dev*>, <role>).
255 * No return value.
257 static void _add_optional_clock_alias(struct omap_device *od,
258 struct omap_hwmod *oh)
260 int i;
262 for (i = 0; i < oh->opt_clks_cnt; i++) {
263 struct omap_hwmod_opt_clk *oc;
264 int r;
266 oc = &oh->opt_clks[i];
268 if (!oc->_clk)
269 continue;
271 r = clk_add_alias(oc->role, dev_name(&od->pdev.dev),
272 (char *)oc->clk, &od->pdev.dev);
273 if (r)
274 pr_err("omap_device: %s: clk_add_alias for %s failed\n",
275 dev_name(&od->pdev.dev), oc->role);
280 /* Public functions for use by core code */
283 * omap_device_get_context_loss_count - get lost context count
284 * @od: struct omap_device *
286 * Using the primary hwmod, query the context loss count for this
287 * device.
289 * Callers should consider context for this device lost any time this
290 * function returns a value different than the value the caller got
291 * the last time it called this function.
293 * If any hwmods exist for the omap_device assoiated with @pdev,
294 * return the context loss counter for that hwmod, otherwise return
295 * zero.
297 u32 omap_device_get_context_loss_count(struct platform_device *pdev)
299 struct omap_device *od;
300 u32 ret = 0;
302 od = _find_by_pdev(pdev);
304 if (od->hwmods_cnt)
305 ret = omap_hwmod_get_context_loss_count(od->hwmods[0]);
307 return ret;
311 * omap_device_count_resources - count number of struct resource entries needed
312 * @od: struct omap_device *
314 * Count the number of struct resource entries needed for this
315 * omap_device @od. Used by omap_device_build_ss() to determine how
316 * much memory to allocate before calling
317 * omap_device_fill_resources(). Returns the count.
319 int omap_device_count_resources(struct omap_device *od)
321 int c = 0;
322 int i;
324 for (i = 0; i < od->hwmods_cnt; i++)
325 c += omap_hwmod_count_resources(od->hwmods[i]);
327 pr_debug("omap_device: %s: counted %d total resources across %d "
328 "hwmods\n", od->pdev.name, c, od->hwmods_cnt);
330 return c;
334 * omap_device_fill_resources - fill in array of struct resource
335 * @od: struct omap_device *
336 * @res: pointer to an array of struct resource to be filled in
338 * Populate one or more empty struct resource pointed to by @res with
339 * the resource data for this omap_device @od. Used by
340 * omap_device_build_ss() after calling omap_device_count_resources().
341 * Ideally this function would not be needed at all. If omap_device
342 * replaces platform_device, then we can specify our own
343 * get_resource()/ get_irq()/etc functions that use the underlying
344 * omap_hwmod information. Or if platform_device is extended to use
345 * subarchitecture-specific function pointers, the various
346 * platform_device functions can simply call omap_device internal
347 * functions to get device resources. Hacking around the existing
348 * platform_device code wastes memory. Returns 0.
350 int omap_device_fill_resources(struct omap_device *od, struct resource *res)
352 int c = 0;
353 int i, r;
355 for (i = 0; i < od->hwmods_cnt; i++) {
356 r = omap_hwmod_fill_resources(od->hwmods[i], res);
357 res += r;
358 c += r;
361 return 0;
365 * omap_device_build - build and register an omap_device with one omap_hwmod
366 * @pdev_name: name of the platform_device driver to use
367 * @pdev_id: this platform_device's connection ID
368 * @oh: ptr to the single omap_hwmod that backs this omap_device
369 * @pdata: platform_data ptr to associate with the platform_device
370 * @pdata_len: amount of memory pointed to by @pdata
371 * @pm_lats: pointer to a omap_device_pm_latency array for this device
372 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
373 * @is_early_device: should the device be registered as an early device or not
375 * Convenience function for building and registering a single
376 * omap_device record, which in turn builds and registers a
377 * platform_device record. See omap_device_build_ss() for more
378 * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
379 * passes along the return value of omap_device_build_ss().
381 struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
382 struct omap_hwmod *oh, void *pdata,
383 int pdata_len,
384 struct omap_device_pm_latency *pm_lats,
385 int pm_lats_cnt, int is_early_device)
387 struct omap_hwmod *ohs[] = { oh };
389 if (!oh)
390 return ERR_PTR(-EINVAL);
392 return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata,
393 pdata_len, pm_lats, pm_lats_cnt,
394 is_early_device);
398 * omap_device_build_ss - build and register an omap_device with multiple hwmods
399 * @pdev_name: name of the platform_device driver to use
400 * @pdev_id: this platform_device's connection ID
401 * @oh: ptr to the single omap_hwmod that backs this omap_device
402 * @pdata: platform_data ptr to associate with the platform_device
403 * @pdata_len: amount of memory pointed to by @pdata
404 * @pm_lats: pointer to a omap_device_pm_latency array for this device
405 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
406 * @is_early_device: should the device be registered as an early device or not
408 * Convenience function for building and registering an omap_device
409 * subsystem record. Subsystem records consist of multiple
410 * omap_hwmods. This function in turn builds and registers a
411 * platform_device record. Returns an ERR_PTR() on error, or passes
412 * along the return value of omap_device_register().
414 struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
415 struct omap_hwmod **ohs, int oh_cnt,
416 void *pdata, int pdata_len,
417 struct omap_device_pm_latency *pm_lats,
418 int pm_lats_cnt, int is_early_device)
420 int ret = -ENOMEM;
421 struct omap_device *od;
422 char *pdev_name2;
423 struct resource *res = NULL;
424 int i, res_count;
425 struct omap_hwmod **hwmods;
427 if (!ohs || oh_cnt == 0 || !pdev_name)
428 return ERR_PTR(-EINVAL);
430 if (!pdata && pdata_len > 0)
431 return ERR_PTR(-EINVAL);
433 pr_debug("omap_device: %s: building with %d hwmods\n", pdev_name,
434 oh_cnt);
436 od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
437 if (!od)
438 return ERR_PTR(-ENOMEM);
440 od->hwmods_cnt = oh_cnt;
442 hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt,
443 GFP_KERNEL);
444 if (!hwmods)
445 goto odbs_exit1;
447 memcpy(hwmods, ohs, sizeof(struct omap_hwmod *) * oh_cnt);
448 od->hwmods = hwmods;
450 pdev_name2 = kzalloc(strlen(pdev_name) + 1, GFP_KERNEL);
451 if (!pdev_name2)
452 goto odbs_exit2;
453 strcpy(pdev_name2, pdev_name);
455 od->pdev.name = pdev_name2;
456 od->pdev.id = pdev_id;
458 res_count = omap_device_count_resources(od);
459 if (res_count > 0) {
460 res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
461 if (!res)
462 goto odbs_exit3;
464 omap_device_fill_resources(od, res);
466 od->pdev.num_resources = res_count;
467 od->pdev.resource = res;
469 ret = platform_device_add_data(&od->pdev, pdata, pdata_len);
470 if (ret)
471 goto odbs_exit4;
473 od->pm_lats = pm_lats;
474 od->pm_lats_cnt = pm_lats_cnt;
476 if (is_early_device)
477 ret = omap_early_device_register(od);
478 else
479 ret = omap_device_register(od);
481 for (i = 0; i < oh_cnt; i++) {
482 hwmods[i]->od = od;
483 _add_optional_clock_alias(od, hwmods[i]);
486 if (ret)
487 goto odbs_exit4;
489 return od;
491 odbs_exit4:
492 kfree(res);
493 odbs_exit3:
494 kfree(pdev_name2);
495 odbs_exit2:
496 kfree(hwmods);
497 odbs_exit1:
498 kfree(od);
500 pr_err("omap_device: %s: build failed (%d)\n", pdev_name, ret);
502 return ERR_PTR(ret);
506 * omap_early_device_register - register an omap_device as an early platform
507 * device.
508 * @od: struct omap_device * to register
510 * Register the omap_device structure. This currently just calls
511 * platform_early_add_device() on the underlying platform_device.
512 * Returns 0 by default.
514 int omap_early_device_register(struct omap_device *od)
516 struct platform_device *devices[1];
518 devices[0] = &(od->pdev);
519 early_platform_add_devices(devices, 1);
520 return 0;
524 * omap_device_register - register an omap_device with one omap_hwmod
525 * @od: struct omap_device * to register
527 * Register the omap_device structure. This currently just calls
528 * platform_device_register() on the underlying platform_device.
529 * Returns the return value of platform_device_register().
531 int omap_device_register(struct omap_device *od)
533 pr_debug("omap_device: %s: registering\n", od->pdev.name);
535 od->pdev.dev.parent = &omap_device_parent;
536 return platform_device_register(&od->pdev);
540 /* Public functions for use by device drivers through struct platform_data */
543 * omap_device_enable - fully activate an omap_device
544 * @od: struct omap_device * to activate
546 * Do whatever is necessary for the hwmods underlying omap_device @od
547 * to be accessible and ready to operate. This generally involves
548 * enabling clocks, setting SYSCONFIG registers; and in the future may
549 * involve remuxing pins. Device drivers should call this function
550 * (through platform_data function pointers) where they would normally
551 * enable clocks, etc. Returns -EINVAL if called when the omap_device
552 * is already enabled, or passes along the return value of
553 * _omap_device_activate().
555 int omap_device_enable(struct platform_device *pdev)
557 int ret;
558 struct omap_device *od;
560 od = _find_by_pdev(pdev);
562 if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
563 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
564 od->pdev.name, od->pdev.id, __func__, od->_state);
565 return -EINVAL;
568 /* Enable everything if we're enabling this device from scratch */
569 if (od->_state == OMAP_DEVICE_STATE_UNKNOWN)
570 od->pm_lat_level = od->pm_lats_cnt;
572 ret = _omap_device_activate(od, IGNORE_WAKEUP_LAT);
574 od->dev_wakeup_lat = 0;
575 od->_dev_wakeup_lat_limit = UINT_MAX;
576 od->_state = OMAP_DEVICE_STATE_ENABLED;
578 return ret;
582 * omap_device_idle - idle an omap_device
583 * @od: struct omap_device * to idle
585 * Idle omap_device @od by calling as many .deactivate_func() entries
586 * in the omap_device's pm_lats table as is possible without exceeding
587 * the device's maximum wakeup latency limit, pm_lat_limit. Device
588 * drivers should call this function (through platform_data function
589 * pointers) where they would normally disable clocks after operations
590 * complete, etc.. Returns -EINVAL if the omap_device is not
591 * currently enabled, or passes along the return value of
592 * _omap_device_deactivate().
594 int omap_device_idle(struct platform_device *pdev)
596 int ret;
597 struct omap_device *od;
599 od = _find_by_pdev(pdev);
601 if (od->_state != OMAP_DEVICE_STATE_ENABLED) {
602 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
603 od->pdev.name, od->pdev.id, __func__, od->_state);
604 return -EINVAL;
607 ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
609 od->_state = OMAP_DEVICE_STATE_IDLE;
611 return ret;
615 * omap_device_shutdown - shut down an omap_device
616 * @od: struct omap_device * to shut down
618 * Shut down omap_device @od by calling all .deactivate_func() entries
619 * in the omap_device's pm_lats table and then shutting down all of
620 * the underlying omap_hwmods. Used when a device is being "removed"
621 * or a device driver is being unloaded. Returns -EINVAL if the
622 * omap_device is not currently enabled or idle, or passes along the
623 * return value of _omap_device_deactivate().
625 int omap_device_shutdown(struct platform_device *pdev)
627 int ret, i;
628 struct omap_device *od;
630 od = _find_by_pdev(pdev);
632 if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
633 od->_state != OMAP_DEVICE_STATE_IDLE) {
634 WARN(1, "omap_device: %s.%d: %s() called from invalid state %d\n",
635 od->pdev.name, od->pdev.id, __func__, od->_state);
636 return -EINVAL;
639 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
641 for (i = 0; i < od->hwmods_cnt; i++)
642 omap_hwmod_shutdown(od->hwmods[i]);
644 od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
646 return ret;
650 * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
651 * @od: struct omap_device *
653 * When a device's maximum wakeup latency limit changes, call some of
654 * the .activate_func or .deactivate_func function pointers in the
655 * omap_device's pm_lats array to ensure that the device's maximum
656 * wakeup latency is less than or equal to the new latency limit.
657 * Intended to be called by OMAP PM code whenever a device's maximum
658 * wakeup latency limit changes (e.g., via
659 * omap_pm_set_dev_wakeup_lat()). Returns 0 if nothing needs to be
660 * done (e.g., if the omap_device is not currently idle, or if the
661 * wakeup latency is already current with the new limit) or passes
662 * along the return value of _omap_device_deactivate() or
663 * _omap_device_activate().
665 int omap_device_align_pm_lat(struct platform_device *pdev,
666 u32 new_wakeup_lat_limit)
668 int ret = -EINVAL;
669 struct omap_device *od;
671 od = _find_by_pdev(pdev);
673 if (new_wakeup_lat_limit == od->dev_wakeup_lat)
674 return 0;
676 od->_dev_wakeup_lat_limit = new_wakeup_lat_limit;
678 if (od->_state != OMAP_DEVICE_STATE_IDLE)
679 return 0;
680 else if (new_wakeup_lat_limit > od->dev_wakeup_lat)
681 ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
682 else if (new_wakeup_lat_limit < od->dev_wakeup_lat)
683 ret = _omap_device_activate(od, USE_WAKEUP_LAT);
685 return ret;
689 * omap_device_get_pwrdm - return the powerdomain * associated with @od
690 * @od: struct omap_device *
692 * Return the powerdomain associated with the first underlying
693 * omap_hwmod for this omap_device. Intended for use by core OMAP PM
694 * code. Returns NULL on error or a struct powerdomain * upon
695 * success.
697 struct powerdomain *omap_device_get_pwrdm(struct omap_device *od)
700 * XXX Assumes that all omap_hwmod powerdomains are identical.
701 * This may not necessarily be true. There should be a sanity
702 * check in here to WARN() if any difference appears.
704 if (!od->hwmods_cnt)
705 return NULL;
707 return omap_hwmod_get_pwrdm(od->hwmods[0]);
711 * omap_device_get_mpu_rt_va - return the MPU's virtual addr for the hwmod base
712 * @od: struct omap_device *
714 * Return the MPU's virtual address for the base of the hwmod, from
715 * the ioremap() that the hwmod code does. Only valid if there is one
716 * hwmod associated with this device. Returns NULL if there are zero
717 * or more than one hwmods associated with this omap_device;
718 * otherwise, passes along the return value from
719 * omap_hwmod_get_mpu_rt_va().
721 void __iomem *omap_device_get_rt_va(struct omap_device *od)
723 if (od->hwmods_cnt != 1)
724 return NULL;
726 return omap_hwmod_get_mpu_rt_va(od->hwmods[0]);
730 * Public functions intended for use in omap_device_pm_latency
731 * .activate_func and .deactivate_func function pointers
735 * omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
736 * @od: struct omap_device *od
738 * Enable all underlying hwmods. Returns 0.
740 int omap_device_enable_hwmods(struct omap_device *od)
742 int i;
744 for (i = 0; i < od->hwmods_cnt; i++)
745 omap_hwmod_enable(od->hwmods[i]);
747 /* XXX pass along return value here? */
748 return 0;
752 * omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
753 * @od: struct omap_device *od
755 * Idle all underlying hwmods. Returns 0.
757 int omap_device_idle_hwmods(struct omap_device *od)
759 int i;
761 for (i = 0; i < od->hwmods_cnt; i++)
762 omap_hwmod_idle(od->hwmods[i]);
764 /* XXX pass along return value here? */
765 return 0;
769 * omap_device_disable_clocks - disable all main and interface clocks
770 * @od: struct omap_device *od
772 * Disable the main functional clock and interface clock for all of the
773 * omap_hwmods associated with the omap_device. Returns 0.
775 int omap_device_disable_clocks(struct omap_device *od)
777 int i;
779 for (i = 0; i < od->hwmods_cnt; i++)
780 omap_hwmod_disable_clocks(od->hwmods[i]);
782 /* XXX pass along return value here? */
783 return 0;
787 * omap_device_enable_clocks - enable all main and interface clocks
788 * @od: struct omap_device *od
790 * Enable the main functional clock and interface clock for all of the
791 * omap_hwmods associated with the omap_device. Returns 0.
793 int omap_device_enable_clocks(struct omap_device *od)
795 int i;
797 for (i = 0; i < od->hwmods_cnt; i++)
798 omap_hwmod_enable_clocks(od->hwmods[i]);
800 /* XXX pass along return value here? */
801 return 0;
804 struct device omap_device_parent = {
805 .init_name = "omap",
806 .parent = &platform_bus,
809 static int __init omap_device_init(void)
811 return device_register(&omap_device_parent);
813 core_initcall(omap_device_init);