1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright © 2014 Broadcom
6 #include <drm/drm_drv.h>
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>
17 struct vc4_debugfs_info_entry {
18 struct list_head link;
19 struct drm_info_list info;
23 * Called at drm_dev_register() time on each of the minors registered
24 * by the DRM device, to attach the debugfs files.
27 vc4_debugfs_init(struct drm_minor *minor)
29 struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
30 struct vc4_debugfs_info_entry *entry;
32 if (!of_device_is_compatible(vc4->hvs->pdev->dev.of_node,
34 debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
35 minor->debugfs_root, &vc4->load_tracker_enabled);
37 list_for_each_entry(entry, &vc4->debugfs_list, link) {
38 drm_debugfs_create_files(&entry->info, 1,
39 minor->debugfs_root, minor);
43 static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
45 struct drm_info_node *node = (struct drm_info_node *)m->private;
46 struct drm_device *drm = node->minor->dev;
47 struct debugfs_regset32 *regset = node->info_ent->data;
48 struct drm_printer p = drm_seq_file_printer(m);
51 if (!drm_dev_enter(drm, &idx))
54 drm_print_regset32(&p, regset);
62 * Registers a debugfs file with a callback function for a vc4 component.
64 * This is like drm_debugfs_create_files(), but that can only be
65 * called a given DRM minor, while the various VC4 components want to
66 * register their debugfs files during the component bind process. We
67 * track the request and delay it to be called on each minor during
70 int vc4_debugfs_add_file(struct drm_device *dev,
72 int (*show)(struct seq_file*, void*),
75 struct vc4_dev *vc4 = to_vc4_dev(dev);
77 struct vc4_debugfs_info_entry *entry =
78 devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
83 entry->info.name = name;
84 entry->info.show = show;
85 entry->info.data = data;
87 list_add(&entry->link, &vc4->debugfs_list);
92 int vc4_debugfs_add_regset32(struct drm_device *drm,
94 struct debugfs_regset32 *regset)
96 return vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);