@@ -301,6 +301,30 @@ static void test_zero_cal(void *obj, void *data, QGuestAllocator *alloc)
g_assert_cmphex(i2c_get16(dev, REG_POWER), ==, 0x0000);
}
+/* Clearing the Calibration zeroes both derived registers in any mode */
+static void test_zero_cal_channels(void *obj, void *data,
+ QGuestAllocator *alloc)
+{
+ QI2CDevice *dev = (QI2CDevice *)obj;
+ static const uint8_t modes[] = { 0x5, 0x6, 0x7 };
+ size_t idx;
+
+ for (idx = 0; idx < ARRAY_SIZE(modes); idx++) {
+ i2c_set16(dev, REG_CONFIG, CONFIG_RST);
+ i2c_set16(dev, REG_CALIBRATION, 0x0A00);
+ qmp_ina230_set("shunt-voltage", 20000000);
+ qmp_ina230_set("bus-voltage", 11980000);
+ g_assert_cmphex(i2c_get16(dev, REG_CURRENT), !=, 0x0000);
+ g_assert_cmphex(i2c_get16(dev, REG_POWER), !=, 0x0000);
+
+ i2c_set16(dev, REG_CONFIG, modes[idx]);
+ i2c_set16(dev, REG_CALIBRATION, 0x0000);
+
+ g_assert_cmphex(i2c_get16(dev, REG_CURRENT), ==, 0x0000);
+ g_assert_cmphex(i2c_get16(dev, REG_POWER), ==, 0x0000);
+ }
+}
+
/* Clamping at full scale and the OVF (math overflow) flag */
static void test_edges_overflow(void *obj, void *data, QGuestAllocator *alloc)
{
@@ -560,6 +584,7 @@ static void ina230_register_nodes(void)
NULL);
qos_add_test("power", "ina230", test_power, NULL);
qos_add_test("zero-cal", "ina230", test_zero_cal, NULL);
+ qos_add_test("zero-cal-channels", "ina230", test_zero_cal_channels, NULL);
qos_add_test("edges-overflow", "ina230", test_edges_overflow, NULL);
qos_add_test("alert-shunt-over", "ina230", test_alert_shunt_over, NULL);
qos_add_test("alert-latch", "ina230", test_alert_latch, NULL);