1
2
3
4
5
6
7
8
9
10#include <plat/cpu-freq.h>
11
12struct seq_file;
13
14#define MAX_BANKS (8)
15#define S3C2412_MAX_IO (8)
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32struct s3c2410_iobank_timing {
33 unsigned long bankcon;
34 unsigned int tacp;
35 unsigned int tacs;
36 unsigned int tcos;
37 unsigned int tacc;
38 unsigned int tcoh;
39 unsigned int tcah;
40 unsigned char nwait_en;
41};
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61struct s3c2412_iobank_timing {
62 unsigned int idcy;
63 unsigned int wstrd;
64 unsigned int wstwr;
65 unsigned int wstoen;
66 unsigned int wstwen;
67 unsigned int wstbrd;
68
69
70 unsigned char smbidcyr;
71 unsigned char smbwstrd;
72 unsigned char smbwstwr;
73 unsigned char smbwstoen;
74 unsigned char smbwstwen;
75 unsigned char smbwstbrd;
76};
77
78union s3c_iobank {
79 struct s3c2410_iobank_timing *io_2410;
80 struct s3c2412_iobank_timing *io_2412;
81};
82
83
84
85
86
87struct s3c_iotimings {
88 union s3c_iobank bank[MAX_BANKS];
89};
90
91
92
93
94
95
96struct s3c_plltab {
97 struct s3c_pllval *vals;
98 int size;
99};
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115struct s3c_cpufreq_config {
116 struct s3c_freq freq;
117 struct s3c_freq max;
118 struct clk *mpll;
119 struct cpufreq_frequency_table pll;
120 struct s3c_clkdivs divs;
121 struct s3c_cpufreq_info *info;
122 struct s3c_cpufreq_board *board;
123
124 unsigned int lock_pll:1;
125};
126
127
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
153struct s3c_cpufreq_info {
154 const char *name;
155 struct s3c_freq max;
156
157 unsigned int latency;
158
159 unsigned int locktime_m;
160 unsigned int locktime_u;
161 unsigned char locktime_bits;
162
163 unsigned int need_pll:1;
164
165
166
167 int (*get_iotiming)(struct s3c_cpufreq_config *cfg,
168 struct s3c_iotimings *timings);
169
170 void (*set_iotiming)(struct s3c_cpufreq_config *cfg,
171 struct s3c_iotimings *timings);
172
173 int (*calc_iotiming)(struct s3c_cpufreq_config *cfg,
174 struct s3c_iotimings *timings);
175
176 int (*calc_freqtable)(struct s3c_cpufreq_config *cfg,
177 struct cpufreq_frequency_table *t,
178 size_t table_size);
179
180 void (*debug_io_show)(struct seq_file *seq,
181 struct s3c_cpufreq_config *cfg,
182 union s3c_iobank *iob);
183
184 void (*set_refresh)(struct s3c_cpufreq_config *cfg);
185 void (*set_fvco)(struct s3c_cpufreq_config *cfg);
186 void (*set_divs)(struct s3c_cpufreq_config *cfg);
187 int (*calc_divs)(struct s3c_cpufreq_config *cfg);
188};
189
190extern int s3c_cpufreq_register(struct s3c_cpufreq_info *info);
191
192extern int s3c_plltab_register(struct cpufreq_frequency_table *plls,
193 unsigned int plls_no);
194
195
196extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
197extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
198
199#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS
200#define s3c_cpufreq_debugfs_call(x) x
201#else
202#define s3c_cpufreq_debugfs_call(x) NULL
203#endif
204
205
206
207extern struct clk *s3c_cpufreq_clk_get(struct device *, const char *);
208
209
210
211extern void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
212extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
213
214#ifdef CONFIG_S3C2410_IOTIMING
215extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
216 struct s3c_cpufreq_config *cfg,
217 union s3c_iobank *iob);
218
219extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
220 struct s3c_iotimings *iot);
221
222extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
223 struct s3c_iotimings *timings);
224
225extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
226 struct s3c_iotimings *iot);
227#else
228#define s3c2410_iotiming_debugfs NULL
229#define s3c2410_iotiming_calc NULL
230#define s3c2410_iotiming_get NULL
231#define s3c2410_iotiming_set NULL
232#endif
233
234
235
236#ifdef CONFIG_S3C2412_IOTIMING
237extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
238 struct s3c_cpufreq_config *cfg,
239 union s3c_iobank *iob);
240
241extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
242 struct s3c_iotimings *timings);
243
244extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
245 struct s3c_iotimings *iot);
246
247extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
248 struct s3c_iotimings *iot);
249#else
250#define s3c2412_iotiming_debugfs NULL
251#define s3c2412_iotiming_calc NULL
252#define s3c2412_iotiming_get NULL
253#define s3c2412_iotiming_set NULL
254#endif
255
256#ifdef CONFIG_ARM_S3C24XX_CPUFREQ_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_ARM_S3C24XX_CPUFREQ_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].driver_data = index;
283 table[index].frequency = freq;
284 }
285
286 return index + 1;
287}
288