i2c_qmsi_ss: add device_busy_set() to avoid re-enter deep sleep

When CONFIG_SYS_POWER_DEEP_SLEEP is enabled, i2c_qmsi_ss will
keep entering deep sleep because it needs to wait until the
current transfer completes, which blocks the current thread.
The system keeps entering deep sleep again and again and the
transfer will never complete.

Add device_busy_set() to i2c_qmsi_ss driver to indicate that
the device is busy and block the system from entering deep
sleep during transaction.

Jira: ZEP-1487

Change-Id: Ia681d242349bce5a9867e54df4e65dba09005930
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
This commit is contained in:
Qiu Peiyang 2016-12-20 08:49:30 +08:00 committed by Anas Nashif
parent a67a54ff4f
commit e4ad31a231

View file

@ -319,6 +319,8 @@ static int i2c_qmsi_ss_transfer(struct device *dev, struct i2c_msg *msgs,
return -ENOTSUP;
}
device_busy_set(dev);
for (int i = 0; i < num_msgs; i++) {
uint8_t *buf = msgs[i].buf;
uint32_t len = msgs[i].len;
@ -342,6 +344,7 @@ static int i2c_qmsi_ss_transfer(struct device *dev, struct i2c_msg *msgs,
rc = qm_ss_i2c_master_irq_transfer(instance, &xfer, addr);
k_sem_give(&driver_data->sem);
if (rc != 0) {
device_busy_clear(dev);
return -EIO;
}
@ -349,10 +352,13 @@ static int i2c_qmsi_ss_transfer(struct device *dev, struct i2c_msg *msgs,
k_sem_take(&driver_data->device_sync_sem, K_FOREVER);
if (driver_data->transfer_status != 0) {
device_busy_clear(dev);
return -EIO;
}
}
device_busy_clear(dev);
return 0;
}