clk.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /*
  2. * Copyright (c) 2014 MundoReader S.L.
  3. * Author: Heiko Stuebner <heiko@sntech.de>
  4. *
  5. * Copyright (c) 2016 Rockchip Electronics Co. Ltd.
  6. * Author: Xing Zheng <zhengxing@rock-chips.com>
  7. *
  8. * based on
  9. *
  10. * samsung/clk.c
  11. * Copyright (c) 2013 Samsung Electronics Co., Ltd.
  12. * Copyright (c) 2013 Linaro Ltd.
  13. * Author: Thomas Abraham <thomas.ab@samsung.com>
  14. *
  15. * This program is free software; you can redistribute it and/or modify
  16. * it under the terms of the GNU General Public License as published by
  17. * the Free Software Foundation; either version 2 of the License, or
  18. * (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU General Public License for more details.
  24. */
  25. #include <linux/slab.h>
  26. #include <linux/clk.h>
  27. #include <linux/clk-provider.h>
  28. #include <linux/mfd/syscon.h>
  29. #include <linux/regmap.h>
  30. #include <linux/reboot.h>
  31. #include <linux/rational.h>
  32. #include "clk.h"
  33. /**
  34. * Register a clock branch.
  35. * Most clock branches have a form like
  36. *
  37. * src1 --|--\
  38. * |M |--[GATE]-[DIV]-
  39. * src2 --|--/
  40. *
  41. * sometimes without one of those components.
  42. */
  43. static struct clk *rockchip_clk_register_branch(const char *name,
  44. const char *const *parent_names, u8 num_parents,
  45. void __iomem *base,
  46. int muxdiv_offset, u8 mux_shift, u8 mux_width, u8 mux_flags,
  47. u8 div_shift, u8 div_width, u8 div_flags,
  48. struct clk_div_table *div_table, int gate_offset,
  49. u8 gate_shift, u8 gate_flags, unsigned long flags,
  50. spinlock_t *lock)
  51. {
  52. struct clk *clk;
  53. struct clk_mux *mux = NULL;
  54. struct clk_gate *gate = NULL;
  55. struct clk_divider *div = NULL;
  56. const struct clk_ops *mux_ops = NULL, *div_ops = NULL,
  57. *gate_ops = NULL;
  58. int ret;
  59. if (num_parents > 1) {
  60. mux = kzalloc(sizeof(*mux), GFP_KERNEL);
  61. if (!mux)
  62. return ERR_PTR(-ENOMEM);
  63. mux->reg = base + muxdiv_offset;
  64. mux->shift = mux_shift;
  65. mux->mask = BIT(mux_width) - 1;
  66. mux->flags = mux_flags;
  67. mux->lock = lock;
  68. mux_ops = (mux_flags & CLK_MUX_READ_ONLY) ? &clk_mux_ro_ops
  69. : &clk_mux_ops;
  70. }
  71. if (gate_offset >= 0) {
  72. gate = kzalloc(sizeof(*gate), GFP_KERNEL);
  73. if (!gate) {
  74. ret = -ENOMEM;
  75. goto err_gate;
  76. }
  77. gate->flags = gate_flags;
  78. gate->reg = base + gate_offset;
  79. gate->bit_idx = gate_shift;
  80. gate->lock = lock;
  81. gate_ops = &clk_gate_ops;
  82. }
  83. if (div_width > 0) {
  84. div = kzalloc(sizeof(*div), GFP_KERNEL);
  85. if (!div) {
  86. ret = -ENOMEM;
  87. goto err_div;
  88. }
  89. div->flags = div_flags;
  90. div->reg = base + muxdiv_offset;
  91. div->shift = div_shift;
  92. div->width = div_width;
  93. div->lock = lock;
  94. div->table = div_table;
  95. div_ops = (div_flags & CLK_DIVIDER_READ_ONLY)
  96. ? &clk_divider_ro_ops
  97. : &clk_divider_ops;
  98. }
  99. clk = clk_register_composite(NULL, name, parent_names, num_parents,
  100. mux ? &mux->hw : NULL, mux_ops,
  101. div ? &div->hw : NULL, div_ops,
  102. gate ? &gate->hw : NULL, gate_ops,
  103. flags);
  104. if (IS_ERR(clk)) {
  105. ret = PTR_ERR(clk);
  106. goto err_composite;
  107. }
  108. return clk;
  109. err_composite:
  110. kfree(div);
  111. err_div:
  112. kfree(gate);
  113. err_gate:
  114. kfree(mux);
  115. return ERR_PTR(ret);
  116. }
  117. struct rockchip_clk_frac {
  118. struct notifier_block clk_nb;
  119. struct clk_fractional_divider div;
  120. struct clk_gate gate;
  121. struct clk_mux mux;
  122. const struct clk_ops *mux_ops;
  123. int mux_frac_idx;
  124. bool rate_change_remuxed;
  125. int rate_change_idx;
  126. };
  127. #define to_rockchip_clk_frac_nb(nb) \
  128. container_of(nb, struct rockchip_clk_frac, clk_nb)
  129. static int rockchip_clk_frac_notifier_cb(struct notifier_block *nb,
  130. unsigned long event, void *data)
  131. {
  132. struct clk_notifier_data *ndata = data;
  133. struct rockchip_clk_frac *frac = to_rockchip_clk_frac_nb(nb);
  134. struct clk_mux *frac_mux = &frac->mux;
  135. int ret = 0;
  136. pr_debug("%s: event %lu, old_rate %lu, new_rate: %lu\n",
  137. __func__, event, ndata->old_rate, ndata->new_rate);
  138. if (event == PRE_RATE_CHANGE) {
  139. frac->rate_change_idx =
  140. frac->mux_ops->get_parent(&frac_mux->hw);
  141. if (frac->rate_change_idx != frac->mux_frac_idx) {
  142. frac->mux_ops->set_parent(&frac_mux->hw,
  143. frac->mux_frac_idx);
  144. frac->rate_change_remuxed = 1;
  145. }
  146. } else if (event == POST_RATE_CHANGE) {
  147. /*
  148. * The POST_RATE_CHANGE notifier runs directly after the
  149. * divider clock is set in clk_change_rate, so we'll have
  150. * remuxed back to the original parent before clk_change_rate
  151. * reaches the mux itself.
  152. */
  153. if (frac->rate_change_remuxed) {
  154. frac->mux_ops->set_parent(&frac_mux->hw,
  155. frac->rate_change_idx);
  156. frac->rate_change_remuxed = 0;
  157. }
  158. }
  159. return notifier_from_errno(ret);
  160. }
  161. /**
  162. * fractional divider must set that denominator is 20 times larger than
  163. * numerator to generate precise clock frequency.
  164. */
  165. static void rockchip_fractional_approximation(struct clk_hw *hw,
  166. unsigned long rate, unsigned long *parent_rate,
  167. unsigned long *m, unsigned long *n)
  168. {
  169. struct clk_fractional_divider *fd = to_clk_fd(hw);
  170. unsigned long p_rate, p_parent_rate;
  171. struct clk_hw *p_parent;
  172. unsigned long scale;
  173. p_rate = clk_hw_get_rate(clk_hw_get_parent(hw));
  174. if ((rate * 20 > p_rate) && (p_rate % rate != 0)) {
  175. p_parent = clk_hw_get_parent(clk_hw_get_parent(hw));
  176. p_parent_rate = clk_hw_get_rate(p_parent);
  177. *parent_rate = p_parent_rate;
  178. }
  179. /*
  180. * Get rate closer to *parent_rate to guarantee there is no overflow
  181. * for m and n. In the result it will be the nearest rate left shifted
  182. * by (scale - fd->nwidth) bits.
  183. */
  184. scale = fls_long(*parent_rate / rate - 1);
  185. if (scale > fd->nwidth)
  186. rate <<= scale - fd->nwidth;
  187. rational_best_approximation(rate, *parent_rate,
  188. GENMASK(fd->mwidth - 1, 0), GENMASK(fd->nwidth - 1, 0),
  189. m, n);
  190. }
  191. static struct clk *rockchip_clk_register_frac_branch(
  192. struct rockchip_clk_provider *ctx, const char *name,
  193. const char *const *parent_names, u8 num_parents,
  194. void __iomem *base, int muxdiv_offset, u8 div_flags,
  195. int gate_offset, u8 gate_shift, u8 gate_flags,
  196. unsigned long flags, struct rockchip_clk_branch *child,
  197. spinlock_t *lock)
  198. {
  199. struct rockchip_clk_frac *frac;
  200. struct clk *clk;
  201. struct clk_gate *gate = NULL;
  202. struct clk_fractional_divider *div = NULL;
  203. const struct clk_ops *div_ops = NULL, *gate_ops = NULL;
  204. if (muxdiv_offset < 0)
  205. return ERR_PTR(-EINVAL);
  206. if (child && child->branch_type != branch_mux) {
  207. pr_err("%s: fractional child clock for %s can only be a mux\n",
  208. __func__, name);
  209. return ERR_PTR(-EINVAL);
  210. }
  211. frac = kzalloc(sizeof(*frac), GFP_KERNEL);
  212. if (!frac)
  213. return ERR_PTR(-ENOMEM);
  214. if (gate_offset >= 0) {
  215. gate = &frac->gate;
  216. gate->flags = gate_flags;
  217. gate->reg = base + gate_offset;
  218. gate->bit_idx = gate_shift;
  219. gate->lock = lock;
  220. gate_ops = &clk_gate_ops;
  221. }
  222. div = &frac->div;
  223. div->flags = div_flags;
  224. div->reg = base + muxdiv_offset;
  225. div->mshift = 16;
  226. div->mwidth = 16;
  227. div->mmask = GENMASK(div->mwidth - 1, 0) << div->mshift;
  228. div->nshift = 0;
  229. div->nwidth = 16;
  230. div->nmask = GENMASK(div->nwidth - 1, 0) << div->nshift;
  231. div->lock = lock;
  232. div->approximation = rockchip_fractional_approximation;
  233. div_ops = &clk_fractional_divider_ops;
  234. clk = clk_register_composite(NULL, name, parent_names, num_parents,
  235. NULL, NULL,
  236. &div->hw, div_ops,
  237. gate ? &gate->hw : NULL, gate_ops,
  238. flags | CLK_SET_RATE_UNGATE);
  239. if (IS_ERR(clk)) {
  240. kfree(frac);
  241. return clk;
  242. }
  243. if (child) {
  244. struct clk_mux *frac_mux = &frac->mux;
  245. struct clk_init_data init;
  246. struct clk *mux_clk;
  247. int ret;
  248. frac->mux_frac_idx = match_string(child->parent_names,
  249. child->num_parents, name);
  250. frac->mux_ops = &clk_mux_ops;
  251. frac->clk_nb.notifier_call = rockchip_clk_frac_notifier_cb;
  252. frac_mux->reg = base + child->muxdiv_offset;
  253. frac_mux->shift = child->mux_shift;
  254. frac_mux->mask = BIT(child->mux_width) - 1;
  255. frac_mux->flags = child->mux_flags;
  256. frac_mux->lock = lock;
  257. frac_mux->hw.init = &init;
  258. init.name = child->name;
  259. init.flags = child->flags | CLK_SET_RATE_PARENT;
  260. init.ops = frac->mux_ops;
  261. init.parent_names = child->parent_names;
  262. init.num_parents = child->num_parents;
  263. mux_clk = clk_register(NULL, &frac_mux->hw);
  264. if (IS_ERR(mux_clk)) {
  265. kfree(frac);
  266. return clk;
  267. }
  268. rockchip_clk_add_lookup(ctx, mux_clk, child->id);
  269. /* notifier on the fraction divider to catch rate changes */
  270. if (frac->mux_frac_idx >= 0) {
  271. pr_debug("%s: found fractional parent in mux at pos %d\n",
  272. __func__, frac->mux_frac_idx);
  273. ret = clk_notifier_register(clk, &frac->clk_nb);
  274. if (ret)
  275. pr_err("%s: failed to register clock notifier for %s\n",
  276. __func__, name);
  277. } else {
  278. pr_warn("%s: could not find %s as parent of %s, rate changes may not work\n",
  279. __func__, name, child->name);
  280. }
  281. }
  282. return clk;
  283. }
  284. static struct clk *rockchip_clk_register_factor_branch(const char *name,
  285. const char *const *parent_names, u8 num_parents,
  286. void __iomem *base, unsigned int mult, unsigned int div,
  287. int gate_offset, u8 gate_shift, u8 gate_flags,
  288. unsigned long flags, spinlock_t *lock)
  289. {
  290. struct clk *clk;
  291. struct clk_gate *gate = NULL;
  292. struct clk_fixed_factor *fix = NULL;
  293. /* without gate, register a simple factor clock */
  294. if (gate_offset == 0) {
  295. return clk_register_fixed_factor(NULL, name,
  296. parent_names[0], flags, mult,
  297. div);
  298. }
  299. gate = kzalloc(sizeof(*gate), GFP_KERNEL);
  300. if (!gate)
  301. return ERR_PTR(-ENOMEM);
  302. gate->flags = gate_flags;
  303. gate->reg = base + gate_offset;
  304. gate->bit_idx = gate_shift;
  305. gate->lock = lock;
  306. fix = kzalloc(sizeof(*fix), GFP_KERNEL);
  307. if (!fix) {
  308. kfree(gate);
  309. return ERR_PTR(-ENOMEM);
  310. }
  311. fix->mult = mult;
  312. fix->div = div;
  313. clk = clk_register_composite(NULL, name, parent_names, num_parents,
  314. NULL, NULL,
  315. &fix->hw, &clk_fixed_factor_ops,
  316. &gate->hw, &clk_gate_ops, flags);
  317. if (IS_ERR(clk)) {
  318. kfree(fix);
  319. kfree(gate);
  320. }
  321. return clk;
  322. }
  323. struct rockchip_clk_provider * __init rockchip_clk_init(struct device_node *np,
  324. void __iomem *base, unsigned long nr_clks)
  325. {
  326. struct rockchip_clk_provider *ctx;
  327. struct clk **clk_table;
  328. int i;
  329. ctx = kzalloc(sizeof(struct rockchip_clk_provider), GFP_KERNEL);
  330. if (!ctx)
  331. return ERR_PTR(-ENOMEM);
  332. clk_table = kcalloc(nr_clks, sizeof(struct clk *), GFP_KERNEL);
  333. if (!clk_table)
  334. goto err_free;
  335. for (i = 0; i < nr_clks; ++i)
  336. clk_table[i] = ERR_PTR(-ENOENT);
  337. ctx->reg_base = base;
  338. ctx->clk_data.clks = clk_table;
  339. ctx->clk_data.clk_num = nr_clks;
  340. ctx->cru_node = np;
  341. spin_lock_init(&ctx->lock);
  342. ctx->grf = syscon_regmap_lookup_by_phandle(ctx->cru_node,
  343. "rockchip,grf");
  344. return ctx;
  345. err_free:
  346. kfree(ctx);
  347. return ERR_PTR(-ENOMEM);
  348. }
  349. void __init rockchip_clk_of_add_provider(struct device_node *np,
  350. struct rockchip_clk_provider *ctx)
  351. {
  352. if (of_clk_add_provider(np, of_clk_src_onecell_get,
  353. &ctx->clk_data))
  354. pr_err("%s: could not register clk provider\n", __func__);
  355. }
  356. void rockchip_clk_add_lookup(struct rockchip_clk_provider *ctx,
  357. struct clk *clk, unsigned int id)
  358. {
  359. if (ctx->clk_data.clks && id)
  360. ctx->clk_data.clks[id] = clk;
  361. }
  362. void __init rockchip_clk_register_plls(struct rockchip_clk_provider *ctx,
  363. struct rockchip_pll_clock *list,
  364. unsigned int nr_pll, int grf_lock_offset)
  365. {
  366. struct clk *clk;
  367. int idx;
  368. for (idx = 0; idx < nr_pll; idx++, list++) {
  369. clk = rockchip_clk_register_pll(ctx, list->type, list->name,
  370. list->parent_names, list->num_parents,
  371. list->con_offset, grf_lock_offset,
  372. list->lock_shift, list->mode_offset,
  373. list->mode_shift, list->rate_table,
  374. list->flags, list->pll_flags);
  375. if (IS_ERR(clk)) {
  376. pr_err("%s: failed to register clock %s\n", __func__,
  377. list->name);
  378. continue;
  379. }
  380. rockchip_clk_add_lookup(ctx, clk, list->id);
  381. }
  382. }
  383. void __init rockchip_clk_register_branches(
  384. struct rockchip_clk_provider *ctx,
  385. struct rockchip_clk_branch *list,
  386. unsigned int nr_clk)
  387. {
  388. struct clk *clk = NULL;
  389. unsigned int idx;
  390. unsigned long flags;
  391. for (idx = 0; idx < nr_clk; idx++, list++) {
  392. flags = list->flags;
  393. /* catch simple muxes */
  394. switch (list->branch_type) {
  395. case branch_mux:
  396. clk = clk_register_mux(NULL, list->name,
  397. list->parent_names, list->num_parents,
  398. flags, ctx->reg_base + list->muxdiv_offset,
  399. list->mux_shift, list->mux_width,
  400. list->mux_flags, &ctx->lock);
  401. break;
  402. case branch_muxgrf:
  403. clk = rockchip_clk_register_muxgrf(list->name,
  404. list->parent_names, list->num_parents,
  405. flags, ctx->grf, list->muxdiv_offset,
  406. list->mux_shift, list->mux_width,
  407. list->mux_flags);
  408. break;
  409. case branch_divider:
  410. if (list->div_table)
  411. clk = clk_register_divider_table(NULL,
  412. list->name, list->parent_names[0],
  413. flags,
  414. ctx->reg_base + list->muxdiv_offset,
  415. list->div_shift, list->div_width,
  416. list->div_flags, list->div_table,
  417. &ctx->lock);
  418. else
  419. clk = clk_register_divider(NULL, list->name,
  420. list->parent_names[0], flags,
  421. ctx->reg_base + list->muxdiv_offset,
  422. list->div_shift, list->div_width,
  423. list->div_flags, &ctx->lock);
  424. break;
  425. case branch_fraction_divider:
  426. clk = rockchip_clk_register_frac_branch(ctx, list->name,
  427. list->parent_names, list->num_parents,
  428. ctx->reg_base, list->muxdiv_offset,
  429. list->div_flags,
  430. list->gate_offset, list->gate_shift,
  431. list->gate_flags, flags, list->child,
  432. &ctx->lock);
  433. break;
  434. case branch_half_divider:
  435. clk = rockchip_clk_register_halfdiv(list->name,
  436. list->parent_names, list->num_parents,
  437. ctx->reg_base, list->muxdiv_offset,
  438. list->mux_shift, list->mux_width,
  439. list->mux_flags, list->div_shift,
  440. list->div_width, list->div_flags,
  441. list->gate_offset, list->gate_shift,
  442. list->gate_flags, flags, &ctx->lock);
  443. break;
  444. case branch_gate:
  445. flags |= CLK_SET_RATE_PARENT;
  446. clk = clk_register_gate(NULL, list->name,
  447. list->parent_names[0], flags,
  448. ctx->reg_base + list->gate_offset,
  449. list->gate_shift, list->gate_flags, &ctx->lock);
  450. break;
  451. case branch_composite:
  452. clk = rockchip_clk_register_branch(list->name,
  453. list->parent_names, list->num_parents,
  454. ctx->reg_base, list->muxdiv_offset,
  455. list->mux_shift,
  456. list->mux_width, list->mux_flags,
  457. list->div_shift, list->div_width,
  458. list->div_flags, list->div_table,
  459. list->gate_offset, list->gate_shift,
  460. list->gate_flags, flags, &ctx->lock);
  461. break;
  462. case branch_mmc:
  463. clk = rockchip_clk_register_mmc(
  464. list->name,
  465. list->parent_names, list->num_parents,
  466. ctx->reg_base + list->muxdiv_offset,
  467. list->div_shift
  468. );
  469. break;
  470. case branch_inverter:
  471. clk = rockchip_clk_register_inverter(
  472. list->name, list->parent_names,
  473. list->num_parents,
  474. ctx->reg_base + list->muxdiv_offset,
  475. list->div_shift, list->div_flags, &ctx->lock);
  476. break;
  477. case branch_factor:
  478. clk = rockchip_clk_register_factor_branch(
  479. list->name, list->parent_names,
  480. list->num_parents, ctx->reg_base,
  481. list->div_shift, list->div_width,
  482. list->gate_offset, list->gate_shift,
  483. list->gate_flags, flags, &ctx->lock);
  484. break;
  485. case branch_ddrclk:
  486. clk = rockchip_clk_register_ddrclk(
  487. list->name, list->flags,
  488. list->parent_names, list->num_parents,
  489. list->muxdiv_offset, list->mux_shift,
  490. list->mux_width, list->div_shift,
  491. list->div_width, list->div_flags,
  492. ctx->reg_base, &ctx->lock);
  493. break;
  494. }
  495. /* none of the cases above matched */
  496. if (!clk) {
  497. pr_err("%s: unknown clock type %d\n",
  498. __func__, list->branch_type);
  499. continue;
  500. }
  501. if (IS_ERR(clk)) {
  502. pr_err("%s: failed to register clock %s: %ld\n",
  503. __func__, list->name, PTR_ERR(clk));
  504. continue;
  505. }
  506. rockchip_clk_add_lookup(ctx, clk, list->id);
  507. }
  508. }
  509. void __init rockchip_clk_register_armclk(struct rockchip_clk_provider *ctx,
  510. unsigned int lookup_id,
  511. const char *name, const char *const *parent_names,
  512. u8 num_parents,
  513. const struct rockchip_cpuclk_reg_data *reg_data,
  514. const struct rockchip_cpuclk_rate_table *rates,
  515. int nrates)
  516. {
  517. struct clk *clk;
  518. clk = rockchip_clk_register_cpuclk(name, parent_names, num_parents,
  519. reg_data, rates, nrates,
  520. ctx->reg_base, &ctx->lock);
  521. if (IS_ERR(clk)) {
  522. pr_err("%s: failed to register clock %s: %ld\n",
  523. __func__, name, PTR_ERR(clk));
  524. return;
  525. }
  526. rockchip_clk_add_lookup(ctx, clk, lookup_id);
  527. }
  528. void __init rockchip_clk_protect_critical(const char *const clocks[],
  529. int nclocks)
  530. {
  531. int i;
  532. /* Protect the clocks that needs to stay on */
  533. for (i = 0; i < nclocks; i++) {
  534. struct clk *clk = __clk_lookup(clocks[i]);
  535. if (clk)
  536. clk_prepare_enable(clk);
  537. }
  538. }
  539. static void __iomem *rst_base;
  540. static unsigned int reg_restart;
  541. static void (*cb_restart)(void);
  542. static int rockchip_restart_notify(struct notifier_block *this,
  543. unsigned long mode, void *cmd)
  544. {
  545. if (cb_restart)
  546. cb_restart();
  547. writel(0xfdb9, rst_base + reg_restart);
  548. return NOTIFY_DONE;
  549. }
  550. static struct notifier_block rockchip_restart_handler = {
  551. .notifier_call = rockchip_restart_notify,
  552. .priority = 128,
  553. };
  554. void __init
  555. rockchip_register_restart_notifier(struct rockchip_clk_provider *ctx,
  556. unsigned int reg,
  557. void (*cb)(void))
  558. {
  559. int ret;
  560. rst_base = ctx->reg_base;
  561. reg_restart = reg;
  562. cb_restart = cb;
  563. ret = register_restart_handler(&rockchip_restart_handler);
  564. if (ret)
  565. pr_err("%s: cannot register restart handler, %d\n",
  566. __func__, ret);
  567. }