0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
0011
0012 #include <linux/init.h>
0013 #include <linux/export.h>
0014 #include <linux/interrupt.h>
0015 #include <linux/ioport.h>
0016 #include <linux/cpufreq.h>
0017 #include <linux/debugfs.h>
0018 #include <linux/seq_file.h>
0019 #include <linux/err.h>
0020
0021 #include <linux/soc/samsung/s3c-cpufreq-core.h>
0022
0023 static struct dentry *dbgfs_root;
0024 static struct dentry *dbgfs_file_io;
0025 static struct dentry *dbgfs_file_info;
0026 static struct dentry *dbgfs_file_board;
0027
0028 #define print_ns(x) ((x) / 10), ((x) % 10)
0029
0030 static void show_max(struct seq_file *seq, struct s3c_freq *f)
0031 {
0032 seq_printf(seq, "MAX: F=%lu, H=%lu, P=%lu, A=%lu\n",
0033 f->fclk, f->hclk, f->pclk, f->armclk);
0034 }
0035
0036 static int board_show(struct seq_file *seq, void *p)
0037 {
0038 struct s3c_cpufreq_config *cfg;
0039 struct s3c_cpufreq_board *brd;
0040
0041 cfg = s3c_cpufreq_getconfig();
0042 if (!cfg) {
0043 seq_printf(seq, "no configuration registered\n");
0044 return 0;
0045 }
0046
0047 brd = cfg->board;
0048 if (!brd) {
0049 seq_printf(seq, "no board definition set?\n");
0050 return 0;
0051 }
0052
0053 seq_printf(seq, "SDRAM refresh %u ns\n", brd->refresh);
0054 seq_printf(seq, "auto_io=%u\n", brd->auto_io);
0055 seq_printf(seq, "need_io=%u\n", brd->need_io);
0056
0057 show_max(seq, &brd->max);
0058
0059
0060 return 0;
0061 }
0062
0063 DEFINE_SHOW_ATTRIBUTE(board);
0064
0065 static int info_show(struct seq_file *seq, void *p)
0066 {
0067 struct s3c_cpufreq_config *cfg;
0068
0069 cfg = s3c_cpufreq_getconfig();
0070 if (!cfg) {
0071 seq_printf(seq, "no configuration registered\n");
0072 return 0;
0073 }
0074
0075 seq_printf(seq, " FCLK %ld Hz\n", cfg->freq.fclk);
0076 seq_printf(seq, " HCLK %ld Hz (%lu.%lu ns)\n",
0077 cfg->freq.hclk, print_ns(cfg->freq.hclk_tns));
0078 seq_printf(seq, " PCLK %ld Hz\n", cfg->freq.hclk);
0079 seq_printf(seq, "ARMCLK %ld Hz\n", cfg->freq.armclk);
0080 seq_printf(seq, "\n");
0081
0082 show_max(seq, &cfg->max);
0083
0084 seq_printf(seq, "Divisors: P=%d, H=%d, A=%d, dvs=%s\n",
0085 cfg->divs.h_divisor, cfg->divs.p_divisor,
0086 cfg->divs.arm_divisor, cfg->divs.dvs ? "on" : "off");
0087 seq_printf(seq, "\n");
0088
0089 seq_printf(seq, "lock_pll=%u\n", cfg->lock_pll);
0090
0091 return 0;
0092 }
0093
0094 DEFINE_SHOW_ATTRIBUTE(info);
0095
0096 static int io_show(struct seq_file *seq, void *p)
0097 {
0098 void (*show_bank)(struct seq_file *, struct s3c_cpufreq_config *, union s3c_iobank *);
0099 struct s3c_cpufreq_config *cfg;
0100 struct s3c_iotimings *iot;
0101 union s3c_iobank *iob;
0102 int bank;
0103
0104 cfg = s3c_cpufreq_getconfig();
0105 if (!cfg) {
0106 seq_printf(seq, "no configuration registered\n");
0107 return 0;
0108 }
0109
0110 show_bank = cfg->info->debug_io_show;
0111 if (!show_bank) {
0112 seq_printf(seq, "no code to show bank timing\n");
0113 return 0;
0114 }
0115
0116 iot = s3c_cpufreq_getiotimings();
0117 if (!iot) {
0118 seq_printf(seq, "no io timings registered\n");
0119 return 0;
0120 }
0121
0122 seq_printf(seq, "hclk period is %lu.%lu ns\n", print_ns(cfg->freq.hclk_tns));
0123
0124 for (bank = 0; bank < MAX_BANKS; bank++) {
0125 iob = &iot->bank[bank];
0126
0127 seq_printf(seq, "bank %d: ", bank);
0128
0129 if (!iob->io_2410) {
0130 seq_printf(seq, "nothing set\n");
0131 continue;
0132 }
0133
0134 show_bank(seq, cfg, iob);
0135 }
0136
0137 return 0;
0138 }
0139
0140 DEFINE_SHOW_ATTRIBUTE(io);
0141
0142 static int __init s3c_freq_debugfs_init(void)
0143 {
0144 dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL);
0145 if (IS_ERR(dbgfs_root)) {
0146 pr_err("%s: error creating debugfs root\n", __func__);
0147 return PTR_ERR(dbgfs_root);
0148 }
0149
0150 dbgfs_file_io = debugfs_create_file("io-timing", S_IRUGO, dbgfs_root,
0151 NULL, &io_fops);
0152
0153 dbgfs_file_info = debugfs_create_file("info", S_IRUGO, dbgfs_root,
0154 NULL, &info_fops);
0155
0156 dbgfs_file_board = debugfs_create_file("board", S_IRUGO, dbgfs_root,
0157 NULL, &board_fops);
0158
0159 return 0;
0160 }
0161
0162 late_initcall(s3c_freq_debugfs_init);
0163