clock2xxx.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * clock2xxx.c - OMAP2xxx-specific clock integration code
  3. *
  4. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2010 Nokia Corporation
  6. *
  7. * Contacts:
  8. * Richard Woodruff <r-woodruff2@ti.com>
  9. * Paul Walmsley
  10. *
  11. * Based on earlier work by Tuukka Tikkanen, Tony Lindgren,
  12. * Gordon McNutt and RidgeRun, Inc.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #undef DEBUG
  19. #include <linux/kernel.h>
  20. #include <linux/errno.h>
  21. #include <linux/clk.h>
  22. #include <linux/io.h>
  23. #include <plat/clock.h>
  24. #include "clock.h"
  25. #include "clock2xxx.h"
  26. #include "cm.h"
  27. #include "cm-regbits-24xx.h"
  28. struct clk *vclk, *sclk, *dclk;
  29. /*
  30. * Omap24xx specific clock functions
  31. */
  32. #ifdef CONFIG_ARCH_OMAP2430
  33. /**
  34. * omap2430_clk_i2chs_find_idlest - return CM_IDLEST info for 2430 I2CHS
  35. * @clk: struct clk * being enabled
  36. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  37. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  38. *
  39. * OMAP2430 I2CHS CM_IDLEST bits are in CM_IDLEST1_CORE, but the
  40. * CM_*CLKEN bits are in CM_{I,F}CLKEN2_CORE. This custom function
  41. * passes back the correct CM_IDLEST register address for I2CHS
  42. * modules. No return value.
  43. */
  44. static void omap2430_clk_i2chs_find_idlest(struct clk *clk,
  45. void __iomem **idlest_reg,
  46. u8 *idlest_bit)
  47. {
  48. *idlest_reg = OMAP_CM_REGADDR(CORE_MOD, CM_IDLEST);
  49. *idlest_bit = clk->enable_bit;
  50. }
  51. #else
  52. #define omap2430_clk_i2chs_find_idlest NULL
  53. #endif
  54. /* 2430 I2CHS has non-standard IDLEST register */
  55. const struct clkops clkops_omap2430_i2chs_wait = {
  56. .enable = omap2_dflt_clk_enable,
  57. .disable = omap2_dflt_clk_disable,
  58. .find_idlest = omap2430_clk_i2chs_find_idlest,
  59. .find_companion = omap2_clk_dflt_find_companion,
  60. };
  61. /*
  62. * Set clocks for bypass mode for reboot to work.
  63. */
  64. void omap2xxx_clk_prepare_for_reboot(void)
  65. {
  66. u32 rate;
  67. if (vclk == NULL || sclk == NULL)
  68. return;
  69. rate = clk_get_rate(sclk);
  70. clk_set_rate(vclk, rate);
  71. }
  72. /*
  73. * Switch the MPU rate if specified on cmdline.
  74. * We cannot do this early until cmdline is parsed.
  75. */
  76. static int __init omap2xxx_clk_arch_init(void)
  77. {
  78. struct clk *virt_prcm_set, *sys_ck, *dpll_ck, *mpu_ck;
  79. unsigned long sys_ck_rate;
  80. if (!cpu_is_omap24xx())
  81. return 0;
  82. if (!mpurate)
  83. return -EINVAL;
  84. virt_prcm_set = clk_get(NULL, "virt_prcm_set");
  85. sys_ck = clk_get(NULL, "sys_ck");
  86. dpll_ck = clk_get(NULL, "dpll_ck");
  87. mpu_ck = clk_get(NULL, "mpu_ck");
  88. if (clk_set_rate(virt_prcm_set, mpurate))
  89. printk(KERN_ERR "Could not find matching MPU rate\n");
  90. recalculate_root_clocks();
  91. sys_ck_rate = clk_get_rate(sys_ck);
  92. pr_info("Switched to new clocking rate (Crystal/DPLL/MPU): "
  93. "%ld.%01ld/%ld/%ld MHz\n",
  94. (sys_ck_rate / 1000000), (sys_ck_rate / 100000) % 10,
  95. (clk_get_rate(dpll_ck) / 1000000),
  96. (clk_get_rate(mpu_ck) / 1000000));
  97. return 0;
  98. }
  99. arch_initcall(omap2xxx_clk_arch_init);