1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright © 2014 Broadcom
4 */
5
6 #include <drm/drm_drv.h>
7 #include <drm/drm_print.h>
8
9 #include <linux/seq_file.h>
10 #include <linux/circ_buf.h>
11 #include <linux/ctype.h>
12 #include <linux/debugfs.h>
13 #include <linux/platform_device.h>
14
15 #include "vc4_drv.h"
16 #include "vc4_regs.h"
17
18 /*
19 * Called at drm_dev_register() time on each of the minors registered
20 * by the DRM device, to attach the debugfs files.
21 */
22 void
vc4_debugfs_init(struct drm_minor * minor)23 vc4_debugfs_init(struct drm_minor *minor)
24 {
25 struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
26 struct drm_device *drm = &vc4->base;
27
28 drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
29
30 if (vc4->v3d) {
31 drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
32 drm_WARN_ON(drm, vc4_v3d_debugfs_init(minor));
33 }
34 }
35
vc4_debugfs_regset32(struct seq_file * m,void * unused)36 static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
37 {
38 struct drm_debugfs_entry *entry = m->private;
39 struct drm_device *drm = entry->dev;
40 struct debugfs_regset32 *regset = entry->file.data;
41 struct drm_printer p = drm_seq_file_printer(m);
42 int idx;
43
44 if (!drm_dev_enter(drm, &idx))
45 return -ENODEV;
46
47 drm_print_regset32(&p, regset);
48
49 drm_dev_exit(idx);
50
51 return 0;
52 }
53
vc4_debugfs_add_regset32(struct drm_device * drm,const char * name,struct debugfs_regset32 * regset)54 void vc4_debugfs_add_regset32(struct drm_device *drm,
55 const char *name,
56 struct debugfs_regset32 *regset)
57 {
58 drm_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
59 }
60