This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / video / mbx / mbxdebugfs.c
1 #include <linux/debugfs.h>
2
3 #define BIG_BUFFER_SIZE (1024)
4
5 static char big_buffer[BIG_BUFFER_SIZE];
6
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 };
14
15 static int open_file_generic(struct inode *inode, struct file *file)
16 {
17         file->private_data = inode->u.generic_ip;
18         return 0;
19 }
20
21 static ssize_t write_file_dummy(struct file *file, const char __user *buf,
22                                 size_t count, loff_t *ppos)
23 {
24         return count;
25 }
26
27 static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
28                                  size_t count, loff_t *ppos)
29 {
30         char * s = big_buffer;
31
32         s += sprintf(s, "SYSCFG = %08lx\n", SYSCFG);
33         s += sprintf(s, "PFBASE = %08lx\n", PFBASE);
34         s += sprintf(s, "PFCEIL = %08lx\n", PFCEIL);
35         s += sprintf(s, "POLLFLAG = %08lx\n", POLLFLAG);
36         s += sprintf(s, "SYSRST = %08lx\n", SYSRST);
37
38         return  simple_read_from_buffer(userbuf, count, ppos,
39                                         big_buffer, s-big_buffer);
40 }
41
42
43 static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
44                                size_t count, loff_t *ppos)
45 {
46         char * s = big_buffer;
47
48         s += sprintf(s, "GSCTRL = %08lx\n", GSCTRL);
49         s += sprintf(s, "VSCTRL = %08lx\n", VSCTRL);
50         s += sprintf(s, "GBBASE = %08lx\n", GBBASE);
51         s += sprintf(s, "VBBASE = %08lx\n", VBBASE);
52         s += sprintf(s, "GDRCTRL = %08lx\n", GDRCTRL);
53         s += sprintf(s, "VCMSK = %08lx\n", VCMSK);
54         s += sprintf(s, "GSCADR = %08lx\n", GSCADR);
55         s += sprintf(s, "VSCADR = %08lx\n", VSCADR);
56         s += sprintf(s, "VUBASE = %08lx\n", VUBASE);
57         s += sprintf(s, "VVBASE = %08lx\n", VVBASE);
58         s += sprintf(s, "GSADR = %08lx\n", GSADR);
59         s += sprintf(s, "VSADR = %08lx\n", VSADR);
60         s += sprintf(s, "HCCTRL = %08lx\n", HCCTRL);
61         s += sprintf(s, "HCSIZE = %08lx\n", HCSIZE);
62         s += sprintf(s, "HCPOS = %08lx\n", HCPOS);
63         s += sprintf(s, "HCBADR = %08lx\n", HCBADR);
64         s += sprintf(s, "HCCKMSK = %08lx\n", HCCKMSK);
65         s += sprintf(s, "GPLUT = %08lx\n", GPLUT);
66
67         return  simple_read_from_buffer(userbuf, count, ppos,
68                                         big_buffer, s-big_buffer);
69 }
70
71 static ssize_t display_read_file(struct file *file, char __user *userbuf,
72                                  size_t count, loff_t *ppos)
73 {
74         char * s = big_buffer;
75
76         s += sprintf(s, "DSCTRL = %08lx\n", DSCTRL);
77         s += sprintf(s, "DHT01 = %08lx\n", DHT01);
78         s += sprintf(s, "DHT02 = %08lx\n", DHT02);
79         s += sprintf(s, "DHT03 = %08lx\n", DHT03);
80         s += sprintf(s, "DVT01 = %08lx\n", DVT01);
81         s += sprintf(s, "DVT02 = %08lx\n", DVT02);
82         s += sprintf(s, "DVT03 = %08lx\n", DVT03);
83         s += sprintf(s, "DBCOL = %08lx\n", DBCOL);
84         s += sprintf(s, "BGCOLOR = %08lx\n", BGCOLOR);
85         s += sprintf(s, "DINTRS = %08lx\n", DINTRS);
86         s += sprintf(s, "DINTRE = %08lx\n", DINTRE);
87         s += sprintf(s, "DINTRCNT = %08lx\n", DINTRCNT);
88         s += sprintf(s, "DSIG = %08lx\n", DSIG);
89         s += sprintf(s, "DMCTRL = %08lx\n", DMCTRL);
90         s += sprintf(s, "CLIPCTRL = %08lx\n", CLIPCTRL);
91         s += sprintf(s, "SPOCTRL = %08lx\n", SPOCTRL);
92         s += sprintf(s, "SVCTRL = %08lx\n", SVCTRL);
93         s += sprintf(s, "DLSTS = %08lx\n", DLSTS);
94         s += sprintf(s, "DLLCTRL = %08lx\n", DLLCTRL);
95         s += sprintf(s, "DVLNUM = %08lx\n", DVLNUM);
96         s += sprintf(s, "DUCTRL = %08lx\n", DUCTRL);
97         s += sprintf(s, "DVECTRL = %08lx\n", DVECTRL);
98         s += sprintf(s, "DHDET = %08lx\n", DHDET);
99         s += sprintf(s, "DVDET = %08lx\n", DVDET);
100         s += sprintf(s, "DODMSK = %08lx\n", DODMSK);
101         s += sprintf(s, "CSC01 = %08lx\n", CSC01);
102         s += sprintf(s, "CSC02 = %08lx\n", CSC02);
103         s += sprintf(s, "CSC03 = %08lx\n", CSC03);
104         s += sprintf(s, "CSC04 = %08lx\n", CSC04);
105         s += sprintf(s, "CSC05 = %08lx\n", CSC05);
106
107         return  simple_read_from_buffer(userbuf, count, ppos,
108                                         big_buffer, s-big_buffer);
109 }
110
111 static ssize_t clock_read_file(struct file *file, char __user *userbuf,
112                                size_t count, loff_t *ppos)
113 {
114         char * s = big_buffer;
115
116         s += sprintf(s, "SYSCLKSRC = %08lx\n", SYSCLKSRC);
117         s += sprintf(s, "PIXCLKSRC = %08lx\n", PIXCLKSRC);
118         s += sprintf(s, "CLKSLEEP = %08lx\n", CLKSLEEP);
119         s += sprintf(s, "COREPLL = %08lx\n", COREPLL);
120         s += sprintf(s, "DISPPLL = %08lx\n", DISPPLL);
121         s += sprintf(s, "PLLSTAT = %08lx\n", PLLSTAT);
122         s += sprintf(s, "VOVRCLK = %08lx\n", VOVRCLK);
123         s += sprintf(s, "PIXCLK = %08lx\n", PIXCLK);
124         s += sprintf(s, "MEMCLK = %08lx\n", MEMCLK);
125         s += sprintf(s, "M24CLK = %08lx\n", M24CLK);
126         s += sprintf(s, "MBXCLK = %08lx\n", MBXCLK);
127         s += sprintf(s, "SDCLK = %08lx\n", SDCLK);
128         s += sprintf(s, "PIXCLKDIV = %08lx\n", PIXCLKDIV);
129
130         return  simple_read_from_buffer(userbuf, count, ppos,
131                                         big_buffer, s-big_buffer);
132 }
133
134 static struct file_operations sysconf_fops = {
135         .read = sysconf_read_file,
136         .write = write_file_dummy,
137         .open = open_file_generic,
138 };
139
140 static struct file_operations clock_fops = {
141         .read = clock_read_file,
142         .write = write_file_dummy,
143         .open = open_file_generic,
144 };
145
146 static struct file_operations display_fops = {
147         .read = display_read_file,
148         .write = write_file_dummy,
149         .open = open_file_generic,
150 };
151
152 static struct file_operations gsctl_fops = {
153         .read = gsctl_read_file,
154         .write = write_file_dummy,
155         .open = open_file_generic,
156 };
157
158
159 static void __devinit mbxfb_debugfs_init(struct fb_info *fbi)
160 {
161         struct mbxfb_info *mfbi = fbi->par;
162         struct mbxfb_debugfs_data *dbg;
163
164         dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
165         mfbi->debugfs_data = dbg;
166
167         dbg->dir = debugfs_create_dir("mbxfb", NULL);
168         dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
169                                       fbi, &sysconf_fops);
170         dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
171                                     fbi, &clock_fops);
172         dbg->display = debugfs_create_file("display", 0444, dbg->dir,
173                                       fbi, &display_fops);
174         dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
175                                     fbi, &gsctl_fops);
176 }
177
178 static void __devexit mbxfb_debugfs_remove(struct fb_info *fbi)
179 {
180         struct mbxfb_info *mfbi = fbi->par;
181         struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
182
183         debugfs_remove(dbg->gsctl);
184         debugfs_remove(dbg->display);
185         debugfs_remove(dbg->clock);
186         debugfs_remove(dbg->sysconf);
187         debugfs_remove(dbg->dir);
188 }