summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2015-04-20 12:37:15 -0600
committerSimon Glass <sjg@chromium.org>2015-05-05 20:58:19 -0600
commit182bf92d19cf007c2d6b9a264107d6996ae9014f (patch)
treed73c8abc54efc11cf05e39f891dd57560448c8d9 /test
parentba3864f8037f58dd1f46cad3b76adc0a84bd33b3 (diff)
downloadblackbird-obmc-uboot-182bf92d19cf007c2d6b9a264107d6996ae9014f.tar.gz
blackbird-obmc-uboot-182bf92d19cf007c2d6b9a264107d6996ae9014f.zip
dm: i2c: Add an explicit test mode to the sandbox I2C driver
At present this driver has a few test features. They are needed for running the driver model unit tests but are confusing and unnecessary if using sandbox at the command line. Add a flag to enable the test mode, and don't enable it by default. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/dm/i2c.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/dm/i2c.c b/test/dm/i2c.c
index 541b73b803..c5939a165e 100644
--- a/test/dm/i2c.c
+++ b/test/dm/i2c.c
@@ -66,6 +66,9 @@ static int dm_test_i2c_speed(struct dm_test_state *dms)
uint8_t buf[5];
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
+
+ /* Use test mode so we create the required errors for invalid speeds */
+ sandbox_i2c_set_test_mode(bus, true);
ut_assertok(i2c_get_chip(bus, chip, 1, &dev));
ut_assertok(dm_i2c_set_bus_speed(bus, 100000));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
@@ -73,6 +76,7 @@ static int dm_test_i2c_speed(struct dm_test_state *dms)
ut_asserteq(400000, dm_i2c_get_bus_speed(bus));
ut_assertok(dm_i2c_read(dev, 0, buf, 5));
ut_asserteq(-EINVAL, dm_i2c_write(dev, 0, buf, 5));
+ sandbox_i2c_set_test_mode(bus, false);
return 0;
}
@@ -100,7 +104,11 @@ static int dm_test_i2c_probe_empty(struct dm_test_state *dms)
struct udevice *bus, *dev;
ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus));
+
+ /* Use test mode so that this chip address will always probe */
+ sandbox_i2c_set_test_mode(bus, true);
ut_assertok(dm_i2c_probe(bus, SANDBOX_I2C_TEST_ADDR, 0, &dev));
+ sandbox_i2c_set_test_mode(bus, false);
return 0;
}
OpenPOWER on IntegriCloud