blob: 5195dbb1a397559f71bd33977e6399622de87596 [file] [log] [blame]
Paul Walmsleyb04b65a2009-09-03 20:14:05 +03001/*
2 * omap_device implementation
3 *
4 * Copyright (C) 2009 Nokia Corporation
5 * Paul Walmsley
6 *
7 * Developed in collaboration with (alphabetical order): Benoit
8 * Cousson, Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram
9 * Pandita, Sakari Poussa, Anand Sawant, Santosh Shilimkar, Richard
10 * Woodruff
11 *
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.
15 *
16 * This code provides a consistent interface for OMAP device drivers
17 * to control power management and interconnect properties of their
18 * devices.
19 *
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
25 *
26 *
27 * Guidelines for usage by driver authors:
28 *
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
32 *
33 * struct foo_driver_platform_data {
34 * ...
35 * int (*device_enable)(struct platform_device *pdev);
36 * ...
37 * }
38 *
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.
42 *
43 * This should be populated during device setup:
44 *
45 * ...
46 * pdata->device_enable = omap_device_enable;
47 * ...
48 *
49 * 2. Drivers should first check to ensure the function pointer is not null
50 * before calling it, as in:
51 *
52 * if (pdata->device_enable)
53 * pdata->device_enable(pdev);
54 *
55 * This allows other architectures that don't use similar device_enable()/
56 * device_shutdown() functions to execute normally.
57 *
58 * ...
59 *
60 * Suggested usage by device drivers:
61 *
62 * During device initialization:
63 * device_enable()
64 *
65 * During device idle:
66 * (save remaining device context if necessary)
67 * device_idle();
68 *
69 * During device resume:
70 * device_enable();
71 * (restore context if necessary)
72 *
73 * During device shutdown:
74 * device_shutdown()
75 * (device must be reinitialized at this point to use it again)
76 *
77 */
78#undef DEBUG
79
80#include <linux/kernel.h>
81#include <linux/platform_device.h>
82#include <linux/err.h>
83#include <linux/io.h>
84
Tony Lindgrence491cf2009-10-20 09:40:47 -070085#include <plat/omap_device.h>
86#include <plat/omap_hwmod.h>
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030087
88/* These parameters are passed to _omap_device_{de,}activate() */
89#define USE_WAKEUP_LAT 0
90#define IGNORE_WAKEUP_LAT 1
91
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030092
93/* Private functions */
94
95/**
Paul Walmsleyb04b65a2009-09-03 20:14:05 +030096 * _omap_device_activate - increase device readiness
97 * @od: struct omap_device *
98 * @ignore_lat: increase to latency target (0) or full readiness (1)?
99 *
100 * Increase readiness of omap_device @od (thus decreasing device
101 * wakeup latency, but consuming more power). If @ignore_lat is
102 * IGNORE_WAKEUP_LAT, make the omap_device fully active. Otherwise,
103 * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
104 * latency is greater than the requested maximum wakeup latency, step
105 * backwards in the omap_device_pm_latency table to ensure the
106 * device's maximum wakeup latency is less than or equal to the
107 * requested maximum wakeup latency. Returns 0.
108 */
109static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
110{
Tony Lindgrenf0594292009-10-19 15:25:24 -0700111 struct timespec a, b, c;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300112
113 pr_debug("omap_device: %s: activating\n", od->pdev.name);
114
115 while (od->pm_lat_level > 0) {
116 struct omap_device_pm_latency *odpl;
Tony Lindgrenf0594292009-10-19 15:25:24 -0700117 unsigned long long act_lat = 0;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300118
119 od->pm_lat_level--;
120
121 odpl = od->pm_lats + od->pm_lat_level;
122
123 if (!ignore_lat &&
124 (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
125 break;
126
Kevin Hilmand2292662009-12-08 16:34:23 -0700127 read_persistent_clock(&a);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300128
129 /* XXX check return code */
130 odpl->activate_func(od);
131
Kevin Hilmand2292662009-12-08 16:34:23 -0700132 read_persistent_clock(&b);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300133
Tony Lindgrenf0594292009-10-19 15:25:24 -0700134 c = timespec_sub(b, a);
Kevin Hilman0d93d8b2009-12-08 16:34:26 -0700135 act_lat = timespec_to_ns(&c);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300136
137 pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time "
Kevin Hilman0d93d8b2009-12-08 16:34:26 -0700138 "%llu nsec\n", od->pdev.name, od->pm_lat_level,
Tony Lindgrenf0594292009-10-19 15:25:24 -0700139 act_lat);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300140
Kevin Hilman9799aca2010-01-26 20:13:02 -0700141 if (act_lat > odpl->activate_lat) {
142 odpl->activate_lat_worst = act_lat;
143 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
144 odpl->activate_lat = act_lat;
145 pr_warning("omap_device: %s.%d: new worst case "
146 "activate latency %d: %llu\n",
147 od->pdev.name, od->pdev.id,
148 od->pm_lat_level, act_lat);
149 } else
150 pr_warning("omap_device: %s.%d: activate "
151 "latency %d higher than exptected. "
152 "(%llu > %d)\n",
153 od->pdev.name, od->pdev.id,
154 od->pm_lat_level, act_lat,
155 odpl->activate_lat);
156 }
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300157
158 od->dev_wakeup_lat -= odpl->activate_lat;
159 }
160
161 return 0;
162}
163
164/**
165 * _omap_device_deactivate - decrease device readiness
166 * @od: struct omap_device *
167 * @ignore_lat: decrease to latency target (0) or full inactivity (1)?
168 *
169 * Decrease readiness of omap_device @od (thus increasing device
170 * wakeup latency, but conserving power). If @ignore_lat is
171 * IGNORE_WAKEUP_LAT, make the omap_device fully inactive. Otherwise,
172 * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
173 * latency is less than the requested maximum wakeup latency, step
174 * forwards in the omap_device_pm_latency table to ensure the device's
175 * maximum wakeup latency is less than or equal to the requested
176 * maximum wakeup latency. Returns 0.
177 */
178static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
179{
Tony Lindgrenf0594292009-10-19 15:25:24 -0700180 struct timespec a, b, c;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300181
182 pr_debug("omap_device: %s: deactivating\n", od->pdev.name);
183
184 while (od->pm_lat_level < od->pm_lats_cnt) {
185 struct omap_device_pm_latency *odpl;
Tony Lindgrenf0594292009-10-19 15:25:24 -0700186 unsigned long long deact_lat = 0;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300187
188 odpl = od->pm_lats + od->pm_lat_level;
189
190 if (!ignore_lat &&
191 ((od->dev_wakeup_lat + odpl->activate_lat) >
192 od->_dev_wakeup_lat_limit))
193 break;
194
Kevin Hilmand2292662009-12-08 16:34:23 -0700195 read_persistent_clock(&a);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300196
197 /* XXX check return code */
198 odpl->deactivate_func(od);
199
Kevin Hilmand2292662009-12-08 16:34:23 -0700200 read_persistent_clock(&b);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300201
Tony Lindgrenf0594292009-10-19 15:25:24 -0700202 c = timespec_sub(b, a);
Kevin Hilman0d93d8b2009-12-08 16:34:26 -0700203 deact_lat = timespec_to_ns(&c);
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300204
205 pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time "
Kevin Hilman0d93d8b2009-12-08 16:34:26 -0700206 "%llu nsec\n", od->pdev.name, od->pm_lat_level,
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300207 deact_lat);
208
Kevin Hilman9799aca2010-01-26 20:13:02 -0700209 if (deact_lat > odpl->deactivate_lat) {
210 odpl->deactivate_lat_worst = deact_lat;
211 if (odpl->flags & OMAP_DEVICE_LATENCY_AUTO_ADJUST) {
212 odpl->deactivate_lat = deact_lat;
213 pr_warning("omap_device: %s.%d: new worst case "
214 "deactivate latency %d: %llu\n",
215 od->pdev.name, od->pdev.id,
216 od->pm_lat_level, deact_lat);
217 } else
218 pr_warning("omap_device: %s.%d: deactivate "
219 "latency %d higher than exptected. "
220 "(%llu > %d)\n",
221 od->pdev.name, od->pdev.id,
222 od->pm_lat_level, deact_lat,
223 odpl->deactivate_lat);
224 }
225
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300226
227 od->dev_wakeup_lat += odpl->activate_lat;
228
229 od->pm_lat_level++;
230 }
231
232 return 0;
233}
234
235static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
236{
237 return container_of(pdev, struct omap_device, pdev);
238}
239
240
241/* Public functions for use by core code */
242
243/**
244 * omap_device_count_resources - count number of struct resource entries needed
245 * @od: struct omap_device *
246 *
247 * Count the number of struct resource entries needed for this
248 * omap_device @od. Used by omap_device_build_ss() to determine how
249 * much memory to allocate before calling
250 * omap_device_fill_resources(). Returns the count.
251 */
252int omap_device_count_resources(struct omap_device *od)
253{
254 struct omap_hwmod *oh;
255 int c = 0;
256 int i;
257
258 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
259 c += omap_hwmod_count_resources(oh);
260
261 pr_debug("omap_device: %s: counted %d total resources across %d "
262 "hwmods\n", od->pdev.name, c, od->hwmods_cnt);
263
264 return c;
265}
266
267/**
268 * omap_device_fill_resources - fill in array of struct resource
269 * @od: struct omap_device *
270 * @res: pointer to an array of struct resource to be filled in
271 *
272 * Populate one or more empty struct resource pointed to by @res with
273 * the resource data for this omap_device @od. Used by
274 * omap_device_build_ss() after calling omap_device_count_resources().
275 * Ideally this function would not be needed at all. If omap_device
276 * replaces platform_device, then we can specify our own
277 * get_resource()/ get_irq()/etc functions that use the underlying
278 * omap_hwmod information. Or if platform_device is extended to use
279 * subarchitecture-specific function pointers, the various
280 * platform_device functions can simply call omap_device internal
281 * functions to get device resources. Hacking around the existing
282 * platform_device code wastes memory. Returns 0.
283 */
284int omap_device_fill_resources(struct omap_device *od, struct resource *res)
285{
286 struct omap_hwmod *oh;
287 int c = 0;
288 int i, r;
289
290 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) {
291 r = omap_hwmod_fill_resources(oh, res);
292 res += r;
293 c += r;
294 }
295
296 return 0;
297}
298
299/**
300 * omap_device_build - build and register an omap_device with one omap_hwmod
301 * @pdev_name: name of the platform_device driver to use
302 * @pdev_id: this platform_device's connection ID
303 * @oh: ptr to the single omap_hwmod that backs this omap_device
304 * @pdata: platform_data ptr to associate with the platform_device
305 * @pdata_len: amount of memory pointed to by @pdata
306 * @pm_lats: pointer to a omap_device_pm_latency array for this device
307 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
308 *
309 * Convenience function for building and registering a single
310 * omap_device record, which in turn builds and registers a
311 * platform_device record. See omap_device_build_ss() for more
312 * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
313 * passes along the return value of omap_device_build_ss().
314 */
315struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
316 struct omap_hwmod *oh, void *pdata,
317 int pdata_len,
318 struct omap_device_pm_latency *pm_lats,
319 int pm_lats_cnt)
320{
321 struct omap_hwmod *ohs[] = { oh };
322
323 if (!oh)
324 return ERR_PTR(-EINVAL);
325
326 return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata,
327 pdata_len, pm_lats, pm_lats_cnt);
328}
329
330/**
331 * omap_device_build_ss - build and register an omap_device with multiple hwmods
332 * @pdev_name: name of the platform_device driver to use
333 * @pdev_id: this platform_device's connection ID
334 * @oh: ptr to the single omap_hwmod that backs this omap_device
335 * @pdata: platform_data ptr to associate with the platform_device
336 * @pdata_len: amount of memory pointed to by @pdata
337 * @pm_lats: pointer to a omap_device_pm_latency array for this device
338 * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
339 *
340 * Convenience function for building and registering an omap_device
341 * subsystem record. Subsystem records consist of multiple
342 * omap_hwmods. This function in turn builds and registers a
343 * platform_device record. Returns an ERR_PTR() on error, or passes
344 * along the return value of omap_device_register().
345 */
346struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
347 struct omap_hwmod **ohs, int oh_cnt,
348 void *pdata, int pdata_len,
349 struct omap_device_pm_latency *pm_lats,
350 int pm_lats_cnt)
351{
352 int ret = -ENOMEM;
353 struct omap_device *od;
354 char *pdev_name2;
355 struct resource *res = NULL;
356 int res_count;
357 struct omap_hwmod **hwmods;
358
359 if (!ohs || oh_cnt == 0 || !pdev_name)
360 return ERR_PTR(-EINVAL);
361
362 if (!pdata && pdata_len > 0)
363 return ERR_PTR(-EINVAL);
364
365 pr_debug("omap_device: %s: building with %d hwmods\n", pdev_name,
366 oh_cnt);
367
368 od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
369 if (!od)
370 return ERR_PTR(-ENOMEM);
371
372 od->hwmods_cnt = oh_cnt;
373
374 hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt,
375 GFP_KERNEL);
376 if (!hwmods)
377 goto odbs_exit1;
378
379 memcpy(hwmods, ohs, sizeof(struct omap_hwmod *) * oh_cnt);
380 od->hwmods = hwmods;
381
382 pdev_name2 = kzalloc(strlen(pdev_name) + 1, GFP_KERNEL);
383 if (!pdev_name2)
384 goto odbs_exit2;
385 strcpy(pdev_name2, pdev_name);
386
387 od->pdev.name = pdev_name2;
388 od->pdev.id = pdev_id;
389
390 res_count = omap_device_count_resources(od);
391 if (res_count > 0) {
392 res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
393 if (!res)
394 goto odbs_exit3;
395 }
396 omap_device_fill_resources(od, res);
397
398 od->pdev.num_resources = res_count;
399 od->pdev.resource = res;
400
401 platform_device_add_data(&od->pdev, pdata, pdata_len);
402
403 od->pm_lats = pm_lats;
404 od->pm_lats_cnt = pm_lats_cnt;
405
406 ret = omap_device_register(od);
407 if (ret)
408 goto odbs_exit4;
409
410 return od;
411
412odbs_exit4:
413 kfree(res);
414odbs_exit3:
415 kfree(pdev_name2);
416odbs_exit2:
417 kfree(hwmods);
418odbs_exit1:
419 kfree(od);
420
421 pr_err("omap_device: %s: build failed (%d)\n", pdev_name, ret);
422
423 return ERR_PTR(ret);
424}
425
426/**
427 * omap_device_register - register an omap_device with one omap_hwmod
428 * @od: struct omap_device * to register
429 *
430 * Register the omap_device structure. This currently just calls
431 * platform_device_register() on the underlying platform_device.
432 * Returns the return value of platform_device_register().
433 */
434int omap_device_register(struct omap_device *od)
435{
436 pr_debug("omap_device: %s: registering\n", od->pdev.name);
437
438 return platform_device_register(&od->pdev);
439}
440
441
442/* Public functions for use by device drivers through struct platform_data */
443
444/**
445 * omap_device_enable - fully activate an omap_device
446 * @od: struct omap_device * to activate
447 *
448 * Do whatever is necessary for the hwmods underlying omap_device @od
449 * to be accessible and ready to operate. This generally involves
450 * enabling clocks, setting SYSCONFIG registers; and in the future may
451 * involve remuxing pins. Device drivers should call this function
452 * (through platform_data function pointers) where they would normally
453 * enable clocks, etc. Returns -EINVAL if called when the omap_device
454 * is already enabled, or passes along the return value of
455 * _omap_device_activate().
456 */
457int omap_device_enable(struct platform_device *pdev)
458{
459 int ret;
460 struct omap_device *od;
461
462 od = _find_by_pdev(pdev);
463
464 if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
465 WARN(1, "omap_device: %s.%d: omap_device_enable() called from "
466 "invalid state\n", od->pdev.name, od->pdev.id);
467 return -EINVAL;
468 }
469
470 /* Enable everything if we're enabling this device from scratch */
471 if (od->_state == OMAP_DEVICE_STATE_UNKNOWN)
472 od->pm_lat_level = od->pm_lats_cnt;
473
474 ret = _omap_device_activate(od, IGNORE_WAKEUP_LAT);
475
476 od->dev_wakeup_lat = 0;
Kevin Hilman5f1b6ef2009-12-08 16:34:22 -0700477 od->_dev_wakeup_lat_limit = UINT_MAX;
Paul Walmsleyb04b65a2009-09-03 20:14:05 +0300478 od->_state = OMAP_DEVICE_STATE_ENABLED;
479
480 return ret;
481}
482
483/**
484 * omap_device_idle - idle an omap_device
485 * @od: struct omap_device * to idle
486 *
487 * Idle omap_device @od by calling as many .deactivate_func() entries
488 * in the omap_device's pm_lats table as is possible without exceeding
489 * the device's maximum wakeup latency limit, pm_lat_limit. Device
490 * drivers should call this function (through platform_data function
491 * pointers) where they would normally disable clocks after operations
492 * complete, etc.. Returns -EINVAL if the omap_device is not
493 * currently enabled, or passes along the return value of
494 * _omap_device_deactivate().
495 */
496int omap_device_idle(struct platform_device *pdev)
497{
498 int ret;
499 struct omap_device *od;
500
501 od = _find_by_pdev(pdev);
502
503 if (od->_state != OMAP_DEVICE_STATE_ENABLED) {
504 WARN(1, "omap_device: %s.%d: omap_device_idle() called from "
505 "invalid state\n", od->pdev.name, od->pdev.id);
506 return -EINVAL;
507 }
508
509 ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
510
511 od->_state = OMAP_DEVICE_STATE_IDLE;
512
513 return ret;
514}
515
516/**
517 * omap_device_shutdown - shut down an omap_device
518 * @od: struct omap_device * to shut down
519 *
520 * Shut down omap_device @od by calling all .deactivate_func() entries
521 * in the omap_device's pm_lats table and then shutting down all of
522 * the underlying omap_hwmods. Used when a device is being "removed"
523 * or a device driver is being unloaded. Returns -EINVAL if the
524 * omap_device is not currently enabled or idle, or passes along the
525 * return value of _omap_device_deactivate().
526 */
527int omap_device_shutdown(struct platform_device *pdev)
528{
529 int ret, i;
530 struct omap_device *od;
531 struct omap_hwmod *oh;
532
533 od = _find_by_pdev(pdev);
534
535 if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
536 od->_state != OMAP_DEVICE_STATE_IDLE) {
537 WARN(1, "omap_device: %s.%d: omap_device_shutdown() called "
538 "from invalid state\n", od->pdev.name, od->pdev.id);
539 return -EINVAL;
540 }
541
542 ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
543
544 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
545 omap_hwmod_shutdown(oh);
546
547 od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
548
549 return ret;
550}
551
552/**
553 * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
554 * @od: struct omap_device *
555 *
556 * When a device's maximum wakeup latency limit changes, call some of
557 * the .activate_func or .deactivate_func function pointers in the
558 * omap_device's pm_lats array to ensure that the device's maximum
559 * wakeup latency is less than or equal to the new latency limit.
560 * Intended to be called by OMAP PM code whenever a device's maximum
561 * wakeup latency limit changes (e.g., via
562 * omap_pm_set_dev_wakeup_lat()). Returns 0 if nothing needs to be
563 * done (e.g., if the omap_device is not currently idle, or if the
564 * wakeup latency is already current with the new limit) or passes
565 * along the return value of _omap_device_deactivate() or
566 * _omap_device_activate().
567 */
568int omap_device_align_pm_lat(struct platform_device *pdev,
569 u32 new_wakeup_lat_limit)
570{
571 int ret = -EINVAL;
572 struct omap_device *od;
573
574 od = _find_by_pdev(pdev);
575
576 if (new_wakeup_lat_limit == od->dev_wakeup_lat)
577 return 0;
578
579 od->_dev_wakeup_lat_limit = new_wakeup_lat_limit;
580
581 if (od->_state != OMAP_DEVICE_STATE_IDLE)
582 return 0;
583 else if (new_wakeup_lat_limit > od->dev_wakeup_lat)
584 ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
585 else if (new_wakeup_lat_limit < od->dev_wakeup_lat)
586 ret = _omap_device_activate(od, USE_WAKEUP_LAT);
587
588 return ret;
589}
590
591/**
592 * omap_device_get_pwrdm - return the powerdomain * associated with @od
593 * @od: struct omap_device *
594 *
595 * Return the powerdomain associated with the first underlying
596 * omap_hwmod for this omap_device. Intended for use by core OMAP PM
597 * code. Returns NULL on error or a struct powerdomain * upon
598 * success.
599 */
600struct powerdomain *omap_device_get_pwrdm(struct omap_device *od)
601{
602 /*
603 * XXX Assumes that all omap_hwmod powerdomains are identical.
604 * This may not necessarily be true. There should be a sanity
605 * check in here to WARN() if any difference appears.
606 */
607 if (!od->hwmods_cnt)
608 return NULL;
609
610 return omap_hwmod_get_pwrdm(od->hwmods[0]);
611}
612
613/*
614 * Public functions intended for use in omap_device_pm_latency
615 * .activate_func and .deactivate_func function pointers
616 */
617
618/**
619 * omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
620 * @od: struct omap_device *od
621 *
622 * Enable all underlying hwmods. Returns 0.
623 */
624int omap_device_enable_hwmods(struct omap_device *od)
625{
626 struct omap_hwmod *oh;
627 int i;
628
629 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
630 omap_hwmod_enable(oh);
631
632 /* XXX pass along return value here? */
633 return 0;
634}
635
636/**
637 * omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
638 * @od: struct omap_device *od
639 *
640 * Idle all underlying hwmods. Returns 0.
641 */
642int omap_device_idle_hwmods(struct omap_device *od)
643{
644 struct omap_hwmod *oh;
645 int i;
646
647 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
648 omap_hwmod_idle(oh);
649
650 /* XXX pass along return value here? */
651 return 0;
652}
653
654/**
655 * omap_device_disable_clocks - disable all main and interface clocks
656 * @od: struct omap_device *od
657 *
658 * Disable the main functional clock and interface clock for all of the
659 * omap_hwmods associated with the omap_device. Returns 0.
660 */
661int omap_device_disable_clocks(struct omap_device *od)
662{
663 struct omap_hwmod *oh;
664 int i;
665
666 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
667 omap_hwmod_disable_clocks(oh);
668
669 /* XXX pass along return value here? */
670 return 0;
671}
672
673/**
674 * omap_device_enable_clocks - enable all main and interface clocks
675 * @od: struct omap_device *od
676 *
677 * Enable the main functional clock and interface clock for all of the
678 * omap_hwmods associated with the omap_device. Returns 0.
679 */
680int omap_device_enable_clocks(struct omap_device *od)
681{
682 struct omap_hwmod *oh;
683 int i;
684
685 for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
686 omap_hwmod_enable_clocks(oh);
687
688 /* XXX pass along return value here? */
689 return 0;
690}