dpll.c 21 KB

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