clock2xxx.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * linux/arch/arm/mach-omap2/clock.c
  3. *
  4. * Copyright (C) 2005-2008 Texas Instruments, Inc.
  5. * Copyright (C) 2004-2008 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/module.h>
  20. #include <linux/kernel.h>
  21. #include <linux/device.h>
  22. #include <linux/list.h>
  23. #include <linux/errno.h>
  24. #include <linux/delay.h>
  25. #include <linux/clk.h>
  26. #include <linux/io.h>
  27. #include <linux/cpufreq.h>
  28. #include <linux/bitops.h>
  29. #include <plat/clock.h>
  30. #include <plat/sram.h>
  31. #include <plat/prcm.h>
  32. #include <plat/clkdev_omap.h>
  33. #include <asm/div64.h>
  34. #include <asm/clkdev.h>
  35. #include <plat/sdrc.h>
  36. #include "clock.h"
  37. #include "clock2xxx.h"
  38. #include "opp2xxx.h"
  39. #include "prm.h"
  40. #include "prm-regbits-24xx.h"
  41. #include "cm.h"
  42. #include "cm-regbits-24xx.h"
  43. struct clk *vclk, *sclk, *dclk;
  44. /*-------------------------------------------------------------------------
  45. * Omap24xx specific clock functions
  46. *-------------------------------------------------------------------------*/
  47. #ifdef CONFIG_ARCH_OMAP2430
  48. /**
  49. * omap2430_clk_i2chs_find_idlest - return CM_IDLEST info for 2430 I2CHS
  50. * @clk: struct clk * being enabled
  51. * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
  52. * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
  53. *
  54. * OMAP2430 I2CHS CM_IDLEST bits are in CM_IDLEST1_CORE, but the
  55. * CM_*CLKEN bits are in CM_{I,F}CLKEN2_CORE. This custom function
  56. * passes back the correct CM_IDLEST register address for I2CHS
  57. * modules. No return value.
  58. */
  59. static void omap2430_clk_i2chs_find_idlest(struct clk *clk,
  60. void __iomem **idlest_reg,
  61. u8 *idlest_bit)
  62. {
  63. *idlest_reg = OMAP_CM_REGADDR(CORE_MOD, CM_IDLEST);
  64. *idlest_bit = clk->enable_bit;
  65. }
  66. #else
  67. #define omap2430_clk_i2chs_find_idlest NULL
  68. #endif
  69. /* 2430 I2CHS has non-standard IDLEST register */
  70. const struct clkops clkops_omap2430_i2chs_wait = {
  71. .enable = omap2_dflt_clk_enable,
  72. .disable = omap2_dflt_clk_disable,
  73. .find_idlest = omap2430_clk_i2chs_find_idlest,
  74. .find_companion = omap2_clk_dflt_find_companion,
  75. };
  76. /*
  77. * Set clocks for bypass mode for reboot to work.
  78. */
  79. void omap2_clk_prepare_for_reboot(void)
  80. {
  81. u32 rate;
  82. if (vclk == NULL || sclk == NULL)
  83. return;
  84. rate = clk_get_rate(sclk);
  85. clk_set_rate(vclk, rate);
  86. }
  87. /*
  88. * Switch the MPU rate if specified on cmdline.
  89. * We cannot do this early until cmdline is parsed.
  90. */
  91. static int __init omap2xxx_clk_arch_init(void)
  92. {
  93. struct clk *virt_prcm_set, *sys_ck, *dpll_ck, *mpu_ck;
  94. unsigned long sys_ck_rate;
  95. if (!cpu_is_omap24xx())
  96. return 0;
  97. if (!mpurate)
  98. return -EINVAL;
  99. virt_prcm_set = clk_get(NULL, "virt_prcm_set");
  100. sys_ck = clk_get(NULL, "sys_ck");
  101. dpll_ck = clk_get(NULL, "dpll_ck");
  102. mpu_ck = clk_get(NULL, "mpu_ck");
  103. if (clk_set_rate(virt_prcm_set, mpurate))
  104. printk(KERN_ERR "Could not find matching MPU rate\n");
  105. recalculate_root_clocks();
  106. sys_ck_rate = clk_get_rate(sys_ck);
  107. pr_info("Switched to new clocking rate (Crystal/DPLL/MPU): "
  108. "%ld.%01ld/%ld/%ld MHz\n",
  109. (sys_ck_rate / 1000000), (sys_ck_rate / 100000) % 10,
  110. (clk_get_rate(dpll_ck) / 1000000),
  111. (clk_get_rate(mpu_ck) / 1000000));
  112. return 0;
  113. }
  114. arch_initcall(omap2xxx_clk_arch_init);