]> git.ipfire.org Git - people/arne_f/kernel.git/blob - drivers/video/fbdev/mbx/mbxdebugfs.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[people/arne_f/kernel.git] / drivers / video / fbdev / mbx / mbxdebugfs.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/debugfs.h>
3 #include <linux/slab.h>
4
5 #define BIG_BUFFER_SIZE (1024)
6
7 static char big_buffer[BIG_BUFFER_SIZE];
8
9 struct mbxfb_debugfs_data {
10 struct dentry *dir;
11 struct dentry *sysconf;
12 struct dentry *clock;
13 struct dentry *display;
14 struct dentry *gsctl;
15 struct dentry *sdram;
16 struct dentry *misc;
17 };
18
19 static ssize_t write_file_dummy(struct file *file, const char __user *buf,
20 size_t count, loff_t *ppos)
21 {
22 return count;
23 }
24
25 static ssize_t sysconf_read_file(struct file *file, char __user *userbuf,
26 size_t count, loff_t *ppos)
27 {
28 char * s = big_buffer;
29
30 s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG));
31 s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE));
32 s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL));
33 s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG));
34 s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST));
35
36 return simple_read_from_buffer(userbuf, count, ppos,
37 big_buffer, s-big_buffer);
38 }
39
40
41 static ssize_t gsctl_read_file(struct file *file, char __user *userbuf,
42 size_t count, loff_t *ppos)
43 {
44 char * s = big_buffer;
45
46 s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL));
47 s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL));
48 s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE));
49 s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE));
50 s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL));
51 s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK));
52 s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR));
53 s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR));
54 s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE));
55 s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE));
56 s += sprintf(s, "GSADR = %08x\n", readl(GSADR));
57 s += sprintf(s, "VSADR = %08x\n", readl(VSADR));
58 s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL));
59 s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE));
60 s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS));
61 s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR));
62 s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK));
63 s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT));
64
65 return simple_read_from_buffer(userbuf, count, ppos,
66 big_buffer, s-big_buffer);
67 }
68
69 static ssize_t display_read_file(struct file *file, char __user *userbuf,
70 size_t count, loff_t *ppos)
71 {
72 char * s = big_buffer;
73
74 s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL));
75 s += sprintf(s, "DHT01 = %08x\n", readl(DHT01));
76 s += sprintf(s, "DHT02 = %08x\n", readl(DHT02));
77 s += sprintf(s, "DHT03 = %08x\n", readl(DHT03));
78 s += sprintf(s, "DVT01 = %08x\n", readl(DVT01));
79 s += sprintf(s, "DVT02 = %08x\n", readl(DVT02));
80 s += sprintf(s, "DVT03 = %08x\n", readl(DVT03));
81 s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL));
82 s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR));
83 s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS));
84 s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE));
85 s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT));
86 s += sprintf(s, "DSIG = %08x\n", readl(DSIG));
87 s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL));
88 s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL));
89 s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL));
90 s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL));
91 s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS));
92 s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL));
93 s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM));
94 s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL));
95 s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL));
96 s += sprintf(s, "DHDET = %08x\n", readl(DHDET));
97 s += sprintf(s, "DVDET = %08x\n", readl(DVDET));
98 s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK));
99 s += sprintf(s, "CSC01 = %08x\n", readl(CSC01));
100 s += sprintf(s, "CSC02 = %08x\n", readl(CSC02));
101 s += sprintf(s, "CSC03 = %08x\n", readl(CSC03));
102 s += sprintf(s, "CSC04 = %08x\n", readl(CSC04));
103 s += sprintf(s, "CSC05 = %08x\n", readl(CSC05));
104
105 return simple_read_from_buffer(userbuf, count, ppos,
106 big_buffer, s-big_buffer);
107 }
108
109 static ssize_t clock_read_file(struct file *file, char __user *userbuf,
110 size_t count, loff_t *ppos)
111 {
112 char * s = big_buffer;
113
114 s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC));
115 s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC));
116 s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP));
117 s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL));
118 s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL));
119 s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT));
120 s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK));
121 s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK));
122 s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK));
123 s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK));
124 s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK));
125 s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK));
126 s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV));
127
128 return simple_read_from_buffer(userbuf, count, ppos,
129 big_buffer, s-big_buffer);
130 }
131
132 static ssize_t sdram_read_file(struct file *file, char __user *userbuf,
133 size_t count, loff_t *ppos)
134 {
135 char * s = big_buffer;
136
137 s += sprintf(s, "LMRST = %08x\n", readl(LMRST));
138 s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG));
139 s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR));
140 s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT));
141 s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR));
142 s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE));
143 s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM));
144 s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH));
145 s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN));
146 s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX));
147 s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG));
148 s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR));
149
150 return simple_read_from_buffer(userbuf, count, ppos,
151 big_buffer, s-big_buffer);
152 }
153
154 static ssize_t misc_read_file(struct file *file, char __user *userbuf,
155 size_t count, loff_t *ppos)
156 {
157 char * s = big_buffer;
158
159 s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG));
160 s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR));
161 s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT));
162 s += sprintf(s, "ID = %08x\n", readl(ID));
163
164 return simple_read_from_buffer(userbuf, count, ppos,
165 big_buffer, s-big_buffer);
166 }
167
168
169 static const struct file_operations sysconf_fops = {
170 .read = sysconf_read_file,
171 .write = write_file_dummy,
172 .open = simple_open,
173 .llseek = default_llseek,
174 };
175
176 static const struct file_operations clock_fops = {
177 .read = clock_read_file,
178 .write = write_file_dummy,
179 .open = simple_open,
180 .llseek = default_llseek,
181 };
182
183 static const struct file_operations display_fops = {
184 .read = display_read_file,
185 .write = write_file_dummy,
186 .open = simple_open,
187 .llseek = default_llseek,
188 };
189
190 static const struct file_operations gsctl_fops = {
191 .read = gsctl_read_file,
192 .write = write_file_dummy,
193 .open = simple_open,
194 .llseek = default_llseek,
195 };
196
197 static const struct file_operations sdram_fops = {
198 .read = sdram_read_file,
199 .write = write_file_dummy,
200 .open = simple_open,
201 .llseek = default_llseek,
202 };
203
204 static const struct file_operations misc_fops = {
205 .read = misc_read_file,
206 .write = write_file_dummy,
207 .open = simple_open,
208 .llseek = default_llseek,
209 };
210
211 static void mbxfb_debugfs_init(struct fb_info *fbi)
212 {
213 struct mbxfb_info *mfbi = fbi->par;
214 struct mbxfb_debugfs_data *dbg;
215
216 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL);
217 mfbi->debugfs_data = dbg;
218
219 dbg->dir = debugfs_create_dir("mbxfb", NULL);
220 dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir,
221 fbi, &sysconf_fops);
222 dbg->clock = debugfs_create_file("clock", 0444, dbg->dir,
223 fbi, &clock_fops);
224 dbg->display = debugfs_create_file("display", 0444, dbg->dir,
225 fbi, &display_fops);
226 dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir,
227 fbi, &gsctl_fops);
228 dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir,
229 fbi, &sdram_fops);
230 dbg->misc = debugfs_create_file("misc", 0444, dbg->dir,
231 fbi, &misc_fops);
232 }
233
234 static void mbxfb_debugfs_remove(struct fb_info *fbi)
235 {
236 struct mbxfb_info *mfbi = fbi->par;
237 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data;
238
239 debugfs_remove(dbg->misc);
240 debugfs_remove(dbg->sdram);
241 debugfs_remove(dbg->gsctl);
242 debugfs_remove(dbg->display);
243 debugfs_remove(dbg->clock);
244 debugfs_remove(dbg->sysconf);
245 debugfs_remove(dbg->dir);
246 }