davinci: enable ARCH_HAS_HOLES_MEMORYMODEL for DaVinci
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / plat-s3c24xx / cpu-freq-debugfs.c
bloba9276667c2fb0e59c21e643aab28aef2debdee84
1 /* linux/arch/arm/plat-s3c24xx/cpu-freq-debugfs.c
3 * Copyright (c) 2009 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
7 * S3C24XX CPU Frequency scaling - debugfs status support
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/interrupt.h>
17 #include <linux/ioport.h>
18 #include <linux/cpufreq.h>
19 #include <linux/debugfs.h>
20 #include <linux/seq_file.h>
21 #include <linux/err.h>
23 #include <plat/cpu-freq-core.h>
25 static struct dentry *dbgfs_root;
26 static struct dentry *dbgfs_file_io;
27 static struct dentry *dbgfs_file_info;
28 static struct dentry *dbgfs_file_board;
30 #define print_ns(x) ((x) / 10), ((x) % 10)
32 static void show_max(struct seq_file *seq, struct s3c_freq *f)
34 seq_printf(seq, "MAX: F=%lu, H=%lu, P=%lu, A=%lu\n",
35 f->fclk, f->hclk, f->pclk, f->armclk);
38 static int board_show(struct seq_file *seq, void *p)
40 struct s3c_cpufreq_config *cfg;
41 struct s3c_cpufreq_board *brd;
43 cfg = s3c_cpufreq_getconfig();
44 if (!cfg) {
45 seq_printf(seq, "no configuration registered\n");
46 return 0;
49 brd = cfg->board;
50 if (!brd) {
51 seq_printf(seq, "no board definition set?\n");
52 return 0;
55 seq_printf(seq, "SDRAM refresh %u ns\n", brd->refresh);
56 seq_printf(seq, "auto_io=%u\n", brd->auto_io);
57 seq_printf(seq, "need_io=%u\n", brd->need_io);
59 show_max(seq, &brd->max);
62 return 0;
65 static int fops_board_open(struct inode *inode, struct file *file)
67 return single_open(file, board_show, NULL);
70 static const struct file_operations fops_board = {
71 .open = fops_board_open,
72 .read = seq_read,
73 .llseek = seq_lseek,
74 .release = single_release,
75 .owner = THIS_MODULE,
78 static int info_show(struct seq_file *seq, void *p)
80 struct s3c_cpufreq_config *cfg;
82 cfg = s3c_cpufreq_getconfig();
83 if (!cfg) {
84 seq_printf(seq, "no configuration registered\n");
85 return 0;
88 seq_printf(seq, " FCLK %ld Hz\n", cfg->freq.fclk);
89 seq_printf(seq, " HCLK %ld Hz (%lu.%lu ns)\n",
90 cfg->freq.hclk, print_ns(cfg->freq.hclk_tns));
91 seq_printf(seq, " PCLK %ld Hz\n", cfg->freq.hclk);
92 seq_printf(seq, "ARMCLK %ld Hz\n", cfg->freq.armclk);
93 seq_printf(seq, "\n");
95 show_max(seq, &cfg->max);
97 seq_printf(seq, "Divisors: P=%d, H=%d, A=%d, dvs=%s\n",
98 cfg->divs.h_divisor, cfg->divs.p_divisor,
99 cfg->divs.arm_divisor, cfg->divs.dvs ? "on" : "off");
100 seq_printf(seq, "\n");
102 seq_printf(seq, "lock_pll=%u\n", cfg->lock_pll);
104 return 0;
107 static int fops_info_open(struct inode *inode, struct file *file)
109 return single_open(file, info_show, NULL);
112 static const struct file_operations fops_info = {
113 .open = fops_info_open,
114 .read = seq_read,
115 .llseek = seq_lseek,
116 .release = single_release,
117 .owner = THIS_MODULE,
120 static int io_show(struct seq_file *seq, void *p)
122 void (*show_bank)(struct seq_file *, struct s3c_cpufreq_config *, union s3c_iobank *);
123 struct s3c_cpufreq_config *cfg;
124 struct s3c_iotimings *iot;
125 union s3c_iobank *iob;
126 int bank;
128 cfg = s3c_cpufreq_getconfig();
129 if (!cfg) {
130 seq_printf(seq, "no configuration registered\n");
131 return 0;
134 show_bank = cfg->info->debug_io_show;
135 if (!show_bank) {
136 seq_printf(seq, "no code to show bank timing\n");
137 return 0;
140 iot = s3c_cpufreq_getiotimings();
141 if (!iot) {
142 seq_printf(seq, "no io timings registered\n");
143 return 0;
146 seq_printf(seq, "hclk period is %lu.%lu ns\n", print_ns(cfg->freq.hclk_tns));
148 for (bank = 0; bank < MAX_BANKS; bank++) {
149 iob = &iot->bank[bank];
151 seq_printf(seq, "bank %d: ", bank);
153 if (!iob->io_2410) {
154 seq_printf(seq, "nothing set\n");
155 continue;
158 show_bank(seq, cfg, iob);
161 return 0;
164 static int fops_io_open(struct inode *inode, struct file *file)
166 return single_open(file, io_show, NULL);
169 static const struct file_operations fops_io = {
170 .open = fops_io_open,
171 .read = seq_read,
172 .llseek = seq_lseek,
173 .release = single_release,
174 .owner = THIS_MODULE,
178 static int __init s3c_freq_debugfs_init(void)
180 dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL);
181 if (IS_ERR(dbgfs_root)) {
182 printk(KERN_ERR "%s: error creating debugfs root\n", __func__);
183 return PTR_ERR(dbgfs_root);
186 dbgfs_file_io = debugfs_create_file("io-timing", S_IRUGO, dbgfs_root,
187 NULL, &fops_io);
189 dbgfs_file_info = debugfs_create_file("info", S_IRUGO, dbgfs_root,
190 NULL, &fops_info);
192 dbgfs_file_board = debugfs_create_file("board", S_IRUGO, dbgfs_root,
193 NULL, &fops_board);
195 return 0;
198 late_initcall(s3c_freq_debugfs_init);