omap_device.c 20 KB

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