diff options
author | Sebastian Reichel <sebastian.reichel@collabora.com> | 2021-07-15 17:39:59 +0200 |
---|---|---|
committer | Heiko Schocher <hs@denx.de> | 2021-08-22 10:52:53 +0200 |
commit | 2aefa6e3f2ab621483ca645b16c7bf8cb9334fa3 (patch) | |
tree | ce32ac1a9ee05266489dd58f9ff0ade8852e51cb /test/dm | |
parent | 79d389a54891a67269bfa366f044a2079409e499 (diff) | |
download | u-boot-2aefa6e3f2ab621483ca645b16c7bf8cb9334fa3.tar.gz u-boot-2aefa6e3f2ab621483ca645b16c7bf8cb9334fa3.tar.bz2 u-boot-2aefa6e3f2ab621483ca645b16c7bf8cb9334fa3.zip |
i2c: add dm_i2c_reg_clrset
Add function to apply a bitmask to an i2c register, so
that specific bits can be cleared and/or set.
Suggested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/dm')
-rw-r--r-- | test/dm/i2c.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/dm/i2c.c b/test/dm/i2c.c index d74f5f9fbc..74b2097195 100644 --- a/test/dm/i2c.c +++ b/test/dm/i2c.c @@ -304,3 +304,32 @@ static int dm_test_i2c_addr_offset(struct unit_test_state *uts) } DM_TEST(dm_test_i2c_addr_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); + +static int dm_test_i2c_reg_clrset(struct unit_test_state *uts) +{ + struct udevice *eeprom; + struct udevice *dev; + u8 buf[5]; + + ut_assertok(i2c_get_chip_for_busnum(busnum, chip, 1, &dev)); + + /* Do a transfer so we can find the emulator */ + ut_assertok(dm_i2c_read(dev, 0, buf, 5)); + ut_assertok(uclass_first_device(UCLASS_I2C_EMUL, &eeprom)); + + /* Dummy data for the test */ + ut_assertok(dm_i2c_write(dev, 0, "\xff\x00\xff\x00\x10", 5)); + + /* Do some clrset tests */ + ut_assertok(dm_i2c_reg_clrset(dev, 0, 0xff, 0x10)); + ut_assertok(dm_i2c_reg_clrset(dev, 1, 0x00, 0x11)); + ut_assertok(dm_i2c_reg_clrset(dev, 2, 0xed, 0x00)); + ut_assertok(dm_i2c_reg_clrset(dev, 3, 0xff, 0x13)); + ut_assertok(dm_i2c_reg_clrset(dev, 4, 0x00, 0x14)); + + ut_assertok(dm_i2c_read(dev, 0, buf, 5)); + ut_asserteq_mem("\x10\x11\x12\x13\x14", buf, sizeof(buf)); + + return 0; +} +DM_TEST(dm_test_i2c_reg_clrset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT); |