blob: 15b8b3c4330ec3b3aca5813a985ef87101dcb295 [file] [log] [blame]
Mike Rapoport22caf042006-07-14 00:24:34 -07001#include <linux/debugfs.h>
2
3#define BIG_BUFFER_SIZE (1024)
4
5static char big_buffer[BIG_BUFFER_SIZE];
6
7struct mbxfb_debugfs_data {
8 struct dentry *dir;
9 struct dentry *sysconf;
10 struct dentry *clock;
11 struct dentry *display;
12 struct dentry *gsctl;
Raphael Assenat128806c2006-12-08 02:40:35 -080013 struct dentry *sdram;
14 struct dentry *misc;
Mike Rapoport22caf042006-07-14 00:24:34 -070015};
16
17static int open_file_generic(struct inode *inode, struct file *file)
18{
19 file->private_data = inode->u.generic_ip;
20 return 0;
21}
22
23static ssize_t write_file_dummy(struct file *file, const char __user *buf,
24 size_t count, loff_t *ppos)
25{
26 return count;
27}
28
29static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
30 size_t count, loff_t *ppos)
31{
32 char * s = big_buffer;
33
Raphael Assenat128806c2006-12-08 02:40:35 -080034 s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
35 s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
36 s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
37 s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
38 s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
Mike Rapoport22caf042006-07-14 00:24:34 -070039
40 return simple_read_from_buffer(userbuf, count, ppos,
41 big_buffer, s-big_buffer);
42}
43
44
45static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
46 size_t count, loff_t *ppos)
47{
48 char * s = big_buffer;
49
Raphael Assenat128806c2006-12-08 02:40:35 -080050 s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
51 s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
52 s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
53 s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
54 s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
55 s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
56 s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
57 s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
58 s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
59 s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
60 s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
61 s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
62 s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
63 s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
64 s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
65 s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
66 s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
67 s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
Mike Rapoport22caf042006-07-14 00:24:34 -070068
69 return simple_read_from_buffer(userbuf, count, ppos,
70 big_buffer, s-big_buffer);
71}
72
73static ssize_t display_read_file(struct file *file, char __user *userbuf,
74 size_t count, loff_t *ppos)
75{
76 char * s = big_buffer;
77
Raphael Assenat128806c2006-12-08 02:40:35 -080078 s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
79 s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
80 s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
81 s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
82 s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
83 s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
84 s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
85 s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
86 s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
87 s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
88 s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
89 s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
90 s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
91 s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
92 s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
93 s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
94 s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
95 s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
96 s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
97 s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
98 s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
99 s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
100 s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
101 s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
102 s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
103 s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
104 s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
105 s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
106 s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
107 s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
Mike Rapoport22caf042006-07-14 00:24:34 -0700108
109 return simple_read_from_buffer(userbuf, count, ppos,
110 big_buffer, s-big_buffer);
111}
112
113static ssize_t clock_read_file(struct file *file, char __user *userbuf,
114 size_t count, loff_t *ppos)
115{
116 char * s = big_buffer;
117
Raphael Assenat128806c2006-12-08 02:40:35 -0800118 s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
119 s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
120 s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
121 s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
122 s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
123 s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
124 s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
125 s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
126 s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
127 s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
128 s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
129 s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
130 s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
Mike Rapoport22caf042006-07-14 00:24:34 -0700131
132 return simple_read_from_buffer(userbuf, count, ppos,
133 big_buffer, s-big_buffer);
134}
135
Raphael Assenat128806c2006-12-08 02:40:35 -0800136static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
137 size_t count, loff_t *ppos)
138{
139 char * s = big_buffer;
140
141 s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
142 s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
143 s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
144 s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
145 s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
146 s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
147 s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
148 s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
149 s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
150 s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
151 s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
152 s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
153
154 return simple_read_from_buffer(userbuf, count, ppos,
155 big_buffer, s-big_buffer);
156}
157
158static ssize_t misc_read_file(struct file *file, char __user *userbuf,
159 size_t count, loff_t *ppos)
160{
161 char * s = big_buffer;
162
163 s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
164 s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
165 s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
166 s += sprintf(s, "ID = %08x\n", readl(ID));
167
168 return simple_read_from_buffer(userbuf, count, ppos,
169 big_buffer, s-big_buffer);
170}
171
172
Arjan van de Ven00977a52007-02-12 00:55:34 -0800173static const struct file_operations sysconf_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700174 .read = sysconf_read_file,
175 .write = write_file_dummy,
176 .open = open_file_generic,
177};
178
Arjan van de Ven00977a52007-02-12 00:55:34 -0800179static const struct file_operations clock_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700180 .read = clock_read_file,
181 .write = write_file_dummy,
182 .open = open_file_generic,
183};
184
Arjan van de Ven00977a52007-02-12 00:55:34 -0800185static const struct file_operations display_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700186 .read = display_read_file,
187 .write = write_file_dummy,
188 .open = open_file_generic,
189};
190
Arjan van de Ven00977a52007-02-12 00:55:34 -0800191static const struct file_operations gsctl_fops = {
Mike Rapoport22caf042006-07-14 00:24:34 -0700192 .read = gsctl_read_file,
193 .write = write_file_dummy,
194 .open = open_file_generic,
195};
196
Arjan van de Ven00977a52007-02-12 00:55:34 -0800197static const struct file_operations sdram_fops = {
Raphael Assenat128806c2006-12-08 02:40:35 -0800198 .read = sdram_read_file,
199 .write = write_file_dummy,
200 .open = open_file_generic,
201};
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,
206 .open = open_file_generic,
207};
Mike Rapoport22caf042006-07-14 00:24:34 -0700208
209static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
210{
211 struct mbxfb_info *mfbi = fbi->par;
212 struct mbxfb_debugfs_data *dbg;
213
214 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
215 mfbi->debugfs_data = dbg;
216
217 dbg->dir = debugfs_create_dir("mbxfb", NULL);
218 dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
219 fbi, &sysconf_fops);
220 dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
221 fbi, &clock_fops);
222 dbg->display = debugfs_create_file("display", 0444, dbg->dir,
223 fbi, &display_fops);
224 dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
225 fbi, &gsctl_fops);
Raphael Assenat128806c2006-12-08 02:40:35 -0800226 dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
227 fbi, &sdram_fops);
228 dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
229 fbi, &misc_fops);
Mike Rapoport22caf042006-07-14 00:24:34 -0700230}
231
232static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
233{
234 struct mbxfb_info *mfbi = fbi->par;
235 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
236
Raphael Assenat128806c2006-12-08 02:40:35 -0800237 debugfs_remove(dbg->misc);
238 debugfs_remove(dbg->sdram);
Mike Rapoport22caf042006-07-14 00:24:34 -0700239 debugfs_remove(dbg->gsctl);
240 debugfs_remove(dbg->display);
241 debugfs_remove(dbg->clock);
242 debugfs_remove(dbg->sysconf);
243 debugfs_remove(dbg->dir);
244}