diff options
Diffstat (limited to 'drivers/usb/chipidea/debug.c')
-rw-r--r-- | drivers/usb/chipidea/debug.c | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index 96d899aee473..7cccab6ff308 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
@@ -7,11 +7,15 @@ | |||
7 | #include <linux/uaccess.h> | 7 | #include <linux/uaccess.h> |
8 | #include <linux/usb/ch9.h> | 8 | #include <linux/usb/ch9.h> |
9 | #include <linux/usb/gadget.h> | 9 | #include <linux/usb/gadget.h> |
10 | #include <linux/usb/phy.h> | ||
11 | #include <linux/usb/otg.h> | ||
12 | #include <linux/usb/otg-fsm.h> | ||
10 | 13 | ||
11 | #include "ci.h" | 14 | #include "ci.h" |
12 | #include "udc.h" | 15 | #include "udc.h" |
13 | #include "bits.h" | 16 | #include "bits.h" |
14 | #include "debug.h" | 17 | #include "debug.h" |
18 | #include "otg.h" | ||
15 | 19 | ||
16 | /** | 20 | /** |
17 | * ci_device_show: prints information about device capabilities and status | 21 | * ci_device_show: prints information about device capabilities and status |
@@ -204,6 +208,80 @@ static const struct file_operations ci_requests_fops = { | |||
204 | .release = single_release, | 208 | .release = single_release, |
205 | }; | 209 | }; |
206 | 210 | ||
211 | int ci_otg_show(struct seq_file *s, void *unused) | ||
212 | { | ||
213 | struct ci_hdrc *ci = s->private; | ||
214 | struct otg_fsm *fsm; | ||
215 | |||
216 | if (!ci || !ci_otg_is_fsm_mode(ci)) | ||
217 | return 0; | ||
218 | |||
219 | fsm = &ci->fsm; | ||
220 | |||
221 | /* ------ State ----- */ | ||
222 | seq_printf(s, "OTG state: %s\n\n", | ||
223 | usb_otg_state_string(ci->transceiver->state)); | ||
224 | |||
225 | /* ------ State Machine Variables ----- */ | ||
226 | seq_printf(s, "a_bus_drop: %d\n", fsm->a_bus_drop); | ||
227 | |||
228 | seq_printf(s, "a_bus_req: %d\n", fsm->a_bus_req); | ||
229 | |||
230 | seq_printf(s, "a_srp_det: %d\n", fsm->a_srp_det); | ||
231 | |||
232 | seq_printf(s, "a_vbus_vld: %d\n", fsm->a_vbus_vld); | ||
233 | |||
234 | seq_printf(s, "b_conn: %d\n", fsm->b_conn); | ||
235 | |||
236 | seq_printf(s, "adp_change: %d\n", fsm->adp_change); | ||
237 | |||
238 | seq_printf(s, "power_up: %d\n", fsm->power_up); | ||
239 | |||
240 | seq_printf(s, "a_bus_resume: %d\n", fsm->a_bus_resume); | ||
241 | |||
242 | seq_printf(s, "a_bus_suspend: %d\n", fsm->a_bus_suspend); | ||
243 | |||
244 | seq_printf(s, "a_conn: %d\n", fsm->a_conn); | ||
245 | |||
246 | seq_printf(s, "b_bus_req: %d\n", fsm->b_bus_req); | ||
247 | |||
248 | seq_printf(s, "b_bus_suspend: %d\n", fsm->b_bus_suspend); | ||
249 | |||
250 | seq_printf(s, "b_se0_srp: %d\n", fsm->b_se0_srp); | ||
251 | |||
252 | seq_printf(s, "b_ssend_srp: %d\n", fsm->b_ssend_srp); | ||
253 | |||
254 | seq_printf(s, "b_sess_vld: %d\n", fsm->b_sess_vld); | ||
255 | |||
256 | seq_printf(s, "b_srp_done: %d\n", fsm->b_srp_done); | ||
257 | |||
258 | seq_printf(s, "drv_vbus: %d\n", fsm->drv_vbus); | ||
259 | |||
260 | seq_printf(s, "loc_conn: %d\n", fsm->loc_conn); | ||
261 | |||
262 | seq_printf(s, "loc_sof: %d\n", fsm->loc_sof); | ||
263 | |||
264 | seq_printf(s, "adp_prb: %d\n", fsm->adp_prb); | ||
265 | |||
266 | seq_printf(s, "id: %d\n", fsm->id); | ||
267 | |||
268 | seq_printf(s, "protocol: %d\n", fsm->protocol); | ||
269 | |||
270 | return 0; | ||
271 | } | ||
272 | |||
273 | static int ci_otg_open(struct inode *inode, struct file *file) | ||
274 | { | ||
275 | return single_open(file, ci_otg_show, inode->i_private); | ||
276 | } | ||
277 | |||
278 | static const struct file_operations ci_otg_fops = { | ||
279 | .open = ci_otg_open, | ||
280 | .read = seq_read, | ||
281 | .llseek = seq_lseek, | ||
282 | .release = single_release, | ||
283 | }; | ||
284 | |||
207 | static int ci_role_show(struct seq_file *s, void *data) | 285 | static int ci_role_show(struct seq_file *s, void *data) |
208 | { | 286 | { |
209 | struct ci_hdrc *ci = s->private; | 287 | struct ci_hdrc *ci = s->private; |
@@ -253,6 +331,50 @@ static const struct file_operations ci_role_fops = { | |||
253 | .release = single_release, | 331 | .release = single_release, |
254 | }; | 332 | }; |
255 | 333 | ||
334 | int ci_registers_show(struct seq_file *s, void *unused) | ||
335 | { | ||
336 | struct ci_hdrc *ci = s->private; | ||
337 | u32 tmp_reg; | ||
338 | |||
339 | if (!ci) | ||
340 | return 0; | ||
341 | |||
342 | /* ------ Registers ----- */ | ||
343 | tmp_reg = hw_read_intr_enable(ci); | ||
344 | seq_printf(s, "USBINTR reg: %08x\n", tmp_reg); | ||
345 | |||
346 | tmp_reg = hw_read_intr_status(ci); | ||
347 | seq_printf(s, "USBSTS reg: %08x\n", tmp_reg); | ||
348 | |||
349 | tmp_reg = hw_read(ci, OP_USBMODE, ~0); | ||
350 | seq_printf(s, "USBMODE reg: %08x\n", tmp_reg); | ||
351 | |||
352 | tmp_reg = hw_read(ci, OP_USBCMD, ~0); | ||
353 | seq_printf(s, "USBCMD reg: %08x\n", tmp_reg); | ||
354 | |||
355 | tmp_reg = hw_read(ci, OP_PORTSC, ~0); | ||
356 | seq_printf(s, "PORTSC reg: %08x\n", tmp_reg); | ||
357 | |||
358 | if (ci->is_otg) { | ||
359 | tmp_reg = hw_read_otgsc(ci, ~0); | ||
360 | seq_printf(s, "OTGSC reg: %08x\n", tmp_reg); | ||
361 | } | ||
362 | |||
363 | return 0; | ||
364 | } | ||
365 | |||
366 | static int ci_registers_open(struct inode *inode, struct file *file) | ||
367 | { | ||
368 | return single_open(file, ci_registers_show, inode->i_private); | ||
369 | } | ||
370 | |||
371 | static const struct file_operations ci_registers_fops = { | ||
372 | .open = ci_registers_open, | ||
373 | .read = seq_read, | ||
374 | .llseek = seq_lseek, | ||
375 | .release = single_release, | ||
376 | }; | ||
377 | |||
256 | /** | 378 | /** |
257 | * dbg_create_files: initializes the attribute interface | 379 | * dbg_create_files: initializes the attribute interface |
258 | * @ci: device | 380 | * @ci: device |
@@ -287,8 +409,21 @@ int dbg_create_files(struct ci_hdrc *ci) | |||
287 | if (!dent) | 409 | if (!dent) |
288 | goto err; | 410 | goto err; |
289 | 411 | ||
412 | if (ci_otg_is_fsm_mode(ci)) { | ||
413 | dent = debugfs_create_file("otg", S_IRUGO, ci->debugfs, ci, | ||
414 | &ci_otg_fops); | ||
415 | if (!dent) | ||
416 | goto err; | ||
417 | } | ||
418 | |||
290 | dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci, | 419 | dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci, |
291 | &ci_role_fops); | 420 | &ci_role_fops); |
421 | if (!dent) | ||
422 | goto err; | ||
423 | |||
424 | dent = debugfs_create_file("registers", S_IRUGO, ci->debugfs, ci, | ||
425 | &ci_registers_fops); | ||
426 | |||
292 | if (dent) | 427 | if (dent) |
293 | return 0; | 428 | return 0; |
294 | err: | 429 | err: |