drivers: smem: sandbox
authorRamon Fried <ramon.fried@gmail.com>
Sun, 1 Jul 2018 23:57:59 +0000 (02:57 +0300)
committerTom Rini <trini@konsulko.com>
Thu, 19 Jul 2018 20:31:38 +0000 (16:31 -0400)
Add Sandbox driver for SMEM. mostly stub operations.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/dts/test.dts
configs/sandbox64_defconfig
configs/sandbox_defconfig
drivers/smem/Kconfig
drivers/smem/Makefile
drivers/smem/sandbox_smem.c [new file with mode: 0644]

index 5752bf547e667459a7c1f31408a42b09a18bc8cc..01e6bc03670ebf495db13d98566f41e1428a159c 100644 (file)
                remoteproc-name = "remoteproc-test-dev2";
        };
 
+       smem@0 {
+               compatible = "sandbox,smem";
+       };
+
        spi@0 {
                #address-cells = <1>;
                #size-cells = <0>;
index 20a2ab3ffb756b01d39d873d36c4a2a737e98064..1fa85a819c9f78874580deb7238b3a9d8abccf6a 100644 (file)
@@ -199,3 +199,5 @@ CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
 CONFIG_UT_ENV=y
 CONFIG_UT_OVERLAY=y
+CONFIG_SMEM=y
+CONFIG_SANDBOX_SMEM=y
index 2fc84a16c916d1101d0cf18b0485a69c0115f173..47f6bfd87ff02fc945529ed7b7a59111bbb2324d 100644 (file)
@@ -200,3 +200,5 @@ CONFIG_UT_TIME=y
 CONFIG_UT_DM=y
 CONFIG_UT_ENV=y
 CONFIG_UT_OVERLAY=y
+CONFIG_SMEM=y
+CONFIG_SANDBOX_SMEM=y
index 6cf5a4e61e345309e69c9d5cfad56e5fdaed9876..7169d0f205a53b1b459ed8710a7bdc2ed7b2a99d 100644 (file)
@@ -3,6 +3,15 @@ menuconfig SMEM
 
 if SMEM
 
+config SANDBOX_SMEM
+    bool "Sandbox Shared Memory Manager (SMEM)"
+    depends on SANDBOX && DM
+    help
+      enable SMEM support for sandbox. This is an emulation of a real SMEM
+      manager.
+      The sandbox driver allocates a shared memory from the heap and
+      initialzies it on start.
+
 config MSM_SMEM
     bool "Qualcomm Shared Memory Manager (SMEM)"
     depends on DM
index 605b8fc290a3bb81a933204dfe7f27526bf9084e..af3e9b50883c8d964da5a590b64833e9bce257a4 100644 (file)
@@ -2,5 +2,6 @@
 #
 # Makefile for the U-Boot SMEM interface drivers
 
+obj-$(CONFIG_SANDBOX_SMEM) += sandbox_smem.o
 obj-$(CONFIG_SMEM) += smem-uclass.o
 obj-$(CONFIG_MSM_SMEM) += msm_smem.o
diff --git a/drivers/smem/sandbox_smem.c b/drivers/smem/sandbox_smem.c
new file mode 100644 (file)
index 0000000..7397e44
--- /dev/null
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2018 Ramon Fried <ramon.fried@gmail.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <smem.h>
+#include <asm/test.h>
+
+static int sandbox_smem_alloc(unsigned int host,
+               unsigned int item, size_t size)
+{
+       return 0;
+}
+
+static void *sandbox_smem_get(unsigned int host,
+               unsigned int item, size_t *size)
+{
+       return NULL;
+}
+
+static int sandbox_smem_get_free_space(unsigned int host)
+{
+       return 0;
+}
+
+static const struct smem_ops sandbox_smem_ops = {
+       .alloc  = sandbox_smem_alloc,
+       .get    = sandbox_smem_get,
+       .get_free_space = sandbox_smem_get_free_space,
+};
+
+static const struct udevice_id sandbox_smem_ids[] = {
+       { .compatible = "sandbox,smem" },
+       { }
+};
+
+U_BOOT_DRIVER(smem_sandbox) = {
+       .name           = "smem_sandbox",
+       .id             = UCLASS_SMEM,
+       .of_match       = sandbox_smem_ids,
+       .ops            = &sandbox_smem_ops,
+};