clock2xxx.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. * @idlest_val: pointer to a u8 to store the CM_IDLEST indicator
  39. *
  40. * OMAP2430 I2CHS CM_IDLEST bits are in CM_IDLEST1_CORE, but the
  41. * CM_*CLKEN bits are in CM_{I,F}CLKEN2_CORE. This custom function
  42. * passes back the correct CM_IDLEST register address for I2CHS
  43. * modules. No return value.
  44. */
  45. static void omap2430_clk_i2chs_find_idlest(struct clk *clk,
  46. void __iomem **idlest_reg,
  47. u8 *idlest_bit,
  48. u8 *idlest_val)
  49. {
  50. *idlest_reg = OMAP_CM_REGADDR(CORE_MOD, CM_IDLEST);
  51. *idlest_bit = clk->enable_bit;
  52. *idlest_val = OMAP24XX_CM_IDLEST_VAL;
  53. }
  54. #else
  55. #define omap2430_clk_i2chs_find_idlest NULL
  56. #endif
  57. /* 2430 I2CHS has non-standard IDLEST register */
  58. const struct clkops clkops_omap2430_i2chs_wait = {
  59. .enable = omap2_dflt_clk_enable,
  60. .disable = omap2_dflt_clk_disable,
  61. .find_idlest = omap2430_clk_i2chs_find_idlest,
  62. .find_companion = omap2_clk_dflt_find_companion,
  63. };
  64. /*
  65. * Set clocks for bypass mode for reboot to work.
  66. */
  67. void omap2xxx_clk_prepare_for_reboot(void)
  68. {
  69. u32 rate;
  70. if (vclk == NULL || sclk == NULL)
  71. return;
  72. rate = clk_get_rate(sclk);
  73. clk_set_rate(vclk, rate);
  74. }
  75. /*
  76. * Switch the MPU rate if specified on cmdline.
  77. * We cannot do this early until cmdline is parsed.
  78. */
  79. static int __init omap2xxx_clk_arch_init(void)
  80. {
  81. struct clk *virt_prcm_set, *sys_ck, *dpll_ck, *mpu_ck;
  82. unsigned long sys_ck_rate;
  83. if (!cpu_is_omap24xx())
  84. return 0;
  85. if (!mpurate)
  86. return -EINVAL;
  87. virt_prcm_set = clk_get(NULL, "virt_prcm_set");
  88. sys_ck = clk_get(NULL, "sys_ck");
  89. dpll_ck = clk_get(NULL, "dpll_ck");
  90. mpu_ck = clk_get(NULL, "mpu_ck");
  91. if (clk_set_rate(virt_prcm_set, mpurate))
  92. printk(KERN_ERR "Could not find matching MPU rate\n");
  93. recalculate_root_clocks();
  94. sys_ck_rate = clk_get_rate(sys_ck);
  95. pr_info("Switched to new clocking rate (Crystal/DPLL/MPU): "
  96. "%ld.%01ld/%ld/%ld MHz\n",
  97. (sys_ck_rate / 1000000), (sys_ck_rate / 100000) % 10,
  98. (clk_get_rate(dpll_ck) / 1000000),
  99. (clk_get_rate(mpu_ck) / 1000000));
  100. return 0;
  101. }
  102. arch_initcall(omap2xxx_clk_arch_init);