clock.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * SH-Mobile Clock Framework
  3. *
  4. * Copyright (C) 2010 Magnus Damm
  5. *
  6. * Used together with arch/arm/common/clkdev.c and drivers/sh/clk.c.
  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 as published by
  10. * the Free Software Foundation; version 2 of the License.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. */
  22. #include <linux/kernel.h>
  23. #include <linux/init.h>
  24. #ifdef CONFIG_COMMON_CLK
  25. #include <linux/clk.h>
  26. #include <linux/clkdev.h>
  27. #include "clock.h"
  28. void __init shmobile_clk_workaround(const struct clk_name *clks,
  29. int nr_clks, bool enable)
  30. {
  31. const struct clk_name *clkn;
  32. struct clk *clk;
  33. unsigned int i;
  34. for (i = 0; i < nr_clks; ++i) {
  35. clkn = clks + i;
  36. clk = clk_get(NULL, clkn->clk);
  37. if (!IS_ERR(clk)) {
  38. clk_register_clkdev(clk, clkn->con_id, clkn->dev_id);
  39. if (enable)
  40. clk_prepare_enable(clk);
  41. clk_put(clk);
  42. }
  43. }
  44. }
  45. #else /* CONFIG_COMMON_CLK */
  46. #include <linux/sh_clk.h>
  47. #include <linux/export.h>
  48. #include "clock.h"
  49. #include "common.h"
  50. unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk)
  51. {
  52. struct clk_ratio *p = clk->priv;
  53. return clk->parent->rate / p->div * p->mul;
  54. };
  55. struct sh_clk_ops shmobile_fixed_ratio_clk_ops = {
  56. .recalc = shmobile_fixed_ratio_clk_recalc,
  57. };
  58. int __init shmobile_clk_init(void)
  59. {
  60. /* Kick the child clocks.. */
  61. recalculate_root_clocks();
  62. /* Enable the necessary init clocks */
  63. clk_enable_init_clocks();
  64. return 0;
  65. }
  66. int __clk_get(struct clk *clk)
  67. {
  68. return 1;
  69. }
  70. EXPORT_SYMBOL(__clk_get);
  71. void __clk_put(struct clk *clk)
  72. {
  73. }
  74. EXPORT_SYMBOL(__clk_put);
  75. #endif /* CONFIG_COMMON_CLK */