Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  *  Copyright © 2014 Broadcom
0004  */
0005 
0006 #include <linux/seq_file.h>
0007 #include <linux/circ_buf.h>
0008 #include <linux/ctype.h>
0009 #include <linux/debugfs.h>
0010 #include <linux/platform_device.h>
0011 
0012 #include "vc4_drv.h"
0013 #include "vc4_regs.h"
0014 
0015 struct vc4_debugfs_info_entry {
0016     struct list_head link;
0017     struct drm_info_list info;
0018 };
0019 
0020 /*
0021  * Called at drm_dev_register() time on each of the minors registered
0022  * by the DRM device, to attach the debugfs files.
0023  */
0024 void
0025 vc4_debugfs_init(struct drm_minor *minor)
0026 {
0027     struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
0028     struct vc4_debugfs_info_entry *entry;
0029 
0030     if (!of_device_is_compatible(vc4->hvs->pdev->dev.of_node,
0031                      "brcm,bcm2711-vc5"))
0032         debugfs_create_bool("hvs_load_tracker", S_IRUGO | S_IWUSR,
0033                     minor->debugfs_root, &vc4->load_tracker_enabled);
0034 
0035     list_for_each_entry(entry, &vc4->debugfs_list, link) {
0036         drm_debugfs_create_files(&entry->info, 1,
0037                      minor->debugfs_root, minor);
0038     }
0039 }
0040 
0041 static int vc4_debugfs_regset32(struct seq_file *m, void *unused)
0042 {
0043     struct drm_info_node *node = (struct drm_info_node *)m->private;
0044     struct debugfs_regset32 *regset = node->info_ent->data;
0045     struct drm_printer p = drm_seq_file_printer(m);
0046 
0047     drm_print_regset32(&p, regset);
0048 
0049     return 0;
0050 }
0051 
0052 /*
0053  * Registers a debugfs file with a callback function for a vc4 component.
0054  *
0055  * This is like drm_debugfs_create_files(), but that can only be
0056  * called a given DRM minor, while the various VC4 components want to
0057  * register their debugfs files during the component bind process.  We
0058  * track the request and delay it to be called on each minor during
0059  * vc4_debugfs_init().
0060  */
0061 void vc4_debugfs_add_file(struct drm_device *dev,
0062               const char *name,
0063               int (*show)(struct seq_file*, void*),
0064               void *data)
0065 {
0066     struct vc4_dev *vc4 = to_vc4_dev(dev);
0067 
0068     struct vc4_debugfs_info_entry *entry =
0069         devm_kzalloc(dev->dev, sizeof(*entry), GFP_KERNEL);
0070 
0071     if (!entry)
0072         return;
0073 
0074     entry->info.name = name;
0075     entry->info.show = show;
0076     entry->info.data = data;
0077 
0078     list_add(&entry->link, &vc4->debugfs_list);
0079 }
0080 
0081 void vc4_debugfs_add_regset32(struct drm_device *drm,
0082                   const char *name,
0083                   struct debugfs_regset32 *regset)
0084 {
0085     vc4_debugfs_add_file(drm, name, vc4_debugfs_regset32, regset);
0086 }