clock.h 25 KB

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