influenceAnalysisOfCableAging.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * OMAP2/3/4 DPLL clock 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. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. #undef DEBUG
  16. #include <linux/kernel.h>
  17. #include <linux/errno.h>
  18. #include <linux/clk-provider.h>
  19. #include <linux/io.h>
  20. #include <asm/div64.h>
  21. #include "soc.h"
  22. #include "clock.h"
  23. #include "cm-regbits-24xx.h"
  24. #include "cm-regbits-34xx.h"
  25. /* DPLL rate rounding: minimum DPLL multiplier, divider values */
  26. #define DPLL_MIN_MULTIPLIER 2
  27. #define DPLL_MIN_DIVIDER 1
  28. /* Possible error results from _dpll_test_mult */
  29. #define DPLL_MULT_UNDERFLOW -1
  30. /*
  31. * Scale factor to mitigate roundoff errors in DPLL rate rounding.
  32. * The higher the scale factor, the greater the risk of arithmetic overflow,
  33. * but the closer the rounded rate to the target rate. DPLL_SCALE_FACTOR
  34. * must be a power of DPLL_SCALE_BASE.
  35. */
  36. #define DPLL_SCALE_FACTOR 64
  37. #define DPLL_SCALE_BASE 2
  38. #define DPLL_ROUNDING_VAL ((DPLL_SCALE_BASE / 2) * \
  39. (DPLL_SCALE_FACTOR / DPLL_SCALE_BASE))
  40. /* DPLL valid Fint frequency band limits - from 34xx TRM Section 4.7.6.2 */
  41. #define OMAP3430_DPLL_FINT_BAND1_MIN 750000
  42. #define OMAP3430_DPLL_FINT_BAND1_MAX 2100000
  43. #define OMAP3430_DPLL_FINT_BAND2_MIN 7500000
  44. #define OMAP3430_DPLL_FINT_BAND2_MAX 21000000
  45. /*
  46. * DPLL valid Fint frequency range for OMAP36xx and OMAP4xxx.
  47. * From device data manual section 4.3 "DPLL and DLL Specifications".
  48. */
  49. #define OMAP3PLUS_DPLL_FINT_JTYPE_MIN 500000
  50. #define OMAP3PLUS_DPLL_FINT_JTYPE_MAX 2500000
  51. #define OMAP3PLUS_DPLL_FINT_MIN 32000
  52. #define OMAP3PLUS_DPLL_FINT_MAX 52000000
  53. /* _dpll_test_fint() return codes */
  54. #define DPLL_FINT_UNDERFLOW -1
  55. #define DPLL_FINT_INVALID -2
  56. /* Private functions */
  57. /*
  58. * _dpll_test_fint - test whether an Fint value is valid for the DPLL
  59. * @clk: DPLL struct clk to test
  60. * @n: divider value (N) to test
  61. *
  62. * Tests whether a particular divider @n will result in a valid DPLL
  63. * internal clock frequency Fint. See the 34xx TRM 4.7.6.2 "DPLL Jitter
  64. * Correction". Returns 0 if OK, -1 if the enclosing loop can terminate
  65. * (assuming that it is counting N upwards), or -2 if the enclosing loop
  66. * should skip to the next iteration (again assuming N is increasing).
  67. */
  68. static int _dpll_test_fint(struct clk_hw_omap *clk, u8 n)
  69. {
  70. struct dpll_data *dd;
  71. long fint, fint_min, fint_max;
  72. int ret = 0;
  73. dd = clk->dpll_data;
  74. /* DPLL divider must result in a valid jitter correction val */
  75. fint = __clk_get_rate(__clk_get_parent(clk->hw.clk)) / n;
  76. if (cpu_is_omap24xx()) {
  77. /* Should not be called for OMAP2, so warn if it is called */
  78. WARN(1, "No fint limits available for OMAP2!\n");
  79. return DPLL_FINT_INVALID;
  80. } else if (cpu_is_omap3430()) {
  81. fint_min = OMAP3430_DPLL_FINT_BAND1_MIN;
  82. fint_max = OMAP3430_DPLL_FINT_BAND2_MAX;
  83. } else if (dd->flags & DPLL_J_TYPE) {
  84. fint_min = OMAP3PLUS_DPLL_FINT_JTYPE_MIN;
  85. fint_max = OMAP3PLUS_DPLL_FINT_JTYPE_MAX;