clock.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. /*
  2. * Clock and PLL control for DaVinci devices
  3. *
  4. * Copyright (C) 2006-2007 Texas Instruments.
  5. * Copyright (C) 2008-2009 Deep Root Systems, LLC
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #include <linux/module.h>
  13. #include <linux/kernel.h>
  14. #include <linux/init.h>
  15. #include <linux/errno.h>
  16. #include <linux/clk.h>
  17. #include <linux/err.h>
  18. #include <linux/mutex.h>
  19. #include <linux/io.h>
  20. #include <linux/delay.h>
  21. #include <mach/hardware.h>
  22. #include <mach/clock.h>
  23. #include "psc.h"
  24. #include <mach/cputype.h>
  25. #include "clock.h"
  26. static LIST_HEAD(clocks);
  27. static DEFINE_MUTEX(clocks_mutex);
  28. static DEFINE_SPINLOCK(clockfw_lock);
  29. static void __clk_enable(struct clk *clk)
  30. {
  31. if (clk->parent)
  32. __clk_enable(clk->parent);
  33. if (clk->usecount++ == 0) {
  34. if (clk->flags & CLK_PSC)
  35. davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
  36. true, clk->flags);
  37. else if (clk->clk_enable)
  38. clk->clk_enable(clk);
  39. }
  40. }
  41. static void __clk_disable(struct clk *clk)
  42. {
  43. if (WARN_ON(clk->usecount == 0))
  44. return;
  45. if (--clk->usecount == 0) {
  46. if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC))
  47. davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc,
  48. false, clk->flags);
  49. else if (clk->clk_disable)
  50. clk->clk_disable(clk);
  51. }
  52. if (clk->parent)
  53. __clk_disable(clk->parent);
  54. }
  55. int davinci_clk_reset(struct clk *clk, bool reset)
  56. {
  57. unsigned long flags;
  58. if (clk == NULL || IS_ERR(clk))
  59. return -EINVAL;
  60. spin_lock_irqsave(&clockfw_lock, flags);
  61. if (clk->flags & CLK_PSC)
  62. davinci_psc_reset(clk->gpsc, clk->lpsc, reset);
  63. spin_unlock_irqrestore(&clockfw_lock, flags);
  64. return 0;
  65. }
  66. EXPORT_SYMBOL(davinci_clk_reset);
  67. int davinci_clk_reset_assert(struct clk *clk)
  68. {
  69. if (clk == NULL || IS_ERR(clk) || !clk->reset)
  70. return -EINVAL;
  71. return clk->reset(clk, true);
  72. }
  73. EXPORT_SYMBOL(davinci_clk_reset_assert);
  74. int davinci_clk_reset_deassert(struct clk *clk)
  75. {
  76. if (clk == NULL || IS_ERR(clk) || !clk->reset)
  77. return -EINVAL;
  78. return clk->reset(clk, false);
  79. }
  80. EXPORT_SYMBOL(davinci_clk_reset_deassert);
  81. int clk_enable(struct clk *clk)
  82. {
  83. unsigned long flags;
  84. if (!clk)
  85. return 0;
  86. else if (IS_ERR(clk))
  87. return -EINVAL;
  88. spin_lock_irqsave(&clockfw_lock, flags);
  89. __clk_enable(clk);
  90. spin_unlock_irqrestore(&clockfw_lock, flags);
  91. return 0;
  92. }
  93. EXPORT_SYMBOL(clk_enable);
  94. void clk_disable(struct clk *clk)
  95. {
  96. unsigned long flags;
  97. if (clk == NULL || IS_ERR(clk))
  98. return;
  99. spin_lock_irqsave(&clockfw_lock, flags);
  100. __clk_disable(clk);
  101. spin_unlock_irqrestore(&clockfw_lock, flags);
  102. }
  103. EXPORT_SYMBOL(clk_disable);
  104. unsigned long clk_get_rate(struct clk *clk)
  105. {
  106. if (clk == NULL || IS_ERR(clk))
  107. return 0;
  108. return clk->rate;
  109. }
  110. EXPORT_SYMBOL(clk_get_rate);
  111. long clk_round_rate(struct clk *clk, unsigned long rate)
  112. {
  113. if (clk == NULL || IS_ERR(clk))
  114. return 0;
  115. if (clk->round_rate)
  116. return clk->round_rate(clk, rate);
  117. return clk->rate;
  118. }
  119. EXPORT_SYMBOL(clk_round_rate);
  120. /* Propagate rate to children */
  121. static void propagate_rate(struct clk *root)
  122. {
  123. struct clk *clk;
  124. list_for_each_entry(clk, &root->children, childnode) {
  125. if (clk->recalc)
  126. clk->rate = clk->recalc(clk);
  127. propagate_rate(clk);
  128. }
  129. }
  130. int clk_set_rate(struct clk *clk, unsigned long rate)
  131. {
  132. unsigned long flags;
  133. int ret = -EINVAL;
  134. if (!clk)
  135. return 0;
  136. else if (IS_ERR(clk))
  137. return -EINVAL;
  138. if (clk->set_rate)
  139. ret = clk->set_rate(clk, rate);
  140. spin_lock_irqsave(&clockfw_lock, flags);
  141. if (ret == 0) {
  142. if (clk->recalc)
  143. clk->rate = clk->recalc(clk);
  144. propagate_rate(clk);
  145. }
  146. spin_unlock_irqrestore(&clockfw_lock, flags);
  147. return ret;
  148. }
  149. EXPORT_SYMBOL(clk_set_rate);
  150. int clk_set_parent(struct clk *clk, struct clk *parent)
  151. {
  152. unsigned long flags;
  153. if (!clk)
  154. return 0;
  155. else if (IS_ERR(clk))
  156. return -EINVAL;
  157. /* Cannot change parent on enabled clock */
  158. if (WARN_ON(clk->usecount))
  159. return -EINVAL;
  160. mutex_lock(&clocks_mutex);
  161. if (clk->set_parent) {
  162. int ret = clk->set_parent(clk, parent);
  163. if (ret) {
  164. mutex_unlock(&clocks_mutex);
  165. return ret;
  166. }
  167. }
  168. clk->parent = parent;
  169. list_del_init(&clk->childnode);
  170. list_add(&clk->childnode, &clk->parent->children);
  171. mutex_unlock(&clocks_mutex);
  172. spin_lock_irqsave(&clockfw_lock, flags);
  173. if (clk->recalc)
  174. clk->rate = clk->recalc(clk);
  175. propagate_rate(clk);
  176. spin_unlock_irqrestore(&clockfw_lock, flags);
  177. return 0;
  178. }
  179. EXPORT_SYMBOL(clk_set_parent);
  180. int clk_register(struct clk *clk)
  181. {
  182. if (clk == NULL || IS_ERR(clk))
  183. return -EINVAL;
  184. if (WARN(clk->parent && !clk->parent->rate,
  185. "CLK: %s parent %s has no rate!\n",
  186. clk->name, clk->parent->name))
  187. return -EINVAL;
  188. INIT_LIST_HEAD(&clk->children);
  189. mutex_lock(&clocks_mutex);
  190. list_add_tail(&clk->node, &clocks);
  191. if (clk->parent) {
  192. if (clk->set_parent) {
  193. int ret = clk->set_parent(clk, clk->parent);
  194. if (ret) {
  195. mutex_unlock(&clocks_mutex);
  196. return ret;
  197. }
  198. }
  199. list_add_tail(&clk->childnode, &clk->parent->children);
  200. }
  201. mutex_unlock(&clocks_mutex);
  202. /* If rate is already set, use it */
  203. if (clk->rate)
  204. return 0;
  205. /* Else, see if there is a way to calculate it */
  206. if (clk->recalc)
  207. clk->rate = clk->recalc(clk);
  208. /* Otherwise, default to parent rate */
  209. else if (clk->parent)
  210. clk->rate = clk->parent->rate;
  211. return 0;
  212. }
  213. EXPORT_SYMBOL(clk_register);
  214. void clk_unregister(struct clk *clk)
  215. {
  216. if (clk == NULL || IS_ERR(clk))
  217. return;
  218. mutex_lock(&clocks_mutex);
  219. list_del(&clk->node);
  220. list_del(&clk->childnode);
  221. mutex_unlock(&clocks_mutex);
  222. }
  223. EXPORT_SYMBOL(clk_unregister);
  224. #ifdef CONFIG_DAVINCI_RESET_CLOCKS
  225. /*
  226. * Disable any unused clocks left on by the bootloader
  227. */
  228. int __init davinci_clk_disable_unused(void)
  229. {
  230. struct clk *ck;
  231. spin_lock_irq(&clockfw_lock);
  232. list_for_each_entry(ck, &clocks, node) {
  233. if (ck->usecount > 0)
  234. continue;
  235. if (!(ck->flags & CLK_PSC))
  236. continue;
  237. /* ignore if in Disabled or SwRstDisable states */
  238. if (!davinci_psc_is_clk_active(ck->gpsc, ck->lpsc))
  239. continue;
  240. pr_debug("Clocks: disable unused %s\n", ck->name);
  241. davinci_psc_config(ck->domain, ck->gpsc, ck->lpsc,
  242. false, ck->flags);
  243. }
  244. spin_unlock_irq(&clockfw_lock);
  245. return 0;
  246. }
  247. #endif
  248. static unsigned long clk_sysclk_recalc(struct clk *clk)
  249. {
  250. u32 v, plldiv;
  251. struct pll_data *pll;
  252. unsigned long rate = clk->rate;
  253. /* If this is the PLL base clock, no more calculations needed */
  254. if (clk->pll_data)
  255. return rate;
  256. if (WARN_ON(!clk->parent))
  257. return rate;
  258. rate = clk->parent->rate;
  259. /* Otherwise, the parent must be a PLL */
  260. if (WARN_ON(!clk->parent->pll_data))
  261. return rate;
  262. pll = clk->parent->pll_data;
  263. /* If pre-PLL, source clock is before the multiplier and divider(s) */
  264. if (clk->flags & PRE_PLL)
  265. rate = pll->input_rate;
  266. if (!clk->div_reg)
  267. return rate;
  268. v = __raw_readl(pll->base + clk->div_reg);
  269. if (v & PLLDIV_EN) {
  270. plldiv = (v & pll->div_ratio_mask) + 1;
  271. if (plldiv)
  272. rate /= plldiv;
  273. }
  274. return rate;
  275. }
  276. int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate)
  277. {
  278. unsigned v;
  279. struct pll_data *pll;
  280. unsigned long input;
  281. unsigned ratio = 0;
  282. /* If this is the PLL base clock, wrong function to call */
  283. if (clk->pll_data)
  284. return -EINVAL;
  285. /* There must be a parent... */
  286. if (WARN_ON(!clk->parent))
  287. return -EINVAL;
  288. /* ... the parent must be a PLL... */
  289. if (WARN_ON(!clk->parent->pll_data))
  290. return -EINVAL;
  291. /* ... and this clock must have a divider. */
  292. if (WARN_ON(!clk->div_reg))
  293. return -EINVAL;
  294. pll = clk->parent->pll_data;
  295. input = clk->parent->rate;
  296. /* If pre-PLL, source clock is before the multiplier and divider(s) */
  297. if (clk->flags & PRE_PLL)
  298. input = pll->input_rate;
  299. if (input > rate) {
  300. /*
  301. * Can afford to provide an output little higher than requested
  302. * only if maximum rate supported by hardware on this sysclk
  303. * is known.
  304. */
  305. if (clk->maxrate) {
  306. ratio = DIV_ROUND_CLOSEST(input, rate);
  307. if (input / ratio > clk->maxrate)
  308. ratio = 0;
  309. }
  310. if (ratio == 0)
  311. ratio = DIV_ROUND_UP(input, rate);
  312. ratio--;
  313. }
  314. if (ratio > pll->div_ratio_mask)
  315. return -EINVAL;
  316. do {
  317. v = __raw_readl(pll->base + PLLSTAT);
  318. } while (v & PLLSTAT_GOSTAT);
  319. v = __raw_readl(pll->base + clk->div_reg);
  320. v &= ~pll->div_ratio_mask;
  321. v |= ratio | PLLDIV_EN;
  322. __raw_writel(v, pll->base + clk->div_reg);
  323. v = __raw_readl(pll->base + PLLCMD);
  324. v |= PLLCMD_GOSET;
  325. __raw_writel(v, pll->base + PLLCMD);
  326. do {
  327. v = __raw_readl(pll->base + PLLSTAT);
  328. } while (v & PLLSTAT_GOSTAT);
  329. return 0;
  330. }
  331. EXPORT_SYMBOL(davinci_set_sysclk_rate);
  332. static unsigned long clk_leafclk_recalc(struct clk *clk)
  333. {
  334. if (WARN_ON(!clk->parent))
  335. return clk->rate;
  336. return clk->parent->rate;
  337. }
  338. int davinci_simple_set_rate(struct clk *clk, unsigned long rate)
  339. {
  340. clk->rate = rate;
  341. return 0;
  342. }
  343. static unsigned long clk_pllclk_recalc(struct clk *clk)
  344. {
  345. u32 ctrl, mult = 1, prediv = 1, postdiv = 1;
  346. u8 bypass;
  347. struct pll_data *pll = clk->pll_data;
  348. unsigned long rate = clk->rate;
  349. ctrl = __raw_readl(pll->base + PLLCTL);
  350. rate = pll->input_rate = clk->parent->rate;
  351. if (ctrl & PLLCTL_PLLEN) {
  352. bypass = 0;
  353. mult = __raw_readl(pll->base + PLLM);
  354. if (cpu_is_davinci_dm365())
  355. mult = 2 * (mult & PLLM_PLLM_MASK);
  356. else
  357. mult = (mult & PLLM_PLLM_MASK) + 1;
  358. } else
  359. bypass = 1;
  360. if (pll->flags & PLL_HAS_PREDIV) {
  361. prediv = __raw_readl(pll->base + PREDIV);
  362. if (prediv & PLLDIV_EN)
  363. prediv = (prediv & pll->div_ratio_mask) + 1;
  364. else
  365. prediv = 1;
  366. }
  367. /* pre-divider is fixed, but (some?) chips won't report that */
  368. if (cpu_is_davinci_dm355() && pll->num == 1)
  369. prediv = 8;
  370. if (pll->flags & PLL_HAS_POSTDIV) {
  371. postdiv = __raw_readl(pll->base + POSTDIV);
  372. if (postdiv & PLLDIV_EN)
  373. postdiv = (postdiv & pll->div_ratio_mask) + 1;
  374. else
  375. postdiv = 1;
  376. }
  377. if (!bypass) {
  378. rate /= prediv;
  379. rate *= mult;
  380. rate /= postdiv;
  381. }
  382. pr_debug("PLL%d: input = %lu MHz [ ",
  383. pll->num, clk->parent->rate / 1000000);
  384. if (bypass)
  385. pr_debug("bypass ");
  386. if (prediv > 1)
  387. pr_debug("/ %d ", prediv);
  388. if (mult > 1)
  389. pr_debug("* %d ", mult);
  390. if (postdiv > 1)
  391. pr_debug("/ %d ", postdiv);
  392. pr_debug("] --> %lu MHz output.\n", rate / 1000000);
  393. return rate;
  394. }
  395. /**
  396. * davinci_set_pllrate - set the output rate of a given PLL.
  397. *
  398. * Note: Currently tested to work with OMAP-L138 only.
  399. *
  400. * @pll: pll whose rate needs to be changed.
  401. * @prediv: The pre divider value. Passing 0 disables the pre-divider.
  402. * @pllm: The multiplier value. Passing 0 leads to multiply-by-one.
  403. * @postdiv: The post divider value. Passing 0 disables the post-divider.
  404. */
  405. int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,
  406. unsigned int mult, unsigned int postdiv)
  407. {
  408. u32 ctrl;
  409. unsigned int locktime;
  410. unsigned long flags;
  411. if (pll->base == NULL)
  412. return -EINVAL;
  413. /*
  414. * PLL lock time required per OMAP-L138 datasheet is
  415. * (2000 * prediv)/sqrt(pllm) OSCIN cycles. We approximate sqrt(pllm)
  416. * as 4 and OSCIN cycle as 25 MHz.
  417. */
  418. if (prediv) {
  419. locktime = ((2000 * prediv) / 100);
  420. prediv = (prediv - 1) | PLLDIV_EN;
  421. } else {
  422. locktime = PLL_LOCK_TIME;
  423. }
  424. if (postdiv)
  425. postdiv = (postdiv - 1) | PLLDIV_EN;
  426. if (mult)
  427. mult = mult - 1;
  428. /* Protect against simultaneous calls to PLL setting seqeunce */
  429. spin_lock_irqsave(&clockfw_lock, flags);
  430. ctrl = __raw_readl(pll->base + PLLCTL);
  431. /* Switch the PLL to bypass mode */
  432. ctrl &= ~(PLLCTL_PLLENSRC | PLLCTL_PLLEN);
  433. __raw_writel(ctrl, pll->base + PLLCTL);
  434. udelay(PLL_BYPASS_TIME);
  435. /* Reset and enable PLL */
  436. ctrl &= ~(PLLCTL_PLLRST | PLLCTL_PLLDIS);
  437. __raw_writel(ctrl, pll->base + PLLCTL);
  438. if (pll->flags & PLL_HAS_PREDIV)
  439. __raw_writel(prediv, pll->base + PREDIV);
  440. __raw_writel(mult, pll->base + PLLM);
  441. if (pll->flags & PLL_HAS_POSTDIV)
  442. __raw_writel(postdiv, pll->base + POSTDIV);
  443. udelay(PLL_RESET_TIME);
  444. /* Bring PLL out of reset */
  445. ctrl |= PLLCTL_PLLRST;
  446. __raw_writel(ctrl, pll->base + PLLCTL);
  447. udelay(locktime);
  448. /* Remove PLL from bypass mode */
  449. ctrl |= PLLCTL_PLLEN;
  450. __raw_writel(ctrl, pll->base + PLLCTL);
  451. spin_unlock_irqrestore(&clockfw_lock, flags);
  452. return 0;
  453. }
  454. EXPORT_SYMBOL(davinci_set_pllrate);
  455. /**
  456. * davinci_set_refclk_rate() - Set the reference clock rate
  457. * @rate: The new rate.
  458. *
  459. * Sets the reference clock rate to a given value. This will most likely
  460. * result in the entire clock tree getting updated.
  461. *
  462. * This is used to support boards which use a reference clock different
  463. * than that used by default in <soc>.c file. The reference clock rate
  464. * should be updated early in the boot process; ideally soon after the
  465. * clock tree has been initialized once with the default reference clock
  466. * rate (davinci_clk_init()).
  467. *
  468. * Returns 0 on success, error otherwise.
  469. */
  470. int davinci_set_refclk_rate(unsigned long rate)
  471. {
  472. struct clk *refclk;
  473. refclk = clk_get(NULL, "ref");
  474. if (IS_ERR(refclk)) {
  475. pr_err("%s: failed to get reference clock\n", __func__);
  476. return PTR_ERR(refclk);
  477. }
  478. clk_set_rate(refclk, rate);
  479. clk_put(refclk);
  480. return 0;
  481. }
  482. int __init davinci_clk_init(struct clk_lookup *clocks)
  483. {
  484. struct clk_lookup *c;
  485. struct clk *clk;
  486. size_t num_clocks = 0;
  487. for (c = clocks; c->clk; c++) {
  488. clk = c->clk;
  489. if (!clk->recalc) {
  490. /* Check if clock is a PLL */
  491. if (clk->pll_data)
  492. clk->recalc = clk_pllclk_recalc;
  493. /* Else, if it is a PLL-derived clock */
  494. else if (clk->flags & CLK_PLL)
  495. clk->recalc = clk_sysclk_recalc;
  496. /* Otherwise, it is a leaf clock (PSC clock) */
  497. else if (clk->parent)
  498. clk->recalc = clk_leafclk_recalc;
  499. }
  500. if (clk->pll_data) {
  501. struct pll_data *pll = clk->pll_data;
  502. if (!pll->div_ratio_mask)
  503. pll->div_ratio_mask = PLLDIV_RATIO_MASK;
  504. if (pll->phys_base && !pll->base) {
  505. pll->base = ioremap(pll->phys_base, SZ_4K);
  506. WARN_ON(!pll->base);
  507. }
  508. }
  509. if (clk->recalc)
  510. clk->rate = clk->recalc(clk);
  511. if (clk->lpsc)
  512. clk->flags |= CLK_PSC;
  513. if (clk->flags & PSC_LRST)
  514. clk->reset = davinci_clk_reset;
  515. clk_register(clk);
  516. num_clocks++;
  517. /* Turn on clocks that Linux doesn't otherwise manage */
  518. if (clk->flags & ALWAYS_ENABLED)
  519. clk_enable(clk);
  520. }
  521. clkdev_add_table(clocks, num_clocks);
  522. return 0;
  523. }
  524. #ifdef CONFIG_DEBUG_FS
  525. #include <linux/debugfs.h>
  526. #include <linux/seq_file.h>
  527. #define CLKNAME_MAX 10 /* longest clock name */
  528. #define NEST_DELTA 2
  529. #define NEST_MAX 4
  530. static void
  531. dump_clock(struct seq_file *s, unsigned nest, struct clk *parent)
  532. {
  533. char *state;
  534. char buf[CLKNAME_MAX + NEST_DELTA * NEST_MAX];
  535. struct clk *clk;
  536. unsigned i;
  537. if (parent->flags & CLK_PLL)
  538. state = "pll";
  539. else if (parent->flags & CLK_PSC)
  540. state = "psc";
  541. else
  542. state = "";
  543. /* <nest spaces> name <pad to end> */
  544. memset(buf, ' ', sizeof(buf) - 1);
  545. buf[sizeof(buf) - 1] = 0;
  546. i = strlen(parent->name);
  547. memcpy(buf + nest, parent->name,
  548. min(i, (unsigned)(sizeof(buf) - 1 - nest)));
  549. seq_printf(s, "%s users=%2d %-3s %9ld Hz\n",
  550. buf, parent->usecount, state, clk_get_rate(parent));
  551. /* REVISIT show device associations too */
  552. /* cost is now small, but not linear... */
  553. list_for_each_entry(clk, &parent->children, childnode) {
  554. dump_clock(s, nest + NEST_DELTA, clk);
  555. }
  556. }
  557. static int davinci_ck_show(struct seq_file *m, void *v)
  558. {
  559. struct clk *clk;
  560. /*
  561. * Show clock tree; We trust nonzero usecounts equate to PSC enables...
  562. */
  563. mutex_lock(&clocks_mutex);
  564. list_for_each_entry(clk, &clocks, node)
  565. if (!clk->parent)
  566. dump_clock(m, 0, clk);
  567. mutex_unlock(&clocks_mutex);
  568. return 0;
  569. }
  570. static int davinci_ck_open(struct inode *inode, struct file *file)
  571. {
  572. return single_open(file, davinci_ck_show, NULL);
  573. }
  574. static const struct file_operations davinci_ck_operations = {
  575. .open = davinci_ck_open,
  576. .read = seq_read,
  577. .llseek = seq_lseek,
  578. .release = single_release,
  579. };
  580. static int __init davinci_clk_debugfs_init(void)
  581. {
  582. debugfs_create_file("davinci_clocks", S_IFREG | S_IRUGO, NULL, NULL,
  583. &davinci_ck_operations);
  584. return 0;
  585. }
  586. device_initcall(davinci_clk_debugfs_init);
  587. #endif /* CONFIG_DEBUG_FS */