diff mbox

[U-Boot,03/23] dm: core: Add support for simple-bus

Message ID 1412443798-6436-4-git-send-email-sjg@chromium.org
State Awaiting Upstream
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Oct. 4, 2014, 5:29 p.m. UTC
Add a driver for the simple-bus nodes, which allows devices within these
nodes to be bound.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/Makefile     |  1 +
 drivers/core/simple-bus.c | 33 +++++++++++++++++++++++++++++++++
 include/dm/uclass-id.h    |  1 +
 3 files changed, 35 insertions(+)
 create mode 100644 drivers/core/simple-bus.c

Comments

Simon Glass Oct. 23, 2014, 3:06 a.m. UTC | #1
On 4 October 2014 11:29, Simon Glass <sjg@chromium.org> wrote:
> Add a driver for the simple-bus nodes, which allows devices within these
> nodes to be bound.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  drivers/core/Makefile     |  1 +
>  drivers/core/simple-bus.c | 33 +++++++++++++++++++++++++++++++++
>  include/dm/uclass-id.h    |  1 +
>  3 files changed, 35 insertions(+)
>  create mode 100644 drivers/core/simple-bus.c
>

Applied to u-boot-dm/master.
diff mbox

Patch

diff --git a/drivers/core/Makefile b/drivers/core/Makefile
index c7905b1..151c239 100644
--- a/drivers/core/Makefile
+++ b/drivers/core/Makefile
@@ -5,3 +5,4 @@ 
 #
 
 obj-y := device.o lists.o root.o uclass.o util.o
+obj-$(CONFIG_OF_CONTROL) += simple-bus.o
diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c
new file mode 100644
index 0000000..3ea4d82
--- /dev/null
+++ b/drivers/core/simple-bus.c
@@ -0,0 +1,33 @@ 
+/*
+ * Copyright (c) 2014 Google, Inc
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <dm/root.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static int simple_bus_post_bind(struct udevice *dev)
+{
+	return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
+}
+
+UCLASS_DRIVER(simple_bus) = {
+	.id		= UCLASS_SIMPLE_BUS,
+	.name		= "simple_bus",
+	.post_bind	= simple_bus_post_bind,
+};
+
+static const struct udevice_id generic_simple_bus_ids[] = {
+	{ .compatible = "simple-bus" },
+	{ }
+};
+
+U_BOOT_DRIVER(simple_bus_drv) = {
+	.name	= "generic_simple_bus",
+	.id	= UCLASS_SIMPLE_BUS,
+	.of_match = generic_simple_bus_ids,
+};
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index 9800777..e3e9296 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -19,6 +19,7 @@  enum uclass_id {
 	UCLASS_TEST_FDT,
 	UCLASS_TEST_BUS,
 	UCLASS_SPI_EMUL,	/* sandbox SPI device emulator */
+	UCLASS_SIMPLE_BUS,
 
 	/* U-Boot uclasses start here */
 	UCLASS_GPIO,		/* Bank of general-purpose I/O pins */