Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cpu-freq-core.h
Go to the documentation of this file.
1 /* arch/arm/plat-samsung/include/plat/cpu-freq-core.h
2  *
3  * Copyright (c) 2006-2009 Simtec Electronics
4  * http://armlinux.simtec.co.uk/
5  * Ben Dooks <[email protected]>
6  *
7  * S3C CPU frequency scaling support - core support
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 <plat/cpu-freq.h>
15 
16 struct seq_file;
17 
18 #define MAX_BANKS (8)
19 #define S3C2412_MAX_IO (8)
20 
37  unsigned long bankcon;
38  unsigned int tacp;
39  unsigned int tacs;
40  unsigned int tcos;
41  unsigned int tacc;
42  unsigned int tcoh; /* nCS hold afrer nOE/nWE */
43  unsigned int tcah; /* Address hold after nCS */
44  unsigned char nwait_en; /* nWait enabled for bank. */
45 };
46 
66  unsigned int idcy;
67  unsigned int wstrd;
68  unsigned int wstwr;
69  unsigned int wstoen;
70  unsigned int wstwen;
71  unsigned int wstbrd;
72 
73  /* register cache */
74  unsigned char smbidcyr;
75  unsigned char smbwstrd;
76  unsigned char smbwstwr;
77  unsigned char smbwstoen;
78  unsigned char smbwstwen;
79  unsigned char smbwstbrd;
80 };
81 
82 union s3c_iobank {
85 };
86 
91 struct s3c_iotimings {
93 };
94 
100 struct s3c_plltab {
101  struct s3c_pllval *vals;
102  int size;
103 };
104 
120  struct s3c_freq freq;
121  struct s3c_freq max;
124  struct s3c_cpufreq_info *info; /* for core, not drivers */
126 
127  unsigned int lock_pll:1;
128 };
129 
158  const char *name;
159  struct s3c_freq max;
160 
161  unsigned int latency;
162 
163  unsigned int locktime_m;
164  unsigned int locktime_u;
165  unsigned char locktime_bits;
166 
167  unsigned int need_pll:1;
168 
169  /* driver routines */
170 
172 
174  struct s3c_iotimings *timings);
175 
177  struct s3c_iotimings *timings);
178 
180  struct s3c_iotimings *timings);
181 
183  struct cpufreq_frequency_table *t,
184  size_t table_size);
185 
187  struct s3c_cpufreq_config *cfg,
188  union s3c_iobank *iob);
189 
194 };
195 
196 extern int s3c_cpufreq_register(struct s3c_cpufreq_info *info);
197 
198 extern int s3c_plltab_register(struct cpufreq_frequency_table *plls,
199  unsigned int plls_no);
200 
201 /* exports and utilities for debugfs */
202 extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
203 extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
204 
205 #ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS
206 #define s3c_cpufreq_debugfs_call(x) x
207 #else
208 #define s3c_cpufreq_debugfs_call(x) NULL
209 #endif
210 
211 /* Useful utility functions. */
212 
213 extern struct clk *s3c_cpufreq_clk_get(struct device *, const char *);
214 
215 /* S3C2410 and compatible exported functions */
216 
218 extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
219 
220 #ifdef CONFIG_S3C2410_IOTIMING
221 extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
222  struct s3c_cpufreq_config *cfg,
223  union s3c_iobank *iob);
224 
225 extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
226  struct s3c_iotimings *iot);
227 
228 extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
229  struct s3c_iotimings *timings);
230 
231 extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
232  struct s3c_iotimings *iot);
233 #else
234 #define s3c2410_iotiming_debugfs NULL
235 #define s3c2410_iotiming_calc NULL
236 #define s3c2410_iotiming_get NULL
237 #define s3c2410_iotiming_set NULL
238 #endif /* CONFIG_S3C2410_IOTIMING */
239 
240 /* S3C2412 compatible routines */
241 
242 #ifdef CONFIG_S3C2412_IOTIMING
243 extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
244  struct s3c_cpufreq_config *cfg,
245  union s3c_iobank *iob);
246 
247 extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
248  struct s3c_iotimings *timings);
249 
250 extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
251  struct s3c_iotimings *iot);
252 
253 extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
254  struct s3c_iotimings *iot);
255 #else
256 #define s3c2412_iotiming_debugfs NULL
257 #define s3c2412_iotiming_calc NULL
258 #define s3c2412_iotiming_get NULL
259 #define s3c2412_iotiming_set NULL
260 #endif /* CONFIG_S3C2412_IOTIMING */
261 
262 #ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUG
263 #define s3c_freq_dbg(x...) printk(KERN_INFO x)
264 #else
265 #define s3c_freq_dbg(x...) do { if (0) printk(x); } while (0)
266 #endif /* CONFIG_CPU_FREQ_S3C24XX_DEBUG */
267 
268 #ifdef CONFIG_CPU_FREQ_S3C24XX_IODEBUG
269 #define s3c_freq_iodbg(x...) printk(KERN_INFO x)
270 #else
271 #define s3c_freq_iodbg(x...) do { if (0) printk(x); } while (0)
272 #endif /* CONFIG_CPU_FREQ_S3C24XX_IODEBUG */
273 
274 static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table,
275  int index, size_t table_size,
276  unsigned int freq)
277 {
278  if (index < 0)
279  return index;
280 
281  if (table) {
282  if (index >= table_size)
283  return -ENOMEM;
284 
285  s3c_freq_dbg("%s: { %d = %u kHz }\n",
286  __func__, index, freq);
287 
288  table[index].index = index;
289  table[index].frequency = freq;
290  }
291 
292  return index + 1;
293 }