dpll.c 19 KB

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