Loading...
Note: File does not exist in v3.1.
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright © 2014 Broadcom
4 */
5
6#include <drm/drm_drv.h>
7
8#include <linux/seq_file.h>
9#include <linux/circ_buf.h>
10#include <linux/ctype.h>
11#include <linux/debugfs.h>
12#include <linux/platform_device.h>
13
14#include "vc4_drv.h"
15#include "vc4_regs.h"
16
17/*
18 * Called at drm_dev_register() time on each of the minors registered
19 * by the DRM device, to attach the debugfs files.
20 */
21void
22vc4_debugfs_init(struct drm_minor *minor)
23{
24 struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
25 struct drm_device *drm = &vc4->base;
26
27 drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
28
29 if (vc4->v3d) {
30 drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
31 drm_WARN_ON(drm, vc4_v3d_debugfs_init(minor));
32 }
33}
34
35static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
36{
37 struct drm_info_node *node = (struct drm_info_node *)m->private;
38 struct drm_device *drm = node->minor->dev;
39 struct debugfs_regset32 *regset = node->info_ent->data;
40 struct drm_printer p = drm_seq_file_printer(m);
41 int idx;
42
43 if (!drm_dev_enter(drm, &idx))
44 return -ENODEV;
45
46 drm_print_regset32(&p, regset);
47
48 drm_dev_exit(idx);
49
50 return 0;
51}
52
53int vc4_debugfs_add_file(struct drm_minor *minor,
54 const char *name,
55 int (*show)(struct seq_file*, void*),
56 void *data)
57{
58 struct drm_device *dev = minor->dev;
59 struct dentry *root = minor->debugfs_root;
60 struct drm_info_list *file;
61
62 file = drmm_kzalloc(dev, sizeof(*file), GFP_KERNEL);
63 if (!file)
64 return -ENOMEM;
65
66 file->name = name;
67 file->show = show;
68 file->data = data;
69
70 drm_debugfs_create_files(file, 1, root, minor);
71
72 return 0;
73}
74
75int vc4_debugfs_add_regset32(struct drm_minor *minor,
76 const char *name,
77 struct debugfs_regset32 *regset)
78{
79 return vc4_debugfs_add_file(minor, name, vc4_debugfs_regset32, regset);
80}