omap_device.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /*
  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. #include <linux/kernel.h>
  80. #include <linux/platform_device.h>
  81. #include <linux/err.h>
  82. #include <linux/io.h>
  83. #include <plat/omap_device.h>
  84. #include <plat/omap_hwmod.h>
  85. /* These parameters are passed to _omap_device_{de,}activate() */
  86. #define USE_WAKEUP_LAT 0
  87. #define IGNORE_WAKEUP_LAT 1
  88. /* XXX this should be moved into a separate file */
  89. #if defined(CONFIG_ARCH_OMAP2420)
  90. # define OMAP_32KSYNCT_BASE 0x48004000
  91. #elif defined(CONFIG_ARCH_OMAP2430)
  92. # define OMAP_32KSYNCT_BASE 0x49020000
  93. #elif defined(CONFIG_ARCH_OMAP3430)
  94. # define OMAP_32KSYNCT_BASE 0x48320000
  95. #else
  96. # error Unknown OMAP device
  97. #endif
  98. /* Private functions */
  99. /**
  100. * _omap_device_activate - increase device readiness
  101. * @od: struct omap_device *
  102. * @ignore_lat: increase to latency target (0) or full readiness (1)?
  103. *
  104. * Increase readiness of omap_device @od (thus decreasing device
  105. * wakeup latency, but consuming more power). If @ignore_lat is
  106. * IGNORE_WAKEUP_LAT, make the omap_device fully active. Otherwise,
  107. * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
  108. * latency is greater than the requested maximum wakeup latency, step
  109. * backwards in the omap_device_pm_latency table to ensure the
  110. * device's maximum wakeup latency is less than or equal to the
  111. * requested maximum wakeup latency. Returns 0.
  112. */
  113. static int _omap_device_activate(struct omap_device *od, u8 ignore_lat)
  114. {
  115. struct timespec a, b, c;
  116. pr_debug("omap_device: %s: activating\n", od->pdev.name);
  117. while (od->pm_lat_level > 0) {
  118. struct omap_device_pm_latency *odpl;
  119. unsigned long long act_lat = 0;
  120. od->pm_lat_level--;
  121. odpl = od->pm_lats + od->pm_lat_level;
  122. if (!ignore_lat &&
  123. (od->dev_wakeup_lat <= od->_dev_wakeup_lat_limit))
  124. break;
  125. read_persistent_clock(&a);
  126. /* XXX check return code */
  127. odpl->activate_func(od);
  128. read_persistent_clock(&b);
  129. c = timespec_sub(b, a);
  130. act_lat = timespec_to_ns(&c);
  131. pr_debug("omap_device: %s: pm_lat %d: activate: elapsed time "
  132. "%llu nsec\n", od->pdev.name, od->pm_lat_level,
  133. act_lat);
  134. WARN(act_lat > odpl->activate_lat, "omap_device: %s.%d: "
  135. "activate step %d took longer than expected (%llu > %d)\n",
  136. od->pdev.name, od->pdev.id, od->pm_lat_level,
  137. act_lat, odpl->activate_lat);
  138. od->dev_wakeup_lat -= odpl->activate_lat;
  139. }
  140. return 0;
  141. }
  142. /**
  143. * _omap_device_deactivate - decrease device readiness
  144. * @od: struct omap_device *
  145. * @ignore_lat: decrease to latency target (0) or full inactivity (1)?
  146. *
  147. * Decrease readiness of omap_device @od (thus increasing device
  148. * wakeup latency, but conserving power). If @ignore_lat is
  149. * IGNORE_WAKEUP_LAT, make the omap_device fully inactive. Otherwise,
  150. * if @ignore_lat is USE_WAKEUP_LAT, and the device's maximum wakeup
  151. * latency is less than the requested maximum wakeup latency, step
  152. * forwards in the omap_device_pm_latency table to ensure the device's
  153. * maximum wakeup latency is less than or equal to the requested
  154. * maximum wakeup latency. Returns 0.
  155. */
  156. static int _omap_device_deactivate(struct omap_device *od, u8 ignore_lat)
  157. {
  158. struct timespec a, b, c;
  159. pr_debug("omap_device: %s: deactivating\n", od->pdev.name);
  160. while (od->pm_lat_level < od->pm_lats_cnt) {
  161. struct omap_device_pm_latency *odpl;
  162. unsigned long long deact_lat = 0;
  163. odpl = od->pm_lats + od->pm_lat_level;
  164. if (!ignore_lat &&
  165. ((od->dev_wakeup_lat + odpl->activate_lat) >
  166. od->_dev_wakeup_lat_limit))
  167. break;
  168. read_persistent_clock(&a);
  169. /* XXX check return code */
  170. odpl->deactivate_func(od);
  171. read_persistent_clock(&b);
  172. c = timespec_sub(b, a);
  173. deact_lat = timespec_to_ns(&c);
  174. pr_debug("omap_device: %s: pm_lat %d: deactivate: elapsed time "
  175. "%llu nsec\n", od->pdev.name, od->pm_lat_level,
  176. deact_lat);
  177. WARN(deact_lat > odpl->deactivate_lat, "omap_device: %s.%d: "
  178. "deactivate step %d took longer than expected "
  179. "(%llu > %d)\n", od->pdev.name, od->pdev.id,
  180. od->pm_lat_level, deact_lat, odpl->deactivate_lat);
  181. od->dev_wakeup_lat += odpl->activate_lat;
  182. od->pm_lat_level++;
  183. }
  184. return 0;
  185. }
  186. static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
  187. {
  188. return container_of(pdev, struct omap_device, pdev);
  189. }
  190. /* Public functions for use by core code */
  191. /**
  192. * omap_device_count_resources - count number of struct resource entries needed
  193. * @od: struct omap_device *
  194. *
  195. * Count the number of struct resource entries needed for this
  196. * omap_device @od. Used by omap_device_build_ss() to determine how
  197. * much memory to allocate before calling
  198. * omap_device_fill_resources(). Returns the count.
  199. */
  200. int omap_device_count_resources(struct omap_device *od)
  201. {
  202. struct omap_hwmod *oh;
  203. int c = 0;
  204. int i;
  205. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  206. c += omap_hwmod_count_resources(oh);
  207. pr_debug("omap_device: %s: counted %d total resources across %d "
  208. "hwmods\n", od->pdev.name, c, od->hwmods_cnt);
  209. return c;
  210. }
  211. /**
  212. * omap_device_fill_resources - fill in array of struct resource
  213. * @od: struct omap_device *
  214. * @res: pointer to an array of struct resource to be filled in
  215. *
  216. * Populate one or more empty struct resource pointed to by @res with
  217. * the resource data for this omap_device @od. Used by
  218. * omap_device_build_ss() after calling omap_device_count_resources().
  219. * Ideally this function would not be needed at all. If omap_device
  220. * replaces platform_device, then we can specify our own
  221. * get_resource()/ get_irq()/etc functions that use the underlying
  222. * omap_hwmod information. Or if platform_device is extended to use
  223. * subarchitecture-specific function pointers, the various
  224. * platform_device functions can simply call omap_device internal
  225. * functions to get device resources. Hacking around the existing
  226. * platform_device code wastes memory. Returns 0.
  227. */
  228. int omap_device_fill_resources(struct omap_device *od, struct resource *res)
  229. {
  230. struct omap_hwmod *oh;
  231. int c = 0;
  232. int i, r;
  233. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++) {
  234. r = omap_hwmod_fill_resources(oh, res);
  235. res += r;
  236. c += r;
  237. }
  238. return 0;
  239. }
  240. /**
  241. * omap_device_build - build and register an omap_device with one omap_hwmod
  242. * @pdev_name: name of the platform_device driver to use
  243. * @pdev_id: this platform_device's connection ID
  244. * @oh: ptr to the single omap_hwmod that backs this omap_device
  245. * @pdata: platform_data ptr to associate with the platform_device
  246. * @pdata_len: amount of memory pointed to by @pdata
  247. * @pm_lats: pointer to a omap_device_pm_latency array for this device
  248. * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
  249. *
  250. * Convenience function for building and registering a single
  251. * omap_device record, which in turn builds and registers a
  252. * platform_device record. See omap_device_build_ss() for more
  253. * information. Returns ERR_PTR(-EINVAL) if @oh is NULL; otherwise,
  254. * passes along the return value of omap_device_build_ss().
  255. */
  256. struct omap_device *omap_device_build(const char *pdev_name, int pdev_id,
  257. struct omap_hwmod *oh, void *pdata,
  258. int pdata_len,
  259. struct omap_device_pm_latency *pm_lats,
  260. int pm_lats_cnt)
  261. {
  262. struct omap_hwmod *ohs[] = { oh };
  263. if (!oh)
  264. return ERR_PTR(-EINVAL);
  265. return omap_device_build_ss(pdev_name, pdev_id, ohs, 1, pdata,
  266. pdata_len, pm_lats, pm_lats_cnt);
  267. }
  268. /**
  269. * omap_device_build_ss - build and register an omap_device with multiple hwmods
  270. * @pdev_name: name of the platform_device driver to use
  271. * @pdev_id: this platform_device's connection ID
  272. * @oh: ptr to the single omap_hwmod that backs this omap_device
  273. * @pdata: platform_data ptr to associate with the platform_device
  274. * @pdata_len: amount of memory pointed to by @pdata
  275. * @pm_lats: pointer to a omap_device_pm_latency array for this device
  276. * @pm_lats_cnt: ARRAY_SIZE() of @pm_lats
  277. *
  278. * Convenience function for building and registering an omap_device
  279. * subsystem record. Subsystem records consist of multiple
  280. * omap_hwmods. This function in turn builds and registers a
  281. * platform_device record. Returns an ERR_PTR() on error, or passes
  282. * along the return value of omap_device_register().
  283. */
  284. struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
  285. struct omap_hwmod **ohs, int oh_cnt,
  286. void *pdata, int pdata_len,
  287. struct omap_device_pm_latency *pm_lats,
  288. int pm_lats_cnt)
  289. {
  290. int ret = -ENOMEM;
  291. struct omap_device *od;
  292. char *pdev_name2;
  293. struct resource *res = NULL;
  294. int res_count;
  295. struct omap_hwmod **hwmods;
  296. if (!ohs || oh_cnt == 0 || !pdev_name)
  297. return ERR_PTR(-EINVAL);
  298. if (!pdata && pdata_len > 0)
  299. return ERR_PTR(-EINVAL);
  300. pr_debug("omap_device: %s: building with %d hwmods\n", pdev_name,
  301. oh_cnt);
  302. od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
  303. if (!od)
  304. return ERR_PTR(-ENOMEM);
  305. od->hwmods_cnt = oh_cnt;
  306. hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt,
  307. GFP_KERNEL);
  308. if (!hwmods)
  309. goto odbs_exit1;
  310. memcpy(hwmods, ohs, sizeof(struct omap_hwmod *) * oh_cnt);
  311. od->hwmods = hwmods;
  312. pdev_name2 = kzalloc(strlen(pdev_name) + 1, GFP_KERNEL);
  313. if (!pdev_name2)
  314. goto odbs_exit2;
  315. strcpy(pdev_name2, pdev_name);
  316. od->pdev.name = pdev_name2;
  317. od->pdev.id = pdev_id;
  318. res_count = omap_device_count_resources(od);
  319. if (res_count > 0) {
  320. res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
  321. if (!res)
  322. goto odbs_exit3;
  323. }
  324. omap_device_fill_resources(od, res);
  325. od->pdev.num_resources = res_count;
  326. od->pdev.resource = res;
  327. platform_device_add_data(&od->pdev, pdata, pdata_len);
  328. od->pm_lats = pm_lats;
  329. od->pm_lats_cnt = pm_lats_cnt;
  330. ret = omap_device_register(od);
  331. if (ret)
  332. goto odbs_exit4;
  333. return od;
  334. odbs_exit4:
  335. kfree(res);
  336. odbs_exit3:
  337. kfree(pdev_name2);
  338. odbs_exit2:
  339. kfree(hwmods);
  340. odbs_exit1:
  341. kfree(od);
  342. pr_err("omap_device: %s: build failed (%d)\n", pdev_name, ret);
  343. return ERR_PTR(ret);
  344. }
  345. /**
  346. * omap_device_register - register an omap_device with one omap_hwmod
  347. * @od: struct omap_device * to register
  348. *
  349. * Register the omap_device structure. This currently just calls
  350. * platform_device_register() on the underlying platform_device.
  351. * Returns the return value of platform_device_register().
  352. */
  353. int omap_device_register(struct omap_device *od)
  354. {
  355. pr_debug("omap_device: %s: registering\n", od->pdev.name);
  356. return platform_device_register(&od->pdev);
  357. }
  358. /* Public functions for use by device drivers through struct platform_data */
  359. /**
  360. * omap_device_enable - fully activate an omap_device
  361. * @od: struct omap_device * to activate
  362. *
  363. * Do whatever is necessary for the hwmods underlying omap_device @od
  364. * to be accessible and ready to operate. This generally involves
  365. * enabling clocks, setting SYSCONFIG registers; and in the future may
  366. * involve remuxing pins. Device drivers should call this function
  367. * (through platform_data function pointers) where they would normally
  368. * enable clocks, etc. Returns -EINVAL if called when the omap_device
  369. * is already enabled, or passes along the return value of
  370. * _omap_device_activate().
  371. */
  372. int omap_device_enable(struct platform_device *pdev)
  373. {
  374. int ret;
  375. struct omap_device *od;
  376. od = _find_by_pdev(pdev);
  377. if (od->_state == OMAP_DEVICE_STATE_ENABLED) {
  378. WARN(1, "omap_device: %s.%d: omap_device_enable() called from "
  379. "invalid state\n", od->pdev.name, od->pdev.id);
  380. return -EINVAL;
  381. }
  382. /* Enable everything if we're enabling this device from scratch */
  383. if (od->_state == OMAP_DEVICE_STATE_UNKNOWN)
  384. od->pm_lat_level = od->pm_lats_cnt;
  385. ret = _omap_device_activate(od, IGNORE_WAKEUP_LAT);
  386. od->dev_wakeup_lat = 0;
  387. od->_dev_wakeup_lat_limit = UINT_MAX;
  388. od->_state = OMAP_DEVICE_STATE_ENABLED;
  389. return ret;
  390. }
  391. /**
  392. * omap_device_idle - idle an omap_device
  393. * @od: struct omap_device * to idle
  394. *
  395. * Idle omap_device @od by calling as many .deactivate_func() entries
  396. * in the omap_device's pm_lats table as is possible without exceeding
  397. * the device's maximum wakeup latency limit, pm_lat_limit. Device
  398. * drivers should call this function (through platform_data function
  399. * pointers) where they would normally disable clocks after operations
  400. * complete, etc.. Returns -EINVAL if the omap_device is not
  401. * currently enabled, or passes along the return value of
  402. * _omap_device_deactivate().
  403. */
  404. int omap_device_idle(struct platform_device *pdev)
  405. {
  406. int ret;
  407. struct omap_device *od;
  408. od = _find_by_pdev(pdev);
  409. if (od->_state != OMAP_DEVICE_STATE_ENABLED) {
  410. WARN(1, "omap_device: %s.%d: omap_device_idle() called from "
  411. "invalid state\n", od->pdev.name, od->pdev.id);
  412. return -EINVAL;
  413. }
  414. ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
  415. od->_state = OMAP_DEVICE_STATE_IDLE;
  416. return ret;
  417. }
  418. /**
  419. * omap_device_shutdown - shut down an omap_device
  420. * @od: struct omap_device * to shut down
  421. *
  422. * Shut down omap_device @od by calling all .deactivate_func() entries
  423. * in the omap_device's pm_lats table and then shutting down all of
  424. * the underlying omap_hwmods. Used when a device is being "removed"
  425. * or a device driver is being unloaded. Returns -EINVAL if the
  426. * omap_device is not currently enabled or idle, or passes along the
  427. * return value of _omap_device_deactivate().
  428. */
  429. int omap_device_shutdown(struct platform_device *pdev)
  430. {
  431. int ret, i;
  432. struct omap_device *od;
  433. struct omap_hwmod *oh;
  434. od = _find_by_pdev(pdev);
  435. if (od->_state != OMAP_DEVICE_STATE_ENABLED &&
  436. od->_state != OMAP_DEVICE_STATE_IDLE) {
  437. WARN(1, "omap_device: %s.%d: omap_device_shutdown() called "
  438. "from invalid state\n", od->pdev.name, od->pdev.id);
  439. return -EINVAL;
  440. }
  441. ret = _omap_device_deactivate(od, IGNORE_WAKEUP_LAT);
  442. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  443. omap_hwmod_shutdown(oh);
  444. od->_state = OMAP_DEVICE_STATE_SHUTDOWN;
  445. return ret;
  446. }
  447. /**
  448. * omap_device_align_pm_lat - activate/deactivate device to match wakeup lat lim
  449. * @od: struct omap_device *
  450. *
  451. * When a device's maximum wakeup latency limit changes, call some of
  452. * the .activate_func or .deactivate_func function pointers in the
  453. * omap_device's pm_lats array to ensure that the device's maximum
  454. * wakeup latency is less than or equal to the new latency limit.
  455. * Intended to be called by OMAP PM code whenever a device's maximum
  456. * wakeup latency limit changes (e.g., via
  457. * omap_pm_set_dev_wakeup_lat()). Returns 0 if nothing needs to be
  458. * done (e.g., if the omap_device is not currently idle, or if the
  459. * wakeup latency is already current with the new limit) or passes
  460. * along the return value of _omap_device_deactivate() or
  461. * _omap_device_activate().
  462. */
  463. int omap_device_align_pm_lat(struct platform_device *pdev,
  464. u32 new_wakeup_lat_limit)
  465. {
  466. int ret = -EINVAL;
  467. struct omap_device *od;
  468. od = _find_by_pdev(pdev);
  469. if (new_wakeup_lat_limit == od->dev_wakeup_lat)
  470. return 0;
  471. od->_dev_wakeup_lat_limit = new_wakeup_lat_limit;
  472. if (od->_state != OMAP_DEVICE_STATE_IDLE)
  473. return 0;
  474. else if (new_wakeup_lat_limit > od->dev_wakeup_lat)
  475. ret = _omap_device_deactivate(od, USE_WAKEUP_LAT);
  476. else if (new_wakeup_lat_limit < od->dev_wakeup_lat)
  477. ret = _omap_device_activate(od, USE_WAKEUP_LAT);
  478. return ret;
  479. }
  480. /**
  481. * omap_device_get_pwrdm - return the powerdomain * associated with @od
  482. * @od: struct omap_device *
  483. *
  484. * Return the powerdomain associated with the first underlying
  485. * omap_hwmod for this omap_device. Intended for use by core OMAP PM
  486. * code. Returns NULL on error or a struct powerdomain * upon
  487. * success.
  488. */
  489. struct powerdomain *omap_device_get_pwrdm(struct omap_device *od)
  490. {
  491. /*
  492. * XXX Assumes that all omap_hwmod powerdomains are identical.
  493. * This may not necessarily be true. There should be a sanity
  494. * check in here to WARN() if any difference appears.
  495. */
  496. if (!od->hwmods_cnt)
  497. return NULL;
  498. return omap_hwmod_get_pwrdm(od->hwmods[0]);
  499. }
  500. /*
  501. * Public functions intended for use in omap_device_pm_latency
  502. * .activate_func and .deactivate_func function pointers
  503. */
  504. /**
  505. * omap_device_enable_hwmods - call omap_hwmod_enable() on all hwmods
  506. * @od: struct omap_device *od
  507. *
  508. * Enable all underlying hwmods. Returns 0.
  509. */
  510. int omap_device_enable_hwmods(struct omap_device *od)
  511. {
  512. struct omap_hwmod *oh;
  513. int i;
  514. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  515. omap_hwmod_enable(oh);
  516. /* XXX pass along return value here? */
  517. return 0;
  518. }
  519. /**
  520. * omap_device_idle_hwmods - call omap_hwmod_idle() on all hwmods
  521. * @od: struct omap_device *od
  522. *
  523. * Idle all underlying hwmods. Returns 0.
  524. */
  525. int omap_device_idle_hwmods(struct omap_device *od)
  526. {
  527. struct omap_hwmod *oh;
  528. int i;
  529. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  530. omap_hwmod_idle(oh);
  531. /* XXX pass along return value here? */
  532. return 0;
  533. }
  534. /**
  535. * omap_device_disable_clocks - disable all main and interface clocks
  536. * @od: struct omap_device *od
  537. *
  538. * Disable the main functional clock and interface clock for all of the
  539. * omap_hwmods associated with the omap_device. Returns 0.
  540. */
  541. int omap_device_disable_clocks(struct omap_device *od)
  542. {
  543. struct omap_hwmod *oh;
  544. int i;
  545. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  546. omap_hwmod_disable_clocks(oh);
  547. /* XXX pass along return value here? */
  548. return 0;
  549. }
  550. /**
  551. * omap_device_enable_clocks - enable all main and interface clocks
  552. * @od: struct omap_device *od
  553. *
  554. * Enable the main functional clock and interface clock for all of the
  555. * omap_hwmods associated with the omap_device. Returns 0.
  556. */
  557. int omap_device_enable_clocks(struct omap_device *od)
  558. {
  559. struct omap_hwmod *oh;
  560. int i;
  561. for (i = 0, oh = *od->hwmods; i < od->hwmods_cnt; i++, oh++)
  562. omap_hwmod_enable_clocks(oh);
  563. /* XXX pass along return value here? */
  564. return 0;
  565. }