All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: linux-renesas-soc@vger.kernel.org
Subject: [PATCH] v4l: rcar-fcp: Read IP version register at probe time
Date: Sat,  8 Jun 2019 15:53:31 +0300	[thread overview]
Message-ID: <20190608125331.29146-1-laurent.pinchart+renesas@ideasonboard.com> (raw)

This helps identifying the IP core version, for debugging purpose only
for now.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/media/platform/rcar-fcp.c | 43 +++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c
index 43c78620c9d8..e9b01965052d 100644
--- a/drivers/media/platform/rcar-fcp.c
+++ b/drivers/media/platform/rcar-fcp.c
@@ -8,6 +8,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/io.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
@@ -21,11 +22,38 @@
 struct rcar_fcp_device {
 	struct list_head list;
 	struct device *dev;
+	void __iomem *iomem;
 };
 
 static LIST_HEAD(fcp_devices);
 static DEFINE_MUTEX(fcp_lock);
 
+#define FCP_VCR			0x0000
+#define FCP_VCR_CATEGORY_MASK	(0xff << 8)
+#define FCP_VCR_CATEGORY_SHIFT	8
+#define FCP_VCR_REVISION_MASK	(0xff << 0)
+#define FCP_VCR_REVISION_SHIFT	0
+
+#define FCP_CFG0		0x0004
+#define FCP_RST			0x0010
+#define FCP_STA			0x0018
+#define FCP_TL_CTRL		0x0070
+#define FCP_PICINFO1		0x00c4
+#define FCP_BA_ANC_Y0		0x0100
+#define FCP_BA_ANC_Y1		0x0104
+#define FCP_BA_ANC_Y2		0x0108
+#define FCP_BA_ANC_C		0x010c
+#define FCP_BA_REF_Y0		0x0110
+#define FCP_BA_REF_Y1		0x0114
+#define FCP_BA_REF_Y2		0x0118
+#define FCP_BA_REF_C		0x011c
+
+
+static inline u32 rcar_fcp_read(struct rcar_fcp_device *fcp, u32 reg)
+{
+	return ioread32(fcp->iomem + reg);
+}
+
 /* -----------------------------------------------------------------------------
  * Public API
  */
@@ -129,6 +157,8 @@ EXPORT_SYMBOL_GPL(rcar_fcp_disable);
 static int rcar_fcp_probe(struct platform_device *pdev)
 {
 	struct rcar_fcp_device *fcp;
+	struct resource *mem;
+	u32 version;
 
 	fcp = devm_kzalloc(&pdev->dev, sizeof(*fcp), GFP_KERNEL);
 	if (fcp == NULL)
@@ -138,6 +168,19 @@ static int rcar_fcp_probe(struct platform_device *pdev)
 
 	pm_runtime_enable(&pdev->dev);
 
+	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	fcp->iomem = devm_ioremap_resource(&pdev->dev, mem);
+	if (IS_ERR(fcp->iomem))
+		return PTR_ERR(fcp->iomem);
+
+	pm_runtime_get_sync(&pdev->dev);
+	version = rcar_fcp_read(fcp, FCP_VCR);
+	pm_runtime_put(&pdev->dev);
+
+	dev_dbg(&pdev->dev, "FCP category %u revision %u\n",
+		(version & FCP_VCR_CATEGORY_MASK) >> FCP_VCR_CATEGORY_SHIFT,
+		(version & FCP_VCR_REVISION_MASK) >> FCP_VCR_REVISION_SHIFT);
+
 	mutex_lock(&fcp_lock);
 	list_add_tail(&fcp->list, &fcp_devices);
 	mutex_unlock(&fcp_lock);
-- 
Regards,

Laurent Pinchart


             reply	other threads:[~2019-06-08 12:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-08 12:53 Laurent Pinchart [this message]
2019-06-09  8:06 ` [PATCH] v4l: rcar-fcp: Read IP version register at probe time Geert Uytterhoeven
2019-06-09 10:08   ` Laurent Pinchart
2019-06-09 11:51     ` Geert Uytterhoeven
2019-06-09 12:37       ` Laurent Pinchart

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=20190608125331.29146-1-laurent.pinchart+renesas@ideasonboard.com \
    --to=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.