Skip to content

Commit 7fc153c

Browse files
teburdjhedberg
authored andcommitted
i2c: RAM test updates to support power management
It's important we test the power management flows when testing i2c Signed-off-by: Tom Burdick <[email protected]>
1 parent cb384cd commit 7fc153c

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

tests/drivers/i2c/i2c_ram/src/test_i2c_ram.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
*/
1414

1515
#include <zephyr/drivers/i2c.h>
16+
#include <zephyr/pm/device_runtime.h>
1617
#include <zephyr/kernel.h>
1718
#include <zephyr/ztest.h>
1819
#include <zephyr/tc_util.h>
@@ -73,6 +74,17 @@ static void i2c_ram_before(void *f)
7374
rx_cmd[1] = (addr) & 0xFF;
7475
addr += ARRAY_SIZE(tx_data) - TX_DATA_OFFSET;
7576
memset(rx_data, 0, ARRAY_SIZE(rx_data));
77+
78+
#ifdef CONFIG_PM_DEVICE_RUNTIME
79+
pm_device_runtime_get(i2c_dev);
80+
#endif
81+
}
82+
83+
static void i2c_ram_after(void *f)
84+
{
85+
#ifdef CONFIG_PM_DEVICE_RUNTIME
86+
pm_device_runtime_put(i2c_dev);
87+
#endif
7688
}
7789

7890
ZTEST(i2c_ram, test_ram_transfer)
@@ -294,4 +306,4 @@ ZTEST(i2c_ram, test_ram_rtio_isr)
294306

295307
#endif /* CONFIG_I2C_RTIO */
296308

297-
ZTEST_SUITE(i2c_ram, NULL, i2c_ram_setup, i2c_ram_before, NULL, NULL);
309+
ZTEST_SUITE(i2c_ram, NULL, i2c_ram_setup, i2c_ram_before, i2c_ram_after, NULL);

tests/drivers/i2c/i2c_ram/testcase.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,19 @@ tests:
1111
- drivers
1212
- i2c
1313
drivers.i2c.ram.rtio:
14+
filter: CONFIG_HAS_I2C_RTIO
1415
extra_configs:
1516
- CONFIG_I2C_RTIO=y
17+
drivers.i2c.ram.pm:
18+
filter: CONFIG_HAS_PM
19+
extra_configs:
20+
- CONFIG_PM=y
21+
- CONFIG_PM_DEVICE=y
22+
- CONFIG_PM_DEVICE_RUNTIME=y
23+
drivers.i2c.ram.pm.rtio:
24+
filter: CONFIG_HAS_PM and CONFIG_HAS_I2C_RTIO
25+
extra_configs:
26+
- CONFIG_PM=y
27+
- CONFIG_PM_DEVICE=y
28+
- CONFIG_PM_DEVICE_RUNTIME=y
29+
- CONFIG_I2C_RTIO=y

0 commit comments

Comments
 (0)