cpu-freq.h 4.4 KB

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