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