cpu-freq.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright (c) 2006-2007 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * S3C CPU frequency scaling support - driver and board
  8. */
  9. #include <linux/cpufreq.h>
  10. struct s3c_cpufreq_info;
  11. struct s3c_cpufreq_board;
  12. struct s3c_iotimings;
  13. /**
  14. * struct s3c_freq - frequency information (mainly for core drivers)
  15. * @fclk: The FCLK frequency in Hz.
  16. * @armclk: The ARMCLK frequency in Hz.
  17. * @hclk_tns: HCLK cycle time in 10ths of nano-seconds.
  18. * @hclk: The HCLK frequency in Hz.
  19. * @pclk: The PCLK frequency in Hz.
  20. *
  21. * This contains the frequency information about the current configuration
  22. * mainly for the core drivers to ensure we do not end up passing about
  23. * a large number of parameters.
  24. *
  25. * The @hclk_tns field is a useful cache for the parts of the drivers that
  26. * need to calculate IO timings and suchlike.
  27. */
  28. struct s3c_freq {
  29. unsigned long fclk;
  30. unsigned long armclk;
  31. unsigned long hclk_tns; /* in 10ths of ns */
  32. unsigned long hclk;
  33. unsigned long pclk;
  34. };
  35. /**
  36. * struct s3c_cpufreq_freqs - s3c cpufreq notification information.
  37. * @freqs: The cpufreq setting information.
  38. * @old: The old clock settings.
  39. * @new: The new clock settings.
  40. * @pll_changing: Set if the PLL is changing.
  41. *
  42. * Wrapper 'struct cpufreq_freqs' so that any drivers receiving the
  43. * notification can use this information that is not provided by just
  44. * having the core frequency alone.
  45. *
  46. * The pll_changing flag is used to indicate if the PLL itself is
  47. * being set during this change. This is important as the clocks
  48. * will temporarily be set to the XTAL clock during this time, so
  49. * drivers may want to close down their output during this time.
  50. *
  51. * Note, this is not being used by any current drivers and therefore
  52. * may be removed in the future.
  53. */
  54. struct s3c_cpufreq_freqs {
  55. struct cpufreq_freqs freqs;
  56. struct s3c_freq old;
  57. struct s3c_freq new;
  58. unsigned int pll_changing:1;
  59. };
  60. #define to_s3c_cpufreq(_cf) container_of(_cf, struct s3c_cpufreq_freqs, freqs)
  61. /**
  62. * struct s3c_clkdivs - clock divisor information
  63. * @p_divisor: Divisor from FCLK to PCLK.
  64. * @h_divisor: Divisor from FCLK to HCLK.
  65. * @arm_divisor: Divisor from FCLK to ARMCLK (not all CPUs).
  66. * @dvs: Non-zero if using DVS mode for ARMCLK.
  67. *
  68. * Divisor settings for the core clocks.
  69. */
  70. struct s3c_clkdivs {
  71. int p_divisor;
  72. int h_divisor;
  73. int arm_divisor;
  74. unsigned char dvs;
  75. };
  76. #define PLLVAL(_m, _p, _s) (((_m) << 12) | ((_p) << 4) | (_s))
  77. /**
  78. * struct s3c_pllval - PLL value entry.
  79. * @freq: The frequency for this entry in Hz.
  80. * @pll_reg: The PLL register setting for this PLL value.
  81. */
  82. struct s3c_pllval {
  83. unsigned long freq;
  84. unsigned long pll_reg;
  85. };
  86. /**
  87. * struct s3c_cpufreq_board - per-board cpu frequency informatin
  88. * @refresh: The SDRAM refresh period in nanoseconds.
  89. * @auto_io: Set if the IO timing settings should be generated from the
  90. * initialisation time hardware registers.
  91. * @need_io: Set if the board has external IO on any of the chipselect
  92. * lines that will require the hardware timing registers to be
  93. * updated on a clock change.
  94. * @max: The maxium frequency limits for the system. Any field that
  95. * is left at zero will use the CPU's settings.
  96. *
  97. * This contains the board specific settings that affect how the CPU
  98. * drivers chose settings. These include the memory refresh and IO
  99. * timing information.
  100. *
  101. * Registration depends on the driver being used, the ARMCLK only
  102. * implementation does not currently need this but the older style
  103. * driver requires this to be available.
  104. */
  105. struct s3c_cpufreq_board {
  106. unsigned int refresh;
  107. unsigned int auto_io:1; /* automatically init io timings. */
  108. unsigned int need_io:1; /* set if needs io timing support. */
  109. /* any non-zero field in here is taken as an upper limit. */
  110. struct s3c_freq max; /* frequency limits */
  111. };
  112. /* Things depending on frequency scaling. */
  113. #ifdef CONFIG_ARM_S3C_CPUFREQ
  114. #define __init_or_cpufreq
  115. #else
  116. #define __init_or_cpufreq __init
  117. #endif
  118. /* Board functions */
  119. #ifdef CONFIG_ARM_S3C_CPUFREQ
  120. extern int s3c_cpufreq_setboard(struct s3c_cpufreq_board *board);
  121. #else
  122. static inline int s3c_cpufreq_setboard(struct s3c_cpufreq_board *board)
  123. {
  124. return 0;
  125. }
  126. #endif /* CONFIG_ARM_S3C_CPUFREQ */