"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

drivers: i3c: Add i3c sandbox simple test.

Add s simple test for the I3C uclass in sandbox.

Signed-off-by: Dinesh Maniyam <dinesh.maniyam@altera.com>

authored by

Dinesh Maniyam and committed by
Heiko Schocher
ca4c92cb 03caa376

+106
+8
arch/sandbox/dts/test.dts
··· 936 936 }; 937 937 }; 938 938 939 + i3c0 { 940 + compatible = "sandbox,i3c"; 941 + }; 942 + 943 + i3c1 { 944 + compatible = "sandbox,i3c"; 945 + }; 946 + 939 947 bootcount@0 { 940 948 compatible = "u-boot,bootcount-rtc"; 941 949 rtc = <&rtc_1>;
+6
drivers/i3c/Kconfig
··· 14 14 If you want I3C support, you should say Y here and also to the 15 15 specific driver for your bus adapter(s) below. 16 16 17 + config I3C_SANDBOX 18 + bool "Enable support for the sandbox I3C" 19 + help 20 + This is a sandbox I3C used for testing. It provides 2 interfaces and 21 + records the settings passed into it. 22 + 17 23 if I3C 18 24 19 25 source "drivers/i3c/master/Kconfig"
+1
drivers/i3c/Makefile
··· 2 2 3 3 obj-y := i3c-uclass.o device.o master.o 4 4 obj-y += master/ 5 + obj-$(CONFIG_I3C_SANDBOX) += sandbox_i3c.o
+56
drivers/i3c/sandbox_i3c.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2025 Altera Corporation <www.altera.com> 4 + */ 5 + 6 + #include <dm.h> 7 + #include <errno.h> 8 + #include <i3c.h> 9 + #include <linux/i3c/master.h> 10 + 11 + struct sandbox_i3c_priv { 12 + struct i3c_priv_xfer i3c_xfers; 13 + }; 14 + 15 + static int sandbox_i3c_priv_read(struct udevice *dev, u32 dev_number, 16 + u8 *buf, u32 buf_size) 17 + { 18 + struct sandbox_i3c_priv *priv = dev_get_priv(dev); 19 + struct i3c_priv_xfer i3c_xfers; 20 + 21 + i3c_xfers = priv->i3c_xfers; 22 + i3c_xfers.data.in = buf; 23 + i3c_xfers.len = buf_size; 24 + 25 + return 0; 26 + } 27 + 28 + static int sandbox_i3c_priv_write(struct udevice *dev, u32 dev_number, 29 + u8 *buf, u32 buf_size) 30 + { 31 + struct sandbox_i3c_priv *priv = dev_get_priv(dev); 32 + struct i3c_priv_xfer i3c_xfers; 33 + 34 + i3c_xfers = priv->i3c_xfers; 35 + i3c_xfers.data.out = buf; 36 + i3c_xfers.len = buf_size; 37 + 38 + return 0; 39 + } 40 + 41 + static const struct dm_i3c_ops sandbox_i3c_ops = { 42 + .read = sandbox_i3c_priv_read, 43 + .write = sandbox_i3c_priv_write, 44 + }; 45 + 46 + static const struct udevice_id sandbox_i3c_ids[] = { 47 + { .compatible = "sandbox,i3c" }, 48 + { } 49 + }; 50 + 51 + U_BOOT_DRIVER(i3c_sandbox) = { 52 + .name = "i3c_sandbox", 53 + .id = UCLASS_I3C, 54 + .of_match = sandbox_i3c_ids, 55 + .ops = &sandbox_i3c_ops, 56 + };
+1
test/dm/Makefile
··· 58 58 obj-$(CONFIG_SANDBOX) += host.o 59 59 obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o 60 60 obj-$(CONFIG_DM_I2C) += i2c.o 61 + obj-$(CONFIG_I3C) += i3c.o 61 62 obj-$(CONFIG_SOUND) += i2s.o 62 63 obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o 63 64 obj-$(CONFIG_IOMMU) += iommu.o
+34
test/dm/i3c.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2025 Altera Corporation <www.altera.com> 4 + */ 5 + 6 + #include <dm.h> 7 + #include <i3c.h> 8 + #include <dm/test.h> 9 + #include <test/ut.h> 10 + 11 + DECLARE_GLOBAL_DATA_PTR; 12 + 13 + /* Basic test of the i3c uclass */ 14 + static int dm_test_i3c_base(struct unit_test_state *uts) 15 + { 16 + struct udevice *dev; 17 + 18 + ut_assertok(uclass_get_device(UCLASS_I3C, 0, &dev)); 19 + ut_assertok(dm_i3c_read(dev, 0, NULL, 1)); 20 + ut_assertok(dm_i3c_read(dev, 0, NULL, 4)); 21 + ut_assertok(dm_i3c_write(dev, 0, "AABB", 2)); 22 + ut_assertok(dm_i3c_write(dev, 0, "AABBCCDD", 4)); 23 + 24 + ut_assertok(uclass_get_device(UCLASS_I3C, 1, &dev)); 25 + ut_assertok(dm_i3c_read(dev, 1, NULL, 1)); 26 + ut_assertok(dm_i3c_read(dev, 1, NULL, 4)); 27 + ut_assertok(dm_i3c_write(dev, 1, "AABB", 2)); 28 + ut_assertok(dm_i3c_write(dev, 1, "AABBCCDD", 4)); 29 + 30 + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_I3C, 2, &dev)); 31 + 32 + return 0; 33 + } 34 + DM_TEST(dm_test_i3c_base, UTF_SCAN_PDATA | UTF_SCAN_FDT);