From patchwork Thu Oct 6 13:23:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roger Quadros X-Patchwork-Id: 1686893 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=hV054McU; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MjscW076Jz1yqk for ; Fri, 7 Oct 2022 00:24:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 232C484DC3; Thu, 6 Oct 2022 15:24:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="hV054McU"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D58B984DAA; Thu, 6 Oct 2022 15:24:14 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id DDE7784C8D for ; Thu, 6 Oct 2022 15:24:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rogerq@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C142F61802; Thu, 6 Oct 2022 13:24:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A19A2C433B5; Thu, 6 Oct 2022 13:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665062648; bh=Buzm7NsrbyrQQmaGOWJ6VtSw2J/bQKMzpVKTEB6V/VI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hV054McU410ydCDuDFSYsXOXiDzS456zZBw0p2dhticWV3igAStlEIhE+uO5FcT1o f0eqczOUZg8w7ftH/vQy7OKQ0x9vHSwFmRMGU5WWh8InA3eETcp8S7t6yk+l6DpH08 Y1OgpcDP0OYc3KHV3Z165psZDymj9+1JyeQyjKG1qye7GJfxODIyx5D+trpHM5FFaw Y8ZVe6C2lsD6nZ9UOz0qoBo7l74V+o+pHIWQX+qbMRERe5AIcF7JVZ7bPMGv4+qbMA wZk4GdTWZujzXbJ+XyMLuYgI5aWnwVBGH8sOZBZpDbyrJsmw5xlKLL6znFY4VINVr4 k+kPK3Q56cfKQ== From: Roger Quadros To: trini@konsulko.com, sjg@chromium.org Cc: u-boot@lists.denx.de, praneeth@ti.com, kishon@ti.com, Roger Quadros Subject: [u-boot][PATCH v2 1/4] dm: memory: Introduce new uclass Date: Thu, 6 Oct 2022 16:23:57 +0300 Message-Id: <20221006132400.5628-2-rogerq@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221006132400.5628-1-rogerq@kernel.org> References: <20221006132400.5628-1-rogerq@kernel.org> 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 Introduce UCLASS_MEMORY for future Memory Controller device drivers. Signed-off-by: Roger Quadros Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 4 ++++ drivers/memory/Kconfig | 17 +++++++++++++++++ drivers/memory/Makefile | 2 ++ drivers/memory/memory-sandbox.c | 18 ++++++++++++++++++ drivers/memory/memory-uclass.c | 13 +++++++++++++ include/dm/uclass-id.h | 1 + test/dm/Makefile | 1 + test/dm/memory.c | 21 +++++++++++++++++++++ 8 files changed, 77 insertions(+) create mode 100644 drivers/memory/memory-sandbox.c create mode 100644 drivers/memory/memory-uclass.c create mode 100644 test/dm/memory.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 2761588f0d..d65b2d2dcb 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -926,6 +926,10 @@ }; }; + memory-controller { + compatible = "sandbox,memory"; + }; + misc-test { #address-cells = <1>; #size-cells = <1>; diff --git a/drivers/memory/Kconfig b/drivers/memory/Kconfig index 7271892763..632feb3aaa 100644 --- a/drivers/memory/Kconfig +++ b/drivers/memory/Kconfig @@ -4,6 +4,23 @@ menu "Memory Controller drivers" +config DM_MEMORY + bool "Enable Driver Model for Memory Controller drivers" + depends on DM + help + Enable driver model for Memory Controller devices. + These devices provide Memory bus interface to various devices like + SRAM, Ethernet adapters, FPGAs, etc. + For now this uclass has no methods yet. + +config SANDBOX_MEMORY + bool "Enable Sandbox Memory Controller driver" + depends on SANDBOX && DM_MEMORY + help + This is a driver model based Memory Controller driver for sandbox. + Currently it is a stub only, as there are no usable uclass methods + yet. + config STM32_FMC2_EBI bool "Support for FMC2 External Bus Interface on STM32MP SoCs" depends on ARCH_STM32MP diff --git a/drivers/memory/Makefile b/drivers/memory/Makefile index fec52efb60..1d68b2b296 100644 --- a/drivers/memory/Makefile +++ b/drivers/memory/Makefile @@ -1,3 +1,5 @@ +obj-$(CONFIG_DM_MEMORY) += memory-uclass.o +obj-$(CONFIG_SANDBOX_MEMORY) += memory-sandbox.o obj-$(CONFIG_STM32_FMC2_EBI) += stm32-fmc2-ebi.o obj-$(CONFIG_TI_AEMIF) += ti-aemif.o diff --git a/drivers/memory/memory-sandbox.c b/drivers/memory/memory-sandbox.c new file mode 100644 index 0000000000..f2ede50863 --- /dev/null +++ b/drivers/memory/memory-sandbox.c @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 + * Texas Instruments Incorporated, + */ + +#include + +static const struct udevice_id sandbox_memory_match[] = { + { .compatible = "sandbox,memory" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(sandbox_memory) = { + .name = "sandbox_memory", + .id = UCLASS_MEMORY, + .of_match = sandbox_memory_match, +}; diff --git a/drivers/memory/memory-uclass.c b/drivers/memory/memory-uclass.c new file mode 100644 index 0000000000..d6d37fe777 --- /dev/null +++ b/drivers/memory/memory-uclass.c @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 + * Texas Instruments Incorporated, + */ + +#include + +UCLASS_DRIVER(memory) = { + .name = "memory", + .id = UCLASS_MEMORY, + .post_bind = dm_scan_fdt_dev, +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index a432e43871..936a16c5d9 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -76,6 +76,7 @@ enum uclass_id { UCLASS_MASS_STORAGE, /* Mass storage device */ UCLASS_MDIO, /* MDIO bus */ UCLASS_MDIO_MUX, /* MDIO MUX/switch */ + UCLASS_MEMORY, /* Memory Controller device */ UCLASS_MISC, /* Miscellaneous device */ UCLASS_MMC, /* SD / MMC card or chip */ UCLASS_MOD_EXP, /* RSA Mod Exp device */ diff --git a/test/dm/Makefile b/test/dm/Makefile index 7543df8823..01275db2cd 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_MEMORY) += memory.o obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o obj-$(CONFIG_DM_I2C) += i2c.o obj-$(CONFIG_SOUND) += i2s.o diff --git a/test/dm/memory.c b/test/dm/memory.c new file mode 100644 index 0000000000..7d9500aa91 --- /dev/null +++ b/test/dm/memory.c @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2022 + * Texas Instruments Incorporated, + */ + +#include +#include +#include +#include + +static int dm_test_memory(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_first_device_err(UCLASS_MEMORY, &dev)); + + return 0; +} + +DM_TEST(dm_test_memory, UT_TESTF_SCAN_FDT);