usb: typec: fusb302: do reset if the power was off in suspend

For power consumption saving, the power of fusb302 may be off in PM
suspend, so we must reset the tcpm port first in PM resume process
to ensure the devices can attach again.

Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Id2cde954663c2f8e01cf19f90066dd1b942a216e
This commit is contained in:
Frank Wang
2021-12-24 17:45:04 +08:00
committed by Tao Huang
parent 1799a4d1ef
commit 44f07bf4bc

View File

@@ -1802,6 +1802,17 @@ static int fusb302_pm_resume(struct device *dev)
{
struct fusb302_chip *chip = dev->driver_data;
unsigned long flags;
u8 pwr;
int ret = 0;
/*
* When the power of fusb302 is lost or i2c read failed in PM S/R
* process, we must reset the tcpm port first to ensure the devices
* can attach again.
*/
ret = fusb302_i2c_read(chip, FUSB_REG_POWER, &pwr);
if (pwr != FUSB_REG_POWER_PWR_ALL || ret < 0)
tcpm_tcpc_reset(chip->tcpm_port);
spin_lock_irqsave(&chip->irq_lock, flags);
if (chip->irq_while_suspended) {