dpll.c 21 KB

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