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