From 7fd7e2cf339ea2ec570f6dae1cdfaf8e066eb4af Mon Sep 17 00:00:00 2001 From: Ramon Fried Date: Mon, 2 Jul 2018 02:57:59 +0300 Subject: [PATCH] drivers: smem: sandbox Add Sandbox driver for SMEM. mostly stub operations. Signed-off-by: Ramon Fried Reviewed-by: Simon Glass --- arch/sandbox/dts/test.dts | 4 ++++ configs/sandbox64_defconfig | 2 ++ configs/sandbox_defconfig | 2 ++ drivers/smem/Kconfig | 9 +++++++++ drivers/smem/Makefile | 1 + drivers/smem/sandbox_smem.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 drivers/smem/sandbox_smem.c diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index 5752bf5..01e6bc0 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -382,6 +382,10 @@ remoteproc-name = "remoteproc-test-dev2"; }; + smem@0 { + compatible = "sandbox,smem"; + }; + spi@0 { #address-cells = <1>; #size-cells = <0>; diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 20a2ab3..1fa85a8 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -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 diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index 2fc84a1..47f6bfd 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -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 diff --git a/drivers/smem/Kconfig b/drivers/smem/Kconfig index 6cf5a4e..7169d0f 100644 --- a/drivers/smem/Kconfig +++ b/drivers/smem/Kconfig @@ -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 diff --git a/drivers/smem/Makefile b/drivers/smem/Makefile index 605b8fc..af3e9b5 100644 --- a/drivers/smem/Makefile +++ b/drivers/smem/Makefile @@ -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 index 0000000..7397e44 --- /dev/null +++ b/drivers/smem/sandbox_smem.c @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2018 Ramon Fried + */ + +#include +#include +#include +#include +#include + +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, +};