linux-renesas-soc.vger.kernel.org archive mirror
 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 01/09] Prototype code for basic IMR-LX4 test
Date: Wed, 19 Dec 2018 19:26:16 +0900	[thread overview]
Message-ID: <154521517624.7290.16869907830594641606.sendpatchset@octo> (raw)
In-Reply-To: <154521516632.7290.5245227863765109428.sendpatchset@octo>

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

Introduce some basic test code for the IMR-LX4 device included in
R-Car Gen3 SoCs. At this point the code only controls clocks and
power domains using Runtime PM and resets the device. Obviously a
proper driver would be much more useful. This code is however useful
to test clocks and power domains and may in the future be extended
for IPMMU and further power management testing. Not for upstream merge.

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

 drivers/soc/renesas/Makefile               |    2 
 drivers/soc/renesas/renesas-test-imr-lx4.c |   71 ++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 1 deletion(-)

--- 0001/drivers/soc/renesas/Makefile
+++ work/drivers/soc/renesas/Makefile	2018-12-19 17:58:52.476078897 +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-imr-lx4.o
 
 # SoC
 obj-$(CONFIG_SYSC_R8A7743)	+= r8a7743-sysc.o
--- /dev/null
+++ work/drivers/soc/renesas/renesas-test-imr-lx4.c	2018-12-19 18:41:47.436079896 +0900
@@ -0,0 +1,71 @@
+#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>
+
+#define REG_CR 0x0008
+#define REG_ICR 0x0014
+#define REG_DLSAR 0x0030
+
+static const struct of_device_id imr_lx4_of_match[] = {
+	{ .compatible = "renesas,imr-lx4" },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, imr_lx4_of_match);
+
+static int imr_lx4_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct resource *res;
+	void __iomem *base;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(base)) {
+		dev_warn(dev, "unable to map imr-lx4 registers\n");
+		return PTR_ERR(base);
+	}
+	
+	pm_runtime_enable(dev);
+	pm_runtime_get_sync(dev);
+
+	printk("IMR-LX4 test: DLSAR, ICR registers should change when reset\n");
+	printk("configuring DLSAR and ICR registers\n");
+	iowrite32(0xdeadbee8, base + REG_DLSAR);
+	iowrite32(0x18, base + REG_ICR);
+
+	printk("DLSAR register 0x%08x\n", ioread32(base + REG_DLSAR));
+	printk("ICR register 0x%08x\n", ioread32(base + REG_ICR));
+	printk("CR register 0x%08x\n", ioread32(base + REG_CR));
+
+	printk("performing reset via CR register\n");
+	iowrite32(0x8000, base + REG_CR);
+
+	mdelay(1000);
+	
+	printk("DLSAR register 0x%08x\n", ioread32(base + REG_DLSAR));
+	printk("ICR register 0x%08x\n", ioread32(base + REG_ICR));
+	printk("CR register 0x%08x\n", ioread32(base + REG_CR));
+	
+	pm_runtime_put(dev);
+	pm_runtime_disable(dev);
+
+	return -ENODEV;
+}
+
+static struct platform_driver imr_lx4_driver = {
+	.driver		= {
+		.name	= "renesas-imr-lx4",
+		.of_match_table = of_match_ptr(imr_lx4_of_match),
+	},
+	.probe		= imr_lx4_probe,
+};
+
+module_platform_driver(imr_lx4_driver);
+
+MODULE_DESCRIPTION("Renesas IMR-LX4 test driver");
+MODULE_LICENSE("GPL v2");

  reply	other threads:[~2018-12-19 10:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 10:26 [PATCH 00/09] Test R-Car Gen3 IMR-LX4 device Magnus Damm
2018-12-19 10:26 ` Magnus Damm [this message]
2018-12-19 10:26 ` [PATCH 02/09] arm64: dts: renesas: r8a7795: One IMR-LX4 device for R-Car H3 Magnus Damm
2018-12-19 10:26 ` [PATCH 03/09] arm64: dts: renesas: r8a7796: One IMR-LX4 device for R-Car M3-W Magnus Damm
2018-12-19 10:26 ` [PATCH 04/09] arm64: dts: renesas: r8a77965: One IMR-LX4 device for R-Car M3-N Magnus Damm
2018-12-19 10:26 ` [PATCH 05/09] arm64: dts: renesas: r8a77970: One IMR-LX4 device for R-Car V3M Magnus Damm
2018-12-19 10:27 ` [PATCH 06/09] arm64: dts: renesas: r8a77980: One IMR-LX4 device for R-Car V3H Magnus Damm
2018-12-19 10:27 ` [PATCH 07/09] arm64: dts: renesas: r8a77995: One IMR-LX4 device for R-Car D3 Magnus Damm
2018-12-19 10:27 ` [PATCH 08/09] arm64: dts: renesas: r8a77990: One IMR-LX4 device for R-Car E3 Magnus Damm
2018-12-19 10:27 ` [PATCH 09/09] Random build workarounds for renesas-drivers 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=154521517624.7290.16869907830594641606.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 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).