diff mbox series

[PATCH/RFC,01/06] Prototype code for IMP-X5

Message ID 154807301237.2406.6258610622802083286.sendpatchset@octo (mailing list archive)
State RFC
Delegated to: Simon Horman
Headers show
Series R-Car Gen3 IMP-X5 prototype code | expand

Commit Message

Magnus Damm Jan. 21, 2019, 12:16 p.m. UTC
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(-)
diff mbox series

Patch

--- 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");