summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDinesh Maniyam <[email protected]>2025-08-06 12:32:29 +0800
committerHeiko Schocher <[email protected]>2025-08-06 08:40:44 +0200
commitca4c92cbffff17ca071774feba849db1b6319220 (patch)
tree33861f56c2a7c19fce0f4b403845091d031b039f /drivers
parent03caa3769a7cc5fc5b13af5f7221e258df3c33b1 (diff)
drivers: i3c: Add i3c sandbox simple test.
Add s simple test for the I3C uclass in sandbox. Signed-off-by: Dinesh Maniyam <[email protected]>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i3c/Kconfig6
-rw-r--r--drivers/i3c/Makefile1
-rw-r--r--drivers/i3c/sandbox_i3c.c56
3 files changed, 63 insertions, 0 deletions
diff --git a/drivers/i3c/Kconfig b/drivers/i3c/Kconfig
index d4451057de0..d877a744353 100644
--- a/drivers/i3c/Kconfig
+++ b/drivers/i3c/Kconfig
@@ -14,6 +14,12 @@ menuconfig I3C
If you want I3C support, you should say Y here and also to the
specific driver for your bus adapter(s) below.
+config I3C_SANDBOX
+ bool "Enable support for the sandbox I3C"
+ help
+ This is a sandbox I3C used for testing. It provides 2 interfaces and
+ records the settings passed into it.
+
if I3C
source "drivers/i3c/master/Kconfig"
diff --git a/drivers/i3c/Makefile b/drivers/i3c/Makefile
index 5ddc4743c86..d38d2350c9a 100644
--- a/drivers/i3c/Makefile
+++ b/drivers/i3c/Makefile
@@ -2,3 +2,4 @@
obj-y := i3c-uclass.o device.o master.o
obj-y += master/
+obj-$(CONFIG_I3C_SANDBOX) += sandbox_i3c.o
diff --git a/drivers/i3c/sandbox_i3c.c b/drivers/i3c/sandbox_i3c.c
new file mode 100644
index 00000000000..e452e982566
--- /dev/null
+++ b/drivers/i3c/sandbox_i3c.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
+ */
+
+#include <dm.h>
+#include <errno.h>
+#include <i3c.h>
+#include <linux/i3c/master.h>
+
+struct sandbox_i3c_priv {
+ struct i3c_priv_xfer i3c_xfers;
+};
+
+static int sandbox_i3c_priv_read(struct udevice *dev, u32 dev_number,
+ u8 *buf, u32 buf_size)
+{
+ struct sandbox_i3c_priv *priv = dev_get_priv(dev);
+ struct i3c_priv_xfer i3c_xfers;
+
+ i3c_xfers = priv->i3c_xfers;
+ i3c_xfers.data.in = buf;
+ i3c_xfers.len = buf_size;
+
+ return 0;
+}
+
+static int sandbox_i3c_priv_write(struct udevice *dev, u32 dev_number,
+ u8 *buf, u32 buf_size)
+{
+ struct sandbox_i3c_priv *priv = dev_get_priv(dev);
+ struct i3c_priv_xfer i3c_xfers;
+
+ i3c_xfers = priv->i3c_xfers;
+ i3c_xfers.data.out = buf;
+ i3c_xfers.len = buf_size;
+
+ return 0;
+}
+
+static const struct dm_i3c_ops sandbox_i3c_ops = {
+ .read = sandbox_i3c_priv_read,
+ .write = sandbox_i3c_priv_write,
+};
+
+static const struct udevice_id sandbox_i3c_ids[] = {
+ { .compatible = "sandbox,i3c" },
+ { }
+};
+
+U_BOOT_DRIVER(i3c_sandbox) = {
+ .name = "i3c_sandbox",
+ .id = UCLASS_I3C,
+ .of_match = sandbox_i3c_ids,
+ .ops = &sandbox_i3c_ops,
+};