Commit ae078092 authored by Chunfeng Yun's avatar Chunfeng Yun Committed by Greg Kroah-Hartman

usb: mtu3: add debugfs interface files

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: default avatarChunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 48e0d373
...@@ -17,3 +17,7 @@ endif ...@@ -17,3 +17,7 @@ endif
ifneq ($(CONFIG_USB_MTU3_DUAL_ROLE),) ifneq ($(CONFIG_USB_MTU3_DUAL_ROLE),)
mtu3-y += mtu3_dr.o mtu3-y += mtu3_dr.o
endif endif
ifneq ($(CONFIG_DEBUG_FS),)
mtu3-y += mtu3_debugfs.o
endif
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include "mtu3.h" #include "mtu3.h"
#include "mtu3_debug.h"
static int ep_fifo_alloc(struct mtu3_ep *mep, u32 seg_size) static int ep_fifo_alloc(struct mtu3_ep *mep, u32 seg_size)
{ {
...@@ -900,6 +901,8 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) ...@@ -900,6 +901,8 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb)
if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG) if (mtu->ssusb->dr_mode == USB_DR_MODE_OTG)
mtu3_stop(mtu); mtu3_stop(mtu);
ssusb_dev_debugfs_init(ssusb);
dev_dbg(dev, " %s() done...\n", __func__); dev_dbg(dev, " %s() done...\n", __func__);
return 0; return 0;
......
// 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__ */
This diff is collapsed.
...@@ -379,20 +379,12 @@ static const struct file_operations ssusb_vbus_fops = { ...@@ -379,20 +379,12 @@ static const struct file_operations ssusb_vbus_fops = {
static void ssusb_debugfs_init(struct ssusb_mtk *ssusb) static void ssusb_debugfs_init(struct ssusb_mtk *ssusb)
{ {
struct dentry *root; struct dentry *root = ssusb->dbgfs_root;
root = debugfs_create_dir(dev_name(ssusb->dev), usb_debug_root);
ssusb->dbgfs_root = root;
debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops); debugfs_create_file("mode", 0644, root, ssusb, &ssusb_mode_fops);
debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops); debugfs_create_file("vbus", 0644, root, ssusb, &ssusb_vbus_fops);
} }
static void ssusb_debugfs_exit(struct ssusb_mtk *ssusb)
{
debugfs_remove_recursive(ssusb->dbgfs_root);
}
void ssusb_set_force_mode(struct ssusb_mtk *ssusb, void ssusb_set_force_mode(struct ssusb_mtk *ssusb,
enum mtu3_dr_force_mode mode) enum mtu3_dr_force_mode mode)
{ {
...@@ -436,9 +428,6 @@ void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb) ...@@ -436,9 +428,6 @@ void ssusb_otg_switch_exit(struct ssusb_mtk *ssusb)
{ {
struct otg_switch_mtk *otg_sx = &ssusb->otg_switch; struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
if (otg_sx->manual_drd_enabled)
ssusb_debugfs_exit(ssusb);
cancel_work_sync(&otg_sx->id_work); cancel_work_sync(&otg_sx->id_work);
cancel_work_sync(&otg_sx->vbus_work); cancel_work_sync(&otg_sx->vbus_work);
} }
...@@ -290,6 +290,7 @@ ...@@ -290,6 +290,7 @@
#define U3D_LTSSM_CTRL (SSUSB_USB3_MAC_CSR_BASE + 0x0010) #define U3D_LTSSM_CTRL (SSUSB_USB3_MAC_CSR_BASE + 0x0010)
#define U3D_USB3_CONFIG (SSUSB_USB3_MAC_CSR_BASE + 0x001C) #define U3D_USB3_CONFIG (SSUSB_USB3_MAC_CSR_BASE + 0x001C)
#define U3D_LINK_STATE_MACHINE (SSUSB_USB3_MAC_CSR_BASE + 0x0134)
#define U3D_LTSSM_INTR_ENABLE (SSUSB_USB3_MAC_CSR_BASE + 0x013C) #define U3D_LTSSM_INTR_ENABLE (SSUSB_USB3_MAC_CSR_BASE + 0x013C)
#define U3D_LTSSM_INTR (SSUSB_USB3_MAC_CSR_BASE + 0x0140) #define U3D_LTSSM_INTR (SSUSB_USB3_MAC_CSR_BASE + 0x0140)
...@@ -307,6 +308,9 @@ ...@@ -307,6 +308,9 @@
/* U3D_USB3_CONFIG */ /* U3D_USB3_CONFIG */
#define USB3_EN BIT(0) #define USB3_EN BIT(0)
/* U3D_LINK_STATE_MACHINE */
#define LTSSM_STATE(x) ((x) & 0x1f)
/* U3D_LTSSM_INTR_ENABLE */ /* U3D_LTSSM_INTR_ENABLE */
/* U3D_LTSSM_INTR */ /* U3D_LTSSM_INTR */
#define U3_RESUME_INTR BIT(18) #define U3_RESUME_INTR BIT(18)
...@@ -372,6 +376,7 @@ ...@@ -372,6 +376,7 @@
#define U3D_USB20_FRAME_NUM (SSUSB_USB2_CSR_BASE + 0x003C) #define U3D_USB20_FRAME_NUM (SSUSB_USB2_CSR_BASE + 0x003C)
#define U3D_USB20_LPM_PARAMETER (SSUSB_USB2_CSR_BASE + 0x0044) #define U3D_USB20_LPM_PARAMETER (SSUSB_USB2_CSR_BASE + 0x0044)
#define U3D_USB20_MISC_CONTROL (SSUSB_USB2_CSR_BASE + 0x004C) #define U3D_USB20_MISC_CONTROL (SSUSB_USB2_CSR_BASE + 0x004C)
#define U3D_USB20_OPSTATE (SSUSB_USB2_CSR_BASE + 0x0060)
/*---------------- SSUSB_USB2_CSR FIELD DEFINITION ----------------*/ /*---------------- SSUSB_USB2_CSR FIELD DEFINITION ----------------*/
...@@ -445,6 +450,12 @@ ...@@ -445,6 +450,12 @@
#define U3D_SSUSB_HW_ID (SSUSB_SIFSLV_IPPC_BASE + 0x00A0) #define U3D_SSUSB_HW_ID (SSUSB_SIFSLV_IPPC_BASE + 0x00A0)
#define U3D_SSUSB_HW_SUB_ID (SSUSB_SIFSLV_IPPC_BASE + 0x00A4) #define U3D_SSUSB_HW_SUB_ID (SSUSB_SIFSLV_IPPC_BASE + 0x00A4)
#define U3D_SSUSB_IP_TRUNK_VERS (U3D_SSUSB_HW_SUB_ID) #define U3D_SSUSB_IP_TRUNK_VERS (U3D_SSUSB_HW_SUB_ID)
#define U3D_SSUSB_PRB_CTRL0 (SSUSB_SIFSLV_IPPC_BASE + 0x00B0)
#define U3D_SSUSB_PRB_CTRL1 (SSUSB_SIFSLV_IPPC_BASE + 0x00B4)
#define U3D_SSUSB_PRB_CTRL2 (SSUSB_SIFSLV_IPPC_BASE + 0x00B8)
#define U3D_SSUSB_PRB_CTRL3 (SSUSB_SIFSLV_IPPC_BASE + 0x00BC)
#define U3D_SSUSB_PRB_CTRL4 (SSUSB_SIFSLV_IPPC_BASE + 0x00C0)
#define U3D_SSUSB_PRB_CTRL5 (SSUSB_SIFSLV_IPPC_BASE + 0x00C4)
#define U3D_SSUSB_IP_SPARE0 (SSUSB_SIFSLV_IPPC_BASE + 0x00C8) #define U3D_SSUSB_IP_SPARE0 (SSUSB_SIFSLV_IPPC_BASE + 0x00C8)
/*---------------- SSUSB_SIFSLV_IPPC FIELD DEFINITION ----------------*/ /*---------------- SSUSB_SIFSLV_IPPC FIELD DEFINITION ----------------*/
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "mtu3.h" #include "mtu3.h"
#include "mtu3_dr.h" #include "mtu3_dr.h"
#include "mtu3_debug.h"
/* u2-port0 should be powered on and enabled; */ /* u2-port0 should be powered on and enabled; */
int ssusb_check_clocks(struct ssusb_mtk *ssusb, u32 ex_clks) int ssusb_check_clocks(struct ssusb_mtk *ssusb, u32 ex_clks)
...@@ -232,7 +233,7 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb) ...@@ -232,7 +233,7 @@ static int get_ssusb_rscs(struct platform_device *pdev, struct ssusb_mtk *ssusb)
int i; int i;
int ret; int ret;
ssusb->vusb33 = devm_regulator_get(&pdev->dev, "vusb33"); ssusb->vusb33 = devm_regulator_get(dev, "vusb33");
if (IS_ERR(ssusb->vusb33)) { if (IS_ERR(ssusb->vusb33)) {
dev_err(dev, "failed to get vusb33\n"); dev_err(dev, "failed to get vusb33\n");
return PTR_ERR(ssusb->vusb33); return PTR_ERR(ssusb->vusb33);
...@@ -353,6 +354,8 @@ static int mtu3_probe(struct platform_device *pdev) ...@@ -353,6 +354,8 @@ static int mtu3_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
ssusb_debugfs_create_root(ssusb);
/* enable power domain */ /* enable power domain */
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_get_sync(dev); pm_runtime_get_sync(dev);
...@@ -423,6 +426,7 @@ static int mtu3_probe(struct platform_device *pdev) ...@@ -423,6 +426,7 @@ static int mtu3_probe(struct platform_device *pdev)
comm_init_err: comm_init_err:
pm_runtime_put_sync(dev); pm_runtime_put_sync(dev);
pm_runtime_disable(dev); pm_runtime_disable(dev);
ssusb_debugfs_remove_root(ssusb);
return ret; return ret;
} }
...@@ -450,6 +454,7 @@ static int mtu3_remove(struct platform_device *pdev) ...@@ -450,6 +454,7 @@ static int mtu3_remove(struct platform_device *pdev)
ssusb_rscs_exit(ssusb); ssusb_rscs_exit(ssusb);
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
ssusb_debugfs_remove_root(ssusb);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment