dpll.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * OMAP DPLL clock support
  4. *
  5. * Copyright (C) 2013 Texas Instruments, Inc.
  6. *
  7. * Tero Kristo <[email protected]>
  8. */
  9. #include <linux/clk.h>
  10. #include <linux/clk-provider.h>
  11. #include <linux/slab.h>
  12. #include <linux/err.h>
  13. #include <linux/of.h>
  14. #include <linux/of_address.h>
  15. #include <linux/clk/ti.h>
  16. #include "clock.h"
  17. #undef pr_fmt
  18. #define pr_fmt(fmt) "%s: " fmt, __func__
  19. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  20. defined(CONFIG_SOC_DRA7XX)
  21. static const struct clk_ops dpll_m4xen_ck_ops = {
  22. .enable = &omap3_noncore_dpll_enable,
  23. .disable = &omap3_noncore_dpll_disable,
  24. .recalc_rate = &omap4_dpll_regm4xen_recalc,
  25. .round_rate = &omap4_dpll_regm4xen_round_rate,
  26. .set_rate = &omap3_noncore_dpll_set_rate,
  27. .set_parent = &omap3_noncore_dpll_set_parent,
  28. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  29. .determine_rate = &omap4_dpll_regm4xen_determine_rate,
  30. .get_parent = &omap2_init_dpll_parent,
  31. .save_context = &omap3_core_dpll_save_context,
  32. .restore_context = &omap3_core_dpll_restore_context,
  33. };
  34. #else
  35. static const struct clk_ops dpll_m4xen_ck_ops = {};
  36. #endif
  37. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
  38. defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
  39. defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  40. static const struct clk_ops dpll_core_ck_ops = {
  41. .recalc_rate = &omap3_dpll_recalc,
  42. .get_parent = &omap2_init_dpll_parent,
  43. };
  44. static const struct clk_ops dpll_ck_ops = {
  45. .enable = &omap3_noncore_dpll_enable,
  46. .disable = &omap3_noncore_dpll_disable,
  47. .recalc_rate = &omap3_dpll_recalc,
  48. .round_rate = &omap2_dpll_round_rate,
  49. .set_rate = &omap3_noncore_dpll_set_rate,
  50. .set_parent = &omap3_noncore_dpll_set_parent,
  51. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  52. .determine_rate = &omap3_noncore_dpll_determine_rate,
  53. .get_parent = &omap2_init_dpll_parent,
  54. .save_context = &omap3_noncore_dpll_save_context,
  55. .restore_context = &omap3_noncore_dpll_restore_context,
  56. };
  57. static const struct clk_ops dpll_no_gate_ck_ops = {
  58. .recalc_rate = &omap3_dpll_recalc,
  59. .get_parent = &omap2_init_dpll_parent,
  60. .round_rate = &omap2_dpll_round_rate,
  61. .set_rate = &omap3_noncore_dpll_set_rate,
  62. .set_parent = &omap3_noncore_dpll_set_parent,
  63. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  64. .determine_rate = &omap3_noncore_dpll_determine_rate,
  65. .save_context = &omap3_noncore_dpll_save_context,
  66. .restore_context = &omap3_noncore_dpll_restore_context
  67. };
  68. #else
  69. static const struct clk_ops dpll_core_ck_ops = {};
  70. static const struct clk_ops dpll_ck_ops = {};
  71. static const struct clk_ops dpll_no_gate_ck_ops = {};
  72. const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
  73. #endif
  74. #ifdef CONFIG_ARCH_OMAP2
  75. static const struct clk_ops omap2_dpll_core_ck_ops = {
  76. .get_parent = &omap2_init_dpll_parent,
  77. .recalc_rate = &omap2_dpllcore_recalc,
  78. .round_rate = &omap2_dpll_round_rate,
  79. .set_rate = &omap2_reprogram_dpllcore,
  80. };
  81. #else
  82. static const struct clk_ops omap2_dpll_core_ck_ops = {};
  83. #endif
  84. #ifdef CONFIG_ARCH_OMAP3
  85. static const struct clk_ops omap3_dpll_core_ck_ops = {
  86. .get_parent = &omap2_init_dpll_parent,
  87. .recalc_rate = &omap3_dpll_recalc,
  88. .round_rate = &omap2_dpll_round_rate,
  89. };
  90. #else
  91. static const struct clk_ops omap3_dpll_core_ck_ops = {};
  92. #endif
  93. #ifdef CONFIG_ARCH_OMAP3
  94. static const struct clk_ops omap3_dpll_ck_ops = {
  95. .enable = &omap3_noncore_dpll_enable,
  96. .disable = &omap3_noncore_dpll_disable,
  97. .get_parent = &omap2_init_dpll_parent,
  98. .recalc_rate = &omap3_dpll_recalc,
  99. .set_rate = &omap3_noncore_dpll_set_rate,
  100. .set_parent = &omap3_noncore_dpll_set_parent,
  101. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  102. .determine_rate = &omap3_noncore_dpll_determine_rate,
  103. .round_rate = &omap2_dpll_round_rate,
  104. };
  105. static const struct clk_ops omap3_dpll5_ck_ops = {
  106. .enable = &omap3_noncore_dpll_enable,
  107. .disable = &omap3_noncore_dpll_disable,
  108. .get_parent = &omap2_init_dpll_parent,
  109. .recalc_rate = &omap3_dpll_recalc,
  110. .set_rate = &omap3_dpll5_set_rate,
  111. .set_parent = &omap3_noncore_dpll_set_parent,
  112. .set_rate_and_parent = &omap3_noncore_dpll_set_rate_and_parent,
  113. .determine_rate = &omap3_noncore_dpll_determine_rate,
  114. .round_rate = &omap2_dpll_round_rate,
  115. };
  116. static const struct clk_ops omap3_dpll_per_ck_ops = {
  117. .enable = &omap3_noncore_dpll_enable,
  118. .disable = &omap3_noncore_dpll_disable,
  119. .get_parent = &omap2_init_dpll_parent,
  120. .recalc_rate = &omap3_dpll_recalc,
  121. .set_rate = &omap3_dpll4_set_rate,
  122. .set_parent = &omap3_noncore_dpll_set_parent,
  123. .set_rate_and_parent = &omap3_dpll4_set_rate_and_parent,
  124. .determine_rate = &omap3_noncore_dpll_determine_rate,
  125. .round_rate = &omap2_dpll_round_rate,
  126. };
  127. #endif
  128. static const struct clk_ops dpll_x2_ck_ops = {
  129. .recalc_rate = &omap3_clkoutx2_recalc,
  130. };
  131. /**
  132. * _register_dpll - low level registration of a DPLL clock
  133. * @user: pointer to the hardware clock definition for the clock
  134. * @node: device node for the clock
  135. *
  136. * Finalizes DPLL registration process. In case a failure (clk-ref or
  137. * clk-bypass is missing), the clock is added to retry list and
  138. * the initialization is retried on later stage.
  139. */
  140. static void __init _register_dpll(void *user,
  141. struct device_node *node)
  142. {
  143. struct clk_hw *hw = user;
  144. struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
  145. struct dpll_data *dd = clk_hw->dpll_data;
  146. const char *name;
  147. struct clk *clk;
  148. const struct clk_init_data *init = hw->init;
  149. clk = of_clk_get(node, 0);
  150. if (IS_ERR(clk)) {
  151. pr_debug("clk-ref missing for %pOFn, retry later\n",
  152. node);
  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 %pOFn, retry later\n",
  161. node);
  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. name = ti_dt_clk_name(node);
  169. clk = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
  170. if (!IS_ERR(clk)) {
  171. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  172. kfree(init->parent_names);
  173. kfree(init);
  174. return;
  175. }
  176. cleanup:
  177. kfree(clk_hw->dpll_data);
  178. kfree(init->parent_names);
  179. kfree(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 = ti_dt_clk_name(node);
  201. const char *parent_name;
  202. parent_name = of_clk_get_parent_name(node, 0);
  203. if (!parent_name) {
  204. pr_err("%pOFn must have parent\n", node);
  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 = of_ti_clk_register_omap_hw(node, &clk_hw->hw, name);
  232. if (IS_ERR(clk))
  233. kfree(clk_hw);
  234. else
  235. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  236. }
  237. #endif
  238. /**
  239. * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
  240. * @node: device node containing the DPLL info
  241. * @ops: ops for the DPLL
  242. * @ddt: DPLL data template to use
  243. *
  244. * Initializes a DPLL clock from device tree data.
  245. */
  246. static void __init of_ti_dpll_setup(struct device_node *node,
  247. const struct clk_ops *ops,
  248. const struct dpll_data *ddt)
  249. {
  250. struct clk_hw_omap *clk_hw = NULL;
  251. struct clk_init_data *init = NULL;
  252. const char **parent_names = NULL;
  253. struct dpll_data *dd = NULL;
  254. int ssc_clk_index;
  255. u8 dpll_mode = 0;
  256. u32 min_div;
  257. dd = kmemdup(ddt, 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. clk_hw->dpll_data = dd;
  263. clk_hw->ops = &clkhwops_omap3_dpll;
  264. clk_hw->hw.init = init;
  265. init->name = ti_dt_clk_name(node);
  266. init->ops = ops;
  267. init->num_parents = of_clk_get_parent_count(node);
  268. if (!init->num_parents) {
  269. pr_err("%pOFn must have parent(s)\n", node);
  270. goto cleanup;
  271. }
  272. parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
  273. if (!parent_names)
  274. goto cleanup;
  275. of_clk_parent_fill(node, parent_names, init->num_parents);
  276. init->parent_names = parent_names;
  277. if (ti_clk_get_reg_addr(node, 0, &dd->control_reg))
  278. goto cleanup;
  279. /*
  280. * Special case for OMAP2 DPLL, register order is different due to
  281. * missing idlest_reg, also clkhwops is different. Detected from
  282. * missing idlest_mask.
  283. */
  284. if (!dd->idlest_mask) {
  285. if (ti_clk_get_reg_addr(node, 1, &dd->mult_div1_reg))
  286. goto cleanup;
  287. #ifdef CONFIG_ARCH_OMAP2
  288. clk_hw->ops = &clkhwops_omap2xxx_dpll;
  289. omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
  290. #endif
  291. } else {
  292. if (ti_clk_get_reg_addr(node, 1, &dd->idlest_reg))
  293. goto cleanup;
  294. if (ti_clk_get_reg_addr(node, 2, &dd->mult_div1_reg))
  295. goto cleanup;
  296. }
  297. if (dd->autoidle_mask) {
  298. if (ti_clk_get_reg_addr(node, 3, &dd->autoidle_reg))
  299. goto cleanup;
  300. ssc_clk_index = 4;
  301. } else {
  302. ssc_clk_index = 3;
  303. }
  304. if (dd->ssc_deltam_int_mask && dd->ssc_deltam_frac_mask &&
  305. dd->ssc_modfreq_mant_mask && dd->ssc_modfreq_exp_mask) {
  306. if (ti_clk_get_reg_addr(node, ssc_clk_index++,
  307. &dd->ssc_deltam_reg))
  308. goto cleanup;
  309. if (ti_clk_get_reg_addr(node, ssc_clk_index++,
  310. &dd->ssc_modfreq_reg))
  311. goto cleanup;
  312. of_property_read_u32(node, "ti,ssc-modfreq-hz",
  313. &dd->ssc_modfreq);
  314. of_property_read_u32(node, "ti,ssc-deltam", &dd->ssc_deltam);
  315. dd->ssc_downspread =
  316. of_property_read_bool(node, "ti,ssc-downspread");
  317. }
  318. if (of_property_read_bool(node, "ti,low-power-stop"))
  319. dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
  320. if (of_property_read_bool(node, "ti,low-power-bypass"))
  321. dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
  322. if (of_property_read_bool(node, "ti,lock"))
  323. dpll_mode |= 1 << DPLL_LOCKED;
  324. if (!of_property_read_u32(node, "ti,min-div", &min_div) &&
  325. min_div > dd->min_divider)
  326. dd->min_divider = min_div;
  327. if (dpll_mode)
  328. dd->modes = dpll_mode;
  329. _register_dpll(&clk_hw->hw, node);
  330. return;
  331. cleanup:
  332. kfree(dd);
  333. kfree(parent_names);
  334. kfree(init);
  335. kfree(clk_hw);
  336. }
  337. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  338. defined(CONFIG_SOC_DRA7XX)
  339. static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
  340. {
  341. _register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
  342. }
  343. CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
  344. of_ti_omap4_dpll_x2_setup);
  345. #endif
  346. #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  347. static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
  348. {
  349. _register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
  350. }
  351. CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
  352. of_ti_am3_dpll_x2_setup);
  353. #endif
  354. #ifdef CONFIG_ARCH_OMAP3
  355. static void __init of_ti_omap3_dpll_setup(struct device_node *node)
  356. {
  357. const struct dpll_data dd = {
  358. .idlest_mask = 0x1,
  359. .enable_mask = 0x7,
  360. .autoidle_mask = 0x7,
  361. .mult_mask = 0x7ff << 8,
  362. .div1_mask = 0x7f,
  363. .max_multiplier = 2047,
  364. .max_divider = 128,
  365. .min_divider = 1,
  366. .freqsel_mask = 0xf0,
  367. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  368. };
  369. if ((of_machine_is_compatible("ti,omap3630") ||
  370. of_machine_is_compatible("ti,omap36xx")) &&
  371. of_node_name_eq(node, "dpll5_ck"))
  372. of_ti_dpll_setup(node, &omap3_dpll5_ck_ops, &dd);
  373. else
  374. of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
  375. }
  376. CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
  377. of_ti_omap3_dpll_setup);
  378. static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
  379. {
  380. const struct dpll_data dd = {
  381. .idlest_mask = 0x1,
  382. .enable_mask = 0x7,
  383. .autoidle_mask = 0x7,
  384. .mult_mask = 0x7ff << 16,
  385. .div1_mask = 0x7f << 8,
  386. .max_multiplier = 2047,
  387. .max_divider = 128,
  388. .min_divider = 1,
  389. .freqsel_mask = 0xf0,
  390. };
  391. of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
  392. }
  393. CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
  394. of_ti_omap3_core_dpll_setup);
  395. static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
  396. {
  397. const struct dpll_data dd = {
  398. .idlest_mask = 0x1 << 1,
  399. .enable_mask = 0x7 << 16,
  400. .autoidle_mask = 0x7 << 3,
  401. .mult_mask = 0x7ff << 8,
  402. .div1_mask = 0x7f,
  403. .max_multiplier = 2047,
  404. .max_divider = 128,
  405. .min_divider = 1,
  406. .freqsel_mask = 0xf00000,
  407. .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
  408. };
  409. of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
  410. }
  411. CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
  412. of_ti_omap3_per_dpll_setup);
  413. static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
  414. {
  415. const struct dpll_data dd = {
  416. .idlest_mask = 0x1 << 1,
  417. .enable_mask = 0x7 << 16,
  418. .autoidle_mask = 0x7 << 3,
  419. .mult_mask = 0xfff << 8,
  420. .div1_mask = 0x7f,
  421. .max_multiplier = 4095,
  422. .max_divider = 128,
  423. .min_divider = 1,
  424. .sddiv_mask = 0xff << 24,
  425. .dco_mask = 0xe << 20,
  426. .flags = DPLL_J_TYPE,
  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_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
  432. of_ti_omap3_per_jtype_dpll_setup);
  433. #endif
  434. static void __init of_ti_omap4_dpll_setup(struct device_node *node)
  435. {
  436. const struct dpll_data dd = {
  437. .idlest_mask = 0x1,
  438. .enable_mask = 0x7,
  439. .autoidle_mask = 0x7,
  440. .mult_mask = 0x7ff << 8,
  441. .div1_mask = 0x7f,
  442. .max_multiplier = 2047,
  443. .max_divider = 128,
  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(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
  450. of_ti_omap4_dpll_setup);
  451. static void __init of_ti_omap5_mpu_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. .dcc_mask = BIT(22),
  462. .dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
  463. .min_divider = 1,
  464. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  465. };
  466. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  467. }
  468. CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
  469. of_ti_omap5_mpu_dpll_setup);
  470. static void __init of_ti_omap4_core_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. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  482. };
  483. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  484. }
  485. CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
  486. of_ti_omap4_core_dpll_setup);
  487. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  488. defined(CONFIG_SOC_DRA7XX)
  489. static void __init of_ti_omap4_m4xen_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 = 0x7ff << 8,
  496. .div1_mask = 0x7f,
  497. .max_multiplier = 2047,
  498. .max_divider = 128,
  499. .min_divider = 1,
  500. .m4xen_mask = 0x800,
  501. .lpmode_mask = 1 << 10,
  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_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
  507. of_ti_omap4_m4xen_dpll_setup);
  508. static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
  509. {
  510. const struct dpll_data dd = {
  511. .idlest_mask = 0x1,
  512. .enable_mask = 0x7,
  513. .autoidle_mask = 0x7,
  514. .mult_mask = 0xfff << 8,
  515. .div1_mask = 0xff,
  516. .max_multiplier = 4095,
  517. .max_divider = 256,
  518. .min_divider = 1,
  519. .sddiv_mask = 0xff << 24,
  520. .flags = DPLL_J_TYPE,
  521. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  522. };
  523. of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
  524. }
  525. CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
  526. of_ti_omap4_jtype_dpll_setup);
  527. #endif
  528. static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
  529. {
  530. const struct dpll_data dd = {
  531. .idlest_mask = 0x1,
  532. .enable_mask = 0x7,
  533. .ssc_enable_mask = 0x1 << 12,
  534. .ssc_downspread_mask = 0x1 << 14,
  535. .mult_mask = 0x7ff << 8,
  536. .div1_mask = 0x7f,
  537. .ssc_deltam_int_mask = 0x3 << 18,
  538. .ssc_deltam_frac_mask = 0x3ffff,
  539. .ssc_modfreq_mant_mask = 0x7f,
  540. .ssc_modfreq_exp_mask = 0x7 << 8,
  541. .max_multiplier = 2047,
  542. .max_divider = 128,
  543. .min_divider = 1,
  544. .max_rate = 1000000000,
  545. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  546. };
  547. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  548. }
  549. CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
  550. of_ti_am3_no_gate_dpll_setup);
  551. static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
  552. {
  553. const struct dpll_data dd = {
  554. .idlest_mask = 0x1,
  555. .enable_mask = 0x7,
  556. .mult_mask = 0x7ff << 8,
  557. .div1_mask = 0x7f,
  558. .max_multiplier = 4095,
  559. .max_divider = 256,
  560. .min_divider = 2,
  561. .flags = DPLL_J_TYPE,
  562. .max_rate = 2000000000,
  563. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  564. };
  565. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  566. }
  567. CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
  568. of_ti_am3_jtype_dpll_setup);
  569. static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
  570. {
  571. const struct dpll_data dd = {
  572. .idlest_mask = 0x1,
  573. .enable_mask = 0x7,
  574. .mult_mask = 0x7ff << 8,
  575. .div1_mask = 0x7f,
  576. .max_multiplier = 2047,
  577. .max_divider = 128,
  578. .min_divider = 1,
  579. .max_rate = 2000000000,
  580. .flags = DPLL_J_TYPE,
  581. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  582. };
  583. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  584. }
  585. CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
  586. "ti,am3-dpll-no-gate-j-type-clock",
  587. of_ti_am3_no_gate_jtype_dpll_setup);
  588. static void __init of_ti_am3_dpll_setup(struct device_node *node)
  589. {
  590. const struct dpll_data dd = {
  591. .idlest_mask = 0x1,
  592. .enable_mask = 0x7,
  593. .ssc_enable_mask = 0x1 << 12,
  594. .ssc_downspread_mask = 0x1 << 14,
  595. .mult_mask = 0x7ff << 8,
  596. .div1_mask = 0x7f,
  597. .ssc_deltam_int_mask = 0x3 << 18,
  598. .ssc_deltam_frac_mask = 0x3ffff,
  599. .ssc_modfreq_mant_mask = 0x7f,
  600. .ssc_modfreq_exp_mask = 0x7 << 8,
  601. .max_multiplier = 2047,
  602. .max_divider = 128,
  603. .min_divider = 1,
  604. .max_rate = 1000000000,
  605. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  606. };
  607. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  608. }
  609. CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
  610. static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
  611. {
  612. const struct dpll_data dd = {
  613. .idlest_mask = 0x1,
  614. .enable_mask = 0x7,
  615. .mult_mask = 0x7ff << 8,
  616. .div1_mask = 0x7f,
  617. .max_multiplier = 2047,
  618. .max_divider = 128,
  619. .min_divider = 1,
  620. .max_rate = 1000000000,
  621. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  622. };
  623. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  624. }
  625. CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
  626. of_ti_am3_core_dpll_setup);
  627. static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
  628. {
  629. const struct dpll_data dd = {
  630. .enable_mask = 0x3,
  631. .mult_mask = 0x3ff << 12,
  632. .div1_mask = 0xf << 8,
  633. .max_divider = 16,
  634. .min_divider = 1,
  635. };
  636. of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
  637. }
  638. CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
  639. of_ti_omap2_core_dpll_setup);