From patchwork Mon Apr 8 11:55:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10889415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E56314DB for ; Mon, 8 Apr 2019 11:58:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FDFE26AE3 for ; Mon, 8 Apr 2019 11:58:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 045C128643; Mon, 8 Apr 2019 11:58:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B57426AE3 for ; Mon, 8 Apr 2019 11:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dNioFx7pr4NDH8Gvp+d06wPvNRLmssjKZ4oQRCZL0+g=; b=Vns1C3SFjlt15b 3o3os2jyUdiWFYENzKQtSWWaRD42BKWmeC7+B5j6T4HKD8K/7veIBmneLVYqCJFC4V6z0j8ovIJYX RZ/zxZqVJG2aAZkFZsNLBBua0ZqXvAzKlS4ywEv7vzRz+/NO+SYPv4CY8nYNhHn9k3wqVWTj3SJ6r 3q/tV7susvR1+tK+1ChFFfO+3O1mt1WDrEBcaUkaRrx9jglZ03efz2bZUgpUiCUBN3V3SYLx+d/zF Hafqyix4j+bNHPq39YmiMujFPuSwpmWsNmmED3H4xHD4ASjphe6qJFH6A9VxCDJyY3uepKks8c63q uiVMjlBVYYJpZpR3Z//Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDSv0-0005UI-Ux; Mon, 08 Apr 2019 11:58:30 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDSsT-0001mH-MR; Mon, 08 Apr 2019 11:55:58 +0000 X-UUID: 14184cf1024d4ac6a4de13bc82913310-20190408 X-UUID: 14184cf1024d4ac6a4de13bc82913310-20190408 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 1789826199; Mon, 08 Apr 2019 03:55:36 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Apr 2019 04:55:34 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Apr 2019 19:55:33 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 8 Apr 2019 19:55:33 +0800 From: Stu Hsieh To: Mauro Carvalho Chehab , Matthias Brugger Subject: [PATCH 14/14] [media] mtk-mipicsi: add debugfs for mipicsi driver Date: Mon, 8 Apr 2019 19:55:05 +0800 Message-ID: <1554724505-19882-15-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1554724505-19882-1-git-send-email-stu.hsieh@mediatek.com> References: <1554724505-19882-1-git-send-email-stu.hsieh@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190408_045554_026744_FFD9064E X-CRM114-Status: GOOD ( 11.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Stu Hsieh , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add debugfs for mipicsi driver. Signed-off-by: Stu Hsieh --- .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c index 95d25db5e606..77aecadab6b7 100644 --- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c @@ -49,6 +49,7 @@ #include #include #include +#include #ifdef CONFIG_VB2_MEDIATEK_DMA_SG #include "mtkbuf-dma-cache-sg.h" @@ -87,6 +88,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 @@ -96,6 +98,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 @@ -118,6 +121,7 @@ #define DMA_FRAME_HEADER_EN 0xE00 #define SerDes_support 1 +#define CONFIG_DEBUG_FS 1 static int mtk_mipicsi_dbg_level; #define mtk_mipicsi_dbg(level, fmt, args...) \ @@ -174,6 +178,9 @@ struct mtk_mipicsi_dev { u32 width; u32 height; u32 bytesperline; +#ifdef CONFIG_DEBUG_FS + struct dentry *mtk_mipicsi_debugfs; +#endif }; static const struct soc_mbus_lookup mtk_mipicsi_formats[] = { @@ -229,6 +236,49 @@ static const struct soc_mbus_lookup mtk_mipicsi_formats[] = { V4L2_MBUS_PCLK_SAMPLE_FALLING | \ V4L2_MBUS_DATA_ACTIVE_HIGH) +#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 soc_camera_host *soc_host = to_soc_camera_host(dev); + struct mtk_mipicsi_dev *mipicsi = soc_host->priv; + 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(mipicsi->seninf_mux[i] + 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 void mtk_mipicsi_ana_clk_enable(void __iomem *base, bool enable) { if (enable) { @@ -1588,6 +1638,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_info(&pdev->dev, "probe done\n"); return ret; clean: @@ -1600,6 +1660,11 @@ static int mtk_mipicsi_remove(struct platform_device *pdev) { struct soc_camera_host *soc_host = to_soc_camera_host(&pdev->dev); +#ifdef CONFIG_DEBUG_FS + struct mtk_mipicsi_dev *mipicsi = soc_host->priv; + + debugfs_remove(mipicsi->mtk_mipicsi_debugfs); +#endif soc_camera_host_unregister(soc_host); pm_runtime_disable(&pdev->dev);