From: Stu Hsieh <stu.hsieh@mediatek.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh+dt@kernel.org>, CK Hu <ck.hu@mediatek.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Stu Hsieh <stu.hsieh@mediatek.com>,
linux-media@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, srv_heupstream@mediatek.com
Subject: [PATCH v4 13/14] [media] mtk-mipicsi: add debugfs for mipicsi driver
Date: Tue, 4 Jun 2019 18:11:54 +0800 [thread overview]
Message-ID: <1559643115-15124-14-git-send-email-stu.hsieh@mediatek.com> (raw)
In-Reply-To: <1559643115-15124-1-git-send-email-stu.hsieh@mediatek.com>
This patch add debugfs for mipicsi driver.
Signed-off-by: Stu Hsieh <stu.hsieh@mediatek.com>
---
.../media/platform/mtk-mipicsi/mtk_mipicsi.c | 68 ++++++++++++++++++-
1 file changed, 67 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c
index b291c95bbf0e..9b5983b39f2b 100644
--- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c
+++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c
@@ -50,6 +50,7 @@
#include <soc/mediatek/smi.h>
#include <linux/regmap.h>
#include <linux/mfd/syscon.h>
+#include <linux/debugfs.h>
#define MTK_MIPICSI_DRV_NAME "mtk-mipicsi"
#define MTK_PLATFORM_STR "platform:mt2712"
@@ -78,6 +79,7 @@
#define SENINF_NCSI2_INT_EN 0xB0
#define SENINF_NCSI2_INT_STATUS 0xB4
#define SENINF_NCSI2_DBG_SEL 0xB8
+#define SENINF_NCSI2_DBG_PORT 0xBC
#define SENINF_NCSI2_HSRX_DBG 0xD8
#define SENINF_NCSI2_DI 0xDC
#define SENINF_NCSI2_DI_CTRL 0xE4
@@ -87,6 +89,7 @@
#define SENINF_TOP_MUX 0x08
#define SENINF_MUX_CTRL 0x00
+#define SENINF_MUX_DEBUG_2 0x14
#define CAMSV_MODULE_EN 0x10
#define CAMSV_FMT_SEL 0x14
@@ -108,6 +111,8 @@
#define IMGO_STRIDE 0x238
#define DMA_FRAME_HEADER_EN 0xE00
+#define CONFIG_DEBUG_FS 1
+
#define notifier_to_mipicsi(n) container_of(n, struct mtk_mipicsi_dev, \
notifier)
static int mtk_mipicsi_dbg_level;
@@ -184,7 +189,9 @@ struct mtk_mipicsi_dev {
spinlock_t irqlock;
spinlock_t queue_lock;
struct mutex lock;
-
+#ifdef CONFIG_DEBUG_FS
+ struct dentry *mtk_mipicsi_debugfs;
+#endif
};
static const struct mtk_format mtk_mipicsi_formats[] = {
@@ -207,12 +214,56 @@ static const struct mtk_format mtk_mipicsi_formats[] = {
},
};
+#ifdef CONFIG_DEBUG_FS
+static ssize_t mtk_mipicsi_debug_read(struct file *file, char __user *user_buf,
+ size_t count, loff_t *ppos)
+{
+ struct device *dev = file->private_data;
+ struct mtk_mipicsi_dev *mipicsi = dev_get_drvdata(dev);
+ struct mtk_mipicsi_channel *ch = mipicsi->channel;
+ u32 int_val;
+ u32 dbg_port;
+ u32 cnt_val;
+ u32 hcnt;
+ u32 vcnt;
+ char buf[256];
+ char cnt_info[150];
+ int i;
+
+ int_val = readl(mipicsi->seninf + SENINF_NCSI2_INT_STATUS);
+ dbg_port = readl(mipicsi->seninf + SENINF_NCSI2_DBG_PORT);
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "%s\nSENINF_NCSI2_INT_STATUS: 0x%X\n"
+ "SENINF_NCSI2_DBG_PORT: 0x%X\n",
+ dev_name(dev), int_val, dbg_port);
+
+ for (i = 0; i < mipicsi->camsv_num; ++i) {
+ cnt_val = readl(ch[i].seninf_mux + SENINF_MUX_DEBUG_2);
+ hcnt = (cnt_val >> 16) & 0xFFFF;
+ vcnt = cnt_val & 0xFFFF;
+ memset(cnt_info, 0, sizeof(cnt_info));
+ snprintf(cnt_info, sizeof(cnt_info),
+ "HCNT[%d]: 0x%X\n"
+ "VCNT[%d]: 0x%X\n",
+ i, hcnt, i, vcnt);
+ strcat(buf, cnt_info);
+ }
+
+ return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+}
+static const struct file_operations mtk_mipicsi_debug_fops = {
+ .open = simple_open,
+ .read = mtk_mipicsi_debug_read,
+};
+#endif /* CONFIG_DEBUG_FS */
+
static int get_subdev_link(struct mtk_mipicsi_dev *mipicsi,
unsigned int *link, u8 *link_reg_val)
{
struct device *dev = &mipicsi->pdev->dev;
struct mtk_mipicsi_subdev *sd = &mipicsi->mipicsi_sd;
+
if (sd->max_vc == 1) {
*link = 1;
*link_reg_val = 0x1;
@@ -1574,6 +1625,16 @@ static int mtk_mipicsi_probe(struct platform_device *pdev)
goto clean;
}
+#ifdef CONFIG_DEBUG_FS
+ mipicsi->mtk_mipicsi_debugfs =
+ debugfs_create_file(mipicsi->drv_name, 0444, NULL,
+ (void *)(&pdev->dev), &mtk_mipicsi_debug_fops);
+ if (mipicsi->mtk_mipicsi_debugfs == NULL) {
+ dev_err(&pdev->dev, "debugfs_create_file fail\n");
+ goto clean;
+ }
+#endif
+
dev_set_drvdata(&pdev->dev, mipicsi);
dev_info(&pdev->dev, "probe done\n");
@@ -1591,6 +1652,11 @@ static int mtk_mipicsi_probe(struct platform_device *pdev)
static int mtk_mipicsi_remove(struct platform_device *pdev)
{
+#ifdef CONFIG_DEBUG_FS
+ struct mtk_mipicsi_dev *mipicsi = dev_get_drvdata(&pdev->dev);
+
+ debugfs_remove(mipicsi->mtk_mipicsi_debugfs);
+#endif
pm_runtime_disable(&pdev->dev);
return 0;
--
2.18.0
next prev parent reply other threads:[~2019-06-04 10:11 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-04 10:11 [PATCH v4 00/14] Add mediatek mipicsi driver for Mediatek SOC MT2712 Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 01/14] dt-bindings: Add binding for MT2712 MIPI-CSI2 Stu Hsieh
2019-06-10 2:34 ` CK Hu
2019-06-10 3:32 ` Tomasz Figa
2019-06-10 7:51 ` CK Hu
2019-06-10 7:58 ` Tomasz Figa
2019-08-26 14:05 ` Sakari Ailus
2019-06-04 10:11 ` [PATCH v4 02/14] dt-bindings: media: Add mipicsi common node " Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 03/14] dt-bindings: media: Add camsv " Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 04/14] [media] mtk-mipicsi: add mediatek mipicsi driver for mt2712 Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 05/14] [media] mtk-mipicsi: register the v4l2 device for mt2712 mipicsi Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 06/14] [media] mtk-mipicsi: enable/disable ana clk Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 07/14] [media] mtk-mipicsi: add function to get the number of subdev link Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 08/14] [media] mtk-mipicsi: enable/disable cmos for mt2712 Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 09/14] [media] mtk-mipicsi: add ISR for writing the data to buffer Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 10/14] [media] mtk-mipicsi: set the output address in HW reg Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 11/14] [media] mtk-mipicsi: add function to get the format Stu Hsieh
2019-06-04 10:11 ` [PATCH v4 12/14] [media] mtk-mipicsi: add debug message for mipicsi driver Stu Hsieh
2019-06-04 10:11 ` Stu Hsieh [this message]
2019-06-04 10:11 ` [PATCH v4 14/14] [media] mtk-mipicsi: add function to support SerDes for link number Stu Hsieh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1559643115-15124-14-git-send-email-stu.hsieh@mediatek.com \
--to=stu.hsieh@mediatek.com \
--cc=ck.hu@mediatek.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
--cc=robh+dt@kernel.org \
--cc=srv_heupstream@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).