]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: memory: Introduce new uclass
authorRoger Quadros <rogerq@kernel.org>
Thu, 20 Oct 2022 13:30:46 +0000 (16:30 +0300)
committerTom Rini <trini@konsulko.com>
Wed, 26 Oct 2022 19:21:11 +0000 (15:21 -0400)
Introduce UCLASS_MEMORY for future Memory Controller
device drivers.

Signed-off-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
drivers/memory/Kconfig
drivers/memory/Makefile
drivers/memory/memory-sandbox.c [new file with mode: 0644]
drivers/memory/memory-uclass.c [new file with mode: 0644]
include/dm/uclass-id.h
test/dm/Makefile
test/dm/memory.c [new file with mode: 0644]

index 70e27cd6a8db24fbd4c2cacd30e40e78a4042b7c..db72c64b1edbcad526efb7dd909443e95919e1d4 100644 (file)
                };
        };
 
+       memory-controller {
+               compatible = "sandbox,memory";
+       };
+
        misc-test {
                #address-cells = <1>;
                #size-cells = <1>;
index 7271892763b5e75afc1ada20b140bfba3aae615c..c621f5bba301e335d2f95d2eca4845a9e06b9888 100644 (file)
@@ -4,6 +4,23 @@
 
 menu "Memory Controller drivers"
 
+config 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 && 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
index fec52efb60e582b53706dc835b8c16b88b528414..b27f7018654f3f712e5d4725d9e56a73565fceb7 100644 (file)
@@ -1,3 +1,5 @@
 
+obj-$(CONFIG_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 (file)
index 0000000..f2ede50
--- /dev/null
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ *     Texas Instruments Incorporated, <www.ti.com>
+ */
+
+#include <dm.h>
+
+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 (file)
index 0000000..d6d37fe
--- /dev/null
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ *     Texas Instruments Incorporated, <www.ti.com>
+ */
+
+#include <dm.h>
+
+UCLASS_DRIVER(memory) = {
+       .name = "memory",
+       .id = UCLASS_MEMORY,
+       .post_bind = dm_scan_fdt_dev,
+};
index c2b15881ba72743cf9157e90e567569038fda9a4..4b2c3234525b9226bf4f0b05295a00be5738869a 100644 (file)
@@ -77,6 +77,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 */
index 499e76980d9fa2f5ba73d5c547d2e511533e71b7..fd7d310e41160c970b41844d0e791783ee0a7a89 100644 (file)
@@ -57,6 +57,7 @@ obj-$(CONFIG_LED) += led.o
 obj-$(CONFIG_DM_MAILBOX) += mailbox.o
 obj-$(CONFIG_DM_MDIO) += mdio.o
 obj-$(CONFIG_DM_MDIO_MUX) += mdio_mux.o
+obj-$(CONFIG_MEMORY) += memory.o
 obj-$(CONFIG_MISC) += misc.o
 obj-$(CONFIG_DM_MMC) += mmc.o
 obj-$(CONFIG_CMD_MUX) += mux-cmd.o
diff --git a/test/dm/memory.c b/test/dm/memory.c
new file mode 100644 (file)
index 0000000..7d9500a
--- /dev/null
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2022
+ *     Texas Instruments Incorporated, <www.ti.com>
+ */
+
+#include <dm.h>
+#include <dm/test.h>
+#include <test/test.h>
+#include <test/ut.h>
+
+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);