drivers/net/netxen/: cleanups
[linux-2.6/openmoko-kernel/knife-kernel.git] / drivers / video / mbx / mbxdebugfs.c
blob15b8b3c4330ec3b3aca5813a985ef87101dcb295
1 #include <linux/debugfs.h>
3 #define BIG_BUFFER_SIZE (1024)
5 static char big_buffer[BIG_BUFFER_SIZE];
7 struct mbxfb_debugfs_data {
8 struct dentry *dir;
9 struct dentry *sysconf;
10 struct dentry *clock;
11 struct dentry *display;
12 struct dentry *gsctl;
13 struct dentry *sdram;
14 struct dentry *misc;
17 static int open_file_generic(struct inode *inode, struct file *file)
19 file->private_data = inode->u.generic_ip;
20 return 0;
23 static ssize_t write_file_dummy(struct file *file, const char __user *buf,
24 size_t count, loff_t *ppos)
26 return count;
29 static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
30 size_t count, loff_t *ppos)
32 char * s = big_buffer;
34 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));
40 return simple_read_from_buffer(userbuf, count, ppos,
41 big_buffer, s-big_buffer);
45 static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
46 size_t count, loff_t *ppos)
48 char * s = big_buffer;
50 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));
69 return simple_read_from_buffer(userbuf, count, ppos,
70 big_buffer, s-big_buffer);
73 static ssize_t display_read_file(struct file *file, char __user *userbuf,
74 size_t count, loff_t *ppos)
76 char * s = big_buffer;
78 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));
109 return simple_read_from_buffer(userbuf, count, ppos,
110 big_buffer, s-big_buffer);
113 static ssize_t clock_read_file(struct file *file, char __user *userbuf,
114 size_t count, loff_t *ppos)
116 char * s = big_buffer;
118 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));
132 return simple_read_from_buffer(userbuf, count, ppos,
133 big_buffer, s-big_buffer);
136 static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
137 size_t count, loff_t *ppos)
139 char * s = big_buffer;
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));
154 return simple_read_from_buffer(userbuf, count, ppos,
155 big_buffer, s-big_buffer);
158 static ssize_t misc_read_file(struct file *file, char __user *userbuf,
159 size_t count, loff_t *ppos)
161 char * s = big_buffer;
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));
168 return simple_read_from_buffer(userbuf, count, ppos,
169 big_buffer, s-big_buffer);
173 static const struct file_operations sysconf_fops = {
174 .read = sysconf_read_file,
175 .write = write_file_dummy,
176 .open = open_file_generic,
179 static const struct file_operations clock_fops = {
180 .read = clock_read_file,
181 .write = write_file_dummy,
182 .open = open_file_generic,
185 static const struct file_operations display_fops = {
186 .read = display_read_file,
187 .write = write_file_dummy,
188 .open = open_file_generic,
191 static const struct file_operations gsctl_fops = {
192 .read = gsctl_read_file,
193 .write = write_file_dummy,
194 .open = open_file_generic,
197 static const struct file_operations sdram_fops = {
198 .read = sdram_read_file,
199 .write = write_file_dummy,
200 .open = open_file_generic,
203 static const struct file_operations misc_fops = {
204 .read = misc_read_file,
205 .write = write_file_dummy,
206 .open = open_file_generic,
209 static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
211 struct mbxfb_info *mfbi = fbi->par;
212 struct mbxfb_debugfs_data *dbg;
214 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
215 mfbi->debugfs_data = dbg;
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);
226 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);
232 static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
234 struct mbxfb_info *mfbi = fbi->par;
235 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
237 debugfs_remove(dbg->misc);
238 debugfs_remove(dbg->sdram);
239 debugfs_remove(dbg->gsctl);
240 debugfs_remove(dbg->display);
241 debugfs_remove(dbg->clock);
242 debugfs_remove(dbg->sysconf);
243 debugfs_remove(dbg->dir);