1
2
3
4
5
6
7
8
9
10
11
12
13
14#include <plat/cpu-freq.h>
15
16struct seq_file;
17
18#define MAX_BANKS (8)
19#define S3C2412_MAX_IO (8)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36struct s3c2410_iobank_timing {
37 unsigned long bankcon;
38 unsigned int tacp;
39 unsigned int tacs;
40 unsigned int tcos;
41 unsigned int tacc;
42 unsigned int tcoh;
43 unsigned int tcah;
44 unsigned char nwait_en;
45};
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65struct s3c2412_iobank_timing {
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
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
82union s3c_iobank {
83 struct s3c2410_iobank_timing *io_2410;
84 struct s3c2412_iobank_timing *io_2412;
85};
86
87
88
89
90
91struct s3c_iotimings {
92 union s3c_iobank bank[MAX_BANKS];
93};
94
95
96
97
98
99
100struct s3c_plltab {
101 struct s3c_pllval *vals;
102 int size;
103};
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119struct s3c_cpufreq_config {
120 struct s3c_freq freq;
121 struct s3c_freq max;
122 struct cpufreq_frequency_table pll;
123 struct s3c_clkdivs divs;
124 struct s3c_cpufreq_info *info;
125 struct s3c_cpufreq_board *board;
126
127 unsigned int lock_pll:1;
128};
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157struct s3c_cpufreq_info {
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
170
171 void (*resume_clocks)(void);
172
173 int (*get_iotiming)(struct s3c_cpufreq_config *cfg,
174 struct s3c_iotimings *timings);
175
176 void (*set_iotiming)(struct s3c_cpufreq_config *cfg,
177 struct s3c_iotimings *timings);
178
179 int (*calc_iotiming)(struct s3c_cpufreq_config *cfg,
180 struct s3c_iotimings *timings);
181
182 int (*calc_freqtable)(struct s3c_cpufreq_config *cfg,
183 struct cpufreq_frequency_table *t,
184 size_t table_size);
185
186 void (*debug_io_show)(struct seq_file *seq,
187 struct s3c_cpufreq_config *cfg,
188 union s3c_iobank *iob);
189
190 void (*set_refresh)(struct s3c_cpufreq_config *cfg);
191 void (*set_fvco)(struct s3c_cpufreq_config *cfg);
192 void (*set_divs)(struct s3c_cpufreq_config *cfg);
193 int (*calc_divs)(struct s3c_cpufreq_config *cfg);
194};
195
196extern int s3c_cpufreq_register(struct s3c_cpufreq_info *info);
197
198extern int s3c_plltab_register(struct cpufreq_frequency_table *plls, unsigned int plls_no);
199
200
201extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
202extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
203
204extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
205 struct s3c_cpufreq_config *cfg,
206 union s3c_iobank *iob);
207
208extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
209 struct s3c_cpufreq_config *cfg,
210 union s3c_iobank *iob);
211
212#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUGFS
213#define s3c_cpufreq_debugfs_call(x) x
214#else
215#define s3c_cpufreq_debugfs_call(x) NULL
216#endif
217
218
219
220extern struct clk *s3c_cpufreq_clk_get(struct device *, const char *);
221
222
223
224extern void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
225extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
226
227#ifdef CONFIG_S3C2410_IOTIMING
228extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
229 struct s3c_iotimings *iot);
230
231extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
232 struct s3c_iotimings *timings);
233
234extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
235 struct s3c_iotimings *iot);
236#else
237#define s3c2410_iotiming_calc NULL
238#define s3c2410_iotiming_get NULL
239#define s3c2410_iotiming_set NULL
240#endif
241
242
243
244extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
245 struct s3c_iotimings *timings);
246
247extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
248 struct s3c_iotimings *timings);
249
250extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
251 struct s3c_iotimings *iot);
252
253extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
254 struct s3c_iotimings *iot);
255
256#ifdef CONFIG_CPU_FREQ_S3C24XX_DEBUG
257#define s3c_freq_dbg(x...) printk(KERN_INFO x)
258#else
259#define s3c_freq_dbg(x...) do { if (0) printk(x); } while (0)
260#endif
261
262#ifdef CONFIG_CPU_FREQ_S3C24XX_IODEBUG
263#define s3c_freq_iodbg(x...) printk(KERN_INFO x)
264#else
265#define s3c_freq_iodbg(x...) do { if (0) printk(x); } while (0)
266#endif
267
268static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table,
269 int index, size_t table_size,
270 unsigned int freq)
271{
272 if (index < 0)
273 return index;
274
275 if (table) {
276 if (index >= table_size)
277 return -ENOMEM;
278
279 s3c_freq_dbg("%s: { %d = %u kHz }\n",
280 __func__, index, freq);
281
282 table[index].index = index;
283 table[index].frequency = freq;
284 }
285
286 return index + 1;
287}
288