clockdomain.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * OMAP2/3 clockdomain framework functions
  3. *
  4. * Copyright (C) 2008 Texas Instruments, Inc.
  5. * Copyright (C) 2008-2009 Nokia Corporation
  6. *
  7. * Written by Paul Walmsley and Jouni Högander
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #undef DEBUG
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/device.h>
  17. #include <linux/list.h>
  18. #include <linux/errno.h>
  19. #include <linux/delay.h>
  20. #include <linux/clk.h>
  21. #include <linux/limits.h>
  22. #include <linux/err.h>
  23. #include <linux/io.h>
  24. #include <linux/bitops.h>
  25. #include <plat/clock.h>
  26. #include "prm.h"
  27. #include "prm-regbits-24xx.h"
  28. #include "cm.h"
  29. #include <plat/powerdomain.h>
  30. #include <plat/clockdomain.h>
  31. /* clkdm_list contains all registered struct clockdomains */
  32. static LIST_HEAD(clkdm_list);
  33. /* clkdm_mutex protects clkdm_list add and del ops */
  34. static DEFINE_MUTEX(clkdm_mutex);
  35. /* array of powerdomain deps to be added/removed when clkdm in hwsup mode */
  36. static struct clkdm_pwrdm_autodep *autodeps;
  37. /* Private functions */
  38. /*
  39. * _autodep_lookup - resolve autodep pwrdm names to pwrdm pointers; store
  40. * @autodep: struct clkdm_pwrdm_autodep * to resolve
  41. *
  42. * Resolve autodep powerdomain names to powerdomain pointers via
  43. * pwrdm_lookup() and store the pointers in the autodep structure. An
  44. * "autodep" is a powerdomain sleep/wakeup dependency that is
  45. * automatically added and removed whenever clocks in the associated
  46. * clockdomain are enabled or disabled (respectively) when the
  47. * clockdomain is in hardware-supervised mode. Meant to be called
  48. * once at clockdomain layer initialization, since these should remain
  49. * fixed for a particular architecture. No return value.
  50. */
  51. static void _autodep_lookup(struct clkdm_pwrdm_autodep *autodep)
  52. {
  53. struct powerdomain *pwrdm;
  54. if (!autodep)
  55. return;
  56. if (!omap_chip_is(autodep->omap_chip))
  57. return;
  58. pwrdm = pwrdm_lookup(autodep->pwrdm.name);
  59. if (!pwrdm) {
  60. pr_err("clockdomain: autodeps: powerdomain %s does not exist\n",
  61. autodep->pwrdm.name);
  62. pwrdm = ERR_PTR(-ENOENT);
  63. }
  64. autodep->pwrdm.ptr = pwrdm;
  65. }
  66. /*
  67. * _clkdm_add_autodeps - add auto sleepdeps/wkdeps to clkdm upon clock enable
  68. * @clkdm: struct clockdomain *
  69. *
  70. * Add the "autodep" sleep & wakeup dependencies to clockdomain 'clkdm'
  71. * in hardware-supervised mode. Meant to be called from clock framework
  72. * when a clock inside clockdomain 'clkdm' is enabled. No return value.
  73. */
  74. static void _clkdm_add_autodeps(struct clockdomain *clkdm)
  75. {
  76. struct clkdm_pwrdm_autodep *autodep;
  77. for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
  78. if (IS_ERR(autodep->pwrdm.ptr))
  79. continue;
  80. if (!omap_chip_is(autodep->omap_chip))
  81. continue;
  82. pr_debug("clockdomain: adding %s sleepdep/wkdep for "
  83. "pwrdm %s\n", autodep->pwrdm.ptr->name,
  84. clkdm->pwrdm.ptr->name);
  85. pwrdm_add_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
  86. pwrdm_add_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
  87. }
  88. }
  89. /*
  90. * _clkdm_add_autodeps - remove auto sleepdeps/wkdeps from clkdm
  91. * @clkdm: struct clockdomain *
  92. *
  93. * Remove the "autodep" sleep & wakeup dependencies from clockdomain 'clkdm'
  94. * in hardware-supervised mode. Meant to be called from clock framework
  95. * when a clock inside clockdomain 'clkdm' is disabled. No return value.
  96. */
  97. static void _clkdm_del_autodeps(struct clockdomain *clkdm)
  98. {
  99. struct clkdm_pwrdm_autodep *autodep;
  100. for (autodep = autodeps; autodep->pwrdm.ptr; autodep++) {
  101. if (IS_ERR(autodep->pwrdm.ptr))
  102. continue;
  103. if (!omap_chip_is(autodep->omap_chip))
  104. continue;
  105. pr_debug("clockdomain: removing %s sleepdep/wkdep for "
  106. "pwrdm %s\n", autodep->pwrdm.ptr->name,
  107. clkdm->pwrdm.ptr->name);
  108. pwrdm_del_sleepdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
  109. pwrdm_del_wkdep(clkdm->pwrdm.ptr, autodep->pwrdm.ptr);
  110. }
  111. }
  112. /*
  113. * _omap2_clkdm_set_hwsup - set the hwsup idle transition bit
  114. * @clkdm: struct clockdomain *
  115. * @enable: int 0 to disable, 1 to enable
  116. *
  117. * Internal helper for actually switching the bit that controls hwsup
  118. * idle transitions for clkdm.
  119. */
  120. static void _omap2_clkdm_set_hwsup(struct clockdomain *clkdm, int enable)
  121. {
  122. u32 v;
  123. if (cpu_is_omap24xx()) {
  124. if (enable)
  125. v = OMAP24XX_CLKSTCTRL_ENABLE_AUTO;
  126. else
  127. v = OMAP24XX_CLKSTCTRL_DISABLE_AUTO;
  128. } else if (cpu_is_omap34xx()) {
  129. if (enable)
  130. v = OMAP34XX_CLKSTCTRL_ENABLE_AUTO;
  131. else
  132. v = OMAP34XX_CLKSTCTRL_DISABLE_AUTO;
  133. } else {
  134. BUG();
  135. }
  136. cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask,
  137. v << __ffs(clkdm->clktrctrl_mask),
  138. clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
  139. }
  140. static struct clockdomain *_clkdm_lookup(const char *name)
  141. {
  142. struct clockdomain *clkdm, *temp_clkdm;
  143. if (!name)
  144. return NULL;
  145. clkdm = NULL;
  146. list_for_each_entry(temp_clkdm, &clkdm_list, node) {
  147. if (!strcmp(name, temp_clkdm->name)) {
  148. clkdm = temp_clkdm;
  149. break;
  150. }
  151. }
  152. return clkdm;
  153. }
  154. /* Public functions */
  155. /**
  156. * clkdm_init - set up the clockdomain layer
  157. * @clkdms: optional pointer to an array of clockdomains to register
  158. * @init_autodeps: optional pointer to an array of autodeps to register
  159. *
  160. * Set up internal state. If a pointer to an array of clockdomains
  161. * was supplied, loop through the list of clockdomains, register all
  162. * that are available on the current platform. Similarly, if a
  163. * pointer to an array of clockdomain-powerdomain autodependencies was
  164. * provided, register those. No return value.
  165. */
  166. void clkdm_init(struct clockdomain **clkdms,
  167. struct clkdm_pwrdm_autodep *init_autodeps)
  168. {
  169. struct clockdomain **c = NULL;
  170. struct clkdm_pwrdm_autodep *autodep = NULL;
  171. if (clkdms)
  172. for (c = clkdms; *c; c++)
  173. clkdm_register(*c);
  174. autodeps = init_autodeps;
  175. if (autodeps)
  176. for (autodep = autodeps; autodep->pwrdm.ptr; autodep++)
  177. _autodep_lookup(autodep);
  178. }
  179. /**
  180. * clkdm_register - register a clockdomain
  181. * @clkdm: struct clockdomain * to register
  182. *
  183. * Adds a clockdomain to the internal clockdomain list.
  184. * Returns -EINVAL if given a null pointer, -EEXIST if a clockdomain is
  185. * already registered by the provided name, or 0 upon success.
  186. */
  187. int clkdm_register(struct clockdomain *clkdm)
  188. {
  189. int ret = -EINVAL;
  190. struct powerdomain *pwrdm;
  191. if (!clkdm || !clkdm->name)
  192. return -EINVAL;
  193. if (!omap_chip_is(clkdm->omap_chip))
  194. return -EINVAL;
  195. pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
  196. if (!pwrdm) {
  197. pr_err("clockdomain: %s: powerdomain %s does not exist\n",
  198. clkdm->name, clkdm->pwrdm.name);
  199. return -EINVAL;
  200. }
  201. clkdm->pwrdm.ptr = pwrdm;
  202. mutex_lock(&clkdm_mutex);
  203. /* Verify that the clockdomain is not already registered */
  204. if (_clkdm_lookup(clkdm->name)) {
  205. ret = -EEXIST;
  206. goto cr_unlock;
  207. }
  208. list_add(&clkdm->node, &clkdm_list);
  209. pwrdm_add_clkdm(pwrdm, clkdm);
  210. pr_debug("clockdomain: registered %s\n", clkdm->name);
  211. ret = 0;
  212. cr_unlock:
  213. mutex_unlock(&clkdm_mutex);
  214. return ret;
  215. }
  216. /**
  217. * clkdm_unregister - unregister a clockdomain
  218. * @clkdm: struct clockdomain * to unregister
  219. *
  220. * Removes a clockdomain from the internal clockdomain list. Returns
  221. * -EINVAL if clkdm argument is NULL.
  222. */
  223. int clkdm_unregister(struct clockdomain *clkdm)
  224. {
  225. if (!clkdm)
  226. return -EINVAL;
  227. pwrdm_del_clkdm(clkdm->pwrdm.ptr, clkdm);
  228. mutex_lock(&clkdm_mutex);
  229. list_del(&clkdm->node);
  230. mutex_unlock(&clkdm_mutex);
  231. pr_debug("clockdomain: unregistered %s\n", clkdm->name);
  232. return 0;
  233. }
  234. /**
  235. * clkdm_lookup - look up a clockdomain by name, return a pointer
  236. * @name: name of clockdomain
  237. *
  238. * Find a registered clockdomain by its name. Returns a pointer to the
  239. * struct clockdomain if found, or NULL otherwise.
  240. */
  241. struct clockdomain *clkdm_lookup(const char *name)
  242. {
  243. struct clockdomain *clkdm, *temp_clkdm;
  244. if (!name)
  245. return NULL;
  246. clkdm = NULL;
  247. mutex_lock(&clkdm_mutex);
  248. list_for_each_entry(temp_clkdm, &clkdm_list, node) {
  249. if (!strcmp(name, temp_clkdm->name)) {
  250. clkdm = temp_clkdm;
  251. break;
  252. }
  253. }
  254. mutex_unlock(&clkdm_mutex);
  255. return clkdm;
  256. }
  257. /**
  258. * clkdm_for_each - call function on each registered clockdomain
  259. * @fn: callback function *
  260. *
  261. * Call the supplied function for each registered clockdomain.
  262. * The callback function can return anything but 0 to bail
  263. * out early from the iterator. The callback function is called with
  264. * the clkdm_mutex held, so no clockdomain structure manipulation
  265. * functions should be called from the callback, although hardware
  266. * clockdomain control functions are fine. Returns the last return
  267. * value of the callback function, which should be 0 for success or
  268. * anything else to indicate failure; or -EINVAL if the function pointer
  269. * is null.
  270. */
  271. int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
  272. void *user)
  273. {
  274. struct clockdomain *clkdm;
  275. int ret = 0;
  276. if (!fn)
  277. return -EINVAL;
  278. mutex_lock(&clkdm_mutex);
  279. list_for_each_entry(clkdm, &clkdm_list, node) {
  280. ret = (*fn)(clkdm, user);
  281. if (ret)
  282. break;
  283. }
  284. mutex_unlock(&clkdm_mutex);
  285. return ret;
  286. }
  287. /**
  288. * clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in
  289. * @clkdm: struct clockdomain *
  290. *
  291. * Return a pointer to the struct powerdomain that the specified clockdomain
  292. * 'clkdm' exists in, or returns NULL if clkdm argument is NULL.
  293. */
  294. struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
  295. {
  296. if (!clkdm)
  297. return NULL;
  298. return clkdm->pwrdm.ptr;
  299. }
  300. /* Hardware clockdomain control */
  301. /**
  302. * omap2_clkdm_clktrctrl_read - read the clkdm's current state transition mode
  303. * @clk: struct clk * of a clockdomain
  304. *
  305. * Return the clockdomain's current state transition mode from the
  306. * corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if clk
  307. * is NULL or the current mode upon success.
  308. */
  309. static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
  310. {
  311. u32 v;
  312. if (!clkdm)
  313. return -EINVAL;
  314. v = cm_read_mod_reg(clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
  315. v &= clkdm->clktrctrl_mask;
  316. v >>= __ffs(clkdm->clktrctrl_mask);
  317. return v;
  318. }
  319. /**
  320. * omap2_clkdm_sleep - force clockdomain sleep transition
  321. * @clkdm: struct clockdomain *
  322. *
  323. * Instruct the CM to force a sleep transition on the specified
  324. * clockdomain 'clkdm'. Returns -EINVAL if clk is NULL or if
  325. * clockdomain does not support software-initiated sleep; 0 upon
  326. * success.
  327. */
  328. int omap2_clkdm_sleep(struct clockdomain *clkdm)
  329. {
  330. if (!clkdm)
  331. return -EINVAL;
  332. if (!(clkdm->flags & CLKDM_CAN_FORCE_SLEEP)) {
  333. pr_debug("clockdomain: %s does not support forcing "
  334. "sleep via software\n", clkdm->name);
  335. return -EINVAL;
  336. }
  337. pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name);
  338. if (cpu_is_omap24xx()) {
  339. cm_set_mod_reg_bits(OMAP24XX_FORCESTATE,
  340. clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
  341. } else if (cpu_is_omap34xx()) {
  342. u32 v = (OMAP34XX_CLKSTCTRL_FORCE_SLEEP <<
  343. __ffs(clkdm->clktrctrl_mask));
  344. cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
  345. clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
  346. } else {
  347. BUG();
  348. };
  349. return 0;
  350. }
  351. /**
  352. * omap2_clkdm_wakeup - force clockdomain wakeup transition
  353. * @clkdm: struct clockdomain *
  354. *
  355. * Instruct the CM to force a wakeup transition on the specified
  356. * clockdomain 'clkdm'. Returns -EINVAL if clkdm is NULL or if the
  357. * clockdomain does not support software-controlled wakeup; 0 upon
  358. * success.
  359. */
  360. int omap2_clkdm_wakeup(struct clockdomain *clkdm)
  361. {
  362. if (!clkdm)
  363. return -EINVAL;
  364. if (!(clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)) {
  365. pr_debug("clockdomain: %s does not support forcing "
  366. "wakeup via software\n", clkdm->name);
  367. return -EINVAL;
  368. }
  369. pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name);
  370. if (cpu_is_omap24xx()) {
  371. cm_clear_mod_reg_bits(OMAP24XX_FORCESTATE,
  372. clkdm->pwrdm.ptr->prcm_offs, PM_PWSTCTRL);
  373. } else if (cpu_is_omap34xx()) {
  374. u32 v = (OMAP34XX_CLKSTCTRL_FORCE_WAKEUP <<
  375. __ffs(clkdm->clktrctrl_mask));
  376. cm_rmw_mod_reg_bits(clkdm->clktrctrl_mask, v,
  377. clkdm->pwrdm.ptr->prcm_offs, CM_CLKSTCTRL);
  378. } else {
  379. BUG();
  380. };
  381. return 0;
  382. }
  383. /**
  384. * omap2_clkdm_allow_idle - enable hwsup idle transitions for clkdm
  385. * @clkdm: struct clockdomain *
  386. *
  387. * Allow the hardware to automatically switch the clockdomain into
  388. * active or idle states, as needed by downstream clocks. If the
  389. * clockdomain has any downstream clocks enabled in the clock
  390. * framework, wkdep/sleepdep autodependencies are added; this is so
  391. * device drivers can read and write to the device. No return value.
  392. */
  393. void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
  394. {
  395. if (!clkdm)
  396. return;
  397. if (!(clkdm->flags & CLKDM_CAN_ENABLE_AUTO)) {
  398. pr_debug("clock: automatic idle transitions cannot be enabled "
  399. "on clockdomain %s\n", clkdm->name);
  400. return;
  401. }
  402. pr_debug("clockdomain: enabling automatic idle transitions for %s\n",
  403. clkdm->name);
  404. if (atomic_read(&clkdm->usecount) > 0)
  405. _clkdm_add_autodeps(clkdm);
  406. _omap2_clkdm_set_hwsup(clkdm, 1);
  407. pwrdm_clkdm_state_switch(clkdm);
  408. }
  409. /**
  410. * omap2_clkdm_deny_idle - disable hwsup idle transitions for clkdm
  411. * @clkdm: struct clockdomain *
  412. *
  413. * Prevent the hardware from automatically switching the clockdomain
  414. * into inactive or idle states. If the clockdomain has downstream
  415. * clocks enabled in the clock framework, wkdep/sleepdep
  416. * autodependencies are removed. No return value.
  417. */
  418. void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
  419. {
  420. if (!clkdm)
  421. return;
  422. if (!(clkdm->flags & CLKDM_CAN_DISABLE_AUTO)) {
  423. pr_debug("clockdomain: automatic idle transitions cannot be "
  424. "disabled on %s\n", clkdm->name);
  425. return;
  426. }
  427. pr_debug("clockdomain: disabling automatic idle transitions for %s\n",
  428. clkdm->name);
  429. _omap2_clkdm_set_hwsup(clkdm, 0);
  430. if (atomic_read(&clkdm->usecount) > 0)
  431. _clkdm_del_autodeps(clkdm);
  432. }
  433. /* Clockdomain-to-clock framework interface code */
  434. /**
  435. * omap2_clkdm_clk_enable - add an enabled downstream clock to this clkdm
  436. * @clkdm: struct clockdomain *
  437. * @clk: struct clk * of the enabled downstream clock
  438. *
  439. * Increment the usecount of this clockdomain 'clkdm' and ensure that
  440. * it is awake. Intended to be called by clk_enable() code. If the
  441. * clockdomain is in software-supervised idle mode, force the
  442. * clockdomain to wake. If the clockdomain is in hardware-supervised
  443. * idle mode, add clkdm-pwrdm autodependencies, to ensure that devices
  444. * in the clockdomain can be read from/written to by on-chip processors.
  445. * Returns -EINVAL if passed null pointers; returns 0 upon success or
  446. * if the clockdomain is in hwsup idle mode.
  447. */
  448. int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
  449. {
  450. int v;
  451. /*
  452. * XXX Rewrite this code to maintain a list of enabled
  453. * downstream clocks for debugging purposes?
  454. */
  455. if (!clkdm || !clk || !clkdm->clktrctrl_mask)
  456. return -EINVAL;
  457. if (atomic_inc_return(&clkdm->usecount) > 1)
  458. return 0;
  459. /* Clockdomain now has one enabled downstream clock */
  460. pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name,
  461. clk->name);
  462. v = omap2_clkdm_clktrctrl_read(clkdm);
  463. if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||
  464. (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO)) {
  465. /* Disable HW transitions when we are changing deps */
  466. _omap2_clkdm_set_hwsup(clkdm, 0);
  467. _clkdm_add_autodeps(clkdm);
  468. _omap2_clkdm_set_hwsup(clkdm, 1);
  469. } else {
  470. omap2_clkdm_wakeup(clkdm);
  471. }
  472. pwrdm_wait_transition(clkdm->pwrdm.ptr);
  473. pwrdm_clkdm_state_switch(clkdm);
  474. return 0;
  475. }
  476. /**
  477. * omap2_clkdm_clk_disable - remove an enabled downstream clock from this clkdm
  478. * @clkdm: struct clockdomain *
  479. * @clk: struct clk * of the disabled downstream clock
  480. *
  481. * Decrement the usecount of this clockdomain 'clkdm'. Intended to be
  482. * called by clk_disable() code. If the usecount goes to 0, put the
  483. * clockdomain to sleep (software-supervised mode) or remove the
  484. * clkdm-pwrdm autodependencies (hardware-supervised mode). Returns
  485. * -EINVAL if passed null pointers; -ERANGE if the clkdm usecount
  486. * underflows and debugging is enabled; or returns 0 upon success or
  487. * if the clockdomain is in hwsup idle mode.
  488. */
  489. int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
  490. {
  491. int v;
  492. /*
  493. * XXX Rewrite this code to maintain a list of enabled
  494. * downstream clocks for debugging purposes?
  495. */
  496. if (!clkdm || !clk || !clkdm->clktrctrl_mask)
  497. return -EINVAL;
  498. #ifdef DEBUG
  499. if (atomic_read(&clkdm->usecount) == 0) {
  500. WARN_ON(1); /* underflow */
  501. return -ERANGE;
  502. }
  503. #endif
  504. if (atomic_dec_return(&clkdm->usecount) > 0)
  505. return 0;
  506. /* All downstream clocks of this clockdomain are now disabled */
  507. pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name,
  508. clk->name);
  509. v = omap2_clkdm_clktrctrl_read(clkdm);
  510. if ((cpu_is_omap34xx() && v == OMAP34XX_CLKSTCTRL_ENABLE_AUTO) ||
  511. (cpu_is_omap24xx() && v == OMAP24XX_CLKSTCTRL_ENABLE_AUTO)) {
  512. /* Disable HW transitions when we are changing deps */
  513. _omap2_clkdm_set_hwsup(clkdm, 0);
  514. _clkdm_del_autodeps(clkdm);
  515. _omap2_clkdm_set_hwsup(clkdm, 1);
  516. } else {
  517. omap2_clkdm_sleep(clkdm);
  518. }
  519. pwrdm_clkdm_state_switch(clkdm);
  520. return 0;
  521. }