clock.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * linux/arch/arm/mach-omap2/clock.h
  3. *
  4. * Copyright (C) 2005-2009 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2011 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. #ifndef __ARCH_ARM_MACH_OMAP2_CLOCK_H
  16. #define __ARCH_ARM_MACH_OMAP2_CLOCK_H
  17. #include <linux/kernel.h>
  18. #include <linux/list.h>
  19. #include <linux/clkdev.h>
  20. struct omap_clk {
  21. u16 cpu;
  22. struct clk_lookup lk;
  23. };
  24. #define CLK(dev, con, ck, cp) \
  25. { \
  26. .cpu = cp, \
  27. .lk = { \
  28. .dev_id = dev, \
  29. .con_id = con, \
  30. .clk = ck, \
  31. }, \
  32. }
  33. /* Platform flags for the clkdev-OMAP integration code */
  34. #define CK_242X (1 << 0)
  35. #define CK_243X (1 << 1) /* 243x, 253x */
  36. #define CK_3430ES1 (1 << 2) /* 34xxES1 only */
  37. #define CK_3430ES2PLUS (1 << 3) /* 34xxES2, ES3, non-Sitara 35xx only */
  38. #define CK_AM35XX (1 << 4) /* Sitara AM35xx */
  39. #define CK_36XX (1 << 5) /* 36xx/37xx-specific clocks */
  40. #define CK_443X (1 << 6)
  41. #define CK_TI816X (1 << 7)
  42. #define CK_446X (1 << 8)
  43. #define CK_AM33XX (1 << 9) /* AM33xx specific clocks */
  44. #define CK_34XX (CK_3430ES1 | CK_3430ES2PLUS)
  45. #define CK_3XXX (CK_34XX | CK_AM35XX | CK_36XX)
  46. #ifdef CONFIG_COMMON_CLK
  47. #include <linux/clk-provider.h>
  48. struct clockdomain;
  49. #define to_clk_hw_omap(_hw) container_of(_hw, struct clk_hw_omap, hw)
  50. #else
  51. struct module;
  52. struct clk;
  53. struct clockdomain;
  54. /* Temporary, needed during the common clock framework conversion */
  55. #define __clk_get_name(clk) (clk->name)
  56. #define __clk_get_parent(clk) (clk->parent)
  57. #define __clk_get_rate(clk) (clk->rate)
  58. /**
  59. * struct clkops - some clock function pointers
  60. * @enable: fn ptr that enables the current clock in hardware
  61. * @disable: fn ptr that enables the current clock in hardware
  62. * @find_idlest: function returning the IDLEST register for the clock's IP blk
  63. * @find_companion: function returning the "companion" clk reg for the clock
  64. * @allow_idle: fn ptr that enables autoidle for the current clock in hardware
  65. * @deny_idle: fn ptr that disables autoidle for the current clock in hardware
  66. *
  67. * A "companion" clk is an accompanying clock to the one being queried
  68. * that must be enabled for the IP module connected to the clock to
  69. * become accessible by the hardware. Neither @find_idlest nor
  70. * @find_companion should be needed; that information is IP
  71. * block-specific; the hwmod code has been created to handle this, but
  72. * until hwmod data is ready and drivers have been converted to use PM
  73. * runtime calls in place of clk_enable()/clk_disable(), @find_idlest and
  74. * @find_companion must, unfortunately, remain.
  75. */
  76. struct clkops {
  77. int (*enable)(struct clk *);
  78. void (*disable)(struct clk *);
  79. void (*find_idlest)(struct clk *, void __iomem **,
  80. u8 *, u8 *);
  81. void (*find_companion)(struct clk *, void __iomem **,
  82. u8 *);
  83. void (*allow_idle)(struct clk *);
  84. void (*deny_idle)(struct clk *);
  85. };
  86. #endif
  87. /* struct clksel_rate.flags possibilities */
  88. #define RATE_IN_242X (1 << 0)
  89. #define RATE_IN_243X (1 << 1)
  90. #define RATE_IN_3430ES1 (1 << 2) /* 3430ES1 rates only */
  91. #define RATE_IN_3430ES2PLUS (1 << 3) /* 3430 ES >= 2 rates only */
  92. #define RATE_IN_36XX (1 << 4)
  93. #define RATE_IN_4430 (1 << 5)
  94. #define RATE_IN_TI816X (1 << 6)
  95. #define RATE_IN_4460 (1 << 7)
  96. #define RATE_IN_AM33XX (1 << 8)
  97. #define RATE_IN_TI814X (1 << 9)
  98. #define RATE_IN_24XX (RATE_IN_242X | RATE_IN_243X)
  99. #define RATE_IN_34XX (RATE_IN_3430ES1 | RATE_IN_3430ES2PLUS)
  100. #define RATE_IN_3XXX (RATE_IN_34XX | RATE_IN_36XX)
  101. #define RATE_IN_44XX (RATE_IN_4430 | RATE_IN_4460)
  102. /* RATE_IN_3430ES2PLUS_36XX includes 34xx/35xx with ES >=2, and all 36xx/37xx */
  103. #define RATE_IN_3430ES2PLUS_36XX (RATE_IN_3430ES2PLUS | RATE_IN_36XX)
  104. /**
  105. * struct clksel_rate - register bitfield values corresponding to clk divisors
  106. * @val: register bitfield value (shifted to bit 0)
  107. * @div: clock divisor corresponding to @val
  108. * @flags: (see "struct clksel_rate.flags possibilities" above)
  109. *
  110. * @val should match the value of a read from struct clk.clksel_reg
  111. * AND'ed with struct clk.clksel_mask, shifted right to bit 0.
  112. *
  113. * @div is the divisor that should be applied to the parent clock's rate
  114. * to produce the current clock's rate.
  115. */
  116. struct clksel_rate {
  117. u32 val;
  118. u8 div;
  119. u16 flags;
  120. };
  121. /**
  122. * struct clksel - available parent clocks, and a pointer to their divisors
  123. * @parent: struct clk * to a possible parent clock
  124. * @rates: available divisors for this parent clock
  125. *
  126. * A struct clksel is always associated with one or more struct clks
  127. * and one or more struct clksel_rates.
  128. */
  129. struct clksel {
  130. struct clk *parent;
  131. const struct clksel_rate *rates;
  132. };
  133. /**
  134. * struct dpll_data - DPLL registers and integration data
  135. * @mult_div1_reg: register containing the DPLL M and N bitfields
  136. * @mult_mask: mask of the DPLL M bitfield in @mult_div1_reg
  137. * @div1_mask: mask of the DPLL N bitfield in @mult_div1_reg
  138. * @clk_bypass: struct clk pointer to the clock's bypass clock input
  139. * @clk_ref: struct clk pointer to the clock's reference clock input
  140. * @control_reg: register containing the DPLL mode bitfield
  141. * @enable_mask: mask of the DPLL mode bitfield in @control_reg
  142. * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate()
  143. * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate()
  144. * @max_multiplier: maximum valid non-bypass multiplier value (actual)
  145. * @last_rounded_n: cache of the last N result of omap2_dpll_round_rate()
  146. * @min_divider: minimum valid non-bypass divider value (actual)
  147. * @max_divider: maximum valid non-bypass divider value (actual)
  148. * @modes: possible values of @enable_mask
  149. * @autoidle_reg: register containing the DPLL autoidle mode bitfield
  150. * @idlest_reg: register containing the DPLL idle status bitfield
  151. * @autoidle_mask: mask of the DPLL autoidle mode bitfield in @autoidle_reg
  152. * @freqsel_mask: mask of the DPLL jitter correction bitfield in @control_reg
  153. * @idlest_mask: mask of the DPLL idle status bitfield in @idlest_reg
  154. * @auto_recal_bit: bitshift of the driftguard enable bit in @control_reg
  155. * @recal_en_bit: bitshift of the PRM_IRQENABLE_* bit for recalibration IRQs
  156. * @recal_st_bit: bitshift of the PRM_IRQSTATUS_* bit for recalibration IRQs
  157. * @flags: DPLL type/features (see below)
  158. *
  159. * Possible values for @flags:
  160. * DPLL_J_TYPE: "J-type DPLL" (only some 36xx, 4xxx DPLLs)
  161. *
  162. * @freqsel_mask is only used on the OMAP34xx family and AM35xx.
  163. *
  164. * XXX Some DPLLs have multiple bypass inputs, so it's not technically
  165. * correct to only have one @clk_bypass pointer.
  166. *
  167. * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m,
  168. * @last_rounded_n) should be separated from the runtime-fixed fields
  169. * and placed into a different structure, so that the runtime-fixed data
  170. * can be placed into read-only space.
  171. */
  172. struct dpll_data {
  173. void __iomem *mult_div1_reg;
  174. u32 mult_mask;
  175. u32 div1_mask;
  176. struct clk *clk_bypass;
  177. struct clk *clk_ref;
  178. void __iomem *control_reg;
  179. u32 enable_mask;
  180. unsigned long last_rounded_rate;
  181. u16 last_rounded_m;
  182. u16 max_multiplier;
  183. u8 last_rounded_n;
  184. u8 min_divider;
  185. u16 max_divider;
  186. u8 modes;
  187. void __iomem *autoidle_reg;
  188. void __iomem *idlest_reg;
  189. u32 autoidle_mask;
  190. u32 freqsel_mask;
  191. u32 idlest_mask;
  192. u32 dco_mask;
  193. u32 sddiv_mask;
  194. u8 auto_recal_bit;
  195. u8 recal_en_bit;
  196. u8 recal_st_bit;
  197. u8 flags;
  198. };
  199. /*
  200. * struct clk.flags possibilities
  201. *
  202. * XXX document the rest of the clock flags here
  203. *
  204. * CLOCK_CLKOUTX2: (OMAP4 only) DPLL CLKOUT and CLKOUTX2 GATE_CTRL
  205. * bits share the same register. This flag allows the
  206. * omap4_dpllmx*() code to determine which GATE_CTRL bit field
  207. * should be used. This is a temporary solution - a better approach
  208. * would be to associate clock type-specific data with the clock,
  209. * similar to the struct dpll_data approach.
  210. */
  211. #define ENABLE_REG_32BIT (1 << 0) /* Use 32-bit access */
  212. #define CLOCK_IDLE_CONTROL (1 << 1)
  213. #define CLOCK_NO_IDLE_PARENT (1 << 2)
  214. #define ENABLE_ON_INIT (1 << 3) /* Enable upon framework init */
  215. #define INVERT_ENABLE (1 << 4) /* 0 enables, 1 disables */
  216. #define CLOCK_CLKOUTX2 (1 << 5)
  217. #ifdef CONFIG_COMMON_CLK
  218. /**
  219. * struct clk_hw_omap - OMAP struct clk
  220. * @node: list_head connecting this clock into the full clock list
  221. * @enable_reg: register to write to enable the clock (see @enable_bit)
  222. * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
  223. * @flags: see "struct clk.flags possibilities" above
  224. * @clksel_reg: for clksel clks, register va containing src/divisor select
  225. * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector
  226. * @clksel: for clksel clks, pointer to struct clksel for this clock
  227. * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock
  228. * @clkdm_name: clockdomain name that this clock is contained in
  229. * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime
  230. * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
  231. * @src_offset: bitshift for source selection bitfield (OMAP1 only)
  232. *
  233. * XXX @rate_offset, @src_offset should probably be removed and OMAP1
  234. * clock code converted to use clksel.
  235. *
  236. */
  237. struct clk_hw_omap_ops;
  238. struct clk_hw_omap {
  239. struct clk_hw hw;
  240. struct list_head node;
  241. unsigned long fixed_rate;
  242. u8 fixed_div;
  243. void __iomem *enable_reg;
  244. u8 enable_bit;
  245. u8 flags;
  246. void __iomem *clksel_reg;
  247. u32 clksel_mask;
  248. const struct clksel *clksel;
  249. struct dpll_data *dpll_data;
  250. const char *clkdm_name;
  251. struct clockdomain *clkdm;
  252. const struct clk_hw_omap_ops *ops;
  253. };
  254. struct clk_hw_omap_ops {
  255. void (*find_idlest)(struct clk_hw_omap *oclk,
  256. void __iomem **idlest_reg,
  257. u8 *idlest_bit, u8 *idlest_val);
  258. void (*find_companion)(struct clk_hw_omap *oclk,
  259. void __iomem **other_reg,
  260. u8 *other_bit);
  261. void (*allow_idle)(struct clk_hw_omap *oclk);
  262. void (*deny_idle)(struct clk_hw_omap *oclk);
  263. };
  264. unsigned long omap_fixed_divisor_recalc(struct clk_hw *hw,
  265. unsigned long parent_rate);
  266. #else
  267. /**
  268. * struct clk - OMAP struct clk
  269. * @node: list_head connecting this clock into the full clock list
  270. * @ops: struct clkops * for this clock
  271. * @name: the name of the clock in the hardware (used in hwmod data and debug)
  272. * @parent: pointer to this clock's parent struct clk
  273. * @children: list_head connecting to the child clks' @sibling list_heads
  274. * @sibling: list_head connecting this clk to its parent clk's @children
  275. * @rate: current clock rate
  276. * @enable_reg: register to write to enable the clock (see @enable_bit)
  277. * @recalc: fn ptr that returns the clock's current rate
  278. * @set_rate: fn ptr that can change the clock's current rate
  279. * @round_rate: fn ptr that can round the clock's current rate
  280. * @init: fn ptr to do clock-specific initialization
  281. * @enable_bit: bitshift to write to enable/disable the clock (see @enable_reg)
  282. * @usecount: number of users that have requested this clock to be enabled
  283. * @fixed_div: when > 0, this clock's rate is its parent's rate / @fixed_div
  284. * @flags: see "struct clk.flags possibilities" above
  285. * @clksel_reg: for clksel clks, register va containing src/divisor select
  286. * @clksel_mask: bitmask in @clksel_reg for the src/divisor selector
  287. * @clksel: for clksel clks, pointer to struct clksel for this clock
  288. * @dpll_data: for DPLLs, pointer to struct dpll_data for this clock
  289. * @clkdm_name: clockdomain name that this clock is contained in
  290. * @clkdm: pointer to struct clockdomain, resolved from @clkdm_name at runtime
  291. * @rate_offset: bitshift for rate selection bitfield (OMAP1 only)
  292. * @src_offset: bitshift for source selection bitfield (OMAP1 only)
  293. *
  294. * XXX @rate_offset, @src_offset should probably be removed and OMAP1
  295. * clock code converted to use clksel.
  296. *
  297. * XXX @usecount is poorly named. It should be "enable_count" or
  298. * something similar. "users" in the description refers to kernel
  299. * code (core code or drivers) that have called clk_enable() and not
  300. * yet called clk_disable(); the usecount of parent clocks is also
  301. * incremented by the clock code when clk_enable() is called on child
  302. * clocks and decremented by the clock code when clk_disable() is
  303. * called on child clocks.
  304. *
  305. * XXX @clkdm, @usecount, @children, @sibling should be marked for
  306. * internal use only.
  307. *
  308. * @children and @sibling are used to optimize parent-to-child clock
  309. * tree traversals. (child-to-parent traversals use @parent.)
  310. *
  311. * XXX The notion of the clock's current rate probably needs to be
  312. * separated from the clock's target rate.
  313. */
  314. struct clk {
  315. struct list_head node;
  316. const struct clkops *ops;
  317. const char *name;
  318. struct clk *parent;
  319. struct list_head children;
  320. struct list_head sibling; /* node for children */
  321. unsigned long rate;
  322. void __iomem *enable_reg;
  323. unsigned long (*recalc)(struct clk *);
  324. int (*set_rate)(struct clk *, unsigned long);
  325. long (*round_rate)(struct clk *, unsigned long);
  326. void (*init)(struct clk *);
  327. u8 enable_bit;
  328. s8 usecount;
  329. u8 fixed_div;
  330. u8 flags;
  331. void __iomem *clksel_reg;
  332. u32 clksel_mask;
  333. const struct clksel *clksel;
  334. struct dpll_data *dpll_data;
  335. const char *clkdm_name;
  336. struct clockdomain *clkdm;
  337. #if defined(CONFIG_PM_DEBUG) && defined(CONFIG_DEBUG_FS)
  338. struct dentry *dent; /* For visible tree hierarchy */
  339. #endif
  340. };
  341. struct clk_functions {
  342. int (*clk_enable)(struct clk *clk);
  343. void (*clk_disable)(struct clk *clk);
  344. long (*clk_round_rate)(struct clk *clk, unsigned long rate);
  345. int (*clk_set_rate)(struct clk *clk, unsigned long rate);
  346. int (*clk_set_parent)(struct clk *clk, struct clk *parent);
  347. void (*clk_allow_idle)(struct clk *clk);
  348. void (*clk_deny_idle)(struct clk *clk);
  349. void (*clk_disable_unused)(struct clk *clk);
  350. };
  351. extern int mpurate;
  352. extern int clk_init(struct clk_functions *custom_clocks);
  353. extern void clk_preinit(struct clk *clk);
  354. extern int clk_register(struct clk *clk);
  355. extern void clk_reparent(struct clk *child, struct clk *parent);
  356. extern void clk_unregister(struct clk *clk);
  357. extern void propagate_rate(struct clk *clk);
  358. extern void recalculate_root_clocks(void);
  359. extern unsigned long followparent_recalc(struct clk *clk);
  360. extern void clk_enable_init_clocks(void);
  361. unsigned long omap_fixed_divisor_recalc(struct clk *clk);
  362. extern struct clk *omap_clk_get_by_name(const char *name);
  363. extern int omap_clk_enable_autoidle_all(void);
  364. extern int omap_clk_disable_autoidle_all(void);
  365. extern const struct clkops clkops_null;
  366. extern struct clk dummy_ck;
  367. #endif /* CONFIG_COMMON_CLK */
  368. /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */
  369. #define CORE_CLK_SRC_32K 0x0
  370. #define CORE_CLK_SRC_DPLL 0x1
  371. #define CORE_CLK_SRC_DPLL_X2 0x2
  372. /* OMAP2xxx CM_CLKEN_PLL.EN_DPLL bits - for omap2_get_dpll_rate() */
  373. #define OMAP2XXX_EN_DPLL_LPBYPASS 0x1
  374. #define OMAP2XXX_EN_DPLL_FRBYPASS 0x2
  375. #define OMAP2XXX_EN_DPLL_LOCKED 0x3
  376. /* OMAP3xxx CM_CLKEN_PLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
  377. #define OMAP3XXX_EN_DPLL_LPBYPASS 0x5
  378. #define OMAP3XXX_EN_DPLL_FRBYPASS 0x6
  379. #define OMAP3XXX_EN_DPLL_LOCKED 0x7
  380. /* OMAP4xxx CM_CLKMODE_DPLL*.EN_*_DPLL bits - for omap2_get_dpll_rate() */
  381. #define OMAP4XXX_EN_DPLL_MNBYPASS 0x4
  382. #define OMAP4XXX_EN_DPLL_LPBYPASS 0x5
  383. #define OMAP4XXX_EN_DPLL_FRBYPASS 0x6
  384. #define OMAP4XXX_EN_DPLL_LOCKED 0x7
  385. /* CM_CLKEN_PLL*.EN* bit values - not all are available for every DPLL */
  386. #define DPLL_LOW_POWER_STOP 0x1
  387. #define DPLL_LOW_POWER_BYPASS 0x5
  388. #define DPLL_LOCKED 0x7
  389. /* DPLL Type and DCO Selection Flags */
  390. #define DPLL_J_TYPE 0x1
  391. #ifndef CONFIG_COMMON_CLK
  392. int omap2_clk_enable(struct clk *clk);
  393. void omap2_clk_disable(struct clk *clk);
  394. long omap2_clk_round_rate(struct clk *clk, unsigned long rate);
  395. int omap2_clk_set_rate(struct clk *clk, unsigned long rate);
  396. int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent);
  397. #endif /* CONFIG_COMMON_CLK */
  398. #ifdef CONFIG_COMMON_CLK
  399. long omap2_dpll_round_rate(struct clk_hw *hw, unsigned long target_rate,
  400. unsigned long *parent_rate);
  401. unsigned long omap3_dpll_recalc(struct clk_hw *hw, unsigned long parent_rate);
  402. int omap3_noncore_dpll_enable(struct clk_hw *hw);
  403. void omap3_noncore_dpll_disable(struct clk_hw *hw);
  404. int omap3_noncore_dpll_set_rate(struct clk_hw *hw, unsigned long rate,
  405. unsigned long parent_rate);
  406. u32 omap3_dpll_autoidle_read(struct clk_hw_omap *clk);
  407. void omap3_dpll_allow_idle(struct clk_hw_omap *clk);
  408. void omap3_dpll_deny_idle(struct clk_hw_omap *clk);
  409. unsigned long omap3_clkoutx2_recalc(struct clk_hw *hw,
  410. unsigned long parent_rate);
  411. int omap4_dpllmx_gatectrl_read(struct clk_hw_omap *clk);
  412. void omap4_dpllmx_allow_gatectrl(struct clk_hw_omap *clk);
  413. void omap4_dpllmx_deny_gatectrl(struct clk_hw_omap *clk);
  414. unsigned long omap4_dpll_regm4xen_recalc(struct clk_hw *hw,
  415. unsigned long parent_rate);
  416. long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
  417. unsigned long target_rate,
  418. unsigned long *parent_rate);
  419. #else
  420. long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate);
  421. unsigned long omap3_dpll_recalc(struct clk *clk);
  422. unsigned long omap3_clkoutx2_recalc(struct clk *clk);
  423. void omap3_dpll_allow_idle(struct clk *clk);
  424. void omap3_dpll_deny_idle(struct clk *clk);
  425. u32 omap3_dpll_autoidle_read(struct clk *clk);
  426. int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
  427. int omap3_noncore_dpll_enable(struct clk *clk);
  428. void omap3_noncore_dpll_disable(struct clk *clk);
  429. int omap4_dpllmx_gatectrl_read(struct clk *clk);
  430. void omap4_dpllmx_allow_gatectrl(struct clk *clk);
  431. void omap4_dpllmx_deny_gatectrl(struct clk *clk);
  432. long omap4_dpll_regm4xen_round_rate(struct clk *clk, unsigned long target_rate);
  433. unsigned long omap4_dpll_regm4xen_recalc(struct clk *clk);
  434. #endif
  435. #ifdef CONFIG_OMAP_RESET_CLOCKS
  436. void omap2_clk_disable_unused(struct clk *clk);
  437. #else
  438. #define omap2_clk_disable_unused NULL
  439. #endif
  440. #ifdef CONFIG_COMMON_CLK
  441. void omap2_init_clk_clkdm(struct clk_hw *clk);
  442. #else
  443. void omap2_init_clk_clkdm(struct clk *clk);
  444. #endif
  445. void __init omap2_clk_disable_clkdm_control(void);
  446. /* clkt_clksel.c public functions */
  447. #ifdef CONFIG_COMMON_CLK
  448. u32 omap2_clksel_round_rate_div(struct clk_hw_omap *clk,
  449. unsigned long target_rate,
  450. u32 *new_div);
  451. u8 omap2_clksel_find_parent_index(struct clk_hw *hw);
  452. unsigned long omap2_clksel_recalc(struct clk_hw *hw, unsigned long parent_rate);
  453. long omap2_clksel_round_rate(struct clk_hw *hw, unsigned long target_rate,
  454. unsigned long *parent_rate);
  455. int omap2_clksel_set_rate(struct clk_hw *hw, unsigned long rate,
  456. unsigned long parent_rate);
  457. int omap2_clksel_set_parent(struct clk_hw *hw, u8 field_val);
  458. #else
  459. u32 omap2_clksel_round_rate_div(struct clk *clk, unsigned long target_rate,
  460. u32 *new_div);
  461. void omap2_init_clksel_parent(struct clk *clk);
  462. unsigned long omap2_clksel_recalc(struct clk *clk);
  463. long omap2_clksel_round_rate(struct clk *clk, unsigned long target_rate);
  464. int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
  465. int omap2_clksel_set_parent(struct clk *clk, struct clk *new_parent);
  466. #endif
  467. /* clkt_iclk.c public functions */
  468. #ifdef CONFIG_COMMON_CLK
  469. extern void omap2_clkt_iclk_allow_idle(struct clk_hw_omap *clk);
  470. extern void omap2_clkt_iclk_deny_idle(struct clk_hw_omap *clk);
  471. #else
  472. extern void omap2_clkt_iclk_allow_idle(struct clk *clk);
  473. extern void omap2_clkt_iclk_deny_idle(struct clk *clk);
  474. #endif
  475. #ifdef CONFIG_COMMON_CLK
  476. u8 omap2_init_dpll_parent(struct clk_hw *hw);
  477. unsigned long omap2_get_dpll_rate(struct clk_hw_omap *clk);
  478. #else
  479. u32 omap2_get_dpll_rate(struct clk *clk);
  480. void omap2_init_dpll_parent(struct clk *clk);
  481. #endif
  482. #ifdef CONFIG_COMMON_CLK
  483. int omap2_dflt_clk_enable(struct clk_hw *hw);
  484. void omap2_dflt_clk_disable(struct clk_hw *hw);
  485. int omap2_dflt_clk_is_enabled(struct clk_hw *hw);
  486. void omap2_clk_dflt_find_companion(struct clk_hw_omap *clk,
  487. void __iomem **other_reg,
  488. u8 *other_bit);
  489. void omap2_clk_dflt_find_idlest(struct clk_hw_omap *clk,
  490. void __iomem **idlest_reg,
  491. u8 *idlest_bit, u8 *idlest_val);
  492. void omap2_init_clk_hw_omap_clocks(struct clk *clk);
  493. int omap2_clk_enable_autoidle_all(void);
  494. int omap2_clk_disable_autoidle_all(void);
  495. #else
  496. int omap2_dflt_clk_enable(struct clk *clk);
  497. void omap2_dflt_clk_disable(struct clk *clk);
  498. void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
  499. u8 *other_bit);
  500. void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
  501. u8 *idlest_bit, u8 *idlest_val);
  502. #endif
  503. int omap2_clk_switch_mpurate_at_boot(const char *mpurate_ck_name);
  504. void omap2_clk_print_new_rates(const char *hfclkin_ck_name,
  505. const char *core_ck_name,
  506. const char *mpu_ck_name);
  507. extern u16 cpu_mask;
  508. extern const struct clkops clkops_omap2_dflt_wait;
  509. extern const struct clkops clkops_dummy;
  510. extern const struct clkops clkops_omap2_dflt;
  511. extern struct clk_functions omap2_clk_functions;
  512. extern const struct clksel_rate gpt_32k_rates[];
  513. extern const struct clksel_rate gpt_sys_rates[];
  514. extern const struct clksel_rate gfx_l3_rates[];
  515. extern const struct clksel_rate dsp_ick_rates[];
  516. #ifdef CONFIG_COMMON_CLK
  517. extern const struct clk_hw_omap_ops clkhwops_omap3_dpll;
  518. extern const struct clk_hw_omap_ops clkhwops_iclk_wait;
  519. extern const struct clk_hw_omap_ops clkhwops_wait;
  520. extern const struct clk_hw_omap_ops clkhwops_omap4_dpllmx;
  521. extern const struct clk_hw_omap_ops clkhwops_iclk;
  522. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_ssi_wait;
  523. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_ssi_wait;
  524. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_dss_usbhost_wait;
  525. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_dss_usbhost_wait;
  526. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_iclk_hsotgusb_wait;
  527. extern const struct clk_hw_omap_ops clkhwops_omap3430es2_hsotgusb_wait;
  528. extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_module_wait;
  529. extern const struct clk_hw_omap_ops clkhwops_am35xx_ipss_wait;
  530. extern const struct clk_hw_omap_ops clkhwops_apll54;
  531. extern const struct clk_hw_omap_ops clkhwops_apll96;
  532. extern const struct clk_hw_omap_ops clkhwops_omap2xxx_dpll;
  533. extern const struct clk_hw_omap_ops clkhwops_omap2430_i2chs_wait;
  534. #else
  535. extern const struct clkops clkops_omap2_iclk_dflt_wait;
  536. extern const struct clkops clkops_omap2_iclk_dflt;
  537. extern const struct clkops clkops_omap2_iclk_idle_only;
  538. extern const struct clkops clkops_omap2_mdmclk_dflt_wait;
  539. extern const struct clkops clkops_omap2xxx_dpll_ops;
  540. extern const struct clkops clkops_omap3_noncore_dpll_ops;
  541. extern const struct clkops clkops_omap3_core_dpll_ops;
  542. extern const struct clkops clkops_omap4_dpllmx_ops;
  543. #endif /* CONFIG_COMMON_CLK */
  544. /* clksel_rate blocks shared between OMAP44xx and AM33xx */
  545. extern const struct clksel_rate div_1_0_rates[];
  546. extern const struct clksel_rate div_1_1_rates[];
  547. extern const struct clksel_rate div_1_2_rates[];
  548. extern const struct clksel_rate div_1_3_rates[];
  549. extern const struct clksel_rate div_1_4_rates[];
  550. extern const struct clksel_rate div31_1to31_rates[];
  551. #ifndef CONFIG_COMMON_CLK
  552. /* clocks shared between various OMAP SoCs */
  553. extern struct clk virt_19200000_ck;
  554. extern struct clk virt_26000000_ck;
  555. #endif
  556. extern int am33xx_clk_init(void);
  557. #ifdef CONFIG_COMMON_CLK
  558. extern int omap2_clkops_enable_clkdm(struct clk_hw *hw);
  559. extern void omap2_clkops_disable_clkdm(struct clk_hw *hw);
  560. #endif
  561. #endif