dpll.c 21 KB

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