dpll.c 20 KB

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