dpll.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * OMAP DPLL clock support
  3. *
  4. * Copyright (C) 2013 Texas Instruments, Inc.
  5. *
  6. * Tero Kristo <t-kristo@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  13. * kind, whether express or implied; without even the implied warranty
  14. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. */
  17. #include <linux/clk-provider.h>
  18. #include <linux/slab.h>
  19. #include <linux/err.h>
  20. #include <linux/of.h>
  21. #include <linux/of_address.h>
  22. #include <linux/clk/ti.h>
  23. #undef pr_fmt
  24. #define pr_fmt(fmt) "%s: " fmt, __func__
  25. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  26. defined(CONFIG_SOC_DRA7XX)
  27. static const struct clk_ops dpll_m4xen_ck_ops = {
  28. .enable = &omap3_noncore_dpll_enable,
  29. .disable = &omap3_noncore_dpll_disable,
  30. .recalc_rate = &omap4_dpll_regm4xen_recalc,
  31. .round_rate = &omap4_dpll_regm4xen_round_rate,
  32. .set_rate = &omap3_noncore_dpll_set_rate,
  33. .get_parent = &omap2_init_dpll_parent,
  34. };
  35. #else
  36. static const struct clk_ops dpll_m4xen_ck_ops = {};
  37. #endif
  38. #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4) || \
  39. defined(CONFIG_SOC_OMAP5) || defined(CONFIG_SOC_DRA7XX) || \
  40. defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  41. static const struct clk_ops dpll_core_ck_ops = {
  42. .recalc_rate = &omap3_dpll_recalc,
  43. .get_parent = &omap2_init_dpll_parent,
  44. };
  45. static const struct clk_ops dpll_ck_ops = {
  46. .enable = &omap3_noncore_dpll_enable,
  47. .disable = &omap3_noncore_dpll_disable,
  48. .recalc_rate = &omap3_dpll_recalc,
  49. .round_rate = &omap2_dpll_round_rate,
  50. .set_rate = &omap3_noncore_dpll_set_rate,
  51. .get_parent = &omap2_init_dpll_parent,
  52. };
  53. static const struct clk_ops dpll_no_gate_ck_ops = {
  54. .recalc_rate = &omap3_dpll_recalc,
  55. .get_parent = &omap2_init_dpll_parent,
  56. .round_rate = &omap2_dpll_round_rate,
  57. .set_rate = &omap3_noncore_dpll_set_rate,
  58. };
  59. #else
  60. static const struct clk_ops dpll_core_ck_ops = {};
  61. static const struct clk_ops dpll_ck_ops = {};
  62. static const struct clk_ops dpll_no_gate_ck_ops = {};
  63. const struct clk_hw_omap_ops clkhwops_omap3_dpll = {};
  64. #endif
  65. #ifdef CONFIG_ARCH_OMAP2
  66. static const struct clk_ops omap2_dpll_core_ck_ops = {
  67. .get_parent = &omap2_init_dpll_parent,
  68. .recalc_rate = &omap2_dpllcore_recalc,
  69. .round_rate = &omap2_dpll_round_rate,
  70. .set_rate = &omap2_reprogram_dpllcore,
  71. };
  72. #else
  73. static const struct clk_ops omap2_dpll_core_ck_ops = {};
  74. #endif
  75. #ifdef CONFIG_ARCH_OMAP3
  76. static const struct clk_ops omap3_dpll_core_ck_ops = {
  77. .get_parent = &omap2_init_dpll_parent,
  78. .recalc_rate = &omap3_dpll_recalc,
  79. .round_rate = &omap2_dpll_round_rate,
  80. };
  81. #else
  82. static const struct clk_ops omap3_dpll_core_ck_ops = {};
  83. #endif
  84. #ifdef CONFIG_ARCH_OMAP3
  85. static const struct clk_ops omap3_dpll_ck_ops = {
  86. .enable = &omap3_noncore_dpll_enable,
  87. .disable = &omap3_noncore_dpll_disable,
  88. .get_parent = &omap2_init_dpll_parent,
  89. .recalc_rate = &omap3_dpll_recalc,
  90. .set_rate = &omap3_noncore_dpll_set_rate,
  91. .round_rate = &omap2_dpll_round_rate,
  92. };
  93. static const struct clk_ops omap3_dpll_per_ck_ops = {
  94. .enable = &omap3_noncore_dpll_enable,
  95. .disable = &omap3_noncore_dpll_disable,
  96. .get_parent = &omap2_init_dpll_parent,
  97. .recalc_rate = &omap3_dpll_recalc,
  98. .set_rate = &omap3_dpll4_set_rate,
  99. .round_rate = &omap2_dpll_round_rate,
  100. };
  101. #endif
  102. static const struct clk_ops dpll_x2_ck_ops = {
  103. .recalc_rate = &omap3_clkoutx2_recalc,
  104. };
  105. /**
  106. * ti_clk_register_dpll - low level registration of a DPLL clock
  107. * @hw: hardware clock definition for the clock
  108. * @node: device node for the clock
  109. *
  110. * Finalizes DPLL registration process. In case a failure (clk-ref or
  111. * clk-bypass is missing), the clock is added to retry list and
  112. * the initialization is retried on later stage.
  113. */
  114. static void __init ti_clk_register_dpll(struct clk_hw *hw,
  115. struct device_node *node)
  116. {
  117. struct clk_hw_omap *clk_hw = to_clk_hw_omap(hw);
  118. struct dpll_data *dd = clk_hw->dpll_data;
  119. struct clk *clk;
  120. dd->clk_ref = of_clk_get(node, 0);
  121. dd->clk_bypass = of_clk_get(node, 1);
  122. if (IS_ERR(dd->clk_ref) || IS_ERR(dd->clk_bypass)) {
  123. pr_debug("clk-ref or clk-bypass missing for %s, retry later\n",
  124. node->name);
  125. if (!ti_clk_retry_init(node, hw, ti_clk_register_dpll))
  126. return;
  127. goto cleanup;
  128. }
  129. /* register the clock */
  130. clk = clk_register(NULL, &clk_hw->hw);
  131. if (!IS_ERR(clk)) {
  132. omap2_init_clk_hw_omap_clocks(clk);
  133. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  134. kfree(clk_hw->hw.init->parent_names);
  135. kfree(clk_hw->hw.init);
  136. return;
  137. }
  138. cleanup:
  139. kfree(clk_hw->dpll_data);
  140. kfree(clk_hw->hw.init->parent_names);
  141. kfree(clk_hw->hw.init);
  142. kfree(clk_hw);
  143. }
  144. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  145. defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \
  146. defined(CONFIG_SOC_AM43XX)
  147. /**
  148. * ti_clk_register_dpll_x2 - Registers a DPLLx2 clock
  149. * @node: device node for this clock
  150. * @ops: clk_ops for this clock
  151. * @hw_ops: clk_hw_ops for this clock
  152. *
  153. * Initializes a DPLL x 2 clock from device tree data.
  154. */
  155. static void ti_clk_register_dpll_x2(struct device_node *node,
  156. const struct clk_ops *ops,
  157. const struct clk_hw_omap_ops *hw_ops)
  158. {
  159. struct clk *clk;
  160. struct clk_init_data init = { NULL };
  161. struct clk_hw_omap *clk_hw;
  162. const char *name = node->name;
  163. const char *parent_name;
  164. parent_name = of_clk_get_parent_name(node, 0);
  165. if (!parent_name) {
  166. pr_err("%s must have parent\n", node->name);
  167. return;
  168. }
  169. clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
  170. if (!clk_hw)
  171. return;
  172. clk_hw->ops = hw_ops;
  173. clk_hw->hw.init = &init;
  174. init.name = name;
  175. init.ops = ops;
  176. init.parent_names = &parent_name;
  177. init.num_parents = 1;
  178. /* register the clock */
  179. clk = clk_register(NULL, &clk_hw->hw);
  180. if (IS_ERR(clk)) {
  181. kfree(clk_hw);
  182. } else {
  183. omap2_init_clk_hw_omap_clocks(clk);
  184. of_clk_add_provider(node, of_clk_src_simple_get, clk);
  185. }
  186. }
  187. #endif
  188. /**
  189. * of_ti_dpll_setup - Setup function for OMAP DPLL clocks
  190. * @node: device node containing the DPLL info
  191. * @ops: ops for the DPLL
  192. * @ddt: DPLL data template to use
  193. *
  194. * Initializes a DPLL clock from device tree data.
  195. */
  196. static void __init of_ti_dpll_setup(struct device_node *node,
  197. const struct clk_ops *ops,
  198. const struct dpll_data *ddt)
  199. {
  200. struct clk_hw_omap *clk_hw = NULL;
  201. struct clk_init_data *init = NULL;
  202. const char **parent_names = NULL;
  203. struct dpll_data *dd = NULL;
  204. int i;
  205. u8 dpll_mode = 0;
  206. dd = kzalloc(sizeof(*dd), GFP_KERNEL);
  207. clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
  208. init = kzalloc(sizeof(*init), GFP_KERNEL);
  209. if (!dd || !clk_hw || !init)
  210. goto cleanup;
  211. memcpy(dd, ddt, sizeof(*dd));
  212. clk_hw->dpll_data = dd;
  213. clk_hw->ops = &clkhwops_omap3_dpll;
  214. clk_hw->hw.init = init;
  215. clk_hw->flags = MEMMAP_ADDRESSING;
  216. init->name = node->name;
  217. init->ops = ops;
  218. init->num_parents = of_clk_get_parent_count(node);
  219. if (init->num_parents < 1) {
  220. pr_err("%s must have parent(s)\n", node->name);
  221. goto cleanup;
  222. }
  223. parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
  224. if (!parent_names)
  225. goto cleanup;
  226. for (i = 0; i < init->num_parents; i++)
  227. parent_names[i] = of_clk_get_parent_name(node, i);
  228. init->parent_names = parent_names;
  229. dd->control_reg = ti_clk_get_reg_addr(node, 0);
  230. /*
  231. * Special case for OMAP2 DPLL, register order is different due to
  232. * missing idlest_reg, also clkhwops is different. Detected from
  233. * missing idlest_mask.
  234. */
  235. if (!dd->idlest_mask) {
  236. dd->mult_div1_reg = ti_clk_get_reg_addr(node, 1);
  237. #ifdef CONFIG_ARCH_OMAP2
  238. clk_hw->ops = &clkhwops_omap2xxx_dpll;
  239. omap2xxx_clkt_dpllcore_init(&clk_hw->hw);
  240. #endif
  241. } else {
  242. dd->idlest_reg = ti_clk_get_reg_addr(node, 1);
  243. if (!dd->idlest_reg)
  244. goto cleanup;
  245. dd->mult_div1_reg = ti_clk_get_reg_addr(node, 2);
  246. }
  247. if (!dd->control_reg || !dd->mult_div1_reg)
  248. goto cleanup;
  249. if (dd->autoidle_mask) {
  250. dd->autoidle_reg = ti_clk_get_reg_addr(node, 3);
  251. if (!dd->autoidle_reg)
  252. goto cleanup;
  253. }
  254. if (of_property_read_bool(node, "ti,low-power-stop"))
  255. dpll_mode |= 1 << DPLL_LOW_POWER_STOP;
  256. if (of_property_read_bool(node, "ti,low-power-bypass"))
  257. dpll_mode |= 1 << DPLL_LOW_POWER_BYPASS;
  258. if (of_property_read_bool(node, "ti,lock"))
  259. dpll_mode |= 1 << DPLL_LOCKED;
  260. if (dpll_mode)
  261. dd->modes = dpll_mode;
  262. ti_clk_register_dpll(&clk_hw->hw, node);
  263. return;
  264. cleanup:
  265. kfree(dd);
  266. kfree(parent_names);
  267. kfree(init);
  268. kfree(clk_hw);
  269. }
  270. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  271. defined(CONFIG_SOC_DRA7XX)
  272. static void __init of_ti_omap4_dpll_x2_setup(struct device_node *node)
  273. {
  274. ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, &clkhwops_omap4_dpllmx);
  275. }
  276. CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock",
  277. of_ti_omap4_dpll_x2_setup);
  278. #endif
  279. #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX)
  280. static void __init of_ti_am3_dpll_x2_setup(struct device_node *node)
  281. {
  282. ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, NULL);
  283. }
  284. CLK_OF_DECLARE(ti_am3_dpll_x2_clock, "ti,am3-dpll-x2-clock",
  285. of_ti_am3_dpll_x2_setup);
  286. #endif
  287. #ifdef CONFIG_ARCH_OMAP3
  288. static void __init of_ti_omap3_dpll_setup(struct device_node *node)
  289. {
  290. const struct dpll_data dd = {
  291. .idlest_mask = 0x1,
  292. .enable_mask = 0x7,
  293. .autoidle_mask = 0x7,
  294. .mult_mask = 0x7ff << 8,
  295. .div1_mask = 0x7f,
  296. .max_multiplier = 2047,
  297. .max_divider = 128,
  298. .min_divider = 1,
  299. .freqsel_mask = 0xf0,
  300. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  301. };
  302. of_ti_dpll_setup(node, &omap3_dpll_ck_ops, &dd);
  303. }
  304. CLK_OF_DECLARE(ti_omap3_dpll_clock, "ti,omap3-dpll-clock",
  305. of_ti_omap3_dpll_setup);
  306. static void __init of_ti_omap3_core_dpll_setup(struct device_node *node)
  307. {
  308. const struct dpll_data dd = {
  309. .idlest_mask = 0x1,
  310. .enable_mask = 0x7,
  311. .autoidle_mask = 0x7,
  312. .mult_mask = 0x7ff << 16,
  313. .div1_mask = 0x7f << 8,
  314. .max_multiplier = 2047,
  315. .max_divider = 128,
  316. .min_divider = 1,
  317. .freqsel_mask = 0xf0,
  318. };
  319. of_ti_dpll_setup(node, &omap3_dpll_core_ck_ops, &dd);
  320. }
  321. CLK_OF_DECLARE(ti_omap3_core_dpll_clock, "ti,omap3-dpll-core-clock",
  322. of_ti_omap3_core_dpll_setup);
  323. static void __init of_ti_omap3_per_dpll_setup(struct device_node *node)
  324. {
  325. const struct dpll_data dd = {
  326. .idlest_mask = 0x1 << 1,
  327. .enable_mask = 0x7 << 16,
  328. .autoidle_mask = 0x7 << 3,
  329. .mult_mask = 0x7ff << 8,
  330. .div1_mask = 0x7f,
  331. .max_multiplier = 2047,
  332. .max_divider = 128,
  333. .min_divider = 1,
  334. .freqsel_mask = 0xf00000,
  335. .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
  336. };
  337. of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
  338. }
  339. CLK_OF_DECLARE(ti_omap3_per_dpll_clock, "ti,omap3-dpll-per-clock",
  340. of_ti_omap3_per_dpll_setup);
  341. static void __init of_ti_omap3_per_jtype_dpll_setup(struct device_node *node)
  342. {
  343. const struct dpll_data dd = {
  344. .idlest_mask = 0x1 << 1,
  345. .enable_mask = 0x7 << 16,
  346. .autoidle_mask = 0x7 << 3,
  347. .mult_mask = 0xfff << 8,
  348. .div1_mask = 0x7f,
  349. .max_multiplier = 4095,
  350. .max_divider = 128,
  351. .min_divider = 1,
  352. .sddiv_mask = 0xff << 24,
  353. .dco_mask = 0xe << 20,
  354. .flags = DPLL_J_TYPE,
  355. .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
  356. };
  357. of_ti_dpll_setup(node, &omap3_dpll_per_ck_ops, &dd);
  358. }
  359. CLK_OF_DECLARE(ti_omap3_per_jtype_dpll_clock, "ti,omap3-dpll-per-j-type-clock",
  360. of_ti_omap3_per_jtype_dpll_setup);
  361. #endif
  362. static void __init of_ti_omap4_dpll_setup(struct device_node *node)
  363. {
  364. const struct dpll_data dd = {
  365. .idlest_mask = 0x1,
  366. .enable_mask = 0x7,
  367. .autoidle_mask = 0x7,
  368. .mult_mask = 0x7ff << 8,
  369. .div1_mask = 0x7f,
  370. .max_multiplier = 2047,
  371. .max_divider = 128,
  372. .min_divider = 1,
  373. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  374. };
  375. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  376. }
  377. CLK_OF_DECLARE(ti_omap4_dpll_clock, "ti,omap4-dpll-clock",
  378. of_ti_omap4_dpll_setup);
  379. static void __init of_ti_omap5_mpu_dpll_setup(struct device_node *node)
  380. {
  381. const struct dpll_data dd = {
  382. .idlest_mask = 0x1,
  383. .enable_mask = 0x7,
  384. .autoidle_mask = 0x7,
  385. .mult_mask = 0x7ff << 8,
  386. .div1_mask = 0x7f,
  387. .max_multiplier = 2047,
  388. .max_divider = 128,
  389. .dcc_mask = BIT(22),
  390. .dcc_rate = 1400000000, /* DCC beyond 1.4GHz */
  391. .min_divider = 1,
  392. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  393. };
  394. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  395. }
  396. CLK_OF_DECLARE(of_ti_omap5_mpu_dpll_clock, "ti,omap5-mpu-dpll-clock",
  397. of_ti_omap5_mpu_dpll_setup);
  398. static void __init of_ti_omap4_core_dpll_setup(struct device_node *node)
  399. {
  400. const struct dpll_data dd = {
  401. .idlest_mask = 0x1,
  402. .enable_mask = 0x7,
  403. .autoidle_mask = 0x7,
  404. .mult_mask = 0x7ff << 8,
  405. .div1_mask = 0x7f,
  406. .max_multiplier = 2047,
  407. .max_divider = 128,
  408. .min_divider = 1,
  409. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  410. };
  411. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  412. }
  413. CLK_OF_DECLARE(ti_omap4_core_dpll_clock, "ti,omap4-dpll-core-clock",
  414. of_ti_omap4_core_dpll_setup);
  415. #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \
  416. defined(CONFIG_SOC_DRA7XX)
  417. static void __init of_ti_omap4_m4xen_dpll_setup(struct device_node *node)
  418. {
  419. const struct dpll_data dd = {
  420. .idlest_mask = 0x1,
  421. .enable_mask = 0x7,
  422. .autoidle_mask = 0x7,
  423. .mult_mask = 0x7ff << 8,
  424. .div1_mask = 0x7f,
  425. .max_multiplier = 2047,
  426. .max_divider = 128,
  427. .min_divider = 1,
  428. .m4xen_mask = 0x800,
  429. .lpmode_mask = 1 << 10,
  430. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  431. };
  432. of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
  433. }
  434. CLK_OF_DECLARE(ti_omap4_m4xen_dpll_clock, "ti,omap4-dpll-m4xen-clock",
  435. of_ti_omap4_m4xen_dpll_setup);
  436. static void __init of_ti_omap4_jtype_dpll_setup(struct device_node *node)
  437. {
  438. const struct dpll_data dd = {
  439. .idlest_mask = 0x1,
  440. .enable_mask = 0x7,
  441. .autoidle_mask = 0x7,
  442. .mult_mask = 0xfff << 8,
  443. .div1_mask = 0xff,
  444. .max_multiplier = 4095,
  445. .max_divider = 256,
  446. .min_divider = 1,
  447. .sddiv_mask = 0xff << 24,
  448. .flags = DPLL_J_TYPE,
  449. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  450. };
  451. of_ti_dpll_setup(node, &dpll_m4xen_ck_ops, &dd);
  452. }
  453. CLK_OF_DECLARE(ti_omap4_jtype_dpll_clock, "ti,omap4-dpll-j-type-clock",
  454. of_ti_omap4_jtype_dpll_setup);
  455. #endif
  456. static void __init of_ti_am3_no_gate_dpll_setup(struct device_node *node)
  457. {
  458. const struct dpll_data dd = {
  459. .idlest_mask = 0x1,
  460. .enable_mask = 0x7,
  461. .mult_mask = 0x7ff << 8,
  462. .div1_mask = 0x7f,
  463. .max_multiplier = 2047,
  464. .max_divider = 128,
  465. .min_divider = 1,
  466. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  467. };
  468. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  469. }
  470. CLK_OF_DECLARE(ti_am3_no_gate_dpll_clock, "ti,am3-dpll-no-gate-clock",
  471. of_ti_am3_no_gate_dpll_setup);
  472. static void __init of_ti_am3_jtype_dpll_setup(struct device_node *node)
  473. {
  474. const struct dpll_data dd = {
  475. .idlest_mask = 0x1,
  476. .enable_mask = 0x7,
  477. .mult_mask = 0x7ff << 8,
  478. .div1_mask = 0x7f,
  479. .max_multiplier = 4095,
  480. .max_divider = 256,
  481. .min_divider = 2,
  482. .flags = DPLL_J_TYPE,
  483. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  484. };
  485. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  486. }
  487. CLK_OF_DECLARE(ti_am3_jtype_dpll_clock, "ti,am3-dpll-j-type-clock",
  488. of_ti_am3_jtype_dpll_setup);
  489. static void __init of_ti_am3_no_gate_jtype_dpll_setup(struct device_node *node)
  490. {
  491. const struct dpll_data dd = {
  492. .idlest_mask = 0x1,
  493. .enable_mask = 0x7,
  494. .mult_mask = 0x7ff << 8,
  495. .div1_mask = 0x7f,
  496. .max_multiplier = 2047,
  497. .max_divider = 128,
  498. .min_divider = 1,
  499. .flags = DPLL_J_TYPE,
  500. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  501. };
  502. of_ti_dpll_setup(node, &dpll_no_gate_ck_ops, &dd);
  503. }
  504. CLK_OF_DECLARE(ti_am3_no_gate_jtype_dpll_clock,
  505. "ti,am3-dpll-no-gate-j-type-clock",
  506. of_ti_am3_no_gate_jtype_dpll_setup);
  507. static void __init of_ti_am3_dpll_setup(struct device_node *node)
  508. {
  509. const struct dpll_data dd = {
  510. .idlest_mask = 0x1,
  511. .enable_mask = 0x7,
  512. .mult_mask = 0x7ff << 8,
  513. .div1_mask = 0x7f,
  514. .max_multiplier = 2047,
  515. .max_divider = 128,
  516. .min_divider = 1,
  517. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  518. };
  519. of_ti_dpll_setup(node, &dpll_ck_ops, &dd);
  520. }
  521. CLK_OF_DECLARE(ti_am3_dpll_clock, "ti,am3-dpll-clock", of_ti_am3_dpll_setup);
  522. static void __init of_ti_am3_core_dpll_setup(struct device_node *node)
  523. {
  524. const struct dpll_data dd = {
  525. .idlest_mask = 0x1,
  526. .enable_mask = 0x7,
  527. .mult_mask = 0x7ff << 8,
  528. .div1_mask = 0x7f,
  529. .max_multiplier = 2047,
  530. .max_divider = 128,
  531. .min_divider = 1,
  532. .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
  533. };
  534. of_ti_dpll_setup(node, &dpll_core_ck_ops, &dd);
  535. }
  536. CLK_OF_DECLARE(ti_am3_core_dpll_clock, "ti,am3-dpll-core-clock",
  537. of_ti_am3_core_dpll_setup);
  538. static void __init of_ti_omap2_core_dpll_setup(struct device_node *node)
  539. {
  540. const struct dpll_data dd = {
  541. .enable_mask = 0x3,
  542. .mult_mask = 0x3ff << 12,
  543. .div1_mask = 0xf << 8,
  544. .max_divider = 16,
  545. .min_divider = 1,
  546. };
  547. of_ti_dpll_setup(node, &omap2_dpll_core_ck_ops, &dd);
  548. }
  549. CLK_OF_DECLARE(ti_omap2_core_dpll_clock, "ti,omap2-dpll-core-clock",
  550. of_ti_omap2_core_dpll_setup);