[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180426152920.21569-3-brgl@bgdev.pl>
Date: Thu, 26 Apr 2018 17:29:20 +0200
From: Bartosz Golaszewski <brgl@...ev.pl>
To: Sekhar Nori <nsekhar@...com>, Kevin Hilman <khilman@...nel.org>,
David Lechner <david@...hnology.com>,
Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
Rich Felker <dalias@...c.org>,
Frank Rowand <frowand.list@...il.com>,
"Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
Arend van Spriel <aspriel@...il.com>,
Heikki Krogerus <heikki.krogerus@...ux.intel.com>,
Michal Suchanek <msuchanek@...e.de>,
Jan Kiszka <jan.kiszka@...mens.com>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Marc Zyngier <marc.zyngier@....com>,
Peter Rosin <peda@...ntia.se>
Cc: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
devicetree@...r.kernel.org,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH RFC PoC 2/2] misc: implement a dummy early platform driver
From: Bartosz Golaszewski <bgolaszewski@...libre.com>
Implement a very simple early platform driver. Its purpose is to show
how such drivers can be registered and to emit a message when probed.
It can be then added to the device tree or machine code to verify that
the early platform devices work as expected.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
drivers/misc/Kconfig | 8 +++++++
drivers/misc/Makefile | 1 +
drivers/misc/dummy-early.c | 46 ++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+)
create mode 100644 drivers/misc/dummy-early.c
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 5d713008749b..99cde8aefdb0 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -91,6 +91,14 @@ config DUMMY_IRQ
The sole purpose of this module is to help with debugging of systems on
which spurious IRQs would happen on disabled IRQ vector.
+config DUMMY_EARLY
+ bool "Dummy early platform driver"
+ select EARLYDEV
+ default n
+ help
+ This module's only function is to register itself with the early
+ platform device framework and be probed early in the boot process.
+
config IBM_ASM
tristate "Device driver for IBM RSA service processor"
depends on X86 && PCI && INPUT
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 20be70c3f118..84ad0225eb14 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_INTEL_MID_PTI) += pti.o
obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o
obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o
obj-$(CONFIG_DUMMY_IRQ) += dummy-irq.o
+obj-$(CONFIG_DUMMY_EARLY) += dummy-early.o
obj-$(CONFIG_ICS932S401) += ics932s401.o
obj-$(CONFIG_LKDTM) += lkdtm/
obj-$(CONFIG_TIFM_CORE) += tifm_core.o
diff --git a/drivers/misc/dummy-early.c b/drivers/misc/dummy-early.c
new file mode 100644
index 000000000000..f00fb1fbd5fa
--- /dev/null
+++ b/drivers/misc/dummy-early.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Texas Instruments
+ *
+ * Author:
+ * Bartosz Golaszewski <bgolaszewski@...libre.com>
+ *
+ * Dummy testing driver whose only purpose is to be registered and probed
+ * using the early platform device mechanism.
+ */
+
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/earlydev.h>
+
+static int dummy_early_probe(struct platform_device *pdev)
+{
+ if (earlydev_probing_early())
+ dev_notice(&pdev->dev, "dummy-early driver probed early!\n");
+ else
+ dev_notice(&pdev->dev, "dummy-early driver probed late!\n");
+
+ return 0;
+}
+
+static const struct of_device_id dummy_early_of_match[] = {
+ { .compatible = "none,dummy-early", },
+ { },
+};
+
+static struct earlydev_driver dummy_early_driver = {
+ .plat_drv = {
+ .probe = dummy_early_probe,
+ .driver = {
+ .name = "dummy-early",
+ .of_match_table = dummy_early_of_match,
+ },
+ }
+};
+earlydev_platform_driver(dummy_early_driver);
+
+MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@...libre.com>");
+MODULE_DESCRIPTION("Dummy early platform device driver");
+MODULE_LICENSE("GPL v2");
--
2.17.0
Powered by blists - more mailing lists