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