// SPDX-License-Identifier: GPL-2.0 /* * debugfs.c - Designware USB2 DRD controller debugfs * * Copyright (C) 2015 Intel Corporation * Mian Yousaf Kaukab <[email protected]> */ #include <linux/spinlock.h> #include <linux/debugfs.h> #include <linux/seq_file.h> #include <linux/uaccess.h> #include "core.h" #include "debug.h" #if IS_ENABLED(CONFIG_USB_DWC2_PERIPHERAL) || \ IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) /** * testmode_write() - change usb test mode state. * @file: The file to write to. * @ubuf: The buffer where user wrote. * @count: The ubuf size. * @ppos: Unused parameter. */ static ssize_t testmode_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { … } /** * testmode_show() - debugfs: show usb test mode state * @s: The seq file to write to. * @unused: Unused parameter. * * This debugfs entry shows which usb test mode is currently enabled. */ static int testmode_show(struct seq_file *s, void *unused) { … } static int testmode_open(struct inode *inode, struct file *file) { … } static const struct file_operations testmode_fops = …; /** * state_show - debugfs: show overall driver and device state. * @seq: The seq file to write to. * @v: Unused parameter. * * This debugfs entry shows the overall state of the hardware and * some general information about each of the endpoints available * to the system. */ static int state_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); /** * fifo_show - debugfs: show the fifo information * @seq: The seq_file to write data to. * @v: Unused parameter. * * Show the FIFO information for the overall fifo and all the * periodic transmission FIFOs. */ static int fifo_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); static const char *decode_direction(int is_in) { … } /** * ep_show - debugfs: show the state of an endpoint. * @seq: The seq_file to write data to. * @v: Unused parameter. * * This debugfs entry shows the state of the given endpoint (one is * registered for each available). */ static int ep_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); /** * dwc2_hsotg_create_debug - create debugfs directory and files * @hsotg: The driver state * * Create the debugfs files to allow the user to get information * about the state of the system. The directory name is created * with the same name as the device itself, in case we end up * with multiple blocks in future systems. */ static void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg) { … } #else static inline void dwc2_hsotg_create_debug(struct dwc2_hsotg *hsotg) {} #endif /* dwc2_hsotg_delete_debug is removed as cleanup in done in dwc2_debugfs_exit */ #define dump_register(nm) … static const struct debugfs_reg32 dwc2_regs[] = …; #define print_param(_seq, _ptr, _param) … #define print_param_hex(_seq, _ptr, _param) … static int params_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); static int hw_params_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); static int dr_mode_show(struct seq_file *seq, void *v) { … } DEFINE_SHOW_ATTRIBUTE(…); int dwc2_debugfs_init(struct dwc2_hsotg *hsotg) { … } void dwc2_debugfs_exit(struct dwc2_hsotg *hsotg) { … }