clock.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353
  1. /*
  2. * linux/arch/arm/mach-omap2/clock.c
  3. *
  4. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2010 Nokia Corporation
  6. *
  7. * Contacts:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Paul Walmsley
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #undef DEBUG
  16. #include <linux/kernel.h>
  17. #include <linux/export.h>
  18. #include <linux/list.h>
  19. #include <linux/errno.h>
  20. #include <linux/err.h>
  21. #include <linux/delay.h>
  22. #ifdef CONFIG_COMMON_CLK
  23. #include <linux/clk-provider.h>
  24. #else
  25. #include <linux/clk.h>
  26. #endif
  27. #include <linux/io.h>
  28. #include <linux/bitops.h>
  29. #include <asm/cpu.h>
  30. #include <trace/events/power.h>
  31. #include "soc.h"
  32. #include "clockdomain.h"
  33. #include "clock.h"
  34. #include "cm.h"
  35. #include "cm2xxx.h"
  36. #include "cm3xxx.h"
  37. #include "cm-regbits-24xx.h"
  38. #include "cm-regbits-34xx.h"
  39. #include "common.h"
  40. /*
  41. * MAX_MODULE_ENABLE_WAIT: maximum of number of microseconds to wait
  42. * for a module to indicate that it is no longer in idle
  43. */
  44. #define MAX_MODULE_ENABLE_WAIT 100000
  45. u16 cpu_mask;
  46. /*
  47. * clkdm_control: if true, then when a clock is enabled in the
  48. * hardware, its clockdomain will first be enabled; and when a clock
  49. * is disabled in the hardware, its clockdomain will be disabled
  50. * afterwards.
  51. */
  52. static bool clkdm_control = true;
  53. static LIST_HEAD(clocks);
  54. static DEFINE_MUTEX(clocks_mutex);
  55. #ifndef CONFIG_COMMON_CLK
  56. static DEFINE_SPINLOCK(clockfw_lock);
  57. #endif
  58. #ifdef CONFIG_COMMON_CLK
  59. /*
  60. * Used for clocks that have the same value as the parent clock,
  61. * divided by some factor
  62. */
  63. unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw,
  64. unsigned long parent_rate)
  65. {
  66. struct clk_hw_omap *oclk;
  67. if (!hw) {
  68. pr_warn("%s: hw is NULL\n", __func__);
  69. return -EINVAL;
  70. }
  71. oclk = to_clk_hw_omap(hw);
  72. WARN_ON(!oclk->fixed_div);
  73. return parent_rate / oclk->fixed_div;
  74. }
  75. #endif
  76. /*
  77. * OMAP2+ specific clock functions
  78. */
  79. /* Private functions */
  80. /**
  81. * _wait_idlest_generic - wait for a module to leave the idle state
  82. * @reg: virtual address of module IDLEST register
  83. * @mask: value to mask against to determine if the module is active
  84. * @idlest: idle state indicator (0 or 1) for the clock
  85. * @name: name of the clock (for printk)
  86. *
  87. * Wait for a module to leave idle, where its idle-status register is
  88. * not inside the CM module. Returns 1 if the module left idle
  89. * promptly, or 0 if the module did not leave idle before the timeout
  90. * elapsed. XXX Deprecated - should be moved into drivers for the
  91. * individual IP block that the IDLEST register exists in.
  92. */
  93. static int _wait_idlest_generic(void __iomem *reg, u32 mask, u8 idlest,
  94. const char *name)
  95. {
  96. int i = 0, ena = 0;
  97. ena = (idlest) ? 0 : mask;
  98. omap_test_timeout(((__raw_readl(reg) & mask) == ena),
  99. MAX_MODULE_ENABLE_WAIT, i);
  100. if (i < MAX_MODULE_ENABLE_WAIT)
  101. pr_debug("omap clock: module associated with clock %s ready after %d loops\n",
  102. name, i);
  103. else
  104. pr_err("omap clock: module associated with clock %s didn't enable in %d tries\n",
  105. name, MAX_MODULE_ENABLE_WAIT);
  106. return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
  107. };
  108. /**
  109. * _omap2_module_wait_ready - wait for an OMAP module to leave IDLE
  110. * @clk: struct clk * belonging to the module
  111. *
  112. * If the necessary clocks for the OMAP hardware IP block that
  113. * corresponds to clock @clk are enabled, then wait for the module to
  114. * indicate readiness (i.e., to leave IDLE). This code does not
  115. * belong in the clock code and will be moved in the medium term to
  116. * module-dependent code. No return value.
  117. */
  118. #ifdef CONFIG_COMMON_CLK
  119. static void _omap2_module_wait_ready(struct clk_hw_omap *clk)
  120. #else
  121. static void _omap2_module_wait_ready(struct clk *clk)
  122. #endif
  123. {
  124. void __iomem *companion_reg, *idlest_reg;
  125. u8 other_bit, idlest_bit, idlest_val, idlest_reg_id;
  126. s16 prcm_mod;
  127. int r;
  128. /* Not all modules have multiple clocks that their IDLEST depends on */
  129. if (clk->ops->find_companion) {
  130. clk->ops->find_companion(clk, &companion_reg, &other_bit);
  131. if (!(__raw_readl(companion_reg) & (1 << other_bit)))
  132. return;
  133. }
  134. clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit, &idlest_val);
  135. r = cm_split_idlest_reg(idlest_reg, &prcm_mod, &idlest_reg_id);
  136. if (r) {
  137. /* IDLEST register not in the CM module */
  138. _wait_idlest_generic(idlest_reg, (1 << idlest_bit), idlest_val,
  139. #ifdef CONFIG_COMMON_CLK
  140. __clk_get_name(clk->hw.clk));
  141. #else
  142. clk->name);
  143. #endif
  144. } else {
  145. cm_wait_module_ready(prcm_mod, idlest_reg_id, idlest_bit);
  146. };
  147. }
  148. /* Public functions */
  149. /**
  150. * omap2_init_clk_clkdm - look up a clockdomain name, store pointer in clk
  151. * @clk: OMAP clock struct ptr to use
  152. *
  153. * Convert a clockdomain name stored in a struct clk 'clk' into a
  154. * clockdomain pointer, and save it into the struct clk. Intended to be
  155. * called during clk_register(). No return value.
  156. */
  157. #ifdef CONFIG_COMMON_CLK
  158. void omap2_init_clk_clkdm(struct clk_hw *hw)
  159. {
  160. struct clk_hw_omap *clk = to_clk_hw_omap(hw);
  161. #else
  162. void omap2_init_clk_clkdm(struct clk *clk)
  163. {
  164. #endif
  165. struct clockdomain *clkdm;
  166. const char *clk_name;
  167. if (!clk->clkdm_name)
  168. return;
  169. #ifdef CONFIG_COMMON_CLK
  170. clk_name = __clk_get_name(hw->clk);
  171. #else
  172. clk_name = __clk_get_name(clk);
  173. #endif
  174. clkdm = clkdm_lookup(clk->clkdm_name);
  175. if (clkdm) {
  176. pr_debug("clock: associated clk %s to clkdm %s\n",
  177. clk_name, clk->clkdm_name);
  178. clk->clkdm = clkdm;
  179. } else {
  180. pr_debug("clock: could not associate clk %s to clkdm %s\n",
  181. clk_name, clk->clkdm_name);
  182. }
  183. }
  184. /**
  185. * omap2_clk_disable_clkdm_control - disable clkdm control on clk enable/disable
  186. *
  187. * Prevent the OMAP clock code from calling into the clockdomain code
  188. * when a hardware clock in that clockdomain is enabled or disabled.
  189. * Intended to be called at init time from omap*_clk_init(). No
  190. * return value.
  191. */
  192. void __init omap2_clk_disable_clkdm_control(void)
  193. {
  194. clkdm_control = false;
  195. }
  196. /**
  197. * omap2_clk_dflt_find_companion - find companion clock to @clk
  198. * @clk: struct clk * to find the companion clock of
  199. * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
  200. * @other_bit: u8 ** to return the companion clock bit shift in
  201. *
  202. * Note: We don't need special code here for INVERT_ENABLE for the
  203. * time being since INVERT_ENABLE only applies to clocks enabled by
  204. * CM_CLKEN_PLL
  205. *
  206. * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes it's
  207. * just a matter of XORing the bits.
  208. *
  209. * Some clocks don't have companion clocks. For example, modules with
  210. * only an interface clock (such as MAILBOXES) don't have a companion
  211. * clock. Right now, this code relies on the hardware exporting a bit
  212. * in the correct companion register that indicates that the
  213. * nonexistent 'companion clock' is active. Future patches will
  214. * associate this type of code with per-module data structures to
  215. * avoid this issue, and remove the casts. No return value.
  216. */
  217. #ifdef CONFIG_COMMON_CLK
  218. void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
  219. #else
  220. void omap2_clk_dflt_find_companion(struct clk *clk,
  221. #endif
  222. void __iomem **other_reg, u8 *other_bit)
  223. {
  224. u32 r;
  225. /*
  226. * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes
  227. * it's just a matter of XORing the bits.
  228. */
  229. r = ((__force u32)clk->enable_reg ^ (CM_FCLKEN ^ CM_ICLKEN));
  230. *other_reg = (__force void __iomem *)r;
  231. *other_bit = clk->enable_bit;
  232. }
  233. /**
  234. * omap2_clk_dflt_find_idlest - find CM_IDLEST reg va, bit shift for @clk
  235. * @clk: struct clk * to find IDLEST info for
  236. * @idlest_reg: void __iomem ** to return the CM_IDLEST va in
  237. * @idlest_bit: u8 * to return the CM_IDLEST bit shift in
  238. * @idlest_val: u8 * to return the idle status indicator
  239. *
  240. * Return the CM_IDLEST register address and bit shift corresponding
  241. * to the module that "owns" this clock. This default code assumes
  242. * that the CM_IDLEST bit shift is the CM_*CLKEN bit shift, and that
  243. * the IDLEST register address ID corresponds to the CM_*CLKEN
  244. * register address ID (e.g., that CM_FCLKEN2 corresponds to
  245. * CM_IDLEST2). This is not true for all modules. No return value.
  246. */
  247. #ifdef CONFIG_COMMON_CLK
  248. void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,
  249. #else
  250. void omap2_clk_dflt_find_idlest(struct clk *clk,
  251. #endif
  252. void __iomem **idlest_reg, u8 *idlest_bit, u8 *idlest_val)
  253. {
  254. u32 r;
  255. r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
  256. *idlest_reg = (__force void __iomem *)r;
  257. *idlest_bit = clk->enable_bit;
  258. /*
  259. * 24xx uses 0 to indicate not ready, and 1 to indicate ready.
  260. * 34xx reverses this, just to keep us on our toes
  261. * AM35xx uses both, depending on the module.
  262. */
  263. if (cpu_is_omap24xx())
  264. *idlest_val = OMAP24XX_CM_IDLEST_VAL;
  265. else if (cpu_is_omap34xx())
  266. *idlest_val = OMAP34XX_CM_IDLEST_VAL;
  267. else
  268. BUG();
  269. }
  270. #ifdef CONFIG_COMMON_CLK
  271. /**
  272. * omap2_dflt_clk_enable - enable a clock in the hardware
  273. * @hw: struct clk_hw * of the clock to enable
  274. *
  275. * Enable the clock @hw in the hardware. We first call into the OMAP
  276. * clockdomain code to "enable" the corresponding clockdomain if this
  277. * is the first enabled user of the clockdomain. Then program the
  278. * hardware to enable the clock. Then wait for the IP block that uses
  279. * this clock to leave idle (if applicable). Returns the error value
  280. * from clkdm_clk_enable() if it terminated with an error, or -EINVAL
  281. * if @hw has a null clock enable_reg, or zero upon success.
  282. */
  283. int omap2_dflt_clk_enable(struct clk_hw *hw)
  284. {
  285. struct clk_hw_omap *clk;
  286. u32 v;
  287. int ret = 0;
  288. clk = to_clk_hw_omap(hw);
  289. if (clkdm_control && clk->clkdm) {
  290. ret = clkdm_clk_enable(clk->clkdm, hw->clk);
  291. if (ret) {
  292. WARN(1, "%s: could not enable %s's clockdomain %s: %d\n",
  293. __func__, __clk_get_name(hw->clk),
  294. clk->clkdm->name, ret);
  295. return ret;
  296. }
  297. }
  298. if (unlikely(clk->enable_reg == NULL)) {
  299. pr_err("%s: %s missing enable_reg\n", __func__,
  300. __clk_get_name(hw->clk));
  301. ret = -EINVAL;
  302. goto err;
  303. }
  304. /* FIXME should not have INVERT_ENABLE bit here */
  305. v = __raw_readl(clk->enable_reg);
  306. if (clk->flags & INVERT_ENABLE)
  307. v &= ~(1 << clk->enable_bit);
  308. else
  309. v |= (1 << clk->enable_bit);
  310. __raw_writel(v, clk->enable_reg);
  311. v = __raw_readl(clk->enable_reg); /* OCP barrier */
  312. if (clk->ops && clk->ops->find_idlest)
  313. _omap2_module_wait_ready(clk);
  314. return 0;
  315. err:
  316. if (clkdm_control && clk->clkdm)
  317. clkdm_clk_disable(clk->clkdm, hw->clk);
  318. return ret;
  319. }
  320. /**
  321. * omap2_dflt_clk_disable - disable a clock in the hardware
  322. * @hw: struct clk_hw * of the clock to disable
  323. *
  324. * Disable the clock @hw in the hardware, and call into the OMAP
  325. * clockdomain code to "disable" the corresponding clockdomain if all
  326. * clocks/hwmods in that clockdomain are now disabled. No return
  327. * value.
  328. */
  329. void omap2_dflt_clk_disable(struct clk_hw *hw)
  330. {
  331. struct clk_hw_omap *clk;
  332. u32 v;
  333. clk = to_clk_hw_omap(hw);
  334. if (!clk->enable_reg) {
  335. /*
  336. * 'independent' here refers to a clock which is not
  337. * controlled by its parent.
  338. */
  339. pr_err("%s: independent clock %s has no enable_reg\n",
  340. __func__, __clk_get_name(hw->clk));
  341. return;
  342. }
  343. v = __raw_readl(clk->enable_reg);
  344. if (clk->flags & INVERT_ENABLE)
  345. v |= (1 << clk->enable_bit);
  346. else
  347. v &= ~(1 << clk->enable_bit);
  348. __raw_writel(v, clk->enable_reg);
  349. /* No OCP barrier needed here since it is a disable operation */
  350. if (clkdm_control && clk->clkdm)
  351. clkdm_clk_disable(clk->clkdm, hw->clk);
  352. }
  353. /**
  354. * omap2_clkops_enable_clkdm - increment usecount on clkdm of @hw
  355. * @hw: struct clk_hw * of the clock being enabled
  356. *
  357. * Increment the usecount of the clockdomain of the clock pointed to
  358. * by @hw; if the usecount is 1, the clockdomain will be "enabled."
  359. * Only needed for clocks that don't use omap2_dflt_clk_enable() as
  360. * their enable function pointer. Passes along the return value of
  361. * clkdm_clk_enable(), -EINVAL if @hw is not associated with a
  362. * clockdomain, or 0 if clock framework-based clockdomain control is
  363. * not implemented.
  364. */
  365. int omap2_clkops_enable_clkdm(struct clk_hw *hw)
  366. {
  367. struct clk_hw_omap *clk;
  368. int ret = 0;
  369. clk = to_clk_hw_omap(hw);
  370. if (unlikely(!clk->clkdm)) {
  371. pr_err("%s: %s: no clkdm set ?!\n", __func__,
  372. __clk_get_name(hw->clk));
  373. return -EINVAL;
  374. }
  375. if (unlikely(clk->enable_reg))
  376. pr_err("%s: %s: should use dflt_clk_enable ?!\n", __func__,
  377. __clk_get_name(hw->clk));
  378. if (!clkdm_control) {
  379. pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
  380. __func__, __clk_get_name(hw->clk));
  381. return 0;
  382. }
  383. ret = clkdm_clk_enable(clk->clkdm, hw->clk);
  384. WARN(ret, "%s: could not enable %s's clockdomain %s: %d\n",
  385. __func__, __clk_get_name(hw->clk), clk->clkdm->name, ret);
  386. return ret;
  387. }
  388. /**
  389. * omap2_clkops_disable_clkdm - decrement usecount on clkdm of @hw
  390. * @hw: struct clk_hw * of the clock being disabled
  391. *
  392. * Decrement the usecount of the clockdomain of the clock pointed to
  393. * by @hw; if the usecount is 0, the clockdomain will be "disabled."
  394. * Only needed for clocks that don't use omap2_dflt_clk_disable() as their
  395. * disable function pointer. No return value.
  396. */
  397. void omap2_clkops_disable_clkdm(struct clk_hw *hw)
  398. {
  399. struct clk_hw_omap *clk;
  400. clk = to_clk_hw_omap(hw);
  401. if (unlikely(!clk->clkdm)) {
  402. pr_err("%s: %s: no clkdm set ?!\n", __func__,
  403. __clk_get_name(hw->clk));
  404. return;
  405. }
  406. if (unlikely(clk->enable_reg))
  407. pr_err("%s: %s: should use dflt_clk_disable ?!\n", __func__,
  408. __clk_get_name(hw->clk));
  409. if (!clkdm_control) {
  410. pr_err("%s: %s: clkfw-based clockdomain control disabled ?!\n",
  411. __func__, __clk_get_name(hw->clk));
  412. return;
  413. }
  414. clkdm_clk_disable(clk->clkdm, hw->clk);
  415. }
  416. /**
  417. * omap2_dflt_clk_is_enabled - is clock enabled in the hardware?
  418. * @hw: struct clk_hw * to check
  419. *
  420. * Return 1 if the clock represented by @hw is enabled in the
  421. * hardware, or 0 otherwise. Intended for use in the struct
  422. * clk_ops.is_enabled function pointer.
  423. */
  424. int omap2_dflt_clk_is_enabled(struct clk_hw *hw)
  425. {
  426. struct clk_hw_omap *clk = to_clk_hw_omap(hw);
  427. u32 v;
  428. v = __raw_readl(clk->enable_reg);
  429. if (clk->flags & INVERT_ENABLE)
  430. v ^= BIT(clk->enable_bit);
  431. v &= BIT(clk->enable_bit);
  432. return v ? 1 : 0;
  433. }
  434. static int __initdata mpurate;
  435. /*
  436. * By default we use the rate set by the bootloader.
  437. * You can override this with mpurate= cmdline option.
  438. */
  439. static int __init omap_clk_setup(char *str)
  440. {
  441. get_option(&str, &mpurate);
  442. if (!mpurate)
  443. return 1;
  444. if (mpurate < 1000)
  445. mpurate *= 1000000;
  446. return 1;
  447. }
  448. __setup("mpurate=", omap_clk_setup);
  449. const struct clk_hw_omap_ops clkhwops_wait = {
  450. .find_idlest = omap2_clk_dflt_find_idlest,
  451. .find_companion = omap2_clk_dflt_find_companion,
  452. };
  453. #else
  454. int omap2_dflt_clk_enable(struct clk *clk)
  455. {
  456. u32 v;
  457. if (unlikely(clk->enable_reg == NULL)) {
  458. pr_err("clock.c: Enable for %s without enable code\n",
  459. clk->name);
  460. return 0; /* REVISIT: -EINVAL */
  461. }
  462. v = __raw_readl(clk->enable_reg);
  463. if (clk->flags & INVERT_ENABLE)
  464. v &= ~(1 << clk->enable_bit);
  465. else
  466. v |= (1 << clk->enable_bit);
  467. __raw_writel(v, clk->enable_reg);
  468. v = __raw_readl(clk->enable_reg); /* OCP barrier */
  469. if (clk->ops->find_idlest)
  470. _omap2_module_wait_ready(clk);
  471. return 0;
  472. }
  473. void omap2_dflt_clk_disable(struct clk *clk)
  474. {
  475. u32 v;
  476. if (!clk->enable_reg) {
  477. /*
  478. * 'Independent' here refers to a clock which is not
  479. * controlled by its parent.
  480. */
  481. pr_err("clock: clk_disable called on independent clock %s which has no enable_reg\n", clk->name);
  482. return;
  483. }
  484. v = __raw_readl(clk->enable_reg);
  485. if (clk->flags & INVERT_ENABLE)
  486. v |= (1 << clk->enable_bit);
  487. else
  488. v &= ~(1 << clk->enable_bit);
  489. __raw_writel(v, clk->enable_reg);
  490. /* No OCP barrier needed here since it is a disable operation */
  491. }
  492. const struct clkops clkops_omap2_dflt_wait = {
  493. .enable = omap2_dflt_clk_enable,
  494. .disable = omap2_dflt_clk_disable,
  495. .find_companion = omap2_clk_dflt_find_companion,
  496. .find_idlest = omap2_clk_dflt_find_idlest,
  497. };
  498. const struct clkops clkops_omap2_dflt = {
  499. .enable = omap2_dflt_clk_enable,
  500. .disable = omap2_dflt_clk_disable,
  501. };
  502. /**
  503. * omap2_clk_disable - disable a clock, if the system is not using it
  504. * @clk: struct clk * to disable
  505. *
  506. * Decrements the usecount on struct clk @clk. If there are no users
  507. * left, call the clkops-specific clock disable function to disable it
  508. * in hardware. If the clock is part of a clockdomain (which they all
  509. * should be), request that the clockdomain be disabled. (It too has
  510. * a usecount, and so will not be disabled in the hardware until it no
  511. * longer has any users.) If the clock has a parent clock (most of
  512. * them do), then call ourselves, recursing on the parent clock. This
  513. * can cause an entire branch of the clock tree to be powered off by
  514. * simply disabling one clock. Intended to be called with the clockfw_lock
  515. * spinlock held. No return value.
  516. */
  517. void omap2_clk_disable(struct clk *clk)
  518. {
  519. if (clk->usecount == 0) {
  520. WARN(1, "clock: %s: omap2_clk_disable() called, but usecount already 0?", clk->name);
  521. return;
  522. }
  523. pr_debug("clock: %s: decrementing usecount\n", clk->name);
  524. clk->usecount--;
  525. if (clk->usecount > 0)
  526. return;
  527. pr_debug("clock: %s: disabling in hardware\n", clk->name);
  528. if (clk->ops && clk->ops->disable) {
  529. trace_clock_disable(clk->name, 0, smp_processor_id());
  530. clk->ops->disable(clk);
  531. }
  532. if (clkdm_control && clk->clkdm)
  533. clkdm_clk_disable(clk->clkdm, clk);
  534. if (clk->parent)
  535. omap2_clk_disable(clk->parent);
  536. }
  537. /**
  538. * omap2_clk_enable - request that the system enable a clock
  539. * @clk: struct clk * to enable
  540. *
  541. * Increments the usecount on struct clk @clk. If there were no users
  542. * previously, then recurse up the clock tree, enabling all of the
  543. * clock's parents and all of the parent clockdomains, and finally,
  544. * enabling @clk's clockdomain, and @clk itself. Intended to be
  545. * called with the clockfw_lock spinlock held. Returns 0 upon success
  546. * or a negative error code upon failure.
  547. */
  548. int omap2_clk_enable(struct clk *clk)
  549. {
  550. int ret;
  551. pr_debug("clock: %s: incrementing usecount\n", clk->name);
  552. clk->usecount++;
  553. if (clk->usecount > 1)
  554. return 0;
  555. pr_debug("clock: %s: enabling in hardware\n", clk->name);
  556. if (clk->parent) {
  557. ret = omap2_clk_enable(clk->parent);
  558. if (ret) {
  559. WARN(1, "clock: %s: could not enable parent %s: %d\n",
  560. clk->name, clk->parent->name, ret);
  561. goto oce_err1;
  562. }
  563. }
  564. if (clkdm_control && clk->clkdm) {
  565. ret = clkdm_clk_enable(clk->clkdm, clk);
  566. if (ret) {
  567. WARN(1, "clock: %s: could not enable clockdomain %s: %d\n",
  568. clk->name, clk->clkdm->name, ret);
  569. goto oce_err2;
  570. }
  571. }
  572. if (clk->ops && clk->ops->enable) {
  573. trace_clock_enable(clk->name, 1, smp_processor_id());
  574. ret = clk->ops->enable(clk);
  575. if (ret) {
  576. WARN(1, "clock: %s: could not enable: %d\n",
  577. clk->name, ret);
  578. goto oce_err3;
  579. }
  580. }
  581. return 0;
  582. oce_err3:
  583. if (clkdm_control && clk->clkdm)
  584. clkdm_clk_disable(clk->clkdm, clk);
  585. oce_err2:
  586. if (clk->parent)
  587. omap2_clk_disable(clk->parent);
  588. oce_err1:
  589. clk->usecount--;
  590. return ret;
  591. }
  592. /* Given a clock and a rate apply a clock specific rounding function */
  593. long omap2_clk_round_rate(struct clk *clk, unsigned long rate)
  594. {
  595. if (clk->round_rate)
  596. return clk->round_rate(clk, rate);
  597. return clk->rate;
  598. }
  599. /* Set the clock rate for a clock source */
  600. int omap2_clk_set_rate(struct clk *clk, unsigned long rate)
  601. {
  602. int ret = -EINVAL;
  603. pr_debug("clock: set_rate for clock %s to rate %ld\n", clk->name, rate);
  604. /* dpll_ck, core_ck, virt_prcm_set; plus all clksel clocks */
  605. if (clk->set_rate) {
  606. trace_clock_set_rate(clk->name, rate, smp_processor_id());
  607. ret = clk->set_rate(clk, rate);
  608. }
  609. return ret;
  610. }
  611. int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent)
  612. {
  613. if (!clk->clksel)
  614. return -EINVAL;
  615. if (clk->parent == new_parent)
  616. return 0;
  617. return omap2_clksel_set_parent(clk, new_parent);
  618. }
  619. /*
  620. * OMAP2+ clock reset and init functions
  621. */
  622. #ifdef CONFIG_OMAP_RESET_CLOCKS
  623. void omap2_clk_disable_unused(struct clk *clk)
  624. {
  625. u32 regval32, v;
  626. v = (clk->flags & INVERT_ENABLE) ? (1 << clk->enable_bit) : 0;
  627. regval32 = __raw_readl(clk->enable_reg);
  628. if ((regval32 & (1 << clk->enable_bit)) == v)
  629. return;
  630. pr_debug("Disabling unused clock \"%s\"\n", clk->name);
  631. if (cpu_is_omap34xx()) {
  632. omap2_clk_enable(clk);
  633. omap2_clk_disable(clk);
  634. } else {
  635. clk->ops->disable(clk);
  636. }
  637. if (clk->clkdm != NULL)
  638. pwrdm_state_switch(clk->clkdm->pwrdm.ptr);
  639. }
  640. #endif
  641. #endif /* CONFIG_COMMON_CLK */
  642. /**
  643. * omap2_clk_switch_mpurate_at_boot - switch ARM MPU rate by boot-time argument
  644. * @mpurate_ck_name: clk name of the clock to change rate
  645. *
  646. * Change the ARM MPU clock rate to the rate specified on the command
  647. * line, if one was specified. @mpurate_ck_name should be
  648. * "virt_prcm_set" on OMAP2xxx and "dpll1_ck" on OMAP34xx/OMAP36xx.
  649. * XXX Does not handle voltage scaling - on OMAP2xxx this is currently
  650. * handled by the virt_prcm_set clock, but this should be handled by
  651. * the OPP layer. XXX This is intended to be handled by the OPP layer
  652. * code in the near future and should be removed from the clock code.
  653. * Returns -EINVAL if 'mpurate' is zero or if clk_set_rate() rejects
  654. * the rate, -ENOENT if the struct clk referred to by @mpurate_ck_name
  655. * cannot be found, or 0 upon success.
  656. */
  657. int __init omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name)
  658. {
  659. struct clk *mpurate_ck;
  660. int r;
  661. if (!mpurate)
  662. return -EINVAL;
  663. mpurate_ck = clk_get(NULL, mpurate_ck_name);
  664. if (WARN(IS_ERR(mpurate_ck), "Failed to get %s.\n", mpurate_ck_name))
  665. return -ENOENT;
  666. r = clk_set_rate(mpurate_ck, mpurate);
  667. if (IS_ERR_VALUE(r)) {
  668. WARN(1, "clock: %s: unable to set MPU rate to %d: %d\n",
  669. mpurate_ck_name, mpurate, r);
  670. clk_put(mpurate_ck);
  671. return -EINVAL;
  672. }
  673. calibrate_delay();
  674. #ifndef CONFIG_COMMON_CLK
  675. recalculate_root_clocks();
  676. #endif
  677. clk_put(mpurate_ck);
  678. return 0;
  679. }
  680. /**
  681. * omap2_clk_print_new_rates - print summary of current clock tree rates
  682. * @hfclkin_ck_name: clk name for the off-chip HF oscillator
  683. * @core_ck_name: clk name for the on-chip CORE_CLK
  684. * @mpu_ck_name: clk name for the ARM MPU clock
  685. *
  686. * Prints a short message to the console with the HFCLKIN oscillator
  687. * rate, the rate of the CORE clock, and the rate of the ARM MPU clock.
  688. * Called by the boot-time MPU rate switching code. XXX This is intended
  689. * to be handled by the OPP layer code in the near future and should be
  690. * removed from the clock code. No return value.
  691. */
  692. void __init omap2_clk_print_new_rates(const char *hfclkin_ck_name,
  693. const char *core_ck_name,
  694. const char *mpu_ck_name)
  695. {
  696. struct clk *hfclkin_ck, *core_ck, *mpu_ck;
  697. unsigned long hfclkin_rate;
  698. mpu_ck = clk_get(NULL, mpu_ck_name);
  699. if (WARN(IS_ERR(mpu_ck), "clock: failed to get %s.\n", mpu_ck_name))
  700. return;
  701. core_ck = clk_get(NULL, core_ck_name);
  702. if (WARN(IS_ERR(core_ck), "clock: failed to get %s.\n", core_ck_name))
  703. return;
  704. hfclkin_ck = clk_get(NULL, hfclkin_ck_name);
  705. if (WARN(IS_ERR(hfclkin_ck), "Failed to get %s.\n", hfclkin_ck_name))
  706. return;
  707. hfclkin_rate = clk_get_rate(hfclkin_ck);
  708. pr_info("Switched to new clocking rate (Crystal/Core/MPU): %ld.%01ld/%ld/%ld MHz\n",
  709. (hfclkin_rate / 1000000), ((hfclkin_rate / 100000) % 10),
  710. (clk_get_rate(core_ck) / 1000000),
  711. (clk_get_rate(mpu_ck) / 1000000));
  712. }
  713. #ifndef CONFIG_COMMON_CLK
  714. /* Common data */
  715. int clk_enable(struct clk *clk)
  716. {
  717. unsigned long flags;
  718. int ret;
  719. if (clk == NULL || IS_ERR(clk))
  720. return -EINVAL;
  721. spin_lock_irqsave(&clockfw_lock, flags);
  722. ret = omap2_clk_enable(clk);
  723. spin_unlock_irqrestore(&clockfw_lock, flags);
  724. return ret;
  725. }
  726. EXPORT_SYMBOL(clk_enable);
  727. void clk_disable(struct clk *clk)
  728. {
  729. unsigned long flags;
  730. if (clk == NULL || IS_ERR(clk))
  731. return;
  732. spin_lock_irqsave(&clockfw_lock, flags);
  733. if (clk->usecount == 0) {
  734. pr_err("Trying disable clock %s with 0 usecount\n",
  735. clk->name);
  736. WARN_ON(1);
  737. goto out;
  738. }
  739. omap2_clk_disable(clk);
  740. out:
  741. spin_unlock_irqrestore(&clockfw_lock, flags);
  742. }
  743. EXPORT_SYMBOL(clk_disable);
  744. unsigned long clk_get_rate(struct clk *clk)
  745. {
  746. unsigned long flags;
  747. unsigned long ret;
  748. if (clk == NULL || IS_ERR(clk))
  749. return 0;
  750. spin_lock_irqsave(&clockfw_lock, flags);
  751. ret = clk->rate;
  752. spin_unlock_irqrestore(&clockfw_lock, flags);
  753. return ret;
  754. }
  755. EXPORT_SYMBOL(clk_get_rate);
  756. /*
  757. * Optional clock functions defined in include/linux/clk.h
  758. */
  759. long clk_round_rate(struct clk *clk, unsigned long rate)
  760. {
  761. unsigned long flags;
  762. long ret;
  763. if (clk == NULL || IS_ERR(clk))
  764. return 0;
  765. spin_lock_irqsave(&clockfw_lock, flags);
  766. ret = omap2_clk_round_rate(clk, rate);
  767. spin_unlock_irqrestore(&clockfw_lock, flags);
  768. return ret;
  769. }
  770. EXPORT_SYMBOL(clk_round_rate);
  771. int clk_set_rate(struct clk *clk, unsigned long rate)
  772. {
  773. unsigned long flags;
  774. int ret = -EINVAL;
  775. if (clk == NULL || IS_ERR(clk))
  776. return ret;
  777. spin_lock_irqsave(&clockfw_lock, flags);
  778. ret = omap2_clk_set_rate(clk, rate);
  779. if (ret == 0)
  780. propagate_rate(clk);
  781. spin_unlock_irqrestore(&clockfw_lock, flags);
  782. return ret;
  783. }
  784. EXPORT_SYMBOL(clk_set_rate);
  785. int clk_set_parent(struct clk *clk, struct clk *parent)
  786. {
  787. unsigned long flags;
  788. int ret = -EINVAL;
  789. if (clk == NULL || IS_ERR(clk) || parent == NULL || IS_ERR(parent))
  790. return ret;
  791. spin_lock_irqsave(&clockfw_lock, flags);
  792. if (clk->usecount == 0) {
  793. ret = omap2_clk_set_parent(clk, parent);
  794. if (ret == 0)
  795. propagate_rate(clk);
  796. } else {
  797. ret = -EBUSY;
  798. }
  799. spin_unlock_irqrestore(&clockfw_lock, flags);
  800. return ret;
  801. }
  802. EXPORT_SYMBOL(clk_set_parent);
  803. struct clk *clk_get_parent(struct clk *clk)
  804. {
  805. return clk->parent;
  806. }
  807. EXPORT_SYMBOL(clk_get_parent);
  808. /*
  809. * OMAP specific clock functions shared between omap1 and omap2
  810. */
  811. int __initdata mpurate;
  812. /*
  813. * By default we use the rate set by the bootloader.
  814. * You can override this with mpurate= cmdline option.
  815. */
  816. static int __init omap_clk_setup(char *str)
  817. {
  818. get_option(&str, &mpurate);
  819. if (!mpurate)
  820. return 1;
  821. if (mpurate < 1000)
  822. mpurate *= 1000000;
  823. return 1;
  824. }
  825. __setup("mpurate=", omap_clk_setup);
  826. /* Used for clocks that always have same value as the parent clock */
  827. unsigned long followparent_recalc(struct clk *clk)
  828. {
  829. return clk->parent->rate;
  830. }
  831. /*
  832. * Used for clocks that have the same value as the parent clock,
  833. * divided by some factor
  834. */
  835. unsigned long omap_fixed_divisor_recalc(struct clk *clk)
  836. {
  837. WARN_ON(!clk->fixed_div);
  838. return clk->parent->rate / clk->fixed_div;
  839. }
  840. void clk_reparent(struct clk *child, struct clk *parent)
  841. {
  842. list_del_init(&child->sibling);
  843. if (parent)
  844. list_add(&child->sibling, &parent->children);
  845. child->parent = parent;
  846. /* now do the debugfs renaming to reattach the child
  847. to the proper parent */
  848. }
  849. /* Propagate rate to children */
  850. void propagate_rate(struct clk *tclk)
  851. {
  852. struct clk *clkp;
  853. list_for_each_entry(clkp, &tclk->children, sibling) {
  854. if (clkp->recalc)
  855. clkp->rate = clkp->recalc(clkp);
  856. propagate_rate(clkp);
  857. }
  858. }
  859. static LIST_HEAD(root_clks);
  860. /**
  861. * recalculate_root_clocks - recalculate and propagate all root clocks
  862. *
  863. * Recalculates all root clocks (clocks with no parent), which if the
  864. * clock's .recalc is set correctly, should also propagate their rates.
  865. * Called at init.
  866. */
  867. void recalculate_root_clocks(void)
  868. {
  869. struct clk *clkp;
  870. list_for_each_entry(clkp, &root_clks, sibling) {
  871. if (clkp->recalc)
  872. clkp->rate = clkp->recalc(clkp);
  873. propagate_rate(clkp);
  874. }
  875. }
  876. /**
  877. * clk_preinit - initialize any fields in the struct clk before clk init
  878. * @clk: struct clk * to initialize
  879. *
  880. * Initialize any struct clk fields needed before normal clk initialization
  881. * can run. No return value.
  882. */
  883. void clk_preinit(struct clk *clk)
  884. {
  885. INIT_LIST_HEAD(&clk->children);
  886. }
  887. int clk_register(struct clk *clk)
  888. {
  889. if (clk == NULL || IS_ERR(clk))
  890. return -EINVAL;
  891. /*
  892. * trap out already registered clocks
  893. */
  894. if (clk->node.next || clk->node.prev)
  895. return 0;
  896. mutex_lock(&clocks_mutex);
  897. if (clk->parent)
  898. list_add(&clk->sibling, &clk->parent->children);
  899. else
  900. list_add(&clk->sibling, &root_clks);
  901. list_add(&clk->node, &clocks);
  902. if (clk->init)
  903. clk->init(clk);
  904. mutex_unlock(&clocks_mutex);
  905. return 0;
  906. }
  907. EXPORT_SYMBOL(clk_register);
  908. void clk_unregister(struct clk *clk)
  909. {
  910. if (clk == NULL || IS_ERR(clk))
  911. return;
  912. mutex_lock(&clocks_mutex);
  913. list_del(&clk->sibling);
  914. list_del(&clk->node);
  915. mutex_unlock(&clocks_mutex);
  916. }
  917. EXPORT_SYMBOL(clk_unregister);
  918. void clk_enable_init_clocks(void)
  919. {
  920. struct clk *clkp;
  921. list_for_each_entry(clkp, &clocks, node)
  922. if (clkp->flags & ENABLE_ON_INIT)
  923. clk_enable(clkp);
  924. }
  925. /**
  926. * omap_clk_get_by_name - locate OMAP struct clk by its name
  927. * @name: name of the struct clk to locate
  928. *
  929. * Locate an OMAP struct clk by its name. Assumes that struct clk
  930. * names are unique. Returns NULL if not found or a pointer to the
  931. * struct clk if found.
  932. */
  933. struct clk *omap_clk_get_by_name(const char *name)
  934. {
  935. struct clk *c;
  936. struct clk *ret = NULL;
  937. mutex_lock(&clocks_mutex);
  938. list_for_each_entry(c, &clocks, node) {
  939. if (!strcmp(c->name, name)) {
  940. ret = c;
  941. break;
  942. }
  943. }
  944. mutex_unlock(&clocks_mutex);
  945. return ret;
  946. }
  947. int omap_clk_enable_autoidle_all(void)
  948. {
  949. struct clk *c;
  950. unsigned long flags;
  951. spin_lock_irqsave(&clockfw_lock, flags);
  952. list_for_each_entry(c, &clocks, node)
  953. if (c->ops->allow_idle)
  954. c->ops->allow_idle(c);
  955. spin_unlock_irqrestore(&clockfw_lock, flags);
  956. return 0;
  957. }
  958. int omap_clk_disable_autoidle_all(void)
  959. {
  960. struct clk *c;
  961. unsigned long flags;
  962. spin_lock_irqsave(&clockfw_lock, flags);
  963. list_for_each_entry(c, &clocks, node)
  964. if (c->ops->deny_idle)
  965. c->ops->deny_idle(c);
  966. spin_unlock_irqrestore(&clockfw_lock, flags);
  967. return 0;
  968. }
  969. /*
  970. * Low level helpers
  971. */
  972. static int clkll_enable_null(struct clk *clk)
  973. {
  974. return 0;
  975. }
  976. static void clkll_disable_null(struct clk *clk)
  977. {
  978. }
  979. const struct clkops clkops_null = {
  980. .enable = clkll_enable_null,
  981. .disable = clkll_disable_null,
  982. };
  983. /*
  984. * Dummy clock
  985. *
  986. * Used for clock aliases that are needed on some OMAPs, but not others
  987. */
  988. struct clk dummy_ck = {
  989. .name = "dummy",
  990. .ops = &clkops_null,
  991. };
  992. /*
  993. *
  994. */
  995. #ifdef CONFIG_OMAP_RESET_CLOCKS
  996. /*
  997. * Disable any unused clocks left on by the bootloader
  998. */
  999. static int __init clk_disable_unused(void)
  1000. {
  1001. struct clk *ck;
  1002. unsigned long flags;
  1003. pr_info("clock: disabling unused clocks to save power\n");
  1004. spin_lock_irqsave(&clockfw_lock, flags);
  1005. list_for_each_entry(ck, &clocks, node) {
  1006. if (ck->ops == &clkops_null)
  1007. continue;
  1008. if (ck->usecount > 0 || !ck->enable_reg)
  1009. continue;
  1010. omap2_clk_disable_unused(ck);
  1011. }
  1012. spin_unlock_irqrestore(&clockfw_lock, flags);
  1013. return 0;
  1014. }
  1015. late_initcall(clk_disable_unused);
  1016. late_initcall(omap_clk_enable_autoidle_all);
  1017. #endif
  1018. #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
  1019. /*
  1020. * debugfs support to trace clock tree hierarchy and attributes
  1021. */
  1022. #include <linux/debugfs.h>
  1023. #include <linux/seq_file.h>
  1024. static struct dentry *clk_debugfs_root;
  1025. static int clk_dbg_show_summary(struct seq_file *s, void *unused)
  1026. {
  1027. struct clk *c;
  1028. struct clk *pa;
  1029. mutex_lock(&clocks_mutex);
  1030. seq_printf(s, "%-30s %-30s %-10s %s\n",
  1031. "clock-name", "parent-name", "rate", "use-count");
  1032. list_for_each_entry(c, &clocks, node) {
  1033. pa = c->parent;
  1034. seq_printf(s, "%-30s %-30s %-10lu %d\n",
  1035. c->name, pa ? pa->name : "none", c->rate,
  1036. c->usecount);
  1037. }
  1038. mutex_unlock(&clocks_mutex);
  1039. return 0;
  1040. }
  1041. static int clk_dbg_open(struct inode *inode, struct file *file)
  1042. {
  1043. return single_open(file, clk_dbg_show_summary, inode->i_private);
  1044. }
  1045. static const struct file_operations debug_clock_fops = {
  1046. .open = clk_dbg_open,
  1047. .read = seq_read,
  1048. .llseek = seq_lseek,
  1049. .release = single_release,
  1050. };
  1051. static int clk_debugfs_register_one(struct clk *c)
  1052. {
  1053. int err;
  1054. struct dentry *d;
  1055. struct clk *pa = c->parent;
  1056. d = debugfs_create_dir(c->name, pa ? pa->dent : clk_debugfs_root);
  1057. if (!d)
  1058. return -ENOMEM;
  1059. c->dent = d;
  1060. d = debugfs_create_u8("usecount", S_IRUGO, c->dent, (u8 *)&c->usecount);
  1061. if (!d) {
  1062. err = -ENOMEM;
  1063. goto err_out;
  1064. }
  1065. d = debugfs_create_u32("rate", S_IRUGO, c->dent, (u32 *)&c->rate);
  1066. if (!d) {
  1067. err = -ENOMEM;
  1068. goto err_out;
  1069. }
  1070. d = debugfs_create_x32("flags", S_IRUGO, c->dent, (u32 *)&c->flags);
  1071. if (!d) {
  1072. err = -ENOMEM;
  1073. goto err_out;
  1074. }
  1075. return 0;
  1076. err_out:
  1077. debugfs_remove_recursive(c->dent);
  1078. return err;
  1079. }
  1080. static int clk_debugfs_register(struct clk *c)
  1081. {
  1082. int err;
  1083. struct clk *pa = c->parent;
  1084. if (pa && !pa->dent) {
  1085. err = clk_debugfs_register(pa);
  1086. if (err)
  1087. return err;
  1088. }
  1089. if (!c->dent) {
  1090. err = clk_debugfs_register_one(c);
  1091. if (err)
  1092. return err;
  1093. }
  1094. return 0;
  1095. }
  1096. static int __init clk_debugfs_init(void)
  1097. {
  1098. struct clk *c;
  1099. struct dentry *d;
  1100. int err;
  1101. d = debugfs_create_dir("clock", NULL);
  1102. if (!d)
  1103. return -ENOMEM;
  1104. clk_debugfs_root = d;
  1105. list_for_each_entry(c, &clocks, node) {
  1106. err = clk_debugfs_register(c);
  1107. if (err)
  1108. goto err_out;
  1109. }
  1110. d = debugfs_create_file("summary", S_IRUGO,
  1111. d, NULL, &debug_clock_fops);
  1112. if (!d)
  1113. return -ENOMEM;
  1114. return 0;
  1115. err_out:
  1116. debugfs_remove_recursive(clk_debugfs_root);
  1117. return err;
  1118. }
  1119. late_initcall(clk_debugfs_init);
  1120. #endif /* defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS) */
  1121. #endif /* CONFIG_COMMON_CLK */