0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __LINUX_SOC_SAMSUNG_S3C_CPUFREQ_CORE_H
0010 #define __LINUX_SOC_SAMSUNG_S3C_CPUFREQ_CORE_H
0011
0012 #include <linux/soc/samsung/s3c-cpu-freq.h>
0013
0014 struct seq_file;
0015
0016 #define MAX_BANKS (8)
0017 #define S3C2412_MAX_IO (8)
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct s3c2410_iobank_timing {
0035 unsigned long bankcon;
0036 unsigned int tacp;
0037 unsigned int tacs;
0038 unsigned int tcos;
0039 unsigned int tacc;
0040 unsigned int tcoh;
0041 unsigned int tcah;
0042 unsigned char nwait_en;
0043 };
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 struct s3c2412_iobank_timing {
0064 unsigned int idcy;
0065 unsigned int wstrd;
0066 unsigned int wstwr;
0067 unsigned int wstoen;
0068 unsigned int wstwen;
0069 unsigned int wstbrd;
0070
0071
0072 unsigned char smbidcyr;
0073 unsigned char smbwstrd;
0074 unsigned char smbwstwr;
0075 unsigned char smbwstoen;
0076 unsigned char smbwstwen;
0077 unsigned char smbwstbrd;
0078 };
0079
0080 union s3c_iobank {
0081 struct s3c2410_iobank_timing *io_2410;
0082 struct s3c2412_iobank_timing *io_2412;
0083 };
0084
0085
0086
0087
0088
0089 struct s3c_iotimings {
0090 union s3c_iobank bank[MAX_BANKS];
0091 };
0092
0093
0094
0095
0096
0097
0098 struct s3c_plltab {
0099 struct s3c_pllval *vals;
0100 int size;
0101 };
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117 struct s3c_cpufreq_config {
0118 struct s3c_freq freq;
0119 struct s3c_freq max;
0120 struct clk *mpll;
0121 struct cpufreq_frequency_table pll;
0122 struct s3c_clkdivs divs;
0123 struct s3c_cpufreq_info *info;
0124 struct s3c_cpufreq_board *board;
0125
0126 unsigned int lock_pll:1;
0127 };
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155 struct s3c_cpufreq_info {
0156 const char *name;
0157 struct s3c_freq max;
0158
0159 unsigned int latency;
0160
0161 unsigned int locktime_m;
0162 unsigned int locktime_u;
0163 unsigned char locktime_bits;
0164
0165 unsigned int need_pll:1;
0166
0167
0168
0169 int (*get_iotiming)(struct s3c_cpufreq_config *cfg,
0170 struct s3c_iotimings *timings);
0171
0172 void (*set_iotiming)(struct s3c_cpufreq_config *cfg,
0173 struct s3c_iotimings *timings);
0174
0175 int (*calc_iotiming)(struct s3c_cpufreq_config *cfg,
0176 struct s3c_iotimings *timings);
0177
0178 int (*calc_freqtable)(struct s3c_cpufreq_config *cfg,
0179 struct cpufreq_frequency_table *t,
0180 size_t table_size);
0181
0182 void (*debug_io_show)(struct seq_file *seq,
0183 struct s3c_cpufreq_config *cfg,
0184 union s3c_iobank *iob);
0185
0186 void (*set_refresh)(struct s3c_cpufreq_config *cfg);
0187 void (*set_fvco)(struct s3c_cpufreq_config *cfg);
0188 void (*set_divs)(struct s3c_cpufreq_config *cfg);
0189 int (*calc_divs)(struct s3c_cpufreq_config *cfg);
0190 };
0191
0192 extern int s3c_cpufreq_register(struct s3c_cpufreq_info *info);
0193
0194 extern int s3c_plltab_register(struct cpufreq_frequency_table *plls,
0195 unsigned int plls_no);
0196
0197
0198 extern struct s3c_cpufreq_config *s3c_cpufreq_getconfig(void);
0199 extern struct s3c_iotimings *s3c_cpufreq_getiotimings(void);
0200
0201 #ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS
0202 #define s3c_cpufreq_debugfs_call(x) x
0203 #else
0204 #define s3c_cpufreq_debugfs_call(x) NULL
0205 #endif
0206
0207
0208
0209 extern struct clk *s3c_cpufreq_clk_get(struct device *, const char *);
0210
0211
0212
0213 extern void s3c2410_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
0214 extern void s3c2410_set_fvco(struct s3c_cpufreq_config *cfg);
0215
0216 #ifdef CONFIG_S3C2410_IOTIMING
0217 extern void s3c2410_iotiming_debugfs(struct seq_file *seq,
0218 struct s3c_cpufreq_config *cfg,
0219 union s3c_iobank *iob);
0220
0221 extern int s3c2410_iotiming_calc(struct s3c_cpufreq_config *cfg,
0222 struct s3c_iotimings *iot);
0223
0224 extern int s3c2410_iotiming_get(struct s3c_cpufreq_config *cfg,
0225 struct s3c_iotimings *timings);
0226
0227 extern void s3c2410_iotiming_set(struct s3c_cpufreq_config *cfg,
0228 struct s3c_iotimings *iot);
0229 #else
0230 #define s3c2410_iotiming_debugfs NULL
0231 #define s3c2410_iotiming_calc NULL
0232 #define s3c2410_iotiming_get NULL
0233 #define s3c2410_iotiming_set NULL
0234 #endif
0235
0236
0237
0238 #ifdef CONFIG_S3C2412_IOTIMING
0239 extern void s3c2412_iotiming_debugfs(struct seq_file *seq,
0240 struct s3c_cpufreq_config *cfg,
0241 union s3c_iobank *iob);
0242
0243 extern int s3c2412_iotiming_get(struct s3c_cpufreq_config *cfg,
0244 struct s3c_iotimings *timings);
0245
0246 extern int s3c2412_iotiming_calc(struct s3c_cpufreq_config *cfg,
0247 struct s3c_iotimings *iot);
0248
0249 extern void s3c2412_iotiming_set(struct s3c_cpufreq_config *cfg,
0250 struct s3c_iotimings *iot);
0251 extern void s3c2412_cpufreq_setrefresh(struct s3c_cpufreq_config *cfg);
0252 #else
0253 #define s3c2412_iotiming_debugfs NULL
0254 #define s3c2412_iotiming_calc NULL
0255 #define s3c2412_iotiming_get NULL
0256 #define s3c2412_iotiming_set NULL
0257 #endif
0258
0259 #ifdef CONFIG_ARM_S3C24XX_CPUFREQ_DEBUG
0260 #define s3c_freq_dbg(x...) printk(KERN_INFO x)
0261 #else
0262 #define s3c_freq_dbg(x...) do { if (0) printk(x); } while (0)
0263 #endif
0264
0265 #ifdef CONFIG_ARM_S3C24XX_CPUFREQ_IODEBUG
0266 #define s3c_freq_iodbg(x...) printk(KERN_INFO x)
0267 #else
0268 #define s3c_freq_iodbg(x...) do { if (0) printk(x); } while (0)
0269 #endif
0270
0271 static inline int s3c_cpufreq_addfreq(struct cpufreq_frequency_table *table,
0272 int index, size_t table_size,
0273 unsigned int freq)
0274 {
0275 if (index < 0)
0276 return index;
0277
0278 if (table) {
0279 if (index >= table_size)
0280 return -ENOMEM;
0281
0282 s3c_freq_dbg("%s: { %d = %u kHz }\n",
0283 __func__, index, freq);
0284
0285 table[index].driver_data = index;
0286 table[index].frequency = freq;
0287 }
0288
0289 return index + 1;
0290 }
0291
0292 u32 s3c2440_read_camdivn(void);
0293 void s3c2440_write_camdivn(u32 camdiv);
0294 u32 s3c24xx_read_clkdivn(void);
0295 void s3c24xx_write_clkdivn(u32 clkdiv);
0296 u32 s3c24xx_read_mpllcon(void);
0297 void s3c24xx_write_locktime(u32 locktime);
0298
0299 #endif