]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: fpga: Introduce new uclass
authorAlexander Dahl <post@lespocky.de>
Fri, 30 Sep 2022 12:04:30 +0000 (14:04 +0200)
committerMichal Simek <michal.simek@amd.com>
Wed, 5 Oct 2022 06:43:53 +0000 (08:43 +0200)
For future DM based FPGA drivers and for now to have a meaningful
logging class for old FPGA drivers.

Suggested-by: Michal Simek <michal.simek@amd.com>
Suggested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Alexander Dahl <post@lespocky.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/r/20220930120430.42307-2-post@lespocky.de
Signed-off-by: Michal Simek <michal.simek@amd.com>
MAINTAINERS
arch/sandbox/dts/test.dts
drivers/fpga/Kconfig
drivers/fpga/Makefile
drivers/fpga/fpga-uclass.c [new file with mode: 0644]
drivers/fpga/sandbox.c [new file with mode: 0644]
include/dm/uclass-id.h
test/dm/Makefile
test/dm/fpga.c [new file with mode: 0644]

index b4b185aacd433ff1d504e10356d5162bdfed0ba8..c4ed454e06548fd2f26c4cc4f1aeb78e6a6e709a 100644 (file)
@@ -945,6 +945,7 @@ T:  git https://source.denx.de/u-boot/custodians/u-boot-microblaze.git
 F:     drivers/fpga/
 F:     cmd/fpga.c
 F:     include/fpga.h
+F:     test/dm/fpga.c
 
 FLATTENED DEVICE TREE
 M:     Simon Glass <sjg@chromium.org>
index 4ee471238eebe99c7c31e7b26c4931b69cea8363..a7b49f315bebea9ed71e157de7cba6007f1a4c16 100644 (file)
                };
        };
 
+       fpga {
+               compatible = "sandbox,fpga";
+       };
+
        pinctrl-gpio {
                compatible = "sandbox,pinctrl-gpio";
 
index e07a9cf80ea43db8bdf1bd052943ea898bf71e2a..e2fd16e6d25f431c1f5f4d5e91c57ce4322b4f33 100644 (file)
@@ -118,4 +118,23 @@ config SPL_FPGA_LOAD_SECURE
          Enables the fpga loads() functions that are used to load secure
          (authenticated or encrypted or both) bitstreams on to FPGA.
 
+config DM_FPGA
+       bool "Enable Driver Model for FPGA drivers"
+       depends on DM
+       select FPGA
+       help
+         Enable driver model for Field-Programmable Gate Array (FPGA) devices.
+         The devices cover a wide range of applications and are configured at
+         runtime by loading a bitstream into the FPGA device.
+         Loading a bitstream from any kind of storage is the main task of the
+         FPGA drivers.
+         For now this uclass has no methods yet.
+
+config SANDBOX_FPGA
+       bool "Enable sandbox FPGA driver"
+       depends on SANDBOX && DM_FPGA
+       help
+         This is a driver model based FPGA driver for sandbox.
+         Currently it is a stub only, as there are no usable uclass methods yet.
+
 endmenu
index 83243fb1070f8a7279d854638c3fa47ce57926f6..610c168fc35c638c56a37ead31665d3382fa8772 100644 (file)
@@ -4,6 +4,9 @@
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
 obj-y += fpga.o
+obj-$(CONFIG_DM_FPGA) += fpga-uclass.o
+obj-$(CONFIG_SANDBOX_FPGA) += sandbox.o
+
 obj-$(CONFIG_FPGA_SPARTAN2) += spartan2.o
 obj-$(CONFIG_FPGA_SPARTAN3) += spartan3.o
 obj-$(CONFIG_FPGA_VERSALPL) += versalpl.o
diff --git a/drivers/fpga/fpga-uclass.c b/drivers/fpga/fpga-uclass.c
new file mode 100644 (file)
index 0000000..4278ec2
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Alexander Dahl <post@lespocky.de>
+ */
+
+#include <dm.h>
+
+UCLASS_DRIVER(fpga) = {
+       .name   = "fpga",
+       .id     = UCLASS_FPGA,
+};
diff --git a/drivers/fpga/sandbox.c b/drivers/fpga/sandbox.c
new file mode 100644 (file)
index 0000000..f17a822
--- /dev/null
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Alexander Dahl <post@lespocky.de>
+ */
+
+#include <dm.h>
+
+static const struct udevice_id sandbox_fpga_match[] = {
+       { .compatible = "sandbox,fpga" },
+       { /* sentinel */ }
+};
+
+U_BOOT_DRIVER(sandbox_fpga) = {
+       .name   = "sandbox_fpga",
+       .id     = UCLASS_FPGA,
+       .of_match = sandbox_fpga_match,
+};
index a432e438716736aa595997ad268ca4cd34a2acfe..c2b15881ba72743cf9157e90e567569038fda9a4 100644 (file)
@@ -56,6 +56,7 @@ enum uclass_id {
        UCLASS_ETH,             /* Ethernet device */
        UCLASS_ETH_PHY,         /* Ethernet PHY device */
        UCLASS_FIRMWARE,        /* Firmware */
+       UCLASS_FPGA,            /* FPGA device */
        UCLASS_FUZZING_ENGINE,  /* Fuzzing engine */
        UCLASS_FS_FIRMWARE_LOADER,              /* Generic loader */
        UCLASS_GPIO,            /* Bank of general-purpose I/O pins */
index 5178daa7cf0dae1d871091f5e0096aa24feafd5b..499e76980d9fa2f5ba73d5c547d2e511533e71b7 100644 (file)
@@ -47,6 +47,7 @@ ifneq ($(CONFIG_EFI_PARTITION),)
 obj-$(CONFIG_FASTBOOT_FLASH_MMC) += fastboot.o
 endif
 obj-$(CONFIG_FIRMWARE) += firmware.o
+obj-$(CONFIG_DM_FPGA) += fpga.o
 obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o
 obj-$(CONFIG_DM_I2C) += i2c.o
 obj-$(CONFIG_SOUND) += i2s.o
diff --git a/test/dm/fpga.c b/test/dm/fpga.c
new file mode 100644 (file)
index 0000000..8bb3535
--- /dev/null
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2022 Alexander Dahl <post@lespocky.de>
+ */
+
+#include <dm.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+static int dm_test_fpga(struct unit_test_state *uts)
+{
+       struct udevice *dev;
+
+       ut_assertok(uclass_first_device_err(UCLASS_FPGA, &dev));
+
+       return 0;
+}
+
+DM_TEST(dm_test_fpga, UT_TESTF_SCAN_FDT);