[U-Boot] [PATCH v2 4/4] dm: test: Add "/firmware" node scan test

Rajan Vaja rajan.vaja at xilinx.com
Wed Sep 19 10:43:46 UTC 2018


Add a test which verifies that all subnodes under "/firmware"
nodes are scanned.

Signed-off-by: Rajan Vaja <rajan.vaja at xilinx.com>
---
Changes in v2:
  * New patch
---
 arch/sandbox/dts/test.dts           |  7 +++++++
 drivers/firmware/Makefile           |  1 +
 drivers/firmware/firmware-sandbox.c | 20 ++++++++++++++++++++
 test/dm/Makefile                    |  1 +
 test/dm/firmware.c                  | 22 ++++++++++++++++++++++
 5 files changed, 51 insertions(+)
 create mode 100644 drivers/firmware/firmware-sandbox.c
 create mode 100644 test/dm/firmware.c

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index 3668263..94c603a 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -630,6 +630,13 @@
 			};
 		};
 	};
+
+	firmware {
+		sandbox_firmware: sandbox-firmware {
+			compatible = "sandbox,firmware";
+		};
+	};
+
 };
 
 #include "sandbox_pmic.dtsi"
diff --git a/drivers/firmware/Makefile b/drivers/firmware/Makefile
index 1cdda14..6cb8358 100644
--- a/drivers/firmware/Makefile
+++ b/drivers/firmware/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_FIRMWARE)		+= firmware-uclass.o
 obj-$(CONFIG_ARM_PSCI_FW)	+= psci.o
 obj-$(CONFIG_TI_SCI_PROTOCOL)	+= ti_sci.o
+obj-$(CONFIG_SANDBOX)		+= firmware-sandbox.o
diff --git a/drivers/firmware/firmware-sandbox.c b/drivers/firmware/firmware-sandbox.c
new file mode 100644
index 0000000..d970d75
--- /dev/null
+++ b/drivers/firmware/firmware-sandbox.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * sandbox firmware driver
+ *
+ * Copyright (C) 2018 Xilinx, Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+
+static const struct udevice_id generic_sandbox_firmware_ids[] = {
+	{ .compatible = "sandbox,firmware" },
+	{ }
+};
+
+U_BOOT_DRIVER(sandbox_firmware) = {
+	.name = "sandbox_firmware",
+	.id = UCLASS_FIRMWARE,
+	.of_match = generic_sandbox_firmware_ids,
+};
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 3f5a634..3f54710 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -47,4 +47,5 @@ obj-$(CONFIG_WDT) += wdt.o
 obj-$(CONFIG_AXI) += axi.o
 obj-$(CONFIG_MISC) += misc.o
 obj-$(CONFIG_DM_SERIAL) += serial.o
+obj-$(CONFIG_FIRMWARE) += firmware.o
 endif
diff --git a/test/dm/firmware.c b/test/dm/firmware.c
new file mode 100644
index 0000000..60fdcbb
--- /dev/null
+++ b/test/dm/firmware.c
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Xilinx, Inc.
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <syscon.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+/* Base test of firmware probe */
+static int dm_test_firmware_probe(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+
+	ut_assertok(uclass_get_device_by_name(UCLASS_FIRMWARE,
+					      "sandbox-firmware", &dev));
+	return 0;
+}
+DM_TEST(dm_test_firmware_probe, DM_TESTF_SCAN_FDT);
-- 
2.7.4



More information about the U-Boot mailing list