dpll.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. /*
  2. * OMAP DPLL clock support
  3. *
  4. * Copyright (C) 2013 Texas Instruments, Inc.
  5. *
  6. * Tero Kristo <t-kristo@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  13. * kind, whether express or implied; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/clk.h>
  18. #include <linux/clk-provider.h>
  19. #include <linux/slab.h>
  20. #include <linux/err.h>
  21. #include <linux/of.h>
  22. #include <linux/of_address.h>
  23. #include <linux/clk/ti.h>
  24. #include "clock.h"
  25. #undef pr_fmt
  26. #define pr_fmt(fmt) "%s: " fmt, __func__
  27. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  28. defined(CONFIG_SOC_DRA7XX)
  29. static const struct clk_ops dpll_m4xen_ck_ops = {
  30. .enable = &omap3_noncore_dpll_enable,
  31. .disable = &omap3_noncore_dpll_disable,
  32. .recalc_rate = &omap4_dpll_regm4xen_recalc,
  33. .round_rate = &omap4_dpll_regm4xen_round_rate,
  34. .set_rate = &omap3_noncore_dpll_set_rate,
  35. .set_parent = &omap3_noncore_dpll_set_parent,
  36. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  37. .determine_rate = &omap4_dpll_regm4xen_determine_rate,
  38. .get_parent = &omap2_init_dpll_parent,
  39. };
  40. #else
  41. static const struct clk_ops dpll_m4xen_ck_ops = {};
  42. #endif
  43. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
  44. defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
  45. defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  46. static const struct clk_ops dpll_core_ck_ops = {
  47. .recalc_rate = &omap3_dpll_recalc,
  48. .get_parent = &omap2_init_dpll_parent,
  49. };
  50. static const struct clk_ops dpll_ck_ops = {
  51. .enable = &omap3_noncore_dpll_enable,
  52. .disable = &omap3_noncore_dpll_disable,
  53. .recalc_rate = &omap3_dpll_recalc,
  54. .round_rate = &omap2_dpll_round_rate,
  55. .set_rate = &omap3_noncore_dpll_set_rate,
  56. .set_parent = &omap3_noncore_dpll_set_parent,
  57. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  58. .determine_rate = &omap3_noncore_dpll_determine_rate,
  59. .get_parent = &omap2_init_dpll_parent,
  60. };
  61. static const struct clk_ops dpll_no_gate_ck_ops = {
  62. .recalc_rate = &omap3_dpll_recalc,
  63. .get_parent = &omap2_init_dpll_parent,
  64. .round_rate = &omap2_dpll_round_rate,
  65. .set_rate = &omap3_noncore_dpll_set_rate,
  66. .set_parent = &omap3_noncore_dpll_set_parent,
  67. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  68. .determine_rate = &omap3_noncore_dpll_determine_rate,
  69. };
  70. #else
  71. static const struct clk_ops dpll_core_ck_ops = {};
  72. static const struct clk_ops dpll_ck_ops = {};
  73. static const struct clk_ops dpll_no_gate_ck_ops = {};
  74. const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
  75. #endif
  76. #ifdef CONFIG_ARCH_OMAP2
  77. static const struct clk_ops omap2_dpll_core_ck_ops = {
  78. .get_parent = &omap2_init_dpll_parent,
  79. .recalc_rate = &omap2_dpllcore_recalc,
  80. .round_rate = &omap2_dpll_round_rate,
  81. .set_rate = &omap2_reprogram_dpllcore,
  82. };
  83. #else
  84. static const struct clk_ops omap2_dpll_core_ck_ops = {};
  85. #endif
  86. #ifdef CONFIG_ARCH_OMAP3
  87. static const struct clk_ops omap3_dpll_core_ck_ops = {
  88. .get_parent = &omap2_init_dpll_parent,
  89. .recalc_rate = &omap3_dpll_recalc,
  90. .round_rate = &omap2_dpll_round_rate,
  91. };
  92. #else
  93. static const struct clk_ops omap3_dpll_core_ck_ops = {};
  94. #endif
  95. #ifdef CONFIG_ARCH_OMAP3
  96. static const struct clk_ops omap3_dpll_ck_ops = {
  97. .enable = &omap3_noncore_dpll_enable,
  98. .disable = &omap3_noncore_dpll_disable,
  99. .get_parent = &omap2_init_dpll_parent,
  100. .recalc_rate = &omap3_dpll_recalc,
  101. .set_rate = &omap3_noncore_dpll_set_rate,
  102. .set_parent = &omap3_noncore_dpll_set_parent,
  103. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  104. .determine_rate = &omap3_noncore_dpll_determine_rate,
  105. .round_rate = &omap2_dpll_round_rate,
  106. };
  107. static const struct clk_ops omap3_dpll_per_ck_ops = {
  108. .enable = &omap3_noncore_dpll_enable,
  109. .disable = &omap3_noncore_dpll_disable,
  110. .get_parent = &omap2_init_dpll_parent,
  111. .recalc_rate = &omap3_dpll_recalc,
  112. .set_rate = &omap3_dpll4_set_rate,
  113. .set_parent = &omap3_noncore_dpll_set_parent,
  114. .set_rate_and_parent = &omap3_dpll4_set_rate_and_parent,
  115. .determine_rate = &omap3_noncore_dpll_determine_rate,
  116. .round_rate = &omap2_dpll_round_rate,
  117. };
  118. #endif
  119. static const struct clk_ops dpll_x2_ck_ops = {
  120. .recalc_rate = &omap3_clkoutx2_recalc,
  121. };
  122. /**
  123. * _register_dpll - low level registration of a DPLL clock
  124. * @hw: hardware clock definition for the clock
  125. * @node: device node for the clock
  126. *
  127. * Finalizes DPLL registration process. In case a failure (clk-ref or
  128. * clk-bypass is missing), the clock is added to retry list and
  129. * the initialization is retried on later stage.
  130. */
  131. static void __init _register_dpll(struct clk_hw *hw,
  132. struct device_node *node)
  133. {
  134. struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
  135. struct dpll_data *dd = clk_hw->dpll_data;
  136. struct clk *clk;
  137. dd->clk_ref = of_clk_get(node, 0);
  138. dd->clk_bypass = of_clk_get(node, 1);
  139. if (IS_ERR(dd->clk_ref) || IS_ERR(dd->clk_bypass)) {
  140. pr_debug("clk-ref or clk-bypass missing for %s, retry later\n",
  141. node->name);
  142. if (!ti_clk_retry_init(node, hw, _register_dpll))
  143. return;
  144. goto cleanup;
  145. }
  146. /* register the clock */
  147. clk = clk_register(NULL, &clk_hw->hw);
  148. if (!IS_ERR(clk)) {
  149. omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
  150. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  151. kfree(clk_hw->hw.init->parent_names);
  152. kfree(clk_hw->hw.init);
  153. return;
  154. }
  155. cleanup:
  156. kfree(clk_hw->dpll_data);
  157. kfree(clk_hw->hw.init->parent_names);
  158. kfree(clk_hw->hw.init);
  159. kfree(clk_hw);
  160. }
  161. #if defined(CONFIG_ARCH_OMAP3) && defined(CONFIG_ATAGS)
  162. static void __iomem *_get_reg(u8 module, u16 offset)
  163. {
  164. u32 reg;
  165. struct clk_omap_reg *reg_setup;
  166. reg_setup = (struct clk_omap_reg *)&reg;
  167. reg_setup->index = module;
  168. reg_setup->offset = offset;
  169. return (void __iomem *)reg;
  170. }
  171. struct clk *ti_clk_register_dpll(struct ti_clk *setup)
  172. {
  173. struct clk_hw_omap *clk_hw;
  174. struct clk_init_data init = { NULL };
  175. struct dpll_data *dd;
  176. struct clk *clk;
  177. struct ti_clk_dpll *dpll;
  178. const struct clk_ops *ops = &omap3_dpll_ck_ops;
  179. struct clk *clk_ref;
  180. struct clk *clk_bypass;
  181. dpll = setup->data;
  182. if (dpll->num_parents < 2)
  183. return ERR_PTR(-EINVAL);
  184. clk_ref = clk_get_sys(NULL, dpll->parents[0]);
  185. clk_bypass = clk_get_sys(NULL, dpll->parents[1]);
  186. if (IS_ERR_OR_NULL(clk_ref) || IS_ERR_OR_NULL(clk_bypass))
  187. return ERR_PTR(-EAGAIN);
  188. dd = kzalloc(sizeof(*dd), GFP_KERNEL);
  189. clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
  190. if (!dd || !clk_hw) {
  191. clk = ERR_PTR(-ENOMEM);
  192. goto cleanup;
  193. }
  194. clk_hw->dpll_data = dd;
  195. clk_hw->ops = &clkhwops_omap3_dpll;
  196. clk_hw->hw.init = &init;
  197. clk_hw->flags = MEMMAP_ADDRESSING;
  198. init.name = setup->name;
  199. init.ops = ops;
  200. init.num_parents = dpll->num_parents;
  201. init.parent_names = dpll->parents;
  202. dd->control_reg = _get_reg(dpll->module, dpll->control_reg);
  203. dd->idlest_reg = _get_reg(dpll->module, dpll->idlest_reg);
  204. dd->mult_div1_reg = _get_reg(dpll->module, dpll->mult_div1_reg);
  205. dd->autoidle_reg = _get_reg(dpll->module, dpll->autoidle_reg);
  206. dd->modes = dpll->modes;
  207. dd->div1_mask = dpll->div1_mask;
  208. dd->idlest_mask = dpll->idlest_mask;
  209. dd->mult_mask = dpll->mult_mask;
  210. dd->autoidle_mask = dpll->autoidle_mask;
  211. dd->enable_mask = dpll->enable_mask;
  212. dd->sddiv_mask = dpll->sddiv_mask;
  213. dd->dco_mask = dpll->dco_mask;
  214. dd->max_divider = dpll->max_divider;
  215. dd->min_divider = dpll->min_divider;
  216. dd->max_multiplier = dpll->max_multiplier;
  217. dd->auto_recal_bit = dpll->auto_recal_bit;
  218. dd->recal_en_bit = dpll->recal_en_bit;
  219. dd->recal_st_bit = dpll->recal_st_bit;
  220. dd->clk_ref = clk_ref;
  221. dd->clk_bypass = clk_bypass;
  222. if (dpll->flags & CLKF_CORE)
  223. ops = &omap3_dpll_core_ck_ops;
  224. if (dpll->flags & CLKF_PER)
  225. ops = &omap3_dpll_per_ck_ops;
  226. if (dpll->flags & CLKF_J_TYPE)
  227. dd->flags |= DPLL_J_TYPE;
  228. clk = clk_register(NULL, &clk_hw->hw);
  229. if (!IS_ERR(clk))
  230. return clk;
  231. cleanup:
  232. kfree(dd);
  233. kfree(clk_hw);
  234. return clk;
  235. }
  236. #endif
  237. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  238. defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
  239. defined(CONFIG_SOC_AM43XX)
  240. /**
  241. * _register_dpll_x2 - Registers a DPLLx2 clock
  242. * @node: device node for this clock
  243. * @ops: clk_ops for this clock
  244. * @hw_ops: clk_hw_ops for this clock
  245. *
  246. * Initializes a DPLL x 2 clock from device tree data.
  247. */
  248. static void _register_dpll_x2(struct device_node *node,
  249. const struct clk_ops *ops,
  250. const struct clk_hw_omap_ops *hw_ops)
  251. {
  252. struct clk *clk;
  253. struct clk_init_data init = { NULL };
  254. struct clk_hw_omap *clk_hw;
  255. const char *name = node->name;
  256. const char *parent_name;
  257. parent_name = of_clk_get_parent_name(node, 0);
  258. if (!parent_name) {
  259. pr_err("%s must have parent\n", node->name);
  260. return;
  261. }
  262. clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
  263. if (!clk_hw)
  264. return;
  265. clk_hw->ops = hw_ops;
  266. clk_hw->hw.init = &init;
  267. init.name = name;
  268. init.ops = ops;
  269. init.parent_names = &parent_name;
  270. init.num_parents = 1;
  271. /* register the clock */
  272. clk = clk_register(NULL, &clk_hw->hw);
  273. if (IS_ERR(clk)) {
  274. kfree(clk_hw);
  275. } else {
  276. omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
  277. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  278. }
  279. }
  280. #endif
  281. /**
  282. * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
  283. * @node: device node containing the DPLL info
  284. * @ops: ops for the DPLL
  285. * @ddt: DPLL data template to use
  286. *
  287. * Initializes a DPLL clock from device tree data.
  288. */
  289. static void __init of_ti_dpll_setup(struct device_node *node,
  290. const struct clk_ops *ops,
  291. const struct dpll_data *ddt)
  292. {
  293. struct clk_hw_omap *clk_hw = NULL;
  294. struct clk_init_data *init = NULL;
  295. const char **parent_names = NULL;
  296. struct dpll_data *dd = NULL;
  297. u8 dpll_mode = 0;
  298. dd = kzalloc(sizeof(*dd), GFP_KERNEL);
  299. clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
  300. init = kzalloc(sizeof(*init), GFP_KERNEL);
  301. if (!dd || !clk_hw || !init)
  302. goto cleanup;
  303. memcpy(dd, ddt, sizeof(*dd));
  304. clk_hw->dpll_data = dd;
  305. clk_hw->ops = &clkhwops_omap3_dpll;
  306. clk_hw->hw.init = init;
  307. clk_hw->flags = MEMMAP_ADDRESSING;
  308. init->name = node->name;
  309. init->ops = ops;
  310. init->num_parents = of_clk_get_parent_count(node);
  311. if (init->num_parents < 1) {
  312. pr_err("%s must have parent(s)\n", node->name);
  313. goto cleanup;
  314. }
  315. parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
  316. if (!parent_names)
  317. goto cleanup;
  318. of_clk_parent_fill(node, parent_names, init->num_parents);
  319. init->parent_names = parent_names;
  320. dd->control_reg = ti_clk_get_reg_addr(node, 0);
  321. /*
  322. * Special case for OMAP2 DPLL, register order is different due to
  323. * missing idlest_reg, also clkhwops is different. Detected from
  324. * missing idlest_mask.
  325. */
  326. if (!dd->idlest_mask) {
  327. dd->mult_div1_reg = ti_clk_get_reg_addr(node, 1);
  328. #ifdef CONFIG_ARCH_OMAP2
  329. clk_hw->ops = &clkhwops_omap2xxx_dpll;
  330. omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
  331. #endif
  332. } else {
  333. dd->idlest_reg = ti_clk_get_reg_addr(node, 1);
  334. if (IS_ERR(dd->idlest_reg))
  335. goto cleanup;
  336. dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2);
  337. }
  338. if (IS_ERR(dd->control_reg) || IS_ERR(dd->mult_div1_reg))
  339. goto cleanup;
  340. if (dd->autoidle_mask) {
  341. dd->autoidle_reg = ti_clk_get_reg_addr(node, 3);
  342. if (IS_ERR(dd->autoidle_reg))
  343. goto cleanup;
  344. }
  345. if (of_property_read_bool(node, "ti,low-power-stop"))
  346. dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
  347. if (of_property_read_bool(node, "ti,low-power-bypass"))
  348. dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
  349. if (of_property_read_bool(node, "ti,lock"))
  350. dpll_mode |= 1 << DPLL_LOCKED;
  351. if (dpll_mode)
  352. dd->modes = dpll_mode;
  353. _register_dpll(&clk_hw->hw, node);
  354. return;
  355. cleanup:
  356. kfree(dd);
  357. kfree(parent_names);
  358. kfree(init);
  359. kfree(clk_hw);
  360. }
  361. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  362. defined(CONFIG_SOC_DRA7XX)
  363. static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
  364. {
  365. _register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
  366. }
  367. CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
  368. of_ti_omap4_dpll_x2_setup);
  369. #endif
  370. #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  371. static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
  372. {
  373. _register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
  374. }
  375. CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
  376. of_ti_am3_dpll_x2_setup);
  377. #endif
  378. #ifdef CONFIG_ARCH_OMAP3
  379. static void __init of_ti_omap3_dpll_setup(struct device_node *node)
  380. {
  381. const struct dpll_data dd = {
  382. .idlest_mask = 0x1,
  383. .enable_mask = 0x7,
  384. .autoidle_mask = 0x7,
  385. .mult_mask = 0x7ff << 8,
  386. .div1_mask = 0x7f,
  387. .max_multiplier = 2047,
  388. .max_divider = 128,
  389. .min_divider = 1,
  390. .freqsel_mask = 0xf0,
  391. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  392. };
  393. of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
  394. }
  395. CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
  396. of_ti_omap3_dpll_setup);
  397. static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
  398. {
  399. const struct dpll_data dd = {
  400. .idlest_mask = 0x1,
  401. .enable_mask = 0x7,
  402. .autoidle_mask = 0x7,
  403. .mult_mask = 0x7ff << 16,
  404. .div1_mask = 0x7f << 8,
  405. .max_multiplier = 2047,
  406. .max_divider = 128,
  407. .min_divider = 1,
  408. .freqsel_mask = 0xf0,
  409. };
  410. of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
  411. }
  412. CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
  413. of_ti_omap3_core_dpll_setup);
  414. static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
  415. {
  416. const struct dpll_data dd = {
  417. .idlest_mask = 0x1 << 1,
  418. .enable_mask = 0x7 << 16,
  419. .autoidle_mask = 0x7 << 3,
  420. .mult_mask = 0x7ff << 8,
  421. .div1_mask = 0x7f,
  422. .max_multiplier = 2047,
  423. .max_divider = 128,
  424. .min_divider = 1,
  425. .freqsel_mask = 0xf00000,
  426. .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
  427. };
  428. of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
  429. }
  430. CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
  431. of_ti_omap3_per_dpll_setup);
  432. static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
  433. {
  434. const struct dpll_data dd = {
  435. .idlest_mask = 0x1 << 1,
  436. .enable_mask = 0x7 << 16,
  437. .autoidle_mask = 0x7 << 3,
  438. .mult_mask = 0xfff << 8,
  439. .div1_mask = 0x7f,
  440. .max_multiplier = 4095,
  441. .max_divider = 128,
  442. .min_divider = 1,
  443. .sddiv_mask = 0xff << 24,
  444. .dco_mask = 0xe << 20,
  445. .flags = DPLL_J_TYPE,
  446. .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
  447. };
  448. of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
  449. }
  450. CLK_OF_DECLARE(ti_omap3_per_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
  451. of_ti_omap3_per_jtype_dpll_setup);
  452. #endif
  453. static void __init of_ti_omap4_dpll_setup(struct device_node *node)
  454. {
  455. const struct dpll_data dd = {
  456. .idlest_mask = 0x1,
  457. .enable_mask = 0x7,
  458. .autoidle_mask = 0x7,
  459. .mult_mask = 0x7ff << 8,
  460. .div1_mask = 0x7f,
  461. .max_multiplier = 2047,
  462. .max_divider = 128,
  463. .min_divider = 1,
  464. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  465. };
  466. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  467. }
  468. CLK_OF_DECLARE(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
  469. of_ti_omap4_dpll_setup);
  470. static void __init of_ti_omap5_mpu_dpll_setup(struct device_node *node)
  471. {
  472. const struct dpll_data dd = {
  473. .idlest_mask = 0x1,
  474. .enable_mask = 0x7,
  475. .autoidle_mask = 0x7,
  476. .mult_mask = 0x7ff << 8,
  477. .div1_mask = 0x7f,
  478. .max_multiplier = 2047,
  479. .max_divider = 128,
  480. .dcc_mask = BIT(22),
  481. .dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
  482. .min_divider = 1,
  483. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  484. };
  485. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  486. }
  487. CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
  488. of_ti_omap5_mpu_dpll_setup);
  489. static void __init of_ti_omap4_core_dpll_setup(struct device_node *node)
  490. {
  491. const struct dpll_data dd = {
  492. .idlest_mask = 0x1,
  493. .enable_mask = 0x7,
  494. .autoidle_mask = 0x7,
  495. .mult_mask = 0x7ff << 8,
  496. .div1_mask = 0x7f,
  497. .max_multiplier = 2047,
  498. .max_divider = 128,
  499. .min_divider = 1,
  500. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  501. };
  502. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  503. }
  504. CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
  505. of_ti_omap4_core_dpll_setup);
  506. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  507. defined(CONFIG_SOC_DRA7XX)
  508. static void __init of_ti_omap4_m4xen_dpll_setup(struct device_node *node)
  509. {
  510. const struct dpll_data dd = {
  511. .idlest_mask = 0x1,
  512. .enable_mask = 0x7,
  513. .autoidle_mask = 0x7,
  514. .mult_mask = 0x7ff << 8,
  515. .div1_mask = 0x7f,
  516. .max_multiplier = 2047,
  517. .max_divider = 128,
  518. .min_divider = 1,
  519. .m4xen_mask = 0x800,
  520. .lpmode_mask = 1 << 10,
  521. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  522. };
  523. of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
  524. }
  525. CLK_OF_DECLARE(ti_omap4_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
  526. of_ti_omap4_m4xen_dpll_setup);
  527. static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
  528. {
  529. const struct dpll_data dd = {
  530. .idlest_mask = 0x1,
  531. .enable_mask = 0x7,
  532. .autoidle_mask = 0x7,
  533. .mult_mask = 0xfff << 8,
  534. .div1_mask = 0xff,
  535. .max_multiplier = 4095,
  536. .max_divider = 256,
  537. .min_divider = 1,
  538. .sddiv_mask = 0xff << 24,
  539. .flags = DPLL_J_TYPE,
  540. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  541. };
  542. of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
  543. }
  544. CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
  545. of_ti_omap4_jtype_dpll_setup);
  546. #endif
  547. static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
  548. {
  549. const struct dpll_data dd = {
  550. .idlest_mask = 0x1,
  551. .enable_mask = 0x7,
  552. .mult_mask = 0x7ff << 8,
  553. .div1_mask = 0x7f,
  554. .max_multiplier = 2047,
  555. .max_divider = 128,
  556. .min_divider = 1,
  557. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  558. };
  559. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  560. }
  561. CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
  562. of_ti_am3_no_gate_dpll_setup);
  563. static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
  564. {
  565. const struct dpll_data dd = {
  566. .idlest_mask = 0x1,
  567. .enable_mask = 0x7,
  568. .mult_mask = 0x7ff << 8,
  569. .div1_mask = 0x7f,
  570. .max_multiplier = 4095,
  571. .max_divider = 256,
  572. .min_divider = 2,
  573. .flags = DPLL_J_TYPE,
  574. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  575. };
  576. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  577. }
  578. CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
  579. of_ti_am3_jtype_dpll_setup);
  580. static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
  581. {
  582. const struct dpll_data dd = {
  583. .idlest_mask = 0x1,
  584. .enable_mask = 0x7,
  585. .mult_mask = 0x7ff << 8,
  586. .div1_mask = 0x7f,
  587. .max_multiplier = 2047,
  588. .max_divider = 128,
  589. .min_divider = 1,
  590. .flags = DPLL_J_TYPE,
  591. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  592. };
  593. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  594. }
  595. CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
  596. "ti,am3-dpll-no-gate-j-type-clock",
  597. of_ti_am3_no_gate_jtype_dpll_setup);
  598. static void __init of_ti_am3_dpll_setup(struct device_node *node)
  599. {
  600. const struct dpll_data dd = {
  601. .idlest_mask = 0x1,
  602. .enable_mask = 0x7,
  603. .mult_mask = 0x7ff << 8,
  604. .div1_mask = 0x7f,
  605. .max_multiplier = 2047,
  606. .max_divider = 128,
  607. .min_divider = 1,
  608. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  609. };
  610. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  611. }
  612. CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
  613. static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
  614. {
  615. const struct dpll_data dd = {
  616. .idlest_mask = 0x1,
  617. .enable_mask = 0x7,
  618. .mult_mask = 0x7ff << 8,
  619. .div1_mask = 0x7f,
  620. .max_multiplier = 2047,
  621. .max_divider = 128,
  622. .min_divider = 1,
  623. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  624. };
  625. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  626. }
  627. CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
  628. of_ti_am3_core_dpll_setup);
  629. static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
  630. {
  631. const struct dpll_data dd = {
  632. .enable_mask = 0x3,
  633. .mult_mask = 0x3ff << 12,
  634. .div1_mask = 0xf << 8,
  635. .max_divider = 16,
  636. .min_divider = 1,
  637. };
  638. of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
  639. }
  640. CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
  641. of_ti_omap2_core_dpll_setup);