linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
To: unlisted-recipients:; (no To-header on input)
Cc: linux-arm-kernel@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org,
	devicetree-discuss@lists.ozlabs.org, linux-i2c@vger.kernel.org,
	naveenkrishna.ch@gmail.com, kgene.kim@samsung.com,
	grant.likely@secretlab.ca, w.sang@pengutronix.de,
	linux-kernel@vger.kernel.org, taeggyun.ko@samsung.com,
	balbi@ti.com, thomas.abraham@linaro.org
Subject: [PATCH 2/2] i2c-exynos5: add debugfs support for registers
Date: Tue, 25 Dec 2012 16:55:55 +0530	[thread overview]
Message-ID: <1356434755-13702-2-git-send-email-ch.naveen@samsung.com> (raw)
In-Reply-To: <1356434755-13702-1-git-send-email-ch.naveen@samsung.com>

This patch replaces the dev_vdbg with debugfs function calls
in i2c-exynos5.c driver.

Signed-off-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
---
Changes since v1:
The debugfs implementation is a suggestion by Felipe Balbi.
Its not tested, Implemented only for review purpose..

 drivers/i2c/busses/i2c-exynos5.c |  140 +++++++++++++++++++++++++++++---------
 1 file changed, 109 insertions(+), 31 deletions(-)

diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index 7614f60..2d2da22 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -12,6 +12,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/debugfs.h>
 
 #include <linux/i2c.h>
 #include <linux/init.h>
@@ -55,6 +56,7 @@ struct exynos5_i2c {
 
 	int			bus_num;
 	int			speed_mode;
+	struct dentry		*debugfs_root;
 };
 
 static const struct of_device_id exynos5_i2c_match[] = {
@@ -63,39 +65,112 @@ static const struct of_device_id exynos5_i2c_match[] = {
 };
 MODULE_DEVICE_TABLE(of, exynos5_i2c_match);
 
-/* TODO: Should go to debugfs */
-static inline void dump_i2c_register(struct exynos5_i2c *i2c)
+static int exynos5_i2c_regs_show(struct seq_file *s, void *data)
 {
-	dev_vdbg(i2c->dev, "Register dump(%d) :\n %x\n %x\n %x\n %x\n"
-		" %x\n %x\n %x\n %x\n %x\n"
-		" %x\n %x\n %x\n %x\n %x\n"
-		" %x\n %x\n %x\n %x\n %x\n"
-		" %x\n %x\n %x\n %x\n %x\n",
-		i2c->suspended,
-		readl(i2c->regs + HSI2C_CTL),
-		readl(i2c->regs + HSI2C_FIFO_CTL),
-		readl(i2c->regs + HSI2C_TRAILIG_CTL),
-		readl(i2c->regs + HSI2C_CLK_CTL),
-		readl(i2c->regs + HSI2C_CLK_SLOT),
-		readl(i2c->regs + HSI2C_INT_ENABLE),
-		readl(i2c->regs + HSI2C_INT_STATUS),
-		readl(i2c->regs + HSI2C_ERR_STATUS),
-		readl(i2c->regs + HSI2C_FIFO_STATUS),
-		readl(i2c->regs + HSI2C_TX_DATA),
-		readl(i2c->regs + HSI2C_RX_DATA),
-		readl(i2c->regs + HSI2C_CONF),
-		readl(i2c->regs + HSI2C_AUTO_CONF),
-		readl(i2c->regs + HSI2C_TIMEOUT),
-		readl(i2c->regs + HSI2C_MANUAL_CMD),
-		readl(i2c->regs + HSI2C_TRANS_STATUS),
-		readl(i2c->regs + HSI2C_TIMING_HS1),
-		readl(i2c->regs + HSI2C_TIMING_HS2),
-		readl(i2c->regs + HSI2C_TIMING_HS3),
-		readl(i2c->regs + HSI2C_TIMING_FS1),
-		readl(i2c->regs + HSI2C_TIMING_FS2),
-		readl(i2c->regs + HSI2C_TIMING_FS3),
-		readl(i2c->regs + HSI2C_TIMING_SLA),
+	struct exynos5_i2c *i2c = (struct exynos5_i2c *)s->private;
+
+	if (i2c->suspended) {
+		seq_printf(s, "i2c suspended, can't read registers\n");
+		return 0;
+	}
+
+	pm_runtime_get_sync(i2c->dev);
+
+	seq_printf(s, "CTL:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_CTL));
+	seq_printf(s, "FIFO_CTL:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_FIFO_CTL));
+	seq_printf(s, "TRAILIG_CTL:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TRAILIG_CTL));
+	seq_printf(s, "CLK_CTL:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_CLK_CTL));
+	seq_printf(s, "CLK_SLOT:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_CLK_SLOT));
+	seq_printf(s, "INT_ENABLE:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_INT_ENABLE));
+	seq_printf(s, "INT_STATUS:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_INT_STATUS));
+	seq_printf(s, "FIFO_STATUS:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_FIFO_STATUS));
+	seq_printf(s, "TX_DATA:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TX_DATA));
+	seq_printf(s, "RX_DATA:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_RX_DATA));
+	seq_printf(s, "CONF:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_CONF));
+	seq_printf(s, "AUTO_CONF:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_AUTO_CONF));
+	seq_printf(s, "TIMEOUT:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMEOUT));
+	seq_printf(s, "MANUAL_CMD:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_MANUAL_CMD));
+	seq_printf(s, "TRANS_STATUS:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TRANS_STATUS));
+	seq_printf(s, "TIMING_HS1:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_HS1));
+	seq_printf(s, "TIMING_HS2:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_HS2));
+	seq_printf(s, "TIMING_HS3:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_HS3));
+	seq_printf(s, "TIMING_FS1:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_FS1));
+	seq_printf(s, "TIMING_FS2:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_FS2));
+	seq_printf(s, "TIMING_FS3:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_FS3));
+	seq_printf(s, "TIMING_SLA:\t\t0x%08x\n",
+		readl(i2c->regs + HSI2C_TIMING_SLA));
+	seq_printf(s, "ADDR:\t\t0x%08x\n",
 		readl(i2c->regs + HSI2C_ADDR));
+
+	pm_runtime_mark_last_busy(i2c->dev);
+	pm_runtime_put_autosuspend(i2c->dev);
+
+	return 0;
+}
+
+static int exynos5_i2c_regs_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, exynos5_i2c_regs_show, inode->i_private);
+}
+
+static const struct file_operations exynos5_i2c_regs_fops = {
+	.open           = exynos5_i2c_regs_open,
+	.read           = seq_read,
+	.llseek         = seq_lseek,
+	.release        = single_release,
+};
+
+static void exynos5_i2c_debugfs(struct exynos5_i2c *i2c)
+{
+	if (i2c->debugfs_root)
+		debugfs_create_file("regs", S_IRUSR, i2c->debugfs_root,
+			i2c, &exynos5_i2c_regs_fops);
+}
+
+static void exynos5_i2c_add_debugfs(struct exynos5_i2c *i2c)
+{
+	struct dentry *root;
+
+	root = debugfs_create_dir(dev_name(i2c->dev), NULL);
+	if (IS_ERR(root))
+		/* Don't complain -- debugfs just isn't enabled */
+		return;
+	if (!root)
+		/* Complain -- debugfs is enabled, but it failed to
+		 * create the directory. */
+		goto err_root;
+
+	i2c->debugfs_root = root;
+	return;
+
+ err_root:
+	dev_err(i2c->dev, "failed to initialize debugfs\n");
+}
+
+void exynos5_i2c_remove_debugfs(struct exynos5_i2c *i2c)
+{
+	debugfs_remove_recursive(i2c->debugfs_root);
 }
 
 static inline void exynos5_i2c_stop(struct exynos5_i2c *i2c, int ret)
@@ -553,6 +628,8 @@ static int exynos5_i2c_probe(struct platform_device *pdev)
 	dev_info(&pdev->dev, "%s: Exynos5 HS-I2C adapter\n",
 		dev_name(&i2c->adap.dev));
 
+	exynos5_i2c_add_debugfs(i2c);
+	exynos5_i2c_debugfs(i2c);
 	clk_disable_unprepare(i2c->clk);
 	pm_runtime_mark_last_busy(i2c->dev);
 	pm_runtime_put_autosuspend(i2c->dev);
@@ -586,6 +663,7 @@ static int exynos5_i2c_remove(struct platform_device *pdev)
 
 	iounmap(i2c->regs);
 	platform_set_drvdata(pdev, NULL);
+	exynos5_i2c_remove_debugfs(i2c);
 
 	return 0;
 }
-- 
1.7.9.5


  reply	other threads:[~2012-12-25 11:26 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-27 13:00 [PATCH 0/3] i2c: Add High speed I2C controller driver for Exynos5 Naveen Krishna Chatradhi
2012-11-27 13:00 ` [PATCH 1/3] i2c: exynos5: add High Speed I2C controller driver Naveen Krishna Chatradhi
2012-11-27 13:23   ` Felipe Balbi
2012-11-27 13:34   ` Thomas Abraham
2012-11-28  4:23     ` Naveen Krishna Ch
2012-12-25 11:25   ` [PATCH 1/2] " Naveen Krishna Chatradhi
2012-12-25 11:25     ` Naveen Krishna Chatradhi [this message]
2012-12-27 22:57       ` [PATCH 2/2] i2c-exynos5: add debugfs support for registers Felipe Balbi
2012-12-27 22:59       ` Felipe Balbi
2012-12-27 22:57     ` [PATCH 1/2] i2c: exynos5: add High Speed I2C controller driver Felipe Balbi
2012-12-28  6:42       ` Naveen Krishna Ch
2012-12-28 11:27   ` [PATCH v3] " Naveen Krishna Chatradhi
2012-12-28 16:36     ` Naveen Krishna Ch
2013-01-15  6:23       ` Naveen Krishna Ch
2013-01-23  5:05     ` Naveen Krishna Ch
2013-02-01 15:54   ` [PATCH v4] " Naveen Krishna Chatradhi
2013-02-01 19:29     ` Wolfram Sang
2013-02-08 13:16     ` Grant Likely
2013-03-12  4:32   ` [PATCH] " Naveen Krishna Chatradhi
2013-03-12 13:13     ` Simon Glass
2013-03-20 16:26       ` Naveen Krishna Ch
2013-03-20 16:24     ` [RFC: PATCH v5] " Naveen Krishna Chatradhi
2013-03-25 11:52       ` Yuvaraj CD
2013-03-26  9:23         ` Wolfram Sang
2013-03-28 22:01   ` [PATCH v6] " Naveen Krishna Chatradhi
2013-03-28 23:40   ` Naveen Krishna Chatradhi
2013-04-05  4:52   ` [PATCH v7] " Naveen Krishna Chatradhi
2013-04-13  4:40     ` Naveen Krishna Ch
2013-04-16 10:29     ` Wolfram Sang
     [not found]       ` <CAHfPSqCe_VJMeH3oCDc0CfcmpawMj0hN7_b3ngHDFtDUsPJLsA@mail.gmail.com>
2013-05-01 23:19         ` Fwd: " Naveen Krishna Ch
2013-05-02 11:27           ` Wolfram Sang
2013-05-02 11:48             ` Naveen Krishna Ch
2013-05-07  2:50   ` [PATCH v8] " Naveen Krishna Chatradhi
2013-05-07 12:06     ` Sachin Kamat
2013-05-17 10:10   ` [PATCH v9] " Naveen Krishna Chatradhi
2013-05-23  6:29     ` Naveen Krishna Ch
2013-06-10  8:10     ` Naveen Krishna Ch
2013-06-10 14:38     ` Wolfram Sang
2013-06-19 10:48   ` [PATCH v10] " Naveen Krishna Chatradhi
2013-07-01  6:17     ` Wolfram Sang
2013-07-01 10:25     ` Tomasz Figa
2013-08-15 13:12       ` Wolfram Sang
2013-08-16  4:58         ` Naveen Krishna Ch
2013-08-16  7:05           ` Wolfram Sang
2013-08-21  9:24   ` [PATCH] " Naveen Krishna Chatradhi
2013-09-08 17:03     ` Wolfram Sang
2013-10-11 11:43       ` Naveen Krishna Ch
2013-10-16  5:30   ` [PATCH v12] " Naveen Krishna Chatradhi
2013-10-25 11:47     ` Naveen Krishna Ch
2013-11-01 11:35     ` Wolfram Sang
2012-11-27 13:00 ` [PATCH 2/3] ARM: exynos5: Add gate clocks for HS-I2C Naveen Krishna Chatradhi
2012-11-27 13:00 ` [PATCH 3/3] arm: exynos5: Add HS-I2C device tree platform information Naveen Krishna Chatradhi

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=1356434755-13702-2-git-send-email-ch.naveen@samsung.com \
    --to=ch.naveen@samsung.com \
    --cc=balbi@ti.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=grant.likely@secretlab.ca \
    --cc=kgene.kim@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=naveenkrishna.ch@gmail.com \
    --cc=taeggyun.ko@samsung.com \
    --cc=thomas.abraham@linaro.org \
    --cc=w.sang@pengutronix.de \
    /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).