blob: f9dec08267dc7a7e8957aca514388c50633b7f9d [file] [log] [blame]
Eric Anholtc8b75bc2015-03-02 13:01:12 -08001/*
2 * Copyright © 2014 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
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 <drm/drmP.h>
14
15#include "vc4_drv.h"
16#include "vc4_regs.h"
17
Eric Anholtc9be8042019-04-01 11:35:58 -070018struct vc4_debugfs_info_entry {
19 struct list_head link;
20 struct drm_info_list info;
Eric Anholtc8b75bc2015-03-02 13:01:12 -080021};
22
Eric Anholtc9be8042019-04-01 11:35:58 -070023/**
24 * Called at drm_dev_register() time on each of the minors registered
25 * by the DRM device, to attach the debugfs files.
26 */
Eric Anholtc8b75bc2015-03-02 13:01:12 -080027int
28vc4_debugfs_init(struct drm_minor *minor)
29{
Paul Kocialkowski6b5c0292019-02-20 16:51:24 +010030 struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
Eric Anholtc9be8042019-04-01 11:35:58 -070031 struct vc4_debugfs_info_entry *entry;
Paul Kocialkowski6b5c0292019-02-20 16:51:24 +010032 struct dentry *dentry;
33
34 dentry = debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
35 minor->debugfs_root,
36 &vc4->load_tracker_enabled);
37 if (!dentry)
38 return -ENOMEM;
39
Eric Anholtc9be8042019-04-01 11:35:58 -070040 list_for_each_entry(entry, &vc4->debugfs_list, link) {
41 int ret = drm_debugfs_create_files(&entry->info, 1,
42 minor->debugfs_root, minor);
43
44 if (ret)
45 return ret;
46 }
47
48 return 0;
49}
50
kbuild test robote31b97e2019-04-04 05:36:29 +080051static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
Eric Anholtc9be8042019-04-01 11:35:58 -070052{
53 struct drm_info_node *node = (struct drm_info_node *)m->private;
54 struct debugfs_regset32 *regset = node->info_ent->data;
55 struct drm_printer p = drm_seq_file_printer(m);
56
57 drm_print_regset32(&p, regset);
58
59 return 0;
60}
61
62/**
63 * Registers a debugfs file with a callback function for a vc4 component.
64 *
65 * This is like drm_debugfs_create_files(), but that can only be
66 * called a given DRM minor, while the various VC4 components want to
67 * register their debugfs files during the component bind process. We
68 * track the request and delay it to be called on each minor during
69 * vc4_debugfs_init().
70 */
71void vc4_debugfs_add_file(struct drm_device *dev,
72 const char *name,
73 int (*show)(struct seq_file*, void*),
74 void *data)
75{
76 struct vc4_dev *vc4 = to_vc4_dev(dev);
77
78 struct vc4_debugfs_info_entry *entry =
79 devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
80
81 if (!entry)
82 return;
83
84 entry->info.name = name;
85 entry->info.show = show;
86 entry->info.data = data;
87
88 list_add(&entry->link, &vc4->debugfs_list);
89}
90
91void vc4_debugfs_add_regset32(struct drm_device *drm,
92 const char *name,
93 struct debugfs_regset32 *regset)
94{
95 vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
Eric Anholtc8b75bc2015-03-02 13:01:12 -080096}