]>
Commit | Line | Data |
---|---|---|
09ec1d7e | 1 | /* |
e6d197a6 BD |
2 | * Copyright (c) 2009 Simtec Electronics |
3 | * http://armlinux.simtec.co.uk/ | |
4 | * Ben Dooks <[email protected]> | |
5 | * | |
6 | * S3C24XX CPU Frequency scaling - debugfs status support | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
1c5864e2 JP |
13 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
14 | ||
e6d197a6 | 15 | #include <linux/init.h> |
a69e4c28 | 16 | #include <linux/export.h> |
e6d197a6 BD |
17 | #include <linux/interrupt.h> |
18 | #include <linux/ioport.h> | |
19 | #include <linux/cpufreq.h> | |
20 | #include <linux/debugfs.h> | |
21 | #include <linux/seq_file.h> | |
22 | #include <linux/err.h> | |
23 | ||
24 | #include <plat/cpu-freq-core.h> | |
25 | ||
26 | static struct dentry *dbgfs_root; | |
27 | static struct dentry *dbgfs_file_io; | |
28 | static struct dentry *dbgfs_file_info; | |
29 | static struct dentry *dbgfs_file_board; | |
30 | ||
31 | #define print_ns(x) ((x) / 10), ((x) % 10) | |
32 | ||
33 | static void show_max(struct seq_file *seq, struct s3c_freq *f) | |
34 | { | |
35 | seq_printf(seq, "MAX: F=%lu, H=%lu, P=%lu, A=%lu\n", | |
36 | f->fclk, f->hclk, f->pclk, f->armclk); | |
37 | } | |
38 | ||
39 | static int board_show(struct seq_file *seq, void *p) | |
40 | { | |
41 | struct s3c_cpufreq_config *cfg; | |
42 | struct s3c_cpufreq_board *brd; | |
43 | ||
44 | cfg = s3c_cpufreq_getconfig(); | |
45 | if (!cfg) { | |
46 | seq_printf(seq, "no configuration registered\n"); | |
47 | return 0; | |
48 | } | |
49 | ||
50 | brd = cfg->board; | |
51 | if (!brd) { | |
52 | seq_printf(seq, "no board definition set?\n"); | |
53 | return 0; | |
54 | } | |
55 | ||
56 | seq_printf(seq, "SDRAM refresh %u ns\n", brd->refresh); | |
57 | seq_printf(seq, "auto_io=%u\n", brd->auto_io); | |
58 | seq_printf(seq, "need_io=%u\n", brd->need_io); | |
59 | ||
60 | show_max(seq, &brd->max); | |
61 | ||
62 | ||
63 | return 0; | |
64 | } | |
65 | ||
66 | static int fops_board_open(struct inode *inode, struct file *file) | |
67 | { | |
68 | return single_open(file, board_show, NULL); | |
69 | } | |
70 | ||
71 | static const struct file_operations fops_board = { | |
72 | .open = fops_board_open, | |
73 | .read = seq_read, | |
74 | .llseek = seq_lseek, | |
75 | .release = single_release, | |
76 | .owner = THIS_MODULE, | |
77 | }; | |
78 | ||
79 | static int info_show(struct seq_file *seq, void *p) | |
80 | { | |
81 | struct s3c_cpufreq_config *cfg; | |
82 | ||
83 | cfg = s3c_cpufreq_getconfig(); | |
84 | if (!cfg) { | |
85 | seq_printf(seq, "no configuration registered\n"); | |
86 | return 0; | |
87 | } | |
88 | ||
89 | seq_printf(seq, " FCLK %ld Hz\n", cfg->freq.fclk); | |
90 | seq_printf(seq, " HCLK %ld Hz (%lu.%lu ns)\n", | |
91 | cfg->freq.hclk, print_ns(cfg->freq.hclk_tns)); | |
92 | seq_printf(seq, " PCLK %ld Hz\n", cfg->freq.hclk); | |
93 | seq_printf(seq, "ARMCLK %ld Hz\n", cfg->freq.armclk); | |
94 | seq_printf(seq, "\n"); | |
95 | ||
96 | show_max(seq, &cfg->max); | |
97 | ||
98 | seq_printf(seq, "Divisors: P=%d, H=%d, A=%d, dvs=%s\n", | |
99 | cfg->divs.h_divisor, cfg->divs.p_divisor, | |
100 | cfg->divs.arm_divisor, cfg->divs.dvs ? "on" : "off"); | |
101 | seq_printf(seq, "\n"); | |
102 | ||
103 | seq_printf(seq, "lock_pll=%u\n", cfg->lock_pll); | |
104 | ||
105 | return 0; | |
106 | } | |
107 | ||
108 | static int fops_info_open(struct inode *inode, struct file *file) | |
109 | { | |
110 | return single_open(file, info_show, NULL); | |
111 | } | |
112 | ||
113 | static const struct file_operations fops_info = { | |
114 | .open = fops_info_open, | |
115 | .read = seq_read, | |
116 | .llseek = seq_lseek, | |
117 | .release = single_release, | |
118 | .owner = THIS_MODULE, | |
119 | }; | |
120 | ||
121 | static int io_show(struct seq_file *seq, void *p) | |
122 | { | |
123 | void (*show_bank)(struct seq_file *, struct s3c_cpufreq_config *, union s3c_iobank *); | |
124 | struct s3c_cpufreq_config *cfg; | |
125 | struct s3c_iotimings *iot; | |
126 | union s3c_iobank *iob; | |
127 | int bank; | |
128 | ||
129 | cfg = s3c_cpufreq_getconfig(); | |
130 | if (!cfg) { | |
131 | seq_printf(seq, "no configuration registered\n"); | |
132 | return 0; | |
133 | } | |
134 | ||
135 | show_bank = cfg->info->debug_io_show; | |
136 | if (!show_bank) { | |
137 | seq_printf(seq, "no code to show bank timing\n"); | |
138 | return 0; | |
139 | } | |
140 | ||
141 | iot = s3c_cpufreq_getiotimings(); | |
142 | if (!iot) { | |
143 | seq_printf(seq, "no io timings registered\n"); | |
144 | return 0; | |
145 | } | |
146 | ||
147 | seq_printf(seq, "hclk period is %lu.%lu ns\n", print_ns(cfg->freq.hclk_tns)); | |
148 | ||
149 | for (bank = 0; bank < MAX_BANKS; bank++) { | |
150 | iob = &iot->bank[bank]; | |
151 | ||
152 | seq_printf(seq, "bank %d: ", bank); | |
153 | ||
154 | if (!iob->io_2410) { | |
155 | seq_printf(seq, "nothing set\n"); | |
156 | continue; | |
157 | } | |
158 | ||
159 | show_bank(seq, cfg, iob); | |
160 | } | |
161 | ||
162 | return 0; | |
163 | } | |
164 | ||
165 | static int fops_io_open(struct inode *inode, struct file *file) | |
166 | { | |
167 | return single_open(file, io_show, NULL); | |
168 | } | |
169 | ||
170 | static const struct file_operations fops_io = { | |
171 | .open = fops_io_open, | |
172 | .read = seq_read, | |
173 | .llseek = seq_lseek, | |
174 | .release = single_release, | |
175 | .owner = THIS_MODULE, | |
176 | }; | |
177 | ||
178 | ||
179 | static int __init s3c_freq_debugfs_init(void) | |
180 | { | |
181 | dbgfs_root = debugfs_create_dir("s3c-cpufreq", NULL); | |
182 | if (IS_ERR(dbgfs_root)) { | |
b49c22a6 | 183 | pr_err("%s: error creating debugfs root\n", __func__); |
e6d197a6 BD |
184 | return PTR_ERR(dbgfs_root); |
185 | } | |
186 | ||
187 | dbgfs_file_io = debugfs_create_file("io-timing", S_IRUGO, dbgfs_root, | |
188 | NULL, &fops_io); | |
189 | ||
190 | dbgfs_file_info = debugfs_create_file("info", S_IRUGO, dbgfs_root, | |
191 | NULL, &fops_info); | |
192 | ||
193 | dbgfs_file_board = debugfs_create_file("board", S_IRUGO, dbgfs_root, | |
194 | NULL, &fops_board); | |
195 | ||
196 | return 0; | |
197 | } | |
198 | ||
199 | late_initcall(s3c_freq_debugfs_init); | |
200 |