]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: Add tests for the extcon
authorSvyatoslav Ryhel <clamor95@gmail.com>
Tue, 25 Apr 2023 07:57:21 +0000 (10:57 +0300)
committerTom Rini <trini@konsulko.com>
Tue, 2 May 2023 18:23:58 +0000 (14:23 -0400)
Provide tests to the simple extcon device.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
drivers/extcon/Kconfig
drivers/extcon/Makefile
drivers/extcon/extcon-sandbox.c [new file with mode: 0644]
test/dm/Makefile
test/dm/extcon.c [new file with mode: 0644]

index bcdea0b8e7b282ec8487183df8684906df4657d4..453e53db71a8877e68f7bde0970142ba2b1fd12a 100644 (file)
                lba_shift = <9>;
                lba = <2048>;
        };
+
+       extcon {
+               compatible = "sandbox,extcon";
+       };
 };
 
 #include "sandbox_pmic.dtsi"
index 8a50250d21c14dc5fa248ba843ec136225c9afb1..6fd3d2b97b14edf5c318553afda0265322ca4563 100644 (file)
@@ -12,4 +12,11 @@ config EXTCON
          and to host USB ports. Many of 30-pin connectors including PDMI
          are also good examples.
 
+config EXTCON_SANDBOX
+       bool "Sandbox extcon"
+       depends on EXTCON
+       help
+         Enable extcon support for sandbox. This is an emulation of a real
+         extcon. Currectly all configuration is done in the probe.
+
 endmenu
index 2510e91c07c388a1f43289891075d1f7f5561ad4..c4223d97d18809d77a2ec87f789bc81dd842bb2e 100644 (file)
@@ -3,3 +3,4 @@
 # Copyright (C) 2023 Svyatoslav Ryhel <clamor95@gmail.com>
 
 obj-$(CONFIG_EXTCON) += extcon-uclass.o
+obj-$(CONFIG_EXTCON_SANDBOX) += extcon-sandbox.o
diff --git a/drivers/extcon/extcon-sandbox.c b/drivers/extcon/extcon-sandbox.c
new file mode 100644 (file)
index 0000000..ab6a6c1
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <dm.h>
+
+static const struct udevice_id sandbox_extcon_ids[] = {
+       { .compatible = "sandbox,extcon" },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(extcon_sandbox) = {
+       .name           = "extcon_sandbox",
+       .id             = UCLASS_EXTCON,
+       .of_match       = sandbox_extcon_ids,
+};
index c8534b5cfa899aea9d65670e7a46f66f846c4cda..3799b1ae8fd921541f8338d812fef88bf90bc3d7 100644 (file)
@@ -49,6 +49,7 @@ obj-$(CONFIG_DM_DSA) += dsa.o
 obj-$(CONFIG_ECDSA_VERIFY) += ecdsa.o
 obj-$(CONFIG_EFI_MEDIA_SANDBOX) += efi_media.o
 obj-$(CONFIG_DM_ETH) += eth.o
+obj-$(CONFIG_EXTCON) += extcon.o
 ifneq ($(CONFIG_EFI_PARTITION),)
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
 endif
diff --git a/test/dm/extcon.c b/test/dm/extcon.c
new file mode 100644 (file)
index 0000000..6a4e22b
--- /dev/null
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2023 Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <dm.h>
+#include <dm/test.h>
+#include <extcon.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static int dm_test_extcon(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       ut_assertok(uclass_get_device_by_name(UCLASS_EXTCON, "extcon", &dev));
+
+       return 0;
+}
+
+DM_TEST(dm_test_extcon, UT_TESTF_SCAN_FDT);