dpll.c 20 KB

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