blob: 2528d3e609a4794d3f0456c35c83640cd6abbed0 [file] [log] [blame]
Mike Rapoport22caf042006-07-14 00:24:34 -07001#include <linux/debugfs.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09002#include <linux/slab.h>
Mike Rapoport22caf042006-07-14 00:24:34 -07003
4#define BIG_BUFFER_SIZE (1024)
5
6static char big_buffer[BIG_BUFFER_SIZE];
7
8struct mbxfb_debugfs_data {
9 struct dentry *dir;
10 struct dentry *sysconf;
11 struct dentry *clock;
12 struct dentry *display;
13 struct dentry *gsctl;
Raphael Assenat128806c2006-12-08 02:40:35 -080014 struct dentry *sdram;
15 struct dentry *misc;
Mike Rapoport22caf042006-07-14 00:24:34 -070016};
17
Mike Rapoport22caf042006-07-14 00:24:34 -070018static ssize_t write_file_dummy(struct file *file, const char __user *buf,
19 size_t count, loff_t *ppos)
20{
21 return count;
22}
23
24static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
25 size_t count, loff_t *ppos)
26{
27 char * s = big_buffer;
28
Raphael Assenat128806c2006-12-08 02:40:35 -080029 s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
30 s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
31 s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
32 s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
33 s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
Mike Rapoport22caf042006-07-14 00:24:34 -070034
35 return simple_read_from_buffer(userbuf, count, ppos,
36 big_buffer, s-big_buffer);
37}
38
39
40static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
41 size_t count, loff_t *ppos)
42{
43 char * s = big_buffer;
44
Raphael Assenat128806c2006-12-08 02:40:35 -080045 s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
46 s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
47 s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
48 s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
49 s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
50 s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
51 s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
52 s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
53 s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
54 s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
55 s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
56 s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
57 s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
58 s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
59 s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
60 s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
61 s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
62 s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
Mike Rapoport22caf042006-07-14 00:24:34 -070063
64 return simple_read_from_buffer(userbuf, count, ppos,
65 big_buffer, s-big_buffer);
66}
67
68static ssize_t display_read_file(struct file *file, char __user *userbuf,
69 size_t count, loff_t *ppos)
70{
71 char * s = big_buffer;
72
Raphael Assenat128806c2006-12-08 02:40:35 -080073 s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
74 s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
75 s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
76 s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
77 s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
78 s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
79 s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
80 s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
81 s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
82 s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
83 s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
84 s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
85 s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
86 s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
87 s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
88 s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
89 s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
90 s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
91 s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
92 s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
93 s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
94 s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
95 s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
96 s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
97 s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
98 s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
99 s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
100 s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
101 s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
102 s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
Mike Rapoport22caf042006-07-14 00:24:34 -0700103
104 return simple_read_from_buffer(userbuf, count, ppos,
105 big_buffer, s-big_buffer);
106}
107
108static ssize_t clock_read_file(struct file *file, char __user *userbuf,
109 size_t count, loff_t *ppos)
110{
111 char * s = big_buffer;
112
Raphael Assenat128806c2006-12-08 02:40:35 -0800113 s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
114 s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
115 s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
116 s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
117 s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
118 s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
119 s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
120 s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
121 s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
122 s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
123 s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
124 s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
125 s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
Mike Rapoport22caf042006-07-14 00:24:34 -0700126
127 return simple_read_from_buffer(userbuf, count, ppos,
128 big_buffer, s-big_buffer);
129}
130
Raphael Assenat128806c2006-12-08 02:40:35 -0800131static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
132 size_t count, loff_t *ppos)
133{
134 char * s = big_buffer;
135
136 s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
137 s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
138 s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
139 s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
140 s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
141 s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
142 s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
143 s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
144 s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
145 s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
146 s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
147 s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
148
149 return simple_read_from_buffer(userbuf, count, ppos,
150 big_buffer, s-big_buffer);
151}
152
153static ssize_t misc_read_file(struct file *file, char __user *userbuf,
154 size_t count, loff_t *ppos)
155{
156 char * s = big_buffer;
157
158 s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
159 s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
160 s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
161 s += sprintf(s, "ID = %08x\n", readl(ID));
162
163 return simple_read_from_buffer(userbuf, count, ppos,
164 big_buffer, s-big_buffer);
165}
166
167
Arjan van de Ven00977a52007-02-12 00:55:34 -0800168static const struct file_operations sysconf_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700169 .read = sysconf_read_file,
170 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100171 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200172 .llseek = default_llseek,
Mike Rapoport22caf042006-07-14 00:24:34 -0700173};
174
Arjan van de Ven00977a52007-02-12 00:55:34 -0800175static const struct file_operations clock_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700176 .read = clock_read_file,
177 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100178 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200179 .llseek = default_llseek,
Mike Rapoport22caf042006-07-14 00:24:34 -0700180};
181
Arjan van de Ven00977a52007-02-12 00:55:34 -0800182static const struct file_operations display_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700183 .read = display_read_file,
184 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100185 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200186 .llseek = default_llseek,
Mike Rapoport22caf042006-07-14 00:24:34 -0700187};
188
Arjan van de Ven00977a52007-02-12 00:55:34 -0800189static const struct file_operations gsctl_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700190 .read = gsctl_read_file,
191 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100192 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200193 .llseek = default_llseek,
Mike Rapoport22caf042006-07-14 00:24:34 -0700194};
195
Arjan van de Ven00977a52007-02-12 00:55:34 -0800196static const struct file_operations sdram_fops = {
Raphael Assenat128806c2006-12-08 02:40:35 -0800197 .read = sdram_read_file,
198 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100199 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200200 .llseek = default_llseek,
Raphael Assenat128806c2006-12-08 02:40:35 -0800201};
202
Arjan van de Ven00977a52007-02-12 00:55:34 -0800203static const struct file_operations misc_fops = {
Raphael Assenat128806c2006-12-08 02:40:35 -0800204 .read = misc_read_file,
205 .write = write_file_dummy,
Geliang Tang0a9aae42017-01-30 17:39:49 +0100206 .open = simple_open,
Arnd Bergmann6038f372010-08-15 18:52:59 +0200207 .llseek = default_llseek,
Raphael Assenat128806c2006-12-08 02:40:35 -0800208};
Mike Rapoport22caf042006-07-14 00:24:34 -0700209
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -0800210static void mbxfb_debugfs_init(struct fb_info *fbi)
Mike Rapoport22caf042006-07-14 00:24:34 -0700211{
212 struct mbxfb_info *mfbi = fbi->par;
213 struct mbxfb_debugfs_data *dbg;
214
215 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
216 mfbi->debugfs_data = dbg;
217
218 dbg->dir = debugfs_create_dir("mbxfb", NULL);
219 dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
220 fbi, &sysconf_fops);
221 dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
222 fbi, &clock_fops);
223 dbg->display = debugfs_create_file("display", 0444, dbg->dir,
224 fbi, &display_fops);
225 dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
226 fbi, &gsctl_fops);
Raphael Assenat128806c2006-12-08 02:40:35 -0800227 dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
228 fbi, &sdram_fops);
229 dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
230 fbi, &misc_fops);
Mike Rapoport22caf042006-07-14 00:24:34 -0700231}
232
Greg Kroah-Hartman48c68c42012-12-21 13:07:39 -0800233static void mbxfb_debugfs_remove(struct fb_info *fbi)
Mike Rapoport22caf042006-07-14 00:24:34 -0700234{
235 struct mbxfb_info *mfbi = fbi->par;
236 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
237
Raphael Assenat128806c2006-12-08 02:40:35 -0800238 debugfs_remove(dbg->misc);
239 debugfs_remove(dbg->sdram);
Mike Rapoport22caf042006-07-14 00:24:34 -0700240 debugfs_remove(dbg->gsctl);
241 debugfs_remove(dbg->display);
242 debugfs_remove(dbg->clock);
243 debugfs_remove(dbg->sysconf);
244 debugfs_remove(dbg->dir);
245}