Skip to content

Commit

Permalink
usb: mtu3: add debugfs interface files
Browse files Browse the repository at this point in the history
This adds more debugfs consumers. The debugfs entries read some
important registers, fifo status, QMU ring, endpoint status, and
IPPC probe interface to get internal status.
With these entries, users can check the registers, endpoint and
GPD used during run time.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Chunfeng Yun authored and Greg Kroah-Hartman committed Mar 26, 2019
1 parent 48e0d37 commit ae07809
Show file tree
Hide file tree
Showing 7 changed files with 503 additions and 13 deletions.
4 changes: 4 additions & 0 deletions drivers/usb/mtu3/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ endif
ifneq ($(CONFIG_USB_MTU3_DUAL_ROLE),)
mtu3-y += mtu3_dr.o
endif

ifneq ($(CONFIG_DEBUG_FS),)
mtu3-y += mtu3_debugfs.o
endif
3 changes: 3 additions & 0 deletions drivers/usb/mtu3/mtu3_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/platform_device.h>

#include "mtu3.h"
#include "mtu3_debug.h"

static int ep_fifo_alloc(struct mtu3_ep *mep, u32 seg_size)
{
Expand Down Expand Up @@ -900,6 +901,8 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
mtu3_stop(mtu);

ssusb_dev_debugfs_init(ssusb);

dev_dbg(dev, " %s() done...\n", __func__);

return 0;
Expand Down
40 changes: 40 additions & 0 deletions drivers/usb/mtu3/mtu3_debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-2.0
/*
* mtu3_debug.h - debug header
*
* Copyright (C) 2019 MediaTek Inc.
*
* Author: Chunfeng Yun <chunfeng.yun@mediatek.com>
*/

#ifndef __MTU3_DEBUG_H__
#define __MTU3_DEBUG_H__

#include <linux/debugfs.h>

#define MTU3_DEBUGFS_NAME_LEN 32

struct mtu3_regset {
char name[MTU3_DEBUGFS_NAME_LEN];
struct debugfs_regset32 regset;
size_t nregs;
};

struct mtu3_file_map {
const char *name;
int (*show)(struct seq_file *s, void *unused);
};

#if IS_ENABLED(CONFIG_DEBUG_FS)
void ssusb_dev_debugfs_init(struct ssusb_mtk *ssusb);
void ssusb_debugfs_create_root(struct ssusb_mtk *ssusb);
void ssusb_debugfs_remove_root(struct ssusb_mtk *ssusb);

#else
static inline void ssusb_dev_debugfs_init(struct ssusb_mtk *ssusb) {}
static inline void ssusb_debugfs_create_root(struct ssusb_mtk *ssusb) {}
static inline void ssusb_debugfs_remove_root(struct ssusb_mtk *ssusb) {}

#endif /* CONFIG_DEBUG_FS */

#endif /* __MTU3_DEBUG_H__ */
Loading

0 comments on commit ae07809

Please sign in to comment.