clkt2xxx_apll.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * OMAP2xxx APLL clock control functions
  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/clk.h>
  21. #include <linux/io.h>
  22. #include "clock.h"
  23. #include "clock2xxx.h"
  24. #include "cm2xxx.h"
  25. #include "cm-regbits-24xx.h"
  26. /* CM_CLKEN_PLL.EN_{54,96}M_PLL options (24XX) */
  27. #define EN_APLL_STOPPED 0
  28. #define EN_APLL_LOCKED 3
  29. /* CM_CLKSEL1_PLL.APLLS_CLKIN options (24XX) */
  30. #define APLLS_CLKIN_19_2MHZ 0
  31. #define APLLS_CLKIN_13MHZ 2
  32. #define APLLS_CLKIN_12MHZ 3
  33. /* Private functions */
  34. static int _apll96_enable(struct clk *clk)
  35. {
  36. return omap2xxx_cm_apll96_enable();
  37. }
  38. static int _apll54_enable(struct clk *clk)
  39. {
  40. return omap2xxx_cm_apll54_enable();
  41. }
  42. static void _apll96_allow_idle(struct clk *clk)
  43. {
  44. omap2xxx_cm_set_apll96_auto_low_power_stop();
  45. }
  46. static void _apll96_deny_idle(struct clk *clk)
  47. {
  48. omap2xxx_cm_set_apll96_disable_autoidle();
  49. }
  50. static void _apll54_allow_idle(struct clk *clk)
  51. {
  52. omap2xxx_cm_set_apll54_auto_low_power_stop();
  53. }
  54. static void _apll54_deny_idle(struct clk *clk)
  55. {
  56. omap2xxx_cm_set_apll54_disable_autoidle();
  57. }
  58. static void _apll96_disable(struct clk *clk)
  59. {
  60. omap2xxx_cm_apll96_disable();
  61. }
  62. static void _apll54_disable(struct clk *clk)
  63. {
  64. omap2xxx_cm_apll54_disable();
  65. }
  66. /* Public data */
  67. const struct clkops clkops_apll96 = {
  68. .enable = _apll96_enable,
  69. .disable = _apll96_disable,
  70. .allow_idle = _apll96_allow_idle,
  71. .deny_idle = _apll96_deny_idle,
  72. };
  73. const struct clkops clkops_apll54 = {
  74. .enable = _apll54_enable,
  75. .disable = _apll54_disable,
  76. .allow_idle = _apll54_allow_idle,
  77. .deny_idle = _apll54_deny_idle,
  78. };
  79. /* Public functions */
  80. u32 omap2xxx_get_apll_clkin(void)
  81. {
  82. u32 aplls, srate = 0;
  83. aplls = omap2_cm_read_mod_reg(PLL_MOD, CM_CLKSEL1);
  84. aplls &= OMAP24XX_APLLS_CLKIN_MASK;
  85. aplls >>= OMAP24XX_APLLS_CLKIN_SHIFT;
  86. if (aplls == APLLS_CLKIN_19_2MHZ)
  87. srate = 19200000;
  88. else if (aplls == APLLS_CLKIN_13MHZ)
  89. srate = 13000000;
  90. else if (aplls == APLLS_CLKIN_12MHZ)
  91. srate = 12000000;
  92. return srate;
  93. }