Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7A8DC433FE for ; Fri, 30 Sep 2022 12:05:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E744884D22; Fri, 30 Sep 2022 14:05:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lespocky.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B5B3384CE4; Fri, 30 Sep 2022 14:05:21 +0200 (CEST) Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 405F384D22 for ; Fri, 30 Sep 2022 14:05:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=lespocky.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=alex@home.lespocky.de Received: from methusalix.internal.home.lespocky.de ([92.117.57.53]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1M3UEW-1odgWu0gks-000Zbq; Fri, 30 Sep 2022 14:04:58 +0200 Received: from [192.168.243.196] (helo=buffy.home.lespocky.de) by methusalix.internal.home.lespocky.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oeElA-0000AF-4E; Fri, 30 Sep 2022 14:04:56 +0200 Received: (nullmailer pid 42370 invoked by uid 2001); Fri, 30 Sep 2022 12:04:51 -0000 From: Alexander Dahl To: u-boot@lists.denx.de Cc: Simon Glass , Michal Simek , Alexander Dahl Subject: [PATCH v2 1/1] dm: fpga: Introduce new uclass Date: Fri, 30 Sep 2022 14:04:30 +0200 Message-Id: <20220930120430.42307-2-post@lespocky.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220930120430.42307-1-post@lespocky.de> References: <20220930120430.42307-1-post@lespocky.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scan-Signature: 3918240c492f27c9e5cce722baaeb3bb X-Provags-ID: V03:K1:1djgvBTxR6vwdQc1SoVTWUxUuzATjb3OC2sOmmU68sZC5rBuHfc JVotlFCFe8b8hV64V0KzYMoDxcklefdyY01/oWTSsAhIK7DRC+ZJly+MzepZqZjbhjdjADW 8bOAxOqF/hlk6uiNfOAeId5iMd6U/jelSjGHUMEemRaZkhJde0buh7TSl+gzZmqLKzIquZ3 ERjN+vqISV3F42gO90AgQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:sXxaEJujEGY=:niuFsuSy+SPnSVlsFYEW3W y4UY4oHhJzk4W4pcpUUt14dS16mj8KAbpqyTT+5YMT5jG3FvpGIKMyGx+mbK0jduNz3zB9g8r wbUBD4/3u5w8whQOHXO6EU3+1iGUb1tMX+oW6olyND+WziHqzOSru+q2zYJp7VTohvDGYK2UU RI9dwaCusV2J63quHfkV2w3FgmtyRtNBjFp8HBUouA5REXA/2h04UQUAVBrLcfWyFeWPylh03 Dj728XwCIKF0WLj57M3IjZTzOUyni7F6H4SF5bxEZ2GzIILJCpCf/6dnHGvWSgB4z9fT8Atwo HFGKxyB5qkOVDpC4JNhPEr+qon87eQGjE6isk0fJWZoObL4xOUbCIhGP/d3hZjQM4vzZih+Sx WqDLukjvJl3HUBM3V6C3JN6aLukF3FQA0qVpGhfQmrQog+Mlle+ktJ+OGZJw0gzhKlybifiws hgb2D6KoXmtAgvp2b9bpoqSYOePJEempkeDS5gDzHYZ/6dgJHOf+imUKzQyxMb8/Cnrlehle5 sW5O/OgfgggCTL/gfww0He3sb7F+ifvxqp/FmOUB9w5FfoENOtGTe+8fvuGglY1nW7rPZJZoA 9IStsyoLNFOsmX8zN35MqCEfzmjHNtfs/JgK+Pd/UA7DXQm7ViCBuHeiXnkEEFGdBEXd3fkoA f4AFMUxQ6S6FBRgACw4NW333dfRX83PNr2oLQ6XvNYDo2qNEzXN9hDFamLDFNRiD7HYtbj2b6 7cg1pVqqeoq/MTKlBWizbBt85zx2MCdLrXfyLSs9MIJqIa29gmIEWJfV+/RAGiZaQYqoeVzC2 n3b1PO4X9Cdql9H3GaVw00QrpVKvg== X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean For future DM based FPGA drivers and for now to have a meaningful logging class for old FPGA drivers. Suggested-by: Michal Simek Suggested-by: Simon Glass Signed-off-by: Alexander Dahl --- Notes: RFC -> v2: - Added/Improved Kconfig help texts - Use `uclass_first_device_err()` in test - Add compatibles match list to sandbox driver - Add 'test/dm/fpga.c' to MAINTAINERS MAINTAINERS | 1 + arch/sandbox/dts/test.dts | 4 ++++ drivers/fpga/Kconfig | 19 +++++++++++++++++++ drivers/fpga/Makefile | 3 +++ drivers/fpga/fpga-uclass.c | 11 +++++++++++ drivers/fpga/sandbox.c | 17 +++++++++++++++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/fpga.c | 20 ++++++++++++++++++++ 9 files changed, 77 insertions(+) create mode 100644 drivers/fpga/fpga-uclass.c create mode 100644 drivers/fpga/sandbox.c create mode 100644 test/dm/fpga.c diff --git a/MAINTAINERS b/MAINTAINERS index 83346183ee..12a7c62a23 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -918,6 +918,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 diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 2761588f0d..3b9cc8cd7c 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -650,6 +650,10 @@ }; }; + fpga { + compatible = "sandbox,fpga"; + }; + pinctrl-gpio { compatible = "sandbox,pinctrl-gpio"; diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig index e07a9cf80e..e2fd16e6d2 100644 --- a/drivers/fpga/Kconfig +++ b/drivers/fpga/Kconfig @@ -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 diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile index 83243fb107..610c168fc3 100644 --- a/drivers/fpga/Makefile +++ b/drivers/fpga/Makefile @@ -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 index 0000000000..4278ec28e5 --- /dev/null +++ b/drivers/fpga/fpga-uclass.c @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include + +UCLASS_DRIVER(fpga) = { + .name = "fpga", + .id = UCLASS_FPGA, +}; diff --git a/drivers/fpga/sandbox.c b/drivers/fpga/sandbox.c new file mode 100644 index 0000000000..f17a822179 --- /dev/null +++ b/drivers/fpga/sandbox.c @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include + +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, +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index a432e43871..c2b15881ba 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -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 */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 7543df8823..666c85f10a 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -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 index 0000000000..8bb3535853 --- /dev/null +++ b/test/dm/fpga.c @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2022 Alexander Dahl + */ + +#include +#include +#include +#include + +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); -- 2.30.2