All of lore.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-renesas-soc@vger.kernel.org
Cc: Magnus Damm <magnus.damm@gmail.com>
Subject: [PATCH/RFC 01/06] Prototype code for IMP-X5
Date: Mon, 21 Jan 2019 21:16:52 +0900	[thread overview]
Message-ID: <154807301237.2406.6258610622802083286.sendpatchset@octo> (raw)
In-Reply-To: <154807300302.2406.14245640502137089757.sendpatchset@octo>

From: Magnus Damm <damm+renesas@opensource.se>

Prototype code to read out the IMP-X5 register settings at probe() time.

Not for upstream merge.

Not-Yet-Signed-off-by: Magnus Damm <damm+renesas@opensource.se>
---

 drivers/soc/renesas/Makefile              |    2 
 drivers/soc/renesas/renesas-test-imp-x5.c |   77 +++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 1 deletion(-)

--- 0001/drivers/soc/renesas/Makefile
+++ work/drivers/soc/renesas/Makefile	2019-01-21 19:52:18.929754637 +0900
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 # Generic, must be first because of soc_device_register()
-obj-$(CONFIG_SOC_RENESAS)	+= renesas-soc.o
+obj-$(CONFIG_SOC_RENESAS)	+= renesas-soc.o renesas-test-imp-x5.o
 
 # SoC
 obj-$(CONFIG_SYSC_R8A7743)	+= r8a7743-sysc.o
--- /dev/null
+++ work/drivers/soc/renesas/renesas-test-imp-x5.c	2019-01-21 20:21:30.895607391 +0900
@@ -0,0 +1,77 @@
+#include <linux/delay.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
+
+static const struct of_device_id imp_x5_of_match[] = {
+	{ .compatible = "renesas,imp-x5" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imp_x5_of_match);
+
+static void imp_x5_dump_line(unsigned long addr, void __iomem *base, int offs)
+{
+	unsigned int buf[4];
+	char pfx[16];
+	int i;
+
+	for (i = 0; i < 4; i++)
+		buf[i] = ioread32(base + offs + i);
+
+	snprintf(pfx, sizeof(pfx), "0x%08lx: ", addr + offs);
+	
+	print_hex_dump(KERN_DEBUG, pfx, 0, 16, 1, &buf[0], 16, true);
+}
+
+static void imp_x5_dump(unsigned long addr, void __iomem *base, int length)
+{
+	int i;
+	
+	for (i = 0; i < length; i += 16)
+		imp_x5_dump_line(addr, base, i);
+}
+
+static int imp_x5_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *res;
+	void __iomem *base;
+	int i;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base)) {
+		dev_warn(dev, "unable to map imp-x5 registers\n");
+		return PTR_ERR(base);
+	}
+	
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
+	printk("IMP-X5 test: dumping registers\n");
+
+	for (i = 0; i < resource_size(res) && i < 0x300000; i += 0x100000)
+		imp_x5_dump(res->start + i, base + i, 64);
+	
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
+
+	return -ENODEV;
+}
+
+static struct platform_driver imp_x5_driver = {
+	.driver		= {
+		.name	= "renesas-imp-x5",
+		.of_match_table = of_match_ptr(imp_x5_of_match),
+	},
+	.probe		= imp_x5_probe,
+};
+
+module_platform_driver(imp_x5_driver);
+
+MODULE_DESCRIPTION("Renesas IMP-X5 test driver");
+MODULE_LICENSE("GPL v2");

  reply	other threads:[~2019-01-21 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-21 12:16 [PATCH/RFC 00/06] R-Car Gen3 IMP-X5 prototype code Magnus Damm
2019-01-21 12:16 ` Magnus Damm [this message]
2019-01-21 12:17 ` [PATCH/RFC 02/06] arm64: dts: renesas: r8a7795: One IMP-X5 device for R-Car H3 Magnus Damm
2019-01-21 12:17 ` [PATCH/RFC 03/06] arm64: dts: renesas: r8a7796: One IMP-X5 device for R-Car M3-W Magnus Damm
2019-01-21 12:17 ` [PATCH/RFC 04/06] arm64: dts: renesas: r8a77965: One IMP-X5 device for R-Car M3-N Magnus Damm
2019-01-21 12:17 ` [PATCH/RFC 05/06] arm64: dts: renesas: r8a77970: One IMP-X5 device for R-Car V3M Magnus Damm
2019-01-21 12:17 ` [PATCH/RFC 06/06] arm64: dts: renesas: r8a77980: One IMP-X5 device for R-Car V3H Magnus Damm

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=154807301237.2406.6258610622802083286.sendpatchset@octo \
    --to=magnus.damm@gmail.com \
    --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.