Shoud I set PM_DEVICE_ACTION_SUSPEND on I2C0 before sys_poweroff() ?

Dear Sir :

              We are now developing on nrf52840, with ncs v2.6.1 and zephyr.

We want to put I2C0 to PM_DEVICE_ACTION_SUSPEND before sys_poweroff().

Our code is below :

const struct device *const i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c0));

int rc = pm_device_action_run(i2c_dev, PM_DEVICE_ACTION_SUSPEND);

if (rc < 0) {
   printf("Could not suspend I2C (%d)\n", rc);
   return 0;
}

sys_poweroff();

But it always return "Could not suspend I2C (-120)".

Our I2C connects to an EEPROM and all read/write operations work fine.

We had search Nordic Q&A and someone said: only UART is not handled when using sys_poweroff(), others are handled automatically.

Does it mean that it is not necessary to put I2C to PM_DEVICE_ACTION_SUSPEND, becasue sys_poweroff will turn off I2C automatically?

Just run sys_poweroff() directly is enough or not?

Device tree overlay for reference :


&i2c0 {
compatible = "nordic,nrf-twim";
status = "okay";
clock-frequency = <100000>;
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
zephyr,concat-buf-size = <64>;
zephyr,flash-buf-max-size = <64>;

};

&pinctrl {
i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
<NRF_PSEL(TWIM_SCL, 0, 27)>;
};
};

i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
<NRF_PSEL(TWIM_SCL, 0, 27)>;
low-power-enable;
};
};
};

Related