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