omap_device.c 20 KB

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