]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
dm: test: Add a test for the system controller uclass
authorSimon Glass <sjg@chromium.org>
Mon, 6 Jul 2015 18:54:35 +0000 (12:54 -0600)
committerLothar Waßmann <LW@KARO-electronics.de>
Wed, 9 Sep 2015 11:48:55 +0000 (13:48 +0200)
Add a test to confirm that we can access system controllers and find their
driver data.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
arch/sandbox/include/asm/test.h
configs/sandbox_defconfig
drivers/misc/Makefile
drivers/misc/syscon_sandbox.c [new file with mode: 0644]
test/dm/Makefile
test/dm/syscon.c [new file with mode: 0644]

index 4b9861835e145fe1ab26af7cc985081cbbe70ba3..51611009aea0ecc7b564cf48389b72973cfa8cad 100644 (file)
                };
        };
 
+       syscon@0 {
+               compatible = "sandbox,syscon0";
+               reg = <0x10>;
+       };
+
+       syscon@1 {
+               compatible = "sandbox,syscon1";
+               reg = <0x20>;
+       };
+
        uart0: serial {
                compatible = "sandbox,serial";
                u-boot,dm-pre-reloc;
index 28e9c09c064288acc6e0c43fd0b8f8643389b04e..d3c7851bb50c427f2296face2a38e1701d35f842 100644 (file)
@@ -28,6 +28,14 @@ enum {
        PERIPH_ID_COUNT,
 };
 
+/* System controller driver data */
+enum {
+       SYSCON0         = 32,
+       SYSCON1,
+
+       SYSCON_COUNT
+};
+
 /**
  * sandbox_i2c_set_test_mode() - set test mode for running unit tests
  *
index 56d55ac5b838cf861576edace11b0b255a6b926c..553574682dcd165d06e892e321fda110725f0554 100644 (file)
@@ -51,3 +51,4 @@ CONFIG_RAM=y
 CONFIG_DM_MMC=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
+CONFIG_SYSCON=y
index 629de25a428b14cb0686bb598cd1f52aa1f5f1d2..5218b91c0baf8a957b11aaca86f5403fb25f4e82 100644 (file)
@@ -29,6 +29,7 @@ endif
 obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o
 obj-$(CONFIG_STATUS_LED) += status_led.o
 obj-$(CONFIG_SANDBOX) += swap_case.o
+obj-$(CONFIG_SANDBOX) += syscon_sandbox.o
 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
diff --git a/drivers/misc/syscon_sandbox.c b/drivers/misc/syscon_sandbox.c
new file mode 100644 (file)
index 0000000..ccfab3e
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ * Written by Simon Glass <sjg@chromium.org>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <syscon.h>
+#include <asm/test.h>
+#include <dm/lists.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static const struct udevice_id sandbox_syscon_ids[] = {
+       { .compatible = "sandbox,syscon0", .data = SYSCON0 },
+       { .compatible = "sandbox,syscon1", .data = SYSCON1 },
+       { }
+};
+
+U_BOOT_DRIVER(sandbox_syscon) = {
+       .name   = "sandbox_syscon",
+       .id     = UCLASS_SYSCON,
+       .of_match = sandbox_syscon_ids,
+};
index 6242a0265a01071fc35f1a01736454dfaed415b3..99cd21fd063c00bf30a568c1dff9b83520b9c7c0 100644 (file)
@@ -27,6 +27,7 @@ obj-$(CONFIG_RESET) += reset.o
 obj-$(CONFIG_DM_RTC) += rtc.o
 obj-$(CONFIG_DM_SPI_FLASH) += sf.o
 obj-$(CONFIG_DM_SPI) += spi.o
+obj-y += syscon.o
 obj-$(CONFIG_DM_USB) += usb.o
 obj-$(CONFIG_DM_PMIC) += pmic.o
 obj-$(CONFIG_DM_REGULATOR) += regulator.o
diff --git a/test/dm/syscon.c b/test/dm/syscon.c
new file mode 100644 (file)
index 0000000..3642481
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <syscon.h>
+#include <asm/test.h>
+#include <dm/test.h>
+#include <test/ut.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Base test of system controllers */
+static int dm_test_syscon_base(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       ut_assertok(uclass_get_device(UCLASS_SYSCON, 0, &dev));
+       ut_asserteq(SYSCON0, dev->driver_data);
+
+       ut_assertok(uclass_get_device(UCLASS_SYSCON, 1, &dev));
+       ut_asserteq(SYSCON1, dev->driver_data);
+
+       ut_asserteq(-ENODEV, uclass_get_device(UCLASS_SYSCON, 2, &dev));
+
+       return 0;
+}
+DM_TEST(dm_test_syscon_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT);