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 clk *mpll;
123 struct cpufreq_frequency_table pll;
124 struct s3c_clkdivs divs;
125 struct s3c_cpufreq_info *info;
126 struct s3c_cpufreq_board *board;
127
128 unsigned int lock_pll:1;
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 int (*get_iotiming)(struct s3c_cpufreq_config *cfg,
172 struct s3c_iotimings *timings);
173
174 void (*set_iotiming)(struct s3c_cpufreq_config *cfg,
175 struct s3c_iotimings *timings);
176
177 int (*calc_iotiming)(struct s3c_cpufreq_config *cfg,
178 struct s3c_iotimings *timings);
179
180 int (*calc_freqtable)(struct s3c_cpufreq_config *cfg,
181 struct cpufreq_frequency_table *t,
182 size_t table_size);
183
184 void (*debug_io_show)(struct seq_file *seq,
185 struct s3c_cpufreq_config *cfg,
186 union s3c_iobank *iob);
187
188 void (*set_refresh)(struct s3c_cpufreq_config *cfg);
189 void (*set_fvco)(struct s3c_cpufreq_config *cfg);
190 void (*set_divs)(struct s3c_cpufreq_config *cfg);
191 int (*calc_divs)(struct s3c_cpufreq_config *cfg);
192};
193
194extern int s3c_cpufreq_register(struct s3c_cpufreq_info *info);
195
196extern int s3c_plltab_register(struct cpufreq_frequency_table *plls,
197 unsigned int plls_no);
198
199
200extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
201extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
202
203#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS
204#define s3c_cpufreq_debugfs_call(x) x
205#else
206#define s3c_cpufreq_debugfs_call(x) NULL
207#endif
208
209
210
211extern struct clk *s3c_cpufreq_clk_get(struct device *, const char *);
212
213
214
215extern void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
216extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
217
218#ifdef CONFIG_S3C2410_IOTIMING
219extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
220 struct s3c_cpufreq_config *cfg,
221 union s3c_iobank *iob);
222
223extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
224 struct s3c_iotimings *iot);
225
226extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
227 struct s3c_iotimings *timings);
228
229extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
230 struct s3c_iotimings *iot);
231#else
232#define s3c2410_iotiming_debugfs NULL
233#define s3c2410_iotiming_calc NULL
234#define s3c2410_iotiming_get NULL
235#define s3c2410_iotiming_set NULL
236#endif
237
238
239
240#ifdef CONFIG_S3C2412_IOTIMING
241extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
242 struct s3c_cpufreq_config *cfg,
243 union s3c_iobank *iob);
244
245extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
246 struct s3c_iotimings *timings);
247
248extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
249 struct s3c_iotimings *iot);
250
251extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
252 struct s3c_iotimings *iot);
253#else
254#define s3c2412_iotiming_debugfs NULL
255#define s3c2412_iotiming_calc NULL
256#define s3c2412_iotiming_get NULL
257#define s3c2412_iotiming_set NULL
258#endif
259
260#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUG
261#define s3c_freq_dbg(x...) printk(KERN_INFO x)
262#else
263#define s3c_freq_dbg(x...) do { if (0) printk(x); } while (0)
264#endif
265
266#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_IODEBUG
267#define s3c_freq_iodbg(x...) printk(KERN_INFO x)
268#else
269#define s3c_freq_iodbg(x...) do { if (0) printk(x); } while (0)
270#endif
271
272static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table,
273 int index, size_t table_size,
274 unsigned int freq)
275{
276 if (index < 0)
277 return index;
278
279 if (table) {
280 if (index >= table_size)
281 return -ENOMEM;
282
283 s3c_freq_dbg("%s: { %d = %u kHz }\n",
284 __func__, index, freq);
285
286 table[index].driver_data = index;
287 table[index].frequency = freq;
288 }
289
290 return index + 1;
291}
292