1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (C) Rockchip Electronics Co.Ltd 4 * Author: Felix Zeng <felix.zeng@rock-chips.com> 5 */ 6 7 #ifndef __LINUX_RKNPU_DEBUGGER_H_ 8 #define __LINUX_RKNPU_DEBUGGER_H_ 9 10 #include <linux/seq_file.h> 11 12 /* 13 * struct rknpu_debugger - rknpu debugger information 14 * 15 * This structure represents a debugger to be created by the rknpu driver 16 * or core. 17 */ 18 struct rknpu_debugger { 19 #ifdef CONFIG_ROCKCHIP_RKNPU_DEBUG_FS 20 /* Directory of debugfs file */ 21 struct dentry *debugfs_dir; 22 struct list_head debugfs_entry_list; 23 struct mutex debugfs_lock; 24 #endif 25 #ifdef CONFIG_ROCKCHIP_RKNPU_PROC_FS 26 /* Directory of procfs file */ 27 struct proc_dir_entry *procfs_dir; 28 struct list_head procfs_entry_list; 29 struct mutex procfs_lock; 30 #endif 31 }; 32 33 /* 34 * struct rknpu_debugger_list - debugfs/procfs info list entry 35 * 36 * This structure represents a debugfs/procfs file to be created by the npu 37 * driver or core. 38 */ 39 struct rknpu_debugger_list { 40 /* File name */ 41 const char *name; 42 /* 43 * Show callback. &seq_file->private will be set to the &struct 44 * rknpu_debugger_node corresponding to the instance of this info 45 * on a given &struct rknpu_debugger. 46 */ 47 int (*show)(struct seq_file *seq, void *data); 48 /* 49 * Write callback. &seq_file->private will be set to the &struct 50 * rknpu_debugger_node corresponding to the instance of this info 51 * on a given &struct rknpu_debugger. 52 */ 53 ssize_t (*write)(struct file *file, const char __user *ubuf, size_t len, 54 loff_t *offp); 55 /* Procfs/Debugfs private data. */ 56 void *data; 57 }; 58 59 /* 60 * struct rknpu_debugger_node - Nodes for debugfs/procfs 61 * 62 * This structure represents each instance of procfs/debugfs created from the 63 * template. 64 */ 65 struct rknpu_debugger_node { 66 struct rknpu_debugger *debugger; 67 68 /* template for this node. */ 69 const struct rknpu_debugger_list *info_ent; 70 71 /* Each Procfs/Debugfs file. */ 72 #ifdef CONFIG_ROCKCHIP_RKNPU_DEBUG_FS 73 struct dentry *dent; 74 #endif 75 76 #ifdef CONFIG_ROCKCHIP_RKNPU_PROC_FS 77 struct proc_dir_entry *pent; 78 #endif 79 80 struct list_head list; 81 }; 82 83 struct rknpu_device; 84 85 int rknpu_debugger_init(struct rknpu_device *rknpu_dev); 86 int rknpu_debugger_remove(struct rknpu_device *rknpu_dev); 87 88 #endif /* __LINUX_RKNPU_FENCE_H_ */ 89