dpll3xxx.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * OMAP3/4 - specific DPLL control functions
  3. *
  4. * Copyright (C) 2009-2010 Texas Instruments, Inc.
  5. * Copyright (C) 2009-2010 Nokia Corporation
  6. *
  7. * Written by Paul Walmsley
  8. * Testing and integration fixes by Jouni Högander
  9. *
  10. * 36xx support added by Vishwanath BS, Richard Woodruff, and Nishanth
  11. * Menon
  12. *
  13. * Parts of this code are based on code written by
  14. * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu
  15. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License version 2 as
  18. * published by the Free Software Foundation.
  19. */
  20. #include <linux/kernel.h>
  21. #include <linux/device.h>
  22. #include <linux/list.h>
  23. #include <linux/errno.h>
  24. #include <linux/delay.h>
  25. #include <linux/clk.h>
  26. #include <linux/io.h>
  27. #include <linux/bitops.h>
  28. #include <linux/clkdev.h>
  29. #include "soc.h"
  30. #include "clock.h"
  31. #include "cm2xxx_3xxx.h"
  32. #include "cm-regbits-34xx.h"
  33. /* CM_AUTOIDLE_PLL*.AUTO_* bit values */
  34. #define DPLL_AUTOIDLE_DISABLE 0x0
  35. #define DPLL_AUTOIDLE_LOW_POWER_STOP 0x1
  36. #define MAX_DPLL_WAIT_TRIES 1000000
  37. /* Private functions */
  38. /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
  39. static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
  40. {
  41. const struct dpll_data *dd;
  42. u32 v;
  43. dd = clk->dpll_data;
  44. v = __raw_readl(dd->control_reg);
  45. v &= ~dd->enable_mask;
  46. v |= clken_bits << __ffs(dd->enable_mask);
  47. __raw_writel(v, dd->control_reg);
  48. }
  49. /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
  50. static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
  51. {
  52. const struct dpll_data *dd;
  53. int i = 0;
  54. int ret = -EINVAL;
  55. const char *clk_name;
  56. dd = clk->dpll_data;
  57. clk_name = __clk_get_name(clk);
  58. state <<= __ffs(dd->idlest_mask);
  59. while (((__raw_readl(dd->idlest_reg) & dd->idlest_mask) != state) &&
  60. i < MAX_DPLL_WAIT_TRIES) {
  61. i++;
  62. udelay(1);
  63. }
  64. if (i == MAX_DPLL_WAIT_TRIES) {
  65. printk(KERN_ERR "clock: %s failed transition to '%s'\n",
  66. clk_name, (state) ? "locked" : "bypassed");
  67. } else {
  68. pr_debug("clock: %s transition to '%s' in %d loops\n",
  69. clk_name, (state) ? "locked" : "bypassed", i);
  70. ret = 0;
  71. }
  72. return ret;
  73. }
  74. /* From 3430 TRM ES2 4.7.6.2 */
  75. static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
  76. {
  77. unsigned long fint;
  78. u16 f = 0;
  79. fint = __clk_get_rate(clk->dpll_data->clk_ref) / n;
  80. pr_debug("clock: fint is %lu\n", fint);
  81. if (fint >= 750000 && fint <= 1000000)
  82. f = 0x3;
  83. else if (fint > 1000000 && fint <= 1250000)
  84. f = 0x4;
  85. else if (fint > 1250000 && fint <= 1500000)
  86. f = 0x5;
  87. else if (fint > 1500000 && fint <= 1750000)
  88. f = 0x6;
  89. else if (fint > 1750000 && fint <= 2100000)
  90. f = 0x7;
  91. else if (fint > 7500000 && fint <= 10000000)
  92. f = 0xB;
  93. else if (fint > 10000000 && fint <= 12500000)
  94. f = 0xC;
  95. else if (fint > 12500000 && fint <= 15000000)
  96. f = 0xD;
  97. else if (fint > 15000000 && fint <= 17500000)
  98. f = 0xE;
  99. else if (fint > 17500000 && fint <= 21000000)
  100. f = 0xF;
  101. else
  102. pr_debug("clock: unknown freqsel setting for %d\n", n);
  103. return f;
  104. }
  105. /*
  106. * _omap3_noncore_dpll_lock - instruct a DPLL to lock and wait for readiness
  107. * @clk: pointer to a DPLL struct clk
  108. *
  109. * Instructs a non-CORE DPLL to lock. Waits for the DPLL to report
  110. * readiness before returning. Will save and restore the DPLL's
  111. * autoidle state across the enable, per the CDP code. If the DPLL
  112. * locked successfully, return 0; if the DPLL did not lock in the time
  113. * allotted, or DPLL3 was passed in, return -EINVAL.
  114. */
  115. static int _omap3_noncore_dpll_lock(struct clk *clk)
  116. {
  117. const struct dpll_data *dd;
  118. u8 ai;
  119. u8 state = 1;
  120. int r = 0;
  121. pr_debug("clock: locking DPLL %s\n", __clk_get_name(clk));
  122. dd = clk->dpll_data;
  123. state <<= __ffs(dd->idlest_mask);
  124. /* Check if already locked */
  125. if ((__raw_readl(dd->idlest_reg) & dd->idlest_mask) == state)
  126. goto done;
  127. ai = omap3_dpll_autoidle_read(clk);
  128. if (ai)
  129. omap3_dpll_deny_idle(clk);
  130. _omap3_dpll_write_clken(clk, DPLL_LOCKED);
  131. r = _omap3_wait_dpll_status(clk, 1);
  132. if (ai)
  133. omap3_dpll_allow_idle(clk);
  134. done:
  135. return r;
  136. }
  137. /*
  138. * _omap3_noncore_dpll_bypass - instruct a DPLL to bypass and wait for readiness
  139. * @clk: pointer to a DPLL struct clk
  140. *
  141. * Instructs a non-CORE DPLL to enter low-power bypass mode. In
  142. * bypass mode, the DPLL's rate is set equal to its parent clock's
  143. * rate. Waits for the DPLL to report readiness before returning.
  144. * Will save and restore the DPLL's autoidle state across the enable,
  145. * per the CDP code. If the DPLL entered bypass mode successfully,
  146. * return 0; if the DPLL did not enter bypass in the time allotted, or
  147. * DPLL3 was passed in, or the DPLL does not support low-power bypass,
  148. * return -EINVAL.
  149. */
  150. static int _omap3_noncore_dpll_bypass(struct clk *clk)
  151. {
  152. int r;
  153. u8 ai;
  154. if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS)))
  155. return -EINVAL;
  156. pr_debug("clock: configuring DPLL %s for low-power bypass\n",
  157. __clk_get_name(clk));
  158. ai = omap3_dpll_autoidle_read(clk);
  159. _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_BYPASS);
  160. r = _omap3_wait_dpll_status(clk, 0);
  161. if (ai)
  162. omap3_dpll_allow_idle(clk);
  163. return r;
  164. }
  165. /*
  166. * _omap3_noncore_dpll_stop - instruct a DPLL to stop
  167. * @clk: pointer to a DPLL struct clk
  168. *
  169. * Instructs a non-CORE DPLL to enter low-power stop. Will save and
  170. * restore the DPLL's autoidle state across the stop, per the CDP
  171. * code. If DPLL3 was passed in, or the DPLL does not support
  172. * low-power stop, return -EINVAL; otherwise, return 0.
  173. */
  174. static int _omap3_noncore_dpll_stop(struct clk *clk)
  175. {
  176. u8 ai;
  177. if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP)))
  178. return -EINVAL;
  179. pr_debug("clock: stopping DPLL %s\n", __clk_get_name(clk));
  180. ai = omap3_dpll_autoidle_read(clk);
  181. _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_STOP);
  182. if (ai)
  183. omap3_dpll_allow_idle(clk);
  184. return 0;
  185. }
  186. /**
  187. * _lookup_dco - Lookup DCO used by j-type DPLL
  188. * @clk: pointer to a DPLL struct clk
  189. * @dco: digital control oscillator selector
  190. * @m: DPLL multiplier to set
  191. * @n: DPLL divider to set
  192. *
  193. * See 36xx TRM section 3.5.3.3.3.2 "Type B DPLL (Low-Jitter)"
  194. *
  195. * XXX This code is not needed for 3430/AM35xx; can it be optimized
  196. * out in non-multi-OMAP builds for those chips?
  197. */
  198. static void _lookup_dco(struct clk *clk, u8 *dco, u16 m, u8 n)
  199. {
  200. unsigned long fint, clkinp; /* watch out for overflow */
  201. clkinp = __clk_get_rate(__clk_get_parent(clk));
  202. fint = (clkinp / n) * m;
  203. if (fint < 1000000000)
  204. *dco = 2;
  205. else
  206. *dco = 4;
  207. }
  208. /**
  209. * _lookup_sddiv - Calculate sigma delta divider for j-type DPLL
  210. * @clk: pointer to a DPLL struct clk
  211. * @sd_div: target sigma-delta divider
  212. * @m: DPLL multiplier to set
  213. * @n: DPLL divider to set
  214. *
  215. * See 36xx TRM section 3.5.3.3.3.2 "Type B DPLL (Low-Jitter)"
  216. *
  217. * XXX This code is not needed for 3430/AM35xx; can it be optimized
  218. * out in non-multi-OMAP builds for those chips?
  219. */
  220. static void _lookup_sddiv(struct clk *clk, u8 *sd_div, u16 m, u8 n)
  221. {
  222. unsigned long clkinp, sd; /* watch out for overflow */
  223. int mod1, mod2;
  224. clkinp = __clk_get_rate(__clk_get_parent(clk));
  225. /*
  226. * target sigma-delta to near 250MHz
  227. * sd = ceil[(m/(n+1)) * (clkinp_MHz / 250)]
  228. */
  229. clkinp /= 100000; /* shift from MHz to 10*Hz for 38.4 and 19.2 */
  230. mod1 = (clkinp * m) % (250 * n);
  231. sd = (clkinp * m) / (250 * n);
  232. mod2 = sd % 10;
  233. sd /= 10;
  234. if (mod1 || mod2)
  235. sd++;
  236. *sd_div = sd;
  237. }
  238. /*
  239. * _omap3_noncore_dpll_program - set non-core DPLL M,N values directly
  240. * @clk: struct clk * of DPLL to set
  241. * @m: DPLL multiplier to set
  242. * @n: DPLL divider to set
  243. * @freqsel: FREQSEL value to set
  244. *
  245. * Program the DPLL with the supplied M, N values, and wait for the DPLL to
  246. * lock.. Returns -EINVAL upon error, or 0 upon success.
  247. */
  248. static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
  249. {
  250. struct dpll_data *dd = clk->dpll_data;
  251. u8 dco, sd_div;
  252. u32 v;
  253. /* 3430 ES2 TRM: 4.7.6.9 DPLL Programming Sequence */
  254. _omap3_noncore_dpll_bypass(clk);
  255. /*
  256. * Set jitter correction. No jitter correction for OMAP4 and 3630
  257. * since freqsel field is no longer present
  258. */
  259. if (!soc_is_am33xx() && !cpu_is_omap44xx() && !cpu_is_omap3630()) {
  260. v = __raw_readl(dd->control_reg);
  261. v &= ~dd->freqsel_mask;
  262. v |= freqsel << __ffs(dd->freqsel_mask);
  263. __raw_writel(v, dd->control_reg);
  264. }
  265. /* Set DPLL multiplier, divider */
  266. v = __raw_readl(dd->mult_div1_reg);
  267. v &= ~(dd->mult_mask | dd->div1_mask);
  268. v |= m << __ffs(dd->mult_mask);
  269. v |= (n - 1) << __ffs(dd->div1_mask);
  270. /* Configure dco and sd_div for dplls that have these fields */
  271. if (dd->dco_mask) {
  272. _lookup_dco(clk, &dco, m, n);
  273. v &= ~(dd->dco_mask);
  274. v |= dco << __ffs(dd->dco_mask);
  275. }
  276. if (dd->sddiv_mask) {
  277. _lookup_sddiv(clk, &sd_div, m, n);
  278. v &= ~(dd->sddiv_mask);
  279. v |= sd_div << __ffs(dd->sddiv_mask);
  280. }
  281. __raw_writel(v, dd->mult_div1_reg);
  282. /* We let the clock framework set the other output dividers later */
  283. /* REVISIT: Set ramp-up delay? */
  284. _omap3_noncore_dpll_lock(clk);
  285. return 0;
  286. }
  287. /* Public functions */
  288. /**
  289. * omap3_dpll_recalc - recalculate DPLL rate
  290. * @clk: DPLL struct clk
  291. *
  292. * Recalculate and propagate the DPLL rate.
  293. */
  294. unsigned long omap3_dpll_recalc(struct clk *clk)
  295. {
  296. return omap2_get_dpll_rate(clk);
  297. }
  298. /* Non-CORE DPLL (e.g., DPLLs that do not control SDRC) clock functions */
  299. /**
  300. * omap3_noncore_dpll_enable - instruct a DPLL to enter bypass or lock mode
  301. * @clk: pointer to a DPLL struct clk
  302. *
  303. * Instructs a non-CORE DPLL to enable, e.g., to enter bypass or lock.
  304. * The choice of modes depends on the DPLL's programmed rate: if it is
  305. * the same as the DPLL's parent clock, it will enter bypass;
  306. * otherwise, it will enter lock. This code will wait for the DPLL to
  307. * indicate readiness before returning, unless the DPLL takes too long
  308. * to enter the target state. Intended to be used as the struct clk's
  309. * enable function. If DPLL3 was passed in, or the DPLL does not
  310. * support low-power stop, or if the DPLL took too long to enter
  311. * bypass or lock, return -EINVAL; otherwise, return 0.
  312. */
  313. int omap3_noncore_dpll_enable(struct clk *clk)
  314. {
  315. int r;
  316. struct dpll_data *dd;
  317. struct clk *parent;
  318. dd = clk->dpll_data;
  319. if (!dd)
  320. return -EINVAL;
  321. parent = __clk_get_parent(clk);
  322. if (__clk_get_rate(clk) == __clk_get_rate(dd->clk_bypass)) {
  323. WARN_ON(parent != dd->clk_bypass);
  324. r = _omap3_noncore_dpll_bypass(clk);
  325. } else {
  326. WARN_ON(parent != dd->clk_ref);
  327. r = _omap3_noncore_dpll_lock(clk);
  328. }
  329. /*
  330. *FIXME: this is dubious - if clk->rate has changed, what about
  331. * propagating?
  332. */
  333. if (!r)
  334. clk->rate = (clk->recalc) ? clk->recalc(clk) :
  335. omap2_get_dpll_rate(clk);
  336. return r;
  337. }
  338. /**
  339. * omap3_noncore_dpll_disable - instruct a DPLL to enter low-power stop
  340. * @clk: pointer to a DPLL struct clk
  341. *
  342. * Instructs a non-CORE DPLL to enter low-power stop. This function is
  343. * intended for use in struct clkops. No return value.
  344. */
  345. void omap3_noncore_dpll_disable(struct clk *clk)
  346. {
  347. _omap3_noncore_dpll_stop(clk);
  348. }
  349. /* Non-CORE DPLL rate set code */
  350. /**
  351. * omap3_noncore_dpll_set_rate - set non-core DPLL rate
  352. * @clk: struct clk * of DPLL to set
  353. * @rate: rounded target rate
  354. *
  355. * Set the DPLL CLKOUT to the target rate. If the DPLL can enter
  356. * low-power bypass, and the target rate is the bypass source clock
  357. * rate, then configure the DPLL for bypass. Otherwise, round the
  358. * target rate if it hasn't been done already, then program and lock
  359. * the DPLL. Returns -EINVAL upon error, or 0 upon success.
  360. */
  361. int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
  362. {
  363. struct clk *new_parent = NULL;
  364. unsigned long hw_rate, bypass_rate;
  365. u16 freqsel = 0;
  366. struct dpll_data *dd;
  367. int ret;
  368. if (!clk || !rate)
  369. return -EINVAL;
  370. dd = clk->dpll_data;
  371. if (!dd)
  372. return -EINVAL;
  373. hw_rate = (clk->recalc) ? clk->recalc(clk) : omap2_get_dpll_rate(clk);
  374. if (rate == hw_rate)
  375. return 0;
  376. /*
  377. * Ensure both the bypass and ref clocks are enabled prior to
  378. * doing anything; we need the bypass clock running to reprogram
  379. * the DPLL.
  380. */
  381. omap2_clk_enable(dd->clk_bypass);
  382. omap2_clk_enable(dd->clk_ref);
  383. bypass_rate = __clk_get_rate(dd->clk_bypass);
  384. if (bypass_rate == rate &&
  385. (clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
  386. pr_debug("clock: %s: set rate: entering bypass.\n", clk->name);
  387. ret = _omap3_noncore_dpll_bypass(clk);
  388. if (!ret)
  389. new_parent = dd->clk_bypass;
  390. } else {
  391. if (dd->last_rounded_rate != rate)
  392. rate = clk->round_rate(clk, rate);
  393. if (dd->last_rounded_rate == 0)
  394. return -EINVAL;
  395. /* No freqsel on OMAP4 and OMAP3630 */
  396. if (!soc_is_am33xx() && !cpu_is_omap44xx() && !cpu_is_omap3630()) {
  397. freqsel = _omap3_dpll_compute_freqsel(clk,
  398. dd->last_rounded_n);
  399. if (!freqsel)
  400. WARN_ON(1);
  401. }
  402. pr_debug("clock: %s: set rate: locking rate to %lu.\n",
  403. __clk_get_name(clk), rate);
  404. ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m,
  405. dd->last_rounded_n, freqsel);
  406. if (!ret)
  407. new_parent = dd->clk_ref;
  408. }
  409. if (!ret) {
  410. /*
  411. * Switch the parent clock in the hierarchy, and make sure
  412. * that the new parent's usecount is correct. Note: we
  413. * enable the new parent before disabling the old to avoid
  414. * any unnecessary hardware disable->enable transitions.
  415. */
  416. if (clk->usecount) {
  417. omap2_clk_enable(new_parent);
  418. omap2_clk_disable(clk->parent);
  419. }
  420. clk_reparent(clk, new_parent);
  421. clk->rate = rate;
  422. }
  423. omap2_clk_disable(dd->clk_ref);
  424. omap2_clk_disable(dd->clk_bypass);
  425. return 0;
  426. }
  427. /* DPLL autoidle read/set code */
  428. /**
  429. * omap3_dpll_autoidle_read - read a DPLL's autoidle bits
  430. * @clk: struct clk * of the DPLL to read
  431. *
  432. * Return the DPLL's autoidle bits, shifted down to bit 0. Returns
  433. * -EINVAL if passed a null pointer or if the struct clk does not
  434. * appear to refer to a DPLL.
  435. */
  436. u32 omap3_dpll_autoidle_read(struct clk *clk)
  437. {
  438. const struct dpll_data *dd;
  439. u32 v;
  440. if (!clk || !clk->dpll_data)
  441. return -EINVAL;
  442. dd = clk->dpll_data;
  443. if (!dd->autoidle_reg)
  444. return -EINVAL;
  445. v = __raw_readl(dd->autoidle_reg);
  446. v &= dd->autoidle_mask;
  447. v >>= __ffs(dd->autoidle_mask);
  448. return v;
  449. }
  450. /**
  451. * omap3_dpll_allow_idle - enable DPLL autoidle bits
  452. * @clk: struct clk * of the DPLL to operate on
  453. *
  454. * Enable DPLL automatic idle control. This automatic idle mode
  455. * switching takes effect only when the DPLL is locked, at least on
  456. * OMAP3430. The DPLL will enter low-power stop when its downstream
  457. * clocks are gated. No return value.
  458. */
  459. void omap3_dpll_allow_idle(struct clk *clk)
  460. {
  461. const struct dpll_data *dd;
  462. u32 v;
  463. if (!clk || !clk->dpll_data)
  464. return;
  465. dd = clk->dpll_data;
  466. if (!dd->autoidle_reg) {
  467. pr_debug("clock: DPLL %s: autoidle not supported\n",
  468. __clk_get_name(clk));
  469. return;
  470. }
  471. /*
  472. * REVISIT: CORE DPLL can optionally enter low-power bypass
  473. * by writing 0x5 instead of 0x1. Add some mechanism to
  474. * optionally enter this mode.
  475. */
  476. v = __raw_readl(dd->autoidle_reg);
  477. v &= ~dd->autoidle_mask;
  478. v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
  479. __raw_writel(v, dd->autoidle_reg);
  480. }
  481. /**
  482. * omap3_dpll_deny_idle - prevent DPLL from automatically idling
  483. * @clk: struct clk * of the DPLL to operate on
  484. *
  485. * Disable DPLL automatic idle control. No return value.
  486. */
  487. void omap3_dpll_deny_idle(struct clk *clk)
  488. {
  489. const struct dpll_data *dd;
  490. u32 v;
  491. if (!clk || !clk->dpll_data)
  492. return;
  493. dd = clk->dpll_data;
  494. if (!dd->autoidle_reg) {
  495. pr_debug("clock: DPLL %s: autoidle not supported\n",
  496. __clk_get_name(clk));
  497. return;
  498. }
  499. v = __raw_readl(dd->autoidle_reg);
  500. v &= ~dd->autoidle_mask;
  501. v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask);
  502. __raw_writel(v, dd->autoidle_reg);
  503. }
  504. /* Clock control for DPLL outputs */
  505. /**
  506. * omap3_clkoutx2_recalc - recalculate DPLL X2 output virtual clock rate
  507. * @clk: DPLL output struct clk
  508. *
  509. * Using parent clock DPLL data, look up DPLL state. If locked, set our
  510. * rate to the dpll_clk * 2; otherwise, just use dpll_clk.
  511. */
  512. unsigned long omap3_clkoutx2_recalc(struct clk *clk)
  513. {
  514. const struct dpll_data *dd;
  515. unsigned long rate;
  516. u32 v;
  517. struct clk *pclk;
  518. unsigned long parent_rate;
  519. /* Walk up the parents of clk, looking for a DPLL */
  520. pclk = __clk_get_parent(clk);
  521. while (pclk && !pclk->dpll_data)
  522. pclk = __clk_get_parent(pclk);
  523. /* clk does not have a DPLL as a parent? error in the clock data */
  524. if (!pclk) {
  525. WARN_ON(1);
  526. return 0;
  527. }
  528. dd = pclk->dpll_data;
  529. WARN_ON(!dd->enable_mask);
  530. parent_rate = __clk_get_rate(__clk_get_parent(clk));
  531. v = __raw_readl(dd->control_reg) & dd->enable_mask;
  532. v >>= __ffs(dd->enable_mask);
  533. if ((v != OMAP3XXX_EN_DPLL_LOCKED) || (dd->flags & DPLL_J_TYPE))
  534. rate = parent_rate;
  535. else
  536. rate = parent_rate * 2;
  537. return rate;
  538. }
  539. /* OMAP3/4 non-CORE DPLL clkops */
  540. const struct clkops clkops_omap3_noncore_dpll_ops = {
  541. .enable = omap3_noncore_dpll_enable,
  542. .disable = omap3_noncore_dpll_disable,
  543. .allow_idle = omap3_dpll_allow_idle,
  544. .deny_idle = omap3_dpll_deny_idle,
  545. };
  546. const struct clkops clkops_omap3_core_dpll_ops = {
  547. .allow_idle = omap3_dpll_allow_idle,
  548. .deny_idle = omap3_dpll_deny_idle,
  549. };